void OnSwitchAnswer(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySandboxGame.Config.GraphicsRenderer = MySandboxGame.DirectX11RendererKey; MySandboxGame.Config.Save(); MyGuiSandbox.BackToMainMenu(); var text = MyTexts.Get(MySpaceTexts.QuickstartDX11PleaseRestartGame); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } else { var text = MyTexts.Get(MySpaceTexts.QuickstartSelectDifferent); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: text, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
private static StringBuilder GetOwnerDisplayName(long owner) { if (owner == 0) { return(MyTexts.Get(MySpaceTexts.BlockOwner_Nobody)); } var identity = Sync.Players.TryGetIdentity(owner); if (identity != null) { return(new StringBuilder(identity.DisplayName)); } else { return(MyTexts.Get(MySpaceTexts.BlockOwner_Unknown)); } }
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 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() ) ); }
private void UpdateDisplay() { DetailedInfo.Clear(); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_Type)); DetailedInfo.Append(BlockDefinition.DisplayNameText); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput)); MyValueFormatter.AppendWorkInBestUnit(PowerReceiver.MaxRequiredInput, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_OxygenOutput)); DetailedInfo.Append((m_maxOxygenOutput * 100f).ToString("F")); DetailedInfo.Append("%"); RaisePropertiesChanged(); UpdateEmissivity(); }
private static void AddShipRespawnInfo(MyRespawnShipDefinition respawnShip, StringBuilder text) { var rc = MySpaceRespawnComponent.Static; int respawnSeconds = MySession.Static.LocalHumanPlayer == null ? 0 : rc.GetRespawnCooldownSeconds(MySession.Static.LocalHumanPlayer.Id, respawnShip.Id.SubtypeName); if (!rc.IsSynced) { text.Append(MyTexts.Get(MySpaceTexts.ScreenMedicals_RespawnShipNotReady)); } else if (respawnSeconds != 0) { MyValueFormatter.AppendTimeExact(respawnSeconds, text); } else { text.Append(MyTexts.Get(MySpaceTexts.ScreenMedicals_RespawnShipReady)); } }
private void grid_ItemClicked(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs) { if (eventArgs.Button == MySharedButtonsEnum.Secondary) { int slot = eventArgs.ColumnIndex; var toolbar = MyToolbarComponent.CurrentToolbar; MyToolbarItem item = toolbar.GetSlotItem(slot); if (item == null) { return; } //right clicks in multifunctional items should trigger their menus (if they have more than 0 options) if (item is MyToolbarItemActions) { var actionList = (item as MyToolbarItemActions).PossibleActions(ShownToolbar.ToolbarType); if (actionList.Count > 0) { m_contextMenu.CreateNewContextMenu(); foreach (var action in actionList) { m_contextMenu.AddItem(action.Name, icon: action.Icon, userData: action.Id); } m_contextMenu.AddItem(MyTexts.Get(MySpaceTexts.BlockAction_RemoveFromToolbar)); m_contextMenu.Enabled = true; m_contextMenuItemIndex = toolbar.SlotToIndex(slot); } else { RemoveToolbarItem(eventArgs.ColumnIndex); } } else { RemoveToolbarItem(eventArgs.ColumnIndex); } } if (m_shownToolbar.IsValidIndex(eventArgs.ColumnIndex)) { m_shownToolbar.ActivateItemAtSlot(eventArgs.ColumnIndex, true); } }
public override bool Update(bool hasFocus) { if (base.Update(hasFocus) == false) { return(false); } //MySandboxGame.GraphicsDeviceManager.DbgDumpLoadedResources(true); //MyTextureManager.DbgDumpLoadedTextures(true); if (m_downloadNewsTask.IsComplete && m_downloadedNewsFinished) { if (m_downloadedNewsOK) { DownloadNewsCompleted(); m_newsControl.State = MyGuiControlNews.StateEnum.Entries; } else { m_newsControl.State = MyGuiControlNews.StateEnum.Error; m_newsControl.ErrorText = MyTexts.Get(MyCommonTexts.NewsDownloadingFailed); } m_downloadedNewsFinished = false; } if (!m_musicPlayed)// && MySandboxGame.TotalTimeInMilliseconds - m_timeFromMenuLoadedMS >= PLAY_MUSIC_AFTER_MENU_LOADED_MS) { if (MyGuiScreenGamePlay.Static == null) { MyAudio.Static.PlayMusic(MyPerGameSettings.MainMenuTrack); } m_musicPlayed = true; } #if !XB1 if (MyReloadTestComponent.Enabled && State == MyGuiScreenState.OPENED) { MyReloadTestComponent.DoReload(); } #endif // !XB1 return(true); }
private void UpdateText() { DetailedInfo.Clear(); DetailedInfo.AppendStringBuilder(MyTexts.Get(MyCommonTexts.BlockPropertiesText_Type)); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BatteryBlock)); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxOutput)); MyValueFormatter.AppendWorkInBestUnit(BlockDefinition.MaxPowerOutput, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput)); MyValueFormatter.AppendWorkInBestUnit(BlockDefinition.RequiredPowerInput, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxStoredPower)); MyValueFormatter.AppendWorkHoursInBestUnit(MaxStoredPower, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyProperties_CurrentInput)); MyValueFormatter.AppendWorkInBestUnit(ResourceSink.CurrentInput, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyProperties_CurrentOutput)); MyValueFormatter.AppendWorkInBestUnit(SourceComp.CurrentOutput, DetailedInfo); DetailedInfo.Append("\n"); DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_StoredPower)); MyValueFormatter.AppendWorkHoursInBestUnit(CurrentStoredPower, DetailedInfo); DetailedInfo.Append("\n"); float currentInput = ResourceSink.CurrentInputByType(MyResourceDistributorComponent.ElectricityId); float currentOutput = SourceComp.CurrentOutputByType(MyResourceDistributorComponent.ElectricityId); if (currentInput > currentOutput) { DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_RechargedIn)); MyValueFormatter.AppendTimeInBestUnit(m_timeRemaining, DetailedInfo); } else if (currentInput == currentOutput) { DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_DepletedIn)); MyValueFormatter.AppendTimeInBestUnit(float.PositiveInfinity, DetailedInfo); } else { DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_DepletedIn)); MyValueFormatter.AppendTimeInBestUnit(m_timeRemaining, DetailedInfo); } RaisePropertiesChanged(); }
public WorldGeneratorDialog(InstanceManager instanceManager) { _instanceManager = instanceManager; InitializeComponent(); _loadLocalization(); var scenarios = MyLocalCache.GetAvailableWorldInfos(new List <string> { Path.Combine(MyFileSystem.ContentPath, "CustomWorlds") }); foreach (var tup in scenarios) { if (tup.Item2 == null) { continue; } string directory = tup.Item1; MyWorldInfo info = tup.Item2; var sessionNameId = MyStringId.GetOrCompute(info.SessionName); string localizedName = MyTexts.GetString(sessionNameId); var checkpoint = MyLocalCache.LoadCheckpoint(directory, out _); checkpoint.OnlineMode = MyOnlineModeEnum.PUBLIC; // Keen, why do random checkpoints point to the SBC and not the folder! directory = directory.Replace("Sandbox.sbc", ""); _checkpoints.Add(new PremadeCheckpointItem { Name = localizedName, Icon = Path.Combine(directory, "thumb.jpg"), Path = directory, Checkpoint = checkpoint }); } /* * var premadeCheckpoints = Directory.EnumerateDirectories(Path.Combine("Content", "CustomWorlds")); * foreach (var path in premadeCheckpoints) * { * var thumbPath = Path.GetFullPath(Directory.EnumerateFiles(path).First(x => x.Contains("thumb"))); * * _checkpoints.Add(new PremadeCheckpointItem * { * Path = path, * Icon = thumbPath, * Name = Path.GetFileName(path) * }); * }*/ PremadeCheckpoints.ItemsSource = _checkpoints; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyTexts.GetString(MyCommonTexts.PerformanceWarningHelpHeader)); m_warningsList = new MyGuiControlList(position: new Vector2(0f, -0.05f), size: new Vector2(0.92f, 0.7f)); var m_showWarningsLabel = new MyGuiControlLabel( text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_EnablePerformanceWarnings), position: new Vector2(-0.17f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER ); m_showWarningsCheckBox = new MyGuiControlCheckbox( toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsEnablePerformanceWarnings), position: new Vector2(-0.15f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); m_showWarningsCheckBox.IsChecked = MySandboxGame.Config.EnablePerformanceWarnings; m_showWarningsCheckBox.IsCheckedChanged += ShowWarningsChanged; var m_showAllLabel = new MyGuiControlLabel( text: MyTexts.GetString(MyCommonTexts.PerformanceWarningShowAll), position: new Vector2(0.25f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER ); m_showAllCheckBox = new MyGuiControlCheckbox( toolTip: MyTexts.GetString(MyCommonTexts.ToolTipPerformanceWarningShowAll), position: new Vector2(0.27f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); m_showAllCheckBox.IsChecked = m_showAll; m_showAllCheckBox.IsCheckedChanged += KeepInListChanged; m_okButton = new MyGuiControlButton(position: new Vector2(0, 0.42f), text: MyTexts.Get(MyCommonTexts.Ok)); m_okButton.ButtonClicked += m_okButton_ButtonClicked; Controls.Add(m_warningsList); Controls.Add(m_showWarningsLabel); Controls.Add(m_showWarningsCheckBox); Controls.Add(m_showAllLabel); Controls.Add(m_showAllCheckBox); Controls.Add(m_okButton); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyProgrammableBlock>()) { return; } base.CreateTerminalControls(); var console = new MyTerminalControlButton <MyProgrammableBlock>("Edit", MySpaceTexts.TerminalControlPanel_EditCode, MySpaceTexts.TerminalControlPanel_EditCode_Tooltip, (b) => b.SendOpenEditorRequest()); console.Visible = (b) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts; console.Enabled = (b) => MySession.Static.IsScripter; MyTerminalControlFactory.AddControl(console); var arg = new MyTerminalControlTextbox <MyProgrammableBlock>("ConsoleCommand", MySpaceTexts.TerminalControlPanel_RunArgument, MySpaceTexts.TerminalControlPanel_RunArgument_ToolTip); arg.Visible = (e) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts; arg.Getter = (e) => new StringBuilder(e.TerminalRunArgument); arg.Setter = (e, v) => e.TerminalRunArgument = v.ToString(); MyTerminalControlFactory.AddControl(arg); var terminalRun = new MyTerminalControlButton <MyProgrammableBlock>("TerminalRun", MySpaceTexts.TerminalControlPanel_RunCode, MySpaceTexts.TerminalControlPanel_RunCode_Tooltip, (b) => b.Run()); terminalRun.Visible = (b) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts; terminalRun.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true; MyTerminalControlFactory.AddControl(terminalRun); var recompile = new MyTerminalControlButton <MyProgrammableBlock>("Recompile", MySpaceTexts.TerminalControlPanel_Recompile, MySpaceTexts.TerminalControlPanel_Recompile_Tooltip, (b) => b.Recompile()); recompile.Visible = (b) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts; recompile.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true; MyTerminalControlFactory.AddControl(recompile); var runAction = new MyTerminalAction <MyProgrammableBlock>("Run", MyTexts.Get(MySpaceTexts.TerminalControlPanel_RunCode), OnRunApplied, null, MyTerminalActionIcons.START); runAction.Enabled = (b) => b.IsFunctional == true; runAction.DoUserParameterRequest = RequestRunArgument; runAction.ParameterDefinitions.Add(TerminalActionParameter.Get(string.Empty)); MyTerminalControlFactory.AddAction(runAction); var runwithDefault = new MyTerminalAction <MyProgrammableBlock>("RunWithDefaultArgument", MyTexts.Get(MySpaceTexts.TerminalControlPanel_RunCodeDefault), OnRunDefaultApplied, MyTerminalActionIcons.START); runwithDefault.Enabled = (b) => b.IsFunctional == true; MyTerminalControlFactory.AddAction(runwithDefault); }
private MyGuiControlTextbox CreateSeedButton(MyGuiControlList list, string seedValue, float usableWidth) { var label = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); Controls.Remove(label); list.Controls.Add(label); var textBox = new MyGuiControlTextbox(m_currentPosition, seedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); textBox.TextChanged += (MyGuiControlTextbox t) => { seedValue = t.Text; }; textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; list.Controls.Add(textBox); var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, (MyGuiControlButton buttonClicked) => { textBox.Text = MyRandom.Instance.Next().ToString(); }); Controls.Remove(button); list.Controls.Add(button); return(textBox); }
private void F12Handling() { if (MyInput.Static.IsNewKeyPressed(MyKeys.F12)) { if (MyInput.Static.ENABLE_DEVELOPER_KEYS) { ShowDeveloperDebugScreen(); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxF12Question), messageText : MyTexts.Get(MyCommonTexts.MessageBoxTextF12Question), buttonType : MyMessageBoxButtonsType.YES_NO, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { ShowDeveloperDebugScreen(); } })); } } if (MyFakes.ALT_AS_DEBUG_KEY) { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsAnyAltKeyPressed() && !MyInput.Static.IsKeyPress(MyKeys.Tab); } else { MyScreenManager.InputToNonFocusedScreens = MyInput.Static.IsKeyPress(MyKeys.ScrollLock) && !MyInput.Static.IsKeyPress(MyKeys.Tab); } if (MyScreenManager.InputToNonFocusedScreens != m_wasInputToNonFocusedScreens) { if (MyScreenManager.InputToNonFocusedScreens && m_currentDebugScreen != null) { SetMouseCursorVisibility(MyScreenManager.InputToNonFocusedScreens); } m_wasInputToNonFocusedScreens = MyScreenManager.InputToNonFocusedScreens; } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; if (Inventories.Count > 1) { for (int n = 0; n < Inventories.Count; n++) { var inventory = Inventories[n]; buf.Clear(); buf.Append(MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_InventoryButton)); buf.Append(n); buf.Append(": "); builder.Add(buf, nameFormat); builder.Add($"{inventory.CurrentVolume:G6} / {inventory.MaxVolume:G6} L ", valueFormat); buf.Clear(); buf.Append('('); buf.Append(Math.Round(100d * inventory.CurrentVolume / inventory.MaxVolume, 2)); buf.Append("%)\n"); builder.Add(buf, nameFormat); } } else { var inventory = Inventories[0]; buf.Clear(); buf.Append(MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_InventoryButton)); buf.Append(": "); builder.Add(buf, nameFormat); builder.Add($"{inventory.CurrentVolume:G6} / {inventory.MaxVolume:G6} L ", valueFormat); buf.Clear(); buf.Append('('); buf.Append(Math.Round(100d * inventory.CurrentVolume / inventory.MaxVolume, 2)); buf.Append("%)\n"); builder.Add(buf, nameFormat); } }
private void OnResetDefaultsClick(MyGuiControlButton sender) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.YES_NO, messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionResetControlsToDefault), messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextResetControlsToDefault), callback: (res) => { if (res == MyGuiScreenMessageBox.ResultEnum.YES) { // revert to controls when the screen was first opened and then close. MyInput.Static.RevertToDefaultControls(); // I need refresh text on buttons. Create them again is the easiest way. DeactivateControls(m_currentControlType); AddControls(); ActivateControls(m_currentControlType); } })); }
private void OnExitToMainMenuClick(MyGuiControlButton sender) { if (!Sync.IsServer || MySession.Static.Battle) { UnloadAndExitToMenu(); return; } this.CanBeHidden = false; var messageBox = MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.YES_NO_CANCEL, messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextSaveChangesBeforeExit), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionExit), callback: OnExitToMainMenuMessageBoxCallback); messageBox.SkipTransition = true; messageBox.InstantClose = false; MyGuiSandbox.AddScreen(messageBox); }
bool CreateInstance(Assembly assembly, IEnumerable <string> messages, string storage) { var response = string.Join("\n", messages); if (assembly == null) { return(false); } var type = assembly.GetType("Program"); if (type != null) { m_instance = FormatterServices.GetUninitializedObject(type) as ModAPI.IMyGridProgram; var constructor = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null); if (m_instance == null || constructor == null) { response = MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_NoValidConstructor) + "\n\n" + response; SetDetailedInfo(response); return(false); } m_runtime.Reset(); m_instance.Runtime = m_runtime; m_instance.Storage = storage; m_instance.Me = this; m_instance.Echo = EchoTextToDetailInfo; RunSandboxedProgramAction(p => { constructor.Invoke(p, null); if (!m_instance.HasMainMethod) { if (m_echoOutput.Length > 0) { response += "\n\n" + m_echoOutput.ToString(); } response = MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_NoMain) + "\n\n" + response; OnProgramTermination(ScriptTerminationReason.NoEntryPoint); } }, out response); SetDetailedInfo(response); } return(true); }
void OnDeleteClick(MyGuiControlButton sender) { var row = m_sessionsTable.SelectedRow; if (row == null) { return; } var save = FindSave(row); if (save != null) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.YES_NO, messageText: new StringBuilder().AppendFormat(MyCommonTexts.MessageBoxTextAreYouSureYouWantToDeleteSave, save.Item2.SessionName), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), callback: OnDeleteConfirm)); } }
private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale); m_physicalObjectCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { if (!definition.Public) { continue; } var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) { continue; } int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText); } m_physicalObjectCombobox.SortItemsByValueText(); m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex); m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected; } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale); m_amountTextbox = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly); m_amountTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_amountTextbox.TextChanged += OnAmountTextChanged; Controls.Add(m_amountTextbox); m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y; m_errorLabel = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale); m_errorLabel.Visible = false; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject); m_currentPosition.Y += separatorSize; }
public void OnClosedTextBox(ResultEnum result) { if (m_textBox == null) { return; } if (m_textBox.Description.Text.Length > MAX_NUMBER_CHARACTERS) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, callback: OnClosedMessageBox, buttonType: MyMessageBoxButtonsType.YES_NO, messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextTooLongText))); } else { CloseWindow(m_isEditingPublic); } }
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(); }
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); }
protected override void OnClientKick(ref MyControlKickClientMsg data, ulong sender) { if (data.KickedClient == Sync.MyId) { // We don't want to send disconnect message because the clients will disconnect the client automatically upon receiving on the MyControlKickClientMsg m_clientJoined = false; Dispose(); MyGuiScreenMainMenu.ReturnToMainMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionKicked), messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenKicked))); } else { AddKickedClient(data.KickedClient); RaiseClientLeft(data.KickedClient, ChatMemberStateChangeEnum.Kicked); } }
private void OnOkButtonClick(object sender) { // Validate if (m_nameTextbox.Text.Length < MySession.MIN_NAME_LENGTH || m_nameTextbox.Text.Length > MySession.MAX_NAME_LENGTH) { MyStringId errorType; if (m_nameTextbox.Text.Length < MySession.MIN_NAME_LENGTH) { errorType = MyCommonTexts.ErrorNameTooShort; } else { errorType = MyCommonTexts.ErrorNameTooLong; } var messageBox = MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(errorType), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); messageBox.SkipTransition = true; messageBox.InstantClose = false; MyGuiSandbox.AddScreen(messageBox); return; } if (m_descriptionTextbox.Text.Length > MySession.MAX_DESCRIPTION_LENGTH) { var messageBox = MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MyCommonTexts.ErrorDescriptionTooLong), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); messageBox.SkipTransition = true; messageBox.InstantClose = false; MyGuiSandbox.AddScreen(messageBox); return; } if (m_isNewGame) { CheckDx11AndStart(); } else { OnOkButtonClickQuestions(0); } }
protected void DrawGuiIndicators() { if (MyHud.MinimalHud) { return; } if (!MySandboxGame.Config.ShowBuildingSizeHint) { return; } if (MyGuiScreenGamePlay.ActiveGameplayScreen != null) { return; } if (IsCubeSizeModesAvailable) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(MyTexts.GetString(MySpaceTexts.CubeBuilder_CubeSizeModeChange), MyGuiSandbox.GetKeyName(MyControlsSpace.CUBE_BUILDER_CUBESIZE_MODE)); Vector2 coords2D = new Vector2(0.5f, 0.13f); MyGuiManager.DrawString(MyFontEnum.White, sb, coords2D, 1.0f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); coords2D = new Vector2(0.52f, 0.2f); float alphaValue = CubeBuilderState.CubeSizeMode != MyCubeSize.Small ? 0.8f : 1.0f; Color premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue); MyRenderProxy.DrawSprite(MyGuiConstants.CB_SMALL_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null); coords2D = new Vector2(0.48f, 0.2f); alphaValue = CubeBuilderState.CubeSizeMode != MyCubeSize.Large ? 0.8f : 1.0f; premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue); MyRenderProxy.DrawSprite(MyGuiConstants.CB_LARGE_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null); } if (BuildInputValid) { Vector2 screenPos = new Vector2(0.5f, 0.1f); string texture = DynamicMode ? MyGuiConstants.CB_FREE_MODE_ICON : MyGuiConstants.CB_LCS_GRID_ICON; MyRenderProxy.DrawSprite(texture, screenPos, Vector2.One, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null); } }
public MyGuiScreenSaveAs(MyWorldInfo copyFrom, string sessionPath, List <string> existingSessionNames) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.5f, 0.35f)) { EnabledBackgroundFade = true; AddCaption(MyCommonTexts.ScreenCaptionSaveAs); float textboxPositionY = -0.02f; m_nameTextbox = new MyGuiControlTextbox( position: new Vector2(0, textboxPositionY), defaultText: copyFrom.SessionName, maxLength: 75); m_okButton = new MyGuiControlButton( text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton( text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.4f); Vector2 buttonOffset = new Vector2(0.01f, 0f); m_okButton.Position = buttonOrigin - buttonOffset; m_cancelButton.Position = buttonOrigin + buttonOffset; Controls.Add(m_nameTextbox); Controls.Add(m_okButton); Controls.Add(m_cancelButton); m_nameTextbox.MoveCarriageToEnd(); m_copyFrom = copyFrom; m_sessionPath = sessionPath; m_existingSessionNames = existingSessionNames; CloseButtonEnabled = true; CloseButtonOffset = new Vector2(-0.005f, 0.0035f); OnEnterCallback = OnEnterPressed; }
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"); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyCommonTexts.ScreenCaptionOptions); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.146f); int index = 0; Controls.Add(new MyGuiControlButton( position: menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, text: MyTexts.Get(MyCommonTexts.ScreenOptionsButtonGame), onButtonClick: OnGameClick)); Controls.Add(new MyGuiControlButton( position: menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, text: new StringBuilder("Display"), onButtonClick: (sender) => { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsDisplay()); })); Controls.Add(new MyGuiControlButton( position: menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, text: new StringBuilder("Graphics"), onButtonClick: (sender) => { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsGraphics()); })); Controls.Add(new MyGuiControlButton( position: menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, text: MyTexts.Get(MyCommonTexts.ScreenOptionsButtonAudio), onButtonClick: OnAudioClick)); Controls.Add(new MyGuiControlButton( position: menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, text: MyTexts.Get(MyCommonTexts.ScreenOptionsButtonControls), onButtonClick: OnControlsClick)); CloseButtonEnabled = true; }
private void EndTutorialLoading(IMyAsyncResult result, MyGuiScreenProgressAsync screen) { var loadListRes = (MyLoadListResult)result; if (loadListRes.ContainsCorruptedWorlds) { var messageBox = MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.SomeWorldFilesCouldNotBeLoaded), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(messageBox); } m_tutorials = new Dictionary <int, List <Tuple <string, MyWorldInfo> > >(); Dictionary <string, int> trainingLevels = new Dictionary <string, int>(); trainingLevels["Basic"] = (int)TrainingLevel.BASIC; trainingLevels["Intermediate"] = (int)TrainingLevel.INTERMEDIATE; trainingLevels["Advanced"] = (int)TrainingLevel.ADVANCED; loadListRes.AvailableSaves.Sort((x, y) => x.Item2.SessionName.CompareTo(y.Item2.SessionName)); foreach (var loadedRes in loadListRes.AvailableSaves) { var splitted = loadedRes.Item1.Split('\\'); var trainingLevel = splitted[splitted.Length - 2]; if (trainingLevels.ContainsKey(trainingLevel)) { int id = trainingLevels[trainingLevel]; if (!m_tutorials.ContainsKey(id)) { m_tutorials[id] = new List <Tuple <string, MyWorldInfo> >(); } m_tutorials[id].Add(loadedRes); } } SelectTutorials(); m_state = StateEnum.ListLoaded; screen.CloseScreen(); }