OpenClonk
C4ConsoleGUI.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2006, Armin Burgmeier
5  * Copyright (c) 2010-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 #ifndef C4CONSOLEGUI_INC
18 #define C4CONSOLEGUI_INC
19 
20 #include "control/C4GameControl.h"
21 #include "game/C4Application.h"
22 #include "player/C4Player.h"
23 
24 namespace OpenFileFlags
25 {
26  const DWORD OFN_HIDEREADONLY = 1 << 0;
27  const DWORD OFN_OVERWRITEPROMPT = 1 << 1;
28  const DWORD OFN_FILEMUSTEXIST = 1 << 2;
29  const DWORD OFN_ALLOWMULTISELECT = 1 << 3;
30 
31  const DWORD OFN_EXPLORER = 0; // ignored
32 }
33 
34 // Separate class containing GUI code for C4Console while C4Console itself only contains functionality
35 class C4ConsoleGUI: public C4Window
36 {
37 public:
38 
39  template<class T> class InternalState
40  {
41  protected:
42  typedef class InternalState<T> Super;
43  private:
44  T *owner;
45  public:
46  InternalState(T *owner): owner(owner) {}
47  T *GetOwner() {return owner;}
48  };
49 
51  {
54  CONSOLE_TimeFPS
55  };
56 
57  enum Stage
58  {
62  };
63 
64  enum Cursor
65  {
67  CURSOR_Wait
68  };
69 
71  {
75  CO_Kick
76  };
77 
78  class State;
79 
80 private:
81  State *state;
82 public:
83  bool Editing;
84  bool fGameOpen;
85 
86  C4ConsoleGUI();
87  ~C4ConsoleGUI() override;
88 
89 #ifdef WITH_QT_EDITOR
90  void Execute();
91  void AddViewport(C4ViewportWindow *cvp);
92  void RemoveViewport(C4ViewportWindow *cvp);
93  void OnObjectSelectionChanged(class C4EditCursorSelection &selection); // selection changed (through other means than creator or object list view)
94  bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network);
95  void OnStartGame();
96  void ClearGamePointers();
97  void EnsureDefinitionListInitialized();
98  void CloseConsoleWindow();
99  void ClearPointers(class C4Object *obj);
100  void EditGraphControl(const class C4ControlEditGraph *control);
101 
102  // TODO some qt editor stuff is in state and needs to be public
103  // Once other editors are removed, C4ConsoleGUI, C4ConsoleQt and C4ConsoleQtState should be reorganized
104  State *GetState() const { return state; }
105 
106  friend class C4ConsoleQtMainWindow;
107  friend class C4ToolsDlg;
108 #else
109  void Execute() { }
113  bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network) { return false; }
114  void OnStartGame() { }
117  void ClearPointers(class C4Object *obj) {}
118  void EditGraphControl(const class C4ControlEditGraph *control) {}
119 #endif
120 
121  void SetCursor(Cursor cursor);
122  void RecordingEnabled();
123  void ShowAboutWithCopyright(StdStrBuf &copyright);
124  bool UpdateModeCtrls(int iMode);
125  void AddNetMenu();
126  void ClearNetMenu();
127  void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co);
128  void ClearPlayerMenu();
129  void SetInputFunctions(std::list<const char*> &functions);
130 
131  bool CreateConsoleWindow(C4AbstractApp *application);
132  void DeleteConsoleWindow();
133  void Out(const char* message);
134  bool ClearLog();
135  void DisplayInfoText(InfoTextType type, StdStrBuf& text);
136  void SetCaptionToFileName(const char* file_name);
137  bool FileSelect(StdStrBuf *sFilename, const char * szFilter, DWORD dwFlags, bool fSave);
138  void AddMenuItemForPlayer(C4Player *player, StdStrBuf& player_text);
139  void AddKickPlayerMenuItem(C4Player *player, StdStrBuf& player_text, bool enabled);
140  void ClearViewportMenu();
141  bool Message(const char *message, bool query);
142 
143  void EnableControls(bool fEnable)
144  {
145  if (!Active) return;
146  // disable Editing if no input allowed
147  Editing &= !::Control.NoInput();
148  DoEnableControls(fEnable);
149  }
150  void DoEnableControls(bool fEnable);
151 
152  bool UpdateHaltCtrls(bool fHalt)
153  {
154  if (!Active)
155  return false;
156  DoUpdateHaltCtrls(fHalt);
157  return true;
158  }
159  bool DoUpdateHaltCtrls(bool fHalt);
160 
161  bool PropertyDlgOpen();
162  void PropertyDlgClose();
163  void PropertyDlgUpdate(class C4EditCursorSelection &rSelection, bool force_function_update);
165 
166  bool ToolsDlgOpen(class C4ToolsDlg *dlg);
167  void ToolsDlgClose();
168  void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg);
169  void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture);
170  void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material);
171  void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture);
172  void ToolsDlgSelectBackMaterial(C4ToolsDlg *dlg, const char *material);
173 
174 #ifdef USE_WIN32_WINDOWS
175  void Win32KeepDialogsFloating(HWND hwnd = nullptr);
176  bool Win32DialogMessageHandling(MSG *msg) override;
177  void UpdateMenuText(HMENU hMenu);
178 
179  friend INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
180  friend INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
181 #endif
182 };
183 
184 #endif
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:143
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:31
INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:116
void EnsureDefinitionListInitialized()
Definition: C4ConsoleGUI.h:115
void OnObjectSelectionChanged(class C4EditCursorSelection &selection)
Definition: C4ConsoleGUI.h:112
void OnStartGame()
Definition: C4ConsoleGUI.h:114
bool Active
Definition: C4ToolsDlg.h:52
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:113
void AddViewport(C4ViewportWindow *cvp)
Definition: C4ConsoleGUI.h:110
C4Object * PropertyDlgObject
Definition: C4ConsoleGUI.h:164
C4GameControl Control
void Execute()
Definition: C4ConsoleGUI.h:109
void EditGraphControl(const class C4ControlEditGraph *control)
Definition: C4ConsoleGUI.h:118
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:28
void ClearPointers(class C4Object *obj)
Definition: C4ConsoleGUI.h:117
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
void RemoveViewport(C4ViewportWindow *cvp)
Definition: C4ConsoleGUI.h:111
bool UpdateHaltCtrls(bool fHalt)
Definition: C4ConsoleGUI.h:152
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:29
uint32_t DWORD
INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
bool NoInput() const
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:27
class InternalState< class C4ToolsDlg > Super
Definition: C4ConsoleGUI.h:42