UIEulaAgreement.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // BEGIN LICENSE MANAGEMENT
  5. #include "AtomicEditor.h"
  6. #include <TurboBadger/tb_window.h>
  7. #include <TurboBadger/tb_select.h>
  8. #include <TurboBadger/tb_editfield.h>
  9. #include <TurboBadger/tb_tab_container.h>
  10. #include <Atomic/Core/Context.h>
  11. #include <Atomic/IO/File.h>
  12. #include <Atomic/Resource/ResourceCache.h>
  13. #include <Atomic/Input/InputEvents.h>
  14. #include <Atomic/UI/UI.h>
  15. #include "Resources/AEResourceOps.h"
  16. #include "AEPreferences.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 "UIEulaAgreement.h"
  23. namespace AtomicEditor
  24. {
  25. // UIBuildSettings------------------------------------------------
  26. UIEulaAgreement::UIEulaAgreement(Context* context):
  27. UIModalOpWindow(context)
  28. {
  29. UI* tbui = GetSubsystem<UI>();
  30. window_->SetSettings(WINDOW_SETTINGS_DEFAULT & ~WINDOW_SETTINGS_CLOSE_BUTTON);
  31. window_->SetText("License Agreement");
  32. tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/eulaagreement.tb.txt");
  33. eulaCheck_ = window_->GetWidgetByIDAndType<TBCheckBox>(TBIDC("eula_check"));
  34. assert(eulaCheck_);
  35. TBEditField* age_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("age_license"));
  36. assert(age_license);
  37. TBEditField* thirdparty_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("thirdparty_license"));
  38. assert(thirdparty_license);
  39. TBEditField* externaltool_license = window_->GetWidgetByIDAndType<TBEditField>(TBIDC("externaltool_license"));
  40. assert(externaltool_license);
  41. ResourceCache* cache = GetSubsystem<ResourceCache>();
  42. SharedPtr<File> file = cache->GetFile("AtomicEditor/eulas/atomic_game_engine_eula.txt");
  43. String text;
  44. file->ReadText(text);
  45. age_license->SetText(text.CString());
  46. file = cache->GetFile("AtomicEditor/eulas/atomic_thirdparty_eula.txt");
  47. file->ReadText(text);
  48. thirdparty_license->SetText(text.CString());
  49. file = cache->GetFile("AtomicEditor/eulas/atomic_external_tools_eula.txt");
  50. file->ReadText(text);
  51. externaltool_license->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. UIEulaAgreement::~UIEulaAgreement()
  59. {
  60. }
  61. bool UIEulaAgreement::OnEvent(const TBWidgetEvent &ev)
  62. {
  63. if (ev.type == EVENT_TYPE_CLICK)
  64. {
  65. if (ev.target->GetID() == TBIDC("quit"))
  66. {
  67. SendEvent(E_EXITREQUESTED);
  68. return true;
  69. }
  70. else if (ev.target->GetID() == TBIDC("ok"))
  71. {
  72. Editor* editor = GetSubsystem<Editor>();
  73. if (!eulaCheck_->GetValue())
  74. {
  75. editor->PostModalInfo("License Agreement", "Please agree to licensing terms and conditions to continue");
  76. return true;
  77. }
  78. SharedPtr<UIEulaAgreement> keepAlive(this);
  79. GetSubsystem<UIModalOps>()->Hide();
  80. LicenseSystem* licenseSystem = GetSubsystem<LicenseSystem>();
  81. licenseSystem->LicenseAgreementConfirmed();
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. }
  88. // END LICENSE MANAGEMENT