V-Gears 0
Free Final Fantasy VII engine.
DialogsManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreSingleton.h>
19#include "Manager.h"
20#include "UiManager.h"
21#include "UiTextArea.h"
22#include "InputManager.h"
23
24
29
34
39
44
49
54};
55
60
65
70
75};
76
82 widget(NULL),
83 window(NULL),
84 scissor(NULL),
85 text_area(NULL),
86 cursor(NULL),
88 clickable(true),
89 show_window(true),
90 show_cursor(false),
91 auto_close(false),
93 cursor_y(0),
98 closeable(true),
99 visible(true),
100 translucent(false),
101 timer(false),
102 numeric(false)
103 {}
104
109
114
119
124
129
134
138 int x = 0;
139
143 int y = 0;
144
148 int w = 0;
149
153 int h = 0;
154
158 std::vector<ScriptId> sync;
159
164
169
174
179
184
188 float cursor_y;
189
194
199
204
209
214
219
224
228 bool timer;
229
234};
235
239class DialogsManager : public Manager, public Ogre::Singleton<DialogsManager>{
240
241 public:
242
247
251 virtual ~DialogsManager();
252
256 void Initialise();
257
263 void Input(const VGears::Event& event) override;
264
268 void UpdateDebug();
269
273 void OnResize() override;
274
278 void ClearField() override;
279
283 void ClearBattle() override;
284
288 void ClearWorld() override;
289
301 void OpenDialog(const char* d_name, int x, int y, int w, int h);
302
311 void SetText(const char* d_name, const char* text);
312
321 void SetNumeric(const char* d_name, const bool numeric, const bool timer);
322
329 void UpdateTimer(const unsigned int seconds);
330
339 void SetMode(const char* d_name, const int bg, const bool closeable);
340
349 int Sync(const char* d_name);
350
358 void Hide(const char* d_name);
359
367 void SetVariable(const char* d_name, const char* name, const char* value);
368
377 void SetClickable(const char* d_name, const bool clickable);
378
386 void SetCursor(const char* d_name, const int first_row, const int last_row);
387
395 int GetCursor(const char* d_name) const;
396
402 void ScriptSetMapName(const char* text_id);
403
409 void SetMapName(std::string name);
410
416 std::string GetMapName();
417
418 private:
419
423 void UpdateField() override;
424
428 void UpdateBattle() override;
429
433 void UpdateWorld() override;
434
445 void ShowMessage(const int id, const int x, const int y, const int width, const int height);
446
452 void HideMessage(const int id);
453
460 int GetMessageId(const char* d_name) const;
461
468 bool AutoCloseCheck(const unsigned int id);
469
474
478 std::vector<MessageData*> messages_;
479
483 std::vector<MessageData*> battle_messages_;
484
489
494
499
504
508 std::string map_name_;
509
514
520 unsigned int timer_seconds_;
521};
522
MessageStyle
Styles for message boxes.
Definition: DialogsManager.h:59
@ MSL_SOLID
Regular message box, solid background.
Definition: DialogsManager.h:64
@ MSL_TRANSPARENT
Translucent message box.
Definition: DialogsManager.h:69
@ MSL_NONE
No message box.
Definition: DialogsManager.h:74
MessageState
Possible states for messages.
Definition: DialogsManager.h:28
@ MS_OPENED
The message window is open.
Definition: DialogsManager.h:48
@ MS_CLOSED
The message is now closed.
Definition: DialogsManager.h:33
@ MS_SHOW_WINDOW
The message window is shown, but there is no text.
Definition: DialogsManager.h:38
@ MS_SHOW_TEXT
The message window and text are shown.
Definition: DialogsManager.h:43
@ MS_HIDE_WINDOW
The message window has been hidden.
Definition: DialogsManager.h:53
The dialog manager.
Definition: DialogsManager.h:239
void SetMapName(std::string name)
Sets the map name from a text ID.
Definition: DialogsManager.cpp:120
std::vector< MessageData * > messages_
The list of messages for the field or the world map.
Definition: DialogsManager.h:478
std::string map_name_
Current map name.
Definition: DialogsManager.h:508
void ClearField() override
Clears all field messages.
Definition: DialogsManager.cpp:103
void UpdateBattle() override
Updates the dialogs during a battle.
Definition: DialogsManager.cpp:491
void SetVariable(const char *d_name, const char *name, const char *value)
Sets a variable in a dialog.
Definition: DialogsManager.cpp:263
void UpdateDebug()
Updates the messagemanager with debug information.
Definition: DialogsManager.cpp:99
void SetCursor(const char *d_name, const int first_row, const int last_row)
Sets a choice sursor in the dialog.
Definition: DialogsManager.cpp:281
unsigned int timer_seconds_
The number of seconds in the timer.
Definition: DialogsManager.h:520
bool down_pressed_
Indicates if the 'down' button has been pressed.
Definition: DialogsManager.h:503
int timer_window_id_
The ID of the window that contains the timer, is any.
Definition: DialogsManager.h:513
void HideMessage(const int id)
Closes and hides a message.
Definition: DialogsManager.cpp:335
void UpdateField() override
Updates the dialogs while in a field.
Definition: DialogsManager.cpp:372
bool next_repeated_
Indicates if the 'next' button is being hold.
Definition: DialogsManager.h:493
bool up_pressed_
Indicates if the 'up' button has been pressed.
Definition: DialogsManager.h:498
void SetText(const char *d_name, const char *text)
Sets the text of a dialog.
Definition: DialogsManager.cpp:147
int GetCursor(const char *d_name) const
Gets the cursor position in a dialog.
Definition: DialogsManager.cpp:299
void SetMode(const char *d_name, const int bg, const bool closeable)
Sets the window mode.
Definition: DialogsManager.cpp:210
void ClearBattle() override
Clears all battle messages.
Definition: DialogsManager.cpp:107
void UpdateWorld() override
Updates the dialogs while on the world map.
Definition: DialogsManager.cpp:493
void UpdateTimer(const unsigned int seconds)
Updates the timer.
Definition: DialogsManager.cpp:198
void Input(const VGears::Event &event) override
Processes an input event.
Definition: DialogsManager.cpp:90
void OnResize() override
Handles resizing events.
Definition: DialogsManager.cpp:101
virtual ~DialogsManager()
Destructor.
Definition: DialogsManager.cpp:46
void SetNumeric(const char *d_name, const bool numeric, const bool timer)
Sets or unsets a dialog window as numeric.
Definition: DialogsManager.cpp:172
std::string GetMapName()
Retrieves the current map name.
Definition: DialogsManager.cpp:122
void Hide(const char *d_name)
Closes and hides a dialog window.
Definition: DialogsManager.cpp:250
int Sync(const char *d_name)
Syncs the dialog and makes the script wait until it is closed.
Definition: DialogsManager.cpp:239
UiWidget * limit_area_
The limit area for message boxes.
Definition: DialogsManager.h:473
void ScriptSetMapName(const char *text_id)
Sets the map name from a text ID.
Definition: DialogsManager.cpp:115
void SetClickable(const char *d_name, const bool clickable)
Makes the dialog clickable or not.
Definition: DialogsManager.cpp:272
void ShowMessage(const int id, const int x, const int y, const int width, const int height)
Shows a message in a dialog.
Definition: DialogsManager.cpp:308
void OpenDialog(const char *d_name, int x, int y, int w, int h)
Opens a dialog.
Definition: DialogsManager.cpp:124
DialogsManager()
Constructor.
Definition: DialogsManager.cpp:35
std::vector< MessageData * > battle_messages_
The list of battle messages.
Definition: DialogsManager.h:483
bool AutoCloseCheck(const unsigned int id)
Checks if a message is set to close automatically.
Definition: DialogsManager.cpp:361
void Initialise()
Initializes the dialog manager.
Definition: DialogsManager.cpp:51
void ClearWorld() override
Clears all world map maeeages.
Definition: DialogsManager.cpp:111
int GetMessageId(const char *d_name) const
Retrieves a message Id from it's name.
Definition: DialogsManager.cpp:355
bool next_pressed_
Indicates if the 'next' button has been pressed.
Definition: DialogsManager.h:488
A base manager.
Definition: Manager.h:24
An ingame textarea.
Definition: UiTextArea.h:163
An UI widget.
Definition: UiWidget.h:28
Message data.
Definition: DialogsManager.h:80
int w
The message width, in pixels.
Definition: DialogsManager.h:148
UiWidget * widget
The widget where the message is displayed.
Definition: DialogsManager.h:108
std::vector< ScriptId > sync
Definition: DialogsManager.h:158
MessageState state
The state of the message.
Definition: DialogsManager.h:133
UiWidget * cursor
The message cursor.
Definition: DialogsManager.h:128
int cursor_row_first
First chooseable line.
Definition: DialogsManager.h:203
float cursor_percent_y
Definition: DialogsManager.h:183
float cursor_y
Y position of the cursor in the message box.
Definition: DialogsManager.h:188
bool auto_close
Indicates if the dialog must be closed automatically.
Definition: DialogsManager.h:178
bool closeable
Indicates if the window is closeable.
Definition: DialogsManager.h:213
bool visible
Indicates if the window background is visible.
Definition: DialogsManager.h:218
int cursor_row_last
Last chooseable line.
Definition: DialogsManager.h:208
bool show_cursor
Indicates if the choice selection cursor must be shown.
Definition: DialogsManager.h:173
UiWidget * scissor
Definition: DialogsManager.h:118
int x
The message window X coordinate.
Definition: DialogsManager.h:138
bool timer
Indicates if the window is for a timer.
Definition: DialogsManager.h:228
MessageData()
Definition: DialogsManager.h:81
UiTextArea * text_area
The message text area.
Definition: DialogsManager.h:123
int y
The message window Y coordinate.
Definition: DialogsManager.h:143
bool clickable
Indicates if the text is 'clickable', i.e., if it requieres a keypress to advance.
Definition: DialogsManager.h:163
bool show_window
Indicates if the dialog window is shown.
Definition: DialogsManager.h:168
int h
The message height, in pixels.
Definition: DialogsManager.h:153
bool translucent
Indicates if the window background is translucent.
Definition: DialogsManager.h:223
bool numeric
Indicates if the window background is for a number.
Definition: DialogsManager.h:233
int cursor_row_current
Currently selected choice line.
Definition: DialogsManager.h:198
int cursor_row_selected
Selected choice line.
Definition: DialogsManager.h:193
UiWidget * window
The window where the message is displayed.
Definition: DialogsManager.h:113
An input event.
Definition: Event.h:84