private void InitControls() { _showQrControl = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyTextPanel>(""); _showQrControl.Title = MyStringId.GetOrCompute("Show QR Code"); _showQrControl.Getter = b => ((IMyTextPanel)b).ShowOnScreen == ShowTextOnScreenFlag.PUBLIC; _showQrControl.Setter = (b, v) => { ((IMyTextPanel)b).SetShowOnScreen(v ? ShowTextOnScreenFlag.PUBLIC : ShowTextOnScreenFlag.NONE); }; _keyControl = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyTextPanel>(""); _keyControl.Title = MyStringId.GetOrCompute("API Key"); _keyControl.Getter = b => { var logic = b.GameLogic.GetAs <WebApiBlockComp>(); if (string.IsNullOrEmpty(logic?.LocalKey)) { RequestKey(b); } return(new StringBuilder(logic?.LocalKey ?? "")); }; _keyControl.Setter = (b, v) => { }; _genControl = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyTextPanel>(""); _genControl.Title = MyStringId.GetOrCompute("Generate New Key"); _genControl.Action = b => RequestKey(b, true); }
public static void CreateControlCheckbox(string id, string title, string tooltip, Func <IMyTerminalBlock, bool> visible, Func <IMyTerminalBlock, bool> enabled, Func <IMyTerminalBlock, bool> getter, Action <IMyTerminalBlock, bool> setter) { if (ControlIdExists(id) != null) { return; } IMyTerminalControlCheckbox checkbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyUpgradeModule>(id); checkbox.Enabled = enabled; checkbox.Visible = visible; checkbox.SupportsMultipleBlocks = false; if (title != null) { checkbox.Title = MyStringId.GetOrCompute(title); } if (tooltip != null) { checkbox.Tooltip = MyStringId.GetOrCompute(tooltip); } checkbox.Getter = getter; checkbox.Setter = setter; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(checkbox); }
internal static void CreateOnOffActionSet <T>(IMyTerminalControlCheckbox tc, string name, int id, Func <IMyTerminalBlock, int, bool> enabler, bool group = false) where T : IMyTerminalBlock { var action0 = MyAPIGateway.TerminalControls.CreateAction <T>($"WC_{id}_Toggle"); action0.Icon = @"Textures\GUI\Icons\Actions\Toggle.dds"; action0.Name = new StringBuilder($"{name} Toggle On/Off"); action0.Action = (b) => tc.Setter(b, !tc.Getter(b)); action0.Writer = (b, t) => t.Append(tc.Getter(b) ? tc.OnText : tc.OffText); action0.Enabled = (b) => enabler(b, id); action0.ValidForGroups = group; MyAPIGateway.TerminalControls.AddAction <T>(action0); var action1 = MyAPIGateway.TerminalControls.CreateAction <T>($"WC_{id}_Toggle_On"); action1.Icon = @"Textures\GUI\Icons\Actions\SwitchOn.dds"; action1.Name = new StringBuilder($"{name} On"); action1.Action = (b) => tc.Setter(b, true); action1.Writer = (b, t) => t.Append(tc.Getter(b) ? tc.OnText : tc.OffText); action1.Enabled = (b) => enabler(b, id); action1.ValidForGroups = group; MyAPIGateway.TerminalControls.AddAction <T>(action1); var action2 = MyAPIGateway.TerminalControls.CreateAction <T>($"WC_{id}_Toggle_Off"); action2.Icon = @"Textures\GUI\Icons\Actions\SwitchOff.dds"; action2.Name = new StringBuilder($"{name} Off"); action2.Action = (b) => tc.Setter(b, true); action2.Writer = (b, t) => t.Append(tc.Getter(b) ? tc.OnText : tc.OffText); action2.Enabled = (b) => enabler(b, id); action2.ValidForGroups = group; MyAPIGateway.TerminalControls.AddAction <T>(action2); }
private void create_checkbox <_block_>(string id, string title, string tooltip, string toolbar_enabled_text, string toolbar_disabled_text, Func <IMyTerminalBlock, bool> getter, Action <IMyTerminalBlock, bool> setter, Func <IMyTerminalBlock, bool> state) where _block_ : IMyTerminalBlock { IMyTerminalControlCheckbox panel_checkbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, _block_>(id); panel_checkbox.Getter = getter; panel_checkbox.Setter = setter; if (state != null) { panel_checkbox.Enabled = state; } panel_checkbox.Title = MyStringId.GetOrCompute(title); if (tooltip != null) { panel_checkbox.Tooltip = MyStringId.GetOrCompute(tooltip); } panel_checkbox.SupportsMultipleBlocks = true; MyAPIGateway.TerminalControls.AddControl <_block_>(panel_checkbox); create_toggle <_block_>(id + "Toggle", title + " On/Off", toolbar_enabled_text, toolbar_disabled_text, delegate(IMyTerminalBlock block) { setter(block, !getter(block)); }, getter, state, "LargeShipToggle"); }
private void CreateTerminalControls() { if (_ControlsInited) { return; } _ControlsInited = true; bool enabledCheck(IMyTerminalBlock b) { return(b.BlockDefinition.SubtypeId == "DrillPlatform"); } m_enableStone = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyAssembler>("EnableStone"); // Separator var sep = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyAssembler>(string.Empty); if (sep != null) { sep.Visible = enabledCheck; sep.Enabled = enabledCheck; MyAPIGateway.TerminalControls.AddControl <IMyAssembler>(sep); } // EnableStone checkbox if (m_enableStone != null) { m_enableStone.Title = MyStringId.GetOrCompute("开采石头"); m_enableStone.Tooltip = MyStringId.GetOrCompute("启用此选项将会在设备中产生石头。"); m_enableStone.Getter = (b) => enabledCheck(b) && b.GameLogic.GetAs <Rig>().StoneEnabled; m_enableStone.Setter = (b, v) => { if (enabledCheck(b)) { MessageUtils.SendMessageToAll(new MessageToggleStoneEnable() { EntityId = b.EntityId, EnableStone = v }); } }; m_enableStone.Visible = enabledCheck; m_enableStone.Enabled = enabledCheck; m_enableStone.OnText = MyStringId.GetOrCompute("On"); m_enableStone.OffText = MyStringId.GetOrCompute("Off"); MyAPIGateway.TerminalControls.AddControl <IMyAssembler>(m_enableStone); var action = MyAPIGateway.TerminalControls.CreateAction <IMyAssembler>("EnableStone"); if (action != null) { StringBuilder actionname = new StringBuilder(); actionname.Append(m_enableStone.Title).Append(" ").Append(m_enableStone.OnText).Append("/").Append(m_enableStone.OffText); action.Name = actionname; action.Icon = @"Textures\GUI\Icons\Actions\Toggle.dds"; action.ValidForGroups = true; action.Action = (b) => m_enableStone.Setter(b, !m_enableStone.Getter(b)); action.Writer = (b, t) => t.Append(b.GameLogic.GetAs <Rig>().StoneEnabled ? m_enableStone.OnText : m_enableStone.OffText); MyAPIGateway.TerminalControls.AddAction <IMyAssembler>(action); } } }
public static IMyTerminalControlCheckbox DistanceMode <T>() where T : IMyTerminalBlock { IMyTerminalControlCheckbox DistanceMode = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, T>("DistanceMode"); DistanceMode.SupportsMultipleBlocks = true; DistanceMode.Enabled = HasBlockLogic; DistanceMode.Visible = HasBlockLogic; DistanceMode.Getter = (Block) => BlockReturn(Block, x => x.DistanceMode); DistanceMode.Setter = (Block, NewMode) => BlockAction(Block, x => x.DistanceMode = NewMode); return(DistanceMode); }
private void CreateTerminalControls() { // Just to make sure we're not subscribing twice without using locks MyAPIGateway.TerminalControls.CustomControlGetter -= CustomControlGetter; MyAPIGateway.TerminalControls.CustomControlGetter += CustomControlGetter; IMyTerminalControlCheckbox checkbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMySensorBlock>("WeatherAlert"); checkbox.Title = MyStringId.GetOrCompute("Enable Weather Alert"); checkbox.Tooltip = MyStringId.GetOrCompute("When enabled, sensor triggers turn-on action in bad weather, and turn-off action when bad weather ends"); checkbox.Getter = (block) => { if (block == null || block.GameLogic == null) { return(false); } var logic = block.GameLogic.GetAs <WeatherAlertLogic>(); return(logic != null ? logic.p_weatheralert_enabled : false); }; checkbox.Setter = (block, value) => { var logic = block.GameLogic.GetAs <WeatherAlertLogic>(); var sb = block as IMySensorBlock; if (logic != null) { logic.p_weatheralert_enabled = value; if (value) { MyLog.Default.WriteLineAndConsole("WeatherAlert - Enabled Weather Alert for \"{block.CustomName}\""); } else { MyLog.Default.WriteLineAndConsole("WeatherAlert - Disabled Weather Alert for \"{block.CustomName}\""); } } }; checkbox.SupportsMultipleBlocks = false; customControls.Add(checkbox); }
public static IMyTerminalAction CreateToggleAction <TBlock>(this IMyTerminalControlCheckbox checkbox, string iconPath) where TBlock : IMyTerminalBlock { var onText = MyTexts.Get(checkbox.OnText); var offText = MyTexts.Get(checkbox.OffText); var name = GetTitle(checkbox.Title).Append(" ").Append(onText).Append("/").Append(offText); var action = MyAPIGateway.TerminalControls.CreateAction <TBlock>(((IMyTerminalControl)checkbox).Id); action.Name = name; action.Action = block => checkbox.Setter(block, !checkbox.Getter(block)); action.Writer = (block, sb) => sb.Append(checkbox.Getter(block) ? onText : offText); action.Icon = iconPath; action.Enabled = checkbox.Enabled; return(action); }
private void CreateAction <T>(IMyTerminalControlCheckbox c, bool addToggle = true, bool addOnOff = false, string iconPack = null, string iconToggle = null, string iconOn = null, string iconOff = null) { try { var id = ((IMyTerminalControl)c).Id; var name = c.Title.String; Action <IMyTerminalBlock, StringBuilder> writer = (b, s) => s.Append(c.Getter(b) ? c.OnText : c.OffText); if (iconToggle == null && iconOn == null && iconOff == null) { var pack = iconPack ?? string.Empty; var gamePath = MyAPIGateway.Utilities.GamePaths.ContentPath; iconToggle = gamePath + @"\Textures\GUI\Icons\Actions\" + pack + "Toggle.dds"; iconOn = gamePath + @"\Textures\GUI\Icons\Actions\" + pack + "SwitchOn.dds"; iconOff = gamePath + @"\Textures\GUI\Icons\Actions\" + pack + "SwitchOff.dds"; } if (addToggle) { var a = MyAPIGateway.TerminalControls.CreateAction <T>(id + "_Toggle"); a.Name = new StringBuilder(name).Append(" On/Off"); a.Icon = iconToggle; a.ValidForGroups = true; a.Action = (b) => c.Setter(b, !c.Getter(b)); if (writer != null) { a.Writer = writer; } MyAPIGateway.TerminalControls.AddAction <T>(a); } if (addOnOff) { { var a = MyAPIGateway.TerminalControls.CreateAction <T>(id + "_On"); a.Name = new StringBuilder(name).Append(" On"); a.Icon = iconOn; a.ValidForGroups = true; a.Action = (b) => c.Setter(b, true); if (writer != null) { a.Writer = writer; } MyAPIGateway.TerminalControls.AddAction <T>(a); } { var a = MyAPIGateway.TerminalControls.CreateAction <T>(id + "_Off"); a.Name = new StringBuilder(name).Append(" Off"); a.Icon = iconOff; a.ValidForGroups = true; a.Action = (b) => c.Setter(b, false); if (writer != null) { a.Writer = writer; } MyAPIGateway.TerminalControls.AddAction <T>(a); } } } catch (Exception ex) { Log.Line($"Exception in CreateAction<T>(IMyTerminalControlCheckbox: {ex}"); } }
private void CreateTerminalControls() { // Just to make sure we're not subscribing twice without using locks MyAPIGateway.TerminalControls.CustomControlGetter -= CustomControlGetter; MyAPIGateway.TerminalControls.CustomControlGetter += CustomControlGetter; IMyTerminalControlCheckbox checkbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyThrust>("LockFlameColors"); checkbox.Title = MyStringId.GetOrCompute("Lock Flame Colors"); checkbox.Getter = (block) => { if (block == null || block.GameLogic == null) { return(false); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_flameColorsLocked : false); }; checkbox.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_flameColorsLocked = value; logic.UpdateFlames(); logic.UpdateCustomData(); } }; checkbox.SupportsMultipleBlocks = true; m_customControls.Add(checkbox); // FlameIdleColor IMyTerminalControlColor color = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyThrust>("FlameIdleColor"); color.Title = MyStringId.GetOrCompute("Idle"); color.Getter = (block) => { if (block == null || block.GameLogic == null) { return((Vector4)Color.Black); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_flameIdleColor : (Vector4)Color.Black); }; color.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { Vector3 v = value.ToVector3(); logic.m_flameIdleColor = new Vector4(v.X, v.Y, v.Z, logic.m_flameIdleColor.W); if (logic.m_renderMode == RenderMode.Linked) { logic.m_flameFullColor = logic.m_flameIdleColor; } foreach (var control in m_customControls) { if (control.Id == "FlameFullColor") { control.UpdateVisual(); } } logic.UpdateFlames(); logic.UpdateCustomData(); } }; m_customControls.Add(color); IMyTerminalControlSlider alpha = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyThrust>("FlameIdleColorAlpha"); alpha.Title = MyStringId.GetOrCompute("Alpha"); alpha.SetLimits(0f, 1f); alpha.Getter = (block) => { if (block == null || block.GameLogic == null) { return(1f); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_flameIdleColor.W : 1f); }; alpha.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_flameIdleColor.W = value; if (logic.m_renderMode == RenderMode.Linked) { logic.m_flameFullColor.W = logic.m_flameIdleColor.W; } foreach (var control in m_customControls) { if (control.Id == "FlameFullColorAlpha" || control.Id == "FlameFullColor" || control.Id == "FlameIdleColor") { control.UpdateVisual(); } } logic.UpdateFlames(); logic.UpdateCustomData(); } }; m_customControls.Add(alpha); var propertyIC = MyAPIGateway.TerminalControls.CreateProperty <Color, IMyThrust>("FlameIdleColorOverride"); propertyIC.SupportsMultipleBlocks = false; propertyIC.Getter = (block) => { if (block == null || block.GameLogic == null) { return(Vector4.Zero); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? (Color)logic.FlameIdleColor : Color.Transparent); }; propertyIC.Setter = (block, value) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_flameIdleColor = value.ToVector4(); // logic.m_flameIdleColor.W = 0.75f; if (logic.m_renderMode == RenderMode.Linked) { logic.FlameFullColor = logic.FlameIdleColor; } } }; MyAPIGateway.TerminalControls.AddControl <IMyThrust>(propertyIC); // FlameFullColor color = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyThrust>("FlameFullColor"); color.Title = MyStringId.GetOrCompute("Full"); color.Enabled = (block) => { if (block == null || block.GameLogic == null) { return(false); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? (logic.m_renderMode != RenderMode.Linked) : false); }; color.Getter = (block) => { if (block == null || block.GameLogic == null) { return((Vector4)Color.Black); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_flameFullColor : (Vector4)Color.Black); }; color.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { Vector3 v = value.ToVector3(); logic.m_flameFullColor = new Vector4(v.X, v.Y, v.Z, logic.m_flameFullColor.W); logic.UpdateFlames(); logic.UpdateCustomData(); } }; m_customControls.Add(color); alpha = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyThrust>("FlameFullColorAlpha"); alpha.Title = MyStringId.GetOrCompute("Alpha"); alpha.SetLimits(0f, 1f); alpha.Getter = (block) => { if (block == null || block.GameLogic == null) { return(1f); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_flameFullColor.W : 1f); }; alpha.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_flameFullColor.W = value; if (logic.m_renderMode == RenderMode.Linked) { logic.m_flameIdleColor.W = logic.m_flameFullColor.W; } foreach (var control in m_customControls) { if (control.Id == "FlameIdleColorAlpha" || control.Id == "FlameFullColor" || control.Id == "FlameIdleColor") { control.UpdateVisual(); } } logic.UpdateFlames(); logic.UpdateCustomData(); } }; m_customControls.Add(alpha); var propertyFC = MyAPIGateway.TerminalControls.CreateProperty <Color, IMyThrust>("FlameFullColorOverride"); propertyFC.SupportsMultipleBlocks = false; propertyFC.Getter = (block) => { if (block == null || block.GameLogic == null) { return(Vector4.Zero); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? (Color)logic.FlameFullColor : Color.Transparent); }; propertyFC.Setter = (block, value) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null && logic.m_renderMode != RenderMode.Linked) { logic.m_flameFullColor = value.ToVector4(); } }; MyAPIGateway.TerminalControls.AddControl <IMyThrust>(propertyFC); IMyTerminalControlSlider renderMode = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyThrust>("FlameRenderMode"); renderMode.Title = MyStringId.GetOrCompute("Flame Render Mode"); renderMode.SetLimits(0, 2); renderMode.Getter = (block) => { if (block == null || block.GameLogic == null) { return((int)m_renderMode); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? (int)logic.m_renderMode : 0); }; renderMode.Setter = (block, value) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_renderMode = (RenderMode)value; if (logic.m_renderMode == RenderMode.Linked) { logic.m_flameFullColor = logic.m_flameIdleColor; } logic.UpdateFlames(); logic.UpdateCustomData(); foreach (var control in m_customControls) { if (control.Id == "FlameFullColor") { control.UpdateVisual(); } } } }; renderMode.Writer = (block, sb) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { sb.Append(logic.m_renderMode.ToString()); } }; renderMode.SupportsMultipleBlocks = true; m_customControls.Add(renderMode); var hideFlamesCheckbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyThrust>("HideThrustFlames"); hideFlamesCheckbox.Title = MyStringId.GetOrCompute("Hide Thrust Flames"); hideFlamesCheckbox.Getter = (block) => { if (block == null || block.GameLogic == null) { return(false); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.m_hideFlames : false); }; hideFlamesCheckbox.Setter = (block, value) => { var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.m_hideFlames = value; logic.UpdateFlames(); logic.UpdateCustomData(); } }; hideFlamesCheckbox.SupportsMultipleBlocks = true; m_customControls.Add(hideFlamesCheckbox); var propertyHF = MyAPIGateway.TerminalControls.CreateProperty <bool, IMyThrust>("HideThrustFlames"); propertyHF.SupportsMultipleBlocks = false; propertyHF.Getter = (block) => { if (block == null || block.GameLogic == null) { return(false); } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); return(logic != null ? logic.HideThrustFlames : false); }; propertyHF.Setter = (block, value) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { logic.HideThrustFlames = value; } }; MyAPIGateway.TerminalControls.AddControl <IMyThrust>(propertyHF); var resetButton = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyThrust>("ResetDefaultColors"); resetButton.Title = MyStringId.GetOrCompute("Reset Default Colors"); resetButton.Action = (block) => { if (block == null || block.GameLogic == null) { return; } var logic = block.GameLogic.GetAs <RecolorableThrustFlameLogic>(); if (logic != null) { var blockDefinition = block.SlimBlock.BlockDefinition as MyThrustDefinition; logic.m_flameIdleColor = blockDefinition.FlameIdleColor; logic.m_flameFullColor = blockDefinition.FlameFullColor; if (logic.m_flameFullColor != logic.m_flameIdleColor) { logic.m_renderMode = RenderMode.Blended; } foreach (var control in m_customControls) { control.UpdateVisual(); } logic.UpdateFlames(); logic.UpdateCustomData(); } }; resetButton.SupportsMultipleBlocks = true; m_customControls.Add(resetButton); }
public static IMyTerminalAction CreateToggleAction <TBlock>(this IMyTerminalControlCheckbox checkbox) where TBlock : IMyTerminalBlock { return(checkbox.CreateToggleAction <TBlock>(TerminalActionIcons.TOGGLE)); }
public static IMyTerminalControlProperty <bool> CreateProperty <TBlock>(this IMyTerminalControlCheckbox checkbox) where TBlock : IMyTerminalBlock { return(checkbox.CreateProperty <TBlock, bool>()); }
// Context: All public override void UpdateOnceBeforeFrame() { if (me.CubeGrid?.Physics == null) { return; } _state = new SyncableProjectorState(me, State.Idle, 0); if (Constants.IsServer) { LoadStorage(); _settings.OnValueReceived += SaveStorage; BuildState = State.Idle; me.IsWorkingChanged += Me_IsWorkingChanged; } else { _settings = new SyncableProjectorSettings(me, 0, true); _state.RequestFromServer(); _settings.RequestFromServer(); _state.OnValueReceived += ReceivedNewState; } MyProjectorDefinition def = (MyProjectorDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(me.BlockDefinition); minPower = def.RequiredPowerInput; sink = me.Components.Get <MyResourceSinkComponent>(); MyDefinitionId powerDef = MyResourceDistributorComponent.ElectricityId; sink.SetRequiredInputFuncByType(powerDef, GetCurrentPower); sink.Update(); _settings.OnValueReceived += RefreshUI; me.AppendingCustomInfo += CustomInfo; me.RefreshCustomInfo(); Settings.MapSettings config = IPSession.Instance.MapSettings; config.OnSubgridsChanged += ClearCachedComps; config.OnComponentCostModifierChanged += ClearCachedComps; config.OnExtraComponentChanged += ClearCachedComps; config.OnExtraCompCostChanged += ClearCachedComps; if (!controls) { // Terminal controls IMyTerminalControlSeparator sep = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyProjector>("BuildGridSep"); sep.Enabled = IsValid; sep.Visible = IsValid; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sep); IMyTerminalControlButton btnBuild = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("BuildGrid"); btnBuild.Enabled = IsWorking; btnBuild.Visible = IsValid; btnBuild.SupportsMultipleBlocks = true; btnBuild.Title = MyStringId.GetOrCompute("Build Grid"); btnBuild.Action = BuildClient; btnBuild.Tooltip = MyStringId.GetOrCompute("Builds the projection instantly.\nThere will be a cooldown after building."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnBuild); IMyTerminalControlButton btnCancel = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("CancelBuildGrid"); btnCancel.Enabled = IsWorking; btnCancel.Visible = IsValid; btnCancel.SupportsMultipleBlocks = true; btnCancel.Title = MyStringId.GetOrCompute("Cancel"); btnCancel.Action = CancelClient; btnCancel.Tooltip = MyStringId.GetOrCompute("Cancels the build process."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnCancel); IMyTerminalControlCheckbox chkShift = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyProjector>("MoveProjectionArea"); chkShift.Enabled = IsWorking; chkShift.Visible = IsValid; chkShift.SupportsMultipleBlocks = true; chkShift.Title = MyStringId.GetOrCompute("Loose Projection Area"); chkShift.OnText = MyStringId.GetOrCompute("On"); chkShift.OffText = MyStringId.GetOrCompute("Off"); chkShift.Tooltip = MyStringId.GetOrCompute("Allow the projection to spawn in a different area if the original area is occupied."); chkShift.Setter = SetLooseArea; chkShift.Getter = GetLooseArea; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(chkShift); IMyTerminalControlSlider sliderSpeed = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyProjector>("BuildSpeed"); sliderSpeed.Enabled = IsWorking; sliderSpeed.Visible = IsValid; sliderSpeed.SupportsMultipleBlocks = true; sliderSpeed.Title = MyStringId.GetOrCompute("Speed"); sliderSpeed.Tooltip = MyStringId.GetOrCompute("Increasing the speed will use more energy."); sliderSpeed.SetLogLimits(Constants.minSpeed, Constants.maxSpeed); sliderSpeed.Writer = GetSpeedText; sliderSpeed.Getter = GetSpeed; sliderSpeed.Setter = SetSpeed; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sliderSpeed); IMyTerminalControlTextbox txtTimeout = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyProjector>("GridTimer"); txtTimeout.Enabled = (b) => false; txtTimeout.Visible = IsValid; txtTimeout.Getter = GetTimer; txtTimeout.Setter = (b, s) => { }; txtTimeout.SupportsMultipleBlocks = false; txtTimeout.Title = MyStringId.GetOrCompute("Build Timer"); txtTimeout.Tooltip = MyStringId.GetOrCompute("The amount of time you must wait after building a grid to be able to build another."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(txtTimeout); // Terminal actions // Button panels are special and trigger on the server instead of the client, making everything more complicated. IMyTerminalAction aCancel = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildAction"); aCancel.Enabled = IsValid; aCancel.Action = CancelClient; // For all except button panels aCancel.ValidForGroups = true; aCancel.Name = new StringBuilder("Cancel Spawn Grid"); aCancel.Writer = (b, s) => s.Append("Cancel"); aCancel.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList(); MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel); IMyTerminalAction aCancel2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildGrid"); aCancel2.Enabled = IsValid; aCancel2.Action = CancelClientUnsafe; // For only button panels aCancel2.ValidForGroups = true; aCancel2.Name = new StringBuilder("Cancel Spawn Grid"); aCancel2.Writer = (b, s) => s.Append("Cancel"); aCancel2.InvalidToolbarTypes = new List <MyToolbarType> { MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit, MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator }; MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel2); IMyTerminalAction aBuild = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGridAction"); aBuild.Enabled = IsValid; aBuild.Action = BuildClient; // For all except button panels aBuild.ValidForGroups = true; aBuild.Name = new StringBuilder("Spawn Grid"); aBuild.Writer = (b, s) => s.Append("Spawn"); aBuild.InvalidToolbarTypes = new [] { MyToolbarType.ButtonPanel }.ToList(); MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild); IMyTerminalAction aBuild2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGrid"); aBuild2.Enabled = IsValid; aBuild2.Action = BuildClientUnsafe; // For only button panels aBuild2.ValidForGroups = true; aBuild2.Name = new StringBuilder("Spawn Grid"); aBuild2.Writer = (b, s) => s.Append("Spawn"); aBuild2.InvalidToolbarTypes = new List <MyToolbarType> { MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit, MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator }; MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild2); IMyTerminalControlListbox itemList = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyProjector>("ComponentList"); itemList.Enabled = IsWorking; itemList.Visible = IsValid; itemList.ListContent = GetItemList; itemList.Multiselect = false; itemList.SupportsMultipleBlocks = false; itemList.Title = MyStringId.GetOrCompute("Components"); itemList.VisibleRowsCount = 10; itemList.ItemSelected = (b, l) => { }; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemList); // Programmable Block stuff IMyTerminalControlProperty <Dictionary <MyItemType, int> > itemListProp = MyAPIGateway.TerminalControls.CreateProperty <Dictionary <MyItemType, int>, IMyProjector>("RequiredComponents"); itemListProp.Enabled = IsWorking; itemListProp.Visible = IsValid; itemListProp.SupportsMultipleBlocks = false; itemListProp.Setter = (b, l) => { }; itemListProp.Getter = GetItemListPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListProp); IMyTerminalControlProperty <int> gridTimeoutProp = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerProjection"); gridTimeoutProp.Enabled = IsWorking; gridTimeoutProp.Visible = IsValid; gridTimeoutProp.SupportsMultipleBlocks = false; gridTimeoutProp.Setter = (b, l) => { }; gridTimeoutProp.Getter = GetMaxTimerPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutProp); IMyTerminalControlProperty <int> gridTimeoutActive = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerCurrent"); gridTimeoutActive.Enabled = IsWorking; gridTimeoutActive.Visible = IsValid; gridTimeoutActive.SupportsMultipleBlocks = false; gridTimeoutActive.Setter = (b, l) => { }; gridTimeoutActive.Getter = GetCurrentTimerPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive); IMyTerminalControlProperty <int> buildState = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("BuildState"); buildState.Enabled = IsWorking; buildState.Visible = IsValid; buildState.SupportsMultipleBlocks = false; buildState.Setter = (b, l) => { }; buildState.Getter = GetStatePB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive); MyLog.Default.WriteLineAndConsole("Initialized Instant Projector."); controls = true; } }
public static void Create() { if (controls) { return; } IMyTerminalControlSeparator sep = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyProjector>("BuildGridSep"); sep.Enabled = IsValid; sep.Visible = IsValid; sep.SupportsMultipleBlocks = true; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sep); IMyTerminalControlLabel lbl = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlLabel, IMyProjector>("BuildGridLabel"); lbl.Enabled = IsValid; lbl.Visible = IsValid; lbl.SupportsMultipleBlocks = true; lbl.Label = MyStringId.GetOrCompute("Instant Projector Controls"); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(lbl); IMyTerminalControlButton btnBuild = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("BuildGrid"); btnBuild.Enabled = IsWorking; btnBuild.Visible = IsValid; btnBuild.SupportsMultipleBlocks = true; btnBuild.Title = MyStringId.GetOrCompute("Build Grid"); btnBuild.Action = BuildClient; btnBuild.Tooltip = MyStringId.GetOrCompute("Builds the projection instantly.\nThere will be a cooldown after building."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnBuild); IMyTerminalControlButton btnCancel = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("CancelBuildGrid"); btnCancel.Enabled = IsWorking; btnCancel.Visible = IsValid; btnCancel.SupportsMultipleBlocks = true; btnCancel.Title = MyStringId.GetOrCompute("Cancel"); btnCancel.Action = CancelClient; btnCancel.Tooltip = MyStringId.GetOrCompute("Cancels the build process."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnCancel); IMyTerminalControlCheckbox chkShift = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyProjector>("MoveProjectionArea"); chkShift.Enabled = IsWorking; chkShift.Visible = IsValid; chkShift.SupportsMultipleBlocks = true; chkShift.Title = MyStringId.GetOrCompute("Loose Projection Area"); chkShift.OnText = MyStringId.GetOrCompute("On"); chkShift.OffText = MyStringId.GetOrCompute("Off"); chkShift.Tooltip = MyStringId.GetOrCompute("Allow the projection to spawn in a different area if the original area is occupied."); chkShift.Setter = SetLooseArea; chkShift.Getter = GetLooseArea; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(chkShift); IMyTerminalControlSlider sliderSpeed = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyProjector>("BuildSpeed"); sliderSpeed.Enabled = IsWorking; sliderSpeed.Visible = IsValid; sliderSpeed.SupportsMultipleBlocks = true; sliderSpeed.Title = MyStringId.GetOrCompute("Speed"); sliderSpeed.Tooltip = MyStringId.GetOrCompute("Increasing the speed will use more energy."); sliderSpeed.SetLogLimits(Constants.minSpeed, Constants.maxSpeed); sliderSpeed.Writer = GetSpeedText; sliderSpeed.Getter = GetSpeed; sliderSpeed.Setter = SetSpeed; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sliderSpeed); IMyTerminalControlTextbox txtTimeout = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyProjector>("GridTimer"); txtTimeout.Enabled = (b) => false; txtTimeout.Visible = IsValid; txtTimeout.Getter = GetTimer; txtTimeout.Setter = (b, s) => { }; txtTimeout.SupportsMultipleBlocks = false; txtTimeout.Title = MyStringId.GetOrCompute("Build Timer"); txtTimeout.Tooltip = MyStringId.GetOrCompute("The amount of time you must wait after building a grid to be able to build another."); MyAPIGateway.TerminalControls.AddControl <IMyProjector>(txtTimeout); // Terminal actions // Button panels are special and trigger on the server instead of the client, making everything more complicated. IMyTerminalAction aCancel = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildAction"); aCancel.Enabled = IsValid; aCancel.Action = CancelClient; // For all except button panels aCancel.ValidForGroups = true; aCancel.Name = new StringBuilder("Cancel Spawn Grid"); aCancel.Writer = (b, s) => s.Append("Cancel"); aCancel.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList(); MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel); IMyTerminalAction aCancel2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildGrid"); aCancel2.Enabled = IsValid; aCancel2.Action = CancelClientUnsafe; // For only button panels aCancel2.ValidForGroups = true; aCancel2.Name = new StringBuilder("Cancel Spawn Grid"); aCancel2.Writer = (b, s) => s.Append("Cancel"); aCancel2.InvalidToolbarTypes = new List <MyToolbarType> { MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit, MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator }; MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel2); IMyTerminalAction aBuild = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGridAction"); aBuild.Enabled = IsValid; aBuild.Action = BuildClient; // For all except button panels aBuild.ValidForGroups = true; aBuild.Name = new StringBuilder("Spawn Grid"); aBuild.Writer = (b, s) => s.Append("Spawn"); aBuild.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList(); MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild); IMyTerminalAction aBuild2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGrid"); aBuild2.Enabled = IsValid; aBuild2.Action = BuildClientUnsafe; // For only button panels aBuild2.ValidForGroups = true; aBuild2.Name = new StringBuilder("Spawn Grid"); aBuild2.Writer = (b, s) => s.Append("Spawn"); aBuild2.InvalidToolbarTypes = new List <MyToolbarType> { MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit, MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator }; MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild2); IMyTerminalControlListbox itemList = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyProjector>("ComponentList"); itemList.Enabled = IsWorking; itemList.Visible = IsValid; itemList.ListContent = GetItemList; itemList.Multiselect = false; itemList.SupportsMultipleBlocks = false; itemList.Title = MyStringId.GetOrCompute("Components"); itemList.VisibleRowsCount = 10; itemList.ItemSelected = (b, l) => { }; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemList); IMyTerminalControlButton itemListInfo = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("ComponentListInfo"); itemListInfo.Enabled = IsWorking; itemListInfo.Visible = IsValid; itemListInfo.SupportsMultipleBlocks = false; itemListInfo.Title = MyStringId.GetOrCompute("Check Inventory"); itemListInfo.Action = OpenItemList; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListInfo); // Programmable Block stuff IMyTerminalControlProperty <Dictionary <MyItemType, int> > itemListProp = MyAPIGateway.TerminalControls.CreateProperty <Dictionary <MyItemType, int>, IMyProjector>("RequiredComponents"); itemListProp.Enabled = IsWorking; itemListProp.Visible = IsValid; itemListProp.SupportsMultipleBlocks = false; itemListProp.Setter = (b, l) => { }; itemListProp.Getter = GetItemListPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListProp); IMyTerminalControlProperty <int> gridTimeoutProp = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerProjection"); gridTimeoutProp.Enabled = IsWorking; gridTimeoutProp.Visible = IsValid; gridTimeoutProp.SupportsMultipleBlocks = false; gridTimeoutProp.Setter = (b, l) => { }; gridTimeoutProp.Getter = GetMaxTimerPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutProp); IMyTerminalControlProperty <int> gridTimeoutActive = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerCurrent"); gridTimeoutActive.Enabled = IsWorking; gridTimeoutActive.Visible = IsValid; gridTimeoutActive.SupportsMultipleBlocks = false; gridTimeoutActive.Setter = (b, l) => { }; gridTimeoutActive.Getter = GetCurrentTimerPB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive); IMyTerminalControlProperty <int> buildState = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("BuildState"); buildState.Enabled = IsWorking; buildState.Visible = IsValid; buildState.SupportsMultipleBlocks = false; buildState.Setter = (b, l) => { }; buildState.Getter = GetStatePB; MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive); MyLog.Default.WriteLineAndConsole("Initialized Instant Projector."); controls = true; }
private void CreateControls() { // Actions IMyTerminalAction toggleWarp = MyAPIGateway.TerminalControls.CreateAction <IMyUpgradeModule>("ToggleWarp"); toggleWarp.Enabled = IsWarpDrive; toggleWarp.Name = new StringBuilder("Toggle Warp"); toggleWarp.Action = ToggleWarp; toggleWarp.Icon = "Textures\\GUI\\Icons\\Actions\\Toggle.dds"; toggleWarp.Writer = GetWarpStatusText; MyAPIGateway.TerminalControls.AddAction <IMyUpgradeModule>(toggleWarp); IMyTerminalAction toggleSafety = MyAPIGateway.TerminalControls.CreateAction <IMyUpgradeModule>("ToggleSafety"); toggleSafety.Enabled = IsWarpDrive; toggleSafety.Name = new StringBuilder("Toggle Safety"); toggleSafety.Action = ToggleSafety; toggleSafety.Icon = "Textures\\GUI\\Icons\\Actions\\Toggle.dds"; toggleSafety.Writer = GetSafetyText; MyAPIGateway.TerminalControls.AddAction <IMyUpgradeModule>(toggleSafety); // Controls IMyTerminalControlButton startWarpBtn = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyUpgradeModule>("StartWarpBtn"); startWarpBtn.Tooltip = MyStringId.GetOrCompute("Toggles the status of the warp drives on the ship"); startWarpBtn.Title = MyStringId.GetOrCompute("Toggle Warp"); startWarpBtn.Enabled = IsWarpDrive; startWarpBtn.Visible = IsWarpDrive; startWarpBtn.SupportsMultipleBlocks = false; startWarpBtn.Action = ToggleWarp; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(startWarpBtn); IMyTerminalControlCheckbox safetyCheckbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyUpgradeModule>("Safety"); safetyCheckbox.Tooltip = MyStringId.GetOrCompute("When checked, the warp drive will not function without a player on the ship."); safetyCheckbox.Title = MyStringId.GetOrCompute("Safety"); safetyCheckbox.OffText = MyStringId.GetOrCompute("Off"); safetyCheckbox.OnText = MyStringId.GetOrCompute("On"); safetyCheckbox.Enabled = IsWarpDrive; safetyCheckbox.Visible = IsWarpDrive; safetyCheckbox.SupportsMultipleBlocks = false; safetyCheckbox.Setter = SetWarpSafety; safetyCheckbox.Getter = GetWarpSafety; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(safetyCheckbox); // Pb Properties IMyTerminalControlProperty <bool> inWarp = MyAPIGateway.TerminalControls.CreateProperty <bool, IMyUpgradeModule>("WarpStatus"); inWarp.Enabled = IsWarpDrive; inWarp.Visible = IsWarpDrive; inWarp.SupportsMultipleBlocks = false; inWarp.Setter = SetWarpStatus; inWarp.Getter = GetWarpStatus; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(inWarp); IMyTerminalControlProperty <bool> warpSafetyProp = MyAPIGateway.TerminalControls.CreateProperty <bool, IMyUpgradeModule>("WarpSafety"); warpSafetyProp.Enabled = IsWarpDrive; warpSafetyProp.Visible = IsWarpDrive; warpSafetyProp.SupportsMultipleBlocks = false; warpSafetyProp.Setter = SetWarpSafety; warpSafetyProp.Getter = GetWarpSafety; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(warpSafetyProp); IMyTerminalControlProperty <float> heatPercent = MyAPIGateway.TerminalControls.CreateProperty <float, IMyUpgradeModule>("WarpHeat"); heatPercent.Enabled = IsWarpDrive; heatPercent.Visible = IsWarpDrive; heatPercent.SupportsMultipleBlocks = false; heatPercent.Setter = (x, y) => { }; heatPercent.Getter = GetWarpHeat; MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(heatPercent); }