UIAbout.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include "AtomicEditor.h"
  5. #include <TurboBadger/tb_window.h>
  6. #include <TurboBadger/tb_select.h>
  7. #include <TurboBadger/tb_editfield.h>
  8. #include <TurboBadger/tb_tab_container.h>
  9. #include <Atomic/Core/Context.h>
  10. #include <Atomic/IO/File.h>
  11. #include <Atomic/Resource/ResourceCache.h>
  12. #include <Atomic/Input/InputEvents.h>
  13. #include <Atomic/UI/UI.h>
  14. #include "Resources/AEResourceOps.h"
  15. #include "AEPreferences.h"
  16. #include "AEVersion.h"
  17. #include "AEEditor.h"
  18. #include "AEEvents.h"
  19. #include "Project/AEProject.h"
  20. #include "Project/ProjectUtils.h"
  21. #include "License/AELicenseSystem.h"
  22. #include "UIAbout.h"
  23. namespace AtomicEditor
  24. {
  25. UIAbout::UIAbout(Context* context):
  26. UIModalOpWindow(context)
  27. {
  28. UI* tbui = GetSubsystem<UI>();
  29. window_->SetText("About the Atomic Game Engine");
  30. tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/about.tb.txt");
  31. TBEditField* age_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("age_license"));
  32. assert(age_license);
  33. TBEditField* thirdparty_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("thirdparty_license"));
  34. assert(thirdparty_license);
  35. TBEditField* externaltool_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("externaltool_license"));
  36. assert(externaltool_license);
  37. TBEditField* about_text = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("about_text"));
  38. assert(about_text);
  39. ResourceCache* cache = GetSubsystem<ResourceCache>();
  40. SharedPtr<File> file = cache->GetFile("AtomicEditor/eulas/atomic_game_engine_eula.txt");
  41. String text;
  42. file->ReadText(text);
  43. age_license->SetText(text.CString());
  44. file = cache->GetFile("AtomicEditor/eulas/atomic_thirdparty_eula.txt");
  45. file->ReadText(text);
  46. thirdparty_license->SetText(text.CString());
  47. file = cache->GetFile("AtomicEditor/eulas/atomic_external_tools_eula.txt");
  48. file->ReadText(text);
  49. externaltool_license->SetText(text.CString());
  50. GenerateAboutText(text);
  51. about_text->SetText(text.CString());
  52. window_->ResizeToFitContent();
  53. Center();
  54. TBTabContainer* container = window_->GetWidgetByIDAndType<TBTabContainer>(TBIDC("tabcontainer"));
  55. assert(container);
  56. container->SetValue(0);
  57. }
  58. UIAbout::~UIAbout()
  59. {
  60. }
  61. void UIAbout::GenerateAboutText(String& text)
  62. {
  63. LicenseSystem* licenseSystem = GetSubsystem<LicenseSystem>();
  64. text.Clear();
  65. text += "<widget TBImageWidget: filename: 'AtomicEditor/editor/images/atomic_logo.png'>\n\n";
  66. text.AppendWithFormat("<color #D4FB79>Version %i.%i.p%i</color>\n\n", ATOMIC_EDITOR_VERSION_MAJOR, ATOMIC_EDITOR_VERSION_MINOR, ATOMIC_EDITOR_VERSION_PATCH);
  67. text += "(c) 2014-2015 THUNDERBEAST GAMES LLC\n\n\n";
  68. text += "<color #D4FB79>Installed platforms and modules:</color>\n\n";
  69. if (licenseSystem->IsStandardLicense())
  70. {
  71. text += " <widget TBSkinImage: skin: 'LogoMac-Small'> <widget TBSkinImage: skin: 'LogoWindows-Small'> <widget TBSkinImage: skin: 'Module2D-Small'>\n\n\n";
  72. text += "<color #76D6FF>Available platforms and modules:</color>\n\n" \
  73. " <widget TBSkinImage: skin: 'LogoHTML5-Small'> <widget TBSkinImage: skin: 'LogoAndroid-Small'> " \
  74. "<widget TBSkinImage: skin: 'LogoIOS-Small'> <widget TBSkinImage: skin: 'Module3D-Small'> "\
  75. "<widget TBButton: text: 'Get Pro' skin: 'TBButton.greentext' id: 'purchase_pro' >\n\n\n";
  76. }
  77. else
  78. {
  79. text += " <widget TBSkinImage: skin: 'LogoMac-Small'> <widget TBSkinImage: skin: 'LogoWindows-Small'> " \
  80. "<widget TBSkinImage: skin: 'LogoHTML5-Small'> <widget TBSkinImage: skin: 'LogoAndroid-Small'> " \
  81. "<widget TBSkinImage: skin: 'LogoIOS-Small'> <widget TBSkinImage: skin: 'Module2D-Small'> <widget TBSkinImage: skin: 'Module3D-Small'>\n\n";
  82. }
  83. text += "<color #76D6FF>Special Thanks:</color>\n\n";
  84. text += " The Urho3D Project - http://urho3d.github.io\n\n";
  85. text += " Sami Vaarala - http://www.duktape.org";
  86. }
  87. bool UIAbout::OnEvent(const TBWidgetEvent &ev)
  88. {
  89. if (ev.type == EVENT_TYPE_CLICK)
  90. {
  91. if (ev.target->GetID() == TBIDC("purchase_pro"))
  92. {
  93. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  94. fileSystem->SystemOpen("https://store.atomicgameengine.com/site");
  95. }
  96. else if (ev.target->GetID() == TBIDC("ok"))
  97. {
  98. GetSubsystem<UIModalOps>()->Hide();
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. }