Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SelectCommunityServerDialog.cs
浏览该文件的文档.
1using Engine;
2using System.Xml.Linq;
3
4namespace Game {
10
12 XElement node = ContentManager.Get<XElement>("Dialogs/SelectCommunityServerDialog");
13 LoadContents(this, node);
14 m_listPanel = Children.Find<ListPanelWidget>("SelectCommunityServerDialog.ListPanel");
15 m_openButton = Children.Find<ButtonWidget>("SelectCommunityServerDialog.Open");
16 m_addButton = Children.Find<ButtonWidget>("SelectCommunityServerDialog.Add");
17 m_editButton = Children.Find<ButtonWidget>("SelectCommunityServerDialog.Edit");
18 m_listPanel.ItemWidgetFactory = o => {
19 if (o is not CommunityServerManager.Info info) {
20 return null;
21 }
22 LabelWidget labelWidget = new () {
25 };
27 labelWidget.Text = LanguageControl.Get("ContentScreen", "CommunityType", "OriginalCommunity");
28 }
30 labelWidget.Text = LanguageControl.Get("ContentScreen", "CommunityType", "ChineseCommunity");
31 }
32 else {
33 labelWidget.Text = info.Name;
34 }
35 return labelWidget;
36 };
37 m_listPanel.ItemClicked = o => {
38 if (o == m_listPanel.SelectedItem
39 && o is CommunityServerManager.Info info) {
40 OpenServerScreen(info);
42 }
43 };
45 }
46
47 public void UpdateServerList() {
48 m_listPanel.ClearItems();
50 m_listPanel.ScrollPosition = 0f;
51 }
52
55 m_listPanel.AddItem(info);
56 m_listPanel.SelectedItem = info;
57 }
58
61 m_listPanel.RemoveItem(info);
62 }
63
65 if (info == null) {
66 return;
67 }
68 switch (info.Type) {
69 case CommunityServerManager.Type.Original:
71 ScreensManager.SwitchScreen("OriginalCommunityContent");
72 break;
73 case CommunityServerManager.Type.Chinese:
75 ScreensManager.SwitchScreen("CommunityContent");
76 break;
77 }
78 }
79
80 public override void Update() {
81 if (m_listPanel.SelectedItem is CommunityServerManager.Info selected) {
82 if (m_openButton.IsClicked) {
83 OpenServerScreen(selected);
85 }
86 if (m_editButton.IsClicked) {
88 }
89 }
90 if (m_addButton.IsClicked) {
92 }
93 if (Input.Back
94 || Input.Cancel
95 || (Input.Tap.HasValue && !HitTest(Input.Tap.Value))) {
97 }
98 }
99 }
100}
static IEnumerable< Info > GetAllInfos()
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static void SwitchScreen(string name, params object[] parameters)
void OpenServerScreen(CommunityServerManager.Info info)
void RemoveServer(CommunityServerManager.Info info)
void AddServer(CommunityServerManager.Info info)
virtual bool HitTest(Vector2 point)
virtual WidgetAlignment VerticalAlignment
virtual WidgetAlignment HorizontalAlignment
virtual void LoadContents(object eventsTarget, XElement node)