Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
ScriptedControls.h
1/* Renegade Scripts.dll
2 Copyright 2022 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12
13#pragma once
14
15#include "engine_string.h"
16#include "Vector3.h"
17#include "ScriptedControlClass.h"
18
19typedef enum
20{
21 TEXTSTYLE_BODY,
22 TEXTSTYLE_TITLE,
23 TEXTSTYLE_LARGE_CONTROL,
24 TEXTSTYLE_TOOLTIP
25} TextStyle;
26
27typedef enum
28{
29 TEXTORIENTATION_LEFT,
30 TEXTORIENTATION_CENTER,
31 TEXTORIENTATION_RIGHT
32} TextOrientation;
33
34typedef enum
35{
36 BUTTONSTYLE_BORDERED,
37 BUTTONSTYLE_TITLE,
38 BUTTONSTYLE_IMAGE
39} ButtonStyle;
40
41/********************************************************************************/
42
43class ScriptedLabelControlClass : public ScriptedControlClass
44{
45public:
46 ScriptedLabelControlClass(int ctl_id);
47
48 virtual ControlType Get_Control_Type() { return CONTROLTYPE_LABEL; }
49 virtual ScriptedLabelControlClass* As_ScriptedLabelControlClass() { return this; }
50
51 const WideStringClass& Get_Label_Text() { return text; }
52 void Set_Label_Text(const wchar_t* newText) { text = newText; Set_Dirty(true); }
53 const Vector3& Get_Text_Color() { return color; }
54 void Set_Text_Color(Vector3& newColor) { color = newColor; Set_Dirty(true); }
55 void Set_Text_Color(int r, int g, int b) { color.X = r / 255.f; color.Y = g / 255.f; color.Z = b / 255.f; Set_Dirty(true); }
56 TextStyle Get_Style() { return style; }
57 void Set_Style(TextStyle newStyle) { style = newStyle; Set_Dirty(true); }
58 TextOrientation Get_Orientation() { return orientation; }
59 void Set_Orientation(TextOrientation newOrientation) { orientation = newOrientation; Set_Dirty(true); }
60private:
61 WideStringClass text;
62 Vector3 color;
63 TextStyle style;
64 TextOrientation orientation;
65};
66
67/********************************************************************************/
68
69class ScriptedImageControlClass : public ScriptedControlClass
70{
71public:
72 ScriptedImageControlClass(int ctl_id);
73
74 virtual ControlType Get_Control_Type() { return CONTROLTYPE_IMAGE; }
75 virtual ScriptedImageControlClass* As_ScriptedImageControlClass() { return this; }
76
77 const StringClass& Get_Image_Name() { return imageName; }
78 void Set_Image_Name(const char* newName) { imageName = newName; Set_Dirty(true); }
79private:
80 StringClass imageName;
81};
82
83/********************************************************************************/
84
85class ScriptedButtonControlClass : public ScriptedControlClass
86{
87public:
88 ScriptedButtonControlClass(int ctl_id);
89
90 virtual ControlType Get_Control_Type() { return CONTROLTYPE_BUTTON; }
91 virtual ScriptedButtonControlClass* As_ScriptedButtonControlClass() { return this; }
92
93 const WideStringClass& Get_Button_Text() { return buttonText; }
94 void Set_Button_Text(const wchar_t* newText) { buttonText = newText; Set_Dirty(true); }
95 const StringClass& Get_Button_Up_Image_Name() { return imageNameUp; }
96 void Set_Button_Up_Image_Name(const char* newName) { imageNameUp = newName; Set_Dirty(true); }
97 const StringClass& Get_Button_Down_Image_Name() { return imageNameDn; }
98 void Set_Button_Down_Image_Name(const char* newName) { imageNameDn = newName; Set_Dirty(true); }
99 ButtonStyle Get_Button_Style() { return style; }
100 void Set_Button_Style(ButtonStyle newStyle) { style = newStyle; Set_Dirty(true); }
101private:
102 WideStringClass buttonText;
103 StringClass imageNameUp;
104 StringClass imageNameDn;
105 ButtonStyle style;
106};
107
108/********************************************************************************/
109
110class ScriptedTextAreaControlClass : public ScriptedControlClass
111{
112public:
113 ScriptedTextAreaControlClass(int ctl_id);
114
115 virtual ControlType Get_Control_Type() { return CONTROLTYPE_TEXTAREA; }
116 virtual ScriptedTextAreaControlClass* As_ScriptedTextAreaControlClass() { return this; }
117
118 int Get_Text_Limit() { return textLimit; }
119 void Set_Text_Limit(int newLimit) { textLimit = newLimit; Set_Dirty(true); }
120 bool Is_Password_Field() { return isPassword; }
121 void Set_Password_Field(bool password) { isPassword = password; Set_Dirty(true); }
122 bool Is_Numeric_Field() { return isNumeric; }
123 void Set_Numeric_Field(bool numeric) { isNumeric = numeric; Set_Dirty(true); }
124 bool Is_Automatic_Horizontal_Scroll() { return autoHorizontalScroll; }
125 void Set_Automatic_Horizontal_Scroll(bool scroll) { autoHorizontalScroll = scroll; Set_Dirty(true); }
126 const WideStringClass& Get_Text() { return textareaText; }
127 void Set_Text(const wchar_t* newText) { textareaText = newText; Set_Dirty(true); }
128 int Get_Text_Length() { return textareaText.Get_Length(); }
129private:
130 int textLimit;
131 bool isNumeric;
132 bool isPassword;
133 bool autoHorizontalScroll;
134 WideStringClass textareaText;
135};
136
137/********************************************************************************/
138
139class ScriptedCheckBoxControlClass : public ScriptedControlClass
140{
141public:
142 ScriptedCheckBoxControlClass(int ctl_id);
143
144 virtual ControlType Get_Control_Type() { return CONTROLTYPE_CHECKBOX; }
145 virtual ScriptedCheckBoxControlClass* As_ScriptedCheckBoxControlClass() { return this; }
146
147 const WideStringClass& Get_Text() { return checkboxText; }
148 void Set_Text(const wchar_t* newText) { checkboxText = newText; Set_Dirty(true); }
149 bool Is_Checked() { return isChecked; }
150 void Set_Checked(bool checked) { isChecked = checked; Set_Dirty(true); }
151private:
152 WideStringClass checkboxText;
153 bool isChecked;
154};
155
156/********************************************************************************/
157
158class ScriptedComboBoxControlClass : public ScriptedControlClass
159{
160public:
161 ScriptedComboBoxControlClass(int ctl_id);
162
163 virtual ControlType Get_Control_Type() { return CONTROLTYPE_COMBOBOX; }
164 virtual ScriptedComboBoxControlClass* As_ScriptedComboBoxControlClass() { return this; }
165
166 int Get_Selected_Index() { return selectedIndex; }
167 void Set_Selected_Index(int newIndex) { selectedIndex = newIndex; Set_Dirty(true); }
168 void Add_Item(const wchar_t* item) { options.Add(item); Set_Dirty(true); }
169 void Insert_Item(int index, const wchar_t* item) { options.Insert(index, item); Set_Dirty(true); }
170 int Get_Item_Count() { return options.Count(); }
171 const WideStringClass& Get_Item(int index) { return options[index]; }
172 const WideStringClass& Get_Selected_Item_Text() { return options[selectedIndex]; }
173 void Remove_Item(int index) { options.Delete(index); Set_Dirty(true); }
174 void Remove_Item(const WideStringClass& item) { options.DeleteObj(item); Set_Dirty(true); }
175 void Clear_Items() { options.Delete_All(); Set_Dirty(true); }
176private:
177 DynamicVectorClass<WideStringClass> options;
178 int selectedIndex;
179};
180
181/********************************************************************************/
182
183class ScriptedSliderControlClass : public ScriptedControlClass
184{
185public:
186 ScriptedSliderControlClass(int ctl_id);
187
188 virtual ControlType Get_Control_Type() { return CONTROLTYPE_SLIDER; }
189 virtual ScriptedSliderControlClass* As_ScriptedSliderControlClass() { return this; }
190
191 int Get_Minimum() { return minVal; }
192 void Set_Minimum(int newMin) { minVal = newMin; Set_Dirty(true); }
193 int Get_Maximum() { return maxVal; }
194 void Set_Maximum(int newMax) { maxVal = newMax; Set_Dirty(true); }
195 int Get_Value() { return value; }
196 void Set_Value(int newValue) { value = newValue; Set_Dirty(true); }
197private:
198 int minVal;
199 int maxVal;
200 int value;
201};
202
203/********************************************************************************/
204
205class ScriptedProgressBarControlClass : public ScriptedControlClass
206{
207public:
208 ScriptedProgressBarControlClass(int ctl_id);
209
210 virtual ControlType Get_Control_Type() { return CONTROLTYPE_PROGRESSBAR; }
211 virtual ScriptedProgressBarControlClass* As_ScriptedProgressBarControlClass() { return this; }
212
213 int Get_Minimum() { return minVal; }
214 void Set_Minimum(int newMin) { minVal = newMin; Set_Dirty(true); }
215 int Get_Maximum() { return maxVal; }
216 void Set_Maximum(int newMax) { maxVal = newMax; Set_Dirty(true); }
217 int Get_Progress() { return progress; }
218 void Set_Progress(int newProgress) { progress = newProgress > maxVal ? maxVal : newProgress < minVal ? minVal : newProgress; Set_Dirty(true); }
219 int Get_Step_Count() { return stepCount; }
220 void Set_Step_Count(int newStep) { stepCount = newStep; /* don't need to set dirty here */ }
221 void Increment_Value() { progress += progress + stepCount > maxVal ? maxVal - progress : stepCount; Set_Dirty(true); }
222 void Decrement_Value() { progress -= progress - stepCount < minVal ? progress - minVal : stepCount; Set_Dirty(true); }
223
224private:
225 int minVal;
226 int maxVal;
227 int progress;
228 int stepCount;
229};
230
231/********************************************************************************/
232
233class ScriptedHealthBarControlClass : public ScriptedControlClass
234{
235public:
236 ScriptedHealthBarControlClass(int ctl_id);
237
238 virtual ControlType Get_Control_Type() { return CONTROLTYPE_HEALTHBAR; }
239 virtual ScriptedHealthBarControlClass* As_ScriptedHealthBarControlClass() { return this; }
240
241 float Get_Life() { return life; }
242 void Set_Life(float newLife) { life = WWMath::Clamp(newLife); Set_Dirty(true); }
243
244private:
245 float life;
246};
247
248/********************************************************************************/