Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CraftingRecipeWidget.cs
浏览该文件的文档.
1
using
System.Xml.Linq;
2
using
Engine
;
3
4
namespace
Game
{
5
public
class
CraftingRecipeWidget
:
CanvasWidget
{
6
public
LabelWidget
m_nameWidget
;
7
8
public
LabelWidget
m_descriptionWidget
;
9
10
public
GridPanelWidget
m_gridWidget
;
11
12
public
CraftingRecipeSlotWidget
m_resultWidget
;
13
14
public
CraftingRecipe
m_recipe
;
15
16
public
string
m_nameSuffix
;
17
18
public
bool
m_dirty
=
true
;
19
20
public
string
NameSuffix
{
21
get
=>
m_nameSuffix
;
22
set
{
23
if
(value !=
m_nameSuffix
) {
24
m_nameSuffix
= value;
25
m_dirty
=
true
;
26
}
27
}
28
}
29
30
public
CraftingRecipe
Recipe
{
31
get
=>
m_recipe
;
32
set
{
33
if
(value !=
m_recipe
) {
34
m_recipe
= value;
35
m_dirty
=
true
;
36
}
37
}
38
}
39
40
public
CraftingRecipeWidget
() {
41
XElement node =
ContentManager
.
Get
<XElement>(
"Widgets/CraftingRecipe"
);
42
LoadContents
(
this
, node);
43
m_nameWidget
=
Children
.Find<
LabelWidget
>(
"CraftingRecipeWidget.Name"
);
44
m_descriptionWidget
=
Children
.Find<
LabelWidget
>(
"CraftingRecipeWidget.Description"
);
45
m_gridWidget
=
Children
.Find<
GridPanelWidget
>(
"CraftingRecipeWidget.Ingredients"
);
46
m_resultWidget
=
Children
.Find<
CraftingRecipeSlotWidget
>(
"CraftingRecipeWidget.Result"
);
47
for
(
int
i = 0; i <
m_gridWidget
.RowsCount; i++) {
48
for
(
int
j = 0; j <
m_gridWidget
.ColumnsCount; j++) {
49
CraftingRecipeSlotWidget
widget =
new
();
50
m_gridWidget
.Children.Add(widget);
51
m_gridWidget
.SetWidgetCell(widget,
new
Point2
(j, i));
52
}
53
}
54
}
55
56
public
override
void
MeasureOverride
(
Vector2
parentAvailableSize) {
57
if
(
m_dirty
) {
58
UpdateWidgets
();
59
}
60
base.MeasureOverride(parentAvailableSize);
61
}
62
63
public
virtual
void
UpdateWidgets
() {
64
m_dirty
=
false
;
65
if
(
m_recipe
!=
null
) {
66
Block
block =
BlocksManager
.
Blocks
[
Terrain
.
ExtractContents
(
m_recipe
.ResultValue)];
67
m_nameWidget.Text = block.
GetDisplayName
(
null
,
m_recipe
.ResultValue)
68
+ (!
string
.IsNullOrEmpty(
NameSuffix
) ?
NameSuffix
:
string
.Empty);
69
m_descriptionWidget.Text =
m_recipe
.Description;
70
m_nameWidget.IsVisible =
true
;
71
m_descriptionWidget.IsVisible =
true
;
72
foreach
(
Widget
widget
in
m_gridWidget
.Children) {
73
if
(widget is
CraftingRecipeSlotWidget
child) {
74
Point2
widgetCell =
m_gridWidget
.GetWidgetCell(child);
75
child.SetIngredient(
m_recipe
.Ingredients[widgetCell.
X
+ widgetCell.
Y
* 3]);
76
}
77
}
78
m_resultWidget
.SetResult(
m_recipe
.ResultValue,
m_recipe
.ResultCount);
79
}
80
else
{
81
m_nameWidget.IsVisible =
false
;
82
m_descriptionWidget.IsVisible =
false
;
83
foreach
(
Widget
widget
in
m_gridWidget
.Children) {
84
(widget as
CraftingRecipeSlotWidget
)?.SetIngredient(
null
);
85
}
86
m_resultWidget
.SetResult(0, 0);
87
}
88
}
89
}
90
}
Game.Block
定义
Block.cs:5
Game.Block.GetDisplayName
virtual string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
定义
Block.cs:233
Game.BlocksManager
定义
BlocksManager.cs:10
Game.BlocksManager.Blocks
static Block[] Blocks
定义
BlocksManager.cs:41
Game.CanvasWidget
定义
CanvasWidget.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.CraftingRecipe
定义
CraftingRecipe.cs:2
Game.CraftingRecipeSlotWidget
定义
CraftingRecipeSlotWidget.cs:5
Game.CraftingRecipeWidget.m_nameSuffix
string m_nameSuffix
定义
CraftingRecipeWidget.cs:16
Game.CraftingRecipeWidget.NameSuffix
string NameSuffix
定义
CraftingRecipeWidget.cs:20
Game.CraftingRecipeWidget.Recipe
CraftingRecipe Recipe
定义
CraftingRecipeWidget.cs:30
Game.CraftingRecipeWidget.m_resultWidget
CraftingRecipeSlotWidget m_resultWidget
定义
CraftingRecipeWidget.cs:12
Game.CraftingRecipeWidget.m_nameWidget
LabelWidget m_nameWidget
定义
CraftingRecipeWidget.cs:6
Game.CraftingRecipeWidget.CraftingRecipeWidget
CraftingRecipeWidget()
定义
CraftingRecipeWidget.cs:40
Game.CraftingRecipeWidget.UpdateWidgets
virtual void UpdateWidgets()
定义
CraftingRecipeWidget.cs:63
Game.CraftingRecipeWidget.m_dirty
bool m_dirty
定义
CraftingRecipeWidget.cs:18
Game.CraftingRecipeWidget.m_descriptionWidget
LabelWidget m_descriptionWidget
定义
CraftingRecipeWidget.cs:8
Game.CraftingRecipeWidget.m_recipe
CraftingRecipe m_recipe
定义
CraftingRecipeWidget.cs:14
Game.CraftingRecipeWidget.m_gridWidget
GridPanelWidget m_gridWidget
定义
CraftingRecipeWidget.cs:10
Game.CraftingRecipeWidget.MeasureOverride
override void MeasureOverride(Vector2 parentAvailableSize)
定义
CraftingRecipeWidget.cs:56
Game.GridPanelWidget
定义
GridPanelWidget.cs:4
Game.LabelWidget
定义
LabelWidget.cs:4
Game.Terrain
定义
Terrain.cs:5
Game.Terrain.ExtractContents
static int ExtractContents(int value)
定义
Terrain.cs:303
Game.Widget
定义
Widget.cs:10
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Engine.Point2
定义
Point2.cs:2
Engine.Point2.Y
int Y
定义
Point2.cs:5
Engine.Point2.X
int X
定义
Point2.cs:3
Engine.Vector2
定义
Vector2.cs:2
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Widget
CraftingRecipeWidget.cs
制作者
1.16.1