Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditColorDialog.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
using
Engine
;
3
using
Engine.Serialization
;
4
5
namespace
Game
{
6
public
class
EditColorDialog
:
Dialog
{
7
public
BevelledButtonWidget
m_rectangle
;
8
public
SliderWidget
m_sliderR
;
9
public
SliderWidget
m_sliderG
;
10
public
SliderWidget
m_sliderB
;
11
public
LabelWidget
m_label
;
12
public
ButtonWidget
m_okButton
;
13
public
ButtonWidget
m_cancelButton
;
14
15
public
Action<Color?>
m_handler
;
16
public
Color
m_color
;
17
public
const
string
fName
=
"EditColorDialog"
;
18
19
public
EditColorDialog
(
Color
color, Action<Color?> handler) {
20
WidgetsList
children =
Children
;
21
CanvasWidget
obj =
new
() {
22
Size
=
new
Vector2
(660f, 420f),
23
HorizontalAlignment
=
WidgetAlignment
.Center,
24
VerticalAlignment
=
WidgetAlignment
.Center,
25
Children
= {
new
BevelledRectangleWidget
{
Style
=
ContentManager
.
Get
<XElement>(
"Styles/DialogArea"
) } }
26
};
27
WidgetsList
children2 = obj.
Children
;
28
StackPanelWidget
obj2 =
new
() {
29
Direction =
LayoutDirection
.Vertical,
30
Margin
=
new
Vector2
(15f),
31
HorizontalAlignment
=
WidgetAlignment
.Center,
32
Children
= {
33
new
LabelWidget
{ Text =
LanguageControl
.
Get
(
fName
, 1),
HorizontalAlignment
=
WidgetAlignment.Center
},
34
new
CanvasWidget
{
Size
=
new
Vector2
(0f, 1f / 0f) }
35
}
36
};
37
WidgetsList
children3 = obj2.
Children
;
38
StackPanelWidget
obj3 =
new
() { Direction =
LayoutDirection.Horizontal
};
39
WidgetsList
children4 = obj3.
Children
;
40
StackPanelWidget
obj4 =
new
() { Direction =
LayoutDirection
.Vertical,
VerticalAlignment
=
WidgetAlignment.Center
};
41
WidgetsList
children5 = obj4.
Children
;
42
StackPanelWidget
obj5 =
new
() {
43
Direction =
LayoutDirection
.Horizontal,
44
HorizontalAlignment
=
WidgetAlignment
.Far,
45
Margin
=
new
Vector2
(0f, 10f),
46
Children
= {
47
new
LabelWidget
{ Text =
LanguageControl
.
Get
(
fName
, 2),
Color
=
Color
.
Gray
,
VerticalAlignment
=
WidgetAlignment.Center
},
48
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) }
49
}
50
};
51
WidgetsList
children6 = obj5.
Children
;
52
SliderWidget
obj6 =
new
() {
53
Size
=
new
Vector2
(300f, 50f), IsLabelVisible =
false
, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName =
""
54
};
55
SliderWidget
widget = obj6;
56
m_sliderR
= obj6;
57
children6.
Add
(widget);
58
children5.
Add
(obj5);
59
WidgetsList
children7 = obj4.
Children
;
60
StackPanelWidget
obj7 =
new
() {
61
Direction =
LayoutDirection
.Horizontal,
62
HorizontalAlignment
=
WidgetAlignment
.Far,
63
Margin
=
new
Vector2
(0f, 10f),
64
Children
= {
65
new
LabelWidget
{ Text =
LanguageControl
.
Get
(
fName
, 3),
Color
=
Color
.
Gray
,
VerticalAlignment
=
WidgetAlignment.Center
},
66
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) }
67
}
68
};
69
WidgetsList
children8 = obj7.
Children
;
70
SliderWidget
obj8 =
new
() {
71
Size
=
new
Vector2
(300f, 50f), IsLabelVisible =
false
, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName =
""
72
};
73
widget = obj8;
74
m_sliderG
= obj8;
75
children8.
Add
(widget);
76
children7.
Add
(obj7);
77
WidgetsList
children9 = obj4.
Children
;
78
StackPanelWidget
obj9 =
new
() {
79
Direction =
LayoutDirection
.Horizontal,
80
HorizontalAlignment
=
WidgetAlignment
.Far,
81
Margin
=
new
Vector2
(0f, 10f),
82
Children
= {
83
new
LabelWidget
{ Text =
LanguageControl
.
Get
(
fName
, 4),
Color
=
Color
.
Gray
,
VerticalAlignment
=
WidgetAlignment.Center
},
84
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) }
85
}
86
};
87
WidgetsList
children10 = obj9.
Children
;
88
SliderWidget
obj10 =
new
() {
89
Size
=
new
Vector2
(300f, 50f), IsLabelVisible =
false
, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName =
""
90
};
91
widget = obj10;
92
m_sliderB
= obj10;
93
children10.
Add
(widget);
94
children9.
Add
(obj9);
95
children4.
Add
(obj4);
96
obj3.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(20f, 0f) });
97
WidgetsList
children11 = obj3.
Children
;
98
CanvasWidget
canvasWidget =
new
();
99
WidgetsList
children12 = canvasWidget.
Children
;
100
BevelledButtonWidget
obj11 =
new
() {
101
Size
=
new
Vector2
(200f, 240f),
102
AmbientLight = 1f,
103
HorizontalAlignment
=
WidgetAlignment
.Center,
104
VerticalAlignment
=
WidgetAlignment.Center
105
};
106
BevelledButtonWidget
widget2 = obj11;
107
m_rectangle
= obj11;
108
children12.
Add
(widget2);
109
WidgetsList
children13 = canvasWidget.
Children
;
110
LabelWidget
obj12 =
new
() {
HorizontalAlignment
=
WidgetAlignment
.Center,
VerticalAlignment
=
WidgetAlignment.Center
};
111
LabelWidget
widget3 = obj12;
112
m_label
= obj12;
113
children13.
Add
(widget3);
114
children11.
Add
(canvasWidget);
115
children3.
Add
(obj3);
116
obj2.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(0f, 1f / 0f) });
117
WidgetsList
children14 = obj2.
Children
;
118
StackPanelWidget
obj13 =
new
() { Direction =
LayoutDirection
.Horizontal,
HorizontalAlignment
=
WidgetAlignment.Center
};
119
WidgetsList
children15 = obj13.
Children
;
120
BevelledButtonWidget
obj14 =
new
() {
Size
=
new
Vector2
(160f, 60f), Text =
LanguageControl.Ok
};
121
ButtonWidget
widget4 = obj14;
122
m_okButton
= obj14;
123
children15.
Add
(widget4);
124
obj13.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(50f, 0f) });
125
WidgetsList
children16 = obj13.
Children
;
126
BevelledButtonWidget
obj15 =
new
() {
Size
=
new
Vector2
(160f, 60f), Text =
LanguageControl.Cancel
};
127
widget4 = obj15;
128
m_cancelButton
= obj15;
129
children16.
Add
(widget4);
130
children14.
Add
(obj13);
131
children2.
Add
(obj2);
132
children.
Add
(obj);
133
m_handler
= handler;
134
m_color
= color;
135
UpdateControls
();
136
}
137
138
public
override
void
Update
() {
139
if
(
m_rectangle
.IsClicked) {
140
DialogsManager
.
ShowDialog
(
141
this
,
142
new
TextBoxDialog
(
143
LanguageControl
.
Get
(
fName
, 5),
144
GetColorString
(),
145
20,
146
delegate(
string
s) {
147
if
(s !=
null
) {
148
try
{
149
m_color.RGB =
HumanReadableConverter
.
ConvertFromString
<
Color
>(s);
150
}
151
catch
{
152
DialogsManager
.
ShowDialog
(
153
this
,
154
new
MessageDialog
(
155
LanguageControl
.
Get
(
fName
, 6),
156
LanguageControl
.
Get
(
fName
, 7),
157
LanguageControl
.
Ok
,
158
null
,
159
null
160
)
161
);
162
}
163
}
164
}
165
)
166
);
167
}
168
if
(
m_sliderR
.IsSliding) {
169
m_color.R = (byte)
m_sliderR
.Value;
170
}
171
if
(
m_sliderG
.IsSliding) {
172
m_color.G = (byte)
m_sliderG
.Value;
173
}
174
if
(
m_sliderB
.IsSliding) {
175
m_color.B = (byte)
m_sliderB
.Value;
176
}
177
if
(
m_okButton
.IsClicked) {
178
Dismiss
(
m_color
);
179
}
180
if
(
Input
.Cancel
181
||
m_cancelButton
.IsClicked) {
182
Dismiss
(
null
);
183
}
184
UpdateControls
();
185
}
186
187
public
virtual
void
UpdateControls
() {
188
m_rectangle.CenterColor =
m_color
;
189
m_sliderR.Value =
m_color
.R;
190
m_sliderG.Value =
m_color
.G;
191
m_sliderB.Value =
m_color
.B;
192
m_label.Text =
GetColorString
();
193
}
194
195
public
string
GetColorString
() => $
"#{m_color.R:X2}{m_color.G:X2}{m_color.B:X2}"
;
196
197
public
void
Dismiss
(
Color
? result) {
198
DialogsManager
.
HideDialog
(
this
);
199
m_handler
?.Invoke(result);
200
}
201
}
202
}
Engine.Serialization.HumanReadableConverter
定义
HumanReadableConverter.cs:5
Engine.Serialization.HumanReadableConverter.ConvertFromString
static object ConvertFromString(Type type, string data)
定义
HumanReadableConverter.cs:55
Game.BevelledButtonWidget
定义
BevelledButtonWidget.cs:6
Game.BevelledRectangleWidget
定义
BevelledRectangleWidget.cs:5
Game.ButtonWidget
定义
ButtonWidget.cs:5
Game.CanvasWidget
定义
CanvasWidget.cs:4
Game.CanvasWidget.Size
Vector2 Size
定义
CanvasWidget.cs:7
Game.ContainerWidget.Children
readonly WidgetsList Children
定义
ContainerWidget.cs:5
Game.ContentManager
定义
ContentManager.cs:50
Game.ContentManager.Get
static object Get(Type type, string name)
定义
ContentManager.cs:70
Game.Dialog.Dialog
Dialog()
定义
Dialog.cs:5
Game.DialogsManager
定义
DialogsManager.cs:4
Game.DialogsManager.HideDialog
static void HideDialog(Dialog dialog)
定义
DialogsManager.cs:58
Game.DialogsManager.ShowDialog
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
定义
DialogsManager.cs:35
Game.EditColorDialog.m_label
LabelWidget m_label
定义
EditColorDialog.cs:11
Game.EditColorDialog.m_handler
Action< Color?> m_handler
定义
EditColorDialog.cs:15
Game.EditColorDialog.m_rectangle
BevelledButtonWidget m_rectangle
定义
EditColorDialog.cs:7
Game.EditColorDialog.fName
const string fName
定义
EditColorDialog.cs:17
Game.EditColorDialog.m_okButton
ButtonWidget m_okButton
定义
EditColorDialog.cs:12
Game.EditColorDialog.m_cancelButton
ButtonWidget m_cancelButton
定义
EditColorDialog.cs:13
Game.EditColorDialog.m_sliderB
SliderWidget m_sliderB
定义
EditColorDialog.cs:10
Game.EditColorDialog.Dismiss
void Dismiss(Color? result)
定义
EditColorDialog.cs:197
Game.EditColorDialog.m_sliderR
SliderWidget m_sliderR
定义
EditColorDialog.cs:8
Game.EditColorDialog.GetColorString
string GetColorString()
定义
EditColorDialog.cs:195
Game.EditColorDialog.m_sliderG
SliderWidget m_sliderG
定义
EditColorDialog.cs:9
Game.EditColorDialog.m_color
Color m_color
定义
EditColorDialog.cs:16
Game.EditColorDialog.EditColorDialog
EditColorDialog(Color color, Action< Color?> handler)
定义
EditColorDialog.cs:19
Game.EditColorDialog.Update
override void Update()
定义
EditColorDialog.cs:138
Game.EditColorDialog.UpdateControls
virtual void UpdateControls()
定义
EditColorDialog.cs:187
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Ok
static string Ok
定义
LanguageControl.cs:11
Game.LanguageControl.Cancel
static string Cancel
定义
LanguageControl.cs:12
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.MessageDialog
定义
MessageDialog.cs:5
Game.SliderWidget
定义
SliderWidget.cs:6
Game.StackPanelWidget
定义
StackPanelWidget.cs:4
Game.TextBoxDialog
定义
TextBoxDialog.cs:4
Game.Widget.VerticalAlignment
virtual WidgetAlignment VerticalAlignment
定义
Widget.cs:445
Game.Widget.Margin
virtual Vector2 Margin
定义
Widget.cs:408
Game.Widget.HorizontalAlignment
virtual WidgetAlignment HorizontalAlignment
定义
Widget.cs:443
Game.Widget.Style
XElement Style
定义
Widget.cs:464
Game.WidgetsList
定义
WidgetsList.cs:4
Game.WidgetsList.Add
void Add(Widget widget)
定义
WidgetsList.cs:55
Engine.Input
定义
CursorType.cs:1
Engine.Serialization
定义
Archive.cs:4
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.LayoutDirection
LayoutDirection
定义
LayoutDirection.cs:2
Game.LayoutDirection.Horizontal
@ Horizontal
定义
LayoutDirection.cs:3
Game.WidgetAlignment
WidgetAlignment
定义
WidgetAlignment.cs:2
Game.WidgetAlignment.Center
@ Center
定义
WidgetAlignment.cs:4
Engine.Color
定义
Color.cs:2
Engine.Color.Gray
static Color Gray
定义
Color.cs:11
Engine.Vector2
定义
Vector2.cs:2
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
EditColorDialog.cs
制作者
1.16.1