Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditCommunityServerInfoDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2
3namespace Game {
7 public bool m_changed;
8 public bool m_toAdd;//false: edit, true: add
9
18
20 m_parentDialog = parentDialog;
21 if (info == null) {
23 m_changed = true;
24 m_toAdd = true;
25 }
27 m_info = info.Clone();
28 m_changed = true;
29 m_toAdd = true;
30 }
31 else {
32 m_info = info;
33 m_changed = false;
34 m_toAdd = false;
35 }
36 if (m_info.Name == string.Empty) {
37 switch (m_info.Type) {
38 case CommunityServerManager.Type.Original:
39 m_info.Name =
40 $"{LanguageControl.Get("ContentScreen", "CommunityType", "OriginalCommunity")} ({LanguageControl.Get("ContentWidgets", "ViewGameLogDialog", "1")})";
41 break;
42 case CommunityServerManager.Type.Chinese:
43 m_info.Name =
44 $"{LanguageControl.Get("ContentScreen", "CommunityType", "ChineseCommunity")} ({LanguageControl.Get("ContentWidgets", "ViewGameLogDialog", "1")})";
45 break;
46 }
47 }
48 XElement node = ContentManager.Get<XElement>("Dialogs/EditCommunityServerInfoDialog");
49 LoadContents(this, node);
50 m_originalCheckbox = Children.Find<CheckboxWidget>("EditCommunityServerInfoDialog.OriginalCheckbox");
51 m_chineseCheckbox = Children.Find<CheckboxWidget>("EditCommunityServerInfoDialog.ChineseCheckbox");
52 m_nameTextBox = Children.Find<TextBoxWidget>("EditCommunityServerInfoDialog.Name");
53 m_apiUrlTextBox = Children.Find<TextBoxWidget>("EditCommunityServerInfoDialog.ApiUrl");
54 m_websiteUrlTextBox = Children.Find<TextBoxWidget>("EditCommunityServerInfoDialog.WebsiteUrl");
55 m_okButton = Children.Find<ButtonWidget>("EditCommunityServerInfoDialog.Ok");
56 m_removeButton = Children.Find<ButtonWidget>("EditCommunityServerInfoDialog.Remove");
57 m_cancelButton = Children.Find<ButtonWidget>("EditCommunityServerInfoDialog.Cancel");
58 if (m_info.Type == CommunityServerManager.Type.Chinese) {
59 m_chineseCheckbox.IsChecked = true;
60 }else {
61 m_originalCheckbox.IsChecked = true;
62 }
63 m_nameTextBox.Text = m_info.Name;
64 m_apiUrlTextBox.Text = m_info.ApiUrl;
65 m_websiteUrlTextBox.Text = m_info.WebsiteUrl;
66 }
67
68 public override void Update() {
69 if (m_originalCheckbox.IsClicked && !m_originalCheckbox.IsChecked) {
70 m_originalCheckbox.IsChecked = true;
71 m_chineseCheckbox.IsChecked = false;
72 m_changed = true;
73 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
74 }
75 if (m_chineseCheckbox.IsClicked && !m_chineseCheckbox.IsChecked) {
76 m_originalCheckbox.IsChecked = false;
77 m_chineseCheckbox.IsChecked = true;
78 m_changed = true;
79 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
80 }
81 if (m_nameTextBox.Text != m_info.Name) {
82 m_changed = true;
83 }
84 if (m_apiUrlTextBox.Text != m_info.ApiUrl) {
85 m_changed = true;
86 }
87 if (m_websiteUrlTextBox.Text != m_info.WebsiteUrl) {
88 m_changed = true;
89 }
90 m_removeButton.IsEnabled = !m_changed;
91 if (m_okButton.IsClicked) {
92 if (m_changed) {
93 if (m_toAdd) {
94 m_parentDialog.AddServer(m_info);
95 }
96 else {
97 m_info.Type = m_chineseCheckbox.IsChecked ? CommunityServerManager.Type.Chinese : CommunityServerManager.Type.Original;
98 m_info.Name = m_nameTextBox.Text;
99 m_info.ApiUrl = m_apiUrlTextBox.Text;
100 m_info.WebsiteUrl = m_websiteUrlTextBox.Text;
101 m_parentDialog.UpdateServerList();
102 m_parentDialog.m_listPanel.SelectedItem = m_info;
103 }
104 }
106 }
107 if (m_removeButton.IsClicked && !m_changed) {
108 m_parentDialog.RemoveServer(m_info);
110 }
111 if (Input.Back
112 || Input.Cancel
113 || (Input.Tap.HasValue && !HitTest(Input.Tap.Value))
114 || m_cancelButton.IsClicked) {
116 }
117 }
118 }
119}
static void PlaySound(string name, float volume, float pitch, float pan)
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
EditCommunityServerInfoDialog(SelectCommunityServerDialog parentDialog, CommunityServerManager.Info info=null)
virtual bool HitTest(Vector2 point)
virtual void LoadContents(object eventsTarget, XElement node)