1using System.Globalization;
18 public static string fName =
"PlayScreen";
33 containerWidget.Tag = worldInfo;
35 labelWidget2.Text =
string.Format(
36 "{0} | {1} | {2} | {3} | {4}",
46 labelWidget2.Text = $
"{labelWidget2.Text} | {(string.IsNullOrEmpty(worldInfo.SerializationVersion)
47 ? LanguageControl.GetContentWidgets("Usual
", "Unknown")
51 "LoadWorldInfoWidget",
53 loader.LoadWorldInfoWidget(worldInfo, node2, ref containerWidget);
57 return containerWidget;
68 worldsListWidget.ItemWidgetFactory = (Func<object, Widget>)Delegate.Combine(worldsListWidget.ItemWidgetFactory,
WorldInfoWidget);
69 m_worldsListWidget.ScrollPosition = 0f;
70 m_worldsListWidget.ScrollSpeed = 0f;
77 ? CultureInfo.CurrentCulture
82 public override void Enter(
object[] parameters) {
90 worldInfos.Sort((w1, w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime));
98 if (selectedItem !=
null) {
99 m_worldsListWidget.SelectedItem = worldInfos.FirstOrDefault(wi => wi.DirectoryName == selectedItem.
DirectoryName);
108 public override void Update() {
113 m_playButton.Size = size;
114 m_newWorldButton.Size = size;
117 m_worldsListWidget.SelectedItem =
null;
120 Children.Find<LabelWidget>(
"TopBar.Label").Text =
string.Format(
127 Children.Find<LabelWidget>(
"TopBar.Label").Text = LanguageControl.Get(
fName,
"11");
129 m_playButton.IsEnabled = m_worldsListWidget.SelectedItem !=
null;
130 m_propertiesButton.IsEnabled = m_worldsListWidget.SelectedItem !=
null;
136 if (WorldsManager.WorldInfos.Count >=
MaxWorlds) {
137 DialogsManager.ShowDialog(
140 LanguageControl.GetContentWidgets(
fName, 7),
141 string.Format(LanguageControl.GetContentWidgets(
fName, 8),
MaxWorlds),
142 LanguageControl.GetContentWidgets(
"Usual",
"ok"),
149 ScreensManager.SwitchScreen(
"NewWorld");
150 m_worldsListWidget.SelectedItem =
null;
156 ScreensManager.SwitchScreen(
"ModifyWorld", worldInfo.DirectoryName, worldInfo.WorldSettings);
160 ||
Children.Find<ButtonWidget>(
"TopBar.Back").IsClicked) {
161 ScreensManager.SwitchScreen(
"MainMenu");
162 m_worldsListWidget.SelectedItem =
null;
169 public void Play(
object item) {
172 string languageType = !
ModsManager.
Configs.TryGetValue(
"Language", out
string config) ?
"zh-CN" : config;
173 if (languageType ==
"zh-CN"
178 List<ValuesDictionary> modsNotLoaded = [];
179 List<ValuesDictionary> modsVersionNotCapable = [];
180 if (worldInfo !=
null) {
182 if (projectNode !=
null) {
184 if (subsystemUsedModsNode !=
null) {
187 int modsCount = subsystemValuesDictionary.GetValue(
"ModsCount", 0);
189 if (valuesDictionary !=
null) {
190 for (
int i = 0; i < modsCount; i++) {
192 if (modDictionary ==
null) {
196 modDictionary.GetValue(
"PackageName",
string.Empty),
200 modsNotLoaded.Add(modDictionary);
203 bool versionComparePass = modEntity?.Loader?.CompareModVersion(
204 modEntity.modInfo.Version,
205 modDictionary.GetValue(
"Version",
"?")
208 modDictionary.SetValue(
"CurrentVersion", modEntity.modInfo.Version);
209 if (!versionComparePass) {
210 modsVersionNotCapable.Add(modDictionary);
218 if (modsNotLoaded.Count > 0
219 || modsVersionNotCapable.Count > 0) {
220 StringBuilder text =
new();
221 if (modsNotLoaded.Count > 0) {
228 modDictionary.GetValue(
"Name",
"?"),
229 modDictionary.GetValue(
"Version",
"?")
233 if (modsVersionNotCapable.Count > 0) {
240 modDictionary.GetValue(
"Name",
"?"),
241 modDictionary.GetValue(
"Version",
"?"),
242 modDictionary.GetValue(
"CurrentVersion",
"?")
272 item = loader.BeforeGameLoading(
this, item);
277 ScreensManager.SwitchScreen(
"GameLoading", item,
null);
279 m_worldsListWidget.SelectedItem =
null;
283 string tips =
string.Empty;
291 tips += $
"{num}.{modEntity.modInfo.Name}(v{modEntity.modInfo.Version}) {value.Explanation}\n";
300 if (!
string.IsNullOrEmpty(tips)) {
301 DialogsManager.ShowDialog(
304 LanguageControl.Get(
fName,
"1"),
306 LanguageControl.Get(
fName,
"2"),
307 LanguageControl.Back,
324 if (v1.Contains(
"~")) {
325 string[] versions = v1.Split([
'~'], StringSplitOptions.RemoveEmptyEntries);
327 double minv =
double.Parse(versions[0]);
328 double maxv =
double.Parse(versions[1]);
329 double v =
double.Parse(v2);
330 return v >= minv && v <= maxv;
336 if (v1.Contains(
";")) {
337 string[] versions = v1.Split([
';'], StringSplitOptions.RemoveEmptyEntries);
338 foreach (
string v
in versions) {
static void Dispatch(Action action, bool waitUntilCompleted=false)
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static string GetContentWidgets(string name, string prop)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static List< FilterMod > FilterModAll
bool ShowTips(object item)
CultureInfo m_cultureInfo
bool CompareVersion(string v1, string v2)
ButtonWidget m_propertiesButton
Widget WorldInfoWidget(object item)
ButtonWidget m_playButton
void GameLoad(object item)
ListPanelWidget m_worldsListWidget
ButtonWidget m_newWorldButton
override void Enter(object[] parameters)
virtual void OnWorldsListWidgetItemClicked(object item)
static string SystemLanguage
static string SerializationVersion
string SerializationVersion
WorldSettings WorldSettings
List< PlayerInfo > PlayerInfos
EnvironmentBehaviorMode EnvironmentBehaviorMode
static void UpdateWorldsList()
static ReadOnlyList< WorldInfo > WorldInfos
static XElement GetProjectNode(WorldInfo worldInfo)
static XElement GetSubsystemNode(XElement projectNode, string subsystemName)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static bool GetModEntity(string packagename, out ModEntity modEntity)
static List< ModEntity > ModList
所有已启用的模组
static string APIVersionString
static Dictionary< string, string > Configs
void ApplyOverrides(ValuesDictionary overridesValuesDictionary)