Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
RemoteControlDialog.cs
浏览该文件的文档.
1#if !IOS && !BROWSER
2using System.Net;
3using System.Xml.Linq;
4
5namespace 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;
13 public readonly ButtonWidget m_closeButton;
14
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) {
34 ModsManager.SetConfig("RemoteControlEnabled", "false");
35 m_statusLabel.Text = LanguageControl.Get("ContentWidgets", "RemoteControlDialog", "5");
36 }
37 else {
39 ModsManager.SetConfig("RemoteControlEnabled", "true");
40 m_statusLabel.Text = LanguageControl.Get("ContentWidgets", "RemoteControlDialog", "4");
41 }
42 }
43 if (m_portButton.IsClicked) {
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 }
62 new TextBoxDialog(
63 LanguageControl.Get("ContentWidgets", "RemoteControlDialog", "10"),
65 18,
66 str => {
67 JsInterface.httpPassword = str;
68 ModsManager.SetConfig("RemoteControlPassword", str);
69 }
70 )
71 );
72 }
73 if (Input.Back
74 || Input.Cancel
76 Dismiss();
77 }
78 }
79
80 public void Dismiss() {
82 }
83 }
84}
85#else
86namespace Game {
87 public class RemoteControlDialog : Dialog {
88
89 }
90}
91#endif
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static void StopHttpListener()
static string httpPassword
static HttpListener httpListener
static async Task StartHttpListener()
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
readonly ButtonWidget m_closeButton
readonly LabelWidget m_addressLabel
readonly ButtonWidget m_passwordButton
readonly ButtonWidget m_statusButton
ContainerWidget ParentWidget
virtual void LoadContents(object eventsTarget, XElement node)
static void SetConfig(string key, string value)