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 235 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().

236 {
237  // Static map mode only
238  if (::Landscape.GetMode() != LandscapeMode::Static) return;
239  // Ignore if not enabled
240  if (!ModeBack) return;
241  // Ignore if sky
242  if (SEqual(BackMaterial,C4TLS_MatSky)) return;
243  // Current material-texture valid
244  if (::TextureMap.GetIndex(BackMaterial,BackTexture,false)) return;
245  // Find valid material-texture
246  const char *szTexture;
247  for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
248  {
249  if (::TextureMap.GetIndex(BackMaterial,szTexture,false))
250  { SelectBackTexture(szTexture); return; }
251  }
252  // No valid texture found
253 }
C4TextureMap TextureMap
Definition: C4Texture.cpp:585
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:423
C4Landscape Landscape
LandscapeMode GetMode() const
bool SelectBackTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:269
bool ModeBack
Definition: C4ToolsDlg.h:58
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:503
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 215 of file C4ToolsDlg.cpp.

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

Referenced by SetMaterial().

216 {
217 #ifndef WITH_QT_EDITOR // Qt Editor textures are always valid, because MatTex entries are selected directly
218  // Static map mode only
219  if (::Landscape.GetMode() != LandscapeMode::Static) return;
220  // Ignore if sky
221  if (SEqual(Material,C4TLS_MatSky)) return;
222  // Current material-texture valid
223  if (::TextureMap.GetIndex(Material,Texture,false)) return;
224  // Find valid material-texture
225  const char *szTexture;
226  for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
227  {
228  if (::TextureMap.GetIndex(Material,szTexture,false))
229  { SelectTexture(szTexture); return; }
230  }
231  // No valid texture found
232 #endif
233 }
C4TextureMap TextureMap
Definition: C4Texture.cpp:585
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:423
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:503
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
bool SelectTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:255

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 172 of file C4ToolsDlg.cpp.

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

Referenced by C4Game::InitKeyboard().

173 {
176  InitGradeCtrl();
177  return true;
178 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:46
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:706
void NeedPreviewUpdate()
Definition: C4Console.cpp:707

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:671

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:129
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 705 of file C4Console.cpp.

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

705 {}

Here is the caller graph for this function:

void C4ToolsDlg::InitGradeCtrl ( )
protected

Definition at line 706 of file C4Console.cpp.

Referenced by ChangeGrade(), and Open().

706 {}

Here is the caller graph for this function:

void C4ToolsDlg::InitMaterialCtrls ( )
protected

Definition at line 51 of file C4ToolsDlg.cpp.

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

Referenced by Open().

52 {
53  // Materials
55  // Textures
57 }
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgInitMaterialCtrls(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:698
void UpdateTextures()
Definition: C4Console.cpp:712

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 707 of file C4Console.cpp.

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

707 {}

Here is the caller graph for this function:

bool C4ToolsDlg::Open ( )

Definition at line 27 of file C4ToolsDlg.cpp.

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

Referenced by C4EditCursor::OpenPropTools().

28 {
29  // Create dialog window
30  Console.ToolsDlgOpen(this);
31  Active = true;
32  // Update contols
33  InitGradeCtrl();
39  return true;
40 }
C4Console Console
Definition: C4Globals.cpp:45
void InitMaterialCtrls()
Definition: C4ToolsDlg.cpp:51
bool Active
Definition: C4ToolsDlg.h:52
void InitGradeCtrl()
Definition: C4Console.cpp:706
void UpdateIFTControls()
Definition: C4Console.cpp:710
bool ToolsDlgOpen(class C4ToolsDlg *dlg)
Definition: C4Console.cpp:699
void UpdateToolCtrls()
Definition: C4Console.cpp:713
void UpdateLandscapeModeCtrls()
Definition: C4Console.cpp:711
void EnableControls()
Definition: C4Console.cpp:705

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::PopMaterial ( )

Definition at line 708 of file C4Console.cpp.

Referenced by C4Game::InitKeyboard().

708 {return 0;}

Here is the caller graph for this function:

bool C4ToolsDlg::PopTextures ( )

Definition at line 709 of file C4Console.cpp.

Referenced by C4Game::InitKeyboard().

709 {return 0;}

Here is the caller graph for this function:

void C4ToolsDlg::ResetAlternateTool ( )

Definition at line 289 of file C4ToolsDlg.cpp.

References SelectedTool, and SetTool().

Referenced by C4EditCursor::AltUp().

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

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 276 of file C4ToolsDlg.cpp.

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

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

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

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 269 of file C4ToolsDlg.cpp.

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

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

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

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 262 of file C4ToolsDlg.cpp.

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

Referenced by C4EditCursor::ApplyToolPicker().

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

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 255 of file C4ToolsDlg.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ToolsDlg::SetAlternateTool ( )

Definition at line 283 of file C4ToolsDlg.cpp.

References C4TLS_Picker, and SetTool().

Referenced by C4EditCursor::AltDown().

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

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 105 of file C4ToolsDlg.cpp.

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

Referenced by SelectBackMaterial(), and ToolsDlgProc().

106 {
107  ModeBack = true;
108 
109  SCopy(szMaterial,BackMaterial,C4M_MaxName);
111  EnableControls();
113 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
const int C4M_MaxName
Definition: C4Constants.h:49
void AssertValidBackTexture()
Definition: C4ToolsDlg.cpp:235
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:712
void EnableControls()
Definition: C4Console.cpp:705

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 115 of file C4ToolsDlg.cpp.

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

Referenced by SelectBackTexture(), and ToolsDlgProc().

116 {
117  ModeBack = true;
118 
119  // assert valid (for separator selection)
120  if (!::TextureMap.GetTexture(szTexture))
121  {
122  // ensure correct texture is in dlg
123  Console.ToolsDlgSelectBackTexture(this, szTexture);
124  return;
125  }
126 
127  SCopy(szTexture,BackTexture,C4M_MaxName);
128 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
C4Console Console
Definition: C4Globals.cpp:45
void ToolsDlgSelectBackTexture(C4ToolsDlg *dlg, const char *texture)
Definition: C4Console.cpp:703
C4TextureMap TextureMap
Definition: C4Texture.cpp:585
const int C4M_MaxName
Definition: C4Constants.h:49
bool ModeBack
Definition: C4ToolsDlg.h:58
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:503
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 161 of file C4ToolsDlg.cpp.

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

Definition at line 165 of file C4ToolsDlg.cpp.

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

Referenced by ToolsDlgProc().

166 {
169  return true;
170 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:46
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:707

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ToolsDlg::SetIFT ( bool  fIFT)

Definition at line 130 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().

131 {
132  ModeBack = false;
133  if (fIFT) ModeIFT = 1; else ModeIFT=0;
134 
135  // Keep sensible default values in BackMaterial / BackTexture
136  if (ModeIFT == 0)
137  {
139  }
140  else
141  {
143  int32_t index = ::TextureMap.GetIndexMatTex(Material);
144  if (index != -1)
145  {
146  BYTE bg_index = ::TextureMap.DefaultBkgMatTex(index);
147  const C4TexMapEntry* entry = ::TextureMap.GetEntry(bg_index);
148  if (entry != nullptr)
149  {
152  }
153  }
154  }
155 
158  return true;
159 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
BYTE DefaultBkgMatTex(BYTE fg) const
Definition: C4Texture.cpp:513
uint8_t BYTE
C4TextureMap TextureMap
Definition: C4Texture.cpp:585
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:710
bool ModeBack
Definition: C4ToolsDlg.h:58
void NeedPreviewUpdate()
Definition: C4Console.cpp:707
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:450
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 180 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().

181 {
182  auto last_mode = ::Landscape.GetMode();
183  auto last_flat_chunk_shapes = ::Game.C4S.Landscape.FlatChunkShapes;
184  // Exact to static: confirm data loss warning
185  if (last_mode == LandscapeMode::Exact)
186  if (mode == LandscapeMode::Static)
187  if (!fThroughControl)
188  if (!Console.Message(LoadResStr("IDS_CNS_EXACTTOSTATIC"), true))
189  return false;
190  // send as control
191  if (!fThroughControl)
192  {
193  ::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, mode, flat_chunk_shapes ? 1 : 0), CDT_Decide);
194  return true;
195  }
196  // Set landscape mode
197  ::Game.C4S.Landscape.FlatChunkShapes = flat_chunk_shapes;
198  ::Landscape.SetMode(mode);
199  // Exact to static: redraw landscape from map
200  if (last_mode == LandscapeMode::Exact || (last_flat_chunk_shapes != flat_chunk_shapes))
201  if (mode == LandscapeMode::Static)
203  // Assert valid tool
204  if (mode != LandscapeMode::Exact)
205  if (SelectedTool == C4TLS_Fill)
206  SetTool(C4TLS_Brush, false);
207  // Update controls
209  EnableControls();
210  UpdateTextures();
211  // Success
212  return true;
213 }
C4Console Console
Definition: C4Globals.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:76
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:711
int32_t SelectedTool
Definition: C4ToolsDlg.h:53
bool SetTool(int32_t iTool, bool fTemp)
Definition: C4ToolsDlg.cpp:42
void UpdateTextures()
Definition: C4Console.cpp:712
bool Message(const char *szMessage, bool fQuery=false)
Definition: C4Console.cpp:297
void EnableControls()
Definition: C4Console.cpp:705

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 59 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().

60 {
61  SCopy(szMaterial,Material,C4M_MaxName);
66  if (ModeBack && SEqual(szMaterial, C4TLS_MatSky))
68 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
void AssertValidTexture()
Definition: C4ToolsDlg.cpp:215
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
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:707
bool SelectBackMaterial(const char *szMaterial, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:276
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
void UpdateTextures()
Definition: C4Console.cpp:712
void EnableControls()
Definition: C4Console.cpp:705

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 70 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().

71 {
72  // assert valid (for separator selection)
73  if (!::TextureMap.GetTexture(szTexture))
74  {
75  // ensure correct texture is in dlg
76  Console.ToolsDlgSelectTexture(this, szTexture);
77  return;
78  }
79 
80  SCopy(szTexture,Texture,C4M_MaxName);
82 
83  // If the front texture changes, reset the background texture
84  // to something sensible.
85  int32_t mat = MaterialMap.Get(Material);
86  if (mat != MNone)
87  {
88  const C4Material* material = &MaterialMap.Map[mat];
89  if(DensitySemiSolid(material->Density))
90  {
92  {
93  SelectBackMaterial("Tunnel");
94  SelectBackTexture("tunnel");
95  }
96  }
97  else
98  {
101  }
102  }
103 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
C4Console Console
Definition: C4Globals.cpp:45
C4Material * Map
Definition: C4Material.h:171
C4TextureMap TextureMap
Definition: C4Texture.cpp:585
bool DensitySemiSolid(int32_t dens)
Definition: C4Landscape.h:204
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
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:701
const int32_t MNone
Definition: C4Constants.h:178
char Material[C4M_MaxName+1]
Definition: C4ToolsDlg.h:56
int32_t Density
Definition: C4Material.h:94
bool SelectBackTexture(const char *szTexture, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:269
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:362
void NeedPreviewUpdate()
Definition: C4Console.cpp:707
bool SelectBackMaterial(const char *szMaterial, bool by_console_gui=false)
Definition: C4ToolsDlg.cpp:276
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:503
C4MaterialMap MaterialMap
Definition: C4Material.cpp:970
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 42 of file C4ToolsDlg.cpp.

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

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

43 {
44  Tool=iTool;
45  if (!fTemp) SelectedTool = Tool;
48  return true;
49 }
void NeedPreviewUpdate()
Definition: C4Console.cpp:707
void UpdateToolCtrls()
Definition: C4Console.cpp:713
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:130
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:42
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 710 of file C4Console.cpp.

Referenced by Open(), and SetIFT().

710 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateLandscapeModeCtrls ( )

Definition at line 711 of file C4Console.cpp.

Referenced by Open(), and SetLandscapeMode().

711 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateTextures ( )
protected

Definition at line 712 of file C4Console.cpp.

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

712 {}

Here is the caller graph for this function:

void C4ToolsDlg::UpdateToolCtrls ( )
protected

Definition at line 713 of file C4Console.cpp.

Referenced by Open(), and SetTool().

713 {}

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: