19 #ifndef INC_C4ConsoleQtState
20 #define INC_C4ConsoleQtState
28 #include "ui_C4ConsoleQtMainWindow.h"
32 class C4ConsoleQtTranslator :
public QTranslator
36 bool isEmpty()
const override {
return false; }
37 QString translate(
const char * context,
const char * sourceText,
const char * disambiguation =
nullptr,
int n = -1)
const override;
42 class C4ConsoleClientAction :
public QAction
51 int32_t GetClientID()
const {
return client_id; }
56 class C4ConsoleRemovePlayerAction :
public QAction
62 C4ConsoleRemovePlayerAction(int32_t player_num,
const char *
text, QObject *parent);
63 int32_t GetPlayerNum()
const {
return player_num; }
68 class C4ConsoleOpenViewportAction :
public QAction
74 C4ConsoleOpenViewportAction(int32_t player_num,
const char *
text, QObject *parent);
75 int32_t GetPlayerNum()
const {
return player_num; }
82 class C4DisableShortcutFilter :
public QObject
87 C4DisableShortcutFilter(QObject *parent) : QObject(parent) {}
89 bool eventFilter(QObject *target, QEvent *event)
override
91 if (event->type() == QEvent::Shortcut)
return true;
92 return QObject::eventFilter(target, event);
96 class C4ConsoleQtMainWindow :
public QMainWindow
99 class C4ConsoleGUIState *state;
102 void keyPressEvent(QKeyEvent * event)
override;
103 void keyReleaseEvent(QKeyEvent * event)
override;
106 C4ConsoleQtMainWindow(
class C4AbstractApp *app,
class C4ConsoleGUIState *state);
108 void closeEvent(
class QCloseEvent *event)
override;
110 class C4ConsoleGUIState *GetConsoleState()
const {
return state; }
114 void PlayPressed(
bool down);
115 void PausePressed(
bool down);
116 void CursorGamePressed(
bool down);
117 void CursorSelectPressed(
bool down);
118 void CursorCreateObjPressed(
bool down);
119 void CursorDrawPenPressed(
bool down);
120 void CursorDrawLinePressed(
bool down);
121 void CursorDrawRectPressed(
bool down);
122 void CursorFillPressed(
bool down);
123 void CursorPickerPressed(
bool down);
124 void DynamicLandscapePressed(
bool down);
125 void StaticLandscapePressed(
bool down);
126 void StaticFlatLandscapePressed(
bool down);
127 void ExactLandscapePressed(
bool down);
128 void DrawSizeChanged(
int newval);
129 void OpenTranslationsOverview();
133 void FileOpenInNetwork();
134 void FileOpenWithPlayers();
138 void FileSaveGameAs();
139 void FileExportPacked();
142 void FileReInitScenario();
149 void HelpToggle(
bool enabled);
151 void MainConsoleEditEnter();
152 void PropertyConsoleEditEnter();
154 void OnCreatorSelectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
155 void OnCreatorCurrentChanged(
const QModelIndex & current,
const QModelIndex & previous);
156 void OnObjectListSelectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
157 void AscendPropertyPath();
158 void AddArrayElement();
159 void RemoveArrayElement();
161 bool HandleEditorKeyDown(QKeyEvent *event);
162 bool HandleEditorKeyUp(QKeyEvent *event);
164 void ForegroundMaterialChanged(
const QString &new_selection);
165 void BackgroundMaterialChanged(
const QString &new_selection);
167 void WelcomeLinkActivated(
const QString &link);
169 void SelectionDelete();
170 void SelectionDuplicate();
171 void SelectionEjectContents();
173 void FocusGlobalScriptBox();
174 void FocusObjectScriptBox();
175 void OpenMaterialSelection();
176 void FocusNextViewport();
184 class C4ConsoleGUIState
187 std::unique_ptr<QApplication> application;
188 std::unique_ptr<C4ConsoleQtMainWindow> window;
189 std::unique_ptr<class C4ConsoleQtPropListModel> property_model;
190 std::unique_ptr<class C4PropertyDelegateFactory> property_delegate_factory;
191 std::unique_ptr<class C4PropertyNameDelegate> property_name_delegate;
192 std::unique_ptr<class C4ConsoleQtObjectListModel> object_list_model;
193 std::unique_ptr<class C4ConsoleQtDefinitionListModel> definition_list_model;
194 std::unique_ptr<class C4DisableShortcutFilter> disable_shortcut_filter;
195 std::unique_ptr<class C4ConsoleQtLocalizeOverviewDlg> translation_overview_dialogue;
196 std::list<class C4ConsoleQtViewportDockWidget *> viewports;
197 std::list<std::unique_ptr<C4ConsoleClientAction> > client_actions;
198 std::list<std::unique_ptr<C4ConsoleRemovePlayerAction> > player_actions;
199 std::list<std::unique_ptr<C4ConsoleOpenViewportAction> > viewport_actions;
203 QMainWindow *viewport_area;
204 QLabel *status_cursor, *status_framecounter, *status_timefps;
205 QAction *window_menu_separator;
210 bool enabled, recording, net_enabled;
212 bool flat_chunk_shapes;
213 int32_t editcursor_mode, drawing_tool;
214 StdCopyStrBuf material, texture, back_material, back_texture;
217 int32_t is_object_selection_updating;
223 ~C4ConsoleGUIState();
225 void AddToolbarSpacer(
int space);
227 void DeleteConsoleWindow();
228 void Execute(
bool redraw_only=
false);
229 void Redraw() { Execute(
true); }
230 void UpdateActionStates();
232 void UpdateBackMatTex();
234 void SetEnabled(
bool to_enabled) { enabled = to_enabled; UpdateActionStates(); ReInitDefinitions(); }
235 void SetLandscapeMode(
LandscapeMode to_landscape_mode,
bool to_flat_chunk_shapes) { landscape_mode = to_landscape_mode; flat_chunk_shapes = to_flat_chunk_shapes; UpdateActionStates(); }
236 void SetEditCursorMode(int32_t to_editcursor_mode) { editcursor_mode = to_editcursor_mode; UpdateActionStates(); }
237 void SetDrawingTool(int32_t to_drawing_tool) { drawing_tool = to_drawing_tool; UpdateActionStates(); }
238 void SetMaterial(
const char *new_material) { material.
Copy(new_material); UpdateMatTex(); }
239 void SetTexture(
const char *new_texture) { texture.
Copy(new_texture); UpdateMatTex(); }
240 void SetBackMaterial(
const char *new_material) { back_material.
Copy(new_material); UpdateBackMatTex(); }
241 void SetBackTexture(
const char *new_texture) { back_texture.
Copy(new_texture); UpdateBackMatTex(); }
242 void SetRecording(
bool to_recording) { recording = to_recording; UpdateActionStates(); }
243 void SetNetEnabled(
bool enabled) { net_enabled = enabled; UpdateActionStates(); }
247 void AddKickPlayerMenuItem(int32_t plr,
const char *
text,
bool item_enabled);
248 void ClearPlayerMenu();
249 void AddPlayerViewportMenuItem(int32_t plr,
const char *
text);
250 void ClearViewportMenu();
253 void SetInputFunctions(std::list<const char*> &functions);
255 void ReInitDefinitions();
256 void OnCreatorSelectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
258 void OnObjectListSelectionChanged(
const QItemSelection & selected,
const QItemSelection & deselected);
259 void OnCreatorCurrentChanged(
const QModelIndex & current,
const QModelIndex & previous);
260 void UpdateActionObject(
C4Object *new_action_object);
262 bool CreateNewScenario(
StdStrBuf *out_filename,
bool *out_host_as_network);
264 #ifdef USE_WIN32_WINDOWS
265 bool HandleWin32KeyboardMessage(MSG *msg);
268 void InitWelcomeScreen();
269 void ShowWelcomeScreen();
270 void HideWelcomeScreen();
272 void ClearGamePointers();
C4ConsoleQtTranslator qt_translator
InternalState(class C4ToolsDlg *owner)
State(C4ConsoleGUI *console)