protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated<MyBeacon>()) return; base.CreateTerminalControls(); //MyTerminalControlFactory.RemoveBaseClass<MyBeacon, MyTerminalBlock>(); // this removed also controls shared with other blocks //removed unnecessary controls var controlList = MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls; controlList.Remove(controlList[4]);//name controlList.Remove(controlList[4]);//show on HUD var customName = new MyTerminalControlTextbox<MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyBeacon>()); var broadcastRadius = new MyTerminalControlSlider<MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE); broadcastRadius.DefaultValue = 10000; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); }
static MyThrust() { float threshold = 0.01f; var thrustOverride = new MyTerminalControlSlider <MyThrust>("Override", MySpaceTexts.BlockPropertyTitle_ThrustOverride, MySpaceTexts.BlockPropertyDescription_ThrustOverride); thrustOverride.Getter = (x) => x.ThrustOverride; thrustOverride.Setter = (x, v) => { float val = v; float limit = x.m_thrustDefinition.ForceMagnitude * threshold; x.SetThrustOverride(val <= limit ? 0 : v); x.SyncObject.SendChangeThrustOverrideRequest(x.ThrustOverride); }; thrustOverride.DefaultValue = 0; thrustOverride.SetLogLimits((x) => x.m_thrustDefinition.ForceMagnitude * 0.01f, (x) => x.m_thrustDefinition.ForceMagnitude); thrustOverride.EnableActions(); thrustOverride.Writer = (x, result) => { if (x.ThrustOverride <= x.m_thrustDefinition.ForceMagnitude * 0.01f) { result.Append(MyTexts.Get(MySpaceTexts.Disabled)); } else { MyValueFormatter.AppendForceInBestUnit(x.ThrustOverride, result); } }; MyTerminalControlFactory.AddControl(thrustOverride); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyBeacon>()) { return; } base.CreateTerminalControls(); //MyTerminalControlFactory.RemoveBaseClass<MyBeacon, MyTerminalBlock>(); // this removed also controls shared with other blocks //removed unnecessary controls var controlList = MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls; controlList.Remove(controlList[4]); //name controlList.Remove(controlList[4]); //show on HUD var customName = new MyTerminalControlTextbox <MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyBeacon>()); var broadcastRadius = new MyTerminalControlSlider <MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE); broadcastRadius.DefaultValue = 10000; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); }
static MyBeacon() { MyTerminalControlFactory.RemoveBaseClass<MyBeacon, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch<MyBeacon>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.ShowInTerminal= v; MyTerminalControlFactory.AddControl(show); var showConfig = new MyTerminalControlOnOffSwitch<MyBeacon>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip); showConfig.Getter = (x) => x.ShowInToolbarConfig; showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v; MyTerminalControlFactory.AddControl(showConfig); var customName = new MyTerminalControlTextbox<MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyBeacon>()); var broadcastRadius = new MyTerminalControlSlider<MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE); broadcastRadius.DefaultValue = 10000; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); }
static MyBeacon() { MyTerminalControlFactory.RemoveBaseClass <MyBeacon, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch <MyBeacon>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.RequestShowInTerminal(v); MyTerminalControlFactory.AddControl(show); var showConfig = new MyTerminalControlOnOffSwitch <MyBeacon>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip); showConfig.Getter = (x) => x.ShowInToolbarConfig; showConfig.Setter = (x, v) => x.RequestShowInToolbarConfig(v); MyTerminalControlFactory.AddControl(showConfig); var customName = new MyTerminalControlTextbox <MyBeacon>("CustomName", MySpaceTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => MySyncBlockHelpers.SendChangeNameRequest(x, v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyBeacon>()); var broadcastRadius = new MyTerminalControlSlider <MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE); broadcastRadius.DefaultValue = 10000; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.RadioBroadcaster.SyncObject.SendChangeRadioAntennaRequest(v, x.RadioBroadcaster.Enabled); broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); }
static MyWarhead() { 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); } }); detonateButton.Enabled = (x) => x.IsArmed; detonateButton.EnableAction(); MyTerminalControlFactory.AddControl(detonateButton); }
static MyTimerBlock() { m_openedToolbars = new List <MyToolbar>(); 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 <MyRadioAntenna>()) { return; } base.CreateTerminalControls(); MyTerminalControlFactory.RemoveBaseClass <MyRadioAntenna, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.ShowInTerminal = v; MyTerminalControlFactory.AddControl(show); var showConfig = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip); showConfig.Getter = (x) => x.ShowInToolbarConfig; showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v; MyTerminalControlFactory.AddControl(showConfig); var customName = new MyTerminalControlTextbox <MyRadioAntenna>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyRadioAntenna>()); var broadcastRadius = new MyTerminalControlSlider <MyRadioAntenna>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits((block) => 1, (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? MyEnergyConstants.MAX_RADIO_POWER_RANGE : MyEnergyConstants.MAX_SMALL_RADIO_POWER_RANGE); broadcastRadius.DefaultValueGetter = (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; //broadcastRadius.Writer = (x, result) => result.Append(x.RadioBroadcaster.BroadcastRadius < MyEnergyConstants.MAX_RADIO_POWER_RANGE ? new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m") : MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); broadcastRadius.Writer = (x, result) => { result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); }; broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); var enableBroadcast = new MyTerminalControlCheckbox <MyRadioAntenna>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast); enableBroadcast.Getter = (x) => x.RadioBroadcaster.Enabled; enableBroadcast.Setter = (x, v) => x.m_enableBroadcasting.Value = v; enableBroadcast.EnableAction(); MyTerminalControlFactory.AddControl(enableBroadcast); var showShipName = new MyTerminalControlCheckbox <MyRadioAntenna>("ShowShipName", MySpaceTexts.BlockPropertyTitle_ShowShipName, MySpaceTexts.BlockPropertyDescription_ShowShipName); showShipName.Getter = (x) => x.ShowShipName; showShipName.Setter = (x, v) => x.ShowShipName = v; showShipName.EnableAction(); MyTerminalControlFactory.AddControl(showShipName); }
public RotorPicker(IMyTerminalBlock cockpit, string rotorName, ControlRotorParams rotorParams, SetControlRotors onComplete) { m_block = cockpit; m_onComplete = onComplete; IEnumerable <IMyMotorStator> selected; rotorParams(out selected, out m_sensitivity, out m_trim); m_trim = MathHelper.ToDegrees(m_trim); m_listbox = new MyTerminalControlListbox <MyCockpit>("Arms_RotorPicker", MyStringId.GetOrCompute(rotorName + " Rotors"), MyStringId.NullOrEmpty, true, 14); m_listbox.ListContent = ListContent; m_listbox.ItemSelected = ItemSelected; m_sensitivitySlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerSensitivity", MyStringId.GetOrCompute("Control Sensitivity"), MyStringId.GetOrCompute("How sensitive the ship will be to input")); m_sensitivitySlider.DefaultValue = 1f; m_sensitivitySlider.Getter = b => m_sensitivity; m_sensitivitySlider.Setter = (b, value) => m_sensitivity = value; m_sensitivitySlider.SetLogLimits(0.01f, 100f); m_sensitivitySlider.Writer = (b, sb) => sb.Append(m_sensitivity); m_trimSlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerTrim", MyStringId.GetOrCompute("Trim"), MyStringId.GetOrCompute("Default angle of rotors")); m_trimSlider.DefaultValue = 0f; m_trimSlider.Getter = b => m_trim; m_trimSlider.Setter = (b, value) => m_trim = value; m_trimSlider.SetLimits(-45f, 45f); m_trimSlider.Writer = (b, sb) => { sb.Append(m_trim); sb.Append('°'); }; m_save = new MyTerminalControlButton <MyCockpit>("Arms_RotorPickerSave", MyStringId.GetOrCompute("Save & Exit"), MyStringId.NullOrEmpty, SaveAndExit); CubeGridCache cache = CubeGridCache.GetFor(m_block.CubeGrid); if (cache == null) { return; } foreach (IMyMotorStator stator in cache.BlocksOfType(typeof(MyObjectBuilder_MotorStator))) { MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(new StringBuilder(stator.DisplayNameText), userData: stator); m_allItems.Add(item); if (selected.Contains(stator)) { m_selected.Add(item); } } MyTerminalControls.Static.CustomControlGetter += CustomControlGetter; cockpit.RebuildControls(); }
static MyRadioAntenna() { MyTerminalControlFactory.RemoveBaseClass <MyRadioAntenna, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.RequestShowInTerminal(v); MyTerminalControlFactory.AddControl(show); var customName = new MyTerminalControlTextbox <MyRadioAntenna>("CustomName", MySpaceTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => MySyncBlockHelpers.SendChangeNameRequest(x, v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyRadioAntenna>()); var broadcastRadius = new MyTerminalControlSlider <MyRadioAntenna>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits((block) => 1, (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? MyEnergyConstants.MAX_RADIO_POWER_RANGE : MyEnergyConstants.MAX_SMALL_RADIO_POWER_RANGE); broadcastRadius.DefaultValueGetter = (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.RadioBroadcaster.SyncObject.SendChangeRadioAntennaRequest(v, x.RadioBroadcaster.Enabled); //broadcastRadius.Writer = (x, result) => result.Append(x.RadioBroadcaster.BroadcastRadius < MyEnergyConstants.MAX_RADIO_POWER_RANGE ? new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m") : MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); broadcastRadius.Writer = (x, result) => { result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); }; broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); var enableBroadcast = new MyTerminalControlCheckbox <MyRadioAntenna>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast); enableBroadcast.Getter = (x) => x.RadioBroadcaster.Enabled; enableBroadcast.Setter = (x, v) => x.RadioBroadcaster.SyncObject.SendChangeRadioAntennaRequest(x.RadioBroadcaster.BroadcastRadius, v); enableBroadcast.EnableAction(); MyTerminalControlFactory.AddControl(enableBroadcast); var showShipName = new MyTerminalControlCheckbox <MyRadioAntenna>("ShowShipName", MySpaceTexts.BlockPropertyTitle_ShowShipName, MySpaceTexts.BlockPropertyDescription_ShowShipName); showShipName.Getter = (x) => x.ShowShipName; showShipName.Setter = (x, v) => x.RadioBroadcaster.SyncObject.SendChangeRadioAntennaDisplayName(v); showShipName.EnableAction(); MyTerminalControlFactory.AddControl(showShipName); }
protected override void CreateTerminalControls() { if (!MyTerminalControlFactory.AreControlsCreated <MyBeacon>()) { base.CreateTerminalControls(); MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls.Remove(MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls[5]); MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls.Remove(MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls[5]); MyTerminalControlTextbox <MyBeacon> textbox3 = new MyTerminalControlTextbox <MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); MyTerminalControlTextbox <MyBeacon> textbox4 = new MyTerminalControlTextbox <MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); textbox4.Getter = x => x.CustomName; MyTerminalControlTextbox <MyBeacon> local24 = textbox4; MyTerminalControlTextbox <MyBeacon> local25 = textbox4; local25.Setter = (x, v) => x.SetCustomName(v); MyTerminalControlTextbox <MyBeacon> control = local25; control.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl <MyBeacon>(control); MyTerminalControlFactory.AddControl <MyBeacon>(new MyTerminalControlSeparator <MyBeacon>()); MyTerminalControlTextbox <MyBeacon> textbox1 = new MyTerminalControlTextbox <MyBeacon>("HudText", MySpaceTexts.BlockPropertiesTitle_HudText, MySpaceTexts.BlockPropertiesTitle_HudText_Tooltip); MyTerminalControlTextbox <MyBeacon> textbox2 = new MyTerminalControlTextbox <MyBeacon>("HudText", MySpaceTexts.BlockPropertiesTitle_HudText, MySpaceTexts.BlockPropertiesTitle_HudText_Tooltip); textbox2.Getter = x => x.HudText; MyTerminalControlTextbox <MyBeacon> local22 = textbox2; MyTerminalControlTextbox <MyBeacon> local23 = textbox2; local23.Setter = (x, v) => x.SetHudText(v); MyTerminalControlTextbox <MyBeacon> local6 = local23; local6.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl <MyBeacon>(local6); MyTerminalControlSlider <MyBeacon> slider1 = new MyTerminalControlSlider <MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); MyTerminalControlSlider <MyBeacon> slider2 = new MyTerminalControlSlider <MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); slider2.SetLogLimits(x => 1f, x => (x.BlockDefinition as MyBeaconDefinition).MaxBroadcastRadius); MyTerminalValueControl <MyBeacon, float> .GetterDelegate local20 = (MyTerminalValueControl <MyBeacon, float> .GetterDelegate)slider2; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local21 = (MyTerminalValueControl <MyBeacon, float> .GetterDelegate)slider2; local21.DefaultValueGetter = x => (x.BlockDefinition as MyBeaconDefinition).MaxBroadcastRadius / 10f; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local18 = local21; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local19 = local21; local19.Getter = x => x.RadioBroadcaster.BroadcastRadius; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local16 = local19; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local17 = local19; local17.Setter = (x, v) => x.m_radius.Value = v; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local14 = local17; MyTerminalValueControl <MyBeacon, float> .GetterDelegate local15 = local17; local15.Writer = (x, result) => result.AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m"); MyTerminalValueControl <MyBeacon, float> .GetterDelegate local13 = local15; ((MyTerminalControlSlider <MyBeacon>)local13).EnableActions <MyBeacon>(0.05f, null, null); MyTerminalControlFactory.AddControl <MyBeacon>((MyTerminalControl <MyBeacon>)local13); } }
static void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MyBeacon>()) { return; } MyTerminalControlFactory.RemoveBaseClass <MyBeacon, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch <MyBeacon>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.ShowInTerminal = v; MyTerminalControlFactory.AddControl(show); var showConfig = new MyTerminalControlOnOffSwitch <MyBeacon>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip); showConfig.Getter = (x) => x.ShowInToolbarConfig; showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v; MyTerminalControlFactory.AddControl(showConfig); var customName = new MyTerminalControlTextbox <MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyBeacon>()); var broadcastRadius = new MyTerminalControlSlider <MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE); broadcastRadius.DefaultValue = 10000; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated <MySpaceProjector>()) { return; } base.CreateTerminalControls(); if (!MyFakes.ENABLE_PROJECTOR_BLOCK) { return; } var blueprintBtn = new MyTerminalControlButton <MySpaceProjector>("Blueprint", MyCommonTexts.Blueprints, MySpaceTexts.Blank, (p) => p.SelectBlueprint()); blueprintBtn.Enabled = (b) => b.CanProject(); blueprintBtn.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(blueprintBtn); var removeBtn = new MyTerminalControlButton <MySpaceProjector>("Remove", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (p) => p.SendRemoveProjection()); removeBtn.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(removeBtn); var keepProjectionToggle = new MyTerminalControlCheckbox <MySpaceProjector>("KeepProjection", MySpaceTexts.KeepProjectionToggle, MySpaceTexts.KeepProjectionTooltip); keepProjectionToggle.Getter = (x) => x.KeepProjection; keepProjectionToggle.Setter = (x, v) => x.KeepProjection = v; keepProjectionToggle.EnableAction(); keepProjectionToggle.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(keepProjectionToggle); //ShowOnlyBuildable var showOnlyBuildableBlockToggle = new MyTerminalControlCheckbox <MySpaceProjector>("ShowOnlyBuildable", MySpaceTexts.ShowOnlyBuildableBlockToggle, MySpaceTexts.ShowOnlyBuildableTooltip); showOnlyBuildableBlockToggle.Getter = (x) => x.m_showOnlyBuildable; showOnlyBuildableBlockToggle.Setter = (x, v) => { x.m_showOnlyBuildable = v; x.OnOffsetsChanged(); }; showOnlyBuildableBlockToggle.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(showOnlyBuildableBlockToggle); //Position var offsetX = new MyTerminalControlSlider <MySpaceProjector>("X", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetX, MySpaceTexts.Blank); offsetX.SetLimits(-50, 50); offsetX.DefaultValue = 0; offsetX.Getter = (x) => x.m_projectionOffset.X; offsetX.Setter = (x, v) => { x.m_projectionOffset.X = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetX.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.X)); offsetX.EnableActions(step: 0.01f); offsetX.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetX); var offsetY = new MyTerminalControlSlider <MySpaceProjector>("Y", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetY, MySpaceTexts.Blank); offsetY.SetLimits(-50, 50); offsetY.DefaultValue = 0; offsetY.Getter = (x) => x.m_projectionOffset.Y; offsetY.Setter = (x, v) => { x.m_projectionOffset.Y = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetY.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Y)); offsetY.EnableActions(step: 0.01f); offsetY.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetY); var offsetZ = new MyTerminalControlSlider <MySpaceProjector>("Z", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetZ, MySpaceTexts.Blank); offsetZ.SetLimits(-50, 50); offsetZ.DefaultValue = 0; offsetZ.Getter = (x) => x.m_projectionOffset.Z; offsetZ.Setter = (x, v) => { x.m_projectionOffset.Z = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetZ.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Z)); offsetZ.EnableActions(step: 0.01f); offsetZ.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetZ); //Rotation var rotationX = new MyTerminalControlSlider <MySpaceProjector>("RotX", MySpaceTexts.BlockPropertyTitle_ProjectionRotationX, MySpaceTexts.Blank); rotationX.SetLimits(-2, 2); rotationX.DefaultValue = 0; rotationX.Getter = (x) => x.m_projectionRotation.X; rotationX.Setter = (x, v) => { x.m_projectionRotation.X = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationX.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.X * 90).Append("°"); rotationX.EnableActions(step: 0.2f); rotationX.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationX); var rotationY = new MyTerminalControlSlider <MySpaceProjector>("RotY", MySpaceTexts.BlockPropertyTitle_ProjectionRotationY, MySpaceTexts.Blank); rotationY.SetLimits(-2, 2); rotationY.DefaultValue = 0; rotationY.Getter = (x) => x.m_projectionRotation.Y; rotationY.Setter = (x, v) => { x.m_projectionRotation.Y = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationY.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Y * 90).Append("°"); rotationY.EnableActions(step: 0.2f); rotationY.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationY); var rotationZ = new MyTerminalControlSlider <MySpaceProjector>("RotZ", MySpaceTexts.BlockPropertyTitle_ProjectionRotationZ, MySpaceTexts.Blank); rotationZ.SetLimits(-2, 2); rotationZ.DefaultValue = 0; rotationZ.Getter = (x) => x.m_projectionRotation.Z; rotationZ.Setter = (x, v) => { x.m_projectionRotation.Z = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationZ.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Z * 90).Append("°"); rotationZ.EnableActions(step: 0.2f); rotationZ.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationZ); var scenarioSettingsSeparator = new MyTerminalControlSeparator <MySpaceProjector>(); scenarioSettingsSeparator.Visible = (p) => p.ScenarioSettingsEnabled(); MyTerminalControlFactory.AddControl(scenarioSettingsSeparator); var scenarioSettingsLabel = new MyTerminalControlLabel <MySpaceProjector>(MySpaceTexts.TerminalScenarioSettingsLabel); scenarioSettingsLabel.Visible = (p) => p.ScenarioSettingsEnabled(); MyTerminalControlFactory.AddControl(scenarioSettingsLabel); var spawnProjectionButton = new MyTerminalControlButton <MySpaceProjector>("SpawnProjection", MySpaceTexts.BlockPropertyTitle_ProjectionSpawn, MySpaceTexts.Blank, (p) => p.TrySpawnProjection()); spawnProjectionButton.Visible = (p) => p.ScenarioSettingsEnabled(); spawnProjectionButton.Enabled = (p) => p.CanSpawnProjection(); spawnProjectionButton.EnableAction(); MyTerminalControlFactory.AddControl(spawnProjectionButton); var instantBuildingCheckbox = new MyTerminalControlCheckbox <MySpaceProjector>("InstantBuilding", MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding, MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding_Tooltip); instantBuildingCheckbox.Visible = (p) => p.ScenarioSettingsEnabled(); instantBuildingCheckbox.Enabled = (p) => p.CanEnableInstantBuilding(); instantBuildingCheckbox.Getter = (p) => p.InstantBuildingEnabled; instantBuildingCheckbox.Setter = (p, v) => p.TrySetInstantBuilding(v); MyTerminalControlFactory.AddControl(instantBuildingCheckbox); var getOwnershipCheckbox = new MyTerminalControlCheckbox <MySpaceProjector>("GetOwnership", MySpaceTexts.BlockPropertyTitle_Projector_GetOwnership, MySpaceTexts.BlockPropertiesTooltip_Projector_GetOwnership); getOwnershipCheckbox.Visible = (p) => p.ScenarioSettingsEnabled(); getOwnershipCheckbox.Enabled = (p) => p.CanEditInstantBuildingSettings(); getOwnershipCheckbox.Getter = (p) => p.GetOwnershipFromProjector; getOwnershipCheckbox.Setter = (p, v) => p.TrySetGetOwnership(v); MyTerminalControlFactory.AddControl(getOwnershipCheckbox); var numberOfProjections = new MyTerminalControlSlider <MySpaceProjector>("NumberOfProjections", MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections, MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections_Tooltip); numberOfProjections.Visible = (p) => p.ScenarioSettingsEnabled(); numberOfProjections.Enabled = (p) => p.CanEditInstantBuildingSettings(); numberOfProjections.Getter = (p) => p.MaxNumberOfProjections; numberOfProjections.Setter = (p, v) => p.TryChangeNumberOfProjections(v); numberOfProjections.Writer = (p, s) => { if (p.MaxNumberOfProjections == MAX_NUMBER_OF_PROJECTIONS) { s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); } else { s.AppendInt32(p.MaxNumberOfProjections); } }; numberOfProjections.SetLogLimits(1, MAX_NUMBER_OF_PROJECTIONS); MyTerminalControlFactory.AddControl(numberOfProjections); var numberOfBlocks = new MyTerminalControlSlider <MySpaceProjector>("NumberOfBlocks", MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection, MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection_Tooltip); numberOfBlocks.Visible = (p) => p.ScenarioSettingsEnabled(); numberOfBlocks.Enabled = (p) => p.CanEditInstantBuildingSettings(); numberOfBlocks.Getter = (p) => p.MaxNumberOfBlocksPerProjection; numberOfBlocks.Setter = (p, v) => p.TryChangeMaxNumberOfBlocksPerProjection(v); numberOfBlocks.Writer = (p, s) => { if (p.MaxNumberOfBlocksPerProjection == MAX_NUMBER_OF_BLOCKS) { s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); } else { s.AppendInt32(p.MaxNumberOfBlocksPerProjection); } }; numberOfBlocks.SetLogLimits(1, MAX_NUMBER_OF_BLOCKS); MyTerminalControlFactory.AddControl(numberOfBlocks); }
protected override void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated<MyRadioAntenna>()) return; base.CreateTerminalControls(); MyTerminalControlFactory.RemoveBaseClass<MyRadioAntenna, MyTerminalBlock>(); var show = new MyTerminalControlOnOffSwitch<MyRadioAntenna>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip); show.Getter = (x) => x.ShowInTerminal; show.Setter = (x, v) => x.ShowInTerminal = v; MyTerminalControlFactory.AddControl(show); var showConfig = new MyTerminalControlOnOffSwitch<MyRadioAntenna>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip); showConfig.Getter = (x) => x.ShowInToolbarConfig; showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v; MyTerminalControlFactory.AddControl(showConfig); var customName = new MyTerminalControlTextbox<MyRadioAntenna>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); customName.Getter = (x) => x.CustomName; customName.Setter = (x, v) => x.SetCustomName(v); customName.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(customName); MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyRadioAntenna>()); var broadcastRadius = new MyTerminalControlSlider<MyRadioAntenna>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); broadcastRadius.SetLogLimits((block) => 1, (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? MyEnergyConstants.MAX_RADIO_POWER_RANGE : MyEnergyConstants.MAX_SMALL_RADIO_POWER_RANGE); broadcastRadius.DefaultValueGetter = (block) => block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500; broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius; broadcastRadius.Setter = (x, v) => x.m_radius.Value = v; //broadcastRadius.Writer = (x, result) => result.Append(x.RadioBroadcaster.BroadcastRadius < MyEnergyConstants.MAX_RADIO_POWER_RANGE ? new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m") : MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); broadcastRadius.Writer = (x, result) => { result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); }; broadcastRadius.EnableActions(); MyTerminalControlFactory.AddControl(broadcastRadius); var enableBroadcast = new MyTerminalControlCheckbox<MyRadioAntenna>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast); enableBroadcast.Getter = (x) => x.RadioBroadcaster.Enabled; enableBroadcast.Setter = (x, v) => x.m_enableBroadcasting.Value = v; enableBroadcast.EnableAction(); MyTerminalControlFactory.AddControl(enableBroadcast); var showShipName = new MyTerminalControlCheckbox<MyRadioAntenna>("ShowShipName", MySpaceTexts.BlockPropertyTitle_ShowShipName, MySpaceTexts.BlockPropertyDescription_ShowShipName); showShipName.Getter = (x) => x.ShowShipName; showShipName.Setter = (x, v) => x.ShowShipName = v; showShipName.EnableAction(); MyTerminalControlFactory.AddControl(showShipName); }
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); } }); detonateButton.Enabled = (x) => x.IsArmed; detonateButton.EnableAction(); MyTerminalControlFactory.AddControl(detonateButton); }
static void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated<MyShipConnector>()) return; var throwOut = new MyTerminalControlOnOffSwitch<MyShipConnector>("ThrowOut", MySpaceTexts.Terminal_ThrowOut); throwOut.Getter = (block) => block.ThrowOut; throwOut.Setter = (block, value) => block.ThrowOut.Value = value; throwOut.EnableToggleAction(); MyTerminalControlFactory.AddControl(throwOut); var collectAll = new MyTerminalControlOnOffSwitch<MyShipConnector>("CollectAll", MySpaceTexts.Terminal_CollectAll); collectAll.Getter = (block) => block.CollectAll; collectAll.Setter = (block, value) => block.CollectAll.Value = value; collectAll.EnableToggleAction(); MyTerminalControlFactory.AddControl(collectAll); var lockBtn = new MyTerminalControlButton<MyShipConnector>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.TryConnect()); lockBtn.Enabled = (b) => b.IsWorking && b.InConstraint; lockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector; var actionLock = lockBtn.EnableAction(); actionLock.Enabled = (b) => b.m_connectorMode == Mode.Connector; MyTerminalControlFactory.AddControl(lockBtn); var unlockBtn = new MyTerminalControlButton<MyShipConnector>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.TryDisconnect()); unlockBtn.Enabled = (b) => b.IsWorking && b.InConstraint; unlockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector; var actionUnlock = unlockBtn.EnableAction(); actionUnlock.Enabled = (b) => b.m_connectorMode == Mode.Connector; MyTerminalControlFactory.AddControl(unlockBtn); var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock); MyTerminalAction<MyShipConnector> switchLockAction = new MyTerminalAction<MyShipConnector>("SwitchLock", title, MyTerminalActionIcons.TOGGLE); switchLockAction.Action = (b) => b.TrySwitch(); switchLockAction.Writer = (b, sb) => b.WriteLockStateValue(sb); switchLockAction.Enabled = (b) => b.m_connectorMode == Mode.Connector; MyTerminalControlFactory.AddAction(switchLockAction); var strength = new MyTerminalControlSlider<MyShipConnector>("Strength", MySpaceTexts.BlockPropertyTitle_Connector_Strength, MySpaceTexts.BlockPropertyDescription_Connector_Strength); strength.Getter = (x) => x.Strength; strength.Setter = (x, v) => x.Strength.Value = v; strength.DefaultValue = MyObjectBuilder_ShipConnector.DefaultStrength; strength.SetLogLimits(MinStrength, 1.0f); strength.EnableActions(enabled: (b) => b.m_connectorMode == Mode.Connector); strength.Enabled = (b) => b.m_connectorMode == Mode.Connector; strength.Visible = (b) => b.m_connectorMode == Mode.Connector; strength.Writer = (x, result) => { if (x.Strength <= MinStrength) result.Append(MyTexts.Get(MyCommonTexts.Disabled)); else result.AppendFormatedDecimal("", x.Strength * 100, 4, " %"); }; MyTerminalControlFactory.AddControl(strength); }
static MyProjector() { if (!MyFakes.ENABLE_PROJECTOR_BLOCK) { return; } var blueprintBtn = new MyTerminalControlButton<MyProjector>("Blueprint", MySpaceTexts.Blueprints, MySpaceTexts.Blank, (p) => p.SelectBlueprint()); blueprintBtn.Enabled = (b) => b.CanProject(); blueprintBtn.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl(blueprintBtn); var removeBtn = new MyTerminalControlButton<MyProjector>("Remove", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (p) => p.SyncObject.SendRemoveProjection()); removeBtn.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(removeBtn); var keepProjectionToggle = new MyTerminalControlCheckbox<MyProjector>("KeepProjection", MySpaceTexts.KeepProjectionToggle, MySpaceTexts.KeepProjectionTooltip); keepProjectionToggle.Getter = (x) => x.m_keepProjection; keepProjectionToggle.Setter = (x, v) => { x.SyncObject.SendNewKeepProjection(v); }; keepProjectionToggle.EnableAction(); keepProjectionToggle.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(keepProjectionToggle); //ShowOnlyBuildable var showOnlyBuildableBlockToggle = new MyTerminalControlCheckbox<MyProjector>("ShowOnlyBuildable", MySpaceTexts.ShowOnlyBuildableBlockToggle, MySpaceTexts.ShowOnlyBuildableTooltip); showOnlyBuildableBlockToggle.Getter = (x) => x.m_showOnlyBuildable; showOnlyBuildableBlockToggle.Setter = (x, v) => { x.m_showOnlyBuildable = v; x.OnOffsetsChanged(); }; showOnlyBuildableBlockToggle.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(showOnlyBuildableBlockToggle); //HideArmorBlocks var hideArmorBlockToggle = new MyTerminalControlCheckbox<MyProjector>("HideArmorBlocks", MySpaceTexts.HideArmorBlockToggle, MySpaceTexts.HideArmorBlockTooltip); hideArmorBlockToggle.Getter = (x) => x.m_hideArmorBlock; hideArmorBlockToggle.Setter = (x, v) => { x.m_hideArmorBlock = v; x.OnOffsetsChanged(); }; hideArmorBlockToggle.Enabled = (b) => b.IsProjecting(); MyTerminalControlFactory.AddControl(hideArmorBlockToggle); //Position var offsetX = new MyTerminalControlSlider<MyProjector>("X", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetX, MySpaceTexts.Blank); offsetX.SetLimits(-50, 50); offsetX.DefaultValue = 0; offsetX.Getter = (x) => x.m_projectionOffset.X; offsetX.Setter = (x, v) => { x.m_projectionOffset.X = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetX.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.X)); offsetX.EnableActions(step: 0.01f); offsetX.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetX); var offsetY = new MyTerminalControlSlider<MyProjector>("Y", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetY, MySpaceTexts.Blank); offsetY.SetLimits(-50, 50); offsetY.DefaultValue = 0; offsetY.Getter = (x) => x.m_projectionOffset.Y; offsetY.Setter = (x, v) => { x.m_projectionOffset.Y = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetY.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Y)); offsetY.EnableActions(step: 0.01f); offsetY.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetY); var offsetZ = new MyTerminalControlSlider<MyProjector>("Z", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetZ, MySpaceTexts.Blank); offsetZ.SetLimits(-50, 50); offsetZ.DefaultValue = 0; offsetZ.Getter = (x) => x.m_projectionOffset.Z; offsetZ.Setter = (x, v) => { x.m_projectionOffset.Z = Convert.ToInt32(v); x.OnOffsetsChanged(); }; offsetZ.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Z)); offsetZ.EnableActions(step: 0.01f); offsetZ.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(offsetZ); //Rotation var rotationX = new MyTerminalControlSlider<MyProjector>("RotX", MySpaceTexts.BlockPropertyTitle_ProjectionRotationX, MySpaceTexts.Blank); rotationX.SetLimits(-2, 2); rotationX.DefaultValue = 0; rotationX.Getter = (x) => x.m_projectionRotation.X; rotationX.Setter = (x, v) => { x.m_projectionRotation.X = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationX.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.X * 90).Append("°"); rotationX.EnableActions(step: 0.2f); rotationX.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationX); var rotationY = new MyTerminalControlSlider<MyProjector>("RotY", MySpaceTexts.BlockPropertyTitle_ProjectionRotationY, MySpaceTexts.Blank); rotationY.SetLimits(-2, 2); rotationY.DefaultValue = 0; rotationY.Getter = (x) => x.m_projectionRotation.Y; rotationY.Setter = (x, v) => { x.m_projectionRotation.Y = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationY.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Y * 90).Append("°"); rotationY.EnableActions(step: 0.2f); rotationY.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationY); var rotationZ = new MyTerminalControlSlider<MyProjector>("RotZ", MySpaceTexts.BlockPropertyTitle_ProjectionRotationZ, MySpaceTexts.Blank); rotationZ.SetLimits(-2, 2); rotationZ.DefaultValue = 0; rotationZ.Getter = (x) => x.m_projectionRotation.Z; rotationZ.Setter = (x, v) => { x.m_projectionRotation.Z = Convert.ToInt32(v); x.OnOffsetsChanged(); }; rotationZ.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Z * 90).Append("°"); rotationZ.EnableActions(step: 0.2f); rotationZ.Enabled = (x) => x.IsProjecting(); MyTerminalControlFactory.AddControl(rotationZ); var scenarioSettingsSeparator = new MyTerminalControlSeparator<MyProjector>(); scenarioSettingsSeparator.Visible = (p) => p.ScenarioSettingsEnabled(); MyTerminalControlFactory.AddControl(scenarioSettingsSeparator); var scenarioSettingsLabel = new MyTerminalControlLabel<MyProjector>("ScenarioLabel", MySpaceTexts.TerminalScenarioSettingsLabel); scenarioSettingsLabel.Visible = (p) => p.ScenarioSettingsEnabled(); MyTerminalControlFactory.AddControl(scenarioSettingsLabel); var spawnProjectionButton = new MyTerminalControlButton<MyProjector>("SpawnProjection", MySpaceTexts.BlockPropertyTitle_ProjectionSpawn, MySpaceTexts.Blank, (p) => p.TrySpawnProjection()); spawnProjectionButton.Visible = (p) => p.ScenarioSettingsEnabled(); spawnProjectionButton.Enabled = (p) => p.CanSpawnProjection(); spawnProjectionButton.EnableAction(); MyTerminalControlFactory.AddControl(spawnProjectionButton); var instantBuildingCheckbox = new MyTerminalControlCheckbox<MyProjector>("InstantBuilding", MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding, MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding_Tooltip); instantBuildingCheckbox.Visible = (p) => p.ScenarioSettingsEnabled(); instantBuildingCheckbox.Enabled = (p) => p.CanEnableInstantBuilding(); instantBuildingCheckbox.Getter = (p) => p.m_instantBuildingEnabled; instantBuildingCheckbox.Setter = (p, v) => p.TrySetInstantBuilding(v); MyTerminalControlFactory.AddControl(instantBuildingCheckbox); var getOwnershipCheckbox = new MyTerminalControlCheckbox<MyProjector>("GetOwnership", MySpaceTexts.BlockPropertyTitle_Projector_GetOwnership, MySpaceTexts.BlockPropertiesTooltip_Projector_GetOwnership); getOwnershipCheckbox.Visible = (p) => p.ScenarioSettingsEnabled(); getOwnershipCheckbox.Enabled = (p) => p.CanEditInstantBuildingSettings(); getOwnershipCheckbox.Getter = (p) => p.m_getOwnershipFromProjector; getOwnershipCheckbox.Setter = (p, v) => p.TrySetGetOwnership(v); MyTerminalControlFactory.AddControl(getOwnershipCheckbox); var numberOfProjections = new MyTerminalControlSlider<MyProjector>("NumberOfProjections", MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections, MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections_Tooltip); numberOfProjections.Visible = (p) => p.ScenarioSettingsEnabled(); numberOfProjections.Enabled = (p) => p.CanEditInstantBuildingSettings(); numberOfProjections.Getter = (p) => p.m_maxNumberOfProjections; numberOfProjections.Setter = (p, v) => p.TryChangeNumberOfProjections(v); numberOfProjections.Writer = (p, s) => { if (p.m_maxNumberOfProjections == MAX_NUMBER_OF_PROJECTIONS) { s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); } else { s.AppendInt32(p.m_maxNumberOfProjections); } }; numberOfProjections.SetLogLimits(1, MAX_NUMBER_OF_PROJECTIONS); MyTerminalControlFactory.AddControl(numberOfProjections); var numberOfBlocks = new MyTerminalControlSlider<MyProjector>("NumberOfBlocks", MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection, MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection_Tooltip); numberOfBlocks.Visible = (p) => p.ScenarioSettingsEnabled(); numberOfBlocks.Enabled = (p) => p.CanEditInstantBuildingSettings(); numberOfBlocks.Getter = (p) => p.m_maxNumberOfBlocksPerProjection; numberOfBlocks.Setter = (p, v) => p.TryChangeMaxNumberOfBlocksPerProjection(v); numberOfBlocks.Writer = (p, s) => { if (p.m_maxNumberOfBlocksPerProjection == MAX_NUMBER_OF_BLOCKS) { s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite)); } else { s.AppendInt32(p.m_maxNumberOfBlocksPerProjection); } }; numberOfBlocks.SetLogLimits(1, MAX_NUMBER_OF_BLOCKS); MyTerminalControlFactory.AddControl(numberOfBlocks); }
static MyWarhead() { 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) => MySyncWarhead.SetTimer(x, 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) => MySyncWarhead.StartCountdown(b)); startButton.EnableAction(); MyTerminalControlFactory.AddControl(startButton); var stopButton = new MyTerminalControlButton<MyWarhead>( "StopCountdown", MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown, MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown, (b) => MySyncWarhead.StopCountdown(b)); 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) => MySyncWarhead.SetArm(x, !v); safetyCheckbox.EnableAction(); MyTerminalControlFactory.AddControl(safetyCheckbox); var detonateButton = new MyTerminalControlButton<MyWarhead>( "Detonate", MySpaceTexts.TerminalControlPanel_Warhead_Detonate, MySpaceTexts.TerminalControlPanel_Warhead_Detonate, (b) => MySyncWarhead.Detonate(b)); detonateButton.Enabled = (x) => x.IsArmed; detonateButton.EnableAction(); MyTerminalControlFactory.AddControl(detonateButton); }
protected override void CreateTerminalControls() { if (!MyTerminalControlFactory.AreControlsCreated <MyRadioAntenna>()) { base.CreateTerminalControls(); MyTerminalControlFactory.RemoveBaseClass <MyRadioAntenna, MyTerminalBlock>(); MyStringId?on = null; on = null; MyTerminalControlOnOffSwitch <MyRadioAntenna> switch3 = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip, on, on); MyTerminalControlOnOffSwitch <MyRadioAntenna> switch4 = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip, on, on); switch4.Getter = x => x.ShowInTerminal; MyTerminalControlOnOffSwitch <MyRadioAntenna> local57 = switch4; MyTerminalControlOnOffSwitch <MyRadioAntenna> control = switch4; control.Setter = (x, v) => x.ShowInTerminal = v; MyTerminalControlFactory.AddControl <MyRadioAntenna>(control); on = null; on = null; MyTerminalControlOnOffSwitch <MyRadioAntenna> switch1 = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip, on, on); MyTerminalControlOnOffSwitch <MyRadioAntenna> switch2 = new MyTerminalControlOnOffSwitch <MyRadioAntenna>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip, on, on); switch2.Getter = x => x.ShowInToolbarConfig; MyTerminalControlOnOffSwitch <MyRadioAntenna> local55 = switch2; MyTerminalControlOnOffSwitch <MyRadioAntenna> local56 = switch2; local56.Setter = (x, v) => x.ShowInToolbarConfig = v; MyTerminalControlFactory.AddControl <MyRadioAntenna>(local56); MyTerminalControlButton <MyRadioAntenna> button1 = new MyTerminalControlButton <MyRadioAntenna>("CustomData", MySpaceTexts.Terminal_CustomData, MySpaceTexts.Terminal_CustomDataTooltip, new Action <MyRadioAntenna>(this.CustomDataClicked)); MyTerminalControlButton <MyRadioAntenna> button2 = new MyTerminalControlButton <MyRadioAntenna>("CustomData", MySpaceTexts.Terminal_CustomData, MySpaceTexts.Terminal_CustomDataTooltip, new Action <MyRadioAntenna>(this.CustomDataClicked)); button2.Enabled = x => !x.m_textboxOpen; MyTerminalControlButton <MyRadioAntenna> local6 = button2; local6.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl <MyRadioAntenna>(local6); MyTerminalControlTextbox <MyRadioAntenna> textbox3 = new MyTerminalControlTextbox <MyRadioAntenna>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); MyTerminalControlTextbox <MyRadioAntenna> textbox4 = new MyTerminalControlTextbox <MyRadioAntenna>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank); textbox4.Getter = x => x.CustomName; MyTerminalControlTextbox <MyRadioAntenna> local53 = textbox4; MyTerminalControlTextbox <MyRadioAntenna> local54 = textbox4; local54.Setter = (x, v) => x.SetCustomName(v); MyTerminalControlTextbox <MyRadioAntenna> local9 = local54; local9.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl <MyRadioAntenna>(local9); MyTerminalControlFactory.AddControl <MyRadioAntenna>(new MyTerminalControlSeparator <MyRadioAntenna>()); MyTerminalControlTextbox <MyRadioAntenna> textbox1 = new MyTerminalControlTextbox <MyRadioAntenna>("HudText", MySpaceTexts.BlockPropertiesTitle_HudText, MySpaceTexts.BlockPropertiesTitle_HudText_Tooltip); MyTerminalControlTextbox <MyRadioAntenna> textbox2 = new MyTerminalControlTextbox <MyRadioAntenna>("HudText", MySpaceTexts.BlockPropertiesTitle_HudText, MySpaceTexts.BlockPropertiesTitle_HudText_Tooltip); textbox2.Getter = x => x.HudText; MyTerminalControlTextbox <MyRadioAntenna> local51 = textbox2; MyTerminalControlTextbox <MyRadioAntenna> local52 = textbox2; local52.Setter = (x, v) => x.SetHudText(v); MyTerminalControlTextbox <MyRadioAntenna> local12 = local52; local12.SupportsMultipleBlocks = false; MyTerminalControlFactory.AddControl <MyRadioAntenna>(local12); MyTerminalControlCombobox <MyRadioAntenna> combobox1 = new MyTerminalControlCombobox <MyRadioAntenna>("PBList", MySpaceTexts.BlockPropertyTitle_AssignedPB, MySpaceTexts.Blank); MyTerminalControlCombobox <MyRadioAntenna> combobox2 = new MyTerminalControlCombobox <MyRadioAntenna>("PBList", MySpaceTexts.BlockPropertyTitle_AssignedPB, MySpaceTexts.Blank); combobox2.ComboBoxContentWithBlock = (x, list) => x.FillPBComboBoxContent(list); MyTerminalControlCombobox <MyRadioAntenna> local49 = combobox2; MyTerminalControlCombobox <MyRadioAntenna> local50 = combobox2; local50.Getter = x => (long)x.m_attachedPB; MyTerminalControlCombobox <MyRadioAntenna> local47 = local50; MyTerminalControlCombobox <MyRadioAntenna> local48 = local50; local48.Setter = delegate(MyRadioAntenna x, long y) { x.m_attachedPB.Value = y; m_ignoreAllyCheckbox.UpdateVisual(); m_ignoreOtherCheckbox.UpdateVisual(); }; MyTerminalControlFactory.AddControl <MyRadioAntenna>(local48); MyTerminalControlFactory.AddControl <MyRadioAntenna>(new MyTerminalControlSeparator <MyRadioAntenna>()); MyTerminalControlSlider <MyRadioAntenna> slider1 = new MyTerminalControlSlider <MyRadioAntenna>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); MyTerminalControlSlider <MyRadioAntenna> slider2 = new MyTerminalControlSlider <MyRadioAntenna>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius); slider2.SetLogLimits(block => 1f, block => (block.BlockDefinition as MyRadioAntennaDefinition).MaxBroadcastRadius); MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local45 = (MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate)slider2; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local46 = (MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate)slider2; local46.DefaultValueGetter = x => (x.BlockDefinition as MyRadioAntennaDefinition).MaxBroadcastRadius / 10f; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local43 = local46; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local44 = local46; local44.Getter = x => x.RadioBroadcaster.BroadcastRadius; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local41 = local44; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local42 = local44; local42.Setter = (x, v) => x.m_radius.Value = v; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local39 = local42; MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local40 = local42; local40.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m")); MyTerminalValueControl <MyRadioAntenna, float> .GetterDelegate local22 = local40; ((MyTerminalControlSlider <MyRadioAntenna>)local22).EnableActions <MyRadioAntenna>(0.05f, null, null); MyTerminalControlFactory.AddControl <MyRadioAntenna>((MyTerminalControl <MyRadioAntenna>)local22); on = null; on = null; MyTerminalControlCheckbox <MyRadioAntenna> checkbox3 = new MyTerminalControlCheckbox <MyRadioAntenna>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast, on, on); MyTerminalControlCheckbox <MyRadioAntenna> checkbox4 = new MyTerminalControlCheckbox <MyRadioAntenna>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast, on, on); checkbox4.Getter = x => x.EnableBroadcasting.Value; MyTerminalControlCheckbox <MyRadioAntenna> local37 = checkbox4; MyTerminalControlCheckbox <MyRadioAntenna> local38 = checkbox4; local38.Setter = (x, v) => x.EnableBroadcasting.Value = v; MyTerminalControlCheckbox <MyRadioAntenna> checkbox = local38; checkbox.EnableAction <MyRadioAntenna>(null); MyTerminalControlFactory.AddControl <MyRadioAntenna>(checkbox); on = null; on = null; MyTerminalControlCheckbox <MyRadioAntenna> checkbox1 = new MyTerminalControlCheckbox <MyRadioAntenna>("ShowShipName", MySpaceTexts.BlockPropertyTitle_ShowShipName, MySpaceTexts.BlockPropertyDescription_ShowShipName, on, on); MyTerminalControlCheckbox <MyRadioAntenna> checkbox2 = new MyTerminalControlCheckbox <MyRadioAntenna>("ShowShipName", MySpaceTexts.BlockPropertyTitle_ShowShipName, MySpaceTexts.BlockPropertyDescription_ShowShipName, on, on); checkbox2.Getter = x => x.ShowShipName; MyTerminalControlCheckbox <MyRadioAntenna> local35 = checkbox2; MyTerminalControlCheckbox <MyRadioAntenna> local36 = checkbox2; local36.Setter = (x, v) => x.ShowShipName = v; MyTerminalControlCheckbox <MyRadioAntenna> local28 = local36; local28.EnableAction <MyRadioAntenna>(null); MyTerminalControlFactory.AddControl <MyRadioAntenna>(local28); MyTerminalControlFactory.AddControl <MyRadioAntenna>(new MyTerminalControlSeparator <MyRadioAntenna>()); on = null; on = null; m_ignoreAllyCheckbox = new MyTerminalControlCheckbox <MyRadioAntenna>("IgnoreAlliedBroadcast", MySpaceTexts.Antenna_IgnoreAlliedBroadcast, MySpaceTexts.Antenna_IgnoreAlliedBroadcastTooltip, on, on); m_ignoreAllyCheckbox.Enabled = x => x.m_attachedPB.Value != 0L; m_ignoreAllyCheckbox.Getter = x => (bool)x.m_ignoreAlliedBroadcast; m_ignoreAllyCheckbox.Setter = (x, y) => x.m_ignoreAlliedBroadcast.Value = y; m_ignoreAllyCheckbox.EnableAction <MyRadioAntenna>(null); MyTerminalControlFactory.AddControl <MyRadioAntenna>(m_ignoreAllyCheckbox); on = null; on = null; m_ignoreOtherCheckbox = new MyTerminalControlCheckbox <MyRadioAntenna>("IgnoreOtherBroadcast", MySpaceTexts.Antenna_IgnoreOtherBroadcast, MySpaceTexts.Antenna_IgnoreOtherBroadcastTooltip, on, on); m_ignoreOtherCheckbox.Enabled = x => x.m_attachedPB.Value != 0L; m_ignoreOtherCheckbox.Getter = x => (bool)x.m_ignoreOtherBroadcast; m_ignoreOtherCheckbox.Setter = (x, y) => x.m_ignoreOtherBroadcast.Value = y; m_ignoreOtherCheckbox.EnableAction <MyRadioAntenna>(null); MyTerminalControlFactory.AddControl <MyRadioAntenna>(m_ignoreOtherCheckbox); } }
static MyThrust() { float threshold = 0.01f; var thrustOverride = new MyTerminalControlSlider<MyThrust>("Override", MySpaceTexts.BlockPropertyTitle_ThrustOverride, MySpaceTexts.BlockPropertyDescription_ThrustOverride); thrustOverride.Getter = (x) => x.ThrustOverride; thrustOverride.Setter = (x, v) => { float val = v; float limit = x.BlockDefinition.ForceMagnitude * threshold; x.SetThrustOverride(val <= limit ? 0 : v); x.SyncObject.SendChangeThrustOverrideRequest(x.ThrustOverride); }; thrustOverride.DefaultValue = 0; thrustOverride.SetLogLimits((x) => x.BlockDefinition.ForceMagnitude * 0.01f, (x) => x.BlockDefinition.ForceMagnitude); thrustOverride.EnableActions(); thrustOverride.Writer = (x, result) => { if (x.ThrustOverride <= x.BlockDefinition.ForceMagnitude * 0.01f) result.Append(MyTexts.Get(MySpaceTexts.Disabled)); else MyValueFormatter.AppendForceInBestUnit(x.ThrustOverride, result); }; MyTerminalControlFactory.AddControl(thrustOverride); }
static void CreateTerminalControls() { if (MyTerminalControlFactory.AreControlsCreated<MyTimerBlock>()) return; 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); }