Пример #1
0
 public void OnClosedMessageBox(ResultEnum result)
 {
     if (result == ResultEnum.OK)
     {
         CloseWindow();
     }
     else
     {
         CreateTextBox(true, m_textBox.Description.Text.ToString());
         MyScreenManager.AddScreen(m_textBox);
     }
 }
Пример #2
0
 public void OpenWindow(bool isEditable, bool sync, bool isPublic)
 {
     if (sync)
     {
         SyncObject.SendChangeOpenMessage(true, isEditable, Sync.MyId, isPublic);
         return;
     }
     m_isEditingPublic = isPublic;
     CreateTextBox(isEditable, isPublic ? PublicDescription : PrivateDescription, isPublic);
     MyGuiScreenGamePlay.TmpGameplayScreenHolder = MyGuiScreenGamePlay.ActiveGameplayScreen;
     MyScreenManager.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_textBox);
 }
Пример #3
0
 public void OnClosedMessageBox(MyGuiScreenMessageBox.ResultEnum result)
 {
     if (result == MyGuiScreenMessageBox.ResultEnum.YES)
     {
         m_textBox.Description.Text.Remove(MAX_NUMBER_CHARACTERS, m_textBox.Description.Text.Length - (MAX_NUMBER_CHARACTERS));
         CloseWindow(m_isEditingPublic);
     }
     else
     {
         CreateTextBox(true, m_textBox.Description.Text, m_isEditingPublic);
         MyScreenManager.AddScreen(m_textBox);
     }
 }
Пример #4
0
        private void SaveCode(ResultEnum result)
        {
            MyGuiScreenGamePlay.ActiveGameplayScreen    = MyGuiScreenGamePlay.TmpGameplayScreenHolder;
            MyGuiScreenGamePlay.TmpGameplayScreenHolder = null;
            SyncObject.SendCloseEditor();
            if (m_editorScreen.TextTooLong() == true)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MySpaceTexts.ProgrammableBlock_CodeChanged),
                    messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_TextTooLong),
                    buttonType: MyMessageBoxButtonsType.OK,
                    canHideOthers: false);
                MyScreenManager.AddScreen(messageBox);
                return;
            }

            DetailedInfo.Clear();
            RaisePropertiesChanged();
            if (result == ResultEnum.OK)
            {
                SaveCode();
            }
            else
            {
                string editorText = m_editorScreen.Description.Text.ToString();
                if (editorText != m_programData)
                {
                    var messageBox = MyGuiSandbox.CreateMessageBox(
                        messageCaption: MyTexts.Get(MySpaceTexts.ProgrammableBlock_CodeChanged),
                        messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_SaveChanges),
                        buttonType: MyMessageBoxButtonsType.YES_NO,
                        canHideOthers: false);

                    messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result2)
                    {
                        if (result2 == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            SaveCode(ResultEnum.OK);
                        }
                        else
                        {
                            m_editorData = m_programData;
                        }
                    };
                    MyScreenManager.AddScreen(messageBox);
                }
            }
        }
Пример #5
0
 private void SaveCode()
 {
     if (m_editorScreen.TextTooLong() == true)
     {
         var messageBox = MyGuiSandbox.CreateMessageBox(
             messageCaption: MyTexts.Get(MySpaceTexts.ProgrammableBlock_CodeChanged),
             messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_TextTooLong),
             buttonType: MyMessageBoxButtonsType.OK,
             canHideOthers: false);
         MyScreenManager.AddScreen(messageBox);
         return;
     }
     m_editorData = m_programData = m_editorScreen.Description.Text.ToString();
     m_compilerErrors.Clear();
     SyncObject.SendUpdateProgramRequest(m_programData, m_storageData);
 }
        public override void HandleInput(bool receivedFocusInThisUpdate)
        {
            base.HandleInput(receivedFocusInThisUpdate);

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && MySession.Static.IsServer)
            {
                // Show Scripting tools
                MyScreenManager.AddScreen(new MyGuiScreenScriptingTools());
                CloseScreen();
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F12) || MyInput.Static.IsNewKeyPressed(MyKeys.F10))
            {
                this.CloseScreen();
            }
        }
Пример #7
0
 void OnEditDescription(MyGuiControlButton button)
 {
     m_dialog = new MyGuiBlueprintTextDialog(
         position : m_position,
         caption : "Enter new description",
         defaultName : m_loadedPrefab.ShipBlueprints[0].Description,
         maxLenght : 8000,
         callBack : delegate(string result)
     {
         if (result != null)
         {
             ChangeDescription(result);
         }
     }
         );
     MyScreenManager.AddScreen(m_dialog);
 }
Пример #8
0
        public void OpenEditor()
        {
            if (m_editorData == null)
            {
                m_editorData = "void Main(string argument)\n{\n}";
            }

            m_editorScreen = new MyGuiScreenEditor(missionTitle: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_CodeEditor_Title),
                                                   currentObjectivePrefix: "",
                                                   currentObjective: "",
                                                   description: m_editorData,
                                                   resultCallback: SaveCode,
                                                   saveCodeCallback: SaveCode,
                                                   okButtonCaption: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_CodeEditor_SaveExit));
            MyGuiScreenGamePlay.TmpGameplayScreenHolder = MyGuiScreenGamePlay.ActiveGameplayScreen;
            MyScreenManager.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_editorScreen);
        }
        private void OnPublishButtonOnClick(MyGuiControlButton myGuiControlButton)
        {
            if (m_selectedCampaign == null)
            {
                return;
            }

            MyCampaignManager.Static.SwitchCampaign(m_selectedCampaign.Name, m_selectedCampaign.IsVanilla, m_selectedCampaign.IsLocalMod);
            MyScreenManager.AddScreen(
                MyGuiSandbox.CreateMessageBox(
                    styleEnum: MyMessageBoxStyleEnum.Info,
                    buttonType: MyMessageBoxButtonsType.YES_NO,
                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextDoYouWishToPublishCampaign),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionDoYouWishToPublishCampaign),
                    callback: (e) => MyCampaignManager.Static.PublishActive()
                    )
                );
        }
 public void MySyncScenario_InfoAnswer(bool gameAlreadyRunning, bool canJoinGame)
 {
     if (canJoinGame)
     {
         m_startButton.Enabled = gameAlreadyRunning; //when a client joins into a running game, he needs to have start button enabled (with slightly different meaning than server)
     }
     else
     {
         var messageBox = MyGuiSandbox.CreateMessageBox(
             messageCaption: MyTexts.Get(MySpaceTexts.GuiScenarioCannotJoinCaption),
             messageText: MyTexts.Get(MySpaceTexts.GuiScenarioCannotJoin),
             buttonType: MyMessageBoxButtonsType.OK,
             canHideOthers: false,
             callback:  (v) => { Canceling(); });
         MyScreenManager.AddScreen(messageBox);
         //start button stays disabled
     }
 }
Пример #11
0
        void OnFlagChanged(MyTrashRemovalFlags flag, bool value)
        {
            if (flag == MyTrashRemovalFlags.WithMedBay && value && m_showMedbayNotification)
            {
                var msgBox = MyGuiSandbox.CreateMessageBox(messageText: MyTexts.Get(MySpaceTexts.ScreenDebugAdminMenu_MedbayNotification));
                MyScreenManager.AddScreen(msgBox);
                m_showMedbayNotification = false;
            }

            if (value)
            {
                MyTrashRemoval.PreviewSettings.Flags |= flag;
            }
            else
            {
                MyTrashRemoval.PreviewSettings.Flags &= ~flag;
            }
            RecalcTrash();
        }
Пример #12
0
        void OnRename(MyGuiControlButton button)
        {
            m_dialog = new MyGuiBlueprintTextDialog(
                position : m_position,
                caption : "Enter new name",
                defaultName : m_blueprintName,
                maxLenght : maxNameLenght,
                callBack : delegate(string result)
            {
                if (result != null)
                {
                    ChangeName(result);
                }
            },
                textBoxWidth: 0.3f
                );

            MyScreenManager.AddScreen(m_dialog);
        }
        void OnRename(MyGuiControlButton button)
        {
            m_dialog = new MyGuiBlueprintTextDialog(
                position : m_position,
                caption : MyTexts.GetString(MySpaceTexts.ProgrammableBlock_NewScriptName),
                defaultName : m_selectedItem.ScriptName,
                maxLenght : maxNameLenght,
                callBack : delegate(string result)
            {
                if (result != null)
                {
                    m_parent.ChangeName(result);
                }
            },
                textBoxWidth: 0.3f
                );

            MyScreenManager.AddScreen(m_dialog);
        }
        void OpenEditor()
        {
            if (m_editorData == null)
            {
                var constructorInfo = ToIndentedComment(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_DefaultScript_Constructor).Trim());
                var saveInfo        = ToIndentedComment(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_DefaultScript_Save).Trim());
                var mainInfo        = ToIndentedComment(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_DefaultScript_Main).Trim());
                m_editorData = string.Format(DEFAULT_SCRIPT_TEMPLATE, constructorInfo, saveInfo, mainInfo);
            }

            m_editorScreen = new MyGuiScreenEditor(missionTitle: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_CodeEditor_Title),
                                                   currentObjectivePrefix: "",
                                                   currentObjective: "",
                                                   description: m_editorData,
                                                   resultCallback: SaveCode,
                                                   saveCodeCallback: SaveCode,
                                                   okButtonCaption: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_CodeEditor_SaveExit));
            MyGuiScreenGamePlay.TmpGameplayScreenHolder = MyGuiScreenGamePlay.ActiveGameplayScreen;
            MyScreenManager.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_editorScreen);
        }
 private void SaveCode()
 {
     if (m_editorScreen.TextTooLong() == true)
     {
         var messageBox = MyGuiSandbox.CreateMessageBox(
             messageCaption: MyTexts.Get(MySpaceTexts.ProgrammableBlock_CodeChanged),
             messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_TextTooLong),
             buttonType: MyMessageBoxButtonsType.OK,
             canHideOthers: false);
         MyScreenManager.AddScreen(messageBox);
         return;
     }
     m_editorData = m_programData = m_editorScreen.Description.Text.ToString();
     m_compilerErrors.Clear();
     // If there is an existing instance, make sure the storage data is updated before sending
     // an update request
     if (m_instance != null)
     {
         m_storageData = m_instance.Storage;
     }
     SyncObject.SendUpdateProgramRequest(m_programData, m_storageData);
 }
        void OnRename(MyGuiControlButton button)
        {
            if (m_selectedItem == null)
            {
                return;
            }

            MyScreenManager.AddScreen(new MyGuiBlueprintTextDialog(
                                          position : m_position - new Vector2(SCREEN_SIZE.X, 0.0f),
                                          caption : MyTexts.GetString(MySpaceTexts.ProgrammableBlock_NewScriptName),
                                          defaultName : m_selectedItem.Text.ToString(),
                                          maxLenght : 50,
                                          callBack : delegate(string result)
            {
                if (result != null)
                {
                    ChangeName(result);
                }
            },
                                          textBoxWidth: 0.3f
                                          ));
        }
    private void CreateMainMenuControls()
    {
        MyStringId optionsScreen_Help_Menu = MySpaceTexts.OptionsScreen_Help_Menu;
        Vector2    vector = new Vector2(0.001f, (0f - m_size.Value.Y) / 2f + 0.126f);
        int        num    = 0;
        MyObjectBuilder_LastSession lastSession = MyLocalCache.GetLastSession();

        if (lastSession != null && (lastSession.Path == null || MyPlatformGameSettings.GAME_SAVES_TO_CLOUD || Directory.Exists(lastSession.Path)) && (!lastSession.IsLobby || MyGameService.LobbyDiscovery.ContinueToLobbySupported))
        {
            MyGuiControlButton myGuiControlButton = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonContinueGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession();
                if (mySession == null)
                {
                    return;
                }
                if (mySession.IsOnline)
                {
                    if (mySession.IsLobby)
                    {
                        MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP));
                        return;
                    }
                    MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
                    {
                        switch (granted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                            {
                                switch (crossGranted)
                                {
                                case PermissionResult.Granted:
                                    MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                                    {
                                        switch (ugcGranted)
                                        {
                                        case PermissionResult.Granted:
                                            JoinServer(mySession);
                                            break;

                                        case PermissionResult.Error:
                                            MySandboxGame.Static.Invoke(delegate
                                            {
                                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                            }, "New Game screen");
                                            break;
                                        }
                                    });
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MySandboxGame.Static.Invoke(delegate
                            {
                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            }, "New Game screen");
                            break;
                        }
                    });
                }
                else if (!m_parallelLoadIsRunning)
                {
                    m_parallelLoadIsRunning            = true;
                    MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld));
                    MyScreenManager.AddScreen(progressScreen);
                    Parallel.StartBackground(delegate
                    {
                        MySessionLoader.LoadLastSession();
                    }, delegate
                    {
                        progressScreen.CloseScreen();
                        m_parallelLoadIsRunning = false;
                    });
                }
            });

            myGuiControlButton.GamepadHelpTextId = optionsScreen_Help_Menu;
            Controls.Add(myGuiControlButton);
            m_elementGroup.Add(myGuiControlButton);
        }
        else
        {
            num--;
        }

        MyGuiControlButton myGuiControlButton2 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonCampaign), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenNewGame>(new object[3] {
                true, true, true
            }));
        });

        myGuiControlButton2.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton2);
        m_elementGroup.Add(myGuiControlButton2);



        MyGuiControlButton myGuiControlButton3 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonLoadGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            MyGuiSandbox.AddScreen(new MyGuiScreenLoadSandbox());
        });

        myGuiControlButton3.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton3);
        m_elementGroup.Add(myGuiControlButton3);


        if (MyPerGameSettings.MultiplayerEnabled)
        {
            MyGuiControlButton myGuiControlButton4 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonJoinGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                if (MyGameService.IsOnline)
                {
                    MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
                    {
                        switch (granted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                            {
                                switch (ugcGranted)
                                {
                                case PermissionResult.Granted:
                                    MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                                    {
                                        MyGuiScreenJoinGame myGuiScreenJoinGame = new MyGuiScreenJoinGame(crossGranted == PermissionResult.Granted);
                                        myGuiScreenJoinGame.Closed += joinGameScreen_Closed;
                                        MyGuiSandbox.AddScreen(myGuiScreenJoinGame);
                                    });
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            break;
                        }
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyGameService.IsActive ? MyCommonTexts.SteamIsOfflinePleaseRestart : MyCommonTexts.ErrorJoinSessionNoUser), MySession.GameServiceName)));
                }
            });
            myGuiControlButton4.GamepadHelpTextId = optionsScreen_Help_Menu;
            Controls.Add(myGuiControlButton4);
            m_elementGroup.Add(myGuiControlButton4);
        }

        MyGuiControlButton myGuiControlButton5 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonOptions), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            bool flag = !MyPlatformGameSettings.LIMITED_MAIN_MENU;

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyOldOptionsAccessMenu>(new object[1] {
                !flag
            }));
        });

        myGuiControlButton5.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton5);
        m_elementGroup.Add(myGuiControlButton5);

        if (MyFakes.ENABLE_MAIN_MENU_INVENTORY_SCENE)
        {
            MyGuiControlButton myGuiControlButton6 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonInventory), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                if (MyGameService.IsActive)
                {
                    if (MyGameService.Service.GetInstallStatus(out var _))
                    {
                        if (MySession.Static == null)
                        {
                            MyGuiScreenLoadInventory inventory = MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(Array.Empty <object>());
                            MyGuiScreenLoading screen          = new MyGuiScreenLoading(inventory, null);
                            MyGuiScreenLoadInventory myGuiScreenLoadInventory = inventory;
                            myGuiScreenLoadInventory.OnLoadingAction          = (Action)Delegate.Combine(myGuiScreenLoadInventory.OnLoadingAction, (Action) delegate
                            {
                                MySessionLoader.LoadInventoryScene();
                                MySandboxGame.IsUpdateReady = true;
                                inventory.Initialize(inGame: false, null);
                            });
                            MyGuiSandbox.AddScreen(screen);
                        }
                        else
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(new object[2] {
                                false, null
                            }));
                        }
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionInfo), messageText: MyTexts.Get(MyCommonTexts.InventoryScreen_InstallInProgress)));
                    }
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.SteamIsOfflinePleaseRestart)));
                }
            });
Пример #18
0
 private bool ReloadScreen()
 {
     MyScreenManager.CloseScreen(typeof(MyGuiScreenNewGame));
     MyScreenManager.AddScreen(new MyGuiScreenNewGame());
     return(true);
 }
Пример #19
0
        /// <summary>
        /// Use this method to highlight the set of provided controls and their tooltips.
        /// </summary>
        /// <param name="controls">Array of controls to be highlighted.</param>
        /// <param name="color">Color of the highlight.</param>
        public static void HighlightControls(MyHighlightControl[] controlsData)
        {
            var screen = new MyGuiScreenHighlight(controlsData);

            MyScreenManager.AddScreen(screen);
        }
Пример #20
0
 void OnWorkshopClick(MyGuiControlButton sender)
 {
     MyScreenManager.AddScreen(new MyGuiScreenLoadSubscribedWorld());
 }
 void IMyUtilities.ShowMissionScreen(string screenTitle, string currentObjectivePrefix, string currentObjective, string screenDescription, Action <ResultEnum> callback = null, string okButtonCaption = null)
 {
     MyScreenManager.AddScreen(new MyGuiScreenMission(screenTitle, currentObjectivePrefix, currentObjective, screenDescription, callback, okButtonCaption));
 }
Пример #22
0
 void OpenWorkshopButtonClicked(MyGuiControlButton button)
 {
     DisableButtons();
     MyScreenManager.AddScreen(new MyGuiIngameScriptsPage(ScriptSelected, GetCode, WorkshopWindowClosed));
 }
Пример #23
0
 void OnDetails(MyGuiControlButton button)
 {
     if (m_selectedItem == null)
     {
         if (m_activeDetail)
         {
             MyScreenManager.RemoveScreen(m_detailScreen);
         }
         return;
     }
     else if (m_activeDetail)
     {
         MyScreenManager.RemoveScreen(m_detailScreen);
     }
     else if (!m_activeDetail)
     {
         if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
         {
             var path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "bp.sbc");
             if (File.Exists(path))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen           = new MyGuiDetailScreenLocal(
                     callBack : delegate(MyGuiControlListbox.Item item)
                 {
                     if (item == null)
                     {
                         m_screenshotButton.Enabled = false;
                         m_detailsButton.Enabled    = false;
                         m_replaceButton.Enabled    = false;
                         m_deleteButton.Enabled     = false;
                     }
                     m_selectedItem = item;
                     m_activeDetail = false;
                     m_detailScreen = null;
                     if (m_task.IsComplete)
                     {
                         RefreshBlueprintList();
                     }
                 },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                            buttonType: MyMessageBoxButtonsType.OK,
                                            styleEnum: MyMessageBoxStyleEnum.Error,
                                            messageCaption: new StringBuilder("Error"),
                                            messageText: new StringBuilder("Cannot find the blueprint file.")
                                            ));
             }
         }
         else if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
         {
             var path2 = Path.Combine(m_workshopBlueprintFolder, (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId.ToString() + m_workshopBlueprintSuffix);
             if (File.Exists(path2))
             {
                 m_thumbnailImage.Visible = false;
                 m_detailScreen           = new MyGuiDetailScreenSteam(
                     callBack : delegate(MyGuiControlListbox.Item item)
                 {
                     m_selectedItem = item;
                     m_activeDetail = false;
                     m_detailScreen = null;
                     if (m_task.IsComplete)
                     {
                         RefreshBlueprintList();
                     }
                 },
                     selectedItem: m_selectedItem,
                     parent: this,
                     thumbnailTexture: m_selectedImage.BackgroundTexture,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                            buttonType: MyMessageBoxButtonsType.OK,
                                            styleEnum: MyMessageBoxStyleEnum.Error,
                                            messageCaption: new StringBuilder("Error"),
                                            messageText: new StringBuilder("Cannot find the blueprint file.")
                                            ));
             }
         }
     }
 }
 void OnDetails(MyGuiControlButton button)
 {
     if (m_selectedItem == null)
     {
         if (m_activeDetail)
         {
             MyScreenManager.RemoveScreen(m_detailScreen);
         }
         return;
     }
     else if (m_activeDetail)
     {
         MyScreenManager.RemoveScreen(m_detailScreen);
     }
     else if (!m_activeDetail)
     {
         if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
         {
             var path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString());
             if (Directory.Exists(path))
             {
                 m_detailScreen = new MyGuiDetailScreenScriptLocal(
                     callBack : delegate(MyScriptItemInfo item)
                 {
                     if (item == null)
                     {
                         m_renameButton.Enabled  = false;
                         m_detailsButton.Enabled = false;
                         m_deleteButton.Enabled  = false;
                     }
                     m_activeDetail = false;
                     if (m_task.IsComplete)
                     {
                         RefreshBlueprintList(m_detailScreen.WasPublished);
                     }
                 },
                     selectedItem: (m_selectedItem.UserData  as MyScriptItemInfo),
                     parent: this,
                     textScale: m_textScale
                     );
                 m_activeDetail = true;
                 MyScreenManager.InputToNonFocusedScreens = true;
                 MyScreenManager.AddScreen(m_detailScreen);
             }
             else
             {
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                            buttonType: MyMessageBoxButtonsType.OK,
                                            styleEnum: MyMessageBoxStyleEnum.Error,
                                            messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                            messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_ScriptNotFound)
                                            ));
             }
         }
         else if ((m_selectedItem.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
         {
             m_detailScreen = new MyGuiDetailScreenScriptLocal(
                 callBack : delegate(MyScriptItemInfo item)
             {
                 m_activeDetail = false;
                 if (m_task.IsComplete)
                 {
                     RefreshBlueprintList();
                 }
             },
                 selectedItem: (m_selectedItem.UserData as MyScriptItemInfo),
                 parent: this,
                 textScale: m_textScale
                 );
             m_activeDetail = true;
             MyScreenManager.InputToNonFocusedScreens = true;
             MyScreenManager.AddScreen(m_detailScreen);
         }
     }
 }
Пример #25
0
        void CheckCodeButtonClicked(MyGuiControlButton button)
        {
            string code = Description.Text.ToString();

            m_compilerErrors.Clear();
            Assembly assembly = null;

            if (CompileProgram(code, m_compilerErrors, ref assembly))
            {
                if (MyFakes.ENABLE_ROSLYN_SCRIPTS && m_compilerErrors.Count > 0)
                {
                    var messageBuilder = new StringBuilder();
                    foreach (var message in m_compilerErrors)
                    {
                        messageBuilder.Append(message);
                        messageBuilder.Append('\n');
                    }
                    var errorListScreen = new MyGuiScreenMission(missionTitle: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_CompilationOk),
                                                                 currentObjectivePrefix: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_CompilationOkWarningList),
                                                                 currentObjective: "",
                                                                 description: messageBuilder.ToString(),
                                                                 canHideOthers: false,
                                                                 enableBackgroundFade: true,
                                                                 style: MyMissionScreenStyleEnum.BLUE);

                    MyScreenManager.AddScreen(errorListScreen);
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               styleEnum: MyMessageBoxStyleEnum.Info,
                                               buttonType: MyMessageBoxButtonsType.OK,
                                               messageText: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_CompilationOk),
                                               canHideOthers: false));
                }
            }
            else
            {
                string compilerErrors;
                if (MyFakes.ENABLE_ROSLYN_SCRIPTS && m_compilerErrors.Count > 0)
                {
                    compilerErrors = string.Join("\n", m_compilerErrors);
                }
                else
                {
                    compilerErrors = "";
                    foreach (var error in m_compilerErrors)
                    {
                        compilerErrors += FormatError(error) + "\n";
                    }
                }
                var errorListScreen = new MyGuiScreenMission(missionTitle: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_CompilationFailed),
                                                             currentObjectivePrefix: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_CompilationFailedErrorList),
                                                             currentObjective: "",
                                                             description: compilerErrors,
                                                             canHideOthers: false,
                                                             enableBackgroundFade: true,
                                                             style: MyMissionScreenStyleEnum.RED);

                MyScreenManager.AddScreen(errorListScreen);
            }
            FocusedControl = m_descriptionBox;
        }
Пример #26
0
    private void ContinueGameInternal()
    {
        MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession();

        if (mySession == null)
        {
            return;
        }
        if (mySession.IsOnline)
        {
            if (mySession.IsLobby)
            {
                MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP));
                return;
            }
            MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
            {
                switch (granted)
                {
                case PermissionResult.Granted:
                    MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                    {
                        switch (crossGranted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                            {
                                switch (ugcGranted)
                                {
                                case PermissionResult.Granted:
                                    JoinServer(mySession);
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MySandboxGame.Static.Invoke(delegate
                            {
                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            }, "New Game screen");
                            break;
                        }
                    });
                    break;

                case PermissionResult.Error:
                    MySandboxGame.Static.Invoke(delegate
                    {
                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                    }, "New Game screen");
                    break;
                }
            });
        }
        else if (!m_parallelLoadIsRunning)
        {
            m_parallelLoadIsRunning = true;
            MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld));
            MyScreenManager.AddScreen(progressScreen);
            Parallel.StartBackground(delegate
            {
                MySessionLoader.LoadLastSession();
            }, delegate
            {
                progressScreen.CloseScreen();
                m_parallelLoadIsRunning = false;
            });
        }
    }