1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design)
5 * Copyright (c) 2017-2022, The LegacyClonk 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/* Drawing tools dialog for landscape editing in console mode */
18
19#pragma once
20
21#include "C4Constants.h"
22
23#include <cstdint>
24
25#ifdef _WIN32
26#include "C4Windows.h"
27#endif
28
29#ifdef WITH_DEVELOPER_MODE
30#include <gtk/gtk.h>
31#endif
32
33const int32_t C4TLS_Brush = 0,
34 C4TLS_Line = 1,
35 C4TLS_Rect = 2,
36 C4TLS_Fill = 3,
37 C4TLS_Picker = 4;
38
39const int32_t C4TLS_GradeMax = 50,
40 C4TLS_GradeMin = 1,
41 C4TLS_GradeDefault = 5;
42
43#define C4TLS_MatSky "Sky"
44
45class C4ToolsDlg
46{
47#ifdef _WIN32
48 friend INT_PTR CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
49#endif
50
51public:
52 C4ToolsDlg();
53 ~C4ToolsDlg();
54
55public:
56 bool Active;
57#ifdef _WIN32
58 HWND hDialog;
59#ifndef USE_CONSOLE
60 class CStdGLCtx *pGLCtx; // rendering context for OpenGL
61#endif
62#elif defined(WITH_DEVELOPER_MODE)
63 GtkWidget *hbox;
64
65 GtkWidget *brush;
66 GtkWidget *line;
67 GtkWidget *rect;
68 GtkWidget *fill;
69 GtkWidget *picker;
70
71 GtkWidget *landscape_dynamic;
72 GtkWidget *landscape_static;
73 GtkWidget *landscape_exact;
74
75 GtkWidget *preview;
76 GtkWidget *scale;
77
78 GtkWidget *ift;
79 GtkWidget *no_ift;
80
81 GtkWidget *materials;
82 GtkWidget *textures;
83
84 gulong handlerBrush;
85 gulong handlerLine;
86 gulong handlerRect;
87 gulong handlerFill;
88 gulong handlerPicker;
89
90 gulong handlerDynamic;
91 gulong handlerStatic;
92 gulong handlerExact;
93
94 gulong handlerIft;
95 gulong handlerNoIft;
96
97 gulong handlerMaterials;
98 gulong handlerTextures;
99 gulong handlerScale;
100
101 gulong handlerHide;
102
103 static void OnButtonModeDynamic(GtkWidget *widget, gpointer data);
104 static void OnButtonModeStatic(GtkWidget *widget, gpointer data);
105 static void OnButtonModeExact(GtkWidget *widget, gpointer data);
106 static void OnButtonBrush(GtkWidget *widget, gpointer data);
107 static void OnButtonLine(GtkWidget *widget, gpointer data);
108 static void OnButtonRect(GtkWidget *widget, gpointer data);
109 static void OnButtonFill(GtkWidget *widget, gpointer data);
110 static void OnButtonPicker(GtkWidget *widget, gpointer data);
111 static void OnButtonIft(GtkWidget *widget, gpointer data);
112 static void OnButtonNoIft(GtkWidget *widget, gpointer data);
113 static void OnComboMaterial(GtkWidget *widget, gpointer data);
114 static void OnComboTexture(GtkWidget *widget, gpointer data);
115 static void OnGrade(GtkWidget *widget, gpointer data);
116 static void OnWindowHide(GtkWidget *widget, gpointer data);
117#endif
118 int32_t Tool, SelectedTool;
119 int32_t Grade;
120 bool ModeIFT;
121 char Material[C4M_MaxName + 1];
122 char Texture[C4M_MaxName + 1];
123
124protected:
125#ifdef _WIN32
126 HBITMAP hbmBrush, hbmBrush2;
127 HBITMAP hbmLine, hbmLine2;
128 HBITMAP hbmRect, hbmRect2;
129 HBITMAP hbmFill, hbmFill2;
130 HBITMAP hbmPicker, hbmPicker2;
131 HBITMAP hbmIFT;
132 HBITMAP hbmNoIFT;
133 HBITMAP hbmDynamic;
134 HBITMAP hbmStatic;
135 HBITMAP hbmExact;
136#endif
137
138public:
139 void Default();
140 void Clear();
141 bool PopTextures();
142 bool PopMaterial();
143 bool ChangeGrade(int32_t iChange);
144 void UpdatePreview();
145 bool Open();
146 bool SetGrade(int32_t iGrade);
147 bool SetTool(int32_t iTool, bool fTemp);
148 bool ToggleTool() { return !!SetTool(iTool: (Tool + 1) % 4, fTemp: false); }
149 bool SetLandscapeMode(int32_t iMode, bool fThroughControl = false);
150 bool SetIFT(bool fIFT);
151 bool ToggleIFT() { return !!SetIFT(!ModeIFT); }
152 bool SelectTexture(const char *szTexture);
153 bool SelectMaterial(const char *szMaterial);
154 void SetAlternateTool();
155 void ResetAlternateTool();
156
157protected:
158 void AssertValidTexture();
159 void LoadBitmaps();
160 void EnableControls();
161 void UpdateIFTControls();
162 void InitGradeCtrl();
163 void InitMaterialCtrls();
164 void UpdateToolCtrls();
165 void SetTexture(const char *szTexture);
166 void SetMaterial(const char *szMaterial);
167 void UpdateTextures();
168
169public:
170 void UpdateLandscapeModeCtrls();
171};
172