DialogsManager.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef DIALOGS_MANAGER_h
  2. #define DIALOGS_MANAGER_h
  3. #include <OgreSingleton.h>
  4. #include "UiManager.h"
  5. #include "UiTextArea.h"
  6. enum MessageState
  7. {
  8. MS_CLOSED,
  9. MS_SHOW_WINDOW,
  10. MS_SHOW_TEXT,
  11. MS_OPENED,
  12. MS_HIDE_WINDOW
  13. };
  14. enum MessageStyle
  15. {
  16. MSL_SOLID,
  17. MSL_TRANSPARENT,
  18. MSL_NONE
  19. };
  20. struct MessageData
  21. {
  22. MessageData():
  23. widget( NULL ),
  24. window( NULL ),
  25. scissor( NULL ),
  26. text_area( NULL ),
  27. cursor( NULL ),
  28. state( MS_CLOSED ),
  29. clickable( true ),
  30. show_window( true ),
  31. show_cursor( false ),
  32. auto_close( false ),
  33. cursor_percent_y( 0 ),
  34. cursor_y( 0 ),
  35. cursor_row_selected( 0 ),
  36. cursor_row_current( 0 ),
  37. cursor_row_first( 0 ),
  38. cursor_row_last( 0 )
  39. {
  40. }
  41. UiWidget* widget;
  42. UiWidget* window;
  43. UiWidget* scissor;
  44. UiTextArea* text_area;
  45. UiWidget* cursor;
  46. MessageState state;
  47. int x = 0;
  48. int y = 0;
  49. int w = 0;
  50. int h = 0;
  51. std::vector< ScriptId > sync;
  52. bool clickable;
  53. bool show_window;
  54. bool show_cursor;
  55. bool auto_close;
  56. float cursor_percent_y;
  57. float cursor_y;
  58. int cursor_row_selected;
  59. int cursor_row_current;
  60. int cursor_row_first;
  61. int cursor_row_last;
  62. };
  63. class DialogsManager : public Ogre::Singleton< DialogsManager >
  64. {
  65. public:
  66. DialogsManager();
  67. virtual ~DialogsManager();
  68. void Initialise();
  69. void Input( const QGears::Event& event );
  70. void Update();
  71. void Clear();
  72. void OpenDialog(const char* d_name, int x, int y, int w, int h); // aka dialog_open
  73. void SetText( const char* d_name, const char* text ); // aka dialog_set_text
  74. int Sync( const char* d_name ); // aka dialog_wait_for_close
  75. void Hide(const char* d_name); // aka dialog_close
  76. void SetVariable( const char* d_name, const char* name, const char* value );
  77. void SetClickable( const char* d_name, const bool clickable );
  78. void SetCursor( const char* d_name, const int first_row, const int last_row );
  79. int GetCursor( const char* d_name ) const;
  80. private:
  81. void ShowMessage( const int id, const int x, const int y, const int width, const int height );
  82. void HideMessage( const int id );
  83. int GetMessageId( const char* d_name ) const;
  84. bool AutoCloseCheck( const unsigned int id );
  85. private:
  86. UiWidget* m_LimitArea;
  87. std::vector< MessageData* > m_Messages;
  88. bool m_NextPressed;
  89. bool m_NextRepeated;
  90. bool m_UpPressed;
  91. bool m_DownPressed;
  92. };
  93. #endif // DIALOGS_MANAGER_H