Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
LevelFactorDialog.cs
浏览该文件的文档.
1
using
System.Globalization;
2
using
System.Xml.Linq;
3
4
namespace
Game
{
5
public
class
LevelFactorDialog
:
Dialog
{
6
public
LabelWidget
m_titleWidget
;
7
public
LabelWidget
m_descriptionWidget
;
8
public
LabelWidget
m_namesWidget
;
9
public
LabelWidget
m_valuesWidget
;
10
public
LabelWidget
m_totalNameWidget
;
11
public
LabelWidget
m_totalValueWidget
;
12
public
ButtonWidget
m_okWidget
;
13
public
const
string
fName
=
"LevelFactorDialog"
;
14
15
public
LevelFactorDialog
(
string
title,
string
description, IEnumerable<ComponentLevel.Factor> factors,
float
total) {
16
XElement node =
ContentManager
.
Get
<XElement>(
"Dialogs/LevelFactorDialog"
);
17
LoadContents
(
this
, node);
18
m_titleWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.Title"
);
19
m_descriptionWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.Description"
);
20
m_namesWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.Names"
);
21
m_valuesWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.Values"
);
22
m_totalNameWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.TotalName"
);
23
m_totalValueWidget
=
Children
.Find<
LabelWidget
>(
"LevelFactorDialog.TotalValue"
);
24
m_okWidget
=
Children
.Find<
ButtonWidget
>(
"LevelFactorDialog.OK"
);
25
m_titleWidget.Text = title;
26
m_descriptionWidget.Text = description;
27
m_namesWidget.Text =
string
.Empty;
28
m_valuesWidget.Text =
string
.Empty;
29
foreach
(
ComponentLevel
.
Factor
factor in factors) {
30
m_namesWidget.Text += $
"{factor.Description,24}\n"
;
31
string
factorValueString = factor.Value
switch
{
32
float.NegativeInfinity =>
LanguageControl
.
Get
(
fName
,
"1"
),
33
float.PositiveInfinity =>
LanguageControl
.
Get
(
fName
,
"2"
),
34
_ =>
string
.Format(CultureInfo.InvariantCulture,
"{0:0.00}"
, factor.Value)
35
};
36
m_valuesWidget.Text += factor.FactorAdditionType
switch
{
37
FactorAdditionType.Multiply
=> $
"x {factorValueString}\n"
,
38
_ => $
"+ {factorValueString}\n"
39
};
40
}
41
m_namesWidget.Text =
m_namesWidget
.Text.TrimEnd();
42
m_valuesWidget.Text =
m_valuesWidget
.Text.TrimEnd();
43
m_totalNameWidget.Text = $
"{LanguageControl.Get(fName, "
3
"),24}"
;
44
m_totalValueWidget.Text =
string
.Format(CultureInfo.InvariantCulture,
"x {0:0.00}"
, total);
45
}
46
47
public
override
void
Update
() {
48
if
(Input.Cancel
49
||
m_okWidget
.IsClicked) {
50
DialogsManager
.
HideDialog
(
this
);
51
}
52
}
53
}
54
}
Game.ButtonWidget
定义
ButtonWidget.cs:5
Game.ComponentLevel.Factor
这里的Factor类型从struct改为class,是由于模组在修改Factor的时候,通常是需要修改引用的值。 如果是struct则只能复制并修改值,不能修改引用。
定义
ComponentLevel.cs:17
Game.ComponentLevel
定义
ComponentLevel.cs:12
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.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.LevelFactorDialog.m_valuesWidget
LabelWidget m_valuesWidget
定义
LevelFactorDialog.cs:9
Game.LevelFactorDialog.m_totalValueWidget
LabelWidget m_totalValueWidget
定义
LevelFactorDialog.cs:11
Game.LevelFactorDialog.m_totalNameWidget
LabelWidget m_totalNameWidget
定义
LevelFactorDialog.cs:10
Game.LevelFactorDialog.Update
override void Update()
定义
LevelFactorDialog.cs:47
Game.LevelFactorDialog.m_titleWidget
LabelWidget m_titleWidget
定义
LevelFactorDialog.cs:6
Game.LevelFactorDialog.LevelFactorDialog
LevelFactorDialog(string title, string description, IEnumerable< ComponentLevel.Factor > factors, float total)
定义
LevelFactorDialog.cs:15
Game.LevelFactorDialog.m_namesWidget
LabelWidget m_namesWidget
定义
LevelFactorDialog.cs:8
Game.LevelFactorDialog.m_okWidget
ButtonWidget m_okWidget
定义
LevelFactorDialog.cs:12
Game.LevelFactorDialog.fName
const string fName
定义
LevelFactorDialog.cs:13
Game.LevelFactorDialog.m_descriptionWidget
LabelWidget m_descriptionWidget
定义
LevelFactorDialog.cs:7
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
Game
定义
ContentFileBridge.cs:4
Game.FactorAdditionType.Multiply
@ Multiply
定义
ComponentLevel.cs:8
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
LevelFactorDialog.cs
制作者
1.16.1