OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ToolsDlg Class Reference

#include <C4ToolsDlg.h>

Classes

class  State
 

Public Member Functions

 C4ToolsDlg ()
 
 ~C4ToolsDlg ()
 
void Default ()
 
void Clear ()
 
bool PopTextures ()
 
bool PopMaterial ()
 
bool ChangeGrade (int32_t iChange)
 
void NeedPreviewUpdate ()
 
bool Open ()
 
bool SetGrade (int32_t iGrade)
 
bool SetTool (int32_t iTool, bool fTemp)
 
bool ToggleTool ()
 
bool SetLandscapeMode (LandscapeMode iMode, bool flat_chunk_shapes, bool fThroughControl=false)
 
bool SetIFT (bool fIFT)
 
bool ToggleIFT ()
 
bool SelectTexture (const char *szTexture, bool by_console_gui=false)
 
bool SelectMaterial (const char *szMaterial, bool by_console_gui=false)
 
bool SelectBackTexture (const char *szTexture, bool by_console_gui=false)
 
bool SelectBackMaterial (const char *szMaterial, bool by_console_gui=false)
 
void SetAlternateTool ()
 
void ResetAlternateTool ()
 
bool IsGradedTool () const
 
void UpdateLandscapeModeCtrls ()
 
void SetTexture (const char *szTexture)
 
void SetMaterial (const char *szMaterial)
 
void SetBackTexture (const char *szTexture)
 
void SetBackMaterial (const char *szMaterial)
 

Public Attributes

bool Active
 
int32_t Tool
 
int32_t SelectedTool
 
int32_t Grade
 
bool ModeIFT
 
char Material [C4M_MaxName+1]
 
char Texture [C4M_MaxName+1]
 
bool ModeBack
 
char BackMaterial [C4M_MaxName+1]
 
char BackTexture [C4M_MaxName+1]
 

Protected Member Functions

void AssertValidTexture ()
 
void AssertValidBackTexture ()
 
void LoadBitmaps ()
 
void EnableControls ()
 
void UpdateIFTControls ()
 
void InitGradeCtrl ()
 
void InitMaterialCtrls ()
 
void UpdateToolCtrls ()
 
void UpdateTextures ()
 
void SetColorPattern (const char *szMaterial, const char *szTexture)
 

Friends

class C4ConsoleGUI
 

Detailed Description

Definition at line 42 of file C4ToolsDlg.h.

Constructor & Destructor Documentation

C4ToolsDlg::C4ToolsDlg ( )
C4ToolsDlg::~C4ToolsDlg ( )

Member Function Documentation

void C4ToolsDlg::AssertValidBackTexture ( )
protected

Definition at line 236 of file C4ToolsDlg.cpp.

References BackMaterial, BackTexture, C4TLS_MatSky, C4TextureMap::GetIndex(), C4Landscape::GetMode(), C4TextureMap::GetTexture(), Landscape, ModeBack, SelectBackTexture(), SEqual(), Static, and TextureMap.

Referenced by SetBackMaterial().

237 {
238  // Static map mode only
239  if (::Landscape.GetMode() != LandscapeMode::Static) return;
240  // Ignore if not enabled
241  if (!ModeBack) return;
242  // Ignore if sky
243  if (SEqual(BackMaterial,C4TLS_MatSky)) return;
244  // Current material-texture valid
245  if (::TextureMap.GetIndex(BackMaterial,BackTexture,false)) return;
246  // Find valid material-texture
247  const char *szTexture;
248  for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
249  {
250  if (::TextureMap.GetIndex(BackMaterial,szTexture,false))
251  { SelectBackTexture(szTexture); return; }
252  }
253  // No valid texture found
254 }
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:414
C4Landscape Landscape
LandscapeMode GetMode() const
bool SelectBackTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:270
bool ModeBack
Definition: C4ToolsDlg.h:58
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
char BackMaterial[C4M_MaxName+1]
Definition: C4ToolsDlg.h:59
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
char BackTexture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:60

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::AssertValidTexture ( )
protected

Definition at line 216 of file C4ToolsDlg.cpp.

References C4TLS_MatSky, C4TextureMap::GetIndex(), C4Landscape::GetMode(), C4TextureMap::GetTexture(), Landscape, Material, SelectTexture(), SEqual(), Static, Texture, and TextureMap.

Referenced by SetMaterial().

217 {
218 #ifndef WITH_QT_EDITOR // Qt Editor textures are always valid, because MatTex entries are selected directly
219  // Static map mode only
220  if (::Landscape.GetMode() != LandscapeMode::Static) return;
221  // Ignore if sky
222  if (SEqual(Material,C4TLS_MatSky)) return;
223  // Current material-texture valid
224  if (::TextureMap.GetIndex(Material,Texture,false)) return;
225  // Find valid material-texture
226  const char *szTexture;
227  for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
228  {
229  if (::TextureMap.GetIndex(Material,szTexture,false))
230  { SelectTexture(szTexture); return; }
231  }
232  // No valid texture found
233 #endif
234 }
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:414
char Texture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:57
C4Landscape Landscape
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
LandscapeMode GetMode() const
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
bool SelectTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:256

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::ChangeGrade ( int32_t  iChange)

Definition at line 173 of file C4ToolsDlg.cpp.

References C4TLS_GradeMax, C4TLS_GradeMin, Clamp(), Grade, InitGradeCtrl(), and NeedPreviewUpdate().

Referenced by C4Game::InitKeyboard().

174 {
177  InitGradeCtrl();
178  return true;
179 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
int32_t Grade
Definition: C4ToolsDlg.h:54
const int32_t C4TLS_GradeMin
Definition: C4ToolsDlg.h:36
const int32_t C4TLS_GradeMax
Definition: C4ToolsDlg.h:35
void InitGradeCtrl()
Definition: C4Console.cpp:701
void NeedPreviewUpdate()
Definition: C4Console.cpp:702

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::Clear ( )

Definition at line 41 of file C4ConsoleGUICommon.h.

References Active, Console, and C4ConsoleGUI::ToolsDlgClose().

Referenced by C4Console::Clear(), and ToolsDlgProc().

42 {
43  state->Clear();
45  Active = false;
46 }
C4Console Console
Definition: C4Globals.cpp:45
bool Active
Definition: C4ToolsDlg.h:52
void ToolsDlgClose()
Definition: C4Console.cpp:666

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::Default ( )

Definition at line 48 of file C4ConsoleGUICommon.h.

References Active, BackMaterial, BackTexture, C4TLS_Brush, C4TLS_GradeDefault, C4ToolsDlg::State::Default(), Grade, Material, ModeBack, ModeIFT, SCopy(), SelectedTool, Texture, and Tool.

Referenced by C4Console::Default().

49 {
50  Active = false;
53  ModeIFT = true;
54  SCopy("Earth",Material);
55  SCopy("earth",Texture);
56  ModeBack = false;
57  SCopy("Tunnel", BackMaterial);
58  SCopy("tunnel", BackTexture);
59  state->Default();
60 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
bool Active
Definition: C4ToolsDlg.h:52
int32_t Grade
Definition: C4ToolsDlg.h:54
char Texture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:57
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
bool ModeBack
Definition: C4ToolsDlg.h:58
const int32_t C4TLS_Brush
Definition: C4ToolsDlg.h:28
char BackMaterial[C4M_MaxName+1]
Definition: C4ToolsDlg.h:59
const int32_t C4TLS_GradeDefault
Definition: C4ToolsDlg.h:37
int32_t SelectedTool
Definition: C4ToolsDlg.h:53
char BackTexture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:60
int32_t Tool
Definition: C4ToolsDlg.h:53
bool ModeIFT
Definition: C4ToolsDlg.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::EnableControls ( )
protected

Definition at line 700 of file C4Console.cpp.

Referenced by Open(), SetBackMaterial(), SetLandscapeMode(), and SetMaterial().

700 {}

Here is the caller graph for this function:

void C4ToolsDlg::InitGradeCtrl ( )
protected

Definition at line 701 of file C4Console.cpp.

Referenced by ChangeGrade(), and Open().

701 {}

Here is the caller graph for this function:

void C4ToolsDlg::InitMaterialCtrls ( )
protected

Definition at line 52 of file C4ToolsDlg.cpp.

References Console, C4ConsoleGUI::ToolsDlgInitMaterialCtrls(), and UpdateTextures().

Referenced by Open().

53 {
54  // Materials
56  // Textures
58 }
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:693
void UpdateTextures()
Definition: C4Console.cpp:707

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::IsGradedTool ( ) const
inline

Definition at line 81 of file C4ToolsDlg.h.

References C4TLS_Brush, C4TLS_Fill, and C4TLS_Line.

Referenced by C4EditCursor::Draw().

81 { return Tool == C4TLS_Brush || Tool == C4TLS_Line || Tool == C4TLS_Fill; } // return whether Grade measure affects selected tool
const int32_t C4TLS_Brush
Definition: C4ToolsDlg.h:28
const int32_t C4TLS_Fill
Definition: C4ToolsDlg.h:31
const int32_t C4TLS_Line
Definition: C4ToolsDlg.h:29
int32_t Tool
Definition: C4ToolsDlg.h:53

Here is the caller graph for this function:

void C4ToolsDlg::LoadBitmaps ( )
protected
void C4ToolsDlg::NeedPreviewUpdate ( )

Definition at line 702 of file C4Console.cpp.

Referenced by ChangeGrade(), SetGrade(), SetIFT(), SetMaterial(), SetTexture(), SetTool(), and ToolsDlgProc().

702 {}

Here is the caller graph for this function:

bool C4ToolsDlg::Open ( )

Definition at line 28 of file C4ToolsDlg.cpp.

References Active, Console, EnableControls(), InitGradeCtrl(), InitMaterialCtrls(), C4ConsoleGUI::ToolsDlgOpen(), UpdateIFTControls(), UpdateLandscapeModeCtrls(), and UpdateToolCtrls().

Referenced by C4EditCursor::OpenPropTools().

29 {
30  // Create dialog window
31  Console.ToolsDlgOpen(this);
32  Active = true;
33  // Update contols
34  InitGradeCtrl();
40  return true;
41 }
C4Console Console
Definition: C4Globals.cpp:45
void InitMaterialCtrls()
Definition: C4ToolsDlg.cpp:52
bool Active
Definition: C4ToolsDlg.h:52
void InitGradeCtrl()
Definition: C4Console.cpp:701
void UpdateIFTControls()
Definition: C4Console.cpp:705
bool ToolsDlgOpen(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:694
void UpdateToolCtrls()
Definition: C4Console.cpp:708
void UpdateLandscapeModeCtrls()
Definition: C4Console.cpp:706
void EnableControls()
Definition: C4Console.cpp:700

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::PopMaterial ( )

Definition at line 703 of file C4Console.cpp.

Referenced by C4Game::InitKeyboard().

703 {return false;}

Here is the caller graph for this function:

bool C4ToolsDlg::PopTextures ( )

Definition at line 704 of file C4Console.cpp.

Referenced by C4Game::InitKeyboard().

704 {return false;}

Here is the caller graph for this function:

void C4ToolsDlg::ResetAlternateTool ( )

Definition at line 290 of file C4ToolsDlg.cpp.

References SelectedTool, and SetTool().

Referenced by C4EditCursor::AltUp().

291 {
292  // reset tool to selected tool in case alternate tool was set
293  SetTool(SelectedTool, true);
294 }
int32_t SelectedTool
Definition: C4ToolsDlg.h:53
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:43

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SelectBackMaterial ( const char *  szMaterial,
bool  by_console_gui = false 
)

Definition at line 277 of file C4ToolsDlg.cpp.

References Console, SetBackMaterial(), and C4ConsoleGUI::ToolsDlgSelectBackMaterial().

Referenced by C4EditCursor::ApplyToolPicker(), SetMaterial(), and SetTexture().

278 {
279  if (!by_console_gui) Console.ToolsDlgSelectBackMaterial(this, szMaterial);
280  SetBackMaterial(szMaterial);
281  return true;
282 }
C4Console Console
Definition: C4Globals.cpp:45
void SetBackMaterial(const char *szMaterial)
Definition: C4ToolsDlg.cpp:106
void ToolsDlgSelectBackMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:697

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SelectBackTexture ( const char *  szTexture,
bool  by_console_gui = false 
)

Definition at line 270 of file C4ToolsDlg.cpp.

References Console, SetBackTexture(), and C4ConsoleGUI::ToolsDlgSelectBackTexture().

Referenced by C4EditCursor::ApplyToolPicker(), AssertValidBackTexture(), and SetTexture().

271 {
272  if (!by_console_gui) Console.ToolsDlgSelectBackTexture(this, szTexture);
273  SetBackTexture(szTexture);
274  return true;
275 }
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:698
void SetBackTexture(const char *szTexture)
Definition: C4ToolsDlg.cpp:116

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SelectMaterial ( const char *  szMaterial,
bool  by_console_gui = false 
)

Definition at line 263 of file C4ToolsDlg.cpp.

References Console, SetMaterial(), and C4ConsoleGUI::ToolsDlgSelectMaterial().

Referenced by C4EditCursor::ApplyToolPicker().

264 {
265  if (!by_console_gui) Console.ToolsDlgSelectMaterial(this, szMaterial);
266  SetMaterial(szMaterial);
267  return true;
268 }
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material)
Definition: C4Console.cpp:695
void SetMaterial(const char *szMaterial)
Definition: C4ToolsDlg.cpp:60

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SelectTexture ( const char *  szTexture,
bool  by_console_gui = false 
)

Definition at line 256 of file C4ToolsDlg.cpp.

References Console, SetTexture(), and C4ConsoleGUI::ToolsDlgSelectTexture().

Referenced by C4EditCursor::ApplyToolPicker(), and AssertValidTexture().

257 {
258  if (!by_console_gui) Console.ToolsDlgSelectTexture(this, szTexture);
259  SetTexture(szTexture);
260  return true;
261 }
C4Console Console
Definition: C4Globals.cpp:45
void SetTexture(const char *szTexture)
Definition: C4ToolsDlg.cpp:71
void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:696

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetAlternateTool ( )

Definition at line 284 of file C4ToolsDlg.cpp.

References C4TLS_Picker, and SetTool().

Referenced by C4EditCursor::AltDown().

285 {
286  // alternate tool is the picker in any mode
287  SetTool(C4TLS_Picker, true);
288 }
const int32_t C4TLS_Picker
Definition: C4ToolsDlg.h:32
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:43

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetBackMaterial ( const char *  szMaterial)

Definition at line 106 of file C4ToolsDlg.cpp.

References AssertValidBackTexture(), BackMaterial, C4M_MaxName, EnableControls(), C4Landscape::GetMode(), Landscape, ModeBack, SCopy(), Static, and UpdateTextures().

Referenced by SelectBackMaterial(), and ToolsDlgProc().

107 {
108  ModeBack = true;
109 
110  SCopy(szMaterial,BackMaterial,C4M_MaxName);
112  EnableControls();
114 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
const int C4M_MaxName
Definition: C4Constants.h:49
void AssertValidBackTexture()
Definition: C4ToolsDlg.cpp:236
C4Landscape Landscape
LandscapeMode GetMode() const
bool ModeBack
Definition: C4ToolsDlg.h:58
char BackMaterial[C4M_MaxName+1]
Definition: C4ToolsDlg.h:59
void UpdateTextures()
Definition: C4Console.cpp:707
void EnableControls()
Definition: C4Console.cpp:700

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetBackTexture ( const char *  szTexture)

Definition at line 116 of file C4ToolsDlg.cpp.

References BackTexture, C4M_MaxName, Console, C4TextureMap::GetTexture(), ModeBack, SCopy(), TextureMap, and C4ConsoleGUI::ToolsDlgSelectBackTexture().

Referenced by SelectBackTexture(), and ToolsDlgProc().

117 {
118  ModeBack = true;
119 
120  // assert valid (for separator selection)
121  if (!::TextureMap.GetTexture(szTexture))
122  {
123  // ensure correct texture is in dlg
124  Console.ToolsDlgSelectBackTexture(this, szTexture);
125  return;
126  }
127 
128  SCopy(szTexture,BackTexture,C4M_MaxName);
129 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:698
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
const int C4M_MaxName
Definition: C4Constants.h:49
bool ModeBack
Definition: C4ToolsDlg.h:58
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
char BackTexture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:60

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetColorPattern ( const char *  szMaterial,
const char *  szTexture 
)
protected

Definition at line 162 of file C4ToolsDlg.cpp.

163 {
164 }
bool C4ToolsDlg::SetGrade ( int32_t  iGrade)

Definition at line 166 of file C4ToolsDlg.cpp.

References C4TLS_GradeMax, C4TLS_GradeMin, Clamp(), Grade, and NeedPreviewUpdate().

Referenced by ToolsDlgProc().

167 {
170  return true;
171 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
int32_t Grade
Definition: C4ToolsDlg.h:54
const int32_t C4TLS_GradeMin
Definition: C4ToolsDlg.h:36
const int32_t C4TLS_GradeMax
Definition: C4ToolsDlg.h:35
void NeedPreviewUpdate()
Definition: C4Console.cpp:702

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SetIFT ( bool  fIFT)

Definition at line 131 of file C4ToolsDlg.cpp.

References BackMaterial, BackTexture, C4M_MaxName, C4TLS_MatSky, C4TextureMap::DefaultBkgMatTex(), C4TextureMap::GetEntry(), C4TextureMap::GetIndexMatTex(), C4TexMapEntry::GetMaterialName(), C4TexMapEntry::GetTextureName(), Material, ModeBack, ModeIFT, NeedPreviewUpdate(), SCopy(), TextureMap, and UpdateIFTControls().

Referenced by C4EditCursor::ApplyToolPicker(), and ToggleIFT().

132 {
133  ModeBack = false;
134  if (fIFT) ModeIFT = true; else ModeIFT=false;
135 
136  // Keep sensible default values in BackMaterial / BackTexture
137  if (ModeIFT == 0)
138  {
140  }
141  else
142  {
144  int32_t index = ::TextureMap.GetIndexMatTex(Material);
145  if (index != -1)
146  {
147  BYTE bg_index = ::TextureMap.DefaultBkgMatTex(index);
148  const C4TexMapEntry* entry = ::TextureMap.GetEntry(bg_index);
149  if (entry != nullptr)
150  {
153  }
154  }
155  }
156 
159  return true;
160 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
BYTE DefaultBkgMatTex(BYTE fg) const
Definition: C4Texture.cpp:504
uint8_t BYTE
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
const C4TexMapEntry * GetEntry(int32_t iIndex) const
Definition: C4Texture.h:85
Definition: C4Texture.h:48
const int C4M_MaxName
Definition: C4Constants.h:49
const char * GetMaterialName() const
Definition: C4Texture.h:60
const char * GetTextureName() const
Definition: C4Texture.h:61
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
void UpdateIFTControls()
Definition: C4Console.cpp:705
bool ModeBack
Definition: C4ToolsDlg.h:58
void NeedPreviewUpdate()
Definition: C4Console.cpp:702
char BackMaterial[C4M_MaxName+1]
Definition: C4ToolsDlg.h:59
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
char BackTexture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:60
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture=nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:441
bool ModeIFT
Definition: C4ToolsDlg.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SetLandscapeMode ( LandscapeMode  iMode,
bool  flat_chunk_shapes,
bool  fThroughControl = false 
)

Definition at line 181 of file C4ToolsDlg.cpp.

References C4Game::C4S, C4TLS_Brush, C4TLS_Fill, CDT_Decide, CID_EMDrawTool, Console, Control, C4GameControl::DoInput(), EMDT_SetMode, EnableControls(), Exact, C4SLandscape::FlatChunkShapes, Game, C4Landscape::GetMode(), C4Scenario::Landscape, Landscape, LoadResStr(), C4Landscape::MapToLandscape(), C4Console::Message(), SelectedTool, C4Landscape::SetMode(), SetTool(), Static, UpdateLandscapeModeCtrls(), and UpdateTextures().

Referenced by ToolsDlgProc().

182 {
183  auto last_mode = ::Landscape.GetMode();
184  auto last_flat_chunk_shapes = ::Game.C4S.Landscape.FlatChunkShapes;
185  // Exact to static: confirm data loss warning
186  if (last_mode == LandscapeMode::Exact)
187  if (mode == LandscapeMode::Static)
188  if (!fThroughControl)
189  if (!Console.Message(LoadResStr("IDS_CNS_EXACTTOSTATIC"), true))
190  return false;
191  // send as control
192  if (!fThroughControl)
193  {
194  ::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, mode, flat_chunk_shapes ? 1 : 0), CDT_Decide);
195  return true;
196  }
197  // Set landscape mode
198  ::Game.C4S.Landscape.FlatChunkShapes = flat_chunk_shapes;
199  ::Landscape.SetMode(mode);
200  // Exact to static: redraw landscape from map
201  if (last_mode == LandscapeMode::Exact || (last_flat_chunk_shapes != flat_chunk_shapes))
202  if (mode == LandscapeMode::Static)
204  // Assert valid tool
205  if (mode != LandscapeMode::Exact)
206  if (SelectedTool == C4TLS_Fill)
207  SetTool(C4TLS_Brush, false);
208  // Update controls
210  EnableControls();
211  UpdateTextures();
212  // Success
213  return true;
214 }
C4Console Console
Definition: C4Globals.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
C4SLandscape Landscape
Definition: C4Scenario.h:234
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool MapToLandscape()
C4GameControl Control
C4Landscape Landscape
void SetMode(LandscapeMode iMode)
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery)
LandscapeMode GetMode() const
bool FlatChunkShapes
Definition: C4Scenario.h:186
const int32_t C4TLS_Brush
Definition: C4ToolsDlg.h:28
const int32_t C4TLS_Fill
Definition: C4ToolsDlg.h:31
void UpdateLandscapeModeCtrls()
Definition: C4Console.cpp:706
int32_t SelectedTool
Definition: C4ToolsDlg.h:53
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:43
void UpdateTextures()
Definition: C4Console.cpp:707
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:292
void EnableControls()
Definition: C4Console.cpp:700

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetMaterial ( const char *  szMaterial)

Definition at line 60 of file C4ToolsDlg.cpp.

References AssertValidTexture(), C4M_MaxName, C4TLS_MatSky, EnableControls(), C4Landscape::GetMode(), Landscape, Material, ModeBack, NeedPreviewUpdate(), SCopy(), SelectBackMaterial(), SEqual(), Static, and UpdateTextures().

Referenced by SelectMaterial(), and ToolsDlgProc().

61 {
62  SCopy(szMaterial,Material,C4M_MaxName);
67  if (ModeBack && SEqual(szMaterial, C4TLS_MatSky))
69 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
void AssertValidTexture()
Definition: C4ToolsDlg.cpp:216
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
const int C4M_MaxName
Definition: C4Constants.h:49
C4Landscape Landscape
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
LandscapeMode GetMode() const
bool ModeBack
Definition: C4ToolsDlg.h:58
void NeedPreviewUpdate()
Definition: C4Console.cpp:702
bool SelectBackMaterial(const char *szMaterial, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:277
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
void UpdateTextures()
Definition: C4Console.cpp:707
void EnableControls()
Definition: C4Console.cpp:700

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetTexture ( const char *  szTexture)

Definition at line 71 of file C4ToolsDlg.cpp.

References BackMaterial, C4M_MaxName, C4TLS_MatSky, Console, C4MaterialCore::Density, DensitySemiSolid(), C4MaterialMap::Get(), C4TextureMap::GetTexture(), C4MaterialMap::Map, Material, MaterialMap, MNone, NeedPreviewUpdate(), SCopy(), SelectBackMaterial(), SelectBackTexture(), SEqual(), Texture, TextureMap, and C4ConsoleGUI::ToolsDlgSelectTexture().

Referenced by SelectTexture(), and ToolsDlgProc().

72 {
73  // assert valid (for separator selection)
74  if (!::TextureMap.GetTexture(szTexture))
75  {
76  // ensure correct texture is in dlg
77  Console.ToolsDlgSelectTexture(this, szTexture);
78  return;
79  }
80 
81  SCopy(szTexture,Texture,C4M_MaxName);
83 
84  // If the front texture changes, reset the background texture
85  // to something sensible.
86  int32_t mat = MaterialMap.Get(Material);
87  if (mat != MNone)
88  {
89  const C4Material* material = &MaterialMap.Map[mat];
90  if(DensitySemiSolid(material->Density))
91  {
93  {
94  SelectBackMaterial("Tunnel");
95  SelectBackTexture("tunnel");
96  }
97  }
98  else
99  {
102  }
103  }
104 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
C4Console Console
Definition: C4Globals.cpp:45
C4Material * Map
Definition: C4Material.h:169
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
bool DensitySemiSolid(int32_t dens)
Definition: C4Landscape.h:203
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
const int C4M_MaxName
Definition: C4Constants.h:49
char Texture[C4M_MaxName+1]
Definition: C4ToolsDlg.h:57
void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:696
const int32_t MNone
Definition: C4Constants.h:178
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
int32_t Density
Definition: C4Material.h:92
bool SelectBackTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:270
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:361
void NeedPreviewUpdate()
Definition: C4Console.cpp:702
bool SelectBackMaterial(const char *szMaterial, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:277
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
C4MaterialMap MaterialMap
Definition: C4Material.cpp:969
char BackMaterial[C4M_MaxName+1]
Definition: C4ToolsDlg.h:59
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SetTool ( int32_t  iTool,
bool  fTemp 
)

Definition at line 43 of file C4ToolsDlg.cpp.

References NeedPreviewUpdate(), SelectedTool, Tool, and UpdateToolCtrls().

Referenced by ResetAlternateTool(), SetAlternateTool(), SetLandscapeMode(), ToggleTool(), and ToolsDlgProc().

44 {
45  Tool=iTool;
46  if (!fTemp) SelectedTool = Tool;
49  return true;
50 }
void NeedPreviewUpdate()
Definition: C4Console.cpp:702
void UpdateToolCtrls()
Definition: C4Console.cpp:708
int32_t SelectedTool
Definition: C4ToolsDlg.h:53
int32_t Tool
Definition: C4ToolsDlg.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::ToggleIFT ( )
inline

Definition at line 74 of file C4ToolsDlg.h.

References SetIFT().

Referenced by C4Game::InitKeyboard().

74 { return !!SetIFT(!ModeIFT); }
bool SetIFT(bool fIFT)
Definition: C4ToolsDlg.cpp:131
bool ModeIFT
Definition: C4ToolsDlg.h:55

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::ToggleTool ( )
inline

Definition at line 71 of file C4ToolsDlg.h.

References SetTool().

Referenced by C4Game::InitKeyboard().

71 { return !!SetTool((Tool+1)%4, false); }
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:43
int32_t Tool
Definition: C4ToolsDlg.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::UpdateIFTControls ( )
protected

Definition at line 705 of file C4Console.cpp.

Referenced by Open(), and SetIFT().

705 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateLandscapeModeCtrls ( )

Definition at line 706 of file C4Console.cpp.

Referenced by Open(), and SetLandscapeMode().

706 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateTextures ( )
protected

Definition at line 707 of file C4Console.cpp.

Referenced by InitMaterialCtrls(), SetBackMaterial(), SetLandscapeMode(), and SetMaterial().

707 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateToolCtrls ( )
protected

Definition at line 708 of file C4Console.cpp.

Referenced by Open(), and SetTool().

708 {}

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4ConsoleGUI
friend

Definition at line 44 of file C4ToolsDlg.h.

Member Data Documentation

bool C4ToolsDlg::Active

Definition at line 52 of file C4ToolsDlg.h.

Referenced by Clear(), Default(), and Open().

bool C4ToolsDlg::ModeIFT

Definition at line 55 of file C4ToolsDlg.h.

Referenced by Default(), and SetIFT().

int32_t C4ToolsDlg::SelectedTool

Definition at line 53 of file C4ToolsDlg.h.

Referenced by Default(), ResetAlternateTool(), SetLandscapeMode(), and SetTool().


The documentation for this class was generated from the following files: