private void endActionLoadSaves(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            screen.CloseScreen();

            var selectedRow = m_worldsTable.SelectedRow;
            var world       = (MySteamWorkshop.SubscribedItem)selectedRow.UserData;



            string safeName        = MyUtils.StripInvalidChars(world.Title);
            var    tempSessionPath = MyLocalCache.GetSessionSavesPath(safeName, false, false);

            if (Directory.Exists(tempSessionPath))
            {
                OverwriteWorldDialog();
            }
            else
            {
                MySteamWorkshop.CreateWorldInstanceAsync(world, MySteamWorkshop.MyWorkshopPathInfo.CreateWorldInfo(), false, delegate(bool success, string sessionPath)
                {
                    if (success)
                    {
                        OnSuccess(sessionPath);
                    }
                });
            }
        }
Beispiel #2
0
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            m_availableSaves = loadListRes.AvailableSaves;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            if (m_availableSaves.Count != 0)
            {
                RefreshGameList();
                m_continueLastSave.Enabled = true;
            }
            else
            {
                m_continueLastSave.Enabled = false;
                CloseScreenNow(); // close right away to avoid seeing the screen at all
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextNoSavedWorlds)));
            }
            screen.CloseScreen();
            m_state = StateEnum.ListLoaded;
        }
        private void endLocal(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            loadListRes.AvailableSaves.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
            m_availableSavesLocal = loadListRes.AvailableSaves;
            AfterPartLoaded();
            screen.CloseScreen();
        }
Beispiel #4
0
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            m_listNeedsReload = false;

            var loadResult = (LoadListResult)result;

            m_subscribedWorlds = loadResult.SubscribedWorlds;
            RefreshGameList();
            screen.CloseScreen();
        }
        private void EndTutorialLoading(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            m_tutorials = new Dictionary <int, List <Tuple <string, MyWorldInfo> > >();

            Dictionary <string, int> trainingLevels = new Dictionary <string, int>();

            trainingLevels["Basic"] = (int)TrainingLevel.BASIC;
            //trainingLevels["Intermediate"] = (int)TrainingLevel.INTERMEDIATE;
            //trainingLevels["Advanced"] = (int)TrainingLevel.ADVANCED;
            trainingLevels["Planetary"] = (int)TrainingLevel.PLANETARY;

            loadListRes.AvailableSaves.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
            foreach (var loadedRes in loadListRes.AvailableSaves)
            {
                var splitted      = loadedRes.Item1.Split('\\');
                var trainingLevel = splitted[splitted.Length - 2];
                if (!MyFakes.ENABLE_XMAS15_CONTENT && splitted[splitted.Length - 1].Contains("Tutorial 08 - Climbing on Planets"))
                {
                    continue;
                }
                if (!MyFakes.ENABLE_XMAS15_CONTENT && splitted[splitted.Length - 1].Contains("Tutorial 11 - Mining Planets and Ship Recovery"))
                {
                    continue;
                }
                if (trainingLevels.ContainsKey(trainingLevel))
                {
                    int id = trainingLevels[trainingLevel];
                    if (!m_tutorials.ContainsKey(id))
                    {
                        m_tutorials[id] = new List <Tuple <string, MyWorldInfo> >();
                    }
                    m_tutorials[id].Add(loadedRes);
                }
            }

            SelectTutorials();

            m_state = StateEnum.ListLoaded;

            screen.CloseScreen();
        }
        private void endWorkshop(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadResult = (LoadWorkshopResult)result;

            m_subscribedScenarios = loadResult.SubscribedScenarios;
            foreach (var item in loadResult.SubscribedScenarios)
            {
                MyWorldInfo wi = new MyWorldInfo();
                wi.SessionName = item.Title;
                wi.Briefing    = item.Description;
                wi.WorkshopId  = item.PublishedFileId;
                m_availableSavesWorkshop.Add(new Tuple <string, MyWorldInfo>(WORKSHOP_PATH_TAG, wi));
            }
            m_availableSavesWorkshop.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
            AfterPartLoaded();
            screen.CloseScreen();
        }
        private void endKeens(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            m_availableSavesKeens = loadListRes.AvailableSaves;
            m_availableSavesKeens.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MySpaceTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }
            AfterPartLoaded();
            screen.CloseScreen();
        }
Beispiel #8
0
        private void endPublicLobbiesAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadResult = (LoadLobbyListResult)result;

            m_lobbies.Clear();

            if (m_showOnlyFriends.IsChecked)
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
            }
            else
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
                LobbySearch.AddPublicLobbies(m_lobbies);
            }

            RefreshGameList();
            screen.CloseScreen();
        }
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            m_availableSaves = loadListRes.AvailableSaves;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MySpaceTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            if (m_availableSaves.Count != 0)
            {
                RefreshGameList();
            }
            screen.CloseScreen();
            m_state = StateEnum.ListLoaded;
        }
Beispiel #10
0
        // Checks for corrupted worlds and refreshes the table cells.
        private void OnLoadingFinished(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            m_scenarioTypesGroup.Clear();
            m_scenarioTypesList.Clear();

            foreach (var saveTuple in loadListRes.AvailableSaves)
            {
                var button = new MyGuiControlContentButton(saveTuple.Item2.SessionName,
                                                           Path.Combine(saveTuple.Item1, "thumb.jpg"))
                {
                    UserData = saveTuple.Item1
                };

                m_scenarioTypesGroup.Add(button);
                m_scenarioTypesList.Controls.Add(button);
            }

            SetDefaultValues();

            // Close the loading miniscreen
            screen.CloseScreen();
        }
        public static void PublishIngameScriptAsync(string localWorldFolder,
           string publishedTitle,
           string publishedDescription,
           ulong? publishedFileId,
           PublishedFileVisibility visibility,
           Action<bool, Result, ulong> callbackOnFinished = null)
        {
            m_onPublishingFinished = callbackOnFinished;
            m_publishSuccess = false;
            m_publishedFileId = 0;
            m_publishResult = Result.Fail;

            string[] tags = { WORKSHOP_INGAMESCRIPT_TAG };
            string[] ignoredExtensions = { ".sbmi",".png",".jpg"};

            MyGuiSandbox.AddScreen(m_asyncPublishScreen = new MyGuiScreenProgressAsync(MyCommonTexts.ProgressTextUploadingWorld,
                null,
                () => new PublishItemResult(localWorldFolder, publishedTitle, publishedDescription, publishedFileId, visibility, tags, ignoredExtensions),
                endActionPublish));
        }
        static void endActionCreateWorldInstance(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            screen.CloseScreen();

            var createdWorldResult = (CreateWorldResult)result;

            var callback = createdWorldResult.Callback;

            if (callback != null)
                callback(createdWorldResult.Success, createdWorldResult.m_createdSessionPath);
        }
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            m_listNeedsReload = false;

            var loadResult = (LoadListResult)result;
            m_subscribedMods = loadResult.SubscribedMods;
            m_worldMods = loadResult.WorldMods;
            RefreshGameList();
            screen.CloseScreen();
        }
 private void endWorkshop(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
 {
     var loadResult = (LoadWorkshopResult)result;
     m_subscribedScenarios = loadResult.SubscribedScenarios;
     foreach(var item in loadResult.SubscribedScenarios)
     {
         MyWorldInfo wi = new MyWorldInfo();
         wi.SessionName = item.Title;
         wi.Briefing = item.Description;
         wi.WorkshopId = item.PublishedFileId;
         m_availableSavesWorkshop.Add(new Tuple<string, MyWorldInfo>(WORKSHOP_PATH_TAG, wi));
     }
     m_availableSavesWorkshop.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
     AfterPartLoaded();
     screen.CloseScreen();
 }
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;
            m_availableSaves = loadListRes.AvailableSaves;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            if (m_availableSaves.Count != 0)
            {
                RefreshGameList();
                m_continueLastSave.Enabled = true;
            }
            else
            {
                m_continueLastSave.Enabled = false;
                CloseScreenNow(); // close right away to avoid seeing the screen at all
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextNoSavedWorlds)));
            }
            screen.CloseScreen();
            m_state = StateEnum.ListLoaded;
        }
        private void endActionLoadSaves(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            screen.CloseScreen();

            var selectedRow = m_worldsTable.SelectedRow;
            var world = (MySteamWorkshop.SubscribedItem)selectedRow.UserData;



            string safeName = MyUtils.StripInvalidChars(world.Title);
            var tempSessionPath = MyLocalCache.GetSessionSavesPath(safeName, false, false);
            if (Directory.Exists(tempSessionPath))
            {
                OverwriteWorldDialog();
            }
            else
            {
                MySteamWorkshop.CreateWorldInstanceAsync(world, MySteamWorkshop.MyWorkshopPathInfo.CreateWorldInfo(), false, delegate(bool success, string sessionPath)
                {
                    if (success)
                    {
                        OnSuccess(sessionPath);
                    }
                });
            }
        }
        static void endActionDownloadMods(IMyAsyncResult iResult, MyGuiScreenProgressAsync screen)
        {
            screen.CloseScreen();

            var result = (DownloadModsResult)iResult;

            if (!result.Success)
            {
                MySandboxGame.Log.WriteLine(string.Format("Error downloading mods"));
            }
            result.callback(result.Success);
        }
        private void EndTutorialLoading(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            m_tutorials = new Dictionary<int, List<Tuple<string, MyWorldInfo>>>();

            Dictionary<string, int> trainingLevels = new Dictionary<string, int>();
            trainingLevels["Basic"] = (int)TrainingLevel.BASIC;
            //trainingLevels["Intermediate"] = (int)TrainingLevel.INTERMEDIATE;
            //trainingLevels["Advanced"] = (int)TrainingLevel.ADVANCED;
            trainingLevels["Planetary"] = (int)TrainingLevel.PLANETARY;

            loadListRes.AvailableSaves.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
            foreach (var loadedRes in loadListRes.AvailableSaves)
            {
                var splitted = loadedRes.Item1.Split('\\');
                var trainingLevel = splitted[splitted.Length - 2];
                if (!MyFakes.ENABLE_XMAS15_CONTENT && splitted[splitted.Length - 1].Contains("Tutorial 08 - Climbing on Planets"))
                    continue;
                if (!MyFakes.ENABLE_XMAS15_CONTENT && splitted[splitted.Length - 1].Contains("Tutorial 11 - Mining Planets and Ship Recovery"))
                    continue;
                if (trainingLevels.ContainsKey(trainingLevel))
                {
                    int id = trainingLevels[trainingLevel];
                    if (!m_tutorials.ContainsKey(id))
                        m_tutorials[id] = new List<Tuple<string, MyWorldInfo>>();
                    m_tutorials[id].Add(loadedRes);
                }
            }

            SelectTutorials();

            m_state = StateEnum.ListLoaded;

            screen.CloseScreen();
        }
        public static void PublishScenarioAsync(string localWorldFolder,
            string publishedTitle,
            string publishedDescription,
            ulong? publishedFileId,
            //string[] tags,
            PublishedFileVisibility visibility,
            Action<bool, Result, ulong> callbackOnFinished = null)
        {
            m_onPublishingFinished = callbackOnFinished;
            m_publishSuccess = false;
            m_publishedFileId = 0;
            m_publishResult = Result.Fail;

            string[] ignoredExtensions = { };
            string[] tags = { WORKSHOP_SCENARIO_TAG };
            MyGuiSandbox.AddScreen(m_asyncPublishScreen = new MyGuiScreenProgressAsync(MySpaceTexts.ProgressTextUploadingWorld,
                null,
                () => new PublishItemResult(localWorldFolder, publishedTitle, publishedDescription, publishedFileId, visibility, tags, ignoredExtensions),
                endActionPublish));
        }
        // Checks for corrupted worlds and refreshes the table cells.
        private void OnLoadingFinished(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;

            m_loadedDirectories.Add(CurrentDirectory);
            foreach (var saveTuple in loadListRes.AvailableSaves)
            {
                if(!m_loadedWorldsByFilePaths.ContainsKey(saveTuple.Item1))
                {
                    // add if new
                    m_loadedWorldsByFilePaths.Add(saveTuple.Item1, saveTuple.Item2);
                }
                else
                {
                    // Rewrite if forced
                    m_loadedWorldsByFilePaths[saveTuple.Item1] = saveTuple.Item2;
                }
            }

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            RefreshAfterLoaded();

            // Close the loading miniscreen
            screen.CloseScreen();
        }
 private static void endActionPublish(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
 {
     screen.CloseScreenNow();
     if (m_onPublishingFinished != null)
         m_onPublishingFinished(m_publishSuccess, m_publishResult, m_publishedFileId);
     m_publishSuccess = false;
     m_publishResult = Result.Fail;
     m_onPublishingFinished = null;
     m_asyncPublishScreen = null;
 }
        public static void DownloadModsAsync(List<MyObjectBuilder_Checkpoint.ModItem> mods, Action<bool> onFinishedCallback, Action onCancelledCallback = null)
        {
            if (mods == null || mods.Count == 0)
            {
                onFinishedCallback(true);
                return;
            }

            if (!Directory.Exists(m_workshopModsPath))
                Directory.CreateDirectory(m_workshopModsPath);

            m_asyncDownloadScreen = new MyGuiScreenProgressAsync(MyCommonTexts.ProgressTextCheckingMods,
                MyCommonTexts.Cancel,
                () => new DownloadModsResult(mods, onFinishedCallback),
                endActionDownloadMods);

            m_asyncDownloadScreen.ProgressCancelled += () =>
            {
                m_stop = true;
                if (onCancelledCallback != null)
                    onCancelledCallback();
            };

            MyGuiSandbox.AddScreen(m_asyncDownloadScreen);
        }
        private void endPublicLobbiesAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadResult = (LoadLobbyListResult)result;
            m_lobbies.Clear();

            if (m_showOnlyFriends.IsChecked)
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
            }
            else
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
                LobbySearch.AddPublicLobbies(m_lobbies);
            }

            RefreshGameList();
            screen.CloseScreen();
        }
        private void endKeens(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;
            m_availableSavesKeens = loadListRes.AvailableSaves;
            m_availableSavesKeens.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MyCommonTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }
            AfterPartLoaded();
            screen.CloseScreen();
        }
 private void endLocal(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
 {
     var loadListRes = (MyLoadListResult)result;
     loadListRes.AvailableSaves.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName));
     m_availableSavesLocal = loadListRes.AvailableSaves;
     AfterPartLoaded();
     screen.CloseScreen();
 }
        private void endAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadListRes = (MyLoadListResult)result;
            m_availableSaves = loadListRes.AvailableSaves;

            if (loadListRes.ContainsCorruptedWorlds)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(MySpaceTexts.SomeWorldFilesCouldNotBeLoaded),
                    messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(messageBox);
            }

            if (m_availableSaves.Count != 0)
            {
                RefreshGameList();
            }
            screen.CloseScreen();
            m_state = StateEnum.ListLoaded;
        }
Beispiel #27
0
 private static void endActionPublishUGC(IMyAsyncResult iResult, MyGuiScreenProgressAsync screen)
 {
     screen.CloseScreenNow();
     PublishUGCResult result = (PublishUGCResult)iResult;
     result.CallbackOnFinished(result.PublishedFileId.HasValue, result.PublishedFileId);
 }