public override void Update() { if (m_singlethreadedTerrainUpdateButton.IsClicked) { SettingsManager.MultithreadedTerrainUpdate = !SettingsManager.MultithreadedTerrainUpdate; m_descriptionLabel.Text = StringsManager.GetString("Settings.Compatibility.SinglethreadedTerrainUpdate.Description"); } if (m_useReducedZRangeButton.IsClicked) { SettingsManager.UseReducedZRange = !SettingsManager.UseReducedZRange; m_descriptionLabel.Text = StringsManager.GetString("Settings.Compatibility.UseReducedZRange.Description"); } if (m_viewGameLogButton.IsClicked) { DialogsManager.ShowDialog(null, new ViewGameLogDialog()); } if (m_resetDefaultsButton.IsClicked) { SettingsManager.MultithreadedTerrainUpdate = true; SettingsManager.UseReducedZRange = false; } if (m_useAudioTrackCachingButton.IsClicked) { SettingsManager.EnableAndroidAudioTrackCaching = !SettingsManager.EnableAndroidAudioTrackCaching; } m_singlethreadedTerrainUpdateButton.Text = (SettingsManager.MultithreadedTerrainUpdate ? LanguageControl.Get("Usual", "off") : LanguageControl.Get("Usual", "on")); m_useReducedZRangeButton.Text = (SettingsManager.UseReducedZRange ? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_useAudioTrackCachingButton.Text = (SettingsManager.EnableAndroidAudioTrackCaching? LanguageControl.Get("Usual", "on") : LanguageControl.Get("Usual", "off")); m_resetDefaultsButton.IsEnabled = (!SettingsManager.MultithreadedTerrainUpdate || SettingsManager.UseReducedZRange); if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } }
public static object Get(Type type, string name) { if (type == typeof(Subtexture)) { return(TextureAtlasManager.GetSubtexture(name)); } if (type == typeof(string) && name.StartsWith("Strings/")) { return(StringsManager.GetString(name.Substring(8))); } object obj = Get(name); if (!type.GetTypeInfo().IsAssignableFrom(obj.GetType().GetTypeInfo())) { throw new InvalidOperationException(string.Format(LanguageControl.Get("ContentManager", "1"), name, obj.GetType().FullName, type.FullName)); } return(obj); }
public static object Get(Type type, string name) { if (type == typeof(Subtexture)) { return(TextureAtlasManager.GetSubtexture(name)); } if (type == typeof(string) && name.StartsWith("Strings/")) { return(StringsManager.GetString(name.Substring(8))); } var obj = Get(name); if (!type.GetTypeInfo().IsAssignableFrom(obj.GetType().GetTypeInfo())) { throw new InvalidOperationException(string.Format("Content \"{0}\" has type {1}, requested type was {2}", name, obj.GetType().FullName, type.FullName)); } return(obj); }
public override void Update() { if (m_gameModeButton.IsClicked) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(GameMode)); m_worldSettings.GameMode = (GameMode)((enumValues.IndexOf((int)m_worldSettings.GameMode) + 1) % enumValues.Count); while (m_worldSettings.GameMode == GameMode.Adventure) { m_worldSettings.GameMode = (GameMode)((enumValues.IndexOf((int)m_worldSettings.GameMode) + 1) % enumValues.Count); } } if (m_startingPositionButton.IsClicked) { IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(StartingPositionMode)); m_worldSettings.StartingPositionMode = (StartingPositionMode)((enumValues2.IndexOf((int)m_worldSettings.StartingPositionMode) + 1) % enumValues2.Count); } bool flag = WorldsManager.ValidateWorldName(m_worldSettings.Name); m_nameTextBox.Text = m_worldSettings.Name; m_seedTextBox.Text = m_worldSettings.Seed; m_gameModeButton.Text = LanguageControl.Get("GameMode", m_worldSettings.GameMode.ToString()); m_startingPositionButton.Text = LanguageControl.Get("StartingPositionMode", m_worldSettings.StartingPositionMode.ToString()); m_playButton.IsVisible = flag; m_errorLabel.IsVisible = !flag; m_blankSeedLabel.IsVisible = (m_worldSettings.Seed.Length == 0 && !m_seedTextBox.HasFocus); m_descriptionLabel.Text = StringsManager.GetString("GameMode." + m_worldSettings.GameMode.ToString() + ".Description"); if (m_worldOptionsButton.IsClicked) { ScreensManager.SwitchScreen("WorldOptions", m_worldSettings, false); } if (m_playButton.IsClicked && WorldsManager.ValidateWorldName(m_nameTextBox.Text)) { if (m_worldSettings.GameMode != 0) { m_worldSettings.ResetOptionsForNonCreativeMode(); } WorldInfo worldInfo = WorldsManager.CreateWorld(m_worldSettings); ScreensManager.SwitchScreen("GameLoading", worldInfo, null); } if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen("Play"); } }
public LoadingScreen() { WidgetsManager.LoadWidgetContents((Widget)this.ScreenWidget, (object)this, ContentManager.Get <XElement>("Screens/LoadingScreen")); LabelWidget ExternalAssemblyInfo = new LabelWidget(); ExternalAssemblyInfo.Text = "Powered By GScience Studio\n"; //下列两行代码请勿随意删除 ExternalAssemblyInfo.Text += "Author:" + Info.author + "\n"; ExternalAssemblyInfo.Text += "Version:" + Info.version; ExternalAssemblyInfo.Color = Color.LightBlue; ExternalAssemblyInfo.FontScale = 0.5f; this.ScreenWidget.Children.Add(ExternalAssemblyInfo); this.AddLoadAction((Action)(() => CommunityContentManager.Initialize())); this.AddLoadAction((Action)(() => MotdManager.Initialize())); this.AddLoadAction((Action)(() => LightingManager.Initialize())); this.AddLoadAction((Action)(() => StringsManager.LoadStrings())); this.AddLoadAction((Action)(() => TextureAtlasManager.LoadAtlases())); ReadOnlyList <ContentInfo> readOnlyList = ContentManager.List(); // ISSUE: explicit reference operation using (ReadOnlyList <ContentInfo> .Enumerator enumerator = ((ReadOnlyList <ContentInfo>)@readOnlyList).GetEnumerator()) { // ISSUE: explicit reference operation while (((ReadOnlyList <ContentInfo> .Enumerator)@enumerator).MoveNext()) { // ISSUE: explicit reference operation ContentInfo localContentInfo = ((ReadOnlyList <ContentInfo> .Enumerator)@enumerator).Current; this.AddLoadAction((Action)(() => ContentManager.Get((string)localContentInfo.Name))); } } this.AddLoadAction((Action)(() => DatabaseManager.LoadDatabase())); this.AddLoadAction((Action)(() => WorldsManager.Initialize())); this.AddLoadAction((Action)(() => BlocksTexturesManager.Initialize())); this.AddLoadAction((Action)(() => CharacterSkinsManager.Initialize())); this.AddLoadAction((Action)(() => FurniturePacksManager.Initialize())); this.AddLoadAction((Action)(() => BlocksManager.Initialize())); this.AddLoadAction((Action)(() => CraftingRecipesManager.Initialize())); this.AddLoadAction((Action)(() => GScienceStudio.InputManager.Initialize())); }
public GameMenuDialog(ComponentPlayer componentPlayer) { XElement node = ContentManager.Get <XElement>("Dialogs/GameMenuDialog"); LoadContents(this, node); m_statsPanel = Children.Find <StackPanelWidget>("StatsPanel"); m_componentPlayer = componentPlayer; m_adventureRestartExists = WorldsManager.SnapshotExists(GameManager.WorldInfo.DirectoryName, "AdventureRestart"); if (!m_increaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f < 25f && (SettingsManager.VisibilityRange <= 64 || SettingsManager.ResolutionMode == ResolutionMode.Low)) { m_increaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] IncreaseDetailDialog Shown"); } if (!m_decreaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f > 50f && (SettingsManager.VisibilityRange >= 64 || SettingsManager.ResolutionMode == ResolutionMode.High)) { m_decreaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] DecreaseDetailDialog Shown"); } m_statsPanel.Children.Clear(); Project project = componentPlayer.Project; PlayerData playerData = componentPlayer.PlayerData; PlayerStats playerStats = componentPlayer.PlayerStats; SubsystemGameInfo subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true); BitmapFont font = ContentManager.Get <BitmapFont>("Fonts/Pericles"); BitmapFont font2 = ContentManager.Get <BitmapFont>("Fonts/Pericles"); Color white = Color.White; StackPanelWidget stackPanelWidget = new StackPanelWidget { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center }; m_statsPanel.Children.Add(stackPanelWidget); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 5), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 6), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()) + ", " + LanguageControl.Get("EnvironmentBehaviorMode", subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode.ToString())); AddStat(stackPanelWidget, LanguageControl.Get(fName, 7), StringsManager.GetString("TerrainGenerationMode." + subsystemGameInfo.WorldSettings.TerrainGenerationMode.ToString() + ".Name")); string seed = subsystemGameInfo.WorldSettings.Seed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 8), (!string.IsNullOrEmpty(seed)) ? seed : LanguageControl.Get(fName, 9)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 10), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.SeaLevelOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 11), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.TemperatureOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x"); int num = 0; for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++) { if (subsystemFurnitureBlockBehavior.GetDesign(i) != null) { num++; } } AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 17), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 18), playerData.Name); AddStat(stackPanelWidget, LanguageControl.Get(fName, 19), playerData.PlayerClass.ToString()); string value = (playerData.FirstSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.FirstSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 20)) : LanguageControl.Get(fName, 21); AddStat(stackPanelWidget, LanguageControl.Get(fName, 22), value); string value2 = (playerData.LastSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.LastSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 23)) : LanguageControl.Get(fName, 24); AddStat(stackPanelWidget, LanguageControl.Get(fName, 25), value2); AddStat(stackPanelWidget, LanguageControl.Get(fName, 26), MathUtils.Max(playerData.SpawnsCount - 1, 0).ToString("N0") + LanguageControl.Get(fName, 27)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 28), string.Format(LanguageControl.Get(fName, 29), ((int)MathUtils.Floor(playerStats.HighestLevel)).ToString("N0"))); if (componentPlayer != null) { Vector3 position = componentPlayer.ComponentBody.Position; if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative) { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 31), $"{position.X:0}", $"{position.Z:0}", $"{position.Y:0}")); } else { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 32), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()))); } } if (string.CompareOrdinal(subsystemGameInfo.WorldSettings.OriginalSerializationVersion, "1.29") > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 33), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 34), playerStats.PlayerKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 35), playerStats.LandCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 36), playerStats.WaterCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 37), playerStats.AirCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 38), playerStats.MeleeAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 39), playerStats.MeleeHits.ToString("N0"), $"({((playerStats.MeleeHits == 0L) ? 0.0 : ((double)playerStats.MeleeHits / (double)playerStats.MeleeAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 40), playerStats.RangedAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 41), playerStats.RangedHits.ToString("N0"), $"({((playerStats.RangedHits == 0L) ? 0.0 : ((double)playerStats.RangedHits / (double)playerStats.RangedAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 42), playerStats.HitsReceived.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 43), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 44), playerStats.BlocksDug.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 45), playerStats.BlocksPlaced.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 46), playerStats.BlocksInteracted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 47), playerStats.ItemsCrafted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 48), playerStats.FurnitureItemsMade.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 49), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 50), FormatDistance(playerStats.DistanceTravelled)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 51), FormatDistance(playerStats.DistanceWalked), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceWalked / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 52), FormatDistance(playerStats.DistanceFallen), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFallen / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 53), FormatDistance(playerStats.DistanceClimbed), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceClimbed / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 54), FormatDistance(playerStats.DistanceFlown), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFlown / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 55), FormatDistance(playerStats.DistanceSwam), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceSwam / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 56), FormatDistance(playerStats.DistanceRidden), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceRidden / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 57), FormatDistance(playerStats.LowestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 58), FormatDistance(playerStats.HighestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 59), playerStats.DeepestDive.ToString("N1") + "m"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 60), playerStats.Jumps.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 61), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 62), (playerStats.TotalHealthLost * 100.0).ToString("N0") + "%"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 63), playerStats.FoodItemsEaten.ToString("N0") + LanguageControl.Get(fName, 64)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 65), playerStats.TimesWentToSleep.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 67), (playerStats.TimeSlept / 1200.0).ToString("N1") + LanguageControl.Get(fName, 68)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 69), playerStats.TimesWasSick.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 70), playerStats.TimesPuked.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 71), playerStats.TimesHadFlu.ToString("N0") + LanguageControl.Get(fName, 66)); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 72), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 73), playerStats.StruckByLightning.ToString("N0") + LanguageControl.Get(fName, 66)); GameMode easiestModeUsed = playerStats.EasiestModeUsed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 74), LanguageControl.Get("GameMode", easiestModeUsed.ToString())); if (playerStats.DeathRecords.Count > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 75), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); foreach (PlayerStats.DeathRecord deathRecord in playerStats.DeathRecords) { float num2 = (float)MathUtils.Remainder(deathRecord.Day, 1.0); string arg = (!(num2 < 0.2f) && !(num2 >= 0.8f)) ? ((!(num2 >= 0.7f)) ? ((!(num2 >= 0.5f)) ? LanguageControl.Get(fName, 76) : LanguageControl.Get(fName, 77)) : LanguageControl.Get(fName, 78)) : LanguageControl.Get(fName, 79); AddStat(stackPanelWidget, string.Format(LanguageControl.Get(fName, 80), MathUtils.Floor(deathRecord.Day) + 1.0, arg), "", deathRecord.Cause); } } } else { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 81), WordWrap = true, Font = font2, HorizontalAlignment = WidgetAlignment.Center, TextAnchor = TextAnchor.HorizontalCenter, Margin = new Vector2(20f, 10f), Color = white }); } }
public LoadingScreen() { XElement node = ContentManager.Get <XElement>("Screens/LoadingScreen"); LoadContents(this, node); AddLoadAction(delegate { VrManager.Initialize(); }); AddLoadAction(delegate { CommunityContentManager.Initialize(); }); AddLoadAction(delegate { MotdManager.Initialize(); }); AddLoadAction(delegate { LightingManager.Initialize(); }); AddLoadAction(delegate { StringsManager.LoadStrings(); }); AddLoadAction(delegate { TextureAtlasManager.LoadAtlases(); }); foreach (ContentInfo item in ContentManager.List()) { ContentInfo localContentInfo = item; AddLoadAction(delegate { ContentManager.Get(localContentInfo.Name); }); } AddLoadAction(delegate { DatabaseManager.Initialize(); }); AddLoadAction(delegate { WorldsManager.Initialize(); }); AddLoadAction(delegate { BlocksTexturesManager.Initialize(); }); AddLoadAction(delegate { CharacterSkinsManager.Initialize(); }); AddLoadAction(delegate { FurniturePacksManager.Initialize(); }); AddLoadAction(delegate { BlocksManager.Initialize(); }); AddLoadAction(delegate { CraftingRecipesManager.Initialize(); }); AddLoadAction(delegate { MusicManager.CurrentMix = MusicManager.Mix.Menu; }); }
public override void Update() { if (m_gameModeButton.IsClicked && m_worldSettings.GameMode != GameMode.Cruel) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(GameMode)); do { m_worldSettings.GameMode = (GameMode)((enumValues.IndexOf((int)m_worldSettings.GameMode) + 1) % enumValues.Count); }while (m_worldSettings.GameMode == GameMode.Cruel); m_descriptionLabel.Text = StringsManager.GetString("GameMode." + m_worldSettings.GameMode.ToString() + ".Description"); } m_currentWorldSettingsData.Clear(); m_worldSettings.Save(m_currentWorldSettingsData, liveModifiableParametersOnly: true); bool flag = !CompareValueDictionaries(m_originalWorldSettingsData, m_currentWorldSettingsData); bool flag2 = WorldsManager.ValidateWorldName(m_worldSettings.Name); m_nameTextBox.Text = m_worldSettings.Name; m_seedLabel.Text = m_worldSettings.Seed; m_gameModeButton.Text = LanguageControl.Get("GameMode", m_worldSettings.GameMode.ToString()); m_gameModeButton.IsEnabled = (m_worldSettings.GameMode != GameMode.Cruel); m_errorLabel.IsVisible = !flag2; m_descriptionLabel.IsVisible = flag2; m_uploadButton.IsEnabled = (flag2 && !flag); m_applyButton.IsEnabled = (flag2 && flag); m_descriptionLabel.Text = StringsManager.GetString("GameMode." + m_worldSettings.GameMode.ToString() + ".Description"); if (m_worldOptionsButton.IsClicked) { ScreensManager.SwitchScreen("WorldOptions", m_worldSettings, true); } if (m_deleteButton.IsClicked) { MessageDialog dialog = null; dialog = new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button) { if (button == MessageDialogButton.Button1) { WorldsManager.DeleteWorld(m_directoryName); ScreensManager.SwitchScreen("Play"); DialogsManager.HideDialog(dialog); } else { DialogsManager.HideDialog(dialog); } }); dialog.AutoHide = false; DialogsManager.ShowDialog(null, dialog); } if (m_uploadButton.IsClicked && flag2 && !flag) { ExternalContentManager.ShowUploadUi(ExternalContentType.World, m_directoryName); } if ((m_applyButton.IsClicked && flag2) & flag) { if (m_worldSettings.GameMode != 0 && m_worldSettings.GameMode != GameMode.Adventure) { m_worldSettings.ResetOptionsForNonCreativeMode(); } WorldsManager.ChangeWorld(m_directoryName, m_worldSettings); ScreensManager.SwitchScreen("Play"); } if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { if (flag) { DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton button) { if (button == MessageDialogButton.Button1) { ScreensManager.SwitchScreen("Play"); } })); } else { ScreensManager.SwitchScreen("Play"); } } }
public override void Update() { if (m_addPlayerButton.IsClicked) { SubsystemGameInfo subsystemGameInfo = m_subsystemPlayers.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Cruel) { DialogsManager.ShowDialog(null, new MessageDialog("Unavailable", "Cannot add players in cruel mode.", LanguageControl.Get("Usual", "ok"), null, null)); } else if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure) { DialogsManager.ShowDialog(null, new MessageDialog("Unavailable", "Cannot add players in adventure mode.", LanguageControl.Get("Usual", "ok"), null, null)); } else if (m_subsystemPlayers.PlayersData.Count >= 4) { DialogsManager.ShowDialog(null, new MessageDialog("Unavailable", $"A maximum of {4} players are allowed.", LanguageControl.Get("Usual", "ok"), null, null)); } else { ScreensManager.SwitchScreen("Player", PlayerScreen.Mode.Add, m_subsystemPlayers.Project); } } if (m_screenLayoutButton.IsClicked) { ScreenLayout[] array = null; if (m_subsystemPlayers.PlayersData.Count == 1) { array = new ScreenLayout[1]; } else if (m_subsystemPlayers.PlayersData.Count == 2) { array = new ScreenLayout[3] { ScreenLayout.DoubleVertical, ScreenLayout.DoubleHorizontal, ScreenLayout.DoubleOpposite }; } else if (m_subsystemPlayers.PlayersData.Count == 3) { array = new ScreenLayout[4] { ScreenLayout.TripleVertical, ScreenLayout.TripleHorizontal, ScreenLayout.TripleEven, ScreenLayout.TripleOpposite }; } else if (m_subsystemPlayers.PlayersData.Count == 4) { array = new ScreenLayout[2] { ScreenLayout.Quadruple, ScreenLayout.QuadrupleOpposite }; } if (array != null) { DialogsManager.ShowDialog(null, new ListSelectionDialog("Select Screen Layout", array, 80f, delegate(object o) { string str = o.ToString(); string name = "Textures/Atlas/ScreenLayout" + str; return(new StackPanelWidget { Direction = LayoutDirection.Horizontal, VerticalAlignment = WidgetAlignment.Center, Children = { (Widget) new RectangleWidget { Size = new Vector2(98f, 56f), Subtexture = ContentManager.Get <Subtexture>(name), FillColor = Color.White, OutlineColor = Color.Transparent, Margin = new Vector2(10f, 0f) }, (Widget) new StackPanelWidget { Direction = LayoutDirection.Vertical, VerticalAlignment = WidgetAlignment.Center, Margin = new Vector2(10f, 0f), Children = { (Widget) new LabelWidget { Text = StringsManager.GetString("ScreenLayout." + str + ".Name"), Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }, (Widget) new LabelWidget { Text = StringsManager.GetString("ScreenLayout." + str + ".Description"), Font = ContentManager.Get <BitmapFont>("Fonts/Pericles"), Color = Color.Gray } } } } }); }, delegate(object o) { if (o != null) { if (m_subsystemPlayers.PlayersData.Count == 1) { SettingsManager.ScreenLayout1 = (ScreenLayout)o; } if (m_subsystemPlayers.PlayersData.Count == 2) { SettingsManager.ScreenLayout2 = (ScreenLayout)o; } if (m_subsystemPlayers.PlayersData.Count == 3) { SettingsManager.ScreenLayout3 = (ScreenLayout)o; } if (m_subsystemPlayers.PlayersData.Count == 4) { SettingsManager.ScreenLayout4 = (ScreenLayout)o; } } })); } } if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen("Game"); } }
public override void Update() { if (m_terrainGenerationButton.IsClicked && !m_isExistingWorld) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(TerrainGenerationMode)); DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 1), enumValues, 56f, (object e) => StringsManager.GetString("TerrainGenerationMode." + ((TerrainGenerationMode)e).ToString() + ".Name"), delegate(object e) { if (m_worldSettings.GameMode != 0 && ((TerrainGenerationMode)e == TerrainGenerationMode.FlatContinent || (TerrainGenerationMode)e == TerrainGenerationMode.FlatIsland)) { DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 4), LanguageControl.Get(fName, 5), LanguageControl.Get("Usual", "ok"), null, null)); } else { m_worldSettings.TerrainGenerationMode = (TerrainGenerationMode)e; m_descriptionLabel.Text = StringsManager.GetString("TerrainGenerationMode." + m_worldSettings.TerrainGenerationMode.ToString() + ".Description"); } })); } if (m_islandSizeEW.IsSliding && !m_isExistingWorld) { m_worldSettings.IslandSize.X = m_islandSizes[MathUtils.Clamp((int)m_islandSizeEW.Value, 0, m_islandSizes.Length - 1)]; } if (m_islandSizeNS.IsSliding && !m_isExistingWorld) { m_worldSettings.IslandSize.Y = m_islandSizes[MathUtils.Clamp((int)m_islandSizeNS.Value, 0, m_islandSizes.Length - 1)]; } if (m_flatTerrainLevelSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.TerrainLevel = MathUtils.Clamp((int)m_flatTerrainLevelSlider.Value / (int)m_flatTerrainLevelSlider.Granularity * (int)m_flatTerrainLevelSlider.Granularity, 2, 252); m_descriptionLabel.Text = StringsManager.GetString("FlatTerrainLevel.Description"); } if (m_flatTerrainShoreRoughnessSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.ShoreRoughness = m_flatTerrainShoreRoughnessSlider.Value; m_descriptionLabel.Text = StringsManager.GetString("FlatTerrainShoreRoughness.Description"); } if (m_flatTerrainBlockButton.IsClicked && !m_isExistingWorld) { int[] items = new int[19] { 8, 2, 7, 3, 67, 66, 4, 5, 26, 73, 21, 46, 47, 15, 62, 68, 126, 71, 1 }; DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 2), items, 72f, delegate(object index) { XElement node2 = ContentManager.Get <XElement>("Widgets/SelectBlockItem"); ContainerWidget obj2 = (ContainerWidget)Widget.LoadWidget(null, node2, null); obj2.Children.Find <BlockIconWidget>("SelectBlockItem.Block").Contents = (int)index; obj2.Children.Find <LabelWidget>("SelectBlockItem.Text").Text = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index)); return(obj2); }, delegate(object index) { m_worldSettings.TerrainBlockIndex = (int)index; })); } if (m_flatTerrainMagmaOceanCheckbox.IsClicked) { m_worldSettings.TerrainOceanBlockIndex = ((m_worldSettings.TerrainOceanBlockIndex == 18) ? 92 : 18); m_descriptionLabel.Text = StringsManager.GetString("FlatTerrainMagmaOcean.Description"); } if (m_seaLevelOffsetSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.SeaLevelOffset = (int)m_seaLevelOffsetSlider.Value; m_descriptionLabel.Text = StringsManager.GetString("SeaLevelOffset.Description"); } if (m_temperatureOffsetSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.TemperatureOffset = m_temperatureOffsetSlider.Value; m_descriptionLabel.Text = StringsManager.GetString("TemperatureOffset.Description"); } if (m_humidityOffsetSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.HumidityOffset = m_humidityOffsetSlider.Value; m_descriptionLabel.Text = StringsManager.GetString("HumidityOffset.Description"); } if (m_biomeSizeSlider.IsSliding && !m_isExistingWorld) { m_worldSettings.BiomeSize = m_biomeSizes[MathUtils.Clamp((int)m_biomeSizeSlider.Value, 0, m_biomeSizes.Length - 1)]; m_descriptionLabel.Text = StringsManager.GetString("BiomeSize.Description"); } if (m_blocksTextureButton.IsClicked) { BlocksTexturesManager.UpdateBlocksTexturesList(); ListSelectionDialog dialog = new ListSelectionDialog(LanguageControl.Get(fName, 3), BlocksTexturesManager.BlockTexturesNames, 64f, delegate(object item) { XElement node = ContentManager.Get <XElement>("Widgets/BlocksTextureItem"); ContainerWidget obj = (ContainerWidget)Widget.LoadWidget(this, node, null); Texture2D texture2 = m_blockTexturesCache.GetTexture((string)item); obj.Children.Find <LabelWidget>("BlocksTextureItem.Text").Text = BlocksTexturesManager.GetDisplayName((string)item); obj.Children.Find <LabelWidget>("BlocksTextureItem.Details").Text = $"{texture2.Width}x{texture2.Height}"; obj.Children.Find <RectangleWidget>("BlocksTextureItem.Icon").Subtexture = new Subtexture(texture2, Vector2.Zero, Vector2.One); return(obj); }, delegate(object item) { m_worldSettings.BlocksTextureName = (string)item; }); DialogsManager.ShowDialog(null, dialog); m_descriptionLabel.Text = StringsManager.GetString("BlocksTexture.Description"); } if (m_paletteButton.IsClicked) { DialogsManager.ShowDialog(null, new EditPaletteDialog(m_worldSettings.Palette)); } if (m_supernaturalCreaturesButton.IsClicked) { m_worldSettings.AreSupernaturalCreaturesEnabled = !m_worldSettings.AreSupernaturalCreaturesEnabled; m_descriptionLabel.Text = StringsManager.GetString("SupernaturalCreatures." + m_worldSettings.AreSupernaturalCreaturesEnabled.ToString()); } if (m_friendlyFireButton.IsClicked) { m_worldSettings.IsFriendlyFireEnabled = !m_worldSettings.IsFriendlyFireEnabled; m_descriptionLabel.Text = StringsManager.GetString("FriendlyFire." + m_worldSettings.IsFriendlyFireEnabled.ToString()); } if (m_environmentBehaviorButton.IsClicked) { IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(EnvironmentBehaviorMode)); m_worldSettings.EnvironmentBehaviorMode = (EnvironmentBehaviorMode)((enumValues2.IndexOf((int)m_worldSettings.EnvironmentBehaviorMode) + 1) % enumValues2.Count); m_descriptionLabel.Text = StringsManager.GetString("EnvironmentBehaviorMode." + m_worldSettings.EnvironmentBehaviorMode.ToString() + ".Description"); } if (m_timeOfDayButton.IsClicked) { IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(TimeOfDayMode)); m_worldSettings.TimeOfDayMode = (TimeOfDayMode)((enumValues3.IndexOf((int)m_worldSettings.TimeOfDayMode) + 1) % enumValues3.Count); m_descriptionLabel.Text = StringsManager.GetString("TimeOfDayMode." + m_worldSettings.TimeOfDayMode.ToString() + ".Description"); } if (m_weatherEffectsButton.IsClicked) { m_worldSettings.AreWeatherEffectsEnabled = !m_worldSettings.AreWeatherEffectsEnabled; m_descriptionLabel.Text = StringsManager.GetString("WeatherMode." + m_worldSettings.AreWeatherEffectsEnabled.ToString()); } if (m_adventureRespawnButton.IsClicked) { m_worldSettings.IsAdventureRespawnAllowed = !m_worldSettings.IsAdventureRespawnAllowed; m_descriptionLabel.Text = StringsManager.GetString("AdventureRespawnMode." + m_worldSettings.IsAdventureRespawnAllowed.ToString()); } if (m_adventureSurvivalMechanicsButton.IsClicked) { m_worldSettings.AreAdventureSurvivalMechanicsEnabled = !m_worldSettings.AreAdventureSurvivalMechanicsEnabled; m_descriptionLabel.Text = StringsManager.GetString("AdventureSurvivalMechanics." + m_worldSettings.AreAdventureSurvivalMechanicsEnabled.ToString()); } m_creativeModePanel.IsVisible = (m_worldSettings.GameMode == GameMode.Creative); m_newWorldOnlyPanel.IsVisible = !m_isExistingWorld; m_continentTerrainPanel.IsVisible = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.Continent || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatContinent); m_islandTerrainPanel.IsVisible = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.Island || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatIsland); m_flatTerrainPanel.IsVisible = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatContinent || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatIsland); m_terrainGenerationButton.Text = StringsManager.GetString("TerrainGenerationMode." + m_worldSettings.TerrainGenerationMode.ToString() + ".Name"); m_islandSizeEW.Value = FindNearestIndex(m_islandSizes, m_worldSettings.IslandSize.X); m_islandSizeEW.Text = m_worldSettings.IslandSize.X.ToString(); m_islandSizeNS.Value = FindNearestIndex(m_islandSizes, m_worldSettings.IslandSize.Y); m_islandSizeNS.Text = m_worldSettings.IslandSize.Y.ToString(); m_flatTerrainLevelSlider.Value = m_worldSettings.TerrainLevel; m_flatTerrainLevelSlider.Text = m_worldSettings.TerrainLevel.ToString(); m_flatTerrainShoreRoughnessSlider.Value = m_worldSettings.ShoreRoughness; m_flatTerrainShoreRoughnessSlider.Text = $"{m_worldSettings.ShoreRoughness * 100f:0}%"; m_flatTerrainBlock.Contents = m_worldSettings.TerrainBlockIndex; m_flatTerrainMagmaOceanCheckbox.IsChecked = (m_worldSettings.TerrainOceanBlockIndex == 92); string text = (BlocksManager.Blocks[m_worldSettings.TerrainBlockIndex] != null) ? BlocksManager.Blocks[m_worldSettings.TerrainBlockIndex].GetDisplayName(null, Terrain.MakeBlockValue(m_worldSettings.TerrainBlockIndex)) : string.Empty; m_flatTerrainBlockLabel.Text = ((text.Length > 10) ? (text.Substring(0, 10) + "...") : text); Texture2D texture = m_blockTexturesCache.GetTexture(m_worldSettings.BlocksTextureName); m_blocksTextureIcon.Subtexture = new Subtexture(texture, Vector2.Zero, Vector2.One); m_blocksTextureLabel.Text = BlocksTexturesManager.GetDisplayName(m_worldSettings.BlocksTextureName); m_blocksTextureDetails.Text = $"{texture.Width}x{texture.Height}"; m_seaLevelOffsetSlider.Value = m_worldSettings.SeaLevelOffset; m_seaLevelOffsetSlider.Text = FormatOffset(m_worldSettings.SeaLevelOffset); m_temperatureOffsetSlider.Value = m_worldSettings.TemperatureOffset; m_temperatureOffsetSlider.Text = FormatOffset(m_worldSettings.TemperatureOffset); m_humidityOffsetSlider.Value = m_worldSettings.HumidityOffset; m_humidityOffsetSlider.Text = FormatOffset(m_worldSettings.HumidityOffset); m_biomeSizeSlider.Value = FindNearestIndex(m_biomeSizes, m_worldSettings.BiomeSize); m_biomeSizeSlider.Text = m_worldSettings.BiomeSize.ToString() + "x"; m_environmentBehaviorButton.Text = LanguageControl.Get("EnvironmentBehaviorMode", m_worldSettings.EnvironmentBehaviorMode.ToString()); m_timeOfDayButton.Text = LanguageControl.Get("TimeOfDayMode", m_worldSettings.TimeOfDayMode.ToString()); m_weatherEffectsButton.Text = (m_worldSettings.AreWeatherEffectsEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable")); m_adventureRespawnButton.Text = (m_worldSettings.IsAdventureRespawnAllowed ? LanguageControl.Get("Usual", "allowed") : LanguageControl.Get("Usual", "not allowed")); m_adventureSurvivalMechanicsButton.Text = (m_worldSettings.AreAdventureSurvivalMechanicsEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable")); m_supernaturalCreaturesButton.Text = (m_worldSettings.AreSupernaturalCreaturesEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable")); m_friendlyFireButton.Text = (m_worldSettings.IsFriendlyFireEnabled ? LanguageControl.Get("Usual", "allowed") : LanguageControl.Get("Usual", "not allowed")); if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) { ScreensManager.SwitchScreen(ScreensManager.PreviousScreen); } }
public override void Enter(object[] parameters) { m_worldSettings = (WorldSettings)parameters[0]; m_isExistingWorld = (bool)parameters[1]; m_descriptionLabel.Text = StringsManager.GetString("EnvironmentBehaviorMode." + m_worldSettings.EnvironmentBehaviorMode.ToString() + ".Description"); }