Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditPaletteDialog.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
using
Engine
;
3
4
namespace
Game
{
5
public
class
EditPaletteDialog
:
Dialog
{
6
public
ContainerWidget
m_listPanel
;
7
public
ButtonWidget
m_okButton
;
8
public
ButtonWidget
m_cancelButton
;
9
public
LinkWidget
[]
m_labels
=
new
LinkWidget
[16];
10
public
BevelledButtonWidget
[]
m_rectangles
=
new
BevelledButtonWidget
[16];
11
public
ButtonWidget
[]
m_resetButtons
=
new
ButtonWidget
[16];
12
13
public
WorldPalette
m_palette
;
14
public
WorldPalette
m_tmpPalette
;
15
public
const
string
fName
=
"EditPaletteDialog"
;
16
17
public
EditPaletteDialog
(
WorldPalette
palette) {
18
XElement node =
ContentManager
.
Get
<XElement>(
"Dialogs/EditPaletteDialog"
);
19
LoadContents
(
this
, node);
20
m_listPanel
=
Children
.Find<
ContainerWidget
>(
"EditPaletteDialog.ListPanel"
);
21
m_okButton
=
Children
.Find<
ButtonWidget
>(
"EditPaletteDialog.OK"
);
22
m_cancelButton
=
Children
.Find<
ButtonWidget
>(
"EditPaletteDialog.Cancel"
);
23
for
(
int
i = 0; i < 16; i++) {
24
StackPanelWidget
obj =
new
() {
25
Direction =
LayoutDirection
.Horizontal,
26
Children
= {
27
new
CanvasWidget
{
28
Size
=
new
Vector2
(32f, 60f),
29
Children
= {
30
new
LabelWidget
{
31
Text = $
"{i + 1}."
,
32
Color
=
Color
.
Gray
,
33
HorizontalAlignment
=
WidgetAlignment
.Far,
34
VerticalAlignment
=
WidgetAlignment.Center
35
}
36
}
37
},
38
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) }
39
}
40
};
41
obj.
Children
.
Add
(
m_labels
[i] =
new
LinkWidget
{
Size
=
new
Vector2
(300f, -1f),
VerticalAlignment
=
WidgetAlignment.Center
});
42
obj.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) });
43
obj.
Children
.
Add
(
44
m_rectangles
[i] =
new
BevelledButtonWidget
{
45
Size
=
new
Vector2
(1f / 0f, 60f),
46
BevelSize = 1f,
47
AmbientLight = 1f,
48
DirectionalLight = 0.4f,
49
VerticalAlignment
=
WidgetAlignment.Center
50
}
51
);
52
obj.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) });
53
obj.
Children
.
Add
(
54
m_resetButtons
[i] =
new
BevelledButtonWidget
{
55
Size
=
new
Vector2
(160f, 60f),
VerticalAlignment
=
WidgetAlignment
.Center, Text =
LanguageControl
.
Get
(
fName
, 1)
56
}
57
);
58
obj.
Children
.
Add
(
new
CanvasWidget
{
Size
=
new
Vector2
(10f, 0f) });
59
StackPanelWidget
widget = obj;
60
m_listPanel
.Children.Add(widget);
61
}
62
m_palette
= palette;
63
m_tmpPalette
=
new
WorldPalette
();
64
m_palette
.CopyTo(
m_tmpPalette
);
65
}
66
67
public
override
void
Update
() {
68
for
(
int
j = 0; j < 16; j++) {
69
m_labels
[j].Text =
m_tmpPalette
.Names[j];
70
m_rectangles
[j].CenterColor =
m_tmpPalette
.Colors[j];
71
m_resetButtons
[j].IsEnabled =
m_tmpPalette
.Colors[j] !=
WorldPalette
.
DefaultColors
[j]
72
||
m_tmpPalette
.Names[j] !=
LanguageControl
.
GetWorldPalette
(j);
73
}
74
for
(
int
k = 0; k < 16; k++) {
75
int
i = k;
76
if
(
m_labels
[k].IsClicked) {
77
DialogsManager
.
ShowDialog
(
78
this
,
79
new
TextBoxDialog
(
80
LanguageControl
.
Get
(
fName
, 2),
81
m_labels
[k].Text,
82
16,
83
delegate(
string
s) {
84
if
(s !=
null
) {
85
if
(
WorldPalette
.
VerifyColorName
(s)) {
86
m_tmpPalette
.Names[i] = s;
87
}
88
else
{
89
DialogsManager
.
ShowDialog
(
90
this
,
91
new
MessageDialog
(
LanguageControl
.
Get
(
fName
, 3),
null
,
LanguageControl
.
Ok
,
null
,
null
)
92
);
93
}
94
}
95
}
96
)
97
);
98
}
99
if
(
m_rectangles
[k].IsClicked) {
100
DialogsManager
.
ShowDialog
(
101
this
,
102
new
EditColorDialog
(
103
m_tmpPalette
.Colors[k],
104
delegate(
Color
? color) {
105
if
(color.HasValue) {
106
m_tmpPalette
.Colors[i] = color.Value;
107
}
108
}
109
)
110
);
111
}
112
if
(
m_resetButtons
[k].IsClicked) {
113
m_tmpPalette
.Colors[k] =
WorldPalette
.
DefaultColors
[k];
114
m_tmpPalette
.Names[k] =
LanguageControl
.
GetWorldPalette
(k);
115
}
116
}
117
if
(
m_okButton
.IsClicked) {
118
m_tmpPalette
.CopyTo(
m_palette
);
119
Dismiss
();
120
}
121
if
(
Input
.Cancel
122
||
m_cancelButton
.IsClicked) {
123
Dismiss
();
124
}
125
}
126
127
public
void
Dismiss
() {
128
DialogsManager
.
HideDialog
(
this
);
129
}
130
}
131
}
Game.BevelledButtonWidget
定义
BevelledButtonWidget.cs:6
Game.ButtonWidget
定义
ButtonWidget.cs:5
Game.CanvasWidget
定义
CanvasWidget.cs:4
Game.CanvasWidget.Size
Vector2 Size
定义
CanvasWidget.cs:7
Game.ContainerWidget
定义
ContainerWidget.cs:4
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
定义
EditColorDialog.cs:6
Game.EditPaletteDialog.m_listPanel
ContainerWidget m_listPanel
定义
EditPaletteDialog.cs:6
Game.EditPaletteDialog.m_cancelButton
ButtonWidget m_cancelButton
定义
EditPaletteDialog.cs:8
Game.EditPaletteDialog.m_resetButtons
ButtonWidget[] m_resetButtons
定义
EditPaletteDialog.cs:11
Game.EditPaletteDialog.Dismiss
void Dismiss()
定义
EditPaletteDialog.cs:127
Game.EditPaletteDialog.m_palette
WorldPalette m_palette
定义
EditPaletteDialog.cs:13
Game.EditPaletteDialog.m_labels
LinkWidget[] m_labels
定义
EditPaletteDialog.cs:9
Game.EditPaletteDialog.fName
const string fName
定义
EditPaletteDialog.cs:15
Game.EditPaletteDialog.m_rectangles
BevelledButtonWidget[] m_rectangles
定义
EditPaletteDialog.cs:10
Game.EditPaletteDialog.m_okButton
ButtonWidget m_okButton
定义
EditPaletteDialog.cs:7
Game.EditPaletteDialog.Update
override void Update()
定义
EditPaletteDialog.cs:67
Game.EditPaletteDialog.EditPaletteDialog
EditPaletteDialog(WorldPalette palette)
定义
EditPaletteDialog.cs:17
Game.EditPaletteDialog.m_tmpPalette
WorldPalette m_tmpPalette
定义
EditPaletteDialog.cs:14
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Ok
static string Ok
定义
LanguageControl.cs:11
Game.LanguageControl.GetWorldPalette
static string GetWorldPalette(int index)
定义
LanguageControl.cs:251
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.LinkWidget
定义
LinkWidget.cs:7
Game.MessageDialog
定义
MessageDialog.cs:5
Game.StackPanelWidget
定义
StackPanelWidget.cs:4
Game.TextBoxDialog
定义
TextBoxDialog.cs:4
Game.Widget.VerticalAlignment
virtual WidgetAlignment VerticalAlignment
定义
Widget.cs:445
Game.Widget.HorizontalAlignment
virtual WidgetAlignment HorizontalAlignment
定义
Widget.cs:443
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
Game.WidgetsList.Add
void Add(Widget widget)
定义
WidgetsList.cs:55
Game.WorldPalette
定义
WorldPalette.cs:6
Game.WorldPalette.VerifyColorName
static bool VerifyColorName(string name)
定义
WorldPalette.cs:82
Game.WorldPalette.DefaultColors
static readonly Color[] DefaultColors
定义
WorldPalette.cs:10
Engine.Input
定义
CursorType.cs:1
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.LayoutDirection
LayoutDirection
定义
LayoutDirection.cs:2
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
EditPaletteDialog.cs
制作者
1.16.1