void GetScriptsInfo()
        {
            ProfilerShort.Begin("Getting workshop scripts.");
            ProfilerShort.BeginNextBlock("downloading");
            m_subscribedItemsList.Clear();
            bool success = MySteamWorkshop.GetSubscribedIngameScriptsBlocking(m_subscribedItemsList);

            if (success)
            {
                if (Directory.Exists(m_workshopBlueprintFolder))
                {
                    try
                    {
                        Directory.Delete(m_workshopBlueprintFolder, true);
                    }
                    catch (System.IO.IOException)
                    {
                    }
                }
                Directory.CreateDirectory(m_workshopBlueprintFolder);
            }
            if (success)
            {
                AddWorkshopItemsToList();
            }
            else
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageText: new StringBuilder("Couldn't load scripts from steam workshop"),
                                           messageCaption: new StringBuilder("Error")));
            }
            ProfilerShort.End();
        }
        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);
                    }
                });
            }
        }
Exemplo n.º 3
0
        //loads next mission, SP only
        //id can be workshop ID or save name (in that case official scenarios are searched first, if not found, then user's saves)
        public void LoadNextScenario(string id)
        {
            ulong workshopID;

            if (ulong.TryParse(id, out workshopID))
            {
                MySteamWorkshop.SubscribedItem item = new MySteamWorkshop.SubscribedItem();
                item.PublishedFileId = workshopID;

                MySteamWorkshop.CreateWorldInstanceAsync(item, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath)
                {
                    if (success)
                    {
                        LoadMission(sessionPath, false, MyOnlineModeEnum.OFFLINE, 1);
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                                                   messageCaption: MyTexts.Get(MySpaceTexts.ScreenCaptionWorkshop)));
                    }
                });
            }
            //else
            //    LoadMission(save.Item1, false, MyOnlineModeEnum.OFFLINE, 1);
        }
Exemplo n.º 4
0
#pragma warning restore 649

        private void DoLoadSession(string sessionPath)
        {
            if (!Path.IsPathRooted(sessionPath))
            {
                sessionPath = Path.Combine(MyFileSystem.SavesPath, sessionPath);
            }

            if (!Sandbox.Engine.Platform.Game.IsDedicated)
            {
                MySessionLoader.LoadSingleplayerSession(sessionPath);
                return;
            }
            ulong checkpointSize;
            MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize);

            if (MySession.IsCompatibleVersion(checkpoint))
            {
                if (MySteamWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success)
                {
                    // MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load);
                    MySession.Load(sessionPath, checkpoint, checkpointSize);
                    _hostServerForSession(MySession.Static, MyMultiplayer.Static);
                }
                else
                {
                    MyLog.Default.WriteLineAndConsole("Unable to download mods");
                }
            }
            else
            {
                MyLog.Default.WriteLineAndConsole(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion)
                                                  .ToString());
            }
        }
Exemplo n.º 5
0
            public LoadListResult(HashSet <ulong> ids)
            {
                Task = Parallel.Start(() =>
                {
                    SubscribedMods = new List <MySteamWorkshop.SubscribedItem>(ids.Count);
                    WorldMods      = new List <MySteamWorkshop.SubscribedItem>();

                    if (!MySteam.IsOnline)
                    {
                        return;
                    }

                    if (!MySteamWorkshop.GetSubscribedModsBlocking(SubscribedMods))
                    {
                        return;
                    }

                    var toGet = new HashSet <ulong>(ids);

                    foreach (var mod in SubscribedMods)
                    {
                        toGet.Remove(mod.PublishedFileId);
                    }
                    if (toGet.Count > 0)
                    {
                        MySteamWorkshop.GetItemsBlocking(WorldMods, toGet);
                    }
                });
            }
Exemplo n.º 6
0
        protected override void LoadSandboxInternal(Tuple <string, MyWorldInfo> save, bool MP)
        {
            base.LoadSandboxInternal(save, MP);

            if (save.Item1 == WORKSHOP_PATH_TAG)
            {
                var scenario = FindWorkshopScenario(save.Item2.WorkshopId.Value);
                MySteamWorkshop.CreateWorldInstanceAsync(scenario, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath)
                {
                    if (success)
                    {
                        //add briefing from workshop description
                        ulong dummy;
                        var checkpoint      = MyLocalCache.LoadCheckpoint(sessionPath, out dummy);
                        checkpoint.Briefing = save.Item2.Briefing;
                        MyLocalCache.SaveCheckpoint(checkpoint, sessionPath);
                        MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Scenario);
                        MyScenarioSystem.LoadMission(sessionPath, /*m_nameTextbox.Text, m_descriptionTextbox.Text,*/ MP, (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(), (short)m_maxPlayersSlider.Value);
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                                                   messageCaption: MyTexts.Get(MySpaceTexts.ScreenCaptionWorkshop)));
                    }
                });
            }
            else
            {
                MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Scenario);
                MyScenarioSystem.LoadMission(save.Item1, /*m_nameTextbox.Text, m_descriptionTextbox.Text,*/ MP, (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(), (short)m_maxPlayersSlider.Value);
            }
        }
 void DownloadScriptFromSteam()
 {
     if (m_selectedItem != null)
     {
         MyScriptItemInfo itemInfo = (m_selectedItem.UserData as MyScriptItemInfo);
         MySteamWorkshop.DownloadScriptBlocking(itemInfo.SteamItem);
     }
 }
        void OnPublish(MyGuiControlButton button)
        {
            string modInfoPath = Path.Combine(m_localBlueprintFolder, m_selectedItem.ScriptName, "modinfo.sbmi");
            MyObjectBuilder_ModInfo modInfo;

            if (File.Exists(modInfoPath) && MyObjectBuilderSerializer.DeserializeXML(modInfoPath, out modInfo))
            {
                m_selectedItem.PublishedItemId = modInfo.WorkshopId;
            }

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageCaption : MyTexts.Get(MyCommonTexts.LoadScreenButtonPublish),
                                       messageText : MyTexts.Get(MySpaceTexts.ProgrammableBlock_PublishScriptDialogText),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    WasPublished    = true;
                    string fullPath = Path.Combine(m_localBlueprintFolder, m_selectedItem.ScriptName);
                    MySteamWorkshop.PublishIngameScriptAsync(fullPath, m_selectedItem.ScriptName, m_selectedItem.Description ?? "", m_selectedItem.PublishedItemId, SteamSDK.PublishedFileVisibility.Public,
                                                             callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)
                    {
                        if (success)
                        {
                            MySteamWorkshop.GenerateModInfo(fullPath, publishedFileId, Sync.MyId);
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       styleEnum: MyMessageBoxStyleEnum.Info,
                                                       messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextWorldPublished),
                                                       messageCaption: MyTexts.Get(MySpaceTexts.ProgrammableBlock_PublishScriptPublished),
                                                       callback: (a) =>
                            {
                                MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                            }));
                        }
                        else
                        {
                            MyStringId error;
                            switch (result)
                            {
                            case Result.AccessDenied:
                                error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied;
                                break;

                            default:
                                error = MyCommonTexts.MessageBoxTextWorldPublishFailed;
                                break;
                            }

                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(error),
                                                       messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublishFailed)));
                        }
                    });
                }
            }));
        }
Exemplo n.º 9
0
        public static void LoadMultiplayerScenarioWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            Debug.Assert(MySession.Static != null);

            MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - Start");

            if (world.Checkpoint.BriefingVideo != null && world.Checkpoint.BriefingVideo.Length > 0)
            {
                MyGuiSandbox.OpenUrlWithFallback(world.Checkpoint.BriefingVideo, "Scenario briefing video", true);
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType : MyMessageBoxButtonsType.OK,
                                           callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MySessionLoader.UnloadAndExitToMenu(); }));
                MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success, string mismatchMods)
            {
                if (success)
                {
                    CheckMismatchmods(mismatchMods, callback : delegate(ResultEnum val)
                    {
                        MyScreenManager.CloseAllScreensNowExcept(null);
                        MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                        StartLoading(delegate
                        {
                            MySession.Static.LoadMultiplayerWorld(world, multiplayerSession);
                            if (ScenarioWorldLoaded != null)
                            {
                                ScenarioWorldLoaded();
                            }
                        });
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK,
                                               callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MySessionLoader.UnloadAndExitToMenu(); }));
                }
                MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End");
            },
                                              onCancelledCallback : delegate()
            {
                MySessionLoader.UnloadAndExitToMenu();
            });
        }
        public static void LoadMultiplayerBattleWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - Start");

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType : MyMessageBoxButtonsType.OK,
                                           callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success, string mismatchMods)
            {
                if (success)
                {
                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);
                    CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val)
                    {
                        MyGuiScreenGamePlay.StartLoading(delegate
                        {
                            if (MySession.Static == null)
                            {
                                MySession.CreateWithEmptyWorld(multiplayerSession);
                                MySession.Static.Settings.Battle = true;
                            }

                            MySession.Static.LoadMultiplayerWorld(world, multiplayerSession);
                            Debug.Assert(MySession.Static.Battle);
                            if (BattleWorldLoaded != null)
                            {
                                BattleWorldLoaded();
                            }
                        });
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK,
                                               callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                }
                MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
            },
                                              onCancelledCallback : delegate()
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
            });
        }
Exemplo n.º 11
0
        public static void LoadMission(string sessionPath, bool multiplayer, MyOnlineModeEnum onlineMode, short maxPlayers,
                                       MyGameModeEnum gameMode, MyObjectBuilder_Checkpoint checkpoint, ulong checkpointSizeInBytes)
        {
            var persistentEditMode = checkpoint.Settings.ScenarioEditMode;

            checkpoint.Settings.OnlineMode       = onlineMode;
            checkpoint.Settings.MaxPlayers       = maxPlayers;
            checkpoint.Settings.Scenario         = true;
            checkpoint.Settings.GameMode         = gameMode;
            checkpoint.Settings.ScenarioEditMode = false;

            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            m_checkpointData = new CheckpointData()
            {
                Checkpoint         = checkpoint,
                CheckpointSize     = checkpointSizeInBytes,
                PersistentEditMode = persistentEditMode,
                SessionPath        = sessionPath,
            };

            if (checkpoint.BriefingVideo != null && checkpoint.BriefingVideo.Length > 0 && !MyFakes.XBOX_PREVIEW)
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionVideo),
                                           messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWatchVideo),
                                           buttonType: MyMessageBoxButtonsType.YES_NO,
                                           callback: OnVideoMessageBox));
            }
            else
            {
                var checkpointData = m_checkpointData.Value;
                m_checkpointData = null;
                LoadMission(checkpointData);
            }
        }
Exemplo n.º 12
0
        private void StartNewSandbox()
        {
            MyLog.Default.WriteLine("StartNewSandbox - Start");

            GetSettingsFromControls();
            if (!MySteamWorkshop.CheckLocalModsAllowed(m_mods, m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(m_mods, delegate(bool success)
            {
                if (success || (m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(m_mods))
                {
                    MyScreenManager.RemoveAllScreensExcept(null);

                    if (AsteroidAmount < 0)
                    {
                        MyWorldGenerator.SetProceduralSettings(AsteroidAmount, m_settings);
                        m_asteroidAmount = 0;
                    }

                    MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom);

                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MySession.Start(
                            m_nameTextbox.Text,
                            GetDescription(),
                            GetPassword(),
                            m_settings,
                            m_mods,
                            new MyWorldGenerator.Args()
                        {
                            AsteroidAmount = this.AsteroidAmount,
                            Scenario       = (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario
                        }
                            );
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed),
                                               buttonType: MyMessageBoxButtonsType.OK));
                }
                MyLog.Default.WriteLine("StartNewSandbox - End");
            });
        }
Exemplo n.º 13
0
        private static void LoadMission(CheckpointData data)
        {
            var checkpoint = data.Checkpoint;

            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success, string mismatchMods)
            {
                if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods))
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    MyGuiScreenLoadSandbox.CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val)
                    {
                        // May be called from gameplay, so we must make sure we unload the current game
                        if (MySession.Static != null)
                        {
                            MySession.Static.Unload();
                            MySession.Static = null;
                        }

                        //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since.
                        //  if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED
                        if (checkpoint.Settings.ProceduralSeed == 0)
                        {
                            checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next();
                        }

                        MyGuiScreenGamePlay.StartLoading(delegate
                        {
                            checkpoint.Settings.Scenario = true;
                            MySession.LoadMission(data.SessionPath, checkpoint, data.CheckpointSize, data.PersistentEditMode);
                        });
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString());
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result)
                    {
                        if (MyFakes.QUICK_LAUNCH != null)
                        {
                            MyGuiScreenMainMenu.ReturnToMainMenu();
                        }
                    }));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }
Exemplo n.º 14
0
        public Uploader(WorkshopType type, string path, string[] tags = null, string[] ignoredExtensions = null, bool compile = false, bool dryrun = false, bool development = false, SteamSDK.PublishedFileVisibility visibility = SteamSDK.PublishedFileVisibility.Public, bool force = false)
        {
            m_modPath    = path;
            m_compile    = compile;
            m_dryrun     = dryrun;
            m_visibility = visibility;
            m_title      = Path.GetFileName(path);
            m_modId      = MySteamWorkshop.GetWorkshopIdFromLocalMod(m_modPath);
            m_type       = type;
            m_isDev      = development;
            m_force      = force;

            if (tags != null)
            {
                m_tags = tags;
            }

            // This file list should match the PublishXXXAsync methods in MySteamWorkshop
            switch (m_type)
            {
            case WorkshopType.Mod:
                m_ignoredExtensions = new string[] { ".sbmi" };
                break;

            case WorkshopType.IngameScript:
                m_ignoredExtensions = new string[] { ".sbmi", ".png", ".jpg" };
                break;

            case WorkshopType.World:
                m_ignoredExtensions = new string[] { ".xmlcache", ".png" };
                break;

            case WorkshopType.Blueprint:
                m_ignoredExtensions = new string[] { };
                break;

            case WorkshopType.Scenario:
                m_ignoredExtensions = new string[] { };
                break;
            }

            if (ignoredExtensions != null)
            {
                ignoredExtensions = ignoredExtensions.Select(s => "." + s.TrimStart(new[] { '.', '*' })).ToArray();
                string[] allIgnoredExtensions = new string[m_ignoredExtensions.Length + ignoredExtensions.Length];
                ignoredExtensions.CopyTo(allIgnoredExtensions, 0);
                m_ignoredExtensions.CopyTo(allIgnoredExtensions, ignoredExtensions.Length);
                m_ignoredExtensions = allIgnoredExtensions;
            }

            SetupReflection();
        }
Exemplo n.º 15
0
            void LoadListAsync(out List <MySteamWorkshop.SubscribedItem> list)
            {
                var worlds = new List <MySteamWorkshop.SubscribedItem>();

                if (MySteamWorkshop.GetSubscribedWorldsBlocking(worlds))
                {
                    list = worlds;
                }
                else
                {
                    list = null;
                }
            }
Exemplo n.º 16
0
        public static void LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success)
            {
                if (success)
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }

                    MyGuiScreenGamePlay.StartLoading(delegate { MySession.LoadMultiplayer(world, multiplayerSession); });
                }
                else
                {
                    if (MyMultiplayer.Static != null)
                    {
                        MyMultiplayer.Static.Dispose();
                    }
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType: MyMessageBoxButtonsType.OK));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            },
                                              onCancelledCallback : delegate()
            {
                multiplayerSession.Dispose();
            });
        }
Exemplo n.º 17
0
        /// <summary>
        /// Runs publish process for active campaign.
        /// </summary>
        public void PublishActive()
        {
            var publishedSteamId = MySteamWorkshop.GetWorkshopIdFromLocalMod(m_activeCampaign.ModFolderPath);

            MySteamWorkshop.PublishModAsync(
                m_activeCampaign.ModFolderPath,
                m_activeCampaign.Name,
                m_activeCampaign.Description,
                publishedSteamId,
                new [] { MySteamWorkshop.WORKSHOP_CAMPAIGN_TAG },
                PublishedFileVisibility.Public,
                OnPublishFinished
                );
        }
 private void OnOverwriteWorld(MyGuiScreenMessageBox.ResultEnum callbackReturn)
 {
     if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
     {
         var selectedRow = m_worldsTable.SelectedRow;
         var world       = (MySteamWorkshop.SubscribedItem)selectedRow.UserData;
         MySteamWorkshop.CreateWorldInstanceAsync(world, MySteamWorkshop.MyWorkshopPathInfo.CreateWorldInfo(), true, delegate(bool success, string sessionPath)
         {
             if (success)
             {
                 OnSuccess(sessionPath);
             }
         });
     }
 }
Exemplo n.º 19
0
 public LoadWorkshopResult()
 {
     Task = Parallel.Start(() =>
     {
         SubscribedScenarios = new List <MySteamWorkshop.SubscribedItem>();
         if (!MySteam.IsOnline)
         {
             return;
         }
         if (!MySteamWorkshop.GetSubscribedScenariosBlocking(SubscribedScenarios))
         {
             return;
         }
     });
 }
Exemplo n.º 20
0
 private static void EndActionLoadWorkshop()
 {
     Static.EndAction -= EndActionLoadWorkshop;
     MySteamWorkshop.CreateWorldInstanceAsync(m_newWorkshopMap, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath)
     {
         if (success)
         {
             m_newPath = sessionPath;
             LoadMission(sessionPath, false, MyOnlineModeEnum.OFFLINE, 1);
         }
         else
             MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                         messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                         messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop)));
     });
 }
        private void LoadSandbox(bool MP)
        {
            MyLog.Default.WriteLine("LoadSandbox() - Start");
            var row = m_scenarioTable.SelectedRow;

            if (row != null)
            {
                var save = FindSave(row);
                if (save != null)
                {
                    if (save.Item1 == WORKSHOP_PATH_TAG)
                    {
                        var scenario = FindWorkshopScenario(save.Item2.WorkshopId.Value);
                        MySteamWorkshop.CreateWorldInstanceAsync(scenario, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath)
                        {
                            if (success)
                            {
                                //add briefing from workshop description
                                ulong dummy;
                                var checkpoint      = MyLocalCache.LoadCheckpoint(sessionPath, out dummy);
                                checkpoint.Briefing = save.Item2.Briefing;
                                MyLocalCache.SaveCheckpoint(checkpoint, sessionPath);

                                LoadMission(sessionPath, m_nameTextbox.Text, m_descriptionTextbox.Text, MP);
                            }
                            else
                            {
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                           messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                                                           messageCaption: MyTexts.Get(MySpaceTexts.ScreenCaptionWorkshop)));
                            }
                        });
                    }
                    else
                    {
                        LoadMission(save.Item1, m_nameTextbox.Text, m_descriptionTextbox.Text, MP);
                    }
                }
            }

            MyLog.Default.WriteLine("LoadSandbox() - End");
        }
Exemplo n.º 22
0
        private void CreateAndLoadFromSubscribedWorld()
        {
            var selectedRow = m_worldsTable.SelectedRow;

            if (selectedRow == null)
            {
                return;
            }

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

            if (world == null)
            {
                return;
            }
            MySteamWorkshop.CreateWorldInstanceAsync(world, MySteamWorkshop.MyWorkshopPathInfo.CreateWorldInfo(), false, delegate(bool success, string sessionPath)
            {
                if (success)
                {
                    MyGuiScreenLoadSandbox.LoadSingleplayerSession(sessionPath);
                }
            });
        }
Exemplo n.º 23
0
        void DownloadBlueprints()
        {
            ProfilerShort.Begin("Getting workshop blueprints.");
            m_downloadFromSteam = true;
            ProfilerShort.BeginNextBlock("downloading");
            m_subscribedItemsList.Clear();
            bool success  = MySteamWorkshop.GetSubscribedBlueprintsBlocking(m_subscribedItemsList);
            bool success2 = false;

            if (success)
            {
                if (Directory.Exists(m_workshopBlueprintFolder))
                {
                    try
                    {
                        Directory.Delete(m_workshopBlueprintFolder, true);
                    }
                    catch (System.IO.IOException)
                    {
                    }
                }
                Directory.CreateDirectory(m_workshopBlueprintFolder);
                success2 = MySteamWorkshop.DownloadBlueprintsBlocking(m_subscribedItemsList);
            }
            if (success && success2)
            {
                m_needsExtract      = true;
                m_downloadFromSteam = false;
            }
            else
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageText: new StringBuilder("Couldn't load blueprints from steam workshop"),
                                           messageCaption: new StringBuilder("Error")));
            }
            ProfilerShort.End();
        }
Exemplo n.º 24
0
        // Called when campaign gets uploaded to steam workshop
        private void OnPublishFinished(bool publishSuccess, Result publishResult, ulong publishedFileId)
        {
            if (publishSuccess)
            {
                // Create metadata for further identification of the mod
                MySteamWorkshop.GenerateModInfo(m_activeCampaign.ModFolderPath, publishedFileId, Sync.MyId);
                // Success open the steam overlay with mod opened
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           styleEnum: MyMessageBoxStyleEnum.Info,
                                           messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextCampaignPublished),
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionCampaignPublished),
                                           callback: (a) =>
                {
                    MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                }));
            }
            else
            {
                // Failed upload -- Tell whats the problem
                MyStringId error;
                switch (publishResult)
                {
                case Result.AccessDenied:
                    error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied;
                    break;

                default:
                    error = MyCommonTexts.MessageBoxTextWorldPublishFailed;
                    break;
                }

                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageText: MyTexts.Get(error),
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionModCampaignPublishFailed)));
            }
        }
Exemplo n.º 25
0
        public static void Publish(MyObjectBuilder_Definitions prefab, string blueprintName, Action <ulong> publishCallback = null)
        {
            string file        = Path.Combine(m_localBlueprintFolder, blueprintName);
            string title       = prefab.ShipBlueprints[0].CubeGrids[0].DisplayName;
            string description = prefab.ShipBlueprints[0].Description;
            ulong  publishId   = prefab.ShipBlueprints[0].WorkshopId;

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageCaption : new StringBuilder("Publish"),
                                       messageText : new StringBuilder("Do you want to publish this blueprint?"),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    Action <MyGuiScreenMessageBox.ResultEnum, string[]> onTagsChosen = delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags)
                    {
                        if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            MySteamWorkshop.PublishBlueprintAsync(file, title, description, publishId, outTags, SteamSDK.PublishedFileVisibility.Public,
                                                                  callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)
                            {
                                if (success)
                                {
                                    if (publishCallback != null)
                                    {
                                        publishCallback(publishedFileId);
                                    }

                                    prefab.ShipBlueprints[0].WorkshopId = publishedFileId;
                                    SavePrefabToFile(prefab, blueprintName, true);
                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               styleEnum: MyMessageBoxStyleEnum.Info,
                                                               messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorldPublished),
                                                               messageCaption: new StringBuilder("BLUEPRINT PUBLISHED"),
                                                               callback: (a) =>
                                    {
                                        MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                                    }));
                                }
                                else
                                {
                                    MyStringId error;
                                    switch (result)
                                    {
                                    case Result.AccessDenied:
                                        error = MySpaceTexts.MessageBoxTextPublishFailed_AccessDenied;
                                        break;

                                    default:
                                        error = MySpaceTexts.MessageBoxTextWorldPublishFailed;
                                        break;
                                    }

                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               messageText: MyTexts.Get(error),
                                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionWorldPublishFailed)));
                                }
                            });
                        }
                    };

                    if (MySteamWorkshop.BlueprintCategories.Length > 0)
                    {
                        MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_BLUEPRINT_TAG, MySteamWorkshop.BlueprintCategories, null, onTagsChosen));
                    }
                    else
                    {
                        onTagsChosen(MyGuiScreenMessageBox.ResultEnum.YES, new string[] { MySteamWorkshop.WORKSHOP_BLUEPRINT_TAG });
                    }
                }
            }));
        }
Exemplo n.º 26
0
        void OnPublishButtonClick(MyGuiControlButton sender)
        {
            var row = m_scenarioTable.SelectedRow;

            if (row == null)
            {
                return;
            }

            if (row.UserData == null)
            {
                return;
            }

            string      fullPath  = (string)(((Tuple <string, MyWorldInfo>)row.UserData).Item1);
            MyWorldInfo worldInfo = FindSave(m_scenarioTable.SelectedRow).Item2;
            //var mod = (MyObjectBuilder_Checkpoint.ModItem)row.UserData;
            //var nameSB = m_selectedRow.GetCell(1).Text;
            //var name = nameSB.ToString();

            MyStringId textQuestion, captionQuestion;

            if (worldInfo.WorkshopId != null)
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToUpdateScenario;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToUpdateScenario;
            }
            else
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToPublishScenario;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToPublishScenario;
            }

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageText : MyTexts.Get(textQuestion),
                                       messageCaption : MyTexts.Get(captionQuestion),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    string[] inTags    = null;
                    var subscribedItem = GetSubscribedItem(worldInfo.WorkshopId);
                    if (subscribedItem != null)
                    {
                        inTags = subscribedItem.Tags;

                        if (subscribedItem.SteamIDOwner != MySteam.UserId)
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextPublishFailed_OwnerMismatchMod),//TODO rename
                                                       messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed)));
                            return;
                        }
                    }

                    /*MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_SCENARIO_TAG, MySteamWorkshop.ScenarioCategories, inTags, delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags)
                     * {
                     *  if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES)
                     *  {*/
                    MySteamWorkshop.PublishScenarioAsync(fullPath, worldInfo.SessionName, worldInfo.Description, worldInfo.WorkshopId, /*outTags,*/ SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)           //TODO public visibility!!
                    {
                        if (success)
                        {
                            ulong dummy;
                            var checkpoint        = MyLocalCache.LoadCheckpoint(fullPath, out dummy);
                            worldInfo.WorkshopId  = publishedFileId;
                            checkpoint.WorkshopId = publishedFileId;
                            MyLocalCache.SaveCheckpoint(checkpoint, fullPath);

                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       styleEnum: MyMessageBoxStyleEnum.Info,
                                                       messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextScenarioPublished),
                                                       messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionScenarioPublished),
                                                       callback: (a) =>
                            {
                                MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                                FillList();
                            }));
                        }
                        else
                        {
                            MyStringId error;
                            switch (result)
                            {
                            case Result.AccessDenied:
                                error = MySpaceTexts.MessageBoxTextPublishFailed_AccessDenied;
                                break;

                            default:
                                error = MySpaceTexts.MessageBoxTextScenarioPublishFailed;
                                break;
                            }

                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(error),
                                                       messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed)));
                        }
                    });            /*
                                    * }
                                    * }));*/
                }
            }));
        }
Exemplo n.º 27
0
        private void OnPublishModClick(MyGuiControlButton sender)
        {
            if (m_selectedRow == null)
            {
                return;
            }

            if (m_selectedRow.UserData == null)
            {
                return;
            }

            var mod         = (MyObjectBuilder_Checkpoint.ModItem)m_selectedRow.UserData;
            var modFullPath = Path.Combine(MyFileSystem.ModsPath, mod.Name);
            var nameSB      = m_selectedRow.GetCell(1).Text;
            var name        = nameSB.ToString();

            mod.PublishedFileId = MySteamWorkshop.GetWorkshopIdFromLocalMod(modFullPath);

            MyStringId textQuestion, captionQuestion;

            if (mod.PublishedFileId != 0)
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToUpdateMod;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToUpdateMod;
            }
            else
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToPublishMod;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToPublishMod;
            }

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageText : MyTexts.Get(textQuestion),
                                       messageCaption : MyTexts.Get(captionQuestion),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    string[] inTags    = null;
                    var subscribedItem = GetSubscribedItem(mod.PublishedFileId);
                    if (subscribedItem != null)
                    {
                        inTags = subscribedItem.Tags;

                        if (subscribedItem.SteamIDOwner != MySteam.UserId)
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextPublishFailed_OwnerMismatchMod),
                                                       messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed)));
                            return;
                        }
                    }

                    MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_MOD_TAG, MySteamWorkshop.ModCategories, inTags, delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags)
                    {
                        if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            MySteamWorkshop.PublishModAsync(modFullPath, name, null, mod.PublishedFileId, outTags, SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)
                            {
                                if (success)
                                {
                                    MySteamWorkshop.GenerateModInfo(modFullPath, publishedFileId, MySteam.UserId);
                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               styleEnum: MyMessageBoxStyleEnum.Info,
                                                               messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextModPublished),
                                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublished),
                                                               callback: (a) =>
                                    {
                                        MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                                        FillList();
                                    }));
                                }
                                else
                                {
                                    MyStringId error;
                                    switch (result)
                                    {
                                    case Result.AccessDenied:
                                        error = MySpaceTexts.MessageBoxTextPublishFailed_AccessDenied;
                                        break;

                                    default:
                                        error = MySpaceTexts.MessageBoxTextWorldPublishFailed;
                                        break;
                                    }

                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               messageText: MyTexts.Get(error),
                                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed)));
                                }
                            });
                        }
                    }));
                }
            }));
        }
Exemplo n.º 28
0
        private void RefreshGameList()
        {
            m_selectedRow   = null;
            m_selectedTable = null;

            ListReader <MyObjectBuilder_Checkpoint.ModItem> lastActiveMods;

            if (m_keepActiveMods)
            {
                var tmp = new List <MyObjectBuilder_Checkpoint.ModItem>(m_modsTableEnabled.RowsCount);
                GetActiveMods(tmp);
                lastActiveMods = tmp;
            }
            else
            {
                lastActiveMods = m_modListToEdit;
            }
            m_keepActiveMods = true;
            GetWorldMods(lastActiveMods);

            m_modsTableEnabled.Clear();
            m_modsTableDisabled.Clear();
            AddHeaders();

            foreach (var mod in lastActiveMods)
            {
                if (mod.PublishedFileId == 0)
                {
                    var   title                = new StringBuilder(mod.Name);
                    var   modFullPath          = Path.Combine(MyFileSystem.ModsPath, mod.Name);
                    var   toolTip              = new StringBuilder(modFullPath);
                    var   modState             = MyTexts.Get(MySpaceTexts.ScreenMods_LocalMod);
                    Color?textColor            = null;
                    MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_LOCAL;

                    if (!Directory.Exists(modFullPath) && !File.Exists(modFullPath))
                    {
                        toolTip   = MyTexts.Get(MySpaceTexts.ScreenMods_MissingLocalMod);
                        modState  = toolTip;
                        textColor = MyHudConstants.MARKER_COLOR_RED;
                    }

                    AddMod(true, title, toolTip, modState, icon, mod, textColor);
                }
                else
                {
                    var   title     = new StringBuilder();
                    var   toolTip   = new StringBuilder();
                    var   modState  = MyTexts.Get(MySpaceTexts.ScreenMods_WorkshopMod);
                    Color?textColor = null;

                    var subscribedItem = GetSubscribedItem(mod.PublishedFileId);
                    if (subscribedItem != null)
                    {
                        title.Append(subscribedItem.Title);

                        var shortLen     = Math.Min(subscribedItem.Description.Length, 128);
                        var newlineIndex = subscribedItem.Description.IndexOf("\n");
                        if (newlineIndex > 0)
                        {
                            shortLen = Math.Min(shortLen, newlineIndex - 1);
                        }
                        toolTip.Append(subscribedItem.Description.Substring(0, shortLen));
                    }
                    else
                    {
                        title.Append(mod.PublishedFileId.ToString());
                        toolTip   = MyTexts.Get(MySpaceTexts.ScreenMods_MissingDetails);
                        textColor = MyHudConstants.MARKER_COLOR_RED;
                    }

                    MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP;

                    AddMod(true, title, toolTip, modState, icon, mod, textColor);
                }
            }

            if (!Directory.Exists(MyFileSystem.ModsPath))
            {
                Directory.CreateDirectory(MyFileSystem.ModsPath);
            }

            foreach (var modFullPath in Directory.GetDirectories(MyFileSystem.ModsPath, "*", SearchOption.TopDirectoryOnly))
            {
                var modName = Path.GetFileName(modFullPath);
                if (m_worldLocalMods.Contains(modName))
                {
                    continue;
                }

                if (Directory.GetFileSystemEntries(modFullPath).Length == 0)
                {
                    continue;
                }

                if (MyFakes.ENABLE_MOD_CATEGORIES)
                {
                    if (!CheckSearch(modName))
                    {
                        continue;
                    }
                }

                var titleSB       = new StringBuilder(modName);
                var descriptionSB = modFullPath;
                var modStateSB    = MyTexts.GetString(MySpaceTexts.ScreenMods_LocalMod);

                var publishedFileId = MySteamWorkshop.GetWorkshopIdFromLocalMod(modFullPath);

                MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_LOCAL;

                var row = new MyGuiControlTable.Row(new MyObjectBuilder_Checkpoint.ModItem(modName, 0));
                row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(), toolTip: modStateSB, icon: icon));
                row.AddCell(new MyGuiControlTable.Cell(text: titleSB, toolTip: descriptionSB));
                m_modsTableDisabled.Add(row);
            }

            if (m_subscribedMods != null)
            {
                foreach (var mod in m_subscribedMods)
                {
                    if (m_worldWorkshopMods.Contains(mod.PublishedFileId))
                    {
                        continue;
                    }
                    if (MyFakes.ENABLE_MOD_CATEGORIES)
                    {
                        bool add = false;
                        foreach (var tag in mod.Tags)
                        {
                            if (m_selectedCategories.Contains(tag.ToLower()) || m_selectedCategories.Count == 0)
                            {
                                add = true;
                                break;
                            }
                        }
                        if (!CheckSearch(mod.Title))
                        {
                            continue;
                        }
                        if (!add)
                        {
                            continue;
                        }
                    }
                    var titleSB      = new StringBuilder(mod.Title);
                    var shortLen     = Math.Min(mod.Description.Length, 128);
                    var newlineIndex = mod.Description.IndexOf("\n");
                    if (newlineIndex > 0)
                    {
                        shortLen = Math.Min(shortLen, newlineIndex - 1);
                    }
                    var descriptionSB = new StringBuilder();
                    var modStateSB    = MyTexts.GetString(MySpaceTexts.ScreenMods_WorkshopMod);

                    var path = Path.Combine(MyFileSystem.ModsPath, string.Format("{0}.sbm", mod.PublishedFileId));

                    if (mod.Description.Length != 0)
                    {
                        descriptionSB.AppendLine(path);
                    }
                    else
                    {
                        descriptionSB.Append(path);
                    }
                    descriptionSB.Append(mod.Description.Substring(0, shortLen));

                    MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP;

                    var row = new MyGuiControlTable.Row(new MyObjectBuilder_Checkpoint.ModItem(null, mod.PublishedFileId));
                    row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(), toolTip: modStateSB, icon: icon));
                    row.AddCell(new MyGuiControlTable.Cell(text: titleSB, toolTip: descriptionSB.ToString()));
                    m_modsTableDisabled.Add(row);
                }
            }
        }
Exemplo n.º 29
0
        public static void Publish(string sessionPath, MyWorldInfo worlInfo)
        {
            if (MyFakes.XBOX_PREVIEW)
            {
                MyGuiSandbox.Show(MyCommonTexts.MessageBoxTextErrorFeatureNotAvailableYet, MyCommonTexts.MessageBoxCaptionError);
                return;
            }

            MyStringId textQuestion, captionQuestion;

            if (worlInfo.WorkshopId.HasValue)
            {
                textQuestion    = MyCommonTexts.MessageBoxTextDoYouWishToUpdateWorld;
                captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToUpdateWorld;
            }
            else
            {
                textQuestion    = MyCommonTexts.MessageBoxTextDoYouWishToPublishWorld;
                captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToPublishWorld;
            }

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageText : MyTexts.Get(textQuestion),
                                       messageCaption : MyTexts.Get(captionQuestion),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    Action <MyGuiScreenMessageBox.ResultEnum, string[]> onTagsChosen = delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags)
                    {
                        if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            MySteamWorkshop.PublishWorldAsync(sessionPath, worlInfo.SessionName, worlInfo.Description, worlInfo.WorkshopId, outTags, SteamSDK.PublishedFileVisibility.Public,
                                                              callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)
                            {
                                if (success)
                                {
                                    ulong dummy;
                                    var checkpoint        = MyLocalCache.LoadCheckpoint(sessionPath, out dummy);
                                    worlInfo.WorkshopId   = publishedFileId;
                                    checkpoint.WorkshopId = publishedFileId;
                                    MyLocalCache.SaveCheckpoint(checkpoint, sessionPath);
                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               styleEnum: MyMessageBoxStyleEnum.Info,
                                                               messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextWorldPublished),
                                                               messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublished),
                                                               callback: (a) =>
                                    {
                                        MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                                    }));
                                }
                                else
                                {
                                    MyStringId error;
                                    switch (result)
                                    {
                                    case Result.AccessDenied:
                                        error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied;
                                        break;

                                    default:
                                        error = MyCommonTexts.MessageBoxTextWorldPublishFailed;
                                        break;
                                    }

                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               messageText: MyTexts.Get(error),
                                                               messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublishFailed)));
                                }
                            });
                        }
                    };

                    if (MySteamWorkshop.WorldCategories.Length > 0)
                    {
                        MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_WORLD_TAG, MySteamWorkshop.WorldCategories, null, onTagsChosen));
                    }
                    else
                    {
                        onTagsChosen(MyGuiScreenMessageBox.ResultEnum.YES, new string[] { MySteamWorkshop.WORKSHOP_WORLD_TAG });
                    }
                }
            }));
        }
Exemplo n.º 30
0
        public static void LoadSingleplayerSession(MyObjectBuilder_Checkpoint checkpoint, string sessionPath, ulong checkpointSizeInBytes)
        {
            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }


            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success)
            {
                if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods))
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }
                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load);
                        MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes);
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString());

                    if (MySteam.IsOnline)
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                                   buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result)
                        {
                            if (MyFakes.QUICK_LAUNCH != null)
                            {
                                MyGuiScreenMainMenu.ReturnToMainMenu();
                            }
                        }));
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }