UIMessageModal.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <Atomic/Core/Context.h>
  6. #include "AEEvents.h"
  7. #include "UI/UIMainFrame.h"
  8. #include "UI/Modal/UIMessageModal.h"
  9. #include <TurboBadger/tb_message_window.h>
  10. namespace AtomicEditor
  11. {
  12. /// Construct.
  13. MessageModal::MessageModal(Context* context) :
  14. Object(context)
  15. {
  16. SubscribeToEvent(E_EDITORMODAL, HANDLER(MessageModal, HandleEditorModal));
  17. }
  18. /// Destruct.
  19. MessageModal::~MessageModal()
  20. {
  21. }
  22. void MessageModal::ShowErrorWindow(const String& title, const String& message)
  23. {
  24. MainFrame* mainframe = GetSubsystem<MainFrame>();
  25. TBMessageWindow *msg_win = new TBMessageWindow(mainframe->GetWidgetDelegate(), TBIDC("modal_error"));
  26. TBMessageWindowSettings settings(TB_MSG_OK, TBID(uint32(0)));
  27. settings.dimmer = true;
  28. settings.styling = true;
  29. msg_win->Show(title.CString(), message.CString(), &settings, 640, 360);
  30. }
  31. void MessageModal::ShowInfoWindow(const String& title, const String& message)
  32. {
  33. MainFrame* mainframe = GetSubsystem<MainFrame>();
  34. TBMessageWindow *msg_win = new TBMessageWindow(mainframe->GetWidgetDelegate(), TBIDC("modal_info"));
  35. TBMessageWindowSettings settings(TB_MSG_OK, TBID(uint32(0)));
  36. settings.dimmer = true;
  37. settings.styling = true;
  38. msg_win->Show(title.CString(), message.CString(), &settings, 640, 360);
  39. }
  40. void MessageModal::HandleEditorModal(StringHash eventType, VariantMap& eventData)
  41. {
  42. using namespace EditorModal;
  43. const String& title = eventData[P_TITLE].GetString();
  44. const String& message = eventData[P_MESSAGE].GetString();
  45. if (eventData[P_TYPE].GetUInt() == EDITOR_MODALERROR)
  46. ShowErrorWindow(title, message);
  47. if (eventData[P_TYPE].GetUInt() == EDITOR_MODALINFO)
  48. ShowInfoWindow(title, message);
  49. }
  50. }