Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditWorldSeedDialog.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
3
namespace
Game
{
4
public
class
EditWorldSeedDialog
:
Dialog
{
5
public
Action<string, int>
m_handler
;
6
7
public
TextBoxWidget
m_worldSeedTextBox
;
8
public
LabelWidget
m_worldSeedLabel
;
9
public
TextBoxWidget
m_trueWorldSeedTextBox
;
10
public
ButtonWidget
m_resetButton
;
11
public
ButtonWidget
m_okButton
;
12
public
ButtonWidget
m_cancelButton
;
13
14
public
bool
m_trueWorldSeedEdited
=
false
;
15
16
public
const
string
fName
=
"EditWorldSeedDialog"
;
17
18
public
EditWorldSeedDialog
(
string
seed,
int
trueSeed, Action<string, int> handler) {
19
m_handler
= handler;
20
XElement node =
ContentManager
.
Get
<XElement>(
"Dialogs/EditWorldSeedDialog"
);
21
LoadContents
(
this
, node);
22
m_worldSeedTextBox
=
Children
.Find<
TextBoxWidget
>(
"EditWorldSeedDialog.WorldSeedTextBox"
);
23
m_worldSeedLabel
=
Children
.Find<
LabelWidget
>(
"EditWorldSeedDialog.WorldSeedLabel"
);
24
m_trueWorldSeedTextBox
=
Children
.Find<
TextBoxWidget
>(
"EditWorldSeedDialog.TrueWorldSeedTextBox"
);
25
m_resetButton
=
Children
.Find<
ButtonWidget
>(
"EditWorldSeedDialog.ResetButton"
);
26
m_okButton
=
Children
.Find<
ButtonWidget
>(
"EditWorldSeedDialog.OkButton"
);
27
m_cancelButton
=
Children
.Find<
ButtonWidget
>(
"EditWorldSeedDialog.CancelButton"
);
28
if
(seed ==
null
) {
29
m_trueWorldSeedEdited
=
true
;
30
m_worldSeedTextBox.Text =
string
.Empty;
31
m_worldSeedLabel.Text =
LanguageControl
.
Get
(
fName
,
"2"
);
32
m_worldSeedLabel.IsVisible =
true
;
33
m_trueWorldSeedTextBox.Text = trueSeed.ToString();
34
m_trueWorldSeedTextBox.HasFocus =
true
;
35
}
36
else
{
37
m_worldSeedTextBox.Text = seed;
38
m_worldSeedTextBox.HasFocus =
true
;
39
m_trueWorldSeedTextBox.Text =
SeedToTrueSeed
(seed).ToString();
40
}
41
m_worldSeedTextBox.TextChanged += widget => {
42
if
(
m_trueWorldSeedEdited
) {
43
return
;
44
}
45
m_trueWorldSeedTextBox
.ChangeTextNoEvent(
SeedToTrueSeed
(widget.Text).ToString());
46
if
(
string
.IsNullOrEmpty(widget.Text)) {
47
m_worldSeedLabel.Text =
LanguageControl
.
Get
(
fName
,
"1"
);
48
}
49
};
50
m_trueWorldSeedTextBox.TextChanged += widget => {
51
if
(
m_trueWorldSeedEdited
) {
52
return
;
53
}
54
m_trueWorldSeedEdited
=
true
;
55
m_worldSeedTextBox.Text =
string
.Empty;
56
m_worldSeedLabel.Text =
LanguageControl
.
Get
(
fName
,
"2"
);
57
m_worldSeedLabel.IsVisible =
true
;
58
};
59
}
60
61
public
override
void
Update
() {
62
if
(
m_resetButton
.IsClicked) {
63
m_trueWorldSeedEdited
=
false
;
64
m_worldSeedTextBox.Text =
string
.Empty;
65
m_worldSeedLabel.Text =
LanguageControl
.
Get
(
fName
,
"1"
);
66
m_trueWorldSeedTextBox
.ChangeTextNoEvent(
string
.Empty);
67
}
68
else
if
(Input.Cancel
69
||
m_cancelButton
.IsClicked) {
70
DialogsManager
.
HideDialog
(
this
);
71
}
72
else
if
(Input.Ok
73
||
m_okButton
.IsClicked) {
74
if
(
m_trueWorldSeedEdited
) {
75
if
(
int
.TryParse(
m_trueWorldSeedTextBox
.Text, out
int
trueSeed)) {
76
DialogsManager
.
HideDialog
(
this
);
77
m_handler
?.Invoke(
null
, trueSeed);
78
}
79
else
{
80
DialogsManager
.
ShowDialog
(
81
null
,
82
new
MessageDialog
(
LanguageControl
.
Error
,
LanguageControl
.
Get
(
fName
,
"3"
),
LanguageControl
.
Ok
,
null
,
null
)
83
);
84
}
85
}
86
else
{
87
DialogsManager
.
HideDialog
(
this
);
88
m_handler
?.Invoke(
m_worldSeedTextBox
.Text, 0);
89
}
90
}
91
m_worldSeedLabel.IsVisible =
m_trueWorldSeedEdited
|| (
string
.IsNullOrEmpty(
m_worldSeedTextBox
.Text) && !
m_worldSeedTextBox
.HasFocus);
92
}
93
94
public
static
int
SeedToTrueSeed
(
string
seed) {
95
int
trueSeed = 0;
96
int
num = 1;
97
foreach
(
char
c
in
seed) {
98
trueSeed += c * num;
99
num += 29;
100
}
101
return
trueSeed;
102
}
103
}
104
}
Game.ButtonWidget
定义
ButtonWidget.cs:5
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.EditWorldSeedDialog.m_trueWorldSeedEdited
bool m_trueWorldSeedEdited
定义
EditWorldSeedDialog.cs:14
Game.EditWorldSeedDialog.m_cancelButton
ButtonWidget m_cancelButton
定义
EditWorldSeedDialog.cs:12
Game.EditWorldSeedDialog.m_okButton
ButtonWidget m_okButton
定义
EditWorldSeedDialog.cs:11
Game.EditWorldSeedDialog.SeedToTrueSeed
static int SeedToTrueSeed(string seed)
定义
EditWorldSeedDialog.cs:94
Game.EditWorldSeedDialog.m_worldSeedLabel
LabelWidget m_worldSeedLabel
定义
EditWorldSeedDialog.cs:8
Game.EditWorldSeedDialog.m_worldSeedTextBox
TextBoxWidget m_worldSeedTextBox
定义
EditWorldSeedDialog.cs:7
Game.EditWorldSeedDialog.m_trueWorldSeedTextBox
TextBoxWidget m_trueWorldSeedTextBox
定义
EditWorldSeedDialog.cs:9
Game.EditWorldSeedDialog.Update
override void Update()
定义
EditWorldSeedDialog.cs:61
Game.EditWorldSeedDialog.m_handler
Action< string, int > m_handler
定义
EditWorldSeedDialog.cs:5
Game.EditWorldSeedDialog.EditWorldSeedDialog
EditWorldSeedDialog(string seed, int trueSeed, Action< string, int > handler)
定义
EditWorldSeedDialog.cs:18
Game.EditWorldSeedDialog.fName
const string fName
定义
EditWorldSeedDialog.cs:16
Game.EditWorldSeedDialog.m_resetButton
ButtonWidget m_resetButton
定义
EditWorldSeedDialog.cs:10
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Ok
static string Ok
定义
LanguageControl.cs:11
Game.LanguageControl.Error
static string Error
定义
LanguageControl.cs:15
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.MessageDialog
定义
MessageDialog.cs:5
Game.TextBoxWidget
定义
TextBoxWidget.cs:22
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
Game
定义
ContentFileBridge.cs:4
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
EditWorldSeedDialog.cs
制作者
1.16.1