Example #1
0
        static MyGasTank()
        {
            var isStockpiling = new MyTerminalControlOnOffSwitch <MyGasTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile)
            {
                Getter = (x) => x.IsStockpiling,
                Setter = (x, v) => x.SyncObject.ChangeStockpileMode(v)
            };

            isStockpiling.EnableToggleAction();
            isStockpiling.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isStockpiling);

            var refillButton = new MyTerminalControlButton <MyGasTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed)
            {
                Enabled = (x) => x.CanRefill()
            };

            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox <MyGasTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill)
            {
                Getter = (x) => x.m_autoRefill,
                Setter = (x, v) => x.SyncObject.ChangeAutoRefill(v)
            };

            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyGasTank>())
            {
                return;
            }
            base.CreateTerminalControls();
            var isStockpiling = new MyTerminalControlOnOffSwitch <MyGasTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile)
            {
                Getter = (x) => x.IsStockpiling,
                Setter = (x, v) => x.ChangeStockpileMode(v)
            };

            isStockpiling.EnableToggleAction();
            isStockpiling.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isStockpiling);

            var refillButton = new MyTerminalControlButton <MyGasTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed)
            {
                Enabled = (x) => x.CanRefill()
            };

            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox <MyGasTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill)
            {
                Getter = (x) => x.m_autoRefill,
                Setter = (x, v) => x.ChangeAutoRefill(v)
            };

            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
 static MyAirtightDoorGeneric()
 {
     var open = new MyTerminalControlOnOffSwitch<MyAirtightDoorGeneric>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);
     open.Getter = (x) => x.Open;
     open.Setter = (x, v) => x.m_open.Value = v;
     open.EnableToggleAction();
     open.EnableOnOffActions();
     MyTerminalControlFactory.AddControl(open);
 }
Example #4
0
        static MyAirVent()
        {
            var isDepressurizing = new MyTerminalControlOnOffSwitch <MyAirVent>("Depressurize", MySpaceTexts.BlockPropertyTitle_Depressurize, MySpaceTexts.BlockPropertyDescription_Depressurize);

            isDepressurizing.Getter = (x) => (x as MyAirVent).IsDepressurizing;
            isDepressurizing.Setter = (x, v) => (x as MyAirVent).SyncObject.ChangeDepressurizationMode(v);
            isDepressurizing.EnableToggleAction();
            isDepressurizing.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isDepressurizing);
        }
Example #5
0
        static MyAirtightDoorGeneric()
        {
            var open = new MyTerminalControlOnOffSwitch <MyAirtightDoorGeneric>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);

            open.Getter = (x) => x.Open;
            open.Setter = (x, v) => x.ChangeOpenClose(v);
            open.EnableToggleAction();
            open.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(open);
        }
Example #6
0
        static MyAdvancedDoor()
        {
            var open = new MyTerminalControlOnOffSwitch <MyAdvancedDoor>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);

            open.Getter = (x) => x.Open;
            open.Setter = (x, v) => x.m_sync.SendChangeDoorRequest(v, x.OwnerId);
            open.EnableToggleAction();
            open.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(open);
        }
Example #7
0
        static MyJumpDrive()
        {
            var jumpButton = new MyTerminalControlButton<MyJumpDrive>("Jump", MySpaceTexts.BlockActionTitle_Jump, MySpaceTexts.Blank, (x) => x.RequestJump());
            jumpButton.Enabled = (x) => x.CanJump;
            jumpButton.SupportsMultipleBlocks = false;
            // Can only be called from toolbar of cockpit
            jumpButton.Visible = (x) => false;
            var action = jumpButton.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel, MyToolbarType.Character, MyToolbarType.Seat };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(jumpButton);

            var recharging = new MyTerminalControlOnOffSwitch<MyJumpDrive>("Recharge", MySpaceTexts.BlockPropertyTitle_Recharge, MySpaceTexts.Blank);
            recharging.Getter = (x) => x.m_isRecharging;
            recharging.Setter = (x, v) => x.SetRecharging(v);
            recharging.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(recharging);

            var maxDistanceSlider = new MyTerminalControlSlider<MyJumpDrive>("JumpDistance", MySpaceTexts.BlockPropertyTitle_JumpDistance, MySpaceTexts.Blank);
            maxDistanceSlider.SetLimits(0f, 100f);
            maxDistanceSlider.DefaultValue = 100f;
            maxDistanceSlider.Enabled = (x) => x.CanJump;
            maxDistanceSlider.Getter = (x) => x.m_jumpDistanceRatio;
            maxDistanceSlider.Setter = (x, v) =>
                {
                    x.SetJumpDistanceRatio(v);
                };
            maxDistanceSlider.Writer = (x, v) =>
                {
                    v.AppendFormatedDecimal((x.m_jumpDistanceRatio / 100f).ToString("P0") + " (", (float)x.ComputeMaxDistance() / 1000f, 0, " km").Append(")");
                };
            maxDistanceSlider.EnableActions(0.01f);
            MyTerminalControlFactory.AddControl(maxDistanceSlider);


            var selectedTarget = new MyTerminalControlListbox<MyJumpDrive>("SelectedTarget", MySpaceTexts.BlockPropertyTitle_DestinationGPS, MySpaceTexts.Blank, false, 1);
            selectedTarget.ListContent = (x, list1, list2) => x.FillSelectedTarget(list1, list2);
            MyTerminalControlFactory.AddControl(selectedTarget);

            var removeBtn = new MyTerminalControlButton<MyJumpDrive>("RemoveBtn", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (x) => x.RemoveSelected());
            removeBtn.Enabled = (x) => x.CanRemove();
            MyTerminalControlFactory.AddControl(removeBtn);

            var selectBtn = new MyTerminalControlButton<MyJumpDrive>("SelectBtn", MySpaceTexts.SelectBlueprint, MySpaceTexts.Blank, (x) => x.SelectTarget());
            selectBtn.Enabled = (x) => x.CanSelect();
            MyTerminalControlFactory.AddControl(selectBtn);

            var gpsList = new MyTerminalControlListbox<MyJumpDrive>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);
            gpsList.ListContent = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            MyTerminalControlFactory.AddControl(gpsList);
        }
        static MyFunctionalBlock()
        {
            var onOffSwitch = new MyTerminalControlOnOffSwitch<MyFunctionalBlock>("OnOff", MySpaceTexts.BlockAction_Toggle);
            onOffSwitch.Getter = (x) => x.Enabled;
            onOffSwitch.Setter = (x, v) => x.RequestEnable(v);
            onOffSwitch.EnableToggleAction();
            onOffSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(0, onOffSwitch);

            MyTerminalControlFactory.AddControl(1, new MyTerminalControlSeparator<MyTerminalBlock>());
        }
Example #9
0
 protected override void CreateTerminalControls()
 {
     if (MyTerminalControlFactory.AreControlsCreated<MyDoorBase>())
         return;
     base.CreateTerminalControls();
     var open = new MyTerminalControlOnOffSwitch<MyDoorBase>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);
     open.Getter = (x) => x.Open;
     open.Setter = (x, v) => x.SetOpenRequest(v, x.OwnerId);
     open.EnableToggleAction();
     open.EnableOnOffActions();
     MyTerminalControlFactory.AddControl(open);
 }
Example #10
0
        static MyFunctionalBlock()
        {
            var onOffSwitch = new MyTerminalControlOnOffSwitch <MyFunctionalBlock>("OnOff", MySpaceTexts.BlockAction_Toggle);

            onOffSwitch.Getter = (x) => x.Enabled;
            onOffSwitch.Setter = (x, v) => x.Enabled = v;
            onOffSwitch.EnableToggleAction();
            onOffSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(0, onOffSwitch);

            MyTerminalControlFactory.AddControl(1, new MyTerminalControlSeparator <MyTerminalBlock>());
        }
Example #11
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyFunctionalBlock>())
                return;

            var onOffSwitch = new MyTerminalControlOnOffSwitch<MyFunctionalBlock>("OnOff", MySpaceTexts.BlockAction_Toggle);
            onOffSwitch.Getter = (x) => x.Enabled;
            onOffSwitch.Setter = (x, v) => x.Enabled = v;
            onOffSwitch.EnableToggleAction();
            onOffSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(0, onOffSwitch);

            MyTerminalControlFactory.AddControl(1, new MyTerminalControlSeparator<MyFunctionalBlock>());
        }
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyAirtightDoorGeneric>())
            {
                return;
            }

            var open = new MyTerminalControlOnOffSwitch <MyAirtightDoorGeneric>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);

            open.Getter = (x) => x.Open;
            open.Setter = (x, v) => x.m_open.Value = v;
            open.EnableToggleAction();
            open.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(open);
        }
Example #13
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyAdvancedDoor>())
            {
                return;
            }

            var open = new MyTerminalControlOnOffSwitch <MyAdvancedDoor>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);

            open.Getter = (x) => x.Open;
            open.Setter = (x, v) => x.SetOpenRequest(v, x.OwnerId);
            open.EnableToggleAction();
            open.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(open);
        }
Example #14
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyAirVent>())
            {
                return;
            }
            base.CreateTerminalControls();
            var isDepressurizing = new MyTerminalControlOnOffSwitch <MyAirVent>("Depressurize", MySpaceTexts.BlockPropertyTitle_Depressurize, MySpaceTexts.BlockPropertyDescription_Depressurize);

            isDepressurizing.Getter = (x) => x.IsDepressurizing;
            isDepressurizing.Setter = (x, v) => { x.IsDepressurizing = v; x.UpdateEmissivity(); };
            isDepressurizing.EnableToggleAction();
            isDepressurizing.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isDepressurizing);

            var toolbarButton = new MyTerminalControlButton <MyAirVent>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_SensorToolbarOpen, MySpaceTexts.BlockPropertyDescription_SensorToolbarOpen,
                                                                        delegate(MyAirVent self)
            {
                if (self.m_onFullAction != null)
                {
                    self.m_actionToolbar.SetItemAtIndex(0, self.m_onFullAction);
                }
                if (self.m_onEmptyAction != null)
                {
                    self.m_actionToolbar.SetItemAtIndex(1, self.m_onEmptyAction);
                }

                self.m_actionToolbar.ItemChanged += self.Toolbar_ItemChanged;
                if (MyGuiScreenCubeBuilder.Static == null)
                {
                    MyToolbarComponent.CurrentToolbar = self.m_actionToolbar;
                    MyGuiScreenBase screen            = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                    MyToolbarComponent.AutoUpdate     = false;

                    screen.Closed += (source) =>
                    {
                        MyToolbarComponent.AutoUpdate     = true;
                        self.m_actionToolbar.ItemChanged -= self.Toolbar_ItemChanged;
                        self.m_actionToolbar.Clear();
                    };
                    MyGuiSandbox.AddScreen(screen);
                }
            });

            toolbarButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(toolbarButton);
        }
Example #15
0
 private static void CreateTerminalControls()
 {
     if (!MyTerminalControlFactory.AreControlsCreated <MyAdvancedDoor>())
     {
         MyStringId tooltip = new MyStringId();
         MyTerminalControlOnOffSwitch <MyAdvancedDoor> switch1 = new MyTerminalControlOnOffSwitch <MyAdvancedDoor>("Open", MySpaceTexts.Blank, tooltip, new MyStringId?(MySpaceTexts.BlockAction_DoorOpen), new MyStringId?(MySpaceTexts.BlockAction_DoorClosed));
         MyTerminalControlOnOffSwitch <MyAdvancedDoor> switch2 = new MyTerminalControlOnOffSwitch <MyAdvancedDoor>("Open", MySpaceTexts.Blank, tooltip, new MyStringId?(MySpaceTexts.BlockAction_DoorOpen), new MyStringId?(MySpaceTexts.BlockAction_DoorClosed));
         switch2.Getter = x => x.Open;
         MyTerminalControlOnOffSwitch <MyAdvancedDoor> local4 = switch2;
         MyTerminalControlOnOffSwitch <MyAdvancedDoor> local5 = switch2;
         local5.Setter = (x, v) => x.SetOpenRequest(v, x.OwnerId);
         MyTerminalControlOnOffSwitch <MyAdvancedDoor> onOff = local5;
         onOff.EnableToggleAction <MyAdvancedDoor>();
         onOff.EnableOnOffActions <MyAdvancedDoor>();
         MyTerminalControlFactory.AddControl <MyAdvancedDoor>(onOff);
     }
 }
        static MyUserControllableGun()
        {
            if (MyFakes.ENABLE_WEAPON_TERMINAL_CONTROL)
            {
                var shootOnce = new MyTerminalControlButton <MyUserControllableGun>("ShootOnce", MySpaceTexts.Terminal_ShootOnce, MySpaceTexts.Blank, (b) => b.OnShootOncePressed());
                shootOnce.EnableAction();
                MyTerminalControlFactory.AddControl(shootOnce);

                var shoot = new MyTerminalControlOnOffSwitch <MyUserControllableGun>("Shoot", MySpaceTexts.Terminal_Shoot);
                shoot.Getter = (x) => x.m_isShooting;
                shoot.Setter = (x, v) => x.OnShootPressed(v);
                shoot.EnableToggleAction();
                shoot.EnableOnOffActions();
                MyTerminalControlFactory.AddControl(shoot);
                MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyUserControllableGun>());
            }
        }
        static MyUserControllableGun()
        {
            if (MyFakes.ENABLE_WEAPON_TERMINAL_CONTROL)
            {
                var shootOnce = new MyTerminalControlButton<MyUserControllableGun>("ShootOnce", MySpaceTexts.Terminal_ShootOnce, MySpaceTexts.Blank, (b) => b.OnShootOncePressed());
                shootOnce.EnableAction();
                MyTerminalControlFactory.AddControl(shootOnce);

                var shoot = new MyTerminalControlOnOffSwitch<MyUserControllableGun>("Shoot", MySpaceTexts.Terminal_Shoot);
                shoot.Getter = (x) => x.m_isShooting;
                shoot.Setter = (x, v) => x.OnShootPressed(v);
                shoot.EnableToggleAction();
                shoot.EnableOnOffActions();
                MyTerminalControlFactory.AddControl(shoot);
                MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyUserControllableGun>());
            }
        }
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyFunctionalBlock>())
            {
                return;
            }
            base.CreateTerminalControls();

            var onOffSwitch = new MyTerminalControlOnOffSwitch <MyFunctionalBlock>("OnOff", MySpaceTexts.BlockAction_Toggle);

            onOffSwitch.Getter = (x) => x.Enabled;
            onOffSwitch.Setter = (x, v) => x.Enabled = v;
            onOffSwitch.EnableToggleAction();
            onOffSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(0, onOffSwitch);

            MyTerminalControlFactory.AddControl(1, new MyTerminalControlSeparator <MyFunctionalBlock>());
        }
Example #19
0
 protected override void CreateTerminalControls()
 {
     if (!MyTerminalControlFactory.AreControlsCreated <MyFunctionalBlock>())
     {
         base.CreateTerminalControls();
         MyStringId tooltip = new MyStringId();
         MyStringId?on      = null;
         on = null;
         MyTerminalControlOnOffSwitch <MyFunctionalBlock> onOff = new MyTerminalControlOnOffSwitch <MyFunctionalBlock>("OnOff", MySpaceTexts.BlockAction_Toggle, tooltip, on, on)
         {
             Getter = x => x.Enabled,
             Setter = (x, v) => x.Enabled = v
         };
         onOff.EnableToggleAction <MyFunctionalBlock>();
         onOff.EnableOnOffActions <MyFunctionalBlock>();
         MyTerminalControlFactory.AddControl <MyFunctionalBlock>(0, onOff);
         MyTerminalControlFactory.AddControl <MyFunctionalBlock>(1, new MyTerminalControlSeparator <MyFunctionalBlock>());
     }
 }
        static MyOxygenTank()
        {
            var isStockpiling = new MyTerminalControlOnOffSwitch<MyOxygenTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile);
            isStockpiling.Getter = (x) => x.IsStockpiling;
            isStockpiling.Setter = (x, v) => x.SyncObject.ChangeStockpileMode(v);
            isStockpiling.EnableToggleAction();
            isStockpiling.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isStockpiling);

            var refillButton = new MyTerminalControlButton<MyOxygenTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed);
            refillButton.Enabled = (x) => x.CanRefill();
            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox<MyOxygenTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill);
            autoRefill.Getter = (x) => x.m_autoRefill;
            autoRefill.Setter = (x, v) => x.SyncObject.ChangeAutoRefill(v);
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
Example #21
0
 protected override void CreateTerminalControls()
 {
     if (!MyTerminalControlFactory.AreControlsCreated <MyGasTank>())
     {
         base.CreateTerminalControls();
         MyStringId?on = null;
         on = null;
         MyTerminalControlOnOffSwitch <MyGasTank> switch1 = new MyTerminalControlOnOffSwitch <MyGasTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile, on, on);
         MyTerminalControlOnOffSwitch <MyGasTank> switch2 = new MyTerminalControlOnOffSwitch <MyGasTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile, on, on);
         switch2.Getter = x => x.IsStockpiling;
         MyTerminalControlOnOffSwitch <MyGasTank> local11 = switch2;
         MyTerminalControlOnOffSwitch <MyGasTank> local12 = switch2;
         local12.Setter = (x, v) => x.ChangeStockpileMode(v);
         MyTerminalControlOnOffSwitch <MyGasTank> onOff = local12;
         onOff.EnableToggleAction <MyGasTank>();
         onOff.EnableOnOffActions <MyGasTank>();
         MyTerminalControlFactory.AddControl <MyGasTank>(onOff);
         MyTerminalControlButton <MyGasTank> button1 = new MyTerminalControlButton <MyGasTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, new Action <MyGasTank>(MyGasTank.OnRefillButtonPressed));
         MyTerminalControlButton <MyGasTank> button2 = new MyTerminalControlButton <MyGasTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, new Action <MyGasTank>(MyGasTank.OnRefillButtonPressed));
         button2.Enabled = x => x.CanRefill();
         on = null;
         MyTerminalControlButton <MyGasTank> button = button2;
         button.EnableAction <MyGasTank>(null, on, null);
         MyTerminalControlFactory.AddControl <MyGasTank>(button);
         on = null;
         on = null;
         MyTerminalControlCheckbox <MyGasTank> checkbox1 = new MyTerminalControlCheckbox <MyGasTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill, on, on);
         MyTerminalControlCheckbox <MyGasTank> checkbox2 = new MyTerminalControlCheckbox <MyGasTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill, on, on);
         checkbox2.Getter = x => (bool)x.m_autoRefill;
         MyTerminalControlCheckbox <MyGasTank> local9  = checkbox2;
         MyTerminalControlCheckbox <MyGasTank> local10 = checkbox2;
         local10.Setter = (x, v) => x.m_autoRefill.Value = v;
         MyTerminalControlCheckbox <MyGasTank> checkbox = local10;
         checkbox.EnableAction <MyGasTank>(null);
         MyTerminalControlFactory.AddControl <MyGasTank>(checkbox);
     }
 }
Example #22
0
        static MyRemoteControl()
        {
            var controlBtn = new MyTerminalControlButton<MyRemoteControl>("Control", MySpaceTexts.ControlRemote, MySpaceTexts.Blank, (b) => b.RequestControl());
            controlBtn.Enabled = r => r.CanControl();
            controlBtn.SupportsMultipleBlocks = false;
            var action = controlBtn.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(controlBtn);

            
            var autoPilotSeparator = new MyTerminalControlSeparator<MyRemoteControl>();
            MyTerminalControlFactory.AddControl(autoPilotSeparator);

            var autoPilot = new MyTerminalControlOnOffSwitch<MyRemoteControl>("AutoPilot", MySpaceTexts.BlockPropertyTitle_AutoPilot, MySpaceTexts.Blank);
            autoPilot.Getter = (x) => x.m_autoPilotEnabled;
            autoPilot.Setter = (x, v) => x.SetAutoPilotEnabled(v);
            autoPilot.Enabled = r => r.CanEnableAutoPilot();
            autoPilot.EnableToggleAction();
            autoPilot.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(autoPilot);

            var dockignMode = new MyTerminalControlOnOffSwitch<MyRemoteControl>("DockingMode", MySpaceTexts.BlockPropertyTitle_EnableDockingMode, MySpaceTexts.Blank);
            dockignMode.Getter = (x) => x.m_dockingModeEnabled;
            dockignMode.Setter = (x, v) => x.SetDockingMode(v);
            dockignMode.Enabled = r => r.IsWorking;
            dockignMode.EnableToggleAction();
            dockignMode.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(dockignMode);

            var flightMode = new MyTerminalControlCombobox<MyRemoteControl>("FlightMode", MySpaceTexts.BlockPropertyTitle_FlightMode, MySpaceTexts.Blank);
            flightMode.ComboBoxContent = (x) => FillFlightModeCombo(x);
            flightMode.Getter = (x) => (long)x.m_currentFlightMode;
            flightMode.Setter = (x, v) => x.ChangeFlightMode((FlightMode)v);
            MyTerminalControlFactory.AddControl(flightMode);

            var directionCombo = new MyTerminalControlCombobox<MyRemoteControl>("Direction", MySpaceTexts.BlockPropertyTitle_ForwardDirection, MySpaceTexts.Blank);
            directionCombo.ComboBoxContent = (x) => FillDirectionCombo(x);
            directionCombo.Getter = (x) => (long)x.m_currentDirection;
            directionCombo.Setter = (x, v) => x.ChangeDirection((Base6Directions.Direction)v);
            MyTerminalControlFactory.AddControl(directionCombo);

            var waypointList = new MyTerminalControlListbox<MyRemoteControl>("WaypointList", MySpaceTexts.BlockPropertyTitle_Waypoints, MySpaceTexts.Blank, true);
            waypointList.ListContent = (x, list1, list2) => x.FillWaypointList(list1, list2);
            waypointList.ItemSelected = (x, y) => x.SelectWaypoint(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_waypointGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)waypointList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(waypointList);


            var toolbarButton = new MyTerminalControlButton<MyRemoteControl>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_AutoPilotToolbarOpen, MySpaceTexts.BlockPropertyPopup_AutoPilotToolbarOpen,
                delegate(MyRemoteControl self)
                {
                    var actions = self.m_selectedWaypoints[0].Actions;
                    if (actions != null)
                    {
                        for (int i = 0; i < actions.Length; i++)
                        {
                            if (actions[i] != null)
                            {
                                self.m_actionToolbar.SetItemAtIndex(i, actions[i]);
                            }
                        }
                    }

                    self.m_actionToolbar.ItemChanged += self.Toolbar_ItemChanged;
                    if (MyGuiScreenCubeBuilder.Static == null)
                    {
                        MyToolbarComponent.CurrentToolbar = self.m_actionToolbar;
                        MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                        MyToolbarComponent.AutoUpdate = false;
                        screen.Closed += (source) =>
                        {
                            MyToolbarComponent.AutoUpdate = true;
                            self.m_actionToolbar.ItemChanged -= self.Toolbar_ItemChanged;
                            self.m_actionToolbar.Clear();
                        };
                        MyGuiSandbox.AddScreen(screen);
                    }
                });
            toolbarButton.Enabled = r => r.m_selectedWaypoints.Count == 1;
            toolbarButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(toolbarButton);

            var removeBtn = new MyTerminalControlButton<MyRemoteControl>("RemoveWaypoint", MySpaceTexts.BlockActionTitle_RemoveWaypoint, MySpaceTexts.Blank, (b) => b.RemoveWaypoints());
            removeBtn.Enabled = r => r.CanRemoveWaypoints();
            removeBtn.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(removeBtn);

            var moveUp = new MyTerminalControlButton<MyRemoteControl>("MoveUp", MySpaceTexts.BlockActionTitle_MoveWaypointUp, MySpaceTexts.Blank, (b) => b.MoveWaypointsUp());
            moveUp.Enabled = r => r.CanMoveWaypointsUp();
            moveUp.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveUp);

            var moveDown = new MyTerminalControlButton<MyRemoteControl>("MoveDown", MySpaceTexts.BlockActionTitle_MoveWaypointDown, MySpaceTexts.Blank, (b) => b.MoveWaypointsDown());
            moveDown.Enabled = r => r.CanMoveWaypointsDown();
            moveDown.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveDown);

            var addButton = new MyTerminalControlButton<MyRemoteControl>("AddWaypoint", MySpaceTexts.BlockActionTitle_AddWaypoint, MySpaceTexts.Blank, (b) => b.AddWaypoints());
            addButton.Enabled = r => r.CanAddWaypoints();
            addButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(addButton);

            var gpsList = new MyTerminalControlListbox<MyRemoteControl>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);
            gpsList.ListContent = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_gpsGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)gpsList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(gpsList);

            foreach (var direction in m_directionNames)
            {
                var setDirectionAction = new MyTerminalAction<MyRemoteControl>(MyTexts.Get(direction.Value).ToString(), MyTexts.Get(direction.Value), OnAction, null, MyTerminalActionIcons.TOGGLE);
                setDirectionAction.Enabled = (b) => b.IsWorking;
                setDirectionAction.ParameterDefinitions.Add(TerminalActionParameter.Get((byte)direction.Key));
                MyTerminalControlFactory.AddAction(setDirectionAction);
            }

            var resetButton = new MyTerminalControlButton<MyRemoteControl>("Reset", MySpaceTexts.BlockActionTitle_WaypointReset, MySpaceTexts.BlockActionTooltip_WaypointReset, (b) => b.ResetWaypoint());
            resetButton.Enabled = r => r.IsWorking;
            resetButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(resetButton);

            var copyButton = new MyTerminalControlButton<MyRemoteControl>("Copy", MySpaceTexts.BlockActionTitle_RemoteCopy, MySpaceTexts.Blank, (b) => b.CopyAutopilotSetup());
            copyButton.Enabled = r => r.IsWorking;
            copyButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(copyButton);

            var pasteButton = new MyTerminalControlButton<MyRemoteControl>("Paste", MySpaceTexts.BlockActionTitle_RemotePaste, MySpaceTexts.Blank, (b) => b.PasteAutopilotSetup());
            pasteButton.Enabled = r => r.IsWorking && MyRemoteControl.m_clipboard != null;
            pasteButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(pasteButton);
        }
Example #23
0
 static MyDoor()
 {
     var open = new MyTerminalControlOnOffSwitch<MyDoor>("Open", MySpaceTexts.Blank, on: MySpaceTexts.BlockAction_DoorOpen, off: MySpaceTexts.BlockAction_DoorClosed);
     open.Getter = (x) => x.Open;
     open.Setter = (x, v) => x.SyncObject.SendChangeDoorRequest(v, x.OwnerId);
     open.EnableToggleAction();
     open.EnableOnOffActions();
     MyTerminalControlFactory.AddControl(open);
 }
Example #24
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyGasTank>())
                return;
            base.CreateTerminalControls();
            var isStockpiling = new MyTerminalControlOnOffSwitch<MyGasTank>("Stockpile", MySpaceTexts.BlockPropertyTitle_Stockpile, MySpaceTexts.BlockPropertyDescription_Stockpile)
            {
                Getter = (x) => x.IsStockpiling,
                Setter = (x, v) => x.ChangeStockpileMode(v)
            };
            isStockpiling.EnableToggleAction();
            isStockpiling.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isStockpiling);

            var refillButton = new MyTerminalControlButton<MyGasTank>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed)
            {
                Enabled = (x) => x.CanRefill()
            };
            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox<MyGasTank>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill)
            {
                Getter = (x) => x.m_autoRefill,
                Setter = (x, v) => x.ChangeAutoRefill(v)
            };
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);

        }
Example #25
0
 static MyAirVent()
 {
     var isDepressurizing = new MyTerminalControlOnOffSwitch<MyAirVent>("Depressurize", MySpaceTexts.BlockPropertyTitle_Depressurize, MySpaceTexts.BlockPropertyDescription_Depressurize);
     isDepressurizing.Getter = (x) => (x as MyAirVent).IsDepressurizing;
     isDepressurizing.Setter = (x, v) => (x as MyAirVent).SyncObject.ChangeDepressurizationMode(v);
     isDepressurizing.EnableToggleAction();
     isDepressurizing.EnableOnOffActions();
     MyTerminalControlFactory.AddControl(isDepressurizing);
 }
Example #26
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyAirVent>())
                return;

            var isDepressurizing = new MyTerminalControlOnOffSwitch<MyAirVent>("Depressurize", MySpaceTexts.BlockPropertyTitle_Depressurize, MySpaceTexts.BlockPropertyDescription_Depressurize);
            isDepressurizing.Getter = (x) => x.IsDepressurizing;
            isDepressurizing.Setter = (x, v) => x.IsDepressurizing = v;
            isDepressurizing.EnableToggleAction();
            isDepressurizing.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(isDepressurizing);

            var toolbarButton = new MyTerminalControlButton<MyAirVent>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_SensorToolbarOpen, MySpaceTexts.BlockPropertyDescription_SensorToolbarOpen,
                delegate(MyAirVent self)
                {
                    if (self.m_onFullAction != null)
                    {
                        self.m_actionToolbar.SetItemAtIndex(0, self.m_onFullAction);
                    }
                    if (self.m_onEmptyAction != null)
                    {
                        self.m_actionToolbar.SetItemAtIndex(1, self.m_onEmptyAction);
                    }

                    self.m_actionToolbar.ItemChanged += self.Toolbar_ItemChanged;
                    if (MyGuiScreenCubeBuilder.Static == null)
                    {
                        MyToolbarComponent.CurrentToolbar = self.m_actionToolbar;
                        MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                        MyToolbarComponent.AutoUpdate = false;

                        screen.Closed += (source) =>
                            {
                                MyToolbarComponent.AutoUpdate = true;
                                self.m_actionToolbar.ItemChanged -= self.Toolbar_ItemChanged;
                                self.m_actionToolbar.Clear();
                            };
                        MyGuiSandbox.AddScreen(screen);
                    }
                });
            toolbarButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(toolbarButton);
        }
Example #27
0
        static MySensorBlock()
        {
            m_openedToolbars = new List <MyToolbar>();

            var toolbarButton = new MyTerminalControlButton <MySensorBlock>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_SensorToolbarOpen, MySpaceTexts.BlockPropertyDescription_SensorToolbarOpen,
                                                                            delegate(MySensorBlock 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 fieldWidthMin = new MyTerminalControlSlider <MySensorBlock>("Left", MySpaceTexts.BlockPropertyTitle_SensorFieldWidthMin, MySpaceTexts.BlockPropertyDescription_SensorFieldLeft);

            fieldWidthMin.SetLimits(block => 1, block => block.MaxRange);
            fieldWidthMin.DefaultValue = 5;
            fieldWidthMin.Getter       = (x) => - x.m_fieldMin.X;
            fieldWidthMin.Setter       = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                fieldMin.X = -v;
                x.FieldMin = fieldMin;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMinRequest(ref fieldMin);
            };
            fieldWidthMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.X).Append(" m");
            fieldWidthMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidthMin);

            var fieldWidthMax = new MyTerminalControlSlider <MySensorBlock>("Right", MySpaceTexts.BlockPropertyTitle_SensorFieldWidthMax, MySpaceTexts.BlockPropertyDescription_SensorFieldRight);

            fieldWidthMax.SetLimits(block => 1, block => block.MaxRange);
            fieldWidthMax.DefaultValue = 5;
            fieldWidthMax.Getter       = (x) => x.m_fieldMax.X;
            fieldWidthMax.Setter       = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                fieldMax.X = v;
                x.FieldMax = fieldMax;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMaxRequest(ref fieldMax);
            };
            fieldWidthMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.X).Append(" m");
            fieldWidthMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidthMax);


            var fieldHeightMin = new MyTerminalControlSlider <MySensorBlock>("Bottom", MySpaceTexts.BlockPropertyTitle_SensorFieldHeightMin, MySpaceTexts.BlockPropertyDescription_SensorFieldBottom);

            fieldHeightMin.SetLimits(block => 1, block => block.MaxRange);
            fieldHeightMin.DefaultValue = 5;
            fieldHeightMin.Getter       = (x) => - x.m_fieldMin.Y;
            fieldHeightMin.Setter       = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                fieldMin.Y = -v;
                x.FieldMin = fieldMin;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMinRequest(ref fieldMin);
            };
            fieldHeightMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.Y).Append(" m");
            fieldHeightMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeightMin);

            var fieldHeightMax = new MyTerminalControlSlider <MySensorBlock>("Top", MySpaceTexts.BlockPropertyTitle_SensorFieldHeightMax, MySpaceTexts.BlockPropertyDescription_SensorFieldTop);

            fieldHeightMax.SetLimits(block => 1, block => block.MaxRange);
            fieldHeightMax.DefaultValue = 5;
            fieldHeightMax.Getter       = (x) => x.m_fieldMax.Y;
            fieldHeightMax.Setter       = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                fieldMax.Y = v;
                x.FieldMax = fieldMax;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMaxRequest(ref fieldMax);
            };
            fieldHeightMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.Y).Append(" m");
            fieldHeightMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeightMax);

            var fieldDepthMax = new MyTerminalControlSlider <MySensorBlock>("Back", MySpaceTexts.BlockPropertyTitle_SensorFieldDepthMax, MySpaceTexts.BlockPropertyDescription_SensorFieldBack);

            fieldDepthMax.SetLimits(block => 1, block => block.MaxRange);
            fieldDepthMax.DefaultValue = 5;
            fieldDepthMax.Getter       = (x) => x.m_fieldMax.Z;
            fieldDepthMax.Setter       = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                fieldMax.Z = v;
                x.FieldMax = fieldMax;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMaxRequest(ref fieldMax);
            };
            fieldDepthMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.Z).Append(" m");
            fieldDepthMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepthMax);

            var fieldDepthMin = new MyTerminalControlSlider <MySensorBlock>("Front", MySpaceTexts.BlockPropertyTitle_SensorFieldDepthMin, MySpaceTexts.BlockPropertyDescription_SensorFieldFront);

            fieldDepthMin.SetLimits(block => 1, block => block.MaxRange);
            fieldDepthMin.DefaultValue = 5;
            fieldDepthMin.Getter       = (x) => - x.m_fieldMin.Z;
            fieldDepthMin.Setter       = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                fieldMin.Z = -v;
                x.FieldMin = fieldMin;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorMinRequest(ref fieldMin);
            };
            fieldDepthMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.Z).Append(" m");
            fieldDepthMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepthMin);

            var separatorFilters = new MyTerminalControlSeparator <MySensorBlock>();

            MyTerminalControlFactory.AddControl(separatorFilters);

            var detectPlayProximitySoundSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Audible Proximity Alert", MySpaceTexts.BlockPropertyTitle_SensorPlaySound, MySpaceTexts.BlockPropertyTitle_SensorPlaySound);

            detectPlayProximitySoundSwitch.Getter = (x) => x.PlayProximitySound;
            detectPlayProximitySoundSwitch.Setter = (x, v) =>
            {
                x.PlayProximitySound = v;
                (x.SyncObject as MySyncSensorBlock).SendChangeSensorPlaySoundRequest(x.PlayProximitySound);
            };
            MyTerminalControlFactory.AddControl(detectPlayProximitySoundSwitch);

            var detectPlayersSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Players", MySpaceTexts.BlockPropertyTitle_SensorDetectPlayers, MySpaceTexts.BlockPropertyTitle_SensorDetectPlayers);

            detectPlayersSwitch.Getter = (x) => x.DetectPlayers;
            detectPlayersSwitch.Setter = (x, v) =>
            {
                x.DetectPlayers = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectPlayersSwitch.EnableToggleAction(MyTerminalActionIcons.CHARACTER_TOGGLE);
            detectPlayersSwitch.EnableOnOffActions(MyTerminalActionIcons.CHARACTER_ON, MyTerminalActionIcons.CHARACTER_OFF);
            MyTerminalControlFactory.AddControl(detectPlayersSwitch);

            var detectFloatingObjectsSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Floating Objects", MySpaceTexts.BlockPropertyTitle_SensorDetectFloatingObjects, MySpaceTexts.BlockPropertyTitle_SensorDetectFloatingObjects);

            detectFloatingObjectsSwitch.Getter = (x) => x.DetectFloatingObjects;
            detectFloatingObjectsSwitch.Setter = (x, v) =>
            {
                x.DetectFloatingObjects = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectFloatingObjectsSwitch.EnableToggleAction(MyTerminalActionIcons.MOVING_OBJECT_TOGGLE);
            detectFloatingObjectsSwitch.EnableOnOffActions(MyTerminalActionIcons.MOVING_OBJECT_ON, MyTerminalActionIcons.MOVING_OBJECT_OFF);
            MyTerminalControlFactory.AddControl(detectFloatingObjectsSwitch);

            var detectSmallShipsSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Small Ships", MySpaceTexts.BlockPropertyTitle_SensorDetectSmallShips, MySpaceTexts.BlockPropertyTitle_SensorDetectSmallShips);

            detectSmallShipsSwitch.Getter = (x) => x.DetectSmallShips;
            detectSmallShipsSwitch.Setter = (x, v) =>
            {
                x.DetectSmallShips = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectSmallShipsSwitch.EnableToggleAction(MyTerminalActionIcons.SMALLSHIP_TOGGLE);
            detectSmallShipsSwitch.EnableOnOffActions(MyTerminalActionIcons.SMALLSHIP_ON, MyTerminalActionIcons.SMALLSHIP_OFF);
            MyTerminalControlFactory.AddControl(detectSmallShipsSwitch);

            var detectLargeShipsSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Large Ships", MySpaceTexts.BlockPropertyTitle_SensorDetectLargeShips, MySpaceTexts.BlockPropertyTitle_SensorDetectLargeShips);

            detectLargeShipsSwitch.Getter = (x) => x.DetectLargeShips;
            detectLargeShipsSwitch.Setter = (x, v) =>
            {
                x.DetectLargeShips = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectLargeShipsSwitch.EnableToggleAction(MyTerminalActionIcons.LARGESHIP_TOGGLE);
            detectLargeShipsSwitch.EnableOnOffActions(MyTerminalActionIcons.LARGESHIP_ON, MyTerminalActionIcons.LARGESHIP_OFF);
            MyTerminalControlFactory.AddControl(detectLargeShipsSwitch);

            var detectStationsSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Stations", MySpaceTexts.BlockPropertyTitle_SensorDetectStations, MySpaceTexts.BlockPropertyTitle_SensorDetectStations);

            detectStationsSwitch.Getter = (x) => x.DetectStations;
            detectStationsSwitch.Setter = (x, v) =>
            {
                x.DetectStations = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectStationsSwitch.EnableToggleAction(MyTerminalActionIcons.STATION_TOGGLE);
            detectStationsSwitch.EnableOnOffActions(MyTerminalActionIcons.STATION_ON, MyTerminalActionIcons.STATION_OFF);
            MyTerminalControlFactory.AddControl(detectStationsSwitch);

            var detectAsteroidsSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Asteroids", MySpaceTexts.BlockPropertyTitle_SensorDetectAsteroids, MySpaceTexts.BlockPropertyTitle_SensorDetectAsteroids);

            detectAsteroidsSwitch.Getter = (x) => x.DetectAsteroids;
            detectAsteroidsSwitch.Setter = (x, v) =>
            {
                x.DetectAsteroids = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectAsteroidsSwitch.EnableToggleAction();
            detectAsteroidsSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectAsteroidsSwitch);

            var separatorFactionFilters = new MyTerminalControlSeparator <MySensorBlock>();

            MyTerminalControlFactory.AddControl(separatorFactionFilters);

            var detectOwnerSwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Owner", MySpaceTexts.BlockPropertyTitle_SensorDetectOwner, MySpaceTexts.BlockPropertyTitle_SensorDetectOwner);

            detectOwnerSwitch.Getter = (x) => x.DetectOwner;
            detectOwnerSwitch.Setter = (x, v) =>
            {
                x.DetectOwner = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectOwnerSwitch.EnableToggleAction();
            detectOwnerSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectOwnerSwitch);

            var detectFriendlySwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Friendly", MySpaceTexts.BlockPropertyTitle_SensorDetectFriendly, MySpaceTexts.BlockPropertyTitle_SensorDetectFriendly);

            detectFriendlySwitch.Getter = (x) => x.DetectFriendly;
            detectFriendlySwitch.Setter = (x, v) =>
            {
                x.DetectFriendly = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectFriendlySwitch.EnableToggleAction();
            detectFriendlySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectFriendlySwitch);

            var detectNeutralSwitch = new  MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Neutral", MySpaceTexts.BlockPropertyTitle_SensorDetectNeutral, MySpaceTexts.BlockPropertyTitle_SensorDetectNeutral);

            detectNeutralSwitch.Getter = (x) => x.DetectNeutral;
            detectNeutralSwitch.Setter = (x, v) =>
            {
                x.DetectNeutral = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectNeutralSwitch.EnableToggleAction();
            detectNeutralSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectNeutralSwitch);

            var detectEnemySwitch = new MyTerminalControlOnOffSwitch <MySensorBlock>("Detect Enemy", MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy, MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy);

            detectEnemySwitch.Getter = (x) => x.DetectEnemy;
            detectEnemySwitch.Setter = (x, v) =>
            {
                x.DetectEnemy = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectEnemySwitch.EnableToggleAction();
            detectEnemySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectEnemySwitch);
        }
Example #28
0
        static MyJumpDrive()
        {
            var jumpButton = new MyTerminalControlButton <MyJumpDrive>("Jump", MySpaceTexts.BlockActionTitle_Jump, MySpaceTexts.Blank, (x) => x.RequestJump());

            jumpButton.Enabled = (x) => x.CanJump;
            jumpButton.SupportsMultipleBlocks = false;
            // Can only be called from toolbar of cockpit
            jumpButton.Visible = (x) => false;
            var action = jumpButton.EnableAction(MyTerminalActionIcons.TOGGLE);

            if (action != null)
            {
                action.InvalidToolbarTypes = new List <MyToolbarType> {
                    MyToolbarType.ButtonPanel, MyToolbarType.Character, MyToolbarType.Seat
                };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(jumpButton);

            var recharging = new MyTerminalControlOnOffSwitch <MyJumpDrive>("Recharge", MySpaceTexts.BlockPropertyTitle_Recharge, MySpaceTexts.Blank);

            recharging.Getter = (x) => x.m_isRecharging;
            recharging.Setter = (x, v) => x.m_isRecharging.Value = v;
            recharging.EnableToggleAction();
            recharging.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(recharging);

            var maxDistanceSlider = new MyTerminalControlSlider <MyJumpDrive>("JumpDistance", MySpaceTexts.BlockPropertyTitle_JumpDistance, MySpaceTexts.Blank);

            maxDistanceSlider.SetLimits(0f, 100f);
            maxDistanceSlider.DefaultValue = 100f;
            maxDistanceSlider.Enabled      = (x) => x.m_jumpTarget == null;
            maxDistanceSlider.Getter       = (x) => x.m_jumpDistanceRatio;
            maxDistanceSlider.Setter       = (x, v) =>
            {
                x.m_jumpDistanceRatio.Value = v;
            };
            maxDistanceSlider.Writer = (x, v) =>
            {
                v.AppendFormatedDecimal((x.m_jumpDistanceRatio / 100f).ToString("P0") + " (", (float)x.ComputeMaxDistance() / 1000f, 0, " km").Append(")");
            };
            maxDistanceSlider.EnableActions(0.01f);
            MyTerminalControlFactory.AddControl(maxDistanceSlider);


            var selectedTarget = new MyTerminalControlListbox <MyJumpDrive>("SelectedTarget", MySpaceTexts.BlockPropertyTitle_DestinationGPS, MySpaceTexts.Blank, false, 1);

            selectedTarget.ListContent = (x, list1, list2) => x.FillSelectedTarget(list1, list2);
            MyTerminalControlFactory.AddControl(selectedTarget);

            var removeBtn = new MyTerminalControlButton <MyJumpDrive>("RemoveBtn", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (x) => x.RemoveSelected());

            removeBtn.Enabled = (x) => x.CanRemove();
            MyTerminalControlFactory.AddControl(removeBtn);

            var selectBtn = new MyTerminalControlButton <MyJumpDrive>("SelectBtn", MyCommonTexts.SelectBlueprint, MySpaceTexts.Blank, (x) => x.SelectTarget());

            selectBtn.Enabled = (x) => x.CanSelect();
            MyTerminalControlFactory.AddControl(selectBtn);

            var gpsList = new MyTerminalControlListbox <MyJumpDrive>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);

            gpsList.ListContent  = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            MyTerminalControlFactory.AddControl(gpsList);
            if (!MySandboxGame.IsDedicated)
            {
                m_gpsGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)gpsList.GetGuiControl()).PropertyControl;
            }
        }
Example #29
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MySensorBlock>())
                return;

            m_openedToolbars = new List<MyToolbar>();

            var toolbarButton = new MyTerminalControlButton<MySensorBlock>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_SensorToolbarOpen, MySpaceTexts.BlockPropertyDescription_SensorToolbarOpen,
                delegate(MySensorBlock 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 fieldWidthMin = new MyTerminalControlSlider<MySensorBlock>("Left", MySpaceTexts.BlockPropertyTitle_SensorFieldWidthMin, MySpaceTexts.BlockPropertyDescription_SensorFieldLeft);
            fieldWidthMin.SetLimits(block => 1, block => block.MaxRange);
            fieldWidthMin.DefaultValue = 5;
            fieldWidthMin.Getter = (x) => -x.m_fieldMin.Value.X;
            fieldWidthMin.Setter = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                if (fieldMin.X == -v)
                    return;
                fieldMin.X = -v;
                x.FieldMin = fieldMin;
            };
            fieldWidthMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.Value.X).Append(" m");
            fieldWidthMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidthMin);

            var fieldWidthMax = new MyTerminalControlSlider<MySensorBlock>("Right", MySpaceTexts.BlockPropertyTitle_SensorFieldWidthMax, MySpaceTexts.BlockPropertyDescription_SensorFieldRight);
            fieldWidthMax.SetLimits(block => 1, block => block.MaxRange);
            fieldWidthMax.DefaultValue = 5;
            fieldWidthMax.Getter = (x) => x.m_fieldMax.Value.X;
            fieldWidthMax.Setter = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                if (fieldMax.X == v)
                    return;
                fieldMax.X = v;
                x.FieldMax = fieldMax;
            };
            fieldWidthMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.Value.X).Append(" m");
            fieldWidthMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidthMax);


            var fieldHeightMin = new MyTerminalControlSlider<MySensorBlock>("Bottom", MySpaceTexts.BlockPropertyTitle_SensorFieldHeightMin, MySpaceTexts.BlockPropertyDescription_SensorFieldBottom);
            fieldHeightMin.SetLimits(block => 1, block => block.MaxRange);
            fieldHeightMin.DefaultValue = 5;
            fieldHeightMin.Getter = (x) => -x.m_fieldMin.Value.Y;
            fieldHeightMin.Setter = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                if (fieldMin.Y == -v)
                    return;
                fieldMin.Y = -v;
                x.FieldMin = fieldMin;
            };
            fieldHeightMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.Value.Y).Append(" m");
            fieldHeightMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeightMin);

            var fieldHeightMax = new MyTerminalControlSlider<MySensorBlock>("Top", MySpaceTexts.BlockPropertyTitle_SensorFieldHeightMax, MySpaceTexts.BlockPropertyDescription_SensorFieldTop);
            fieldHeightMax.SetLimits(block => 1, block => block.MaxRange);
            fieldHeightMax.DefaultValue = 5;
            fieldHeightMax.Getter = (x) => x.m_fieldMax.Value.Y;
            fieldHeightMax.Setter = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                if (fieldMax.Y == v)
                    return;
                fieldMax.Y = v;
                x.FieldMax = fieldMax;
            };
            fieldHeightMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.Value.Y).Append(" m");
            fieldHeightMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeightMax);

            var fieldDepthMax = new MyTerminalControlSlider<MySensorBlock>("Back", MySpaceTexts.BlockPropertyTitle_SensorFieldDepthMax, MySpaceTexts.BlockPropertyDescription_SensorFieldBack);
            fieldDepthMax.SetLimits(block => 1, block => block.MaxRange);
            fieldDepthMax.DefaultValue = 5;
            fieldDepthMax.Getter = (x) => x.m_fieldMax.Value.Z;
            fieldDepthMax.Setter = (x, v) =>
            {
                var fieldMax = x.FieldMax;
                if (fieldMax.Z == v)
                    return;
                fieldMax.Z = v;
                x.FieldMax = fieldMax;
            };
            fieldDepthMax.Writer = (x, result) => result.AppendInt32((int)x.m_fieldMax.Value.Z).Append(" m");
            fieldDepthMax.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepthMax);

            var fieldDepthMin = new MyTerminalControlSlider<MySensorBlock>("Front", MySpaceTexts.BlockPropertyTitle_SensorFieldDepthMin, MySpaceTexts.BlockPropertyDescription_SensorFieldFront);
            fieldDepthMin.SetLimits(block => 1, block => block.MaxRange);
            fieldDepthMin.DefaultValue = 5;
            fieldDepthMin.Getter = (x) => -x.m_fieldMin.Value.Z;
            fieldDepthMin.Setter = (x, v) =>
            {
                var fieldMin = x.FieldMin;
                if (fieldMin.Z == -v)
                    return;
                fieldMin.Z = -v;
                x.FieldMin = fieldMin;
            };
            fieldDepthMin.Writer = (x, result) => result.AppendInt32((int)-x.m_fieldMin.Value.Z).Append(" m");
            fieldDepthMin.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepthMin);

            var separatorFilters = new MyTerminalControlSeparator<MySensorBlock>();
            MyTerminalControlFactory.AddControl(separatorFilters);

            var detectPlayProximitySoundSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Audible Proximity Alert", MySpaceTexts.BlockPropertyTitle_SensorPlaySound, MySpaceTexts.BlockPropertyTitle_SensorPlaySound);
            detectPlayProximitySoundSwitch.Getter = (x) => x.PlayProximitySound;
            detectPlayProximitySoundSwitch.Setter = (x, v) =>
            {
                x.PlayProximitySound = v;
            };                   
            MyTerminalControlFactory.AddControl(detectPlayProximitySoundSwitch);

            var detectPlayersSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Players", MySpaceTexts.BlockPropertyTitle_SensorDetectPlayers, MySpaceTexts.BlockPropertyTitle_SensorDetectPlayers);
            detectPlayersSwitch.Getter = (x) => x.DetectPlayers;
            detectPlayersSwitch.Setter = (x, v) =>
            {
                x.DetectPlayers = v;
            };
            detectPlayersSwitch.EnableToggleAction(MyTerminalActionIcons.CHARACTER_TOGGLE);
            detectPlayersSwitch.EnableOnOffActions(MyTerminalActionIcons.CHARACTER_ON, MyTerminalActionIcons.CHARACTER_OFF);
            MyTerminalControlFactory.AddControl(detectPlayersSwitch);

            var detectFloatingObjectsSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Floating Objects", MySpaceTexts.BlockPropertyTitle_SensorDetectFloatingObjects, MySpaceTexts.BlockPropertyTitle_SensorDetectFloatingObjects);
            detectFloatingObjectsSwitch.Getter = (x) => x.DetectFloatingObjects;
            detectFloatingObjectsSwitch.Setter = (x, v) =>
            {
                x.DetectFloatingObjects = v;
            };
            detectFloatingObjectsSwitch.EnableToggleAction(MyTerminalActionIcons.MOVING_OBJECT_TOGGLE);
            detectFloatingObjectsSwitch.EnableOnOffActions(MyTerminalActionIcons.MOVING_OBJECT_ON, MyTerminalActionIcons.MOVING_OBJECT_OFF);
            MyTerminalControlFactory.AddControl(detectFloatingObjectsSwitch);

            var detectSmallShipsSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Small Ships", MySpaceTexts.BlockPropertyTitle_SensorDetectSmallShips, MySpaceTexts.BlockPropertyTitle_SensorDetectSmallShips);
            detectSmallShipsSwitch.Getter = (x) => x.DetectSmallShips;
            detectSmallShipsSwitch.Setter = (x, v) =>
            {
                x.DetectSmallShips = v;
            };
            detectSmallShipsSwitch.EnableToggleAction(MyTerminalActionIcons.SMALLSHIP_TOGGLE);
            detectSmallShipsSwitch.EnableOnOffActions(MyTerminalActionIcons.SMALLSHIP_ON, MyTerminalActionIcons.SMALLSHIP_OFF);
            MyTerminalControlFactory.AddControl(detectSmallShipsSwitch);

            var detectLargeShipsSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Large Ships", MySpaceTexts.BlockPropertyTitle_SensorDetectLargeShips, MySpaceTexts.BlockPropertyTitle_SensorDetectLargeShips);
            detectLargeShipsSwitch.Getter = (x) => x.DetectLargeShips;
            detectLargeShipsSwitch.Setter = (x, v) =>
            {
                x.DetectLargeShips = v;
            };
            detectLargeShipsSwitch.EnableToggleAction(MyTerminalActionIcons.LARGESHIP_TOGGLE);
            detectLargeShipsSwitch.EnableOnOffActions(MyTerminalActionIcons.LARGESHIP_ON, MyTerminalActionIcons.LARGESHIP_OFF);
            MyTerminalControlFactory.AddControl(detectLargeShipsSwitch);

            var detectStationsSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Stations", MySpaceTexts.BlockPropertyTitle_SensorDetectStations, MySpaceTexts.BlockPropertyTitle_SensorDetectStations);
            detectStationsSwitch.Getter = (x) => x.DetectStations;
            detectStationsSwitch.Setter = (x, v) =>
            {
                x.DetectStations = v;
            };
            detectStationsSwitch.EnableToggleAction(MyTerminalActionIcons.STATION_TOGGLE);
            detectStationsSwitch.EnableOnOffActions(MyTerminalActionIcons.STATION_ON, MyTerminalActionIcons.STATION_OFF);
            MyTerminalControlFactory.AddControl(detectStationsSwitch);

            var detectAsteroidsSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Asteroids", MySpaceTexts.BlockPropertyTitle_SensorDetectAsteroids, MySpaceTexts.BlockPropertyTitle_SensorDetectAsteroids);
            detectAsteroidsSwitch.Getter = (x) => x.DetectAsteroids;
            detectAsteroidsSwitch.Setter = (x, v) =>
            {
                x.DetectAsteroids = v;
            };
            detectAsteroidsSwitch.EnableToggleAction();
            detectAsteroidsSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectAsteroidsSwitch);

            var separatorFactionFilters = new MyTerminalControlSeparator<MySensorBlock>();
            MyTerminalControlFactory.AddControl(separatorFactionFilters);

            var detectOwnerSwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Owner", MySpaceTexts.BlockPropertyTitle_SensorDetectOwner, MySpaceTexts.BlockPropertyTitle_SensorDetectOwner);
            detectOwnerSwitch.Getter = (x) => x.DetectOwner;
            detectOwnerSwitch.Setter = (x, v) =>
            {
                x.DetectOwner = v;
            };
            detectOwnerSwitch.EnableToggleAction();
            detectOwnerSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectOwnerSwitch);

            var detectFriendlySwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Friendly", MySpaceTexts.BlockPropertyTitle_SensorDetectFriendly, MySpaceTexts.BlockPropertyTitle_SensorDetectFriendly);
            detectFriendlySwitch.Getter = (x) => x.DetectFriendly;
            detectFriendlySwitch.Setter = (x, v) =>
            {
                x.DetectFriendly = v;
            };
            detectFriendlySwitch.EnableToggleAction();
            detectFriendlySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectFriendlySwitch);

            var detectNeutralSwitch = new  MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Neutral", MySpaceTexts.BlockPropertyTitle_SensorDetectNeutral, MySpaceTexts.BlockPropertyTitle_SensorDetectNeutral);
            detectNeutralSwitch.Getter = (x) => x.DetectNeutral;
            detectNeutralSwitch.Setter = (x, v) =>
            {
                x.DetectNeutral = v;
            };
            detectNeutralSwitch.EnableToggleAction();
            detectNeutralSwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectNeutralSwitch);

            var detectEnemySwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Enemy", MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy, MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy);
            detectEnemySwitch.Getter = (x) => x.DetectEnemy;
            detectEnemySwitch.Setter = (x, v) =>
            {
                x.DetectEnemy = v;
            };
            detectEnemySwitch.EnableToggleAction();
            detectEnemySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectEnemySwitch);
        }
Example #30
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyRemoteControl>())
                return;
            base.CreateTerminalControls();
            var controlBtn = new MyTerminalControlButton<MyRemoteControl>("Control", MySpaceTexts.ControlRemote, MySpaceTexts.Blank, (b) => b.RequestControl());
            controlBtn.Enabled = r => r.CanControl();
            controlBtn.SupportsMultipleBlocks = false;
            var action = controlBtn.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(controlBtn);

            
            var autoPilotSeparator = new MyTerminalControlSeparator<MyRemoteControl>();
            MyTerminalControlFactory.AddControl(autoPilotSeparator);

            var autoPilot = new MyTerminalControlOnOffSwitch<MyRemoteControl>("AutoPilot", MySpaceTexts.BlockPropertyTitle_AutoPilot, MySpaceTexts.Blank);
            autoPilot.Getter = (x) => x.m_autoPilotEnabled;
            autoPilot.Setter = (x, v) => x.SetAutoPilotEnabled(v);
            autoPilot.Enabled = r => r.CanEnableAutoPilot();
            autoPilot.EnableToggleAction();
            autoPilot.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(autoPilot);

            var collisionAv = new MyTerminalControlOnOffSwitch<MyRemoteControl>("CollisionAvoidance", MySpaceTexts.BlockPropertyTitle_CollisionAvoidance, MySpaceTexts.Blank);
            collisionAv.Getter = (x) => x.m_useCollisionAvoidance;
            collisionAv.Setter = (x, v) => x.SetCollisionAvoidance(v);
            collisionAv.Enabled = r => true;
            collisionAv.EnableToggleAction();
            collisionAv.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(collisionAv);

            var dockignMode = new MyTerminalControlOnOffSwitch<MyRemoteControl>("DockingMode", MySpaceTexts.BlockPropertyTitle_EnableDockingMode, MySpaceTexts.Blank);
            dockignMode.Getter = (x) => x.m_dockingModeEnabled;
            dockignMode.Setter = (x, v) => x.SetDockingMode(v);
            dockignMode.Enabled = r => r.IsWorking;
            dockignMode.EnableToggleAction();
            dockignMode.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(dockignMode);

            var cameraList = new MyTerminalControlCombobox<MyRemoteControl>("CameraList", MySpaceTexts.BlockPropertyTitle_AssignedCamera, MySpaceTexts.Blank);
            cameraList.ComboBoxContentWithBlock = (x, list) => x.FillCameraComboBoxContent(list);
            cameraList.Getter = (x) => (long)x.m_bindedCamera;
            cameraList.Setter = (x, y) => x.m_bindedCamera.Value = y;
            MyTerminalControlFactory.AddControl(cameraList);
            m_cameraList = cameraList;

            var flightMode = new MyTerminalControlCombobox<MyRemoteControl>("FlightMode", MySpaceTexts.BlockPropertyTitle_FlightMode, MySpaceTexts.Blank);
            flightMode.ComboBoxContent = (x) => FillFlightModeCombo(x);
            flightMode.Getter = (x) => (long)x.m_currentFlightMode.Value;
            flightMode.Setter = (x, v) => x.ChangeFlightMode((FlightMode)v);
            flightMode.SetSerializerRange((int)MyEnum<FlightMode>.Range.Min, (int)MyEnum<FlightMode>.Range.Max);
            MyTerminalControlFactory.AddControl(flightMode);

            var directionCombo = new MyTerminalControlCombobox<MyRemoteControl>("Direction", MySpaceTexts.BlockPropertyTitle_ForwardDirection, MySpaceTexts.Blank);
            directionCombo.ComboBoxContent = (x) => FillDirectionCombo(x);
            directionCombo.Getter = (x) => (long)x.m_currentDirection.Value;
            directionCombo.Setter = (x, v) => x.ChangeDirection((Base6Directions.Direction)v);
            MyTerminalControlFactory.AddControl(directionCombo);

            if (MyFakes.ENABLE_VR_REMOTE_BLOCK_AUTOPILOT_SPEED_LIMIT)
            {
                var sliderSpeedLimit = new MyTerminalControlSlider<MyRemoteControl>("SpeedLimit", MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit,
                    MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit);
                sliderSpeedLimit.SetLimits(1, 200);
                sliderSpeedLimit.DefaultValue = MyObjectBuilder_RemoteControl.DEFAULT_AUTOPILOT_SPEED_LIMIT;
                sliderSpeedLimit.Getter = (x) => x.m_autopilotSpeedLimit;
                sliderSpeedLimit.Setter = (x, v) => x.m_autopilotSpeedLimit.Value = v;
                sliderSpeedLimit.Writer = (x, sb) => sb.Append(MyValueFormatter.GetFormatedFloat(x.m_autopilotSpeedLimit, 0));
                sliderSpeedLimit.EnableActions();
                MyTerminalControlFactory.AddControl(sliderSpeedLimit);
            }

            var waypointList = new MyTerminalControlListbox<MyRemoteControl>("WaypointList", MySpaceTexts.BlockPropertyTitle_Waypoints, MySpaceTexts.Blank, true);
            waypointList.ListContent = (x, list1, list2) => x.FillWaypointList(list1, list2);
            waypointList.ItemSelected = (x, y) => x.SelectWaypoint(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_waypointGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)waypointList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(waypointList);


            var toolbarButton = new MyTerminalControlButton<MyRemoteControl>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_AutoPilotToolbarOpen, MySpaceTexts.BlockPropertyPopup_AutoPilotToolbarOpen,
                delegate(MyRemoteControl self)
                {
                    var actions = self.m_selectedWaypoints[0].Actions;
                    if (actions != null)
                    {
                        for (int i = 0; i < actions.Length; i++)
                        {
                            if (actions[i] != null)
                            {
                                self.m_actionToolbar.SetItemAtIndex(i, actions[i]);
                            }
                        }
                    }

                    self.m_actionToolbar.ItemChanged += self.Toolbar_ItemChanged;
                    if (MyGuiScreenCubeBuilder.Static == null)
                    {
                        MyToolbarComponent.CurrentToolbar = self.m_actionToolbar;
                        MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                        MyToolbarComponent.AutoUpdate = false;
                        screen.Closed += (source) =>
                        {
                            MyToolbarComponent.AutoUpdate = true;
                            self.m_actionToolbar.ItemChanged -= self.Toolbar_ItemChanged;
                            self.m_actionToolbar.Clear();
                        };
                        MyGuiSandbox.AddScreen(screen);
                    }
                });
            toolbarButton.Enabled = r => r.m_selectedWaypoints.Count == 1;
            toolbarButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(toolbarButton);

            var removeBtn = new MyTerminalControlButton<MyRemoteControl>("RemoveWaypoint", MySpaceTexts.BlockActionTitle_RemoveWaypoint, MySpaceTexts.Blank, (b) => b.RemoveWaypoints());
            removeBtn.Enabled = r => r.CanRemoveWaypoints();
            removeBtn.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(removeBtn);

            var moveUp = new MyTerminalControlButton<MyRemoteControl>("MoveUp", MySpaceTexts.BlockActionTitle_MoveWaypointUp, MySpaceTexts.Blank, (b) => b.MoveWaypointsUp());
            moveUp.Enabled = r => r.CanMoveWaypointsUp();
            moveUp.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveUp);

            var moveDown = new MyTerminalControlButton<MyRemoteControl>("MoveDown", MySpaceTexts.BlockActionTitle_MoveWaypointDown, MySpaceTexts.Blank, (b) => b.MoveWaypointsDown());
            moveDown.Enabled = r => r.CanMoveWaypointsDown();
            moveDown.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(moveDown);

            var addButton = new MyTerminalControlButton<MyRemoteControl>("AddWaypoint", MySpaceTexts.BlockActionTitle_AddWaypoint, MySpaceTexts.Blank, (b) => b.AddWaypoints());
            addButton.Enabled = r => r.CanAddWaypoints();
            addButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(addButton);

            var gpsList = new MyTerminalControlListbox<MyRemoteControl>("GpsList", MySpaceTexts.BlockPropertyTitle_GpsLocations, MySpaceTexts.Blank, true);
            gpsList.ListContent = (x, list1, list2) => x.FillGpsList(list1, list2);
            gpsList.ItemSelected = (x, y) => x.SelectGps(y);
            if (!MySandboxGame.IsDedicated)
            {
                m_gpsGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)gpsList.GetGuiControl()).PropertyControl;
            }
            MyTerminalControlFactory.AddControl(gpsList);

            foreach (var direction in m_directionNames)
            {
                var setDirectionAction = new MyTerminalAction<MyRemoteControl>(MyTexts.Get(direction.Value).ToString(), MyTexts.Get(direction.Value), OnAction, null, MyTerminalActionIcons.TOGGLE);
                setDirectionAction.Enabled = (b) => b.IsWorking;
                setDirectionAction.ParameterDefinitions.Add(TerminalActionParameter.Get((byte)direction.Key));
                MyTerminalControlFactory.AddAction(setDirectionAction);
            }

            var resetButton = new MyTerminalControlButton<MyRemoteControl>("Reset", MySpaceTexts.BlockActionTitle_WaypointReset, MySpaceTexts.BlockActionTooltip_WaypointReset, (b) => b.ResetWaypoint());
            resetButton.Enabled = r => r.IsWorking;
            resetButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(resetButton);

            var copyButton = new MyTerminalControlButton<MyRemoteControl>("Copy", MySpaceTexts.BlockActionTitle_RemoteCopy, MySpaceTexts.Blank, (b) => b.CopyAutopilotSetup());
            copyButton.Enabled = r => r.IsWorking;
            copyButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(copyButton);

            var pasteButton = new MyTerminalControlButton<MyRemoteControl>("Paste", MySpaceTexts.BlockActionTitle_RemotePaste, MySpaceTexts.Blank, (b) => b.PasteAutopilotSetup());
            pasteButton.Enabled = r => r.IsWorking && MyRemoteControl.m_clipboard != null;
            pasteButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(pasteButton);
        }