UIAbout::UIAbout(Context* context): UIModalOpWindow(context) { UI* tbui = GetSubsystem<UI>(); window_->SetText("About the Atomic Game Engine"); tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/about.tb.txt"); TBEditField* age_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("age_license")); assert(age_license); TBEditField* thirdparty_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("thirdparty_license")); assert(thirdparty_license); TBEditField* externaltool_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("externaltool_license")); assert(externaltool_license); TBEditField* about_text = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("about_text")); assert(about_text); ResourceCache* cache = GetSubsystem<ResourceCache>(); SharedPtr<File> file = cache->GetFile("AtomicEditor/eulas/atomic_game_engine_eula.txt"); String text; file->ReadText(text); age_license->SetText(text.CString()); file = cache->GetFile("AtomicEditor/eulas/atomic_thirdparty_eula.txt"); file->ReadText(text); thirdparty_license->SetText(text.CString()); file = cache->GetFile("AtomicEditor/eulas/atomic_external_tools_eula.txt"); file->ReadText(text); externaltool_license->SetText(text.CString()); GenerateAboutText(text); about_text->SetText(text.CString()); window_->ResizeToFitContent(); Center(); TBTabContainer* container = window_->GetWidgetByIDAndType<TBTabContainer>(TBIDC("tabcontainer")); assert(container); container->SetValue(0); }
UIEulaAgreement::UIEulaAgreement(Context* context): UIModalOpWindow(context) { UI* tbui = GetSubsystem<UI>(); window_->SetSettings(WINDOW_SETTINGS_DEFAULT & ~WINDOW_SETTINGS_CLOSE_BUTTON); window_->SetText("License Agreement"); tbui->LoadResourceFile(window_->GetContentRoot(), "ClockworkEditor/editor/ui/eulaagreement.tb.txt"); eulaCheck_ = window_->GetWidgetByIDAndType<TBCheckBox>(TBIDC("eula_check")); assert(eulaCheck_); TBEditField* age_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("age_license")); assert(age_license); TBEditField* thirdparty_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("thirdparty_license")); assert(thirdparty_license); TBEditField* externaltool_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("externaltool_license")); assert(externaltool_license); ResourceCache* cache = GetSubsystem<ResourceCache>(); SharedPtr<File> file = cache->GetFile("ClockworkEditor/eulas/clockwork_game_engine_eula.txt"); String text; file->ReadText(text); age_license->SetText(text.CString()); file = cache->GetFile("ClockworkEditor/eulas/clockwork_thirdparty_eula.txt"); file->ReadText(text); thirdparty_license->SetText(text.CString()); file = cache->GetFile("ClockworkEditor/eulas/clockwork_external_tools_eula.txt"); file->ReadText(text); externaltool_license->SetText(text.CString()); window_->ResizeToFitContent(); Center(); TBTabContainer* container = window_->GetWidgetByIDAndType<TBTabContainer>(TBIDC("tabcontainer")); assert(container); container->SetValue(0); }
bool RequestClose() { if (editor_->HasUnsavedModifications()) { TBMessageWindow *msg_win = new TBMessageWindow(this, TBIDC("unsaved_modifications_dialog")); TBMessageWindowSettings settings(TB_MSG_NONE, TBID(uint32(0))); settings.dimmer = true; settings.styling = true; String windowString = Atomic::ToString("%s has unsaved modifications.\nDo you wish to discard them and close?", GetFileNameAndExtension(editor_->GetFullPath()).CString()); msg_win->Show("Unsaved Modifications", windowString.CString(), &settings, 640, 360); msg_win->AddButtonLeft("dont_save", false); msg_win->AddButton("TBMessageWindow.cancel", false); msg_win->AddButton("save", true); return false; } else { editor_->Close(container_->GetNumPages()>1); return true; } }
bool OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_CLICK) { if (ev.target->GetID() == TBIDC("unsaved_modifications_dialog")) { if (ev.ref_id == TBIDC("dont_save")) { container_->OnEvent(ev); editor_->Close(container_->GetNumPages()>1); } else if (ev.ref_id == TBIDC("TBMessageWindow.cancel")) { editor_->SendEvent(E_EDITORRESOURCECLOSECANCELED); SetFocus(WIDGET_FOCUS_REASON_UNKNOWN); } else if (ev.ref_id == TBIDC("save")) { editor_->Save(); container_->OnEvent(ev); editor_->Close(container_->GetNumPages()>1); } return true; } else if (ev.target->GetID() == TBIDC("tabclose")) { if (RequestClose()) { container_->OnEvent(ev); } return true; } else { TBWidgetEvent nevent = ev; nevent.target = this; return container_->OnEvent(nevent); } } return false; }