Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
RemoteControlDialog.cs
浏览该文件的文档.
1
#if !IOS && !BROWSER
2
using
System.Net;
3
using
System.Xml.Linq;
4
5
namespace
Game
{
6
public
class
RemoteControlDialog
:
Dialog
{
7
public
readonly
LabelWidget
m_statusLabel
;
8
public
readonly
ButtonWidget
m_statusButton
;
9
public
readonly
LabelWidget
m_addressLabel
;
10
public
readonly
ButtonWidget
m_portButton
;
11
public
readonly
LabelWidget
m_passwordLabel
;
12
public
readonly
ButtonWidget
m_passwordButton
;
13
public
readonly
ButtonWidget
m_closeButton
;
14
15
public
RemoteControlDialog
() {
16
XElement node =
ContentManager
.
Get
<XElement>(
"Dialogs/RemoteControlDialog"
);
17
LoadContents
(
this
, node);
18
m_statusLabel
=
Children
.Find<
LabelWidget
>(
"RemoteControlDialog.StatusLabel"
);
19
m_statusButton
=
Children
.Find<
ButtonWidget
>(
"RemoteControlDialog.StatusButton"
);
20
m_addressLabel
=
Children
.Find<
LabelWidget
>(
"RemoteControlDialog.AddressLabel"
);
21
m_portButton
=
Children
.Find<
ButtonWidget
>(
"RemoteControlDialog.PortButton"
);
22
m_passwordLabel
=
Children
.Find<
LabelWidget
>(
"RemoteControlDialog.PasswordLabel"
);
23
m_passwordButton
=
Children
.Find<
ButtonWidget
>(
"RemoteControlDialog.PasswordButton"
);
24
m_closeButton
=
Children
.Find<
ButtonWidget
>(
"RemoteControlDialog.CloseButton"
);
25
m_statusLabel.Text =
LanguageControl
.
Get
(
"ContentWidgets"
,
"RemoteControlDialog"
,
JsInterface
.
httpListener
.IsListening ?
"4"
:
"5"
);
26
m_addressLabel.Text = $
"http://{IPAddress.Loopback}:{JsInterface.httpPort}/"
;
27
m_passwordLabel.Text =
JsInterface
.
httpPassword
;
28
}
29
30
public
override
void
Update
() {
31
if
(
m_statusButton
.IsClicked) {
32
if
(
JsInterface
.
httpListener
.IsListening) {
33
JsInterface
.
StopHttpListener
();
34
ModsManager
.
SetConfig
(
"RemoteControlEnabled"
,
"false"
);
35
m_statusLabel.Text =
LanguageControl
.
Get
(
"ContentWidgets"
,
"RemoteControlDialog"
,
"5"
);
36
}
37
else
{
38
Task.Run(
JsInterface
.
StartHttpListener
);
39
ModsManager
.
SetConfig
(
"RemoteControlEnabled"
,
"true"
);
40
m_statusLabel.Text =
LanguageControl
.
Get
(
"ContentWidgets"
,
"RemoteControlDialog"
,
"4"
);
41
}
42
}
43
if
(
m_portButton
.IsClicked) {
44
DialogsManager
.
ShowDialog
(
45
ParentWidget
,
46
new
TextBoxDialog
(
47
LanguageControl
.
Get
(
"ContentWidgets"
,
"RemoteControlDialog"
,
"8"
),
48
JsInterface
.
httpPort
.ToString(),
49
5,
50
str => {
51
if (int.TryParse(str, out int port)) {
52
JsInterface.SetHttpPort(port, true);
53
m_addressLabel.Text = $
"http://{IPAddress.Loopback}:{port}/"
;
54
}
55
}
56
)
57
);
58
}
59
if
(
m_passwordButton
.
IsClicked
) {
60
DialogsManager
.
ShowDialog
(
61
ParentWidget
,
62
new
TextBoxDialog
(
63
LanguageControl
.
Get
(
"ContentWidgets"
,
"RemoteControlDialog"
,
"10"
),
64
JsInterface
.
httpPassword
,
65
18,
66
str => {
67
JsInterface.httpPassword = str;
68
ModsManager.SetConfig(
"RemoteControlPassword"
, str);
69
}
70
)
71
);
72
}
73
if
(Input.Back
74
|| Input.Cancel
75
||
m_closeButton
.
IsClicked
) {
76
Dismiss
();
77
}
78
}
79
80
public
void
Dismiss
() {
81
DialogsManager
.
HideDialog
(
this
);
82
}
83
}
84
}
85
#else
86
namespace
Game
{
87
public
class
RemoteControlDialog
:
Dialog
{
88
89
}
90
}
91
#endif
Game.ButtonWidget
定义
ButtonWidget.cs:5
Game.ButtonWidget.IsClicked
bool IsClicked
定义
ButtonWidget.cs:6
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.cs:4
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.JsInterface
定义
JsInterface.cs:15
Game.JsInterface.StopHttpListener
static void StopHttpListener()
定义
JsInterface.cs:228
Game.JsInterface.httpPassword
static string httpPassword
定义
JsInterface.cs:22
Game.JsInterface.httpPort
static int httpPort
定义
JsInterface.cs:21
Game.JsInterface.httpListener
static HttpListener httpListener
定义
JsInterface.cs:20
Game.JsInterface.StartHttpListener
static async Task StartHttpListener()
定义
JsInterface.cs:215
Game.LabelWidget
定义
LabelWidget.cs:4
Game.LanguageControl
定义
LanguageControl.cs:8
Game.LanguageControl.Get
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
定义
LanguageControl.cs:247
Game.RemoteControlDialog
定义
RemoteControlDialog.cs:6
Game.RemoteControlDialog.m_statusLabel
readonly LabelWidget m_statusLabel
定义
RemoteControlDialog.cs:7
Game.RemoteControlDialog.Update
override void Update()
定义
RemoteControlDialog.cs:30
Game.RemoteControlDialog.RemoteControlDialog
RemoteControlDialog()
定义
RemoteControlDialog.cs:15
Game.RemoteControlDialog.m_closeButton
readonly ButtonWidget m_closeButton
定义
RemoteControlDialog.cs:13
Game.RemoteControlDialog.m_passwordLabel
readonly LabelWidget m_passwordLabel
定义
RemoteControlDialog.cs:11
Game.RemoteControlDialog.m_addressLabel
readonly LabelWidget m_addressLabel
定义
RemoteControlDialog.cs:9
Game.RemoteControlDialog.m_passwordButton
readonly ButtonWidget m_passwordButton
定义
RemoteControlDialog.cs:12
Game.RemoteControlDialog.m_statusButton
readonly ButtonWidget m_statusButton
定义
RemoteControlDialog.cs:8
Game.RemoteControlDialog.Dismiss
void Dismiss()
定义
RemoteControlDialog.cs:80
Game.RemoteControlDialog.m_portButton
readonly ButtonWidget m_portButton
定义
RemoteControlDialog.cs:10
Game.TextBoxDialog
定义
TextBoxDialog.cs:4
Game.Widget.ParentWidget
ContainerWidget ParentWidget
定义
Widget.cs:468
Game.Widget.LoadContents
virtual void LoadContents(object eventsTarget, XElement node)
定义
Widget.cs:507
ModsManager
定义
ModsManager.cs:19
ModsManager.SetConfig
static void SetConfig(string key, string value)
定义
ModsManager.cs:361
Game
定义
ContentFileBridge.cs:4
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Dialog
RemoteControlDialog.cs
制作者
1.16.1