1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Drawing tools dialog for landscape editing in console mode */
19 
20 #ifndef INC_C4ToolsDlg
21 #define INC_C4ToolsDlg
22 
23 
24 #include "config/C4Constants.h"
25 #include "landscape/C4Landscape.h"
26 
27 const int32_t
28 	C4TLS_Brush  = 0,
29 	C4TLS_Line   = 1,
30 	C4TLS_Rect   = 2,
31 	C4TLS_Fill   = 3,
32 	C4TLS_Picker = 4;
33 
34 const int32_t
35 	C4TLS_GradeMax     = 50,
36 	C4TLS_GradeMin     = 1,
37 	C4TLS_GradeDefault = 5;
38 
39 #define C4TLS_MatSky "Sky"
40 
41 enum class LandscapeMode;
42 class C4ToolsDlg
43 {
44 	friend class C4ConsoleGUI;
45 	private:
46 	class State;
47 	State *state;
48 public:
49 	C4ToolsDlg();
50 	~C4ToolsDlg();
51 public:
52 	bool Active;
53 	int32_t Tool, SelectedTool;
54 	int32_t Grade;
55 	bool ModeIFT;
56 	char Material[C4M_MaxName+1];
57 	char Texture[C4M_MaxName+1];
58 	bool ModeBack; // If true, IFT is ignored and background material/texture is always used
59 	char BackMaterial[C4M_MaxName+1];
60 	char BackTexture[C4M_MaxName+1];
61 public:
62 	void Default();
63 	void Clear();
64 	bool PopTextures();
65 	bool PopMaterial();
66 	bool ChangeGrade(int32_t iChange);
67 	void NeedPreviewUpdate();
68 	bool Open();
69 	bool SetGrade(int32_t iGrade);
70 	bool SetTool(int32_t iTool, bool fTemp);
ToggleTool()71 	bool ToggleTool() { return !!SetTool((Tool+1)%4, false); }
72 	bool SetLandscapeMode(LandscapeMode iMode, bool flat_chunk_shapes, bool fThroughControl=false);
73 	bool SetIFT(bool fIFT);
ToggleIFT()74 	bool ToggleIFT() { return !!SetIFT(!ModeIFT); }
75 	bool SelectTexture(const char *szTexture, bool by_console_gui=false);
76 	bool SelectMaterial(const char *szMaterial, bool by_console_gui = false);
77 	bool SelectBackTexture(const char *szTexture, bool by_console_gui = false);
78 	bool SelectBackMaterial(const char *szMaterial, bool by_console_gui = false);
79 	void SetAlternateTool();
80 	void ResetAlternateTool();
IsGradedTool()81 	bool IsGradedTool() const { return Tool == C4TLS_Brush || Tool == C4TLS_Line || Tool == C4TLS_Fill; } // return whether Grade measure affects selected tool
82 protected:
83 	void AssertValidTexture();
84 	void AssertValidBackTexture();
85 	void LoadBitmaps();
86 	void EnableControls();
87 	void UpdateIFTControls();
88 	void InitGradeCtrl();
89 	void InitMaterialCtrls();
90 	void UpdateToolCtrls();
91 	void UpdateTextures();
92 	void SetColorPattern(const char *szMaterial, const char *szTexture);
93 public:
94 	void UpdateLandscapeModeCtrls();
95 	void SetTexture(const char *szTexture);
96 	void SetMaterial(const char *szMaterial);
97 	void SetBackTexture(const char *szTexture);
98 	void SetBackMaterial(const char *szMaterial);
99 };
100 
101 #endif //INC_C4ToolsDlg
102