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 "game/C4Application.h"
21 #include "player/C4Player.h"
22 #include "control/C4GameControl.h"
23 #include "lib/StdBuf.h"
24 
25 namespace OpenFileFlags
26 {
27  const DWORD OFN_HIDEREADONLY = 1 << 0;
28  const DWORD OFN_OVERWRITEPROMPT = 1 << 1;
29  const DWORD OFN_FILEMUSTEXIST = 1 << 2;
30  const DWORD OFN_ALLOWMULTISELECT = 1 << 3;
31 
32  const DWORD OFN_EXPLORER = 0; // ignored
33 }
34 
35 // Separate class containing GUI code for C4Console while C4Console itself only contains functionality
36 class C4ConsoleGUI: public C4Window
37 {
38 public:
39 
40  template<class T> class InternalState
41  {
42  protected:
43  typedef class InternalState<T> Super;
44  private:
45  T *owner;
46  public:
47  InternalState(T *owner): owner(owner) {}
48  T *GetOwner() {return owner;}
49  };
50 
52  {
56  };
57 
58  enum Stage
59  {
63  };
64 
65  enum Cursor
66  {
69  };
70 
72  {
77  };
78 
79  class State;
80 
81 private:
82  State *state;
83 public:
84  bool Editing;
85  bool fGameOpen;
86 
87  C4ConsoleGUI();
88  ~C4ConsoleGUI();
89 
90 #ifdef WITH_QT_EDITOR
91  void Execute();
92  void AddViewport(C4ViewportWindow *cvp);
94  void OnObjectSelectionChanged(class C4EditCursorSelection &selection); // selection changed (through other means than creator or object list view)
95  bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network);
96  void OnStartGame();
97  void ClearGamePointers();
99  void CloseConsoleWindow();
100  void ClearPointers(class C4Object *obj);
101  void EditGraphControl(const class C4ControlEditGraph *control);
102 
103  // TODO some qt editor stuff is in state and needs to be public
104  // Once other editors are removed, C4ConsoleGUI, C4ConsoleQt and C4ConsoleQtState should be reorganized
105  State *GetState() const { return state; }
106 
107  friend class C4ConsoleQtMainWindow;
108  friend class C4ToolsDlg;
109 #else
110  void Execute() { }
114  bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network) { return false; }
115  void OnStartGame() { }
118  void ClearPointers(class C4Object *obj) {}
119  void EditGraphControl(const class C4ControlEditGraph *control) {}
120 #endif
121 
122  void SetCursor(Cursor cursor);
123  void RecordingEnabled();
124  void ShowAboutWithCopyright(StdStrBuf &copyright);
125  bool UpdateModeCtrls(int iMode);
126  void AddNetMenu();
127  void ClearNetMenu();
128  void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co);
129  void ClearPlayerMenu();
130  void SetInputFunctions(std::list<const char*> &functions);
131 
132  bool CreateConsoleWindow(C4AbstractApp *application);
133  void DeleteConsoleWindow();
134  void Out(const char* message);
135  bool ClearLog();
137  void SetCaptionToFileName(const char* file_name);
138  bool FileSelect(StdStrBuf *sFilename, const char * szFilter, DWORD dwFlags, bool fSave);
139  void AddMenuItemForPlayer(C4Player *player, StdStrBuf& player_text);
140  void AddKickPlayerMenuItem(C4Player *player, StdStrBuf& player_text, bool enabled);
141  void ClearViewportMenu();
142  bool Message(const char *message, bool query);
143 
144  void EnableControls(bool fEnable)
145  {
146  if (!Active) return;
147  // disable Editing if no input allowed
148  Editing &= !::Control.NoInput();
149  DoEnableControls(fEnable);
150  }
151  void DoEnableControls(bool fEnable);
152 
153  bool UpdateHaltCtrls(bool fHalt)
154  {
155  if (!Active)
156  return false;
157  DoUpdateHaltCtrls(fHalt);
158  return true;
159  }
160  bool DoUpdateHaltCtrls(bool fHalt);
161 
162  bool PropertyDlgOpen();
163  void PropertyDlgClose();
164  void PropertyDlgUpdate(class C4EditCursorSelection &rSelection, bool force_function_update);
166 
167  bool ToolsDlgOpen(class C4ToolsDlg *dlg);
168  void ToolsDlgClose();
169  void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg);
170  void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture);
171  void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material);
172  void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture);
173  void ToolsDlgSelectBackMaterial(C4ToolsDlg *dlg, const char *material);
174 
175 #ifdef USE_WIN32_WINDOWS
176  void Win32KeepDialogsFloating(HWND hwnd = 0);
177  virtual bool Win32DialogMessageHandling(MSG *msg);
178  void UpdateMenuText(HMENU hMenu);
179 
180  friend INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
181  friend INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
182 #endif
183 };
184 
185 #endif
void EnableControls(bool fEnable)
Definition: C4ConsoleGUI.h:144
const DWORD OFN_EXPLORER
Definition: C4ConsoleGUI.h:32
INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
void SetCaptionToFileName(const char *file_name)
Definition: C4Console.cpp:694
void CloseConsoleWindow()
Definition: C4ConsoleGUI.h:117
void EnsureDefinitionListInitialized()
Definition: C4ConsoleGUI.h:116
void OnObjectSelectionChanged(class C4EditCursorSelection &selection)
Definition: C4ConsoleGUI.h:113
void DeleteConsoleWindow()
Definition: C4Console.cpp:683
void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:700
void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:703
void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:698
bool DoUpdateHaltCtrls(bool fHalt)
Definition: C4Console.cpp:686
void OnStartGame()
Definition: C4ConsoleGUI.h:115
void PropertyDlgUpdate(class C4EditCursorSelection &rSelection, bool force_function_update)
Definition: C4Console.cpp:692
bool PropertyDlgOpen()
Definition: C4Console.cpp:690
void ClearNetMenu()
Definition: C4Console.cpp:673
bool CreateNewScenario(StdStrBuf *out_filename, bool *out_host_as_network)
Definition: C4ConsoleGUI.h:114
void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:701
void ShowAboutWithCopyright(StdStrBuf &copyright)
Definition: C4Console.cpp:697
void AddViewport(C4ViewportWindow *cvp)
Definition: C4ConsoleGUI.h:111
C4Object * PropertyDlgObject
Definition: C4ConsoleGUI.h:165
C4GameControl Control
void Execute()
Definition: C4ConsoleGUI.h:110
void EditGraphControl(const class C4ControlEditGraph *control)
Definition: C4ConsoleGUI.h:119
const DWORD OFN_FILEMUSTEXIST
Definition: C4ConsoleGUI.h:29
bool NoInput() const
void Out(const char *message)
Definition: C4Console.cpp:689
void ToolsDlgSelectBackMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:702
void ClearPointers(class C4Object *obj)
Definition: C4ConsoleGUI.h:118
const DWORD OFN_HIDEREADONLY
Definition: C4ConsoleGUI.h:27
bool Message(const char *message, bool query)
Definition: C4Console.cpp:688
void AddNetMenuItemForPlayer(int32_t client_id, const char *text, C4ConsoleGUI::ClientOperation co)
Definition: C4Console.cpp:669
void AddKickPlayerMenuItem(C4Player *player, StdStrBuf &player_text, bool enabled)
Definition: C4Console.cpp:667
bool ToolsDlgOpen(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:699
void ClearViewportMenu()
Definition: C4Console.cpp:675
bool UpdateModeCtrls(int iMode)
Definition: C4Console.cpp:704
void RemoveViewport(C4ViewportWindow *cvp)
Definition: C4ConsoleGUI.h:112
void RecordingEnabled()
Definition: C4Console.cpp:693
bool CreateConsoleWindow(C4AbstractApp *application)
Definition: C4Console.cpp:676
bool UpdateHaltCtrls(bool fHalt)
Definition: C4ConsoleGUI.h:153
bool Active
Definition: C4Window.h:278
void SetInputFunctions(std::list< const char * > &functions)
Definition: C4Console.cpp:696
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave)
Definition: C4Console.cpp:687
bool ClearLog()
Definition: C4Console.cpp:672
void AddMenuItemForPlayer(C4Player *player, StdStrBuf &player_text)
Definition: C4Console.cpp:668
void ToolsDlgClose()
Definition: C4Console.cpp:671
void DoEnableControls(bool fEnable)
Definition: C4Console.cpp:685
void AddNetMenu()
Definition: C4Console.cpp:670
const DWORD OFN_ALLOWMULTISELECT
Definition: C4ConsoleGUI.h:30
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
Definition: C4Console.cpp:684
void ClearPlayerMenu()
Definition: C4Console.cpp:674
uint32_t DWORD
INT_PTR CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
void SetCursor(Cursor cursor)
Definition: C4Console.cpp:695
const DWORD OFN_OVERWRITEPROMPT
Definition: C4ConsoleGUI.h:28
void PropertyDlgClose()
Definition: C4Console.cpp:691
class InternalState< class C4ToolsDlg > Super
Definition: C4ConsoleGUI.h:43