public override void Enter(object[] parameters)
        {
            BusyDialog dialog = new BusyDialog("Scanning Worlds", (string)null);

            DialogsManager.ShowDialog((Dialog)dialog);
            Task.Run((Action)(() =>
            {
                WorldInfo selectedItem = (WorldInfo)this.m_worldsListWidget.SelectedItem;
                WorldsManager.UpdateWorldsList();
                List <WorldInfo> worldInfos = new List <WorldInfo>((IEnumerable <WorldInfo>)(object) WorldsManager.WorldInfos);
                worldInfos.Sort((Comparison <WorldInfo>)((w1, w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime)));
                Dispatcher.Dispatch((Action)(() =>
                {
                    this.m_worldsListWidget.ClearItems();
                    foreach (object obj in worldInfos)
                    {
                        this.m_worldsListWidget.AddItem(obj);
                    }
                    if (selectedItem != null)
                    {
                        this.m_worldsListWidget.SelectedItem = (object)worldInfos.FirstOrDefault <WorldInfo>((Func <WorldInfo, bool>)(wi => wi.DirectoryName == selectedItem.DirectoryName));
                    }
                    DialogsManager.HideDialog((Dialog)dialog);
                }), false);
            }));
        }
        public static void UpgradeWorld(string directoryName)
        {
            WorldInfo worldInfo = WorldsManager.GetWorldInfo(directoryName);

            if (worldInfo == null)
            {
                object[] objArray1 = new object[] { directoryName };
                throw new InvalidOperationException(string.Format("Cannot determine version of world at \"{0}\"", (object[])objArray1));
            }
            if (worldInfo.SerializationVersion != SerializationVersion)
            {
                object[] objArray2 = new object[] { SerializationVersion };
                ProgressManager.UpdateProgress(string.Format("Upgrading World To {0}", (object[])objArray2), 0f);
                List <VersionConverter> list = FindTransform(worldInfo.SerializationVersion, SerializationVersion, (IEnumerable <VersionConverter>)m_versionConverters, 0);
                if (list == null)
                {
                    object[] objArray3 = new object[] { worldInfo.SerializationVersion, SerializationVersion };
                    throw new InvalidOperationException(string.Format("Cannot find conversion path from version \"{0}\" to version \"{1}\"", (object[])objArray3));
                }
                foreach (VersionConverter converter in list)
                {
                    object[] objArray4 = new object[] { converter.SourceVersion, converter.TargetVersion };
                    Log.Information(string.Format("Upgrading world version \"{0}\" to \"{1}\".", (object[])objArray4));
                    converter.ConvertWorld(directoryName);
                }
                WorldInfo info2 = WorldsManager.GetWorldInfo(directoryName);
                if (info2.SerializationVersion != SerializationVersion)
                {
                    object[] objArray5 = new object[] { SerializationVersion, info2.SerializationVersion };
                    throw new InvalidOperationException(string.Format("Upgrade produced invalid project version. Expected \"{0}\", found \"{1}\".", (object[])objArray5));
                }
                AnalyticsParameter[] parameters = new AnalyticsParameter[] { new AnalyticsParameter("SourceVersion", worldInfo.SerializationVersion), new AnalyticsParameter("TargetVersion", SerializationVersion) };
                AnalyticsManager.LogEvent("[VersionConverter] Upgrade world", parameters);
            }
        }
예제 #3
0
        public override void Enter(object[] parameters)
        {
            BusyDialog dialog = new BusyDialog(LanguageControl.GetContentWidgets(fName, 5), null);

            DialogsManager.ShowDialog(null, dialog);
            Task.Run(delegate
            {
                WorldInfo selectedItem = (WorldInfo)m_worldsListWidget.SelectedItem;
                WorldsManager.UpdateWorldsList();
                List <WorldInfo> worldInfos = new List <WorldInfo>(WorldsManager.WorldInfos);
                worldInfos.Sort((WorldInfo w1, WorldInfo w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime));
                Dispatcher.Dispatch(delegate
                {
                    m_worldsListWidget.ClearItems();
                    foreach (WorldInfo item in worldInfos)
                    {
                        m_worldsListWidget.AddItem(item);
                    }
                    if (selectedItem != null)
                    {
                        m_worldsListWidget.SelectedItem = worldInfos.FirstOrDefault((WorldInfo wi) => wi.DirectoryName == selectedItem.DirectoryName);
                    }
                    DialogsManager.HideDialog(dialog);
                });
            });
        }
예제 #4
0
        public GameLoadingScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/GameLoadingScreen");

            LoadContents(this, node);
            m_stateMachine.AddState("WaitingForFadeIn", null, delegate
            {
                if (!ScreensManager.IsAnimating)
                {
                    if (string.IsNullOrEmpty(m_worldSnapshotName))
                    {
                        m_stateMachine.TransitionTo("Loading");
                    }
                    else
                    {
                        m_stateMachine.TransitionTo("RestoringSnapshot");
                    }
                }
            }, null);
            m_stateMachine.AddState("Loading", null, delegate
            {
                ContainerWidget gamesWidget = ScreensManager.FindScreen <GameScreen>("Game").Children.Find <ContainerWidget>("GamesWidget");
                GameManager.LoadProject(m_worldInfo, gamesWidget);
                ScreensManager.SwitchScreen("Game");
            }, null);
            m_stateMachine.AddState("RestoringSnapshot", null, delegate
            {
                GameManager.DisposeProject();
                WorldsManager.RestoreWorldFromSnapshot(m_worldInfo.DirectoryName, m_worldSnapshotName);
                m_stateMachine.TransitionTo("Loading");
            }, null);
        }
예제 #5
0
 public static void SaveProject(bool waitForCompletion, bool showErrorDialog)
 {
     if (m_project != null)
     {
         double      realTime    = Time.RealTime;
         ProjectData projectData = m_project.Save();
         m_saveCompleted.WaitOne();
         m_saveCompleted.Reset();
         SubsystemGameInfo subsystemGameInfo = m_project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
         string            projectFileName   = Storage.CombinePaths(subsystemGameInfo.DirectoryName, "Project.xml");
         Exception         e = default(Exception);
         Task.Run(delegate
         {
             try
             {
                 WorldsManager.MakeQuickWorldBackup(subsystemGameInfo.DirectoryName);
                 XElement xElement = new XElement("Project");
                 projectData.Save(xElement);
                 XmlUtils.SetAttributeValue(xElement, "Version", VersionsManager.SerializationVersion);
                 Storage.CreateDirectory(subsystemGameInfo.DirectoryName);
                 using (Stream stream = Storage.OpenFile(projectFileName, OpenFileMode.Create))
                 {
                     XmlUtils.SaveXmlToStream(xElement, stream, null, throwOnError: true);
                 }
             }
             catch (Exception ex)
             {
                 e = ex;
                 if (showErrorDialog)
                 {
                     Dispatcher.Dispatch(delegate
                     {
                         DialogsManager.ShowDialog(null, new MessageDialog("Error saving game", e.Message, LanguageControl.Get("Usual", "ok"), null, null));
                     });
                 }
             }
             finally
             {
                 m_saveCompleted.Set();
             }
         });
         if (waitForCompletion)
         {
             m_saveCompleted.WaitOne();
         }
         double realTime2 = Time.RealTime;
         Log.Verbose($"Saved project, {MathUtils.Round((realTime2 - realTime) * 1000.0)}ms");
     }
 }
예제 #6
0
        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()));
        }
예제 #8
0
        public static string ImportExternalContentSync(Stream stream, ExternalContentType type, string name)
        {
            switch (type)
            {
            case ExternalContentType.World:
                return(WorldsManager.ImportWorld(stream));

            case ExternalContentType.BlocksTexture:
                return(BlocksTexturesManager.ImportBlocksTexture(name, stream));

            case ExternalContentType.CharacterSkin:
                return(CharacterSkinsManager.ImportCharacterSkin(name, stream));

            case ExternalContentType.FurniturePack:
                return(FurniturePacksManager.ImportFurniturePack(name, stream));

            default:
                throw new InvalidOperationException(LanguageControl.Get(fName, 4));
            }
        }
예제 #9
0
        public static void UpgradeWorld(string directoryName)
        {
            WorldInfo worldInfo = WorldsManager.GetWorldInfo(directoryName);

            if (worldInfo == null)
            {
                throw new InvalidOperationException($"Cannot determine version of world at \"{directoryName}\"");
            }
            if (worldInfo.SerializationVersion != SerializationVersion)
            {
                ProgressManager.UpdateProgress($"Upgrading World To {SerializationVersion}", 0f);
                foreach (VersionConverter item in FindTransform(worldInfo.SerializationVersion, SerializationVersion, m_versionConverters, 0) ?? throw new InvalidOperationException($"Cannot find conversion path from version \"{worldInfo.SerializationVersion}\" to version \"{SerializationVersion}\""))
                {
                    Log.Information($"Upgrading world version \"{item.SourceVersion}\" to \"{item.TargetVersion}\".");
                    item.ConvertWorld(directoryName);
                }
                WorldInfo worldInfo2 = WorldsManager.GetWorldInfo(directoryName);
                if (worldInfo2.SerializationVersion != SerializationVersion)
                {
                    throw new InvalidOperationException($"Upgrade produced invalid project version. Expected \"{SerializationVersion}\", found \"{worldInfo2.SerializationVersion}\".");
                }
                AnalyticsManager.LogEvent("[VersionConverter] Upgrade world", new AnalyticsParameter("SourceVersion", worldInfo.SerializationVersion), new AnalyticsParameter("TargetVersion", SerializationVersion));
            }
        }
예제 #10
0
 public static void LoadProject(WorldInfo worldInfo, ContainerWidget gamesWidget)
 {
     DisposeProject();
     WorldsManager.RepairWorldIfNeeded(worldInfo.DirectoryName);
     VersionsManager.UpgradeWorld(worldInfo.DirectoryName);
     using (Stream stream = Storage.OpenFile(Storage.CombinePaths(worldInfo.DirectoryName, "Project.xml"), OpenFileMode.Read))
     {
         ValuesDictionary valuesDictionary  = new ValuesDictionary();
         ValuesDictionary valuesDictionary2 = new ValuesDictionary();
         valuesDictionary.SetValue("GameInfo", valuesDictionary2);
         valuesDictionary2.SetValue("WorldDirectoryName", worldInfo.DirectoryName);
         ValuesDictionary valuesDictionary3 = new ValuesDictionary();
         valuesDictionary.SetValue("Views", valuesDictionary3);
         valuesDictionary3.SetValue("GamesWidget", gamesWidget);
         XElement    projectNode = XmlUtils.LoadXmlFromStream(stream, null, throwOnError: true);
         ProjectData projectData = new ProjectData(DatabaseManager.GameDatabase, projectNode, valuesDictionary, ignoreInvalidEntities: true);
         m_project         = new Project(DatabaseManager.GameDatabase, projectData);
         m_subsystemUpdate = m_project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
     }
     m_worldInfo = worldInfo;
     Log.Information("Loaded world, GameMode={0}, StartingPosition={1}, WorldName={2}, VisibilityRange={3}, Resolution={4}", worldInfo.WorldSettings.GameMode, worldInfo.WorldSettings.StartingPositionMode, worldInfo.WorldSettings.Name, SettingsManager.VisibilityRange.ToString(), SettingsManager.ResolutionMode.ToString());
     AnalyticsManager.LogEvent("[GameManager] Loaded world", new AnalyticsParameter("GameMode", worldInfo.WorldSettings.GameMode.ToString()), new AnalyticsParameter("EnvironmentBehaviorMode", worldInfo.WorldSettings.EnvironmentBehaviorMode.ToString()), new AnalyticsParameter("TerrainGenerationMode", worldInfo.WorldSettings.TerrainGenerationMode.ToString()), new AnalyticsParameter("WorldDirectory", worldInfo.DirectoryName), new AnalyticsParameter("WorldName", worldInfo.WorldSettings.Name), new AnalyticsParameter("WorldSeedString", worldInfo.WorldSettings.Seed), new AnalyticsParameter("VisibilityRange", SettingsManager.VisibilityRange.ToString()), new AnalyticsParameter("Resolution", SettingsManager.ResolutionMode.ToString()));
     GC.Collect();
 }
예제 #11
0
        public static void DeleteExternalContent(ExternalContentType type, string name)
        {
            switch (type)
            {
            case ExternalContentType.World:
                WorldsManager.DeleteWorld(name);
                break;

            case ExternalContentType.BlocksTexture:
                BlocksTexturesManager.DeleteBlocksTexture(name);
                break;

            case ExternalContentType.CharacterSkin:
                CharacterSkinsManager.DeleteCharacterSkin(name);
                break;

            case ExternalContentType.FurniturePack:
                FurniturePacksManager.DeleteFurniturePack(name);
                break;

            default:
                throw new InvalidOperationException(LanguageControl.Get(fName, 4));
            }
        }
예제 #12
0
        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
                });
            }
        }
예제 #13
0
        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;
            });
        }
예제 #14
0
        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");
                }
            }
        }
예제 #15
0
 public static void ShowUploadUi(ExternalContentType type, string name)
 {
     DialogsManager.ShowDialog(null, new SelectExternalContentProviderDialog(LanguageControl.Get(fName, 9), listingSupportRequired : false, delegate(IExternalContentProvider provider)
     {
         try
         {
             if (provider != null)
             {
                 ShowLoginUiIfNeeded(provider, showWarningDialog: true, delegate
                 {
                     CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 10), autoHideOnCancel: false);
                     DialogsManager.ShowDialog(null, busyDialog);
                     Task.Run(delegate
                     {
                         bool needsDelete  = false;
                         string sourcePath = null;
                         Stream stream     = null;
                         Action cleanup    = delegate
                         {
                             Utilities.Dispose(ref stream);
                             if (needsDelete && sourcePath != null)
                             {
                                 try
                                 {
                                     Storage.DeleteFile(sourcePath);
                                 }
                                 catch
                                 {
                                 }
                             }
                         };
                         try
                         {
                             string path;
                             if (type == ExternalContentType.BlocksTexture)
                             {
                                 sourcePath = BlocksTexturesManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else if (type == ExternalContentType.CharacterSkin)
                             {
                                 sourcePath = CharacterSkinsManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else if (type == ExternalContentType.FurniturePack)
                             {
                                 sourcePath = FurniturePacksManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else
                             {
                                 if (type != ExternalContentType.World)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 12));
                                 }
                                 busyDialog.LargeMessage = LanguageControl.Get(fName, 13);
                                 sourcePath   = "android:SurvivalCraft2.2/WorldUpload.tmp";
                                 needsDelete  = true;
                                 string name2 = WorldsManager.GetWorldInfo(name).WorldSettings.Name;
                                 path         = $"{name2}.scworld";
                                 using (Stream targetStream = Storage.OpenFile(sourcePath, OpenFileMode.Create))
                                 {
                                     WorldsManager.ExportWorld(name, targetStream);
                                 }
                             }
                             busyDialog.LargeMessage = LanguageControl.Get(fName, 14);
                             stream = Storage.OpenFile(sourcePath, OpenFileMode.Read);
                             provider.Upload(path, stream, busyDialog.Progress, delegate(string link)
                             {
                                 long length = stream.Length;
                                 cleanup();
                                 DialogsManager.HideDialog(busyDialog);
                                 if (string.IsNullOrEmpty(link))
                                 {
                                     DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "success"), string.Format(LanguageControl.Get(fName, 15), DataSizeFormatter.Format(length)), LanguageControl.Get("Usual", "ok"), null, null));
                                 }
                                 else
                                 {
                                     DialogsManager.ShowDialog(null, new ExternalContentLinkDialog(link));
                                 }
                             }, delegate(Exception error)
                             {
                                 cleanup();
                                 DialogsManager.HideDialog(busyDialog);
                                 DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                             });
                         }
                         catch (Exception ex2)
                         {
                             cleanup();
                             DialogsManager.HideDialog(busyDialog);
                             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex2.Message, LanguageControl.Get("Usual", "ok"), null, null));
                         }
                     });
                 });
             }
         }
         catch (Exception ex)
         {
             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
         }
     }));
 }