OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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  {
55  };
56 
57  enum Stage
58  {
62  };
63 
64  enum Cursor
65  {
68  };
69 
71  {
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);
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();
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();
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)
~C4ConsoleGUI() override
void SetCaptionToFileName(const char *file_name)
Definition: C4Console.cpp:689
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:116
void EnsureDefinitionListInitialized()
Definition: C4ConsoleGUI.h:115
void OnObjectSelectionChanged(class C4EditCursorSelection &selection)
Definition: C4ConsoleGUI.h:112
void DeleteConsoleWindow()
Definition: C4Console.cpp:678
void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:695
void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:698
void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:693
bool DoUpdateHaltCtrls(bool fHalt)
Definition: C4Console.cpp:681
void OnStartGame()
Definition: C4ConsoleGUI.h:114
void PropertyDlgUpdate(class C4EditCursorSelection &rSelection, bool force_function_update)
Definition: C4Console.cpp:687
bool PropertyDlgOpen()
Definition: C4Console.cpp:685
void ClearNetMenu()
Definition: C4Console.cpp:668
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:113
void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:696
void ShowAboutWithCopyright(StdStrBuf &copyright)
Definition: C4Console.cpp:692
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
bool NoInput() const
void Out(const char *message)
Definition: C4Console.cpp:684
void ToolsDlgSelectBackMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:697
void ClearPointers(class C4Object *obj)
Definition: C4ConsoleGUI.h:117
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:26
bool Message(const char *message, bool query)
Definition: C4Console.cpp:683
void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co)
Definition: C4Console.cpp:664
void AddKickPlayerMenuItem(C4Player *player, StdStrBuf &player_text, bool enabled)
Definition: C4Console.cpp:662
bool ToolsDlgOpen(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:694
void ClearViewportMenu()
Definition: C4Console.cpp:670
bool UpdateModeCtrls(int iMode)
Definition: C4Console.cpp:699
void RemoveViewport(C4ViewportWindow *cvp)
Definition: C4ConsoleGUI.h:111
void RecordingEnabled()
Definition: C4Console.cpp:688
bool CreateConsoleWindow(C4AbstractApp *application)
Definition: C4Console.cpp:671
bool UpdateHaltCtrls(bool fHalt)
Definition: C4ConsoleGUI.h:152
bool Active
Definition: C4Window.h:273
void SetInputFunctions(std::list< const char * > &functions)
Definition: C4Console.cpp:691
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave)
Definition: C4Console.cpp:682
bool ClearLog()
Definition: C4Console.cpp:667
void AddMenuItemForPlayer(C4Player *player, StdStrBuf &player_text)
Definition: C4Console.cpp:663
void ToolsDlgClose()
Definition: C4Console.cpp:666
void DoEnableControls(bool fEnable)
Definition: C4Console.cpp:680
void AddNetMenu()
Definition: C4Console.cpp:665
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:29
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
Definition: C4Console.cpp:679
void ClearPlayerMenu()
Definition: C4Console.cpp:669
uint32_t DWORD
INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:690
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:27
void PropertyDlgClose()
Definition: C4Console.cpp:686
class InternalState< class C4ToolsDlg > Super
Definition: C4ConsoleGUI.h:42