Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ModifyWorldScreen.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
4
5namespace Game {
6 public class ModifyWorldScreen : Screen {
8
10
12
14
16
18
20
22
24
25 public string m_directoryName;
26
28
30
32
34
36
37 public bool m_cruelAllowed = true;
38
39 public const string fName = "ModifyWorldScreen";
40
42 XElement node = ContentManager.Get<XElement>("Screens/ModifyWorldScreen");
43 LoadContents(this, node);
44 m_nameTextBox = Children.Find<TextBoxWidget>("Name");
45 m_seedLabel = Children.Find<LabelWidget>("Seed");
46 m_gameModeButton = Children.Find<ButtonWidget>("GameMode");
47 m_worldOptionsButton = Children.Find<ButtonWidget>("WorldOptions");
48 m_errorLabel = Children.Find<LabelWidget>("Error");
49 m_descriptionLabel = Children.Find<LabelWidget>("Description");
50 m_applyButton = Children.Find<ButtonWidget>("Apply");
51 m_deleteButton = Children.Find<ButtonWidget>("Delete");
52 m_uploadButton = Children.Find<ButtonWidget>("Upload");
53 m_nameTextBox.TextChanged += delegate { m_worldSettings.Name = m_nameTextBox.Text; };
54 m_nameTextBox.MaximumLength = 128;
55 }
56
57 public override void Enter(object[] parameters) {
59 m_directoryName = (string)parameters[0];
60 m_worldSettings = (WorldSettings)parameters[1];
65 m_changingGameModeAllowed = m_worldSettings.GameMode != GameMode.Cruel;
66 }
67 }
68
69 public override void Update() {
72 null,
73 new SelectGameModeDialog(string.Empty, true, m_cruelAllowed, delegate(GameMode gameMode) { m_worldSettings.GameMode = gameMode; })
74 );
75 }
76 m_worldSettingsData.Clear();
80 m_nameTextBox.Text = m_worldSettings.Name;
81 m_seedLabel.Text = $"{(string.IsNullOrEmpty(m_worldSettings.Seed) ? LanguageControl.Get(fName, "6") : m_worldSettings.Seed)} ({m_worldSettings.WorldSeed})";
82 m_gameModeButton.Text = LanguageControl.Get("GameMode", m_worldSettings.GameMode.ToString());
83 m_gameModeButton.IsEnabled = m_changingGameModeAllowed;
84 m_errorLabel.IsVisible = !flag2;
85 m_descriptionLabel.IsVisible = flag2;
86 m_uploadButton.IsEnabled = flag2 && !flag;
87 m_applyButton.IsEnabled = flag2 && flag;
88 m_descriptionLabel.Text = StringsManager.GetString($"GameMode.{m_worldSettings.GameMode}.Description");
89 if (m_worldOptionsButton.IsClicked) {
90 ScreensManager.SwitchScreen("WorldOptions", m_worldSettings, true);
91 }
92 if (m_deleteButton.IsClicked) {
93 Dialog dialog = null;
95 TextBoxDialog textBoxDialog = new(
97 string.Empty,
98 3,
99 delegate(string content) {
100 if (content?.ToLower() == "yes") {
103 // ReSharper disable AccessToModifiedClosure
105 }
106 else {
108 }
109 }
110 );
111 dialog = textBoxDialog;
112 textBoxDialog.Children.Find<LabelWidget>("TextBoxDialog.Title").Color = Color.Red;
113 textBoxDialog.AutoHide = false;
114 }
115 else {
116 dialog = new MessageDialog(
121 delegate(MessageDialogButton button) {
122 if (button == MessageDialogButton.Button1) {
126 }
127 else {
129 // ReSharper restore AccessToModifiedClosure
130 }
131 }
132 );
133 }
134 DialogsManager.ShowDialog(null, dialog);
135 }
136 if (m_uploadButton.IsClicked
137 && flag2
138 && !flag) {
140 }
141 if (m_applyButton.IsClicked
142 && flag2
143 && flag) {
144 if (m_worldSettings.GameMode != 0
145 && m_worldSettings.GameMode != GameMode.Adventure) {
146 m_worldSettings.ResetOptionsForNonCreativeMode(null);
147 }
150 }
151 if (!Input.Back
152 && !Input.Cancel
153 && !Children.Find<ButtonWidget>("TopBar.Back").IsClicked) {
154 return;
155 }
156 if (flag) {
158 null,
159 new MessageDialog(
164 delegate(MessageDialogButton button) {
165 if (button == MessageDialogButton.Button1) {
167 }
168 }
169 )
170 );
171 }
172 else {
174 }
175 }
176
178 if (d1.Count != d2.Count) {
179 return false;
180 }
181 foreach (KeyValuePair<string, object> item in d1) {
182 object value = d2.GetValue<object>(item.Key, null);
183 if (value is ValuesDictionary valuesDictionary) {
184 if (item.Value is not ValuesDictionary valuesDictionary2
185 || !CompareValueDictionaries(valuesDictionary, valuesDictionary2)) {
186 return false;
187 }
188 }
189 else if (!Equals(value, item.Value)) {
190 return false;
191 }
192 }
193 return true;
194 }
195 }
196}
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static void ShowUploadUi(ExternalContentType type, string name)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
ValuesDictionary m_originalWorldSettingsData
static bool CompareValueDictionaries(ValuesDictionary d1, ValuesDictionary d2)
override void Enter(object[] parameters)
static Screen PreviousScreen
上一个Screen
static void SwitchScreen(string name, params object[] parameters)
static string GetString(string name)
virtual void LoadContents(object eventsTarget, XElement node)
Widget Find(string name, Type type, bool throwIfNotFound=true)
static bool ValidateWorldName(string name)
static void DeleteWorld(string directoryName)
static void ChangeWorld(string directoryName, WorldSettings worldSettings)
模组调整世界设置的界面需要继承该接口
static Color Red