| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799 |
- // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
- // Please see LICENSE.md in repository root for license information
- // https://github.com/AtomicGameEngine/AtomicGameEngine
- #include "AtomicEditor.h"
- #include <TurboBadger/tb_message_window.h>
- #include <TurboBadger/tb_editfield.h>
- #include <Atomic/Core/ProcessUtils.h>
- #include <Atomic/UI/TBUI.h>
- #include <Atomic/IO/Log.h>
- #include <Atomic/Core/Context.h>
- #include <Atomic/Graphics/Graphics.h>
- #include <Atomic/Graphics/GraphicsEvents.h>
- #include <Atomic/Resource/ResourceCache.h>
- #include <Atomic/IO/File.h>
- #include <Atomic/IO/FileSystem.h>
- #include "UIMainFrame.h"
- #include "UIMainToolbar.h"
- #include "UIProjectFrame.h"
- #include "UIHierarchyFrame.h"
- #include "UIInspectorFrame.h"
- #include "UIPlayerWidget.h"
- #include "UIResourceFrame.h"
- #include "UIWelcomeFrame.h"
- #include "UI/Modal/UIModalOps.h"
- #include "UI/Modal/UIMessageModal.h"
- #include "License/AEVersionCheck.h"
- #include "UIFindTextWidget.h"
- #include "AEEvents.h"
- #include "AEEditor.h"
- #include "AEEditorStrings.h"
- #include "AEEditorShortcuts.h"
- #include "AEPreferences.h"
- #include "AEJavascript.h"
- #include "Player/AEPlayer.h"
- #include "Project/AEProject.h"
- #include "Project/ProjectUtils.h"
- #include "Editors/ResourceEditor.h"
- #include "Tools/External/AEExternalTooling.h"
- using namespace tb;
- namespace AtomicEditor
- {
- MainFrame::MainFrame(Context* context) :
- AEWidget(context),
- consoletext_(0),
- resourceviewcontainer_(0),
- platformIndicator_(0)
- {
- context->RegisterSubsystem(this);
- InitializeMenuSources();
- TBUI* tbui = GetSubsystem<TBUI>();
- tbui->LoadResourceFile(delegate_, "AtomicEditor/editor/ui/mainframe.tb.txt");
- Graphics* graphics = GetSubsystem<Graphics>();
- delegate_->SetSize(graphics->GetWidth(), graphics->GetHeight());
- tbui->GetRootWidget()->AddChild(delegate_);
- maintoolbar_ = new MainToolbar(context_);
- TBLayout* maintoolbarcontainer = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("maintoolbarcontainer"));
- assert(maintoolbarcontainer);
- TBWidget* wd = maintoolbar_->GetWidgetDelegate();
- TBRect rect = maintoolbarcontainer->GetRect();
- wd->SetSize(rect.w, rect.h);
- maintoolbarcontainer->AddChild(wd);
- projectframe_ = new ProjectFrame(context_);
- TBLayout* projectviewcontainer = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("projectviewcontainer"));
- assert(projectviewcontainer);
- // better way to do this? projectviewcontainer isn't a layout
- wd = projectframe_->GetWidgetDelegate();
- rect = projectviewcontainer->GetRect();
- wd->SetSize(rect.w, rect.h);
- projectviewcontainer->AddChild(wd);
- hierarchyframe_ = new HierarchyFrame(context_);
- TBLayout* hierarchycontainer = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("hierarchycontainer"));
- assert(hierarchycontainer);
- // better way to do this? projectviewcontainer isn't a layout
- wd = hierarchyframe_->GetWidgetDelegate();
- rect = hierarchycontainer->GetRect();
- wd->SetSize(rect.w, rect.h);
- hierarchycontainer->AddChild(wd);
- inspectorlayout_ = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("inspectorlayout"));
- assert(inspectorlayout_);
- inspectorframe_ = new InspectorFrame(context_);
- TBLayout* inspectorcontainer = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("inspectorcontainer"));
- assert(inspectorcontainer);
- // better way to do this? inspectorcontainer isn't a layout
- wd = inspectorframe_->GetWidgetDelegate();
- rect = inspectorcontainer->GetRect();
- wd->SetSize(rect.w, rect.h);
- inspectorcontainer->AddChild(wd);
- resourceviewcontainer_ = delegate_->GetWidgetByIDAndType<TBLayout>(TBIDC("resourceviewcontainer"));
- assert(resourceviewcontainer_);
- rect = resourceviewcontainer_->GetRect();
- // player widget
- playerwidget_ = new PlayerWidget(context_);
- wd = playerwidget_->GetWidgetDelegate();
- wd->SetSize(rect.w, rect.h);
- // welcome frame
- welcomeframe_ = new WelcomeFrame(context_);
- wd = welcomeframe_->GetWidgetDelegate();
- wd->SetSize(rect.w, rect.h);
- resourceframe_ = new ResourceFrame(context_);
- // better way to do this? projectviewcontainer isn't a layout
- wd = resourceframe_->GetWidgetDelegate();
- wd->SetSize(rect.w, rect.h);
- platformIndicator_ = delegate_->GetWidgetByIDAndType<TBSkinImage>(TBIDC("current_platform_indicator"));
- assert(platformIndicator_);
- consoletext_ = delegate_->GetWidgetByIDAndType<TBEditField>(TBIDC("consoletext"));
- consoletext_->SetText("Atomic Editor Initialized");
- TBContainer* consolecontainer = delegate_->GetWidgetByIDAndType<TBContainer>(TBIDC("consolecontainer"));
- assert(consolecontainer);
- consolecontainer->SetVisibilility(WIDGET_VISIBILITY_INVISIBLE);
- consolecontainer->GetParent()->RemoveChild(consolecontainer);
- findtextwidget_ = new FindTextWidget(context_);
- UpdateFindTextWidget();
- SubscribeToEvent(E_SCREENMODE, HANDLER(MainFrame, HandleScreenMode));
- SubscribeToEvent(E_JAVASCRIPTSAVED, HANDLER(MainFrame, HandleJavascriptSaved));
- SubscribeToEvent(E_PLATFORMCHANGE, HANDLER(MainFrame, HandlePlatformChange));
- SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(MainFrame, HandleEditorShutdown));
- SubscribeToEvent(E_EDITORRESOURCEEDITORCHANGED, HANDLER(MainFrame, HandleResourceEditorChanged));
- messageModal_ = new MessageModal(context_);
- uiModalOps_ = new UIModalOps(context_);
- ShowInspectorFrame(false);
- // show welcome frame to start
- ShowWelcomeFrame();
- }
- MainFrame::~MainFrame()
- {
- }
- void MainFrame::InitializeMenuSources()
- {
- // Instead of TBGenericStringItem here, we need custom item so can have shortcuts be right aligned
- menuAtomicEditorSource.AddItem(new MenubarItem("About Atomic Editor", TBIDC("about atomic editor")));
- menuAtomicEditorSource.AddItem(new MenubarItem("-"));
- menuAtomicEditorSource.AddItem(new MenubarItem("Manage License", TBIDC("manage license")));
- menuAtomicEditorSource.AddItem(new MenubarItem("-"));
- menuAtomicEditorSource.AddItem(new MenubarItem("Check for Updates", TBIDC("check update")));
- menuAtomicEditorSource.AddItem(new MenubarItem("-"));
- menuAtomicEditorSource.AddItem(new MenubarItem("Quit", TBIDC("quit")));
- menuFileSource.AddItem(new MenubarItem("New Project", TBIDC("new project")));
- menuFileSource.AddItem(new MenubarItem("Open Project", TBIDC("open project")));
- menuFileSource.AddItem(new MenubarItem("Save Project", TBIDC("save project")));
- menuFileSource.AddItem(new MenubarItem("-"));
- menuFileSource.AddItem(new MenubarItem("Close Project", TBIDC("close project")));
- menuFileSource.AddItem(new MenubarItem("-"));
- menuFileSource.AddItem(new MenubarItem("Save File", TBIDC("save file"), EDITOR_STRING(ShortcutSaveFile)));
- menuFileSource.AddItem(new MenubarItem("Close File", TBIDC("close file"), EDITOR_STRING(ShortcutCloseFile)));
- menuBuildSource.AddItem(new MenubarItem("Build", TBIDC("project_build"), EDITOR_STRING(ShortcutBuild)));
- menuBuildSource.AddItem(new MenubarItem("-"));
- menuBuildSource.AddItem(new MenubarItem("Build Settings", TBIDC("project_build_settings"), EDITOR_STRING(ShortcutBuildSettings)));
- menuToolsSource.AddItem(new MenubarItem("Tiled Map Editor", TBIDC("tools tiled")));
- menuEditSource.AddItem(new MenubarItem("Undo", TBIDC("edit undo"), EDITOR_STRING(ShortcutUndo)));
- menuEditSource.AddItem(new MenubarItem("Redo", TBIDC("edit redo"), EDITOR_STRING(ShortcutRedo)));
- menuEditSource.AddItem(new MenubarItem("-"));
- menuEditSource.AddItem(new MenubarItem("Cut", TBIDC("edit cut"), EDITOR_STRING(ShortcutCut)));
- menuEditSource.AddItem(new MenubarItem("Copy", TBIDC("edit copy"), EDITOR_STRING(ShortcutCopy)));
- menuEditSource.AddItem(new MenubarItem("Paste", TBIDC("edit paste"), EDITOR_STRING(ShortcutPaste)));
- menuEditSource.AddItem(new MenubarItem("Select All", TBIDC("edit select all"), EDITOR_STRING(ShortcutSelectAll)));
- menuEditSource.AddItem(new MenubarItem("-"));
- menuEditSource.AddItem(new MenubarItem("Find", TBIDC("edit find"), EDITOR_STRING(ShortcutFind)));
- menuEditSource.AddItem(new MenubarItem("Find Next", TBIDC("edit find next"), EDITOR_STRING(ShortcutFindNext)));
- menuEditSource.AddItem(new MenubarItem("Find Prev", TBIDC("edit find prev"), EDITOR_STRING(ShortcutFindPrev)));
- menuEditSource.AddItem(new MenubarItem("-"));
- menuEditSource.AddItem(new MenubarItem("Format Code", TBIDC("edit format code"), EDITOR_STRING(ShortcutBeautify)));
- menuEditSource.AddItem(new MenubarItem("-"));
- menuEditSource.AddItem(new MenubarItem("Play", TBIDC("edit play"), EDITOR_STRING(ShortcutPlay)));
- menuHelpSource.AddItem(new MenubarItem("API Documentation", TBIDC("help_api")));
- menuHelpSource.AddItem(new MenubarItem("-"));
- menuHelpSource.AddItem(new MenubarItem("Forums", TBIDC("help_forums")));
- menuHelpSource.AddItem(new MenubarItem("-"));
- menuHelpSource.AddItem(new MenubarItem("Atomic Game Engine on GitHub", TBIDC("help_github")));
- menuDeveloperSource.AddItem(new MenubarItem("Set 1920x1080 Resolution", TBIDC("developer_resolution")));
- }
- ProjectFrame* MainFrame::GetProjectFrame()
- {
- return projectframe_;
- }
- ResourceFrame* MainFrame::GetResourceFrame()
- {
- return resourceframe_;
- }
- FindTextWidget* MainFrame::GetFindTextWidget()
- {
- return findtextwidget_;
- }
- MainToolbar* MainFrame::GetMainToolbar()
- {
- return maintoolbar_;
- }
- PlayerWidget* MainFrame::GetPlayerWidget()
- {
- return playerwidget_;
- }
- MessageModal* MainFrame::GetMessageModal()
- {
- return messageModal_;
- }
- UIModalOps* MainFrame::GetUIModalOps()
- {
- return uiModalOps_;
- }
- InspectorFrame* MainFrame::GetInspectorFrame()
- {
- return inspectorframe_;
- }
- void MainFrame::ShowInspectorFrame(bool show)
- {
- if (!show)
- inspectorlayout_->SetVisibilility(WIDGET_VISIBILITY_GONE);
- else
- inspectorlayout_->SetVisibilility(WIDGET_VISIBILITY_VISIBLE);
- }
- bool MainFrame::InspectorFrameVisible()
- {
- return inspectorlayout_->GetVisibility() == WIDGET_VISIBILITY_VISIBLE;
- }
- void MainFrame::HandleJavascriptSaved(StringHash eventType, VariantMap& eventData)
- {
- UpdateJavascriptErrors();
- }
- bool MainFrame::UpdateJavascriptErrors()
- {
- // parse errors
- bool hasErrors = false;
- AEJavascript* aejs = GetSubsystem<AEJavascript>();
- aejs->CheckJSErrors();
- const Vector<JSError>& errors = aejs->GetJSErrors();
- if (errors.Size())
- {
- hasErrors = true;
- resourceframe_->ShowIssuesWidget();
- }
- else
- {
- resourceframe_->ShowIssuesWidget(false);
- }
- AEPlayer* player = GetSubsystem<AEPlayer>();
- if (player)
- {
- const Vector<AEPlayerError>& playererrors = player->GetErrors();
- if (playererrors.Size())
- {
- hasErrors = true;
- resourceframe_->ShowErrorsWidget();
- }
- else
- resourceframe_->ShowErrorsWidget(false);
- }
- return hasErrors;
- }
- bool MainFrame::ResourceFrameVisible()
- {
- TBWidget *child;
- for (child = resourceviewcontainer_->GetFirstChild(); child; child = child->GetNext())
- {
- if (child == resourceframe_->GetWidgetDelegate())
- break;
- }
- return child != NULL;
- }
- bool MainFrame::WelcomeFrameVisible()
- {
- TBWidget *child;
- for (child = resourceviewcontainer_->GetFirstChild(); child; child = child->GetNext())
- {
- if (child == welcomeframe_->GetWidgetDelegate())
- break;
- }
- return child != NULL;
- }
- void MainFrame::ShowResourceFrame(bool show)
- {
- if (show && ResourceFrameVisible())
- return;
- if (show && WelcomeFrameVisible())
- ShowWelcomeFrame(false);
- TBWidget *child;
- for (child = resourceviewcontainer_->GetFirstChild(); child; child = child->GetNext())
- {
- if (child == resourceframe_->GetWidgetDelegate())
- break;
- }
- if (show)
- {
- if (!child)
- {
- resourceviewcontainer_->AddChild(resourceframe_->GetWidgetDelegate());
- }
- }
- else
- {
- if (child)
- resourceviewcontainer_->RemoveChild(child);
- }
- }
- void MainFrame::ShowWelcomeFrame(bool show)
- {
- if (show && WelcomeFrameVisible())
- return;
- if (show && ResourceFrameVisible())
- ShowResourceFrame(false);
- TBWidget *child;
- for (child = resourceviewcontainer_->GetFirstChild(); child; child = child->GetNext())
- {
- if (child == welcomeframe_->GetWidgetDelegate())
- break;
- }
- if (show)
- {
- ShowInspectorFrame(false);
- welcomeframe_->UpdateRecentProjects();
- if (!child)
- {
- resourceviewcontainer_->AddChild(welcomeframe_->GetWidgetDelegate());
- }
- }
- else
- {
- if (child)
- resourceviewcontainer_->RemoveChild(child);
- }
- }
- bool MainFrame::IsProjectLoaded()
- {
- Editor* editor = GetSubsystem<Editor>();
- Project* project = editor->GetProject();
- if (!project)
- return false;
- return true;
- }
- bool MainFrame::HandleMenubarEvent(const TBWidgetEvent &ev)
- {
- if (ev.type == EVENT_TYPE_CLICK)
- {
- if (ev.target->GetID() == TBIDC("menu atomic editor"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("atomic editor popup")))
- {
- menu->Show(&menuAtomicEditorSource, TBPopupAlignment());
- }
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu edit"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("edit popup")))
- menu->Show(&menuEditSource, TBPopupAlignment());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu file"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("file popup")))
- menu->Show(&menuFileSource, TBPopupAlignment());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu build"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("build popup")))
- menu->Show(&menuBuildSource, TBPopupAlignment());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu tools"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("tools popup")))
- menu->Show(&menuToolsSource, TBPopupAlignment());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu issues"))
- {
- resourceframe_->ShowIssuesWidget(!resourceframe_->IssuesWidgetVisible());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu console"))
- {
- resourceframe_->ShowConsoleWidget(!resourceframe_->ConsoleWidgetVisible());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu errors"))
- {
- resourceframe_->ShowErrorsWidget(!resourceframe_->ErrorsWidgetVisible());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu help"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("help popup")))
- menu->Show(&menuHelpSource, TBPopupAlignment());
- return true;
- }
- else if (ev.target->GetID() == TBIDC("menu developer"))
- {
- if (TBMenuWindow *menu = new TBMenuWindow(ev.target, TBIDC("developer popup")))
- menu->Show(&menuDeveloperSource, TBPopupAlignment());
- return true;
- }
- }
- return false;
- }
- bool MainFrame::HandlePopupMenuEvent(const TBWidgetEvent &ev)
- {
- EditorShortcuts* shortcuts = GetSubsystem<EditorShortcuts>();
- if (ev.type == EVENT_TYPE_CLICK)
- {
- Editor* editor = GetSubsystem<Editor>();
- if (ev.target->GetID() == TBIDC("file popup"))
- {
- if (ev.ref_id == TBIDC("new project"))
- {
- if (editor->IsProjectLoaded())
- {
- editor->PostModalError("Close Project", "Please close the current project before creating a new one");
- }
- else
- {
- uiModalOps_->ShowNewProject();
- }
- }
- else if (ev.ref_id == TBIDC("open project"))
- {
- if (editor->IsProjectLoaded())
- {
- editor->PostModalError("Close Project", "Please close the current project before opening a new one");
- return true;
- }
- else
- {
- GetSubsystem<ProjectUtils>()->OpenProjectFileDialog();
- return true;
- }
- }
- else if (ev.ref_id == TBIDC("close project"))
- {
- //TODO: Confirmation
- editor->CloseProject();
- }
- else if (ev.ref_id == TBIDC("close file"))
- {
- shortcuts->InvokeFileClose();
- }
- else if (ev.ref_id == TBIDC("save file"))
- {
- shortcuts->InvokeFileSave();
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("atomic editor popup"))
- {
- if (ev.ref_id == TBIDC("about atomic editor"))
- {
- uiModalOps_->ShowAbout();
- return true;
- }
- else if (ev.ref_id == TBIDC("manage license"))
- {
- uiModalOps_->ShowManageLicense();
- return true;
- }
- else if (ev.ref_id == TBIDC("check update"))
- {
- GetSubsystem<VersionCheck>()->DoVersionCheck();
- return true;
- }
- else if (ev.ref_id == TBIDC("quit"))
- {
- // TODO: confirmation
- // shenanigens, need to delete the popup on quit
- // otherwise it is still live with a source at exit
- ev.target->GetParent()->RemoveChild(ev.target);
- delete ev.target;
- TBWidgetEvent* eptr = (TBWidgetEvent*) &ev;
- eptr->target = NULL;
- editor->RequestExit();
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("build popup"))
- {
- if (ev.ref_id == TBIDC("project_build_settings"))
- {
- shortcuts->InvokeBuildSettings();
- }
- else if (ev.ref_id == TBIDC("project_build"))
- {
- shortcuts->InvokeBuild();
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("edit popup"))
- {
- if (ev.ref_id == TBIDC("edit cut"))
- {
- shortcuts->InvokeEditCut();
- }
- else if (ev.ref_id == TBIDC("edit copy"))
- {
- shortcuts->InvokeEditCopy();
- }
- else if (ev.ref_id == TBIDC("edit paste"))
- {
- shortcuts->InvokeEditPaste();
- }
- else if (ev.ref_id == TBIDC("edit select all"))
- {
- shortcuts->InvokeEditSelectAll();
- }
- else if (ev.ref_id == TBIDC("edit undo"))
- {
- shortcuts->InvokeEditUndo();
- }
- else if (ev.ref_id == TBIDC("edit redo"))
- {
- shortcuts->InvokeEditRedo();
- }
- else if (ev.ref_id == TBIDC("edit find"))
- {
- shortcuts->InvokeEditFind();
- }
- else if (ev.ref_id == TBIDC("edit find next"))
- {
- shortcuts->InvokeEditFindNext();
- }
- else if (ev.ref_id == TBIDC("edit find prev"))
- {
- shortcuts->InvokeEditFindPrev();
- }
- else if (ev.ref_id == TBIDC("edit format code"))
- {
- shortcuts->InvokeEditFormatCode();
- }
- else if (ev.ref_id == TBIDC("edit play"))
- {
- shortcuts->InvokePlayStop();
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("tools popup"))
- {
- if (ev.ref_id == TBIDC("tools tiled"))
- {
- ExternalTooling* tooling = GetSubsystem<ExternalTooling>();
- tooling->LaunchOrOpen("AtomicTiled", "");
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("help popup"))
- {
- FileSystem* fileSystem = GetSubsystem<FileSystem>();
- if (ev.ref_id == TBIDC("help_forums"))
- {
- fileSystem->SystemOpen("http://www.atomicgameengine.com/forum");
- }
- if (ev.ref_id == TBIDC("help_github"))
- {
- fileSystem->SystemOpen("https://github.com/AtomicGameEngine/AtomicGameEngine");
- }
- else if (ev.ref_id == TBIDC("help_api"))
- {
- #ifdef ATOMIC_PLATFORM_OSX
- String docSourceDir = fileSystem->GetAppBundleResourceFolder();
- #else
- String docSourceDir = fileSystem->GetProgramDir();
- #endif
- docSourceDir += "Docs/index.html";
- fileSystem->SystemOpen("file://" + docSourceDir);
- }
- return true;
- }
- if (ev.target->GetID() == TBIDC("developer popup"))
- {
- if (ev.ref_id == TBIDC("developer_resolution"))
- {
- Graphics* graphics = GetSubsystem<Graphics>();
- graphics->SetWindowSize(1920, 1080);
- graphics->CenterWindow();
- }
- return true;
- }
- }
- return false;
- }
- bool MainFrame::OnEvent(const TBWidgetEvent &ev)
- {
- if (HandleMenubarEvent(ev))
- return true;
- if (HandlePopupMenuEvent(ev))
- return true;
- if (ev.type == EVENT_TYPE_CLICK)
- {
- if (ev.target->GetID() == TBIDC("unsaved_modifications_dialog"))
- {
- resourceframe_->FocusCurrentTab();
- return true;
- }
- }
- return false;
- }
- void MainFrame::UpdateFindTextWidget()
- {
- TBRect rect = delegate_->GetRect();
- findtextwidget_->SetUISize(rect.w, rect.h);
- }
- void MainFrame::HandleScreenMode(StringHash eventType, VariantMap& eventData)
- {
- using namespace ScreenMode;
- int width = eventData[P_WIDTH].GetInt();
- int height = eventData[P_HEIGHT].GetInt();
- delegate_->SetSize(width, height);
- UpdateFindTextWidget();
- }
- void MainFrame::RevealInFinder()
- {
- Editor* editor = context_->GetSubsystem<Editor>();
- Project* project = editor->GetProject();
- if (!project)
- return;
- String resourcePath = projectframe_->GetCurrentContentFolder();
- if (!resourcePath.Length())
- resourcePath = project->GetResourcePath();
- ProjectUtils* utils = context_->GetSubsystem<ProjectUtils>();
- utils->RevealInFinder(resourcePath);
- }
- void MainFrame::HandleResourceEditorChanged(StringHash eventType, VariantMap& eventData)
- {
- ResourceEditor* editor = static_cast<ResourceEditor*>(eventData[EditorResourceEditorChanged::P_RESOURCEEDITOR].GetPtr());
- if (!editor || !editor->RequiresInspector())
- {
- ShowInspectorFrame(false);
- maintoolbar_->Show3DWidgets(false);
- }
- else
- {
- ShowInspectorFrame(true);
- maintoolbar_->Show3DWidgets(true);
- }
- }
- void MainFrame::HandlePlatformChange(StringHash eventType, VariantMap& eventData)
- {
- using namespace PlatformChange;
- AEEditorPlatform platform = (AEEditorPlatform) eventData[P_PLATFORM].GetUInt();
- if (platform == AE_PLATFORM_MAC)
- platformIndicator_->SetSkinBg(TBIDC("LogoMac"));
- else if (platform == AE_PLATFORM_WINDOWS)
- platformIndicator_->SetSkinBg(TBIDC("LogoWindows"));
- else if (platform == AE_PLATFORM_ANDROID)
- platformIndicator_->SetSkinBg(TBIDC("LogoAndroid"));
- else if (platform == AE_PLATFORM_HTML5)
- platformIndicator_->SetSkinBg(TBIDC("LogoHTML5"));
- else if (platform == AE_PLATFORM_IOS)
- platformIndicator_->SetSkinBg(TBIDC("LogoIOS"));
- }
- void MainFrame::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
- {
- messageModal_= 0;
- context_->RemoveSubsystem(GetType());
- }
- }
|