Example #1
0
        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 MyProgrammableBlock()
        {
            var console = new MyTerminalControlButton<MyProgrammableBlock>("Edit", MySpaceTexts.TerminalControlPanel_EditCode, MySpaceTexts.TerminalControlPanel_EditCode_Tooltip, (b) => b.SyncObject.SendOpenEditorRequest(Sync.MyId));
            console.Visible = (b) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts;
            MyTerminalControlFactory.AddControl(console);

            var arg = new MyTerminalControlTextbox<MyProgrammableBlock>("ConsoleCommand", MySpaceTexts.TerminalControlPanel_RunArgument, MySpaceTexts.TerminalControlPanel_RunArgument_ToolTip);
            arg.Visible = (e) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts;
            arg.Getter = (e) => new StringBuilder(e.TerminalRunArgument);
            arg.Setter = (e, v) => e.TerminalRunArgument = v.ToString();
            MyTerminalControlFactory.AddControl(arg);
            
            var terminalRun = new MyTerminalControlButton<MyProgrammableBlock>("TerminalRun", MySpaceTexts.TerminalControlPanel_RunCode, MySpaceTexts.TerminalControlPanel_RunCode_Tooltip, (b) => b.Run());
            terminalRun.Visible = (b) => MyFakes.ENABLE_PROGRAMMABLE_BLOCK && MySession.Static.EnableIngameScripts;
            terminalRun.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddControl(terminalRun);
            
            var runAction = new MyTerminalAction<MyProgrammableBlock>("Run", MyTexts.Get(MySpaceTexts.TerminalControlPanel_RunCode), OnRunApplied, null, MyTerminalActionIcons.START);
            runAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            runAction.DoUserParameterRequest = RequestRunArgument;
            runAction.ParameterDefinitions.Add(TerminalActionParameter.Get(string.Empty));
            MyTerminalControlFactory.AddAction(runAction);

            var runwithDefault = new MyTerminalAction<MyProgrammableBlock>("RunWithDefaultArgument", MyTexts.Get(MySpaceTexts.TerminalControlPanel_RunCodeDefault), OnRunDefaultApplied, MyTerminalActionIcons.START);
            runwithDefault.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(runwithDefault);
        }
Example #3
0
        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 MyTerminalBlock()
        {
            var show = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip);
            show.Getter = (x) => x.m_showInTerminal;
            show.Setter = (x, v) => x.RequestShowInTerminal(v);
            MyTerminalControlFactory.AddControl(show);

            var customName = new MyTerminalControlTextbox<MyTerminalBlock>("Name", MySpaceTexts.Name, MySpaceTexts.Blank);
            customName.Getter = (x) => x.CustomName;
            customName.Setter = (x, v) => MySyncBlockHelpers.SendChangeNameRequest(x, v);
            customName.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(customName);

            var onOffSwitch = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowOnHUD", MySpaceTexts.Terminal_ShowOnHUD, MySpaceTexts.Terminal_ShowOnHUDToolTip);
            onOffSwitch.Getter = (x) => x.ShowOnHUD;
            onOffSwitch.Setter = (x, v) => x.RequestShowOnHUD(v);
            MyTerminalControlFactory.AddControl(onOffSwitch);
        }
        static MyTerminalBlock()
        {
            var show = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip);
            show.Getter = (x) => x.m_showInTerminal;
            show.Setter = (x, v) => x.ShowInTerminal = v;
            MyTerminalControlFactory.AddControl(show);

            var showConfig = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip);
            showConfig.Getter = (x) => x.m_showInToolbarConfig;
            showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v;
            MyTerminalControlFactory.AddControl(showConfig);

            var customName = new MyTerminalControlTextbox<MyTerminalBlock>("Name", MyCommonTexts.Name, MySpaceTexts.Blank);
            customName.Getter = (x) => x.CustomName;
            customName.Setter = (x, v) => x.SetCustomName(v);
            customName.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(customName);

            var onOffSwitch = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowOnHUD", MySpaceTexts.Terminal_ShowOnHUD, MySpaceTexts.Terminal_ShowOnHUDToolTip);
            onOffSwitch.Getter = (x) => x.ShowOnHUD;
            onOffSwitch.Setter = (x, v) => x.ShowOnHUD = v;
            MyTerminalControlFactory.AddControl(onOffSwitch);
        }
Example #6
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyButtonPanel>())
                return;

            var checkAccess = new MyTerminalControlCheckbox<MyButtonPanel>("AnyoneCanUse", MySpaceTexts.BlockPropertyText_AnyoneCanUse, MySpaceTexts.BlockPropertyDescription_AnyoneCanUse);
            checkAccess.Getter = (x) => x.AnyoneCanUse;
            checkAccess.Setter = (x, v) => x.AnyoneCanUse = v;
            checkAccess.EnableAction();
            MyTerminalControlFactory.AddControl(checkAccess);

            var toolbarButton = new MyTerminalControlButton<MyButtonPanel>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_SensorToolbarOpen, MySpaceTexts.BlockPropertyDescription_SensorToolbarOpen,
                delegate(MyButtonPanel 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 buttonsList = new MyTerminalControlListbox<MyButtonPanel>("ButtonText", MySpaceTexts.BlockPropertyText_ButtonList, MySpaceTexts.Blank);
            buttonsList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2);
            buttonsList.ItemSelected = (x, y) => x.SelectButtonToName(y);
            MyTerminalControlFactory.AddControl(buttonsList);

            var customButtonName = new MyTerminalControlTextbox<MyButtonPanel>("ButtonName", MySpaceTexts.BlockPropertyText_ButtonName, MySpaceTexts.Blank);
            customButtonName.Getter = (x) => x.GetButtonName();
            customButtonName.Setter = (x, v) => x.SetCustomButtonName(v);
            customButtonName.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(customButtonName);
        }
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyTextPanel>())
                return;

            var publicTitleField = new MyTerminalControlTextbox<MyTextPanel>("PublicTitle", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank);
            publicTitleField.Getter = (x) => x.PublicTitle;
            publicTitleField.Setter = (x, v) => x.SendChangeTitleMessage(v, true);
            publicTitleField.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(publicTitleField);

            var showPublicButton = new MyTerminalControlButton<MyTextPanel>("ShowPublicTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true));
            showPublicButton.Enabled = (x) => !x.IsOpen;
            showPublicButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showPublicButton);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyTextPanel>());

            var titleField = new MyTerminalControlTextbox<MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelTitle, MySpaceTexts.Blank);
            titleField.Getter = (x) => x.PrivateTitle;
            titleField.Setter = (x, v) => x.SendChangeTitleMessage(v, false);
            titleField.SupportsMultipleBlocks = false;

            MyTerminalControlFactory.AddControl(titleField);

            var showButton = new MyTerminalControlButton<MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, false));
            showButton.Enabled = (x) => !x.IsOpen;
            showButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showButton);

            var comboAccess = new MyTerminalControlCombobox<MyTextPanel>("Access", MySpaceTexts.BlockPropertyTitle_TextPanelAccessType, MySpaceTexts.Blank);
            comboAccess.ComboBoxContent = (x) => FillComboBoxContent(x);
            comboAccess.Getter = (x) => (long)x.AccessFlag;
            comboAccess.Setter = (x, y) => x.AccessFlag = (TextPanelAccessFlag)y;
            comboAccess.Enabled = (x) => x.OwnerId != 0;
            comboAccess.SetSerializerRange(0, (int)TextPanelAccessFlag.READ_AND_WRITE_ALL);
            MyTerminalControlFactory.AddControl(comboAccess);
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyTextPanel>());

            var showTextOnScreen = new MyTerminalControlCombobox<MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank);
            showTextOnScreen.ComboBoxContent = (x) => FillShowOnScreenComboBoxContent(x);
            showTextOnScreen.Getter = (x) => (long)x.ShowTextFlag;
            showTextOnScreen.Setter = (x, y) => x.ShowTextFlag = (ShowTextOnScreenFlag)y;
            showTextOnScreen.Enabled = (x) => x.OwnerId != 0;

            MyTerminalControlFactory.AddControl(showTextOnScreen);

            var changeFontSlider = new MyTerminalControlSlider<MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank);
            changeFontSlider.SetLimits(0.1f, 10.0f);
            changeFontSlider.DefaultValue = 1.0f;
            changeFontSlider.Getter = (x) => x.FontSize;
            changeFontSlider.Setter = (x, v) => x.FontSize = v;
            changeFontSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, 1));
            changeFontSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeFontSlider);

            var fontColor = new MyTerminalControlColor<MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor);
            fontColor.Getter = (x) => x.FontColor;
            fontColor.Setter = (x, v) => x.FontColor = v;
            MyTerminalControlFactory.AddControl(fontColor);

            var backgroundColor = new MyTerminalControlColor<MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor);
            backgroundColor.Getter = (x) => x.BackgroundColor;
            backgroundColor.Setter = (x, v) => x.BackgroundColor = v;
            MyTerminalControlFactory.AddControl(backgroundColor);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyTextPanel>());

            var imagesList = new MyTerminalControlListbox<MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true);
            imagesList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2);
            imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y);
            MyTerminalControlFactory.AddControl(imagesList);

            var addToSelectionButton = new MyTerminalControlButton<MyTextPanel>("SelectTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectTextures, MySpaceTexts.Blank, (x) => x.AddImagesToSelection());
            MyTerminalControlFactory.AddControl(addToSelectionButton);

            var changeIntervalSlider = new MyTerminalControlSlider<MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank);
            changeIntervalSlider.SetLimits(0, 30.0f);
            changeIntervalSlider.DefaultValue = 0;
            changeIntervalSlider.Getter = (x) => x.ChangeInterval;
            changeIntervalSlider.Setter = (x, v) => x.ChangeInterval = v;
            changeIntervalSlider.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s");
            changeIntervalSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeIntervalSlider);

            var selectedImagesList = new MyTerminalControlListbox<MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true);
            selectedImagesList.ListContent = (x, list1, list2) => x.FillSelectedListContent(list1, list2);
            selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y);
            MyTerminalControlFactory.AddControl(selectedImagesList);

            var removeSelectedButton = new MyTerminalControlButton<MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection());
            MyTerminalControlFactory.AddControl(removeSelectedButton);
        }
Example #8
0
        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);

        }
Example #9
0
        protected override void CreateTerminalControls()
        {
            /*MyTerminalControlFactory.RemoveBaseClass<MyLaserAntenna, MyTerminalBlock>();

            var customName = new MyTerminalControlTextbox<MyLaserAntenna>("CustomName", MySpaceTexts.Name, MySpaceTexts.Blank);
            customName.Getter = (x) => x.CustomName;
            customName.Setter = (x, v) => MySyncBlockHelpers.SendChangeNameRequest(x, v);
            customName.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(customName);*/

            if (MyTerminalControlFactory.AreControlsCreated<MyLaserAntenna>())
                return;
            base.CreateTerminalControls();
            idleButton = new MyTerminalControlButton<MyLaserAntenna>("Idle", MySpaceTexts.LaserAntennaIdleButton, MySpaceTexts.Blank,
                delegate (MyLaserAntenna self)
                {
                    self.SetIdle();
                    idleButton.UpdateVisual();
                });
            idleButton.Enabled = (x) => x.m_state != StateEnum.idle;
            idleButton.EnableAction();
            MyTerminalControlFactory.AddControl(idleButton);

            //--------------------------------------------------------------------------------------
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyLaserAntenna>());

            var copyCoordsButton = new MyTerminalControlButton<MyLaserAntenna>("CopyCoords", MySpaceTexts.LaserAntennaCopyCoords, MySpaceTexts.LaserAntennaCopyCoordsHelp,
                delegate (MyLaserAntenna self)
                {
                    StringBuilder sanitizedName = new StringBuilder(self.DisplayNameText);
                    sanitizedName.Replace(':', ' ');
                    StringBuilder sb = new StringBuilder("GPS:", 256);
                    sb.Append(sanitizedName); sb.Append(":");
                    sb.Append(Math.Round(self.HeadPos.X, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
                    sb.Append(Math.Round(self.HeadPos.Y, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
                    sb.Append(Math.Round(self.HeadPos.Z, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
#if !XB1
                    Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(sb.ToString()));
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
#else
                    Debug.Assert(false, "Not Clipboard support on XB1!");
#endif
                });
            MyTerminalControlFactory.AddControl(copyCoordsButton);

            var copyTargetCoordsButton = new MyTerminalControlButton<MyLaserAntenna>("CopyTargetCoords", MySpaceTexts.LaserAntennaCopyTargetCoords, MySpaceTexts.LaserAntennaCopyTargetCoordsHelp,
                delegate (MyLaserAntenna self)
                {
                    if (self.m_targetId == null)
                        return;
                    StringBuilder sanitizedName = new StringBuilder(self.m_lastKnownTargetName.ToString());
                    sanitizedName.Replace(':', ' ');
                    StringBuilder sb = new StringBuilder("GPS:", 256);
                    sb.Append(sanitizedName); sb.Append(":");
                    sb.Append(Math.Round(self.m_targetCoords.X, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
                    sb.Append(Math.Round(self.m_targetCoords.Y, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
                    sb.Append(Math.Round(self.m_targetCoords.Z, 2).ToString(System.Globalization.CultureInfo.InvariantCulture)); sb.Append(":");
#if !XB1
                    Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(sb.ToString()));
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
#else
                    Debug.Assert(false, "Not Clipboard support on XB1!");
#endif
                });
            copyTargetCoordsButton.Enabled = (x) => x.m_targetId != null;
            MyTerminalControlFactory.AddControl(copyTargetCoordsButton);

            PasteGpsCoords = new MyTerminalControlButton<MyLaserAntenna>("PasteGpsCoords", MySpaceTexts.LaserAntennaPasteGPS, MySpaceTexts.Blank,
                delegate (MyLaserAntenna self)
                {
                    Thread thread = new Thread(() => PasteFromClipboard());
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                    self.PasteCoordinates(m_clipboardText);
                });
            //PasteGpsCoords.Enabled = (x) => x.P2PTargetCoords;
            PasteGpsCoords.EnableAction();
            MyTerminalControlFactory.AddControl(PasteGpsCoords);

            gpsCoords = new MyTerminalControlTextbox<MyLaserAntenna>("gpsCoords", MySpaceTexts.LaserAntennaSelectedCoords, MySpaceTexts.Blank);
            gpsCoords.Getter = (x) => x.m_termGpsName;
            gpsCoords.Enabled = (x) => false;
            MyTerminalControlFactory.AddControl(gpsCoords);

            connectGPS = new MyTerminalControlButton<MyLaserAntenna>("ConnectGPS", MySpaceTexts.LaserAntennaConnectGPS, MySpaceTexts.Blank,
                delegate (MyLaserAntenna self)
                {
                    if (self.m_termGpsCoords == null)
                        return;//should not get here anyway
                    self.ConnectToGps();
                });
            connectGPS.Enabled = (x) => x.CanConnectToGPS();
            connectGPS.EnableAction();
            MyTerminalControlFactory.AddControl(connectGPS);

            var isPerm = new MyTerminalControlCheckbox<MyLaserAntenna>("isPerm", MySpaceTexts.LaserAntennaPermanentCheckbox, MySpaceTexts.Blank);
            isPerm.Getter = (self) => self.m_IsPermanent;
            isPerm.Setter = (self, v) =>
            {
                self.ChangePerm(v);
            };
            isPerm.Enabled = (self) => self.State == StateEnum.connected;
            isPerm.EnableAction();
            MyTerminalControlFactory.AddControl(isPerm);

            //--------------------------------------------------------------------------------------
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyLaserAntenna>());

            receiversList = new MyTerminalControlListbox<MyLaserAntenna>("receiversList", MySpaceTexts.LaserAntennaReceiversList, MySpaceTexts.LaserAntennaReceiversListHelp);
            receiversList.ListContent = (x, population, selected) => x.PopulatePossibleReceivers(population, selected);
            receiversList.ItemSelected = (x, y) => x.ReceiverSelected(y);
            //receiversList.Enabled = (x) => !x.P2PTargetCoords;
            MyTerminalControlFactory.AddControl(receiversList);

            ConnectReceiver = new MyTerminalControlButton<MyLaserAntenna>("ConnectReceiver", MySpaceTexts.LaserAntennaConnectButton, MySpaceTexts.Blank,
                delegate (MyLaserAntenna self)
                {
                    self.ConnectToId();
                });
            ConnectReceiver.Enabled = (x) => x.m_selectedEntityId != null;
            MyTerminalControlFactory.AddControl(ConnectReceiver);
        }
Example #10
0
        /// <summary>
        /// Control creation was moved from the static ctor into this static function.  Control creation should still be static, but static ctors
        /// only ever get called once, which means we can never modify these controls (remove), since they will be removed forever.  All classes
        /// that inherit MyTerminalBlock should put terminal control creation in a function called CreateTerminalControls, as MyTerminalControlFactory 
        /// will properly ensure their base classes' controls are added in.  I can't make this virtual because terminal controls don't deal with instances
        /// directly (this should probably change)
        /// 
        /// GR: Had to change this from static due to parallelization issues with multuple threads. Now it should run only once.
        /// </summary>
        protected virtual void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyTerminalBlock>())
                return;

            var show = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip);
            show.Getter = (x) => x.m_showInTerminal;
            show.Setter = (x, v) => x.ShowInTerminal = v;
            MyTerminalControlFactory.AddControl(show);

            var showInInventory = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInInventory", MySpaceTexts.Terminal_ShowInInventory, MySpaceTexts.Terminal_ShowInInventoryToolTip);
            showInInventory.Getter = (x) => x.m_showInInventory;
            showInInventory.Setter = (x, v) => x.ShowInInventory = v;
            showInInventory.Visible = (x) => x.HasInventory;
            MyTerminalControlFactory.AddControl(showInInventory);

            var showConfig = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip);
            showConfig.Getter = (x) => x.m_showInToolbarConfig;
            showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v;
            MyTerminalControlFactory.AddControl(showConfig);

            var customName = new MyTerminalControlTextbox<MyTerminalBlock>("Name", MyCommonTexts.Name, MySpaceTexts.Blank);
            customName.Getter = (x) => x.CustomName;
            customName.Setter = (x, v) => x.SetCustomName(v);
            customName.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(customName);

            var onOffSwitch = new MyTerminalControlOnOffSwitch<MyTerminalBlock>("ShowOnHUD", MySpaceTexts.Terminal_ShowOnHUD, MySpaceTexts.Terminal_ShowOnHUDToolTip);
            onOffSwitch.Getter = (x) => x.ShowOnHUD;
            onOffSwitch.Setter = (x, v) => x.ShowOnHUD = v;
            MyTerminalControlFactory.AddControl(onOffSwitch);
        }