public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); if (m_asteroid_showPlanet) { CreatePlanetMenu(); return; } Vector2 cbOffset = new Vector2(-0.05f, 0.0f); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float separatorSize = 0.01f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; m_currentPosition = -m_size.Value / 2.0f; m_currentPosition += controlPadding; m_currentPosition.Y += hiddenPartTop; m_scale = textScale; var caption = AddCaption(MySpaceTexts.ScreenDebugSpawnMenu_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize; if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS || MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale); var combo = AddCombo(); combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids); combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids); // DA: Remove from MySpaceTexts and just hardcode until release. Leave a todo so you don't forget about it before release of planets. combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets); combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2); combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); }; } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; } if (MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS && !m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; } CreateObjectsSpawnMenu(separatorSize, usableWidth); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyMotorStator>()) { return; } base.CreateTerminalControls(); var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM); reverse.EnableAction(MyTerminalActionIcons.REVERSE); MyTerminalControlFactory.AddControl(reverse); var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State() { TopBlockId = null, MasterToSlave = null }); detach.Enabled = (b) => b.m_connectionState.Value.TopBlockId.HasValue && b.m_isWelding == false && b.m_welded == false; detach.Visible = (b) => b.m_canBeDetached; var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE); actionDetach.Enabled = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(detach); var attach = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State() { TopBlockId = 0, MasterToSlave = null }); attach.Enabled = (b) => !b.m_connectionState.Value.TopBlockId.HasValue; attach.Visible = (b) => b.m_canBeDetached; var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE); actionAttach.Enabled = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(attach); var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque); torque.Getter = (x) => x.Torque; torque.Setter = (x, v) => x.Torque.Value = v; torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude; torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result); torque.EnableActions(); torque.Denormalizer = (x, v) => x.DenormalizeTorque(v); torque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(torque); var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque); brakingTorque.Getter = (x) => x.BrakingTorque; brakingTorque.Setter = (x, v) => x.BrakingTorque.Value = v; brakingTorque.DefaultValue = 0; brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result); brakingTorque.EnableActions(); brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v); brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(brakingTorque); var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity); targetVelocity.Getter = (x) => x.TargetVelocityRPM; targetVelocity.Setter = (x, v) => x.TargetVelocityRPM = v; targetVelocity.DefaultValue = 0; targetVelocity.Writer = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm"); targetVelocity.EnableActionsWithReset(); targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v); targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v); MyTerminalControlFactory.AddControl(targetVelocity); var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit); lowerLimit.Getter = (x) => x.MinAngle; lowerLimit.Setter = (x, v) => x.MinAngle = v; lowerLimit.DefaultValue = -361; lowerLimit.SetLimits(-361, 360); lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result); lowerLimit.EnableActions(); MyTerminalControlFactory.AddControl(lowerLimit); var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit); upperLimit.Getter = (x) => x.MaxAngle; upperLimit.Setter = (x, v) => x.MaxAngle = v; upperLimit.DefaultValue = 361; upperLimit.SetLimits(-360, 361); upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result); upperLimit.EnableActions(); MyTerminalControlFactory.AddControl(upperLimit); var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement); rotorDisplacement.Getter = (x) => x.DummyDisplacement; rotorDisplacement.Setter = (x, v) => x.DummyDisplacement = v; rotorDisplacement.DefaultValueGetter = (x) => 0.0f; rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax); rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result); rotorDisplacement.Enabled = (b) => b.m_isAttached; rotorDisplacement.EnableActions(); MyTerminalControlFactory.AddControl(rotorDisplacement); }
static MyMotorStator() { var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM); reverse.EnableAction(MyTerminalActionIcons.REVERSE); MyTerminalControlFactory.AddControl(reverse); var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State() { OtherEntityId = null, MasterToSlave = null }); detach.Enabled = (b) => b.m_rotorBlockId.Value.OtherEntityId.HasValue; detach.Visible = (b) => b.m_canBeDetached; var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE); actionDetach.Enabled = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(detach); var attach = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State() { OtherEntityId = 0, MasterToSlave = null }); attach.Enabled = (b) => !b.m_rotorBlockId.Value.OtherEntityId.HasValue; attach.Visible = (b) => b.m_canBeDetached; var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE); actionAttach.Enabled = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(attach); var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque); torque.Getter = (x) => x.Torque; torque.Setter = (x, v) => x.Torque.Value = v; torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude; torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result); torque.EnableActions(); torque.Denormalizer = (x, v) => x.DenormalizeTorque(v); torque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(torque); var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque); brakingTorque.Getter = (x) => x.BrakingTorque; brakingTorque.Setter = (x, v) => x.BrakingTorque.Value = v; brakingTorque.DefaultValue = 0; brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result); brakingTorque.EnableActions(); brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v); brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(brakingTorque); var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity); targetVelocity.Getter = (x) => x.TargetVelocityRPM; targetVelocity.Setter = (x, v) => x.TargetVelocityRPM = v; targetVelocity.DefaultValue = 0; targetVelocity.Writer = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm"); targetVelocity.EnableActionsWithReset(); targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v); targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v); MyTerminalControlFactory.AddControl(targetVelocity); var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit); lowerLimit.Getter = (x) => x.MinAngle; lowerLimit.Setter = (x, v) => x.MinAngle = v; lowerLimit.DefaultValue = -361; lowerLimit.SetLimits(-361, 360); lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result); lowerLimit.EnableActions(); MyTerminalControlFactory.AddControl(lowerLimit); var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit); upperLimit.Getter = (x) => x.MaxAngle; upperLimit.Setter = (x, v) => x.MaxAngle = v; upperLimit.DefaultValue = 361; upperLimit.SetLimits(-360, 361); upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result); upperLimit.EnableActions(); MyTerminalControlFactory.AddControl(upperLimit); var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement); rotorDisplacement.Getter = (x) => x.DummyDisplacement; rotorDisplacement.Setter = (x, v) => x.DummyDisplacement = v; rotorDisplacement.DefaultValueGetter = (x) => 0.0f; rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax); rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result); rotorDisplacement.Enabled = (b) => b.m_isAttached; rotorDisplacement.EnableActions(); MyTerminalControlFactory.AddControl(rotorDisplacement); var weldSpeed = new MyTerminalControlSlider <MyMotorStator>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank); weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity()); weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f; weldSpeed.Getter = (x) => (float)Math.Sqrt(x.m_weldSpeedSq); weldSpeed.Setter = (x, v) => x.m_weldSpeedSq.Value = v * v; weldSpeed.Writer = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s"); weldSpeed.EnableActions(); MyTerminalControlFactory.AddControl(weldSpeed); var weldForce = new MyTerminalControlCheckbox <MyMotorStator>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank); weldForce.Getter = (x) => x.m_forceWeld; weldForce.Setter = (x, v) => x.m_forceWeld.Value = v; weldForce.EnableAction(); MyTerminalControlFactory.AddControl(weldForce); }
static MyTextPanel() { var publicTitleField = new MyTerminalControlTextbox <MyTextPanel>("PublicTitle", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank); publicTitleField.Getter = (x) => x.PublicTitle; publicTitleField.Setter = (x, v) => x.SyncObject.SendChangeTitleMessage(v, true); publicTitleField.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(publicTitleField); var showPublicButton = new MyTerminalControlButton <MyTextPanel>("ShowPublicTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true)); showPublicButton.Enabled = (x) => !x.IsOpen; showPublicButton.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(showPublicButton); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var titleField = new MyTerminalControlTextbox <MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelTitle, MySpaceTexts.Blank); titleField.Getter = (x) => x.PrivateTitle; titleField.Setter = (x, v) => x.SyncObject.SendChangeTitleMessage(v, false); titleField.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(titleField); var showButton = new MyTerminalControlButton <MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, false)); showButton.Enabled = (x) => !x.IsOpen; showButton.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(showButton); var comboAccess = new MyTerminalControlCombobox <MyTextPanel>("Access", MySpaceTexts.BlockPropertyTitle_TextPanelAccessType, MySpaceTexts.Blank); comboAccess.ComboBoxContent = (x) => FillComboBoxContent(x); comboAccess.Getter = (x) => (long)x.AccessFlag; comboAccess.Setter = (x, y) => x.SyncObject.SendChangeAccessFlagMessage((byte)y); comboAccess.Enabled = (x) => x.OwnerId != 0; MyTerminalControlFactory.AddControl(comboAccess); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var showTextOnScreen = new MyTerminalControlCombobox <MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank); showTextOnScreen.ComboBoxContent = (x) => FillShowOnScreenComboBoxContent(x); showTextOnScreen.Getter = (x) => (long)x.ShowTextFlag; showTextOnScreen.Setter = (x, y) => x.SyncObject.SendShowOnScreenChangeRequest((byte)y); showTextOnScreen.Enabled = (x) => x.OwnerId != 0; MyTerminalControlFactory.AddControl(showTextOnScreen); var changeFontSlider = new MyTerminalControlSlider <MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank); changeFontSlider.SetLimits(0.1f, 10.0f); changeFontSlider.DefaultValue = 1.0f; changeFontSlider.Getter = (x) => x.FontSize; changeFontSlider.Setter = (x, v) => x.SyncObject.SendFontSizeChangeRequest(v); changeFontSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, 1)); changeFontSlider.EnableActions(); MyTerminalControlFactory.AddControl(changeFontSlider); var fontColor = new MyTerminalControlColor <MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor); fontColor.Getter = (x) => x.FontColor; fontColor.Setter = (x, v) => x.SyncObject.SendChangeFontColorRequest(v); MyTerminalControlFactory.AddControl(fontColor); var backgroundColor = new MyTerminalControlColor <MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor); backgroundColor.Getter = (x) => x.BackgroundColor; backgroundColor.Setter = (x, v) => x.SyncObject.SendChangeBackgroundColorRequest(v); MyTerminalControlFactory.AddControl(backgroundColor); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var imagesList = new MyTerminalControlListbox <MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true); imagesList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2); imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y); MyTerminalControlFactory.AddControl(imagesList); var addToSelectionButton = new MyTerminalControlButton <MyTextPanel>("SelectTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectTextures, MySpaceTexts.Blank, (x) => x.AddImagesToSelection()); MyTerminalControlFactory.AddControl(addToSelectionButton); var changeIntervalSlider = new MyTerminalControlSlider <MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank); changeIntervalSlider.SetLimits(0, 30.0f); changeIntervalSlider.DefaultValue = 0; changeIntervalSlider.Getter = (x) => x.ChangeInterval; changeIntervalSlider.Setter = (x, v) => x.SyncObject.SendIntervalChangeRequest(v); changeIntervalSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s"); changeIntervalSlider.EnableActions(); MyTerminalControlFactory.AddControl(changeIntervalSlider); var selectedImagesList = new MyTerminalControlListbox <MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true); selectedImagesList.ListContent = (x, list1, list2) => x.FillSelectedListContent(list1, list2); selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y); MyTerminalControlFactory.AddControl(selectedImagesList); var removeSelectedButton = new MyTerminalControlButton <MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection()); MyTerminalControlFactory.AddControl(removeSelectedButton); }
private void UpdateLabel() { m_label.UpdateFormatParams(MyValueFormatter.GetFormatedFloat(m_value, LabelDecimalPlaces)); RefreshInternals(); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyGravityGenerator>()) { return; } base.CreateTerminalControls(); var fieldWidth = new MyTerminalControlSlider <MyGravityGenerator>("Width", MySpaceTexts.BlockPropertyTitle_GravityFieldWidth, MySpaceTexts.BlockPropertyDescription_GravityFieldWidth); fieldWidth.SetLimits((x) => x.BlockDefinition.MinFieldSize.X, (x) => x.BlockDefinition.MaxFieldSize.X); fieldWidth.DefaultValue = 150; fieldWidth.Getter = (x) => x.m_fieldSize.Value.X; fieldWidth.Setter = (x, v) => { Vector3 fieldSize = x.m_fieldSize; fieldSize.X = v; x.m_fieldSize.Value = fieldSize; }; fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.X, NUM_DECIMALS)).Append(" m"); fieldWidth.EnableActions(); MyTerminalControlFactory.AddControl(fieldWidth); var fieldHeight = new MyTerminalControlSlider <MyGravityGenerator>("Height", MySpaceTexts.BlockPropertyTitle_GravityFieldHeight, MySpaceTexts.BlockPropertyDescription_GravityFieldHeight); fieldHeight.SetLimits((x) => x.BlockDefinition.MinFieldSize.Y, (x) => x.BlockDefinition.MaxFieldSize.Y); fieldHeight.DefaultValue = 150; fieldHeight.Getter = (x) => x.m_fieldSize.Value.Y; fieldHeight.Setter = (x, v) => { Vector3 fieldSize = x.m_fieldSize; fieldSize.Y = v; x.m_fieldSize.Value = fieldSize; }; fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Y, NUM_DECIMALS)).Append(" m"); fieldHeight.EnableActions(); MyTerminalControlFactory.AddControl(fieldHeight); var fieldDepth = new MyTerminalControlSlider <MyGravityGenerator>("Depth", MySpaceTexts.BlockPropertyTitle_GravityFieldDepth, MySpaceTexts.BlockPropertyDescription_GravityFieldDepth); fieldDepth.SetLimits((x) => x.BlockDefinition.MinFieldSize.Z, (x) => x.BlockDefinition.MaxFieldSize.Z); fieldDepth.DefaultValue = 150; fieldDepth.Getter = (x) => x.m_fieldSize.Value.Z; fieldDepth.Setter = (x, v) => { Vector3 fieldSize = x.m_fieldSize; fieldSize.Z = v; x.m_fieldSize.Value = fieldSize; }; fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Z, NUM_DECIMALS)).Append(" m"); fieldDepth.EnableActions(); MyTerminalControlFactory.AddControl(fieldDepth); var gravityAcceleration = new MyTerminalControlSlider <MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration); gravityAcceleration.SetLimits((x) => x.BlockDefinition.MinGravityAcceleration, (x) => x.BlockDefinition.MaxGravityAcceleration); gravityAcceleration.DefaultValue = MyGravityProviderSystem.G; gravityAcceleration.Getter = (x) => x.GravityAcceleration; gravityAcceleration.Setter = (x, v) => x.GravityAcceleration = v; gravityAcceleration.Writer = (x, result) => result.AppendDecimal(x.GravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G"); gravityAcceleration.EnableActions(); MyTerminalControlFactory.AddControl(gravityAcceleration); }
static MyMotorStator() { var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.ReverseValuesRequest()); reverse.EnableAction(MyTerminalActionIcons.REVERSE); MyTerminalControlFactory.AddControl(reverse); var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.OnDetachRotorBtnClick()); var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE); actionDetach.Enabled = (b) => b.m_canBeDetached; detach.Enabled = (b) => b.m_isAttached; detach.Visible = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(detach); var attach = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.SyncObject.AttachRotor()); var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE); actionAttach.Enabled = (b) => b.m_canBeDetached; attach.Enabled = (b) => !b.m_isAttached; attach.Visible = (b) => b.m_canBeDetached; MyTerminalControlFactory.AddControl(attach); var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque); torque.Getter = (x) => x.Torque; torque.Setter = (x, v) => x.TorqueChangeRequest(v); torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude; torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result); torque.EnableActions(); torque.Denormalizer = (x, v) => x.DenormalizeTorque(v); torque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(torque); var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque); brakingTorque.Getter = (x) => x.BrakingTorque; brakingTorque.Setter = (x, v) => x.BrakingTorqueChangeRequest(v); brakingTorque.DefaultValue = 0; brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result); brakingTorque.EnableActions(); brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v); brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v); MyTerminalControlFactory.AddControl(brakingTorque); var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity); targetVelocity.Getter = (x) => x.GetTargetVelocityRPM(); targetVelocity.Setter = (x, v) => x.SetTargetVelocity(v); targetVelocity.DefaultValue = 0; targetVelocity.Writer = (x, result) => result.Concat(x.GetTargetVelocityRPM(), 2).Append(" rpm"); targetVelocity.EnableActionsWithReset(); targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v); targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v); MyTerminalControlFactory.AddControl(targetVelocity); var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit); lowerLimit.Getter = (x) => x.MinAngle; lowerLimit.Setter = (x, v) => x.MinAngleChangeRequest(v); lowerLimit.DefaultValue = -361; lowerLimit.SetLimits(-361, 360); lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result); lowerLimit.EnableActions(); MyTerminalControlFactory.AddControl(lowerLimit); var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit); upperLimit.Getter = (x) => x.MaxAngle; upperLimit.Setter = (x, v) => x.MaxAngleChangeRequest(v); upperLimit.DefaultValue = 361; upperLimit.SetLimits(-360, 361); upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result); upperLimit.EnableActions(); MyTerminalControlFactory.AddControl(upperLimit); var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement); rotorDisplacement.Getter = (x) => x.DummyDisplacement; rotorDisplacement.Setter = (x, v) => x.SyncObject.ChangeRotorDisplacement(v); rotorDisplacement.DefaultValueGetter = (x) => 0.0f; rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax); rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result); rotorDisplacement.Enabled = (b) => b.m_isAttached; rotorDisplacement.EnableActions(); MyTerminalControlFactory.AddControl(rotorDisplacement); }
public override void Draw() { base.Draw(); if (MySession.Static == null) { return; } Text("Game time: {0}", MySession.Static.ElapsedGameTime); Vector3 camPos = MySector.MainCamera.Position; float instantSpeed = 0; float averageSpeed = 0; if (m_lastCameraPosition.IsValid()) { instantSpeed = (camPos - m_lastCameraPosition).Length() * VRage.Game.MyEngineConstants.UPDATE_STEPS_PER_SECOND; if (m_speeds.Count == 60) { m_speeds.Dequeue(); } m_speeds.Enqueue(instantSpeed); foreach (var s in m_speeds) { averageSpeed += s; } averageSpeed /= m_speeds.Count; } m_lastCameraPosition = camPos; Section("Controlled Entity/Camera"); Text("Speed: {0:F2}ms -- {1:F2}m/s", instantSpeed, averageSpeed); if (MySession.Static.LocalHumanPlayer == null || MySession.Static.LocalHumanPlayer.Controller.ControlledEntity == null) { return; } var controlled = MySession.Static.LocalHumanPlayer.Controller.ControlledEntity; var centity = (MyEntity)controlled; if (centity is MyCubeBlock) { centity = ((MyCubeBlock)centity).CubeGrid; } StringBuilder sb = new StringBuilder(); if (centity.Physics != null) { sb.Clear(); sb.Append("Mass: "); MyValueFormatter.AppendWeightInBestUnit(centity.Physics.Mass, sb); Text(sb.ToString()); } MyEntityThrustComponent component; if (centity.Components.TryGet(out component)) { sb.Clear(); sb.Append("Current Thrust: "); MyValueFormatter.AppendForceInBestUnit(component.FinalThrust.Length(), sb); sb.AppendFormat(" : {0}", component.FinalThrust); Text(sb.ToString()); } }
private void CreateProceduralAsteroidsSpawnMenu(float separatorSize, float usableWidth) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyTimerBlock>()) { return; } base.CreateTerminalControls(); var silent = new MyTerminalControlCheckbox <MyTimerBlock>("Silent", MySpaceTexts.BlockPropertyTitle_Silent, MySpaceTexts.ToolTipTimerBlock_Silent); silent.Getter = (x) => x.Silent; silent.Setter = (x, v) => x.Silent = v; silent.EnableAction(); MyTerminalControlFactory.AddControl(silent); var slider = new MyTerminalControlSlider <MyTimerBlock>("TriggerDelay", MySpaceTexts.TerminalControlPanel_TimerDelay, MySpaceTexts.TerminalControlPanel_TimerDelay); slider.SetLogLimits(1, 60 * 60); slider.DefaultValue = 10; slider.Enabled = (x) => !x.IsCountingDown; slider.Getter = (x) => x.TriggerDelay; slider.Setter = (x, v) => x.m_timerSync.Value = ((int)(Math.Round(v, 1) * 1000)); slider.Writer = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMsStart, 1000) / 1000, sb); slider.EnableActions(); MyTerminalControlFactory.AddControl(slider); var toolbarButton = new MyTerminalControlButton <MyTimerBlock>("OpenToolbar", MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen, MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen, delegate(MyTimerBlock self) { m_openedToolbars.Add(self.Toolbar); if (MyGuiScreenCubeBuilder.Static == null) { m_shouldSetOtherToolbars = true; MyToolbarComponent.CurrentToolbar = self.Toolbar; MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self); MyToolbarComponent.AutoUpdate = false; screen.Closed += (source) => { MyToolbarComponent.AutoUpdate = true; m_openedToolbars.Clear(); }; MyGuiSandbox.AddScreen(screen); } }); MyTerminalControlFactory.AddControl(toolbarButton); var triggerButton = new MyTerminalControlButton <MyTimerBlock>("TriggerNow", MySpaceTexts.BlockPropertyTitle_TimerTrigger, MySpaceTexts.BlockPropertyTitle_TimerTrigger, (x) => x.OnTrigger()); triggerButton.EnableAction(); MyTerminalControlFactory.AddControl(triggerButton); var startButton = new MyTerminalControlButton <MyTimerBlock>("Start", MySpaceTexts.BlockPropertyTitle_TimerStart, MySpaceTexts.BlockPropertyTitle_TimerStart, (x) => x.StartBtn()); startButton.EnableAction(); MyTerminalControlFactory.AddControl(startButton); var stopButton = new MyTerminalControlButton <MyTimerBlock>("Stop", MySpaceTexts.BlockPropertyTitle_TimerStop, MySpaceTexts.BlockPropertyTitle_TimerStop, (x) => x.StopBtn()); stopButton.EnableAction(); MyTerminalControlFactory.AddControl(stopButton); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyTextPanel>()) { return; } base.CreateTerminalControls(); var publicTitleField = new MyTerminalControlTextbox <MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank); publicTitleField.Getter = (x) => x.PublicTitle; publicTitleField.Setter = (x, v) => x.SendChangeTitleMessage(v, true); publicTitleField.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(publicTitleField); var showPublicButton = new MyTerminalControlButton <MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true)); showPublicButton.Enabled = (x) => !x.IsOpen; showPublicButton.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(showPublicButton); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var showTextOnScreen = new MyTerminalControlOnOffSwitch <MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank); showTextOnScreen.Getter = (x) => x.ShowTextFlag != ShowTextOnScreenFlag.NONE; showTextOnScreen.Setter = (x, y) => x.ShowTextFlag = y ? ShowTextOnScreenFlag.PUBLIC : ShowTextOnScreenFlag.NONE; MyTerminalControlFactory.AddControl(showTextOnScreen); var comboFont = new MyTerminalControlCombobox <MyTextPanel>("Font", MySpaceTexts.BlockPropertyTitle_Font, MySpaceTexts.Blank); comboFont.ComboBoxContent = (x) => FillFontComboBoxContent(x); comboFont.Getter = (x) => (long)x.Font.SubtypeId; comboFont.Setter = (x, y) => x.Font = new MyDefinitionId(typeof(MyObjectBuilder_FontDefinition), MyStringHash.TryGet((int)y)); MyTerminalControlFactory.AddControl(comboFont); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var changeFontSlider = new MyTerminalControlSlider <MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank); changeFontSlider.SetLimits(0.1f, 10.0f); changeFontSlider.DefaultValue = 1.0f; changeFontSlider.Getter = (x) => x.FontSize; changeFontSlider.Setter = (x, v) => x.FontSize = v; changeFontSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, NUM_DECIMALS)); changeFontSlider.EnableActions(); MyTerminalControlFactory.AddControl(changeFontSlider); var fontColor = new MyTerminalControlColor <MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor); fontColor.Getter = (x) => x.FontColor; fontColor.Setter = (x, v) => x.FontColor = v; MyTerminalControlFactory.AddControl(fontColor); var backgroundColor = new MyTerminalControlColor <MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor); backgroundColor.Getter = (x) => x.BackgroundColor; backgroundColor.Setter = (x, v) => x.BackgroundColor = v; MyTerminalControlFactory.AddControl(backgroundColor); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>()); var imagesList = new MyTerminalControlListbox <MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true); imagesList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2); imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y); MyTerminalControlFactory.AddControl(imagesList); var addToSelectionButton = new MyTerminalControlButton <MyTextPanel>("SelectTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectTextures, MySpaceTexts.Blank, (x) => x.AddImagesToSelection()); MyTerminalControlFactory.AddControl(addToSelectionButton); var changeIntervalSlider = new MyTerminalControlSlider <MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank); changeIntervalSlider.SetLimits(0, 30.0f); changeIntervalSlider.DefaultValue = 0; changeIntervalSlider.Getter = (x) => x.ChangeInterval; changeIntervalSlider.Setter = (x, v) => x.ChangeInterval = v; changeIntervalSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s"); changeIntervalSlider.EnableActions(); MyTerminalControlFactory.AddControl(changeIntervalSlider); var selectedImagesList = new MyTerminalControlListbox <MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true); selectedImagesList.ListContent = (x, list1, list2) => x.FillSelectedListContent(list1, list2); selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y); MyTerminalControlFactory.AddControl(selectedImagesList); var removeSelectedButton = new MyTerminalControlButton <MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection()); MyTerminalControlFactory.AddControl(removeSelectedButton); }
// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput) { if (!Visible) { return(false); } bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput); if (ret == false) { if ((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true)) { m_carriagePositionIndex = GetCarriagePositionFromMouseCursor(); ret = true; } if ((m_hasKeyboardActiveControl == true) && (hasKeyboardActiveControlPrevious == false)) { UpdateLastKeyPressTimes(null); } if (hasKeyboardActiveControl == true) { bool isShiftPressed = input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift); bool isCapsLockOn = (ushort)MyGuiInput.GetKeyState(0x14) == 1; //(deltaFromLastKeypress > MyGuiConstants.TEXTBOX_KEYPRESS_DELAY) //int deltaFromLastKeypress = MyMinerGame.TotalGameTime_Miliseconds - m_lastKeyPressTime; input.GetPressedKeys(m_pressedKeys); for (int i = 0; i < m_pressedKeys.Count; i++) { System.Diagnostics.Debug.Assert(input.IsKeyPress((Keys)m_pressedKeys[i])); } // Transform pressed letters, characters, numbers, etc to real character/string for (int i = 0; i < m_pressedKeys.Count; i++) { bool tempShift = isShiftPressed; bool transformText = true; MyGuiControlTextboxKeyToString pressedKey = m_keyToString[(int)m_pressedKeys[i]]; //Allow to enter only digits in case such textbox type is set if (m_type == MyGuiControlTextboxType.DIGITS_ONLY) { if ((pressedKey != null) && !input.IsKeyDigit(pressedKey.Key) && pressedKey.Key != Keys.OemPeriod && pressedKey.Key != Keys.Decimal) { transformText = false; } } if (transformText) { // If we have mapping from this key to string (that means it's allowed character) if (pressedKey != null && m_text.Length < m_maxLength && pressedKey.Character != null && pressedKey.CharacterWhenShift != null) { ret = true; if (IsEnoughDelay((Keys)m_pressedKeys[i], MyGuiConstants.TEXTBOX_CHANGE_DELAY)) { if (Char.IsLetter(pressedKey.Character, 0)) { if (isCapsLockOn) { tempShift = !tempShift;//carefull here variable is not used anymore so we can invert it } } m_text = m_text.Insert(m_carriagePositionIndex, (tempShift == true) ? pressedKey.CharacterWhenShift : pressedKey.Character); m_carriagePositionIndex++; UpdateLastKeyPressTimes((Keys)m_pressedKeys[i]); OnTextChanged(); } } } } // Move left if ((input.IsKeyPress(Keys.Left)) && (IsEnoughDelay(Keys.Left, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { m_carriagePositionIndex--; if (m_carriagePositionIndex < 0) { m_carriagePositionIndex = 0; } UpdateLastKeyPressTimes(Keys.Left); } // Move right if ((input.IsKeyPress(Keys.Right)) && (IsEnoughDelay(Keys.Right, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { m_carriagePositionIndex++; if (m_carriagePositionIndex > m_text.Length) { m_carriagePositionIndex = m_text.Length; } UpdateLastKeyPressTimes(Keys.Right); } // Move home if ((input.IsNewKeyPress(Keys.Home)) && (IsEnoughDelay(Keys.Home, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { m_carriagePositionIndex = 0; UpdateLastKeyPressTimes(Keys.Home); } // Move end if ((input.IsNewKeyPress(Keys.End)) && (IsEnoughDelay(Keys.End, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { m_carriagePositionIndex = m_text.Length; UpdateLastKeyPressTimes(Keys.End); } // Delete if ((input.IsKeyPress(Keys.Delete)) && (IsEnoughDelay(Keys.Delete, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { if (m_carriagePositionIndex < m_text.Length) { m_text = m_text.Remove(m_carriagePositionIndex, 1); UpdateLastKeyPressTimes(Keys.Delete); OnTextChanged(); } } // Backspace if ((input.IsKeyPress(Keys.Back)) && (IsEnoughDelay(Keys.Back, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { if (m_carriagePositionIndex > 0) { // Handle text scrolling, basicaly try hold carriage on same position in textBox window (avoid textBox with hidden characters) var carriagePositionChange = GetCarriagePosition(m_carriagePositionIndex) - GetCarriagePosition(m_carriagePositionIndex - 1);; var textAreaPosition = GetTextAreaPosition(); if (m_slidingWindowPosition.X - carriagePositionChange.X >= textAreaPosition.X) { m_slidingWindowPosition.X -= carriagePositionChange.X; } else { m_slidingWindowPosition.X = textAreaPosition.X; } m_text = m_text.Remove(m_carriagePositionIndex - 1, 1); m_carriagePositionIndex--; UpdateLastKeyPressTimes(Keys.Back); OnTextChanged(); } } ResetLastKeyPressTimes(input); m_formattedAlready = false; } else { if (m_type == MyGuiControlTextboxType.DIGITS_ONLY && m_formattedAlready == false && !string.IsNullOrEmpty(m_text)) { var number = MyValueFormatter.GetDecimalFromString(m_text, 1); int decimalDigits = (number - (int)number > 0) ? 1 : 0; m_text = MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, ""); m_carriagePositionIndex = m_text.Length; m_formattedAlready = true; } } } return(ret); }
public void UpdateBlockInfo(Sandbox.ModAPI.IMyTerminalBlock block, StringBuilder info) { try { if (block == null) { return; } if (info == null) { return; } info.Clear(); info.AppendLine(" "); IMyGridTerminalSystem tsystem = null; if (block.CubeGrid != null) { tsystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(block.CubeGrid); } if (tsystem != null) { List <IMyTerminalBlock> shieldsConnected = new List <IMyTerminalBlock>(); tsystem.GetBlocksOfType <IMyRefinery>(shieldsConnected, EnergyShieldsCore.shieldFilter); float shipCurrentShieldPoints = 0f; float shipMaximumShieldPoints = 0f; foreach (var shield in shieldsConnected) { if (shield == null) { continue; } ShieldGeneratorGameLogic generatorLogic = null; if (EnergyShieldsCore.shieldGenerators.TryGetValue(shield.EntityId, out generatorLogic)) { shipCurrentShieldPoints += generatorLogic.m_currentShieldPoints; shipMaximumShieldPoints += generatorLogic.m_maximumShieldPoints; } } info.Append("总护盾: "); MyValueFormatter.AppendGenericInBestUnit(shipCurrentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(shipMaximumShieldPoints, info); info.Append("Pt\n"); } info.Append("此护盾: "); MyValueFormatter.AppendGenericInBestUnit(m_currentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(m_maximumShieldPoints, info); info.Append("Pt\n"); info.Append("充能: "); MyValueFormatter.AppendGenericInBestUnit(m_pointsToRecharge * 60, info); info.Append("Pt/s "); if (EnergyShieldsCore.Config.AlternativeRechargeMode.Enable && (m_ticksUntilRecharge > 0)) { info.Append("(" + (int)Math.Ceiling(m_ticksUntilRecharge / 60d) + "s)\n"); } else { info.Append("\n"); } info.Append("有效性: "); MyValueFormatter.AppendWorkInBestUnit(m_currentPowerConsumption, info); info.Append("/"); MyValueFormatter.AppendWorkInBestUnit(m_setPowerConsumption, info); info.Append(" (" + (m_rechargeMultiplier * 100).ToString("N") + "%)"); } catch (Exception e) { } }
public static void LogEnvironmentInformation() { MySandboxGame.Log.WriteLine("MyVideoModeManager.LogEnvironmentInformation - START"); MySandboxGame.Log.IncreaseIndent(); try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select Manufacturer, Model from Win32_ComputerSystem"); if (searcher != null) { foreach (ManagementBaseObject obj2 in searcher.Get()) { MySandboxGame.Log.WriteLine("Win32_ComputerSystem.Manufacturer: " + obj2["Manufacturer"]); MySandboxGame.Log.WriteLine("Win32_ComputerSystem.Model: " + obj2["Model"]); MySandboxGame.Log.WriteLine("Virtualized: " + IsVirtualized(obj2["Manufacturer"].ToString(), obj2["Model"].ToString()).ToString()); } } ManagementObjectSearcher searcher2 = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_Processor"); if (searcher2 != null) { foreach (ManagementObject obj3 in searcher2.Get()) { MySandboxGame.Log.WriteLine("Environment.ProcessorName: " + obj3["Name"]); } } WinApi.MEMORYSTATUSEX lpBuffer = new WinApi.MEMORYSTATUSEX(); WinApi.GlobalMemoryStatusEx(lpBuffer); MySandboxGame.Log.WriteLine("ComputerInfo.TotalPhysicalMemory: " + MyValueFormatter.GetFormatedLong((long)lpBuffer.ullTotalPhys) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.TotalVirtualMemory: " + MyValueFormatter.GetFormatedLong((long)lpBuffer.ullTotalVirtual) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailablePhysicalMemory: " + MyValueFormatter.GetFormatedLong((long)lpBuffer.ullAvailPhys) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailableVirtualMemory: " + MyValueFormatter.GetFormatedLong((long)lpBuffer.ullAvailVirtual) + " bytes"); ConnectionOptions options = new ConnectionOptions(); using (ManagementObjectSearcher searcher3 = new ManagementObjectSearcher(new ManagementScope(@"\\localhost", options), new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3"))) { ManagementObjectCollection objects = searcher3.Get(); foreach (ManagementObject obj1 in objects) { string formatedLong = MyValueFormatter.GetFormatedLong(Convert.ToInt64(obj1["Size"])); string str2 = MyValueFormatter.GetFormatedLong(Convert.ToInt64(obj1["FreeSpace"])); string str3 = obj1["Name"].ToString(); string[] textArray1 = new string[] { "Drive ", str3, " | Capacity: ", formatedLong, " bytes | Free space: ", str2, " bytes" }; MySandboxGame.Log.WriteLine(string.Concat(textArray1)); } objects.Dispose(); } } catch (Exception exception) { MySandboxGame.Log.WriteLine("Error occured during enumerating environment information. Application is continuing. Exception: " + exception.ToString()); } MySandboxGame.Log.DecreaseIndent(); MySandboxGame.Log.WriteLine("MyVideoModeManager.LogEnvironmentInformation - END"); }
private void CreatePlanetControls(MyGuiControlList list, float usableWidth) { var asteroidSizeLabel = CreateSliderWithDescription(list, usableWidth, 8000f, 120000f, MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), ref m_procAsteroidSize); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { asteroidSizeLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = 8000.1f; m_procAsteroidSeed = CreateSeedButton(list, m_procAsteroidSeedValue, usableWidth); }
// Outputs all voxel maps in the scene to a file of the OBJ file format // All voxel maps will be output as a single mesh public static void SaveTriangles() { if (m_voxelMaps.Count <= 0) { return; } String fileName = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "VoxelMaps_" + MyValueFormatter.GetFormatedDateTimeForFilename(DateTime.Now) + ".obj"); using (FileStream fs = File.Create(fileName)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach (MyVoxelMap voxelMap in m_voxelMaps) { voxelMap.SaveVoxelVertices(sw); } foreach (MyVoxelMap voxelMap in m_voxelMaps) { voxelMap.SaveVoxelNormals(sw); } int vertexOffset = 0; foreach (MyVoxelMap voxelMap in m_voxelMaps) { voxelMap.SaveVoxelFaces(sw, ref vertexOffset); } } } }
static MyLightingBlock() { var lightColor = new MyTerminalControlColor <MyLightingBlock>("Color", MySpaceTexts.BlockPropertyTitle_LightColor); lightColor.Getter = (x) => x.Color; lightColor.Setter = (x, v) => x.SyncObject.SendChangeLightColorRequest(v); MyTerminalControlFactory.AddControl(lightColor); var lightRadius = new MyTerminalControlSlider <MyLightingBlock>("Radius", MySpaceTexts.BlockPropertyTitle_LightRadius, MySpaceTexts.BlockPropertyDescription_LightRadius); lightRadius.SetLimits((x) => x.RadiusBounds.Min, (x) => x.RadiusBounds.Max); lightRadius.DefaultValueGetter = (x) => x.RadiusBounds.Default; lightRadius.Getter = (x) => x.Radius; lightRadius.Setter = (x, v) => x.SyncObject.SendChangeLightRadiusRequest(v); lightRadius.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Range, 1)).Append(" m"); lightRadius.EnableActions(); MyTerminalControlFactory.AddControl(lightRadius); var lightFalloff = new MyTerminalControlSlider <MyLightingBlock>("Falloff", MySpaceTexts.BlockPropertyTitle_LightFalloff, MySpaceTexts.BlockPropertyDescription_LightFalloff); lightFalloff.SetLimits((x) => x.FalloffBounds.Min, (x) => x.FalloffBounds.Max); lightFalloff.DefaultValueGetter = (x) => x.FalloffBounds.Default; lightFalloff.Getter = (x) => x.Falloff; lightFalloff.Setter = (x, v) => x.SyncObject.SendChangeLightFalloffRequest(v); lightFalloff.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Falloff, 1)); lightRadius.EnableActions(); MyTerminalControlFactory.AddControl(lightFalloff); var lightIntensity = new MyTerminalControlSlider <MyLightingBlock>("Intensity", MySpaceTexts.BlockPropertyTitle_LightIntensity, MySpaceTexts.BlockPropertyDescription_LightIntensity); lightIntensity.SetLimits((x) => x.IntensityBounds.Min, (x) => x.IntensityBounds.Max); lightIntensity.DefaultValueGetter = (x) => x.IntensityBounds.Default; lightIntensity.Getter = (x) => x.Intensity; lightIntensity.Setter = (x, v) => x.SyncObject.SendChangeLightIntensityRequest(v); lightIntensity.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.Intensity, 1)); lightRadius.EnableActions(); MyTerminalControlFactory.AddControl(lightIntensity); var lightBlinkTime = new MyTerminalControlSlider <MyLightingBlock>("Blink Interval", MySpaceTexts.BlockPropertyTitle_LightBlinkInterval, MySpaceTexts.BlockPropertyDescription_LightBlinkInterval); lightBlinkTime.SetLimits((x) => x.BlinkIntervalSecondsBounds.Min, (x) => x.BlinkIntervalSecondsBounds.Max); lightBlinkTime.DefaultValueGetter = (x) => x.BlinkIntervalSecondsBounds.Default; lightBlinkTime.Getter = (x) => x.BlinkIntervalSeconds; lightBlinkTime.Setter = (x, v) => x.SyncObject.SendChangeLightBlinkIntervalRequest(v); lightBlinkTime.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkIntervalSeconds, NUM_DECIMALS)).Append(" s"); lightBlinkTime.EnableActions(); MyTerminalControlFactory.AddControl(lightBlinkTime); var lightBlinkLenght = new MyTerminalControlSlider <MyLightingBlock>("Blink Lenght", MySpaceTexts.BlockPropertyTitle_LightBlinkLenght, MySpaceTexts.BlockPropertyDescription_LightBlinkLenght); lightBlinkLenght.SetLimits((x) => x.BlinkLenghtBounds.Min, (x) => x.BlinkLenghtBounds.Max); lightBlinkLenght.DefaultValueGetter = (x) => x.BlinkLenghtBounds.Default; lightBlinkLenght.Getter = (x) => x.BlinkLength; lightBlinkLenght.Setter = (x, v) => x.SyncObject.SendChangeLightBlinkLengthRequest(v); lightBlinkLenght.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkLength, NUM_DECIMALS)).Append(" %"); lightBlinkLenght.EnableActions(); MyTerminalControlFactory.AddControl(lightBlinkLenght); var ligthBlinkOffset = new MyTerminalControlSlider <MyLightingBlock>("Blink Offset", MySpaceTexts.BlockPropertyTitle_LightBlinkOffset, MySpaceTexts.BlockPropertyDescription_LightBlinkOffset); ligthBlinkOffset.SetLimits((x) => x.BlinkOffsetBounds.Min, (x) => x.BlinkOffsetBounds.Max); ligthBlinkOffset.DefaultValueGetter = (x) => x.BlinkOffsetBounds.Default; ligthBlinkOffset.Getter = (x) => x.BlinkOffset; ligthBlinkOffset.Setter = (x, v) => x.SyncObject.SendChangeLightBlinkOffsetRequest(v); ligthBlinkOffset.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkOffset, NUM_DECIMALS)).Append(" %"); ligthBlinkOffset.EnableActions(); MyTerminalControlFactory.AddControl(ligthBlinkOffset); }
static MyMotorSuspension() { var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering); steering.Getter = (x) => x.Steering; steering.Setter = (x, v) => x.Steering = v; steering.EnableAction(); steering.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(steering); var maxSteerAngle = new MyTerminalControlSlider <MyMotorSuspension>("MaxSteerAngle", MySpaceTexts.BlockPropertyTitle_Motor_MaxSteerAngle, MySpaceTexts.BlockPropertyDescription_Motor_MaxSteerAngle); maxSteerAngle.SetLimits((x) => 0, (x) => x.BlockDefinition.MaxSteer); maxSteerAngle.DefaultValue = 0.45f; maxSteerAngle.Getter = (x) => x.GetMaxSteerAngleForTerminal(); maxSteerAngle.Setter = (x, v) => x.MaxSteerAngle = v; maxSteerAngle.Writer = (x, res) => MyMotorStator.WriteAngle(x.GetMaxSteerAngleForTerminal(), res); maxSteerAngle.EnableActionsWithReset(); maxSteerAngle.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(maxSteerAngle); var steerSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerSpeed); steerSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100); steerSpeed.DefaultValue = 2f; steerSpeed.Getter = (x) => x.GetSteerSpeedForTerminal(); steerSpeed.Setter = (x, v) => x.SteerSpeed = v / 100; steerSpeed.Writer = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerSpeedForTerminal(), res); steerSpeed.EnableActionsWithReset(); steerSpeed.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(steerSpeed); var steerReturnSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerReturnSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerReturnSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerReturnSpeed); steerReturnSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100); steerReturnSpeed.DefaultValue = 1f; steerReturnSpeed.Getter = (x) => x.GetSteerReturnSpeedForTerminal(); steerReturnSpeed.Setter = (x, v) => x.SteerReturnSpeed = v / 100; steerReturnSpeed.Writer = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerReturnSpeedForTerminal(), res); steerReturnSpeed.EnableActionsWithReset(); steerReturnSpeed.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(steerReturnSpeed); var invertSteer = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertSteering", MySpaceTexts.BlockPropertyTitle_Motor_InvertSteer, MySpaceTexts.BlockPropertyDescription_Motor_InvertSteer); invertSteer.Getter = (x) => x.InvertSteer; invertSteer.Setter = (x, v) => x.InvertSteer = v; invertSteer.EnableAction(); invertSteer.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(invertSteer); var propulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("Propulsion", MySpaceTexts.BlockPropertyTitle_Motor_Propulsion, MySpaceTexts.BlockPropertyDescription_Motor_Propulsion); propulsion.Getter = (x) => x.Propulsion; propulsion.Setter = (x, v) => x.Propulsion = v; propulsion.EnableAction(); propulsion.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(propulsion); var invertPropulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertPropulsion", MySpaceTexts.BlockPropertyTitle_Motor_InvertPropulsion, MySpaceTexts.BlockPropertyDescription_Motor_InvertPropulsion); invertPropulsion.Getter = (x) => x.InvertPropulsion; invertPropulsion.Setter = (x, v) => x.InvertPropulsion = v; invertPropulsion.EnableAction(); invertPropulsion.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(invertPropulsion); var power = new MyTerminalControlSlider <MyMotorSuspension>("Power", MySpaceTexts.BlockPropertyTitle_Motor_Power, MySpaceTexts.BlockPropertyDescription_Motor_Power); power.SetLimits(0, 100); power.DefaultValue = 100; power.Getter = (x) => x.GetPowerForTerminal(); power.Setter = (x, v) => x.Power = v / 100; power.Writer = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%"); power.EnableActions(); power.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(power); var friction = new MyTerminalControlSlider <MyMotorSuspension>("Friction", MySpaceTexts.BlockPropertyTitle_Motor_Friction, MySpaceTexts.BlockPropertyDescription_Motor_Friction); friction.SetLimits(0, 100); friction.DefaultValue = 150f / 800; friction.Getter = (x) => x.GetFrictionForTerminal(); friction.Setter = (x, v) => x.Friction = v / 100; friction.Writer = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%"); friction.EnableActions(); friction.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(friction); var damping = new MyTerminalControlSlider <MyMotorSuspension>("Damping", MySpaceTexts.BlockPropertyTitle_Motor_Damping, MySpaceTexts.BlockPropertyTitle_Motor_Damping); damping.SetLimits(0, 100); damping.Getter = (x) => x.GetDampingForTerminal(); damping.Setter = (x, v) => x.Damping = v / 100; damping.Writer = (x, res) => res.AppendInt32((int)(x.GetDampingForTerminal())).Append("%"); damping.EnableActions(); damping.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(damping); var strength = new MyTerminalControlSlider <MyMotorSuspension>("Strength", MySpaceTexts.BlockPropertyTitle_Motor_Strength, MySpaceTexts.BlockPropertyTitle_Motor_Strength); strength.SetLimits(0, 100); strength.Getter = (x) => x.GetStrengthForTerminal(); strength.Setter = (x, v) => x.Strength = v / 100; strength.Writer = (x, res) => res.AppendInt32((int)(x.GetStrengthForTerminal())).Append("%"); strength.EnableActions(); strength.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(strength); var height = new MyTerminalControlSlider <MyMotorSuspension>("Height", MySpaceTexts.BlockPropertyTitle_Motor_Height, MySpaceTexts.BlockPropertyDescription_Motor_Height); height.SetLimits((x) => x.BlockDefinition.MinHeight, (x) => x.BlockDefinition.MaxHeight); height.DefaultValue = 0; height.Getter = (x) => x.GetHeightForTerminal(); height.Setter = (x, v) => x.Height = v; height.Writer = (x, res) => MyValueFormatter.AppendDistanceInBestUnit(x.Height, res); height.EnableActionsWithReset(); height.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(height); var travel = new MyTerminalControlSlider <MyMotorSuspension>("Travel", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionTravel, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionTravel); travel.SetLimits(0, 100); travel.DefaultValue = 100; travel.Getter = (x) => x.GetSuspensionTravelForTerminal(); travel.Setter = (x, v) => x.SuspensionTravel = v / 100.0f; travel.Writer = (x, res) => res.AppendInt32((int)x.GetSuspensionTravelForTerminal()).Append("%"); travel.EnableActionsWithReset(); travel.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(travel); var speed = new MyTerminalControlSlider <MyMotorSuspension>("Speed Limit", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionSpeed); speed.SetLimits(0, MaxSpeedLimit); speed.DefaultValue = MaxSpeedLimit; speed.Getter = (x) => x.SpeedLimit; speed.Setter = (x, v) => x.SpeedLimit = v; speed.Writer = (x, res) => { if (x.SpeedLimit >= MyMotorSuspension.MaxSpeedLimit) { res.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited)); } else { res.AppendInt32((int)x.SpeedLimit).Append("km/h"); } }; speed.EnableActionsWithReset(); speed.Enabled = (x) => x.m_constraint != null; MyTerminalControlFactory.AddControl(speed); }
/// <summary> /// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update /// </summary> public override MyGuiControlBase HandleInput() { MyGuiControlBase ret = base.HandleInput(); try { if (ret == null && Enabled) { if (MyInput.Static.IsNewLeftMousePressed()) { if (IsMouseOver) { m_selection.Dragging = true; CarriagePositionIndex = GetCarriagePositionFromMouseCursor(); if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } else { m_selection.Reset(this); } } else if (MyInput.Static.IsNewLeftMouseReleased()) { m_selection.Dragging = false; } else if (m_selection.Dragging) { CarriagePositionIndex = GetCarriagePositionFromMouseCursor(); m_selection.SetEnd(this); ret = this; } if (HasFocus) { if (!MyInput.Static.IsAnyCtrlKeyPressed()) { HandleTextInputBuffered(ref ret); } // Move left if (m_keyThrottler.GetKeyStatus(MyKeys.Left) == ThrottledKeyStatus.PRESSED_AND_READY) { if (MyInput.Static.IsAnyCtrlKeyPressed()) { CarriagePositionIndex = GetPreviousSpace(); } else { CarriagePositionIndex--; } if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } // Move right if (m_keyThrottler.GetKeyStatus(MyKeys.Right) == ThrottledKeyStatus.PRESSED_AND_READY) { if (MyInput.Static.IsAnyCtrlKeyPressed()) { CarriagePositionIndex = GetNextSpace(); } else { CarriagePositionIndex++; } if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } // Move home if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.Home)) { CarriagePositionIndex = 0; if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } // Move end if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.End)) { CarriagePositionIndex = m_text.Length; if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } //Cut selected text if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.X) && MyInput.Static.IsAnyCtrlKeyPressed()) { m_selection.CutText(this); } //Copy if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.C) && MyInput.Static.IsAnyCtrlKeyPressed()) { m_selection.CopyText(this); } //Paste if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.V) && MyInput.Static.IsAnyCtrlKeyPressed()) { m_selection.PasteText(this); } //Select All if (m_keyThrottler.IsNewPressAndThrottled(MyKeys.A) && MyInput.Static.IsAnyCtrlKeyPressed()) { m_selection.SelectAll(this); } if (MyInput.Static.IsNewKeyPressed(MyKeys.Enter)) { if (EnterPressed != null) { EnterPressed(this); } } m_formattedAlready = false; } else { if (Type == MyGuiControlTextboxType.DigitsOnly && m_formattedAlready == false && m_text.Length != 0) { var number = MyValueFormatter.GetDecimalFromString(Text, 1); int decimalDigits = (number - Decimal.Truncate(number) > 0) ? 1 : 0; m_text.Clear().Append(MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, "")); CarriagePositionIndex = m_text.Length; m_formattedAlready = true; } } } } catch (IndexOutOfRangeException) // mkTODO: Why? Handle correctly { } m_hadFocusLastTime = HasFocus; return(ret); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyWarhead>()) { return; } base.CreateTerminalControls(); var slider = new MyTerminalControlSlider <MyWarhead>("DetonationTime", MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime, MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime); slider.SetLogLimits(1, 60 * 60); slider.DefaultValue = 10; slider.Enabled = (x) => !x.IsCountingDown; slider.Getter = (x) => x.DetonationTime; slider.Setter = (x, v) => x.m_countdownMs.Value = (int)(v * 1000); slider.Writer = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMs, 1000) / 1000, sb); slider.EnableActions(); MyTerminalControlFactory.AddControl(slider); var startButton = new MyTerminalControlButton <MyWarhead>( "StartCountdown", MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown, MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown, (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, true)); startButton.EnableAction(); MyTerminalControlFactory.AddControl(startButton); var stopButton = new MyTerminalControlButton <MyWarhead>( "StopCountdown", MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown, MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown, (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, false)); stopButton.EnableAction(); MyTerminalControlFactory.AddControl(stopButton); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyWarhead>()); var safetyCheckbox = new MyTerminalControlCheckbox <MyWarhead>( "Safety", MySpaceTexts.TerminalControlPanel_Warhead_Safety, MySpaceTexts.TerminalControlPanel_Warhead_SafetyTooltip, MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextDisarmed, MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextArmed); safetyCheckbox.Getter = (x) => !x.IsArmed; safetyCheckbox.Setter = (x, v) => x.IsArmed = !v; safetyCheckbox.EnableAction(); MyTerminalControlFactory.AddControl(safetyCheckbox); var detonateButton = new MyTerminalControlButton <MyWarhead>( "Detonate", MySpaceTexts.TerminalControlPanel_Warhead_Detonate, MySpaceTexts.TerminalControlPanel_Warhead_Detonate, (b) => { if (b.IsArmed) { MyMultiplayer.RaiseEvent(b, x => x.DetonateRequest); var handler = OnWarheadDetonatedClient; if (handler != null) { handler(b); } } }); detonateButton.Enabled = (x) => x.IsArmed; detonateButton.EnableAction(); MyTerminalControlFactory.AddControl(detonateButton); }
public static void LogEnvironmentInformation() { MySandboxGame.Log.WriteLine("MyVideoModeManager.LogEnvironmentInformation - START"); MySandboxGame.Log.IncreaseIndent(); try { ManagementObjectSearcher mosComputer = new System.Management.ManagementObjectSearcher("Select Manufacturer, Model from Win32_ComputerSystem"); if (mosComputer != null) { foreach (var item in mosComputer.Get()) { MySandboxGame.Log.WriteLine("Win32_ComputerSystem.Manufacturer: " + item["Manufacturer"]); MySandboxGame.Log.WriteLine("Win32_ComputerSystem.Model: " + item["Model"]); MySandboxGame.Log.WriteLine("Virtualized: " + IsVirtualized(item["Manufacturer"].ToString(), item["Model"].ToString())); } } ManagementObjectSearcher mos = new ManagementObjectSearcher("root\\CIMV2", "SELECT Name FROM Win32_Processor"); if (mos != null) { foreach (ManagementObject mo in mos.Get()) { MySandboxGame.Log.WriteLine("Environment.ProcessorName: " + mo["Name"]); } } #if !XB1 // Get info about memory var memory = new WinApi.MEMORYSTATUSEX(); WinApi.GlobalMemoryStatusEx(memory); MySandboxGame.Log.WriteLine("ComputerInfo.TotalPhysicalMemory: " + MyValueFormatter.GetFormatedLong((long)memory.ullTotalPhys) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.TotalVirtualMemory: " + MyValueFormatter.GetFormatedLong((long)memory.ullTotalVirtual) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailablePhysicalMemory: " + MyValueFormatter.GetFormatedLong((long)memory.ullAvailPhys) + " bytes"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailableVirtualMemory: " + MyValueFormatter.GetFormatedLong((long)memory.ullAvailVirtual) + " bytes"); #else // XB1 MySandboxGame.Log.WriteLine("ComputerInfo.TotalPhysicalMemory: N/A (XB1 TODO?)"); MySandboxGame.Log.WriteLine("ComputerInfo.TotalVirtualMemory: N/A (XB1 TODO?)"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailablePhysicalMemory: N/A (XB1 TODO?)"); MySandboxGame.Log.WriteLine("ComputerInfo.AvailableVirtualMemory: N/A (XB1 TODO?)"); #endif // XB1 // Get info about hard drives ConnectionOptions oConn = new ConnectionOptions(); ManagementScope oMs = new ManagementScope("\\\\localhost", oConn); ObjectQuery oQuery = new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3"); using (ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery)) { ManagementObjectCollection oReturnCollection = oSearcher.Get(); foreach (ManagementObject oReturn in oReturnCollection) { string capacity = MyValueFormatter.GetFormatedLong(Convert.ToInt64(oReturn["Size"])); string freeSpace = MyValueFormatter.GetFormatedLong(Convert.ToInt64(oReturn["FreeSpace"])); string name = oReturn["Name"].ToString(); MySandboxGame.Log.WriteLine("Drive " + name + " | Capacity: " + capacity + " bytes | Free space: " + freeSpace + " bytes"); } oReturnCollection.Dispose(); } } catch (Exception e) { MySandboxGame.Log.WriteLine("Error occured during enumerating environment information. Application is continuing. Exception: " + e.ToString()); } MySandboxGame.Log.DecreaseIndent(); MySandboxGame.Log.WriteLine("MyVideoModeManager.LogEnvironmentInformation - END"); }
private void Refresh() { m_needsRefresh = false; var items = Data; items[(int)LineEnum.ReflectorLights].Name.Clear() .AppendStringBuilder((ReflectorLights == MyMultipleEnabledEnum.AllDisabled) ? MyTexts.Get(MySpaceTexts.HudInfoReflectorsOff) : (ReflectorLights == MyMultipleEnabledEnum.NoObjects) ? MyTexts.Get(MySpaceTexts.HudInfoNoReflectors) : MyTexts.Get(MySpaceTexts.HudInfoReflectorsOn)); if (Mass == 0) { items[(int)LineEnum.Mass].Value.Clear().Append("-").Append(" kg"); } else { items[(int)LineEnum.Mass].Value.Clear().AppendInt32(Mass).Append(" kg"); } items[(int)LineEnum.Speed].Value.Clear().AppendDecimal(Speed, 1).Append(" m/s"); var powerState = items[(int)LineEnum.PowerState]; if (PowerState == MyPowerStateEnum.NoPower) { powerState.Name.Clear().AppendStringBuilder(MyTexts.Get(MySpaceTexts.HudInfoNoPower)); powerState.Visible = true; } else { powerState.Visible = false; } var powerUsage = items[(int)LineEnum.PowerUsage]; if (PowerState == MyPowerStateEnum.OverloadBlackout || PowerState == MyPowerStateEnum.OverloadAdaptible) { powerUsage.NameFont = powerUsage.ValueFont = MyFontEnum.Red; } else { powerUsage.NameFont = powerUsage.ValueFont = null; } powerUsage.Value.Clear(); if (PowerState == MyPowerStateEnum.OverloadBlackout) { powerUsage.Value.AppendStringBuilder(MyTexts.Get(MySpaceTexts.HudInfoPowerOverload)); } else { powerUsage.Value.AppendDecimal(PowerUsage * 100, 2).Append(" %"); } { var text = items[(int)LineEnum.ReactorsMaxOutput].Value; text.Clear(); MyValueFormatter.AppendWorkInBestUnit(Reactors, text); } var fuelTime = items[(int)LineEnum.FuelTime]; fuelTime.Value.Clear(); if (PowerState != MyPowerStateEnum.NoPower) { MyValueFormatter.AppendTimeInBestUnit(FuelRemainingTime * 3600, fuelTime.Value); fuelTime.Visible = true; } else { fuelTime.Visible = false; } var numberOfBatteries = items[(int)LineEnum.NumberOfBatteries]; numberOfBatteries.Value.Clear().AppendInt32(NumberOfBatteries); var gyroCount = items[(int)LineEnum.GyroCount]; gyroCount.Value.Clear().AppendInt32(GyroCount); if (GyroCount == 0) { gyroCount.NameFont = gyroCount.ValueFont = MyFontEnum.Red; } else { gyroCount.NameFont = gyroCount.ValueFont = null; } var thrustCount = items[(int)LineEnum.ThrustCount]; thrustCount.Value.Clear().AppendInt32(ThrustCount); if (ThrustCount == 0) { thrustCount.NameFont = thrustCount.ValueFont = MyFontEnum.Red; } else { thrustCount.NameFont = thrustCount.ValueFont = null; } var dampenersState = items[(int)LineEnum.DampenersState]; dampenersState.Value.Clear().AppendStringBuilder(MyTexts.Get((DampenersEnabled) ? MySpaceTexts.HudInfoOn : MySpaceTexts.HudInfoOff)); var landingGearState = items[(int)LineEnum.LandingGearState]; var landingGearStateLine2 = items[(int)LineEnum.LandingGearStateSecondLine]; if (LandingGearsLocked > 0) { items[(int)LineEnum.LandingGearStateSecondLine].Name.Clear().Append(" ").AppendStringBuilder(MyTexts.Get(MySpaceTexts.HudInfoNameLocked)); landingGearState.Value.Clear().Append(LandingGearsTotal); landingGearStateLine2.Value.Clear().AppendInt32(LandingGearsLocked); } else { items[(int)LineEnum.LandingGearStateSecondLine].Name.Clear().Append(" ").AppendStringBuilder(MyTexts.Get(MySpaceTexts.HudInfoNameInProximity)); landingGearState.Value.Clear().Append(LandingGearsTotal); landingGearStateLine2.Value.Clear().AppendInt32(LandingGearsInProximity); } }
protected override void CreateTerminalControls <T>() { if (m_ControlsInited.Contains(typeof(T))) { return; // This must be first! } base.CreateTerminalControls <T>(); // Change the Jump button to do my own stuff List <IMyTerminalControl> controls; List <IMyTerminalAction> actions; MyAPIGateway.TerminalControls.GetControls <T>(out controls); MyAPIGateway.TerminalControls.GetActions <T>(out actions); var jumpControl = controls.FirstOrDefault((x) => x.Id == "Jump") as IMyTerminalControlButton; if (jumpControl != null) { jumpControl.Visible = (b) => b.IsFTL(); var oldAction = jumpControl.Action; jumpControl.Action = (b) => { if (b.IsFTL()) { b.GameLogic.GetAs <FTLBase>().RequestJump(); } else { oldAction(b); } }; } var jumpAction = actions.FirstOrDefault((x) => x.Id == "Jump") as IMyTerminalAction; if (jumpAction != null) { var oldAction = jumpAction.Action; var oldToolbars = jumpAction.InvalidToolbarTypes; jumpAction.InvalidToolbarTypes = null; jumpAction.Action = (b) => { if (b.IsFTL()) { b.GameLogic.GetAs <FTLBase>().RequestJump(); } else { oldAction(b); } }; } // Keep track of slider control, to change limits var distanceControl = controls.FirstOrDefault((x) => x.Id == "JumpDistance") as IMyTerminalControlSlider; if (distanceControl != null) { var oldWriter = distanceControl.Writer; distanceControl.Writer = (b, t) => { if (b.IsFTL()) { t.AppendFormat("{0:P0} (", distanceControl.Getter(b) / 100f); MyValueFormatter.AppendDistanceInBestUnit(b.GameLogic.GetAs <FTLJumpDrive>().ComputeMaxDistance(), t); t.Append(")"); } else { oldWriter(b, t); } }; } }
/// <summary> /// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update /// </summary> public override MyGuiControlBase HandleInput() { MyGuiControlBase ret = base.HandleInput(); try { if (ret == null && Enabled) { if (MyInput.Static.IsNewLeftMousePressed()) { if (IsMouseOver) { m_selection.Dragging = true; CarriagePositionIndex = GetCarriagePositionFromMouseCursor(); if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } else { m_selection.Reset(this); } } else if (MyInput.Static.IsNewLeftMouseReleased()) { m_selection.Dragging = false; } else if (m_selection.Dragging) { if (IsMouseOver) { CarriagePositionIndex = GetCarriagePositionFromMouseCursor(); m_selection.SetEnd(this); ret = this; } } if (HasFocus && !m_hadFocusLastTime) { UpdateLastKeyPressTimes(null); } if (HasFocus) { if (!MyInput.Static.IsAnyCtrlKeyPressed()) { HandleTextInputBuffered(ref ret); } // Move left if ((MyInput.Static.IsKeyPress(MyKeys.Left)) && (IsEnoughDelay(MyKeys.Left, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { if (MyInput.Static.IsAnyCtrlKeyPressed()) { CarriagePositionIndex = GetPreviousSpace(); } else { CarriagePositionIndex--; } UpdateLastKeyPressTimes(MyKeys.Left); if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } // Move right if ((MyInput.Static.IsKeyPress(MyKeys.Right)) && (IsEnoughDelay(MyKeys.Right, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { if (MyInput.Static.IsAnyCtrlKeyPressed()) { CarriagePositionIndex = GetNextSpace(); } else { CarriagePositionIndex++; } UpdateLastKeyPressTimes(MyKeys.Right); if (MyInput.Static.IsAnyShiftKeyPressed()) { m_selection.SetEnd(this); } else { m_selection.Reset(this); } ret = this; } // Move home if ((MyInput.Static.IsNewKeyPressed(MyKeys.Home)) && (IsEnoughDelay(MyKeys.Home, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { CarriagePositionIndex = 0; UpdateLastKeyPressTimes(MyKeys.Home); ret = this; } // Move end if ((MyInput.Static.IsNewKeyPressed(MyKeys.End)) && (IsEnoughDelay(MyKeys.End, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))) { CarriagePositionIndex = m_text.Length; UpdateLastKeyPressTimes(MyKeys.End); ret = this; } //Cut selected text if (MyInput.Static.IsNewKeyPressed(MyKeys.X) && IsEnoughDelay(MyKeys.X, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && MyInput.Static.IsAnyCtrlKeyPressed()) { UpdateLastKeyPressTimes(MyKeys.X); m_selection.CutText(this); } //Copy if (MyInput.Static.IsNewKeyPressed(MyKeys.C) && IsEnoughDelay(MyKeys.C, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && MyInput.Static.IsAnyCtrlKeyPressed()) { UpdateLastKeyPressTimes(MyKeys.C); m_selection.CopyText(this); } //Paste if (MyInput.Static.IsNewKeyPressed(MyKeys.V) && IsEnoughDelay(MyKeys.V, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && MyInput.Static.IsAnyCtrlKeyPressed()) { UpdateLastKeyPressTimes(MyKeys.V); m_selection.PasteText(this); } //Select All if (MyInput.Static.IsNewKeyPressed(MyKeys.A) && IsEnoughDelay(MyKeys.A, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && MyInput.Static.IsAnyCtrlKeyPressed()) { UpdateLastKeyPressTimes(MyKeys.A); m_selection.SelectAll(this); } if (MyInput.Static.IsNewKeyPressed(MyKeys.Enter)) { if (EnterPressed != null) { EnterPressed(this); } } ResetLastKeyPressTimes(); m_formattedAlready = false; } else { if (Type == MyGuiControlTextboxType.DigitsOnly && m_formattedAlready == false && m_text.Length != 0) { var number = MyValueFormatter.GetDecimalFromString(Text, 1); int decimalDigits = (number - (int)number > 0) ? 1 : 0; m_text.Clear().Append(MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, "")); CarriagePositionIndex = m_text.Length; m_formattedAlready = true; } } } } catch (IndexOutOfRangeException) // mkTODO: Why? Handle correctly { } m_hadFocusLastTime = HasFocus; return(ret); }