Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SelectClassSubstituteDialog.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
3
namespace
Game
{
4
public
class
SelectClassSubstituteDialog
:
Dialog
{
5
public
string
m_guid
;
6
public
XElement
m_element
;
7
public
Action
m_handler
;
8
9
public
ListPanelWidget
m_listPanel
;
10
11
public
const
string
fName
=
"SelectClassSubstituteDialog"
;
12
13
public
SelectClassSubstituteDialog
(
string
guid, XElement element, Action handler) {
14
m_guid
= guid;
15
m_element
= element;
16
m_handler
= handler;
17
LoadContents
(
this
,
ContentManager
.
Get
<XElement>(
"Dialogs/SelectClassSubstituteDialog"
));
18
m_listPanel
=
Children
.Find<
ListPanelWidget
>(
"SelectClassSubstituteDialog.ListPanel"
);
19
m_listPanel.ItemWidgetFactory = o => {
20
if
(o is not
ModsManager
.
ClassSubstitute
substitute) {
21
return
null
;
22
}
23
if
(substitute.PackageName ==
"survivalcraft"
) {
24
return
new
LabelWidget
() {
25
Text = $
"{LanguageControl.Get(fName, "
1
")} - {substitute.ClassName}"
,
VerticalAlignment
=
WidgetAlignment.Center
26
};
27
}
28
if
(
ModsManager
.
PackageNameToModEntity
.TryGetValue(substitute.PackageName, out
ModEntity
modEntity)) {
29
return
new
ScrollPanelWidget
() {
30
Direction =
LayoutDirection
.Horizontal,
31
Children
= {
32
new
LabelWidget
() {
33
Text = $
"{modEntity.modInfo.Name} - {substitute.ClassName}"
,
VerticalAlignment
=
WidgetAlignment.Center
34
}
35
}
36
};
37
}
38
return
null
;
39
};
40
m_listPanel.ItemClicked = o => {
41
if
(o is not
ModsManager
.
ClassSubstitute
substitute) {
42
return
;
43
}
44
ModsManager
.
SelectedClassSubstitutes
[
m_guid
] = substitute;
45
m_element
.SetAttributeValue(
"Value"
, substitute.ClassName);
46
DialogsManager
.
HideDialog
(
this
);
47
m_handler
?.Invoke();
48
};
49
if
(
ModsManager
.
ClassSubstitutes
.TryGetValue(guid, out List<ModsManager.ClassSubstitute> substitutes)
50
&& substitutes.Count > 0) {
51
string
description = element.Parent?.Attribute(
"Description"
)?.Value ??
LanguageControl
.
Unknown
;
52
if
(description.StartsWith(
'['
)
53
&& description.EndsWith(
']'
)) {
54
string
[] array = description.Substring(1, description.Length - 2).Split(
':'
);
55
if
(array.Length == 2) {
56
description =
LanguageControl
.
GetDatabase
(array[0], array[1]);
57
}
58
}
59
Children
.Find<
LabelWidget
>(
"SelectClassSubstituteDialog.Description"
)?.Text =
string
.Format(
60
LanguageControl
.
Get
(
fName
,
"2"
),
61
substitutes.Count - 1,
62
substitutes[0].ClassName,
63
description
64
);
65
m_listPanel
.AddItems(substitutes);
66
if
(
ModsManager
.
SelectedClassSubstitutes
.TryGetValue(guid, out
ModsManager
.
ClassSubstitute
selected)) {
67
m_listPanel.SelectedItem = selected;
68
}
69
}
70
}
71
72
public
override
void
Update
() {
73
if
(Input.Back
74
|| Input.Cancel
75
|| (Input.Tap.HasValue && !
HitTest
(Input.Tap.Value))) {
76
// 直接关闭将保持原版
77
DialogsManager
.
HideDialog
(
this
);
78
m_handler
?.Invoke();
79
}
80
}
81
}
82
}
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.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Unknown
static string Unknown
定义
LanguageControl.cs:24
Game.LanguageControl.GetDatabase
static string GetDatabase(string name, string prop)
定义
LanguageControl.cs:352
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.ListPanelWidget
定义
ListPanelWidget.cs:5
Game.ModEntity
定义
ModEntity.cs:8
Game.ScrollPanelWidget
定义
ScrollPanelWidget.cs:5
Game.SelectClassSubstituteDialog.m_listPanel
ListPanelWidget m_listPanel
定义
SelectClassSubstituteDialog.cs:9
Game.SelectClassSubstituteDialog.m_handler
Action m_handler
定义
SelectClassSubstituteDialog.cs:7
Game.SelectClassSubstituteDialog.m_element
XElement m_element
定义
SelectClassSubstituteDialog.cs:6
Game.SelectClassSubstituteDialog.m_guid
string m_guid
定义
SelectClassSubstituteDialog.cs:5
Game.SelectClassSubstituteDialog.SelectClassSubstituteDialog
SelectClassSubstituteDialog(string guid, XElement element, Action handler)
定义
SelectClassSubstituteDialog.cs:13
Game.SelectClassSubstituteDialog.Update
override void Update()
定义
SelectClassSubstituteDialog.cs:72
Game.SelectClassSubstituteDialog.fName
const string fName
定义
SelectClassSubstituteDialog.cs:11
Game.Widget.HitTest
virtual bool HitTest(Vector2 point)
定义
Widget.cs:686
Game.Widget.VerticalAlignment
virtual WidgetAlignment VerticalAlignment
定义
Widget.cs:445
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
ModsManager.ClassSubstitute
定义
ModsManager.cs:670
ModsManager
定义
ModsManager.cs:19
ModsManager.PackageNameToModEntity
static Dictionary< string, ModEntity > PackageNameToModEntity
含所有已启用的模组
定义
ModsManager.cs:116
ModsManager.ClassSubstitutes
static Dictionary< string, List< ClassSubstitute > > ClassSubstitutes
定义
ModsManager.cs:701
ModsManager.SelectedClassSubstitutes
static Dictionary< string, ClassSubstitute > SelectedClassSubstitutes
定义
ModsManager.cs:703
Game
定义
ContentFileBridge.cs:4
Game.LayoutDirection
LayoutDirection
定义
LayoutDirection.cs:2
Game.WidgetAlignment.Center
@ Center
定义
WidgetAlignment.cs:4
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
SelectClassSubstituteDialog.cs
制作者
1.16.1