DialogsManager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. std::vector< ScriptId > sync;
  48. bool clickable;
  49. bool show_window;
  50. bool show_cursor;
  51. bool auto_close;
  52. float cursor_percent_y;
  53. float cursor_y;
  54. int cursor_row_selected;
  55. int cursor_row_current;
  56. int cursor_row_first;
  57. int cursor_row_last;
  58. };
  59. class DialogsManager : public Ogre::Singleton< DialogsManager >
  60. {
  61. public:
  62. DialogsManager();
  63. virtual ~DialogsManager();
  64. void Initialise();
  65. void Input( const QGears::Event& event );
  66. void Update();
  67. void Clear();
  68. void ShowDialog( const char* d_name, const char* name, const int x, const int y );
  69. void ShowText( const char* d_name, const char* text, const int x, const int y, const int width, const int height );
  70. int Sync( const char* d_name );
  71. void SetVariable( const char* d_name, const char* name, const char* value );
  72. void Hide( const char* d_name );
  73. void SetClickable( const char* d_name, const bool clickable );
  74. void SetCursor( const char* d_name, const int first_row, const int last_row );
  75. int GetCursor( const char* d_name ) const;
  76. private:
  77. void ShowMessage( const int id, const int x, const int y, const int width, const int height );
  78. void HideMessage( const int id );
  79. int GetMessageId( const char* d_name ) const;
  80. bool AutoCloseCheck( const unsigned int id );
  81. private:
  82. UiWidget* m_LimitArea;
  83. std::vector< MessageData* > m_Messages;
  84. bool m_NextPressed;
  85. bool m_NextRepeated;
  86. bool m_UpPressed;
  87. bool m_DownPressed;
  88. };
  89. #endif // DIALOGS_MANAGER_H