Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
LoginDialog.cs
浏览该文件的文档.
1
using
Engine
;
2
3
namespace
Game
{
4
public
class
LoginDialog
:
Dialog
{
5
public
Action<byte[]>
succ
;
6
public
Action<Exception>
fail
;
7
public
StackPanelWidget
MainView
;
8
public
BevelledButtonWidget
btna
,
btnb
,
btnc
;
9
public
TextBoxWidget
txa
,
txb
;
10
public
BusyDialog
busyDialog
=
new
(
"提示"
,
"登录中"
);
11
12
public
LabelWidget
tip
=
new
() {
13
HorizontalAlignment
=
WidgetAlignment
.Near,
VerticalAlignment
=
WidgetAlignment
.Near,
Margin
=
new
Vector2
(1f, 1f)
14
};
15
16
public
Action
cancel
;
17
18
public
LoginDialog
() {
19
CanvasWidget
canvasWidget =
new
() {
20
Size
=
new
Vector2
(600f, 240f),
HorizontalAlignment
=
WidgetAlignment
.Center,
VerticalAlignment
=
WidgetAlignment.Center
21
};
22
RectangleWidget
rectangleWidget =
new
() {
23
FillColor =
new
Color
(0, 0, 0, 255), OutlineColor =
new
Color
(128, 128, 128, 128), OutlineThickness = 2
24
};
25
StackPanelWidget
stackPanelWidget =
new
() {
26
Direction =
LayoutDirection
.Vertical,
27
HorizontalAlignment
=
WidgetAlignment
.Center,
28
VerticalAlignment
=
WidgetAlignment
.Near,
29
Margin
=
new
Vector2
(10f, 10f)
30
};
31
Children
.Add(canvasWidget);
32
canvasWidget.
Children
.
Add
(rectangleWidget);
33
canvasWidget.
Children
.
Add
(stackPanelWidget);
34
MainView
= stackPanelWidget;
35
MainView
.Children.Add(
tip
);
36
MainView
.Children.Add(
makeTextBox
(
"账号:"
));
37
MainView
.Children.Add(
makeTextBox
(
"密码:"
,
true
));
38
MainView
.Children.Add(
makeButton
());
39
}
40
41
public
Widget
makeTextBox
(
string
title,
bool
passwordMode =
false
) {
42
CanvasWidget
canvasWidget =
new
() {
Margin
=
new
Vector2
(10, 0) };
43
RectangleWidget
rectangleWidget =
new
() {
44
FillColor =
Color
.
Black
, OutlineColor =
Color
.
White
,
Size
=
new
Vector2
(
float
.PositiveInfinity, 80)
45
};
46
StackPanelWidget
stack =
new
() { Direction =
LayoutDirection.Horizontal
};
47
LabelWidget
label =
new
() {
48
HorizontalAlignment
=
WidgetAlignment
.Near,
VerticalAlignment
=
WidgetAlignment
.Near, Text = title,
Margin
=
new
Vector2
(1f, 1f)
49
};
50
TextBoxWidget
textBox =
new
() {
51
PasswordMode = passwordMode,
52
VerticalAlignment
=
WidgetAlignment
.Center,
53
HorizontalAlignment
=
WidgetAlignment
.Stretch,
54
Color
=
new
Color
(255, 255, 255),
55
Margin
=
new
Vector2
(4f, 0f),
56
Size
=
new
Vector2
(
float
.PositiveInfinity, 80)
57
};
58
if
(title ==
"账号:"
) {
59
txa
= textBox;
60
}
61
if
(title ==
"密码:"
) {
62
txb
= textBox;
63
}
64
stack.
Children
.
Add
(label);
65
stack.
Children
.
Add
(textBox);
66
canvasWidget.
Children
.
Add
(rectangleWidget);
67
canvasWidget.
Children
.
Add
(stack);
68
return
canvasWidget;
69
}
70
71
public
Widget
makeButton
() {
72
StackPanelWidget
stack =
new
() { Direction =
LayoutDirection.Horizontal
};
73
BevelledButtonWidget
bevelledButtonWidget1 =
new
() {
Size
=
new
Vector2
(160, 60),
Margin
=
new
Vector2
(4f, 0), Text =
"登录"
};
74
BevelledButtonWidget
bevelledButtonWidget2 =
new
() {
Size
=
new
Vector2
(160, 60),
Margin
=
new
Vector2
(4f, 0), Text =
"注册"
};
75
BevelledButtonWidget
bevelledButtonWidget3 =
new
() {
Size
=
new
Vector2
(160, 60),
Margin
=
new
Vector2
(4f, 0), Text =
"取消"
};
76
stack.
Children
.
Add
(bevelledButtonWidget1);
77
stack.
Children
.
Add
(bevelledButtonWidget2);
78
stack.
Children
.
Add
(bevelledButtonWidget3);
79
btna
= bevelledButtonWidget1;
80
btnb
= bevelledButtonWidget2;
81
btnc
= bevelledButtonWidget3;
82
return
stack;
83
}
84
85
public
override
void
Update
() {
86
if
(
btna
.IsClicked) {
87
Dictionary<string, string> par =
new
() { {
"user"
, txa.Text }, {
"pass"
, txb.Text } };
88
DialogsManager
.
ShowDialog
(
this
,
busyDialog
);
89
WebManager
.
Post
(
90
$
"{CommunityServerManager.CurrentChineseInfo.ApiUrl}/com/api/login"
,
91
par,
92
null
,
93
new
MemoryStream(),
94
new
CancellableProgress
(),
95
succ
,
96
fail
97
);
98
}
99
if
(
btnb
.IsClicked) {
100
WebBrowserManager
.
LaunchBrowser
($
"{CommunityServerManager.CurrentChineseInfo.ApiUrl}/com/reg"
);
101
}
102
if
(
btnc
.IsClicked) {
103
cancel
?.Invoke();
104
}
105
}
106
}
107
}
Color
Engine.Color Color
定义
CommunityContentScreen.cs:9
Game.BevelledButtonWidget
定义
BevelledButtonWidget.cs:6
Game.BusyDialog
定义
BusyDialog.cs:4
Game.CancellableProgress
定义
CancellableProgress.cs:2
Game.CanvasWidget
定义
CanvasWidget.cs:4
Game.CanvasWidget.Size
Vector2 Size
定义
CanvasWidget.cs:7
Game.ContainerWidget.Children
readonly WidgetsList Children
定义
ContainerWidget.cs:5
Game.Dialog.Dialog
Dialog()
定义
Dialog.cs:5
Game.DialogsManager
定义
DialogsManager.cs:4
Game.DialogsManager.ShowDialog
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
定义
DialogsManager.cs:35
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LoginDialog.tip
LabelWidget tip
定义
LoginDialog.cs:12
Game.LoginDialog.LoginDialog
LoginDialog()
定义
LoginDialog.cs:18
Game.LoginDialog.succ
Action< byte[]> succ
定义
LoginDialog.cs:5
Game.LoginDialog.makeTextBox
Widget makeTextBox(string title, bool passwordMode=false)
定义
LoginDialog.cs:41
Game.LoginDialog.MainView
StackPanelWidget MainView
定义
LoginDialog.cs:7
Game.LoginDialog.txb
TextBoxWidget txb
定义
LoginDialog.cs:9
Game.LoginDialog.txa
TextBoxWidget txa
定义
LoginDialog.cs:9
Game.LoginDialog.cancel
Action cancel
定义
LoginDialog.cs:16
Game.LoginDialog.makeButton
Widget makeButton()
定义
LoginDialog.cs:71
Game.LoginDialog.Update
override void Update()
定义
LoginDialog.cs:85
Game.LoginDialog.btna
BevelledButtonWidget btna
定义
LoginDialog.cs:8
Game.LoginDialog.busyDialog
BusyDialog busyDialog
定义
LoginDialog.cs:10
Game.LoginDialog.btnc
BevelledButtonWidget btnc
定义
LoginDialog.cs:8
Game.LoginDialog.fail
Action< Exception > fail
定义
LoginDialog.cs:6
Game.LoginDialog.btnb
BevelledButtonWidget btnb
定义
LoginDialog.cs:8
Game.RectangleWidget
定义
RectangleWidget.cs:5
Game.StackPanelWidget
定义
StackPanelWidget.cs:4
Game.TextBoxWidget
定义
TextBoxWidget.cs:22
Game.WebBrowserManager
定义
WebBrowserManager.cs:7
Game.WebBrowserManager.LaunchBrowser
static void LaunchBrowser(string url)
定义
WebBrowserManager.cs:8
Game.WebManager
定义
WebManager.cs:17
Game.WebManager.Post
static void Post(string address, Dictionary< string, string > parameters, Dictionary< string, string > headers, Stream data, CancellableProgress progress, Action< byte[]> success, Action< Exception > failure)
定义
WebManager.cs:179
Game.Widget
定义
Widget.cs:10
Game.Widget.VerticalAlignment
virtual WidgetAlignment VerticalAlignment
定义
Widget.cs:445
Game.Widget.Margin
virtual Vector2 Margin
定义
Widget.cs:408
Game.Widget.HorizontalAlignment
virtual WidgetAlignment HorizontalAlignment
定义
Widget.cs:443
Game.WidgetsList.Add
void Add(Widget widget)
定义
WidgetsList.cs:55
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.LayoutDirection
LayoutDirection
定义
LayoutDirection.cs:2
Game.LayoutDirection.Horizontal
@ Horizontal
定义
LayoutDirection.cs:3
Game.WidgetAlignment
WidgetAlignment
定义
WidgetAlignment.cs:2
Game.WidgetAlignment.Center
@ Center
定义
WidgetAlignment.cs:4
Engine.Color
定义
Color.cs:2
Engine.Color.White
static Color White
定义
Color.cs:15
Engine.Color.Black
static Color Black
定义
Color.cs:7
Engine.Vector2
定义
Vector2.cs:2
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
LoginDialog.cs
制作者
1.16.1