Ejemplo n.º 1
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyCameraBlock>())
            {
                return;
            }
            base.CreateTerminalControls();
            var viewBtn = new MyTerminalControlButton <MyCameraBlock>("View", MySpaceTexts.BlockActionTitle_View, MySpaceTexts.Blank, (b) => b.RequestSetView());

            viewBtn.Enabled = (b) => b.CanUse();
            viewBtn.SupportsMultipleBlocks = false;
            var action = viewBtn.EnableAction(MyTerminalActionIcons.TOGGLE);

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

            var controlName = MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);

            m_hudNotification = new MyHudNotification(MySpaceTexts.NotificationHintPressToExitCamera);
            m_hudNotification.SetTextFormatArguments(controlName);
        }
Ejemplo n.º 2
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyGasGenerator>())
            {
                return;
            }

            var useConveyorSystem = new MyTerminalControlOnOffSwitch <MyGasGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem);

            useConveyorSystem.Getter = (x) => x.UseConveyorSystem;
            useConveyorSystem.Setter = (x, v) => x.UseConveyorSystem = v;
            useConveyorSystem.EnableToggleAction();
            MyTerminalControlFactory.AddControl(useConveyorSystem);

            var refillButton = new MyTerminalControlButton <MyGasGenerator>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed);

            refillButton.Enabled = (x) => x.CanRefill();
            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox <MyGasGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill);

            autoRefill.Getter = (x) => x.AutoRefill;
            autoRefill.Setter = (x, v) => x.ChangeAutoRefill(v);
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
Ejemplo n.º 3
0
        static MyGasTank()
        {
            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);
        }
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyMechanicalConnectionBlockBase>())
            {
                return;
            }
            base.CreateTerminalControls();
            var weldSpeed = new MyTerminalControlSlider <MyMechanicalConnectionBlockBase>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);

            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter             = (x) => x.m_weldSpeed;
            weldSpeed.Setter             = (x, v) => x.m_weldSpeed.Value = v;
            weldSpeed.Writer             = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox <MyMechanicalConnectionBlockBase>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);

            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);

            var addPistonHead = new MyTerminalControlButton <MyMechanicalConnectionBlockBase>("Add Top Part", MySpaceTexts.BlockActionTitle_AddPistonHead, MySpaceTexts.BlockActionTooltip_AddPistonHead, (b) => b.RecreateTop());

            addPistonHead.Enabled = (b) => (b.TopBlock == null);
            addPistonHead.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addPistonHead);
        }
Ejemplo n.º 5
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyPistonBase>())
            {
                return;
            }

            var reverse = new MyTerminalControlButton <MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.Velocity.Value = -x.Velocity);

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction <MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);

            extendAction.Enabled = (b) => b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);

            var retractAction = new MyTerminalAction <MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);

            retractAction.Enabled = (b) => b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider <MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);

            velocity.SetLimits((block) => - block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter       = (x) => x.Velocity;
            velocity.Setter       = (x, v) => x.Velocity.Value = v;
            velocity.Writer       = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider <MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);

            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter             = (x) => x.MaxLimit;
            maxDist.Setter             = (x, v) => x.MaxLimit.Value = v;
            maxDist.Writer             = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider <MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);

            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter             = (x) => x.MinLimit;
            minDist.Setter             = (x, v) => x.MinLimit.Value = v;
            minDist.Writer             = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);


            var addPistonHead = new MyTerminalControlButton <MyPistonBase>("Add Piston Head", MySpaceTexts.BlockActionTitle_AddPistonHead, MySpaceTexts.BlockActionTooltip_AddPistonHead, (b) => b.RecreateTop());

            addPistonHead.Enabled = (b) => (b.m_topBlock == null);
            addPistonHead.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addPistonHead);
        }
Ejemplo n.º 6
0
        static MyWarhead()
        {
            var slider = new MyTerminalControlSlider <MyWarhead>("DetonationTime", MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime, MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime);

            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled      = (x) => !x.IsCountingDown;
            slider.Getter       = (x) => x.DetonationTime;
            slider.Setter       = (x, v) => x.m_countdownMs.Value = (int)(v * 1000);
            slider.Writer       = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMs, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var startButton = new MyTerminalControlButton <MyWarhead>(
                "StartCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, true));

            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton <MyWarhead>(
                "StopCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, false));

            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);

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

            var safetyCheckbox = new MyTerminalControlCheckbox <MyWarhead>(
                "Safety",
                MySpaceTexts.TerminalControlPanel_Warhead_Safety,
                MySpaceTexts.TerminalControlPanel_Warhead_SafetyTooltip,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextDisarmed,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextArmed);

            safetyCheckbox.Getter = (x) => !x.IsArmed;
            safetyCheckbox.Setter = (x, v) => x.IsArmed = !v;
            safetyCheckbox.EnableAction();
            MyTerminalControlFactory.AddControl(safetyCheckbox);

            var detonateButton = new MyTerminalControlButton <MyWarhead>(
                "Detonate",
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                (b) => { if (b.IsArmed)
                         {
                             MyMultiplayer.RaiseEvent(b, x => x.DetonateRequest);
                         }
                });

            detonateButton.Enabled = (x) => x.IsArmed;
            detonateButton.EnableAction();
            MyTerminalControlFactory.AddControl(detonateButton);
        }
Ejemplo n.º 7
0
        static MyTimerBlock()
        {
            m_openedToolbars = new List <MyToolbar>();

            var silent = new MyTerminalControlCheckbox <MyTimerBlock>("Silent", MySpaceTexts.BlockPropertyTitle_Silent, MySpaceTexts.ToolTipTimerBlock_Silent);

            silent.Getter = (x) => x.Silent;
            silent.Setter = (x, v) => x.Silent = v;
            silent.EnableAction();
            MyTerminalControlFactory.AddControl(silent);

            var slider = new MyTerminalControlSlider <MyTimerBlock>("TriggerDelay", MySpaceTexts.TerminalControlPanel_TimerDelay, MySpaceTexts.TerminalControlPanel_TimerDelay);

            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled      = (x) => !x.IsCountingDown;
            slider.Getter       = (x) => x.TriggerDelay;
            slider.Setter       = (x, v) => x.m_timerSync.Value = ((int)(Math.Round(v, 1) * 1000));
            slider.Writer       = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMsStart, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var toolbarButton = new MyTerminalControlButton <MyTimerBlock>("OpenToolbar", MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen, MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen,
                                                                           delegate(MyTimerBlock self)
            {
                m_openedToolbars.Add(self.Toolbar);
                if (MyGuiScreenCubeBuilder.Static == null)
                {
                    m_shouldSetOtherToolbars          = true;
                    MyToolbarComponent.CurrentToolbar = self.Toolbar;
                    MyGuiScreenBase screen            = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                    MyToolbarComponent.AutoUpdate     = false;
                    screen.Closed += (source) =>
                    {
                        MyToolbarComponent.AutoUpdate = true;
                        m_openedToolbars.Clear();
                    };
                    MyGuiSandbox.AddScreen(screen);
                }
            });

            MyTerminalControlFactory.AddControl(toolbarButton);

            var triggerButton = new MyTerminalControlButton <MyTimerBlock>("TriggerNow", MySpaceTexts.BlockPropertyTitle_TimerTrigger, MySpaceTexts.BlockPropertyTitle_TimerTrigger, (x) => x.OnTrigger());

            triggerButton.EnableAction();
            MyTerminalControlFactory.AddControl(triggerButton);

            var startButton = new MyTerminalControlButton <MyTimerBlock>("Start", MySpaceTexts.BlockPropertyTitle_TimerStart, MySpaceTexts.BlockPropertyTitle_TimerStart, (x) => x.StartBtn());

            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton <MyTimerBlock>("Stop", MySpaceTexts.BlockPropertyTitle_TimerStop, MySpaceTexts.BlockPropertyTitle_TimerStop, (x) => x.StopBtn());

            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);
        }
Ejemplo n.º 8
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyLandingGear>())
            {
                return;
            }
            base.CreateTerminalControls();
            var stateWriter = new MyTerminalControl <MyLandingGear> .WriterDelegate((b, sb) => b.WriteLockStateValue(sb));

            var lockBtn = new MyTerminalControlButton <MyLandingGear>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.RequestLandingGearLock());

            lockBtn.Enabled = (b) => b.IsWorking;
            lockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
            MyTerminalControlFactory.AddControl(lockBtn);

            var unlockBtn = new MyTerminalControlButton <MyLandingGear>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.RequestLandingGearUnlock());

            unlockBtn.Enabled = (b) => b.IsWorking;
            unlockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
            MyTerminalControlFactory.AddControl(unlockBtn);

            var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
            MyTerminalAction <MyLandingGear> switchLockAction = new MyTerminalAction <MyLandingGear>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);

            switchLockAction.Action = (b) => b.RequestLandingGearSwitch();
            switchLockAction.Writer = stateWriter;
            MyTerminalControlFactory.AddAction(switchLockAction);

            var autoLock = new MyTerminalControlCheckbox <MyLandingGear>("Autolock", MySpaceTexts.BlockPropertyTitle_LandGearAutoLock, MySpaceTexts.Blank);

            autoLock.Getter = (b) => b.m_autoLock;
            autoLock.Setter = (b, v) => b.m_autoLock.Value = v;
            autoLock.EnableAction();
            MyTerminalControlFactory.AddControl(autoLock);

            if (MyFakes.LANDING_GEAR_BREAKABLE)
            {
                var brakeForce = new MyTerminalControlSlider <MyLandingGear>("BreakForce", MySpaceTexts.BlockPropertyTitle_BreakForce, MySpaceTexts.BlockPropertyDescription_BreakForce);
                brakeForce.Getter       = (x) => x.BreakForce;
                brakeForce.Setter       = (x, v) => x.m_breakForceSync.Value = v;
                brakeForce.DefaultValue = 1;
                brakeForce.Writer       = (x, result) =>
                {
                    if (x.BreakForce >= MyObjectBuilder_LandingGear.MaxSolverImpulse)
                    {
                        result.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
                    }
                    else
                    {
                        MyValueFormatter.AppendForceInBestUnit(x.BreakForce, result);
                    }
                };
                brakeForce.Normalizer   = (b, v) => ThresholdToRatio(v);
                brakeForce.Denormalizer = (b, v) => RatioToThreshold(v);
                brakeForce.EnableActions();
                MyTerminalControlFactory.AddControl(brakeForce);
            }
        }
Ejemplo n.º 9
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MySoundBlock>())
            {
                return;
            }

            var volumeSlider = new MyTerminalControlSlider <MySoundBlock>("VolumeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockVolume, MySpaceTexts.BlockPropertyDescription_SoundBlockVolume);

            volumeSlider.SetLimits(0, 1.0f);
            volumeSlider.DefaultValue = 1;
            volumeSlider.Getter       = (x) => x.Volume;
            volumeSlider.Setter       = (x, v) => x.Volume = v;
            volumeSlider.Writer       = (x, result) => result.AppendInt32((int)(x.Volume * 100.0)).Append(" %");
            volumeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(volumeSlider);

            var rangeSlider = new MyTerminalControlSlider <MySoundBlock>("RangeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockRange, MySpaceTexts.BlockPropertyDescription_SoundBlockRange);

            rangeSlider.SetLimits(0, 500);
            rangeSlider.DefaultValue = 50;
            rangeSlider.Getter       = (x) => x.Range;
            rangeSlider.Setter       = (x, v) => x.Range = v;
            rangeSlider.Writer       = (x, result) => result.AppendInt32((int)x.Range).Append(" m");
            rangeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(rangeSlider);

            m_playButton         = new MyTerminalControlButton <MySoundBlock>("PlaySound", MySpaceTexts.BlockPropertyTitle_SoundBlockPlay, MySpaceTexts.Blank, (x) => MyMultiplayer.RaiseEvent(x, y => y.PlaySound));
            m_playButton.Enabled = (x) => x.IsSoundSelected;
            m_playButton.EnableAction();
            MyTerminalControlFactory.AddControl(m_playButton);

            m_stopButton = new MyTerminalControlButton <MySoundBlock>("StopSound", MySpaceTexts.BlockPropertyTitle_SoundBlockStop, MySpaceTexts.Blank,
                                                                      (x) => { MyMultiplayer.RaiseEvent(x, y => y.StopSound); x.m_willStartSound = false; });
            m_stopButton.Enabled = (x) => x.IsSoundSelected;
            m_stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(m_stopButton);

            m_loopableTimeSlider = new MyTerminalControlSlider <MySoundBlock>("LoopableSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockLoopTime, MySpaceTexts.Blank);
            m_loopableTimeSlider.DefaultValue = 1f;
            m_loopableTimeSlider.Getter       = (x) => x.LoopPeriod;
            m_loopableTimeSlider.Setter       = (x, f) => x.LoopPeriod = f;
            m_loopableTimeSlider.Writer       = (x, result) => MyValueFormatter.AppendTimeInBestUnit(x.LoopPeriod, result);
            m_loopableTimeSlider.Enabled      = (x) => x.IsLoopable;
            m_loopableTimeSlider.Normalizer   = (x, f) => x.NormalizeLoopPeriod(f);
            m_loopableTimeSlider.Denormalizer = (x, f) => x.DenormalizeLoopPeriod(f);
            m_loopableTimeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(m_loopableTimeSlider);

            var soundsList = new MyTerminalControlListbox <MySoundBlock>("SoundsList", MySpaceTexts.BlockPropertyTitle_SoundBlockSoundList, MySpaceTexts.Blank);

            soundsList.ListContent  = (x, list1, list2) => x.FillListContent(list1, list2);
            soundsList.ItemSelected = (x, y) => x.SelectSound(y, true);
            MyTerminalControlFactory.AddControl(soundsList);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        static MySoundBlock()
        {
            var volumeSlider = new MyTerminalControlSlider <MySoundBlock>("VolumeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockVolume, MySpaceTexts.BlockPropertyDescription_SoundBlockVolume);

            volumeSlider.SetLimits(0, 1.0f);
            volumeSlider.DefaultValue = 1;
            volumeSlider.Getter       = (x) => x.Volume;
            volumeSlider.Setter       = (x, v) => x.SyncObject.SendChangeSoundVolumeRequest(v);
            volumeSlider.Writer       = (x, result) => result.AppendInt32((int)(x.Volume * 100.0)).Append(" %");
            volumeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(volumeSlider);

            var rangeSlider = new MyTerminalControlSlider <MySoundBlock>("RangeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockRange, MySpaceTexts.BlockPropertyDescription_SoundBlockRange);

            rangeSlider.SetLimits(0, 500);
            rangeSlider.DefaultValue = 50;
            rangeSlider.Getter       = (x) => x.Range;
            rangeSlider.Setter       = (x, v) => x.SyncObject.SendChangeSoundRangeRequest(v);
            rangeSlider.Writer       = (x, result) => result.AppendInt32((int)x.Range).Append(" m");
            rangeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(rangeSlider);

            var playButton = new MyTerminalControlButton <MySoundBlock>("PlaySound", MySpaceTexts.BlockPropertyTitle_SoundBlockPlay, MySpaceTexts.Blank, (x) => x.SyncObject.SendPlaySoundRequest());

            playButton.Enabled = (x) => x.IsSoundSelected;
            playButton.EnableAction();
            MyTerminalControlFactory.AddControl(playButton);

            var stopButton = new MyTerminalControlButton <MySoundBlock>("StopSound", MySpaceTexts.BlockPropertyTitle_SoundBlockStop, MySpaceTexts.Blank, (x) => x.SyncObject.SendStopSoundRequest());

            stopButton.Enabled = (x) => x.IsSoundSelected;
            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);

            var loopableTimeSlider = new MyTerminalControlSlider <MySoundBlock>("LoopableSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockLoopTime, MySpaceTexts.Blank);

            loopableTimeSlider.DefaultValue = 1f;
            loopableTimeSlider.Getter       = (x) => x.LoopPeriod;
            loopableTimeSlider.Setter       = (x, f) => x.SyncObject.SendChangeLoopPeriodRequest(f);
            loopableTimeSlider.Writer       = (x, result) => MyValueFormatter.AppendTimeInBestUnit(x.LoopPeriod, result);
            loopableTimeSlider.Enabled      = (x) => x.IsLoopable;
            loopableTimeSlider.Normalizer   = (x, f) => x.NormalizeLoopPeriod(f);
            loopableTimeSlider.Denormalizer = (x, f) => x.DenormalizeLoopPeriod(f);
            loopableTimeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(loopableTimeSlider);

            var soundsList = new MyTerminalControlListbox <MySoundBlock>("SoundsList", MySpaceTexts.BlockPropertyTitle_SoundBlockSoundList, MySpaceTexts.Blank);

            soundsList.ListContent  = (x, list1, list2) => x.FillListContent(list1, list2);
            soundsList.ItemSelected = (x, y) => x.SelectSound(y, true);
            MyTerminalControlFactory.AddControl(soundsList);
        }
Ejemplo n.º 12
0
        static MyPistonBase()
        {
            var reverse = new MyTerminalControlButton <MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.SyncObject.SetVelocity(-x.Velocity));

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction <MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);

            extendAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);

            var retractAction = new MyTerminalAction <MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);

            retractAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider <MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);

            velocity.SetLimits((block) => - block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter       = (x) => x.Velocity;
            velocity.Setter       = (x, v) => x.SyncObject.SetVelocity(v);
            velocity.Writer       = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider <MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);

            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter             = (x) => x.MaxLimit;
            maxDist.Setter             = (x, v) => x.SyncObject.SetMax(v);
            maxDist.Writer             = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider <MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);

            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter             = (x) => x.MinLimit;
            minDist.Setter             = (x, v) => x.SyncObject.SetMin(v);
            minDist.Writer             = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);
        }
Ejemplo n.º 13
0
        static MyCameraBlock()
        {
            var viewBtn = new MyTerminalControlButton<MyCameraBlock>("View", MySpaceTexts.BlockActionTitle_View, MySpaceTexts.Blank, (b) => b.RequestSetView());
            viewBtn.Enabled = (b) => b.CanUse();
            viewBtn.SupportsMultipleBlocks = false;
            var action = viewBtn.EnableAction(MyTerminalActionIcons.TOGGLE);
            if (action != null)
            {
                action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel };
                action.ValidForGroups = false;
            }
            MyTerminalControlFactory.AddControl(viewBtn);

            var controlName = MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
            m_hudNotification = new MyHudNotification(MySpaceTexts.NotificationHintPressToExitCamera);
            m_hudNotification.SetTextFormatArguments(controlName);
        }
        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>());
            }
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        static MyOxygenGenerator()
        {
            var useConveyorSystem = new MyTerminalControlOnOffSwitch<MyOxygenGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem);
            useConveyorSystem.Getter = (x) => (x as IMyInventoryOwner).UseConveyorSystem;
            useConveyorSystem.Setter = (x, v) => MySyncConveyors.SendChangeUseConveyorSystemRequest(x.EntityId, v);
            useConveyorSystem.EnableToggleAction();
            MyTerminalControlFactory.AddControl(useConveyorSystem);

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

            var autoRefill = new MyTerminalControlCheckbox<MyOxygenGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill);
            autoRefill.Getter = (x) => x.m_autoRefill;
            autoRefill.Setter = (x, v) => x.m_autoRefill = v;
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
Ejemplo n.º 18
0
        static MyGasGenerator()
        {
            var useConveyorSystem = new MyTerminalControlOnOffSwitch<MyGasGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem);
            useConveyorSystem.Getter = (x) => x.UseConveyorSystem;
            useConveyorSystem.Setter = (x, v) => x.UseConveyorSystem = v ;
            useConveyorSystem.EnableToggleAction();
            MyTerminalControlFactory.AddControl(useConveyorSystem);

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

            var autoRefill = new MyTerminalControlCheckbox<MyGasGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill);
            autoRefill.Getter = (x) => x.AutoRefill;
            autoRefill.Setter = (x, v) => x.ChangeAutoRefill(v);
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
Ejemplo n.º 19
0
        static MyOxygenGenerator()
        {
            var useConveyorSystem = new MyTerminalControlOnOffSwitch <MyOxygenGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem);

            useConveyorSystem.Getter = (x) => (x as IMyInventoryOwner).UseConveyorSystem;
            useConveyorSystem.Setter = (x, v) => MySyncConveyors.SendChangeUseConveyorSystemRequest(x.EntityId, v);
            useConveyorSystem.EnableToggleAction();
            MyTerminalControlFactory.AddControl(useConveyorSystem);

            var refillButton = new MyTerminalControlButton <MyOxygenGenerator>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, OnRefillButtonPressed);

            refillButton.Enabled = (x) => x.CanRefill();
            refillButton.EnableAction();
            MyTerminalControlFactory.AddControl(refillButton);

            var autoRefill = new MyTerminalControlCheckbox <MyOxygenGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill);

            autoRefill.Getter = (x) => x.m_autoRefill;
            autoRefill.Setter = (x, v) => x.m_autoRefill = v;
            autoRefill.EnableAction();
            MyTerminalControlFactory.AddControl(autoRefill);
        }
Ejemplo n.º 20
0
 protected override void CreateTerminalControls()
 {
     if (!MyTerminalControlFactory.AreControlsCreated <MyGasGenerator>())
     {
         base.CreateTerminalControls();
         MyStringId tooltip = new MyStringId();
         MyStringId?on      = null;
         on = null;
         MyTerminalControlOnOffSwitch <MyGasGenerator> switch1 = new MyTerminalControlOnOffSwitch <MyGasGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem, tooltip, on, on);
         MyTerminalControlOnOffSwitch <MyGasGenerator> switch2 = new MyTerminalControlOnOffSwitch <MyGasGenerator>("UseConveyor", MySpaceTexts.Terminal_UseConveyorSystem, tooltip, on, on);
         switch2.Getter = x => x.UseConveyorSystem;
         MyTerminalControlOnOffSwitch <MyGasGenerator> local11 = switch2;
         MyTerminalControlOnOffSwitch <MyGasGenerator> local12 = switch2;
         local12.Setter = (x, v) => x.UseConveyorSystem = v;
         MyTerminalControlOnOffSwitch <MyGasGenerator> onOff = local12;
         onOff.EnableToggleAction <MyGasGenerator>();
         MyTerminalControlFactory.AddControl <MyGasGenerator>(onOff);
         MyTerminalControlButton <MyGasGenerator> button1 = new MyTerminalControlButton <MyGasGenerator>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, new Action <MyGasGenerator>(MyGasGenerator.OnRefillButtonPressed));
         MyTerminalControlButton <MyGasGenerator> button2 = new MyTerminalControlButton <MyGasGenerator>("Refill", MySpaceTexts.BlockPropertyTitle_Refill, MySpaceTexts.BlockPropertyTitle_Refill, new Action <MyGasGenerator>(MyGasGenerator.OnRefillButtonPressed));
         button2.Enabled = x => x.CanRefill();
         on = null;
         MyTerminalControlButton <MyGasGenerator> button = button2;
         button.EnableAction <MyGasGenerator>(null, on, null);
         MyTerminalControlFactory.AddControl <MyGasGenerator>(button);
         on = null;
         on = null;
         MyTerminalControlCheckbox <MyGasGenerator> checkbox1 = new MyTerminalControlCheckbox <MyGasGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill, on, on);
         MyTerminalControlCheckbox <MyGasGenerator> checkbox2 = new MyTerminalControlCheckbox <MyGasGenerator>("Auto-Refill", MySpaceTexts.BlockPropertyTitle_AutoRefill, MySpaceTexts.BlockPropertyTitle_AutoRefill, on, on);
         checkbox2.Getter = x => x.AutoRefill;
         MyTerminalControlCheckbox <MyGasGenerator> local9  = checkbox2;
         MyTerminalControlCheckbox <MyGasGenerator> local10 = checkbox2;
         local10.Setter = (x, v) => x.AutoRefill = v;
         MyTerminalControlCheckbox <MyGasGenerator> checkbox = local10;
         checkbox.EnableAction <MyGasGenerator>(null);
         MyTerminalControlFactory.AddControl <MyGasGenerator>(checkbox);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 22
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyMotorSuspension>())
                return;

            var steering = new MyTerminalControlCheckbox<MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);
            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.Steering = v;
            steering.EnableAction();
            steering.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steering);

            var maxSteerAngle = new MyTerminalControlSlider<MyMotorSuspension>("MaxSteerAngle", MySpaceTexts.BlockPropertyTitle_Motor_MaxSteerAngle, MySpaceTexts.BlockPropertyDescription_Motor_MaxSteerAngle);
            maxSteerAngle.SetLimits((x) => 0, (x) => x.BlockDefinition.MaxSteer);
            maxSteerAngle.DefaultValue = 0.45f;
            maxSteerAngle.Getter = (x) => x.GetMaxSteerAngleForTerminal();
            maxSteerAngle.Setter = (x, v) => x.MaxSteerAngle = v;
            maxSteerAngle.Writer = (x, res) => MyMotorStator.WriteAngle(x.GetMaxSteerAngleForTerminal(), res);
            maxSteerAngle.EnableActionsWithReset();
            maxSteerAngle.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(maxSteerAngle);

            var steerSpeed = new MyTerminalControlSlider<MyMotorSuspension>("SteerSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerSpeed);
            steerSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerSpeed.DefaultValue = 2f;
            steerSpeed.Getter = (x) => x.GetSteerSpeedForTerminal();
            steerSpeed.Setter = (x, v) => x.SteerSpeed = v / 100;
            steerSpeed.Writer = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerSpeedForTerminal(), res);
            steerSpeed.EnableActionsWithReset();
            steerSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerSpeed);

            var steerReturnSpeed = new MyTerminalControlSlider<MyMotorSuspension>("SteerReturnSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerReturnSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerReturnSpeed);
            steerReturnSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerReturnSpeed.DefaultValue = 1f;
            steerReturnSpeed.Getter = (x) => x.GetSteerReturnSpeedForTerminal();
            steerReturnSpeed.Setter = (x, v) => x.SteerReturnSpeed = v / 100;
            steerReturnSpeed.Writer = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerReturnSpeedForTerminal(), res);
            steerReturnSpeed.EnableActionsWithReset();
            steerReturnSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerReturnSpeed);

            var invertSteer = new MyTerminalControlCheckbox<MyMotorSuspension>("InvertSteering", MySpaceTexts.BlockPropertyTitle_Motor_InvertSteer, MySpaceTexts.BlockPropertyDescription_Motor_InvertSteer);
            invertSteer.Getter = (x) => x.InvertSteer;
            invertSteer.Setter = (x, v) => x.InvertSteer = v;
            invertSteer.EnableAction();
            invertSteer.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertSteer);

            var propulsion = new MyTerminalControlCheckbox<MyMotorSuspension>("Propulsion", MySpaceTexts.BlockPropertyTitle_Motor_Propulsion, MySpaceTexts.BlockPropertyDescription_Motor_Propulsion);
            propulsion.Getter = (x) => x.Propulsion;
            propulsion.Setter = (x, v) => x.Propulsion = v;
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            var invertPropulsion = new MyTerminalControlCheckbox<MyMotorSuspension>("InvertPropulsion", MySpaceTexts.BlockPropertyTitle_Motor_InvertPropulsion, MySpaceTexts.BlockPropertyDescription_Motor_InvertPropulsion);
            invertPropulsion.Getter = (x) => x.InvertPropulsion;
            invertPropulsion.Setter = (x, v) => x.InvertPropulsion = v;
            invertPropulsion.EnableAction();
            invertPropulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertPropulsion);

            var power = new MyTerminalControlSlider<MyMotorSuspension>("Power", MySpaceTexts.BlockPropertyTitle_Motor_Power, MySpaceTexts.BlockPropertyDescription_Motor_Power);
            power.SetLimits(0, 100);
            power.DefaultValue = 100;
            power.Getter = (x) => x.GetPowerForTerminal();
            power.Setter = (x, v) => x.Power = v / 100;
            power.Writer = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            power.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(power);

            var friction = new MyTerminalControlSlider<MyMotorSuspension>("Friction", MySpaceTexts.BlockPropertyTitle_Motor_Friction, MySpaceTexts.BlockPropertyDescription_Motor_Friction);
            friction.SetLimits(0, 100);
            friction.DefaultValue = 150f / 800;
            friction.Getter = (x) => x.GetFrictionForTerminal();
            friction.Setter = (x, v) => x.Friction = v / 100;
            friction.Writer = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            friction.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(friction);

            var damping = new MyTerminalControlSlider<MyMotorSuspension>("Damping", MySpaceTexts.BlockPropertyTitle_Motor_Damping, MySpaceTexts.BlockPropertyTitle_Motor_Damping);
            damping.SetLimits(0, 100);
            damping.Getter = (x) => x.GetDampingForTerminal();
            damping.Setter = (x, v) => x.Damping = v / 100;
            damping.Writer = (x, res) => res.AppendInt32((int)(x.GetDampingForTerminal())).Append("%");
            damping.EnableActions();
            damping.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(damping);

            var strength = new MyTerminalControlSlider<MyMotorSuspension>("Strength", MySpaceTexts.BlockPropertyTitle_Motor_Strength, MySpaceTexts.BlockPropertyTitle_Motor_Strength);
            strength.SetLimits(0, 100);
            strength.Getter = (x) => x.GetStrengthForTerminal();
            strength.Setter = (x, v) => x.Strength = v / 100;
            strength.Writer = (x, res) => res.AppendInt32((int)(x.GetStrengthForTerminal())).Append("%");
            strength.EnableActions();
            strength.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(strength);

            var height = new MyTerminalControlSlider<MyMotorSuspension>("Height", MySpaceTexts.BlockPropertyTitle_Motor_Height, MySpaceTexts.BlockPropertyDescription_Motor_Height);
            height.SetLimits((x) => x.BlockDefinition.MinHeight, (x) => x.BlockDefinition.MaxHeight);
            height.DefaultValue = 0;
            height.Getter = (x) => x.GetHeightForTerminal();
            height.Setter = (x, v) => x.Height = v;
            height.Writer = (x, res) => MyValueFormatter.AppendDistanceInBestUnit(x.Height, res);
            height.EnableActionsWithReset();
            height.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(height);

            var travel = new MyTerminalControlSlider<MyMotorSuspension>("Travel", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionTravel, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionTravel);
            travel.SetLimits(0, 100);
            travel.DefaultValue = 100;
            travel.Getter = (x) => x.GetSuspensionTravelForTerminal();
            travel.Setter = (x, v) => x.SuspensionTravel = v / 100.0f;
            travel.Writer = (x, res) => res.AppendInt32((int)x.GetSuspensionTravelForTerminal()).Append("%");
            travel.EnableActionsWithReset();
            travel.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(travel);

            var speed = new MyTerminalControlSlider<MyMotorSuspension>("Speed Limit", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionSpeed);
            speed.SetLimits(0, MaxSpeedLimit);
            speed.DefaultValue = MaxSpeedLimit;
            speed.Getter = (x) => x.SpeedLimit;
            speed.Setter = (x, v) => x.SpeedLimit = v;
            speed.Writer = (x, res) =>
            {
                if (x.SpeedLimit >= MyMotorSuspension.MaxSpeedLimit)
                    res.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
                else
                    res.AppendInt32((int)x.SpeedLimit).Append("km/h");
            };
            speed.EnableActionsWithReset();
            speed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(speed);

            var addWheel = new MyTerminalControlButton<MyMotorSuspension>("Add Wheel", MySpaceTexts.BlockActionTitle_AddWheel, MySpaceTexts.BlockActionTooltip_AddWheel, (b) => b.RecreateRotor());
            addWheel.Enabled = (b) => (b.m_topBlock == null);
            addWheel.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addWheel);
        }
Ejemplo n.º 23
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MySpaceProjector>())
            {
                return;
            }
            base.CreateTerminalControls();
            if (!MyFakes.ENABLE_PROJECTOR_BLOCK)
            {
                return;
            }

            var blueprintBtn = new MyTerminalControlButton <MySpaceProjector>("Blueprint", MyCommonTexts.Blueprints, MySpaceTexts.Blank, (p) => p.SelectBlueprint());

            blueprintBtn.Enabled = (b) => b.CanProject();
            blueprintBtn.SupportsMultipleBlocks = false;

            MyTerminalControlFactory.AddControl(blueprintBtn);

            var removeBtn = new MyTerminalControlButton <MySpaceProjector>("Remove", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (p) => p.SendRemoveProjection());

            removeBtn.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(removeBtn);

            var keepProjectionToggle = new MyTerminalControlCheckbox <MySpaceProjector>("KeepProjection", MySpaceTexts.KeepProjectionToggle, MySpaceTexts.KeepProjectionTooltip);

            keepProjectionToggle.Getter = (x) => x.KeepProjection;
            keepProjectionToggle.Setter = (x, v) => x.KeepProjection = v;
            keepProjectionToggle.EnableAction();
            keepProjectionToggle.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(keepProjectionToggle);

            //ShowOnlyBuildable
            var showOnlyBuildableBlockToggle = new MyTerminalControlCheckbox <MySpaceProjector>("ShowOnlyBuildable", MySpaceTexts.ShowOnlyBuildableBlockToggle, MySpaceTexts.ShowOnlyBuildableTooltip);

            showOnlyBuildableBlockToggle.Getter = (x) => x.m_showOnlyBuildable;
            showOnlyBuildableBlockToggle.Setter = (x, v) =>
            {
                x.m_showOnlyBuildable = v;
                x.OnOffsetsChanged();
            };
            showOnlyBuildableBlockToggle.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(showOnlyBuildableBlockToggle);

            //Position
            var offsetX = new MyTerminalControlSlider <MySpaceProjector>("X", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetX, MySpaceTexts.Blank);

            offsetX.SetLimits(-50, 50);
            offsetX.DefaultValue = 0;
            offsetX.Getter       = (x) => x.m_projectionOffset.X;
            offsetX.Setter       = (x, v) =>
            {
                x.m_projectionOffset.X = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetX.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.X));
            offsetX.EnableActions(step: 0.01f);
            offsetX.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetX);

            var offsetY = new MyTerminalControlSlider <MySpaceProjector>("Y", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetY, MySpaceTexts.Blank);

            offsetY.SetLimits(-50, 50);
            offsetY.DefaultValue = 0;
            offsetY.Getter       = (x) => x.m_projectionOffset.Y;
            offsetY.Setter       = (x, v) =>
            {
                x.m_projectionOffset.Y = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetY.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Y));
            offsetY.EnableActions(step: 0.01f);
            offsetY.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetY);

            var offsetZ = new MyTerminalControlSlider <MySpaceProjector>("Z", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetZ, MySpaceTexts.Blank);

            offsetZ.SetLimits(-50, 50);
            offsetZ.DefaultValue = 0;
            offsetZ.Getter       = (x) => x.m_projectionOffset.Z;
            offsetZ.Setter       = (x, v) =>
            {
                x.m_projectionOffset.Z = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetZ.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Z));
            offsetZ.EnableActions(step: 0.01f);
            offsetZ.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetZ);

            //Rotation

            var rotationX = new MyTerminalControlSlider <MySpaceProjector>("RotX", MySpaceTexts.BlockPropertyTitle_ProjectionRotationX, MySpaceTexts.Blank);

            rotationX.SetLimits(-2, 2);
            rotationX.DefaultValue = 0;
            rotationX.Getter       = (x) => x.m_projectionRotation.X;
            rotationX.Setter       = (x, v) =>
            {
                x.m_projectionRotation.X = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationX.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.X * 90).Append("°");
            rotationX.EnableActions(step: 0.2f);
            rotationX.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationX);

            var rotationY = new MyTerminalControlSlider <MySpaceProjector>("RotY", MySpaceTexts.BlockPropertyTitle_ProjectionRotationY, MySpaceTexts.Blank);

            rotationY.SetLimits(-2, 2);
            rotationY.DefaultValue = 0;
            rotationY.Getter       = (x) => x.m_projectionRotation.Y;
            rotationY.Setter       = (x, v) =>
            {
                x.m_projectionRotation.Y = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationY.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Y * 90).Append("°");
            rotationY.EnableActions(step: 0.2f);
            rotationY.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationY);

            var rotationZ = new MyTerminalControlSlider <MySpaceProjector>("RotZ", MySpaceTexts.BlockPropertyTitle_ProjectionRotationZ, MySpaceTexts.Blank);

            rotationZ.SetLimits(-2, 2);
            rotationZ.DefaultValue = 0;
            rotationZ.Getter       = (x) => x.m_projectionRotation.Z;
            rotationZ.Setter       = (x, v) =>
            {
                x.m_projectionRotation.Z = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationZ.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Z * 90).Append("°");
            rotationZ.EnableActions(step: 0.2f);
            rotationZ.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationZ);

            var scenarioSettingsSeparator = new MyTerminalControlSeparator <MySpaceProjector>();

            scenarioSettingsSeparator.Visible = (p) => p.ScenarioSettingsEnabled();
            MyTerminalControlFactory.AddControl(scenarioSettingsSeparator);

            var scenarioSettingsLabel = new MyTerminalControlLabel <MySpaceProjector>(MySpaceTexts.TerminalScenarioSettingsLabel);

            scenarioSettingsLabel.Visible = (p) => p.ScenarioSettingsEnabled();
            MyTerminalControlFactory.AddControl(scenarioSettingsLabel);

            var spawnProjectionButton = new MyTerminalControlButton <MySpaceProjector>("SpawnProjection", MySpaceTexts.BlockPropertyTitle_ProjectionSpawn, MySpaceTexts.Blank, (p) => p.TrySpawnProjection());

            spawnProjectionButton.Visible = (p) => p.ScenarioSettingsEnabled();
            spawnProjectionButton.Enabled = (p) => p.CanSpawnProjection();
            spawnProjectionButton.EnableAction();
            MyTerminalControlFactory.AddControl(spawnProjectionButton);

            var instantBuildingCheckbox = new MyTerminalControlCheckbox <MySpaceProjector>("InstantBuilding", MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding, MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding_Tooltip);

            instantBuildingCheckbox.Visible = (p) => p.ScenarioSettingsEnabled();
            instantBuildingCheckbox.Enabled = (p) => p.CanEnableInstantBuilding();
            instantBuildingCheckbox.Getter  = (p) => p.InstantBuildingEnabled;
            instantBuildingCheckbox.Setter  = (p, v) => p.TrySetInstantBuilding(v);
            MyTerminalControlFactory.AddControl(instantBuildingCheckbox);

            var getOwnershipCheckbox = new MyTerminalControlCheckbox <MySpaceProjector>("GetOwnership", MySpaceTexts.BlockPropertyTitle_Projector_GetOwnership, MySpaceTexts.BlockPropertiesTooltip_Projector_GetOwnership);

            getOwnershipCheckbox.Visible = (p) => p.ScenarioSettingsEnabled();
            getOwnershipCheckbox.Enabled = (p) => p.CanEditInstantBuildingSettings();
            getOwnershipCheckbox.Getter  = (p) => p.GetOwnershipFromProjector;
            getOwnershipCheckbox.Setter  = (p, v) => p.TrySetGetOwnership(v);
            MyTerminalControlFactory.AddControl(getOwnershipCheckbox);

            var numberOfProjections = new MyTerminalControlSlider <MySpaceProjector>("NumberOfProjections", MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections, MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections_Tooltip);

            numberOfProjections.Visible = (p) => p.ScenarioSettingsEnabled();
            numberOfProjections.Enabled = (p) => p.CanEditInstantBuildingSettings();
            numberOfProjections.Getter  = (p) => p.MaxNumberOfProjections;
            numberOfProjections.Setter  = (p, v) => p.TryChangeNumberOfProjections(v);
            numberOfProjections.Writer  = (p, s) =>
            {
                if (p.MaxNumberOfProjections == MAX_NUMBER_OF_PROJECTIONS)
                {
                    s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite));
                }
                else
                {
                    s.AppendInt32(p.MaxNumberOfProjections);
                }
            };
            numberOfProjections.SetLogLimits(1, MAX_NUMBER_OF_PROJECTIONS);
            MyTerminalControlFactory.AddControl(numberOfProjections);

            var numberOfBlocks = new MyTerminalControlSlider <MySpaceProjector>("NumberOfBlocks", MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection, MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection_Tooltip);

            numberOfBlocks.Visible = (p) => p.ScenarioSettingsEnabled();
            numberOfBlocks.Enabled = (p) => p.CanEditInstantBuildingSettings();
            numberOfBlocks.Getter  = (p) => p.MaxNumberOfBlocksPerProjection;
            numberOfBlocks.Setter  = (p, v) => p.TryChangeMaxNumberOfBlocksPerProjection(v);
            numberOfBlocks.Writer  = (p, s) =>
            {
                if (p.MaxNumberOfBlocksPerProjection == MAX_NUMBER_OF_BLOCKS)
                {
                    s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite));
                }
                else
                {
                    s.AppendInt32(p.MaxNumberOfBlocksPerProjection);
                }
            };
            numberOfBlocks.SetLogLimits(1, MAX_NUMBER_OF_BLOCKS);
            MyTerminalControlFactory.AddControl(numberOfBlocks);
        }
Ejemplo n.º 24
0
        static MyWarhead()
        {
            var slider = new MyTerminalControlSlider<MyWarhead>("DetonationTime", MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime, MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime);
            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled = (x) => !x.IsCountingDown;
            slider.Getter = (x) => x.DetonationTime;
            slider.Setter = (x, v) => MySyncWarhead.SetTimer(x, v * 1000);
            slider.Writer = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMs, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var startButton = new MyTerminalControlButton<MyWarhead>(
                "StartCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                (b) => MySyncWarhead.StartCountdown(b));
            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton<MyWarhead>(
                "StopCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                (b) => MySyncWarhead.StopCountdown(b));
            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);

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

            var safetyCheckbox = new MyTerminalControlCheckbox<MyWarhead>(
                "Safety",
                MySpaceTexts.TerminalControlPanel_Warhead_Safety,
                MySpaceTexts.TerminalControlPanel_Warhead_SafetyTooltip,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextDisarmed,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextArmed);
            safetyCheckbox.Getter = (x) => !x.IsArmed;
            safetyCheckbox.Setter = (x, v) => MySyncWarhead.SetArm(x, !v);
            safetyCheckbox.EnableAction();
            MyTerminalControlFactory.AddControl(safetyCheckbox);

            var detonateButton = new MyTerminalControlButton<MyWarhead>(
                "Detonate",
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                (b) => MySyncWarhead.Detonate(b));
            detonateButton.Enabled = (x) => x.IsArmed;
            detonateButton.EnableAction();
            MyTerminalControlFactory.AddControl(detonateButton);
        }
Ejemplo n.º 25
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;
            }
        }
Ejemplo n.º 26
0
        static MySoundBlock()
        {      
            var volumeSlider = new MyTerminalControlSlider<MySoundBlock>("VolumeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockVolume, MySpaceTexts.BlockPropertyDescription_SoundBlockVolume);
            volumeSlider.SetLimits(0, 1.0f);
            volumeSlider.DefaultValue = 1;
            volumeSlider.Getter = (x) => x.Volume;
            volumeSlider.Setter = (x, v) => x.SyncObject.SendChangeSoundVolumeRequest(v);
            volumeSlider.Writer = (x, result) => result.AppendInt32((int)(x.Volume * 100.0)).Append(" %");
            volumeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(volumeSlider);

            var rangeSlider = new MyTerminalControlSlider<MySoundBlock>("RangeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockRange, MySpaceTexts.BlockPropertyDescription_SoundBlockRange);
            rangeSlider.SetLimits(0, 500);
            rangeSlider.DefaultValue = 50;
            rangeSlider.Getter = (x) => x.Range;
            rangeSlider.Setter = (x, v) => x.SyncObject.SendChangeSoundRangeRequest(v);
            rangeSlider.Writer = (x, result) => result.AppendInt32((int)x.Range).Append(" m");
            rangeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(rangeSlider);
            
            var playButton = new MyTerminalControlButton<MySoundBlock>("PlaySound", MySpaceTexts.BlockPropertyTitle_SoundBlockPlay, MySpaceTexts.Blank, (x) => x.SyncObject.SendPlaySoundRequest());
            playButton.Enabled = (x) => x.IsSoundSelected;
            playButton.EnableAction();
            MyTerminalControlFactory.AddControl(playButton);

            var stopButton = new MyTerminalControlButton<MySoundBlock>("StopSound", MySpaceTexts.BlockPropertyTitle_SoundBlockStop, MySpaceTexts.Blank, (x) => x.SyncObject.SendStopSoundRequest());
            stopButton.Enabled = (x) => x.IsSoundSelected;
            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);

            var loopableTimeSlider = new MyTerminalControlSlider<MySoundBlock>("LoopableSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockLoopTime, MySpaceTexts.Blank);
            loopableTimeSlider.DefaultValue = 1f;
            loopableTimeSlider.Getter = (x) => x.LoopPeriod;
            loopableTimeSlider.Setter = (x, f) => x.SyncObject.SendChangeLoopPeriodRequest(f);
            loopableTimeSlider.Writer = (x, result) => MyValueFormatter.AppendTimeInBestUnit(x.LoopPeriod, result);
            loopableTimeSlider.Enabled = (x) => x.IsLoopable;
            loopableTimeSlider.Normalizer = (x, f) => x.NormalizeLoopPeriod(f);
            loopableTimeSlider.Denormalizer = (x, f) => x.DenormalizeLoopPeriod(f);
            loopableTimeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(loopableTimeSlider);

            var soundsList = new MyTerminalControlListbox<MySoundBlock>("SoundsList", MySpaceTexts.BlockPropertyTitle_SoundBlockSoundList, MySpaceTexts.Blank);
            soundsList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2);
            soundsList.ItemSelected = (x, y) => x.SelectSound(y, true);
            MyTerminalControlFactory.AddControl(soundsList);
        }
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyShipConnector>())
                return;

            var throwOut = new MyTerminalControlOnOffSwitch<MyShipConnector>("ThrowOut", MySpaceTexts.Terminal_ThrowOut);
            throwOut.Getter = (block) => block.ThrowOut;
            throwOut.Setter = (block, value) => block.ThrowOut.Value = value;
            throwOut.EnableToggleAction();
            MyTerminalControlFactory.AddControl(throwOut);

            var collectAll = new MyTerminalControlOnOffSwitch<MyShipConnector>("CollectAll", MySpaceTexts.Terminal_CollectAll);
            collectAll.Getter = (block) => block.CollectAll;
            collectAll.Setter = (block, value) => block.CollectAll.Value = value;
            collectAll.EnableToggleAction();
            MyTerminalControlFactory.AddControl(collectAll);

            var lockBtn = new MyTerminalControlButton<MyShipConnector>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.TryConnect());
            lockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
            lockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
            var actionLock = lockBtn.EnableAction();
            actionLock.Enabled = (b) => b.m_connectorMode == Mode.Connector;
            MyTerminalControlFactory.AddControl(lockBtn);

            var unlockBtn = new MyTerminalControlButton<MyShipConnector>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.TryDisconnect());
            unlockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
            unlockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
            var actionUnlock = unlockBtn.EnableAction();
            actionUnlock.Enabled = (b) => b.m_connectorMode == Mode.Connector;
            MyTerminalControlFactory.AddControl(unlockBtn);

            var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
            MyTerminalAction<MyShipConnector> switchLockAction = new MyTerminalAction<MyShipConnector>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);
            switchLockAction.Action = (b) => b.TrySwitch();
            switchLockAction.Writer = (b, sb) => b.WriteLockStateValue(sb);
            switchLockAction.Enabled = (b) => b.m_connectorMode == Mode.Connector;
            MyTerminalControlFactory.AddAction(switchLockAction);

            var strength = new MyTerminalControlSlider<MyShipConnector>("Strength", MySpaceTexts.BlockPropertyTitle_Connector_Strength, MySpaceTexts.BlockPropertyDescription_Connector_Strength);
            strength.Getter = (x) => x.Strength;
            strength.Setter = (x, v) => x.Strength.Value = v;
            strength.DefaultValue = MyObjectBuilder_ShipConnector.DefaultStrength;
            strength.SetLogLimits(MinStrength, 1.0f);
            strength.EnableActions(enabled: (b) => b.m_connectorMode == Mode.Connector);
            strength.Enabled = (b) => b.m_connectorMode == Mode.Connector;
            strength.Visible = (b) => b.m_connectorMode == Mode.Connector;
            strength.Writer = (x, result) =>
            {
                if (x.Strength <= MinStrength)
                    result.Append(MyTexts.Get(MyCommonTexts.Disabled));
                else
                    result.AppendFormatedDecimal("", x.Strength * 100, 4, " %");
            };
            MyTerminalControlFactory.AddControl(strength);
        }
Ejemplo n.º 28
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyMotorSuspension>())
            {
                return;
            }

            var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);

            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.Steering = v;
            steering.EnableAction();
            steering.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steering);

            var maxSteerAngle = new MyTerminalControlSlider <MyMotorSuspension>("MaxSteerAngle", MySpaceTexts.BlockPropertyTitle_Motor_MaxSteerAngle, MySpaceTexts.BlockPropertyDescription_Motor_MaxSteerAngle);

            maxSteerAngle.SetLimits((x) => 0, (x) => x.BlockDefinition.MaxSteer);
            maxSteerAngle.DefaultValue = 0.45f;
            maxSteerAngle.Getter       = (x) => x.GetMaxSteerAngleForTerminal();
            maxSteerAngle.Setter       = (x, v) => x.MaxSteerAngle = v;
            maxSteerAngle.Writer       = (x, res) => MyMotorStator.WriteAngle(x.GetMaxSteerAngleForTerminal(), res);
            maxSteerAngle.EnableActionsWithReset();
            maxSteerAngle.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(maxSteerAngle);

            var steerSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerSpeed);

            steerSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerSpeed.DefaultValue = 2f;
            steerSpeed.Getter       = (x) => x.GetSteerSpeedForTerminal();
            steerSpeed.Setter       = (x, v) => x.SteerSpeed = v / 100;
            steerSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerSpeedForTerminal(), res);
            steerSpeed.EnableActionsWithReset();
            steerSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerSpeed);

            var steerReturnSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerReturnSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerReturnSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerReturnSpeed);

            steerReturnSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerReturnSpeed.DefaultValue = 1f;
            steerReturnSpeed.Getter       = (x) => x.GetSteerReturnSpeedForTerminal();
            steerReturnSpeed.Setter       = (x, v) => x.SteerReturnSpeed = v / 100;
            steerReturnSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerReturnSpeedForTerminal(), res);
            steerReturnSpeed.EnableActionsWithReset();
            steerReturnSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerReturnSpeed);

            var invertSteer = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertSteering", MySpaceTexts.BlockPropertyTitle_Motor_InvertSteer, MySpaceTexts.BlockPropertyDescription_Motor_InvertSteer);

            invertSteer.Getter = (x) => x.InvertSteer;
            invertSteer.Setter = (x, v) => x.InvertSteer = v;
            invertSteer.EnableAction();
            invertSteer.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertSteer);

            var propulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("Propulsion", MySpaceTexts.BlockPropertyTitle_Motor_Propulsion, MySpaceTexts.BlockPropertyDescription_Motor_Propulsion);

            propulsion.Getter = (x) => x.Propulsion;
            propulsion.Setter = (x, v) => x.Propulsion = v;
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            var invertPropulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertPropulsion", MySpaceTexts.BlockPropertyTitle_Motor_InvertPropulsion, MySpaceTexts.BlockPropertyDescription_Motor_InvertPropulsion);

            invertPropulsion.Getter = (x) => x.InvertPropulsion;
            invertPropulsion.Setter = (x, v) => x.InvertPropulsion = v;
            invertPropulsion.EnableAction();
            invertPropulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertPropulsion);

            var power = new MyTerminalControlSlider <MyMotorSuspension>("Power", MySpaceTexts.BlockPropertyTitle_Motor_Power, MySpaceTexts.BlockPropertyDescription_Motor_Power);

            power.SetLimits(0, 100);
            power.DefaultValue = 100;
            power.Getter       = (x) => x.GetPowerForTerminal();
            power.Setter       = (x, v) => x.Power = v / 100;
            power.Writer       = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            power.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(power);

            var friction = new MyTerminalControlSlider <MyMotorSuspension>("Friction", MySpaceTexts.BlockPropertyTitle_Motor_Friction, MySpaceTexts.BlockPropertyDescription_Motor_Friction);

            friction.SetLimits(0, 100);
            friction.DefaultValue = 150f / 800;
            friction.Getter       = (x) => x.GetFrictionForTerminal();
            friction.Setter       = (x, v) => x.Friction = v / 100;
            friction.Writer       = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            friction.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(friction);

            var damping = new MyTerminalControlSlider <MyMotorSuspension>("Damping", MySpaceTexts.BlockPropertyTitle_Motor_Damping, MySpaceTexts.BlockPropertyTitle_Motor_Damping);

            damping.SetLimits(0, 100);
            damping.Getter = (x) => x.GetDampingForTerminal();
            damping.Setter = (x, v) => x.Damping = v / 100;
            damping.Writer = (x, res) => res.AppendInt32((int)(x.GetDampingForTerminal())).Append("%");
            damping.EnableActions();
            damping.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(damping);

            var strength = new MyTerminalControlSlider <MyMotorSuspension>("Strength", MySpaceTexts.BlockPropertyTitle_Motor_Strength, MySpaceTexts.BlockPropertyTitle_Motor_Strength);

            strength.SetLimits(0, 100);
            strength.Getter = (x) => x.GetStrengthForTerminal();
            strength.Setter = (x, v) => x.Strength = v / 100;
            strength.Writer = (x, res) => res.AppendInt32((int)(x.GetStrengthForTerminal())).Append("%");
            strength.EnableActions();
            strength.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(strength);

            var height = new MyTerminalControlSlider <MyMotorSuspension>("Height", MySpaceTexts.BlockPropertyTitle_Motor_Height, MySpaceTexts.BlockPropertyDescription_Motor_Height);

            height.SetLimits((x) => x.BlockDefinition.MinHeight, (x) => x.BlockDefinition.MaxHeight);
            height.DefaultValue = 0;
            height.Getter       = (x) => x.GetHeightForTerminal();
            height.Setter       = (x, v) => x.Height = v;
            height.Writer       = (x, res) => MyValueFormatter.AppendDistanceInBestUnit(x.Height, res);
            height.EnableActionsWithReset();
            height.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(height);

            var travel = new MyTerminalControlSlider <MyMotorSuspension>("Travel", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionTravel, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionTravel);

            travel.SetLimits(0, 100);
            travel.DefaultValue = 100;
            travel.Getter       = (x) => x.GetSuspensionTravelForTerminal();
            travel.Setter       = (x, v) => x.SuspensionTravel = v / 100.0f;
            travel.Writer       = (x, res) => res.AppendInt32((int)x.GetSuspensionTravelForTerminal()).Append("%");
            travel.EnableActionsWithReset();
            travel.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(travel);

            var speed = new MyTerminalControlSlider <MyMotorSuspension>("Speed Limit", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionSpeed);

            speed.SetLimits(0, MaxSpeedLimit);
            speed.DefaultValue = MaxSpeedLimit;
            speed.Getter       = (x) => x.SpeedLimit;
            speed.Setter       = (x, v) => x.SpeedLimit = v;
            speed.Writer       = (x, res) =>
            {
                if (x.SpeedLimit >= MyMotorSuspension.MaxSpeedLimit)
                {
                    res.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
                }
                else
                {
                    res.AppendInt32((int)x.SpeedLimit).Append("km/h");
                }
            };
            speed.EnableActionsWithReset();
            speed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(speed);

            var addWheel = new MyTerminalControlButton <MyMotorSuspension>("Add Wheel", MySpaceTexts.BlockActionTitle_AddWheel, MySpaceTexts.BlockActionTooltip_AddWheel, (b) => b.RecreateRotor());

            addWheel.Enabled = (b) => (b.m_topBlock == null);
            addWheel.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addWheel);
        }
Ejemplo n.º 29
0
        static MyMotorStator()
        {
            var reverse = new MyTerminalControlButton<MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.ReverseValuesRequest());
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton<MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.OnDetachRotorBtnClick());

            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);
            actionDetach.Enabled = (b) => b.m_canBeDetached;
            detach.Enabled = (b) => b.m_isAttached;
            detach.Visible = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach = new MyTerminalControlButton<MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.SyncObject.AttachRotor());
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);
            actionAttach.Enabled = (b) => b.m_canBeDetached;
            attach.Enabled = (b) => !b.m_isAttached;
            attach.Visible = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider<MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);
            torque.Getter = (x) => x.Torque;
            torque.Setter = (x, v) => x.TorqueChangeRequest(v);
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider<MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);
            brakingTorque.Getter = (x) => x.BrakingTorque;
            brakingTorque.Setter = (x, v) => x.BrakingTorqueChangeRequest(v);
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider<MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);
            targetVelocity.Getter = (x) => x.GetTargetVelocityRPM();
            targetVelocity.Setter = (x, v) => x.SetTargetVelocity(v);
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer = (x, result) => result.Concat(x.GetTargetVelocityRPM(), 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider<MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);
            lowerLimit.Getter = (x) => x.MinAngle;
            lowerLimit.Setter = (x, v) => x.MinAngleChangeRequest(v);
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider<MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);
            upperLimit.Getter = (x) => x.MaxAngle;
            upperLimit.Setter = (x, v) => x.MaxAngleChangeRequest(v);
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider<MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);
            rotorDisplacement.Getter = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter = (x, v) => x.SyncObject.ChangeRotorDisplacement(v);
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);
        }
Ejemplo n.º 30
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyTimerBlock>())
                return;

            var silent = new MyTerminalControlCheckbox<MyTimerBlock>("Silent", MySpaceTexts.BlockPropertyTitle_Silent, MySpaceTexts.ToolTipTimerBlock_Silent);
            silent.Getter = (x) => x.Silent;
            silent.Setter = (x, v) => x.Silent = v;
            silent.EnableAction();
            MyTerminalControlFactory.AddControl(silent);

            var slider = new MyTerminalControlSlider<MyTimerBlock>("TriggerDelay", MySpaceTexts.TerminalControlPanel_TimerDelay, MySpaceTexts.TerminalControlPanel_TimerDelay);
            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled = (x) => !x.IsCountingDown;
            slider.Getter = (x) => x.TriggerDelay;
            slider.Setter = (x, v) => x.m_timerSync.Value = ((int)(Math.Round(v, 1) * 1000));
            slider.Writer = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMsStart, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var toolbarButton = new MyTerminalControlButton<MyTimerBlock>("OpenToolbar", MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen, MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen,
            delegate(MyTimerBlock self)
            {
                m_openedToolbars.Add(self.Toolbar);
                if (MyGuiScreenCubeBuilder.Static == null)
                {
                    m_shouldSetOtherToolbars = true;
                    MyToolbarComponent.CurrentToolbar = self.Toolbar;
                    MyGuiScreenBase screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                    MyToolbarComponent.AutoUpdate = false;
                    screen.Closed += (source) =>
                    {
                        MyToolbarComponent.AutoUpdate = true;
                        m_openedToolbars.Clear();
                    };
                    MyGuiSandbox.AddScreen(screen);
                }
            });

            MyTerminalControlFactory.AddControl(toolbarButton);

            var triggerButton = new MyTerminalControlButton<MyTimerBlock>("TriggerNow", MySpaceTexts.BlockPropertyTitle_TimerTrigger, MySpaceTexts.BlockPropertyTitle_TimerTrigger, (x) => x.OnTrigger());
            triggerButton.EnableAction();
            MyTerminalControlFactory.AddControl(triggerButton);

            var startButton = new MyTerminalControlButton<MyTimerBlock>("Start", MySpaceTexts.BlockPropertyTitle_TimerStart, MySpaceTexts.BlockPropertyTitle_TimerStart, (x) => x.StartBtn());
            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton<MyTimerBlock>("Stop", MySpaceTexts.BlockPropertyTitle_TimerStop, MySpaceTexts.BlockPropertyTitle_TimerStop, (x) => x.StopBtn());
            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);
        }
Ejemplo n.º 31
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyPistonBase>())
                return;

            var reverse = new MyTerminalControlButton<MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.Velocity.Value = -x.Velocity);
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction<MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);
            extendAction.Enabled = (b) => b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);

            var retractAction = new MyTerminalAction<MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);
            retractAction.Enabled = (b) => b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider<MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);
            velocity.SetLimits((block) => -block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter = (x) => x.Velocity;
            velocity.Setter = (x, v) => x.Velocity.Value = v;
            velocity.Writer = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider<MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);
            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter = (x) => x.MaxLimit;
            maxDist.Setter = (x, v) => x.MaxLimit.Value = v;
            maxDist.Writer = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider<MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);
            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter = (x) => x.MinLimit;
            minDist.Setter = (x, v) => x.MinLimit.Value = v;
            minDist.Writer = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);

           
            var addPistonHead = new MyTerminalControlButton<MyPistonBase>("Add Piston Head", MySpaceTexts.BlockActionTitle_AddPistonHead, MySpaceTexts.BlockActionTooltip_AddPistonHead, (b) => b.RecreateTop());
            addPistonHead.Enabled = (b) => (b.m_topBlock == null);
            addPistonHead.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addPistonHead);
        }
Ejemplo n.º 32
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyMotorStator>())
            {
                return;
            }
            base.CreateTerminalControls();
            var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM);

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State()
            {
                TopBlockId = null, MasterToSlave = null
            });

            detach.Enabled = (b) => b.m_connectionState.Value.TopBlockId.HasValue && b.m_isWelding == false && b.m_welded == false;
            detach.Visible = (b) => b.m_canBeDetached;
            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);

            actionDetach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State()
            {
                TopBlockId = 0, MasterToSlave = null
            });

            attach.Enabled = (b) => !b.m_connectionState.Value.TopBlockId.HasValue;
            attach.Visible = (b) => b.m_canBeDetached;
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);

            actionAttach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);

            torque.Getter             = (x) => x.Torque;
            torque.Setter             = (x, v) => x.Torque.Value = v;
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer             = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);

            brakingTorque.Getter       = (x) => x.BrakingTorque;
            brakingTorque.Setter       = (x, v) => x.BrakingTorque.Value = v;
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer       = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);

            targetVelocity.Getter       = (x) => x.TargetVelocityRPM;
            targetVelocity.Setter       = (x, v) => x.TargetVelocityRPM = v;
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer       = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer   = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);

            lowerLimit.Getter       = (x) => x.MinAngle;
            lowerLimit.Setter       = (x, v) => x.MinAngle = v;
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);

            upperLimit.Getter       = (x) => x.MaxAngle;
            upperLimit.Setter       = (x, v) => x.MaxAngle = v;
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);

            rotorDisplacement.Getter             = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter             = (x, v) => x.DummyDisplacement = v;
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer  = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);
        }
Ejemplo n.º 33
0
        static MyPistonBase()
        {
            var reverse = new MyTerminalControlButton <MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.Velocity.Value = -x.Velocity);

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction <MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);

            extendAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);

            var retractAction = new MyTerminalAction <MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);

            retractAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider <MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);

            velocity.SetLimits((block) => - block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter       = (x) => x.Velocity;
            velocity.Setter       = (x, v) => x.Velocity.Value = v;
            velocity.Writer       = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider <MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);

            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter             = (x) => x.MaxLimit;
            maxDist.Setter             = (x, v) => x.MaxLimit.Value = v;
            maxDist.Writer             = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider <MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);

            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter             = (x) => x.MinLimit;
            minDist.Setter             = (x, v) => x.MinLimit.Value = v;
            minDist.Writer             = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);

            var weldSpeed = new MyTerminalControlSlider <MyPistonBase>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);

            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter             = (x) => (float)Math.Sqrt(x.m_weldSpeedSq);
            weldSpeed.Setter             = (x, v) => x.m_weldSpeedSq.Value = v * v;
            weldSpeed.Writer             = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox <MyPistonBase>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);

            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);
        }
Ejemplo n.º 34
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyMotorStator>())
                return;
            base.CreateTerminalControls();
            var reverse = new MyTerminalControlButton<MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM);
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton<MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State() { TopBlockId = null, MasterToSlave = null });
            detach.Enabled = (b) => b.m_connectionState.Value.TopBlockId.HasValue && b.m_isWelding == false && b.m_welded == false;
            detach.Visible = (b) => b.m_canBeDetached;
            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);
            actionDetach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach = new MyTerminalControlButton<MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_connectionState.Value = new State() { TopBlockId = 0, MasterToSlave = null });
            attach.Enabled = (b) => !b.m_connectionState.Value.TopBlockId.HasValue;
            attach.Visible = (b) => b.m_canBeDetached;
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);
            actionAttach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider<MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);
            torque.Getter = (x) => x.Torque;
            torque.Setter = (x, v) => x.Torque.Value = v;
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider<MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);
            brakingTorque.Getter = (x) => x.BrakingTorque;
            brakingTorque.Setter = (x, v) => x.BrakingTorque.Value = v;
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider<MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);
            targetVelocity.Getter = (x) => x.TargetVelocityRPM;
            targetVelocity.Setter = (x, v) => x.TargetVelocityRPM = v;
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider<MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);
            lowerLimit.Getter = (x) => x.MinAngle;
            lowerLimit.Setter = (x, v) => x.MinAngle = v;
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider<MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);
            upperLimit.Getter = (x) => x.MaxAngle;
            upperLimit.Setter = (x, v) => x.MaxAngle = v;
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider<MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);
            rotorDisplacement.Getter = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter = (x, v) => x.DummyDisplacement = v;
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);
        }
Ejemplo n.º 35
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);
        }
Ejemplo n.º 36
0
        static MyProjector()
        {
            if (!MyFakes.ENABLE_PROJECTOR_BLOCK)
            {
                return;
            }

            var blueprintBtn = new MyTerminalControlButton<MyProjector>("Blueprint", MySpaceTexts.Blueprints, MySpaceTexts.Blank, (p) => p.SelectBlueprint());
            blueprintBtn.Enabled = (b) => b.CanProject();
            blueprintBtn.SupportsMultipleBlocks = false;

            MyTerminalControlFactory.AddControl(blueprintBtn);

            var removeBtn = new MyTerminalControlButton<MyProjector>("Remove", MySpaceTexts.RemoveProjectionButton, MySpaceTexts.Blank, (p) => p.SyncObject.SendRemoveProjection());
            removeBtn.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(removeBtn);

            var keepProjectionToggle = new MyTerminalControlCheckbox<MyProjector>("KeepProjection", MySpaceTexts.KeepProjectionToggle, MySpaceTexts.KeepProjectionTooltip);
            keepProjectionToggle.Getter = (x) => x.m_keepProjection;
            keepProjectionToggle.Setter = (x, v) =>
                {
                    x.SyncObject.SendNewKeepProjection(v);
                };
            keepProjectionToggle.EnableAction();
            keepProjectionToggle.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(keepProjectionToggle);

            //ShowOnlyBuildable
            var showOnlyBuildableBlockToggle = new MyTerminalControlCheckbox<MyProjector>("ShowOnlyBuildable", MySpaceTexts.ShowOnlyBuildableBlockToggle, MySpaceTexts.ShowOnlyBuildableTooltip);
            showOnlyBuildableBlockToggle.Getter = (x) => x.m_showOnlyBuildable;
            showOnlyBuildableBlockToggle.Setter = (x, v) =>
            {
                x.m_showOnlyBuildable = v;
                x.OnOffsetsChanged();
            };
            showOnlyBuildableBlockToggle.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(showOnlyBuildableBlockToggle);

            //HideArmorBlocks
            var hideArmorBlockToggle = new MyTerminalControlCheckbox<MyProjector>("HideArmorBlocks", MySpaceTexts.HideArmorBlockToggle, MySpaceTexts.HideArmorBlockTooltip);
            hideArmorBlockToggle.Getter = (x) => x.m_hideArmorBlock;
            hideArmorBlockToggle.Setter = (x, v) =>
            {
                x.m_hideArmorBlock = v;
                x.OnOffsetsChanged();
            };
            hideArmorBlockToggle.Enabled = (b) => b.IsProjecting();
            MyTerminalControlFactory.AddControl(hideArmorBlockToggle);

            //Position
            var offsetX = new MyTerminalControlSlider<MyProjector>("X", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetX, MySpaceTexts.Blank);
            offsetX.SetLimits(-50, 50);
            offsetX.DefaultValue = 0;
            offsetX.Getter = (x) => x.m_projectionOffset.X;
            offsetX.Setter = (x, v) =>
            {
                x.m_projectionOffset.X = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetX.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.X));
            offsetX.EnableActions(step: 0.01f);
            offsetX.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetX);

            var offsetY = new MyTerminalControlSlider<MyProjector>("Y", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetY, MySpaceTexts.Blank);
            offsetY.SetLimits(-50, 50);
            offsetY.DefaultValue = 0;
            offsetY.Getter = (x) => x.m_projectionOffset.Y;
            offsetY.Setter = (x, v) =>
            {
                x.m_projectionOffset.Y = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetY.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Y));
            offsetY.EnableActions(step: 0.01f);
            offsetY.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetY);

            var offsetZ = new MyTerminalControlSlider<MyProjector>("Z", MySpaceTexts.BlockPropertyTitle_ProjectionOffsetZ, MySpaceTexts.Blank);
            offsetZ.SetLimits(-50, 50);
            offsetZ.DefaultValue = 0;
            offsetZ.Getter = (x) => x.m_projectionOffset.Z;
            offsetZ.Setter = (x, v) =>
            {
                x.m_projectionOffset.Z = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            offsetZ.Writer = (x, result) => result.AppendInt32((int)(x.m_projectionOffset.Z));
            offsetZ.EnableActions(step: 0.01f);
            offsetZ.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(offsetZ);

            //Rotation

            var rotationX = new MyTerminalControlSlider<MyProjector>("RotX", MySpaceTexts.BlockPropertyTitle_ProjectionRotationX, MySpaceTexts.Blank);
            rotationX.SetLimits(-2, 2);
            rotationX.DefaultValue = 0;
            rotationX.Getter = (x) => x.m_projectionRotation.X;
            rotationX.Setter = (x, v) =>
            {
                x.m_projectionRotation.X = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationX.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.X * 90).Append("°");
            rotationX.EnableActions(step: 0.2f);
            rotationX.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationX);

            var rotationY = new MyTerminalControlSlider<MyProjector>("RotY", MySpaceTexts.BlockPropertyTitle_ProjectionRotationY, MySpaceTexts.Blank);
            rotationY.SetLimits(-2, 2);
            rotationY.DefaultValue = 0;
            rotationY.Getter = (x) => x.m_projectionRotation.Y;
            rotationY.Setter = (x, v) =>
            {
                x.m_projectionRotation.Y = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationY.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Y * 90).Append("°");
            rotationY.EnableActions(step: 0.2f);
            rotationY.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationY);

            var rotationZ = new MyTerminalControlSlider<MyProjector>("RotZ", MySpaceTexts.BlockPropertyTitle_ProjectionRotationZ, MySpaceTexts.Blank);
            rotationZ.SetLimits(-2, 2);
            rotationZ.DefaultValue = 0;
            rotationZ.Getter = (x) => x.m_projectionRotation.Z;
            rotationZ.Setter = (x, v) =>
            {
                x.m_projectionRotation.Z = Convert.ToInt32(v);
                x.OnOffsetsChanged();
            };
            rotationZ.Writer = (x, result) => result.AppendInt32((int)x.m_projectionRotation.Z * 90).Append("°");
            rotationZ.EnableActions(step: 0.2f);
            rotationZ.Enabled = (x) => x.IsProjecting();
            MyTerminalControlFactory.AddControl(rotationZ);

            var scenarioSettingsSeparator = new MyTerminalControlSeparator<MyProjector>();
            scenarioSettingsSeparator.Visible = (p) => p.ScenarioSettingsEnabled();
            MyTerminalControlFactory.AddControl(scenarioSettingsSeparator);

            var scenarioSettingsLabel = new MyTerminalControlLabel<MyProjector>("ScenarioLabel", MySpaceTexts.TerminalScenarioSettingsLabel);
            scenarioSettingsLabel.Visible = (p) => p.ScenarioSettingsEnabled();
            MyTerminalControlFactory.AddControl(scenarioSettingsLabel);

            var spawnProjectionButton = new MyTerminalControlButton<MyProjector>("SpawnProjection", MySpaceTexts.BlockPropertyTitle_ProjectionSpawn, MySpaceTexts.Blank, (p) => p.TrySpawnProjection());
            spawnProjectionButton.Visible = (p) => p.ScenarioSettingsEnabled();
            spawnProjectionButton.Enabled = (p) => p.CanSpawnProjection();
            spawnProjectionButton.EnableAction();
            MyTerminalControlFactory.AddControl(spawnProjectionButton);

            var instantBuildingCheckbox = new MyTerminalControlCheckbox<MyProjector>("InstantBuilding", MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding, MySpaceTexts.BlockPropertyTitle_Projector_InstantBuilding_Tooltip);
            instantBuildingCheckbox.Visible = (p) => p.ScenarioSettingsEnabled();
            instantBuildingCheckbox.Enabled = (p) => p.CanEnableInstantBuilding();
            instantBuildingCheckbox.Getter = (p) => p.m_instantBuildingEnabled;
            instantBuildingCheckbox.Setter = (p, v) => p.TrySetInstantBuilding(v);
            MyTerminalControlFactory.AddControl(instantBuildingCheckbox);

            var getOwnershipCheckbox = new MyTerminalControlCheckbox<MyProjector>("GetOwnership", MySpaceTexts.BlockPropertyTitle_Projector_GetOwnership, MySpaceTexts.BlockPropertiesTooltip_Projector_GetOwnership);
            getOwnershipCheckbox.Visible = (p) => p.ScenarioSettingsEnabled();
            getOwnershipCheckbox.Enabled = (p) => p.CanEditInstantBuildingSettings();
            getOwnershipCheckbox.Getter = (p) => p.m_getOwnershipFromProjector;
            getOwnershipCheckbox.Setter = (p, v) => p.TrySetGetOwnership(v);
            MyTerminalControlFactory.AddControl(getOwnershipCheckbox);

            var numberOfProjections = new MyTerminalControlSlider<MyProjector>("NumberOfProjections", MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections, MySpaceTexts.BlockPropertyTitle_Projector_NumberOfProjections_Tooltip);
            numberOfProjections.Visible = (p) => p.ScenarioSettingsEnabled();
            numberOfProjections.Enabled = (p) => p.CanEditInstantBuildingSettings();
            numberOfProjections.Getter = (p) => p.m_maxNumberOfProjections;
            numberOfProjections.Setter = (p, v) => p.TryChangeNumberOfProjections(v);
            numberOfProjections.Writer = (p, s) =>
                {
                    if (p.m_maxNumberOfProjections == MAX_NUMBER_OF_PROJECTIONS)
                    {
                        s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite));
                    }
                    else
                    {
                        s.AppendInt32(p.m_maxNumberOfProjections);
                    }
                };
            numberOfProjections.SetLogLimits(1, MAX_NUMBER_OF_PROJECTIONS);
            MyTerminalControlFactory.AddControl(numberOfProjections);

            var numberOfBlocks = new MyTerminalControlSlider<MyProjector>("NumberOfBlocks", MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection, MySpaceTexts.BlockPropertyTitle_Projector_BlocksPerProjection_Tooltip);
            numberOfBlocks.Visible = (p) => p.ScenarioSettingsEnabled();
            numberOfBlocks.Enabled = (p) => p.CanEditInstantBuildingSettings();
            numberOfBlocks.Getter = (p) => p.m_maxNumberOfBlocksPerProjection;
            numberOfBlocks.Setter = (p, v) => p.TryChangeMaxNumberOfBlocksPerProjection(v);
            numberOfBlocks.Writer = (p, s) =>
                {
                    if (p.m_maxNumberOfBlocksPerProjection == MAX_NUMBER_OF_BLOCKS)
                    {
                        s.AppendStringBuilder(MyTexts.Get(MySpaceTexts.ScreenTerminal_Infinite));
                    }
                    else
                    {
                        s.AppendInt32(p.m_maxNumberOfBlocksPerProjection);
                    }
                };
            numberOfBlocks.SetLogLimits(1, MAX_NUMBER_OF_BLOCKS);
            MyTerminalControlFactory.AddControl(numberOfBlocks);
        }
Ejemplo n.º 37
0
        static MyMotorStator()
        {
            var reverse = new MyTerminalControlButton<MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM);
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton<MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State() { OtherEntityId = null, MasterToSlave = null});
            detach.Enabled = (b) => b.m_rotorBlockId.Value.OtherEntityId.HasValue;
            detach.Visible = (b) => b.m_canBeDetached;
            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);
            actionDetach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach = new MyTerminalControlButton<MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State() { OtherEntityId = 0, MasterToSlave = null});
            attach.Enabled = (b) => !b.m_rotorBlockId.Value.OtherEntityId.HasValue;
            attach.Visible = (b) => b.m_canBeDetached;
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);
            actionAttach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider<MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);
            torque.Getter = (x) => x.Torque;
            torque.Setter = (x, v) => x.Torque.Value = v;
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider<MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);
            brakingTorque.Getter = (x) => x.BrakingTorque;
            brakingTorque.Setter = (x, v) => x.BrakingTorque.Value = v;
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider<MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);
            targetVelocity.Getter = (x) => x.TargetVelocityRPM;
            targetVelocity.Setter = (x, v) => x.TargetVelocityRPM = v;
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider<MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);
            lowerLimit.Getter = (x) => x.MinAngle;
            lowerLimit.Setter = (x, v) => x.MinAngle = v;
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider<MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);
            upperLimit.Getter = (x) => x.MaxAngle;
            upperLimit.Setter = (x, v) => x.MaxAngle = v;
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider<MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);
            rotorDisplacement.Getter = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter = (x, v) => x.DummyDisplacement = v;
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);

            var weldSpeed = new MyTerminalControlSlider<MyMotorStator>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);
            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter = (x) => (float)Math.Sqrt(x.m_weldSpeedSq);
            weldSpeed.Setter = (x, v) => x.m_weldSpeedSq.Value = v * v;
            weldSpeed.Writer = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox<MyMotorStator>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);
            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);
        }
Ejemplo n.º 38
0
        static MyLandingGear()
        {
            var stateWriter = new MyTerminalControl<MyLandingGear>.WriterDelegate((b, sb) => b.WriteLockStateValue(sb));

            var lockBtn = new MyTerminalControlButton<MyLandingGear>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.RequestLandingGearLock());
            lockBtn.Enabled = (b) => b.IsWorking;
            lockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
            MyTerminalControlFactory.AddControl(lockBtn);

            var unlockBtn = new MyTerminalControlButton<MyLandingGear>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.RequestLandingGearUnlock());
            unlockBtn.Enabled = (b) => b.IsWorking;
            unlockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
            MyTerminalControlFactory.AddControl(unlockBtn);

            var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
            MyTerminalAction<MyLandingGear> switchLockAction = new MyTerminalAction<MyLandingGear>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);
            switchLockAction.Action = (b) => b.RequestLandingGearSwitch();
            switchLockAction.Writer = stateWriter;
            MyTerminalControlFactory.AddAction(switchLockAction);

            var autoLock = new MyTerminalControlCheckbox<MyLandingGear>("Autolock", MySpaceTexts.BlockPropertyTitle_LandGearAutoLock, MySpaceTexts.Blank);
            autoLock.Getter = (b) => b.m_autoLock;
            autoLock.Setter = (b, v) => b.SyncObject.SendAutoLockChange(v);
            autoLock.EnableAction();
            MyTerminalControlFactory.AddControl(autoLock);

            if (MyFakes.LANDING_GEAR_BREAKABLE)
            {
                var brakeForce = new MyTerminalControlSlider<MyLandingGear>("BreakForce", MySpaceTexts.BlockPropertyTitle_BreakForce, MySpaceTexts.BlockPropertyDescription_BreakForce);
                brakeForce.Getter = (x) => x.BreakForce;
                brakeForce.Setter = (x, v) => x.SyncObject.SendBrakeForceChange(v);
                brakeForce.DefaultValue = 1;
                brakeForce.Writer = (x, result) =>
                {
                    if (x.BreakForce >= MaxSolverImpulse) result.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
                    else MyValueFormatter.AppendForceInBestUnit(x.BreakForce, result);
                };
                brakeForce.Normalizer = (b, v) => ThresholdToRatio(v);
                brakeForce.Denormalizer = (b, v) => RatioToThreshold(v);
                brakeForce.EnableActions();
                MyTerminalControlFactory.AddControl(brakeForce);
            }
        }
Ejemplo n.º 39
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyMotorStator>())
            {
                return;
            }

            var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM);

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State()
            {
                OtherEntityId = null, MasterToSlave = null
            });

            detach.Enabled = (b) => b.m_rotorBlockId.Value.OtherEntityId.HasValue && b.m_isWelding == false && b.m_welded == false;
            detach.Visible = (b) => b.m_canBeDetached;
            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);

            actionDetach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => b.m_rotorBlockId.Value = new State()
            {
                OtherEntityId = 0, MasterToSlave = null
            });

            attach.Enabled = (b) => !b.m_rotorBlockId.Value.OtherEntityId.HasValue;
            attach.Visible = (b) => b.m_canBeDetached;
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);

            actionAttach.Enabled = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);

            torque.Getter             = (x) => x.Torque;
            torque.Setter             = (x, v) => x.Torque.Value = v;
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer             = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);

            brakingTorque.Getter       = (x) => x.BrakingTorque;
            brakingTorque.Setter       = (x, v) => x.BrakingTorque.Value = v;
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer       = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);

            targetVelocity.Getter       = (x) => x.TargetVelocityRPM;
            targetVelocity.Setter       = (x, v) => x.TargetVelocityRPM = v;
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer       = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer   = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);

            lowerLimit.Getter       = (x) => x.MinAngle;
            lowerLimit.Setter       = (x, v) => x.MinAngle = v;
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);

            upperLimit.Getter       = (x) => x.MaxAngle;
            upperLimit.Setter       = (x, v) => x.MaxAngle = v;
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);

            rotorDisplacement.Getter             = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter             = (x, v) => x.DummyDisplacement = v;
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer  = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);

            var weldSpeed = new MyTerminalControlSlider <MyMotorStator>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);

            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter             = (x) => (float)Math.Sqrt(x.m_weldSpeedSq);
            weldSpeed.Setter             = (x, v) => x.m_weldSpeedSq.Value = v * v;
            weldSpeed.Writer             = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox <MyMotorStator>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);

            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);
        }
Ejemplo n.º 40
0
        static MyMotorStator()
        {
            var reverse = new MyTerminalControlButton <MyMotorStator>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (b) => b.TargetVelocityRPM = -b.TargetVelocityRPM);

            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var detach = new MyTerminalControlButton <MyMotorStator>("Detach", MySpaceTexts.BlockActionTitle_Detach, MySpaceTexts.Blank, (b) => MyMultiplayer.RaiseEvent(b, x => x.Detach_Implementation));

            var actionDetach = detach.EnableAction(MyTerminalActionIcons.NONE);

            actionDetach.Enabled = (b) => b.m_canBeDetached;
            detach.Enabled       = (b) => b.m_isAttached;
            detach.Visible       = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(detach);

            var attach       = new MyTerminalControlButton <MyMotorStator>("Attach", MySpaceTexts.BlockActionTitle_Attach, MySpaceTexts.Blank, (b) => MyMultiplayer.RaiseEvent(b, x => x.Attach_Implementation));
            var actionAttach = attach.EnableAction(MyTerminalActionIcons.NONE);

            actionAttach.Enabled = (b) => b.m_canBeDetached;
            attach.Enabled       = (b) => !b.m_isAttached;
            attach.Visible       = (b) => b.m_canBeDetached;
            MyTerminalControlFactory.AddControl(attach);

            var torque = new MyTerminalControlSlider <MyMotorStator>("Torque", MySpaceTexts.BlockPropertyTitle_MotorTorque, MySpaceTexts.BlockPropertyDescription_MotorTorque);

            torque.Getter             = (x) => x.Torque;
            torque.Setter             = (x, v) => x.Torque.Value = v;
            torque.DefaultValueGetter = (x) => x.MotorDefinition.MaxForceMagnitude;
            torque.Writer             = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.Torque, result);
            torque.EnableActions();
            torque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            torque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(torque);

            var brakingTorque = new MyTerminalControlSlider <MyMotorStator>("BrakingTorque", MySpaceTexts.BlockPropertyTitle_MotorBrakingTorque, MySpaceTexts.BlockPropertyDescription_MotorBrakingTorque);

            brakingTorque.Getter       = (x) => x.BrakingTorque;
            brakingTorque.Setter       = (x, v) => x.BrakingTorque.Value = v;
            brakingTorque.DefaultValue = 0;
            brakingTorque.Writer       = (x, result) => MyValueFormatter.AppendTorqueInBestUnit(x.BrakingTorque, result);
            brakingTorque.EnableActions();
            brakingTorque.Denormalizer = (x, v) => x.DenormalizeTorque(v);
            brakingTorque.Normalizer   = (x, v) => x.NormalizeTorque(v);
            MyTerminalControlFactory.AddControl(brakingTorque);

            var targetVelocity = new MyTerminalControlSlider <MyMotorStator>("Velocity", MySpaceTexts.BlockPropertyTitle_MotorTargetVelocity, MySpaceTexts.BlockPropertyDescription_MotorVelocity);

            targetVelocity.Getter       = (x) => x.TargetVelocityRPM;
            targetVelocity.Setter       = (x, v) => x.TargetVelocityRPM = v;
            targetVelocity.DefaultValue = 0;
            targetVelocity.Writer       = (x, result) => result.Concat(x.TargetVelocityRPM, 2).Append(" rpm");
            targetVelocity.EnableActionsWithReset();
            targetVelocity.Denormalizer = (x, v) => x.DenormalizeRPM(v);
            targetVelocity.Normalizer   = (x, v) => x.NormalizeRPM(v);
            MyTerminalControlFactory.AddControl(targetVelocity);

            var lowerLimit = new MyTerminalControlSlider <MyMotorStator>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MotorMinAngle, MySpaceTexts.BlockPropertyDescription_MotorLowerLimit);

            lowerLimit.Getter       = (x) => x.MinAngle;
            lowerLimit.Setter       = (x, v) => x.MinAngle = v;
            lowerLimit.DefaultValue = -361;
            lowerLimit.SetLimits(-361, 360);
            lowerLimit.Writer = (x, result) => WriteAngle(x.m_minAngle, result);
            lowerLimit.EnableActions();
            MyTerminalControlFactory.AddControl(lowerLimit);

            var upperLimit = new MyTerminalControlSlider <MyMotorStator>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MotorMaxAngle, MySpaceTexts.BlockPropertyDescription_MotorUpperLimit);

            upperLimit.Getter       = (x) => x.MaxAngle;
            upperLimit.Setter       = (x, v) => x.MaxAngle = v;
            upperLimit.DefaultValue = 361;
            upperLimit.SetLimits(-360, 361);
            upperLimit.Writer = (x, result) => WriteAngle(x.m_maxAngle, result);
            upperLimit.EnableActions();
            MyTerminalControlFactory.AddControl(upperLimit);

            var rotorDisplacement = new MyTerminalControlSlider <MyMotorStator>("Displacement", MySpaceTexts.BlockPropertyTitle_MotorRotorDisplacement, MySpaceTexts.BlockPropertyDescription_MotorRotorDisplacement);

            rotorDisplacement.Getter             = (x) => x.DummyDisplacement;
            rotorDisplacement.Setter             = (x, v) => x.DummyDisplacement = v;
            rotorDisplacement.DefaultValueGetter = (x) => 0.0f;
            rotorDisplacement.SetLimits((x) => x.MotorDefinition.RotorDisplacementMin, (x) => x.MotorDefinition.RotorDisplacementMax);
            rotorDisplacement.Writer  = (x, result) => MyValueFormatter.AppendDistanceInBestUnit(x.DummyDisplacement, result);
            rotorDisplacement.Enabled = (b) => b.m_isAttached;
            rotorDisplacement.EnableActions();
            MyTerminalControlFactory.AddControl(rotorDisplacement);
        }
Ejemplo n.º 41
0
        static MyPistonBase()
        {
            var reverse = new MyTerminalControlButton<MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.Velocity.Value = -x.Velocity);
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction<MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);
            extendAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);

            var retractAction = new MyTerminalAction<MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);
            retractAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider<MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);
            velocity.SetLimits((block) => -block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter = (x) => x.Velocity;
            velocity.Setter = (x, v) => x.Velocity.Value = v;
            velocity.Writer = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider<MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);
            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter = (x) => x.MaxLimit;
            maxDist.Setter = (x, v) => x.MaxLimit.Value = v;
            maxDist.Writer = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider<MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);
            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter = (x) => x.MinLimit;
            minDist.Setter = (x, v) => x.MinLimit.Value = v;
            minDist.Writer = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);

            var weldSpeed = new MyTerminalControlSlider<MyPistonBase>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);
            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter = (x) => (float)Math.Sqrt(x.m_weldSpeedSq);
            weldSpeed.Setter = (x, v) => x.m_weldSpeedSq.Value = v * v;
            weldSpeed.Writer = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox<MyPistonBase>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);
            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);
        }
Ejemplo n.º 42
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyWarhead>())
                return;
            base.CreateTerminalControls();
            var slider = new MyTerminalControlSlider<MyWarhead>("DetonationTime", MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime, MySpaceTexts.TerminalControlPanel_Warhead_DetonationTime);
            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled = (x) => !x.IsCountingDown;
            slider.Getter = (x) => x.DetonationTime;
            slider.Setter = (x, v) => x.m_countdownMs.Value = (int)(v * 1000);
            slider.Writer = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMs, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var startButton = new MyTerminalControlButton<MyWarhead>(
                "StartCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown,
                (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, true));
            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton<MyWarhead>(
                "StopCountdown",
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown,
                (b) => MyMultiplayer.RaiseEvent(b, x => x.SetCountdown, false));
            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);

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

            var safetyCheckbox = new MyTerminalControlCheckbox<MyWarhead>(
                "Safety",
                MySpaceTexts.TerminalControlPanel_Warhead_Safety,
                MySpaceTexts.TerminalControlPanel_Warhead_SafetyTooltip,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextDisarmed,
                MySpaceTexts.TerminalControlPanel_Warhead_SwitchTextArmed);
            safetyCheckbox.Getter = (x) => !x.IsArmed;
            safetyCheckbox.Setter = (x, v) => x.IsArmed = !v;
            safetyCheckbox.EnableAction();
            MyTerminalControlFactory.AddControl(safetyCheckbox);

            var detonateButton = new MyTerminalControlButton<MyWarhead>(
                "Detonate",
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                MySpaceTexts.TerminalControlPanel_Warhead_Detonate,
                (b) => { if (b.IsArmed) { MyMultiplayer.RaiseEvent(b, x => x.DetonateRequest); } });
            detonateButton.Enabled = (x) => x.IsArmed;
            detonateButton.EnableAction();
            MyTerminalControlFactory.AddControl(detonateButton);
        }
Ejemplo n.º 43
0
		static MyShipConnector()
        {
            var stateWriter = new MyTerminalControl<MyShipConnector>.WriterDelegate((b, sb) => b.WriteLockStateValue(sb));

            var throwOut = new MyTerminalControlOnOffSwitch<MyShipConnector>("ThrowOut", MySpaceTexts.Terminal_ThrowOut);
            throwOut.Getter = (block) => block.ThrowOut;
            throwOut.Setter = (block, value) => MySyncShipConnector.SendChangePropertyMessage(value, block, MySyncShipConnector.Properties.ThrowOut);
            throwOut.EnableToggleAction();
            MyTerminalControlFactory.AddControl(throwOut);

            var collectAll = new MyTerminalControlOnOffSwitch<MyShipConnector>("CollectAll", MySpaceTexts.Terminal_CollectAll);
            collectAll.Getter = (block) => block.CollectAll;
            collectAll.Setter = (block, value) => MySyncShipConnector.SendChangePropertyMessage(value, block, MySyncShipConnector.Properties.CollectAll);
            collectAll.EnableToggleAction();
            MyTerminalControlFactory.AddControl(collectAll);

            var lockBtn = new MyTerminalControlButton<MyShipConnector>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.TryConnect());
            lockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
            lockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
            lockBtn.EnableAction();
            MyTerminalControlFactory.AddControl(lockBtn);

            var unlockBtn = new MyTerminalControlButton<MyShipConnector>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.TryDisconnect());
            unlockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
            unlockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
            unlockBtn.EnableAction();
            MyTerminalControlFactory.AddControl(unlockBtn);

            var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
            MyTerminalAction<MyShipConnector> switchLockAction = new MyTerminalAction<MyShipConnector>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);
            switchLockAction.Action = (b) => b.TrySwitch();
            switchLockAction.Writer = stateWriter;
            switchLockAction.Enabled = (b) => b.m_connectorMode == Mode.Connector;
            MyTerminalControlFactory.AddAction(switchLockAction);
        }
Ejemplo n.º 44
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);
        }
Ejemplo n.º 45
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);
 }
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyMechanicalConnectionBlockBase>())
                return;

            var weldSpeed = new MyTerminalControlSlider<MyMechanicalConnectionBlockBase>("Weld speed", MySpaceTexts.BlockPropertyTitle_WeldSpeed, MySpaceTexts.Blank);
            weldSpeed.SetLimits((block) => 0f, (block) => MyGridPhysics.SmallShipMaxLinearVelocity());
            weldSpeed.DefaultValueGetter = (block) => MyGridPhysics.LargeShipMaxLinearVelocity() - 5f;
            weldSpeed.Getter = (x) => x.m_weldSpeed;
            weldSpeed.Setter = (x, v) => x.m_weldSpeed.Value = v;
            weldSpeed.Writer = (x, res) => res.AppendDecimal((float)Math.Sqrt(x.m_weldSpeedSq), 1).Append("m/s");
            weldSpeed.EnableActions();
            MyTerminalControlFactory.AddControl(weldSpeed);

            var weldForce = new MyTerminalControlCheckbox<MyMechanicalConnectionBlockBase>("Force weld", MySpaceTexts.BlockPropertyTitle_WeldForce, MySpaceTexts.Blank);
            weldForce.Getter = (x) => x.m_forceWeld;
            weldForce.Setter = (x, v) => x.m_forceWeld.Value = v;
            weldForce.EnableAction();
            MyTerminalControlFactory.AddControl(weldForce);

            var addPistonHead = new MyTerminalControlButton<MyMechanicalConnectionBlockBase>("Add Top Part", MySpaceTexts.BlockActionTitle_AddPistonHead, MySpaceTexts.BlockActionTooltip_AddPistonHead, (b) => b.RecreateTop());
            addPistonHead.Enabled = (b) => (b.TopBlock == null);
            addPistonHead.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addPistonHead);
        }
Ejemplo n.º 47
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MySoundBlock>())
                return;

            var volumeSlider = new MyTerminalControlSlider<MySoundBlock>("VolumeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockVolume, MySpaceTexts.BlockPropertyDescription_SoundBlockVolume);
            volumeSlider.SetLimits(0, 1.0f);
            volumeSlider.DefaultValue = 1;
            volumeSlider.Getter = (x) => x.Volume;
            volumeSlider.Setter = (x, v) => x.Volume = v;
            volumeSlider.Writer = (x, result) => result.AppendInt32((int)(x.Volume * 100.0)).Append(" %");
            volumeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(volumeSlider);

            var rangeSlider = new MyTerminalControlSlider<MySoundBlock>("RangeSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockRange, MySpaceTexts.BlockPropertyDescription_SoundBlockRange);
            rangeSlider.SetLimits(0, 500);
            rangeSlider.DefaultValue = 50;
            rangeSlider.Getter = (x) => x.Range;
            rangeSlider.Setter = (x, v) => x.Range = v;
            rangeSlider.Writer = (x, result) => result.AppendInt32((int)x.Range).Append(" m");
            rangeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(rangeSlider);

            m_playButton = new MyTerminalControlButton<MySoundBlock>("PlaySound", MySpaceTexts.BlockPropertyTitle_SoundBlockPlay, MySpaceTexts.Blank, (x) => MyMultiplayer.RaiseEvent(x, y => y.PlaySound));
            m_playButton.Enabled = (x) => x.IsSoundSelected;
            m_playButton.EnableAction();
            MyTerminalControlFactory.AddControl(m_playButton);

            m_stopButton = new MyTerminalControlButton<MySoundBlock>("StopSound", MySpaceTexts.BlockPropertyTitle_SoundBlockStop, MySpaceTexts.Blank,
                (x) => { MyMultiplayer.RaiseEvent(x, y => y.StopSound); x.m_willStartSound = false; });
            m_stopButton.Enabled = (x) => x.IsSoundSelected;
            m_stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(m_stopButton);

            m_loopableTimeSlider = new MyTerminalControlSlider<MySoundBlock>("LoopableSlider", MySpaceTexts.BlockPropertyTitle_SoundBlockLoopTime, MySpaceTexts.Blank);
            m_loopableTimeSlider.DefaultValue = 1f;
            m_loopableTimeSlider.Getter = (x) => x.LoopPeriod;
            m_loopableTimeSlider.Setter = (x, f) => x.LoopPeriod = f;
            m_loopableTimeSlider.Writer = (x, result) => MyValueFormatter.AppendTimeInBestUnit(x.LoopPeriod, result);
            m_loopableTimeSlider.Enabled = (x) => x.IsLoopable;
            m_loopableTimeSlider.Normalizer = (x, f) => x.NormalizeLoopPeriod(f);
            m_loopableTimeSlider.Denormalizer = (x, f) => x.DenormalizeLoopPeriod(f);
            m_loopableTimeSlider.EnableActions();
            MyTerminalControlFactory.AddControl(m_loopableTimeSlider);

            var soundsList = new MyTerminalControlListbox<MySoundBlock>("SoundsList", MySpaceTexts.BlockPropertyTitle_SoundBlockSoundList, MySpaceTexts.Blank);
            soundsList.ListContent = (x, list1, list2) => x.FillListContent(list1, list2);
            soundsList.ItemSelected = (x, y) => x.SelectSound(y, true);
            MyTerminalControlFactory.AddControl(soundsList);
        }
Ejemplo n.º 48
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);
        }
Ejemplo n.º 49
0
        static MyPistonBase()
        {
            var reverse = new MyTerminalControlButton<MyPistonBase>("Reverse", MySpaceTexts.BlockActionTitle_Reverse, MySpaceTexts.Blank, (x) => x.SyncObject.SetVelocity(-x.Velocity));
            reverse.EnableAction(MyTerminalActionIcons.REVERSE);
            MyTerminalControlFactory.AddControl(reverse);

            var extendAction = new MyTerminalAction<MyPistonBase>("Extend", MyTexts.Get(MySpaceTexts.BlockActionTitle_Extend), OnExtendApplied, null, MyTerminalActionIcons.REVERSE);
            extendAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(extendAction);
        
            var retractAction = new MyTerminalAction<MyPistonBase>("Retract", MyTexts.Get(MySpaceTexts.BlockActionTitle_Retract), OnRetractApplied, null, MyTerminalActionIcons.REVERSE);
            retractAction.Enabled = (b) => b.IsWorking == true && b.IsFunctional == true;
            MyTerminalControlFactory.AddAction(retractAction);

            var velocity = new MyTerminalControlSlider<MyPistonBase>("Velocity", MySpaceTexts.BlockPropertyTitle_Velocity, MySpaceTexts.Blank);
            velocity.SetLimits((block) => -block.BlockDefinition.MaxVelocity, (block) => block.BlockDefinition.MaxVelocity);
            velocity.DefaultValue = -0.5f;
            velocity.Getter = (x) => x.Velocity;
            velocity.Setter = (x, v) => x.SyncObject.SetVelocity(v);
            velocity.Writer = (x, res) => res.AppendDecimal(x.Velocity, 1).Append("m/s");
            velocity.EnableActionsWithReset();
            MyTerminalControlFactory.AddControl(velocity);

            var maxDist = new MyTerminalControlSlider<MyPistonBase>("UpperLimit", MySpaceTexts.BlockPropertyTitle_MaximalDistance, MySpaceTexts.Blank);
            maxDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            maxDist.DefaultValueGetter = (block) => block.BlockDefinition.Maximum;
            maxDist.Getter = (x) => x.MaxLimit;
            maxDist.Setter = (x, v) => x.SyncObject.SetMax(v);
            maxDist.Writer = (x, res) => res.AppendDecimal(x.MaxLimit, 1).Append("m");
            maxDist.EnableActions();
            MyTerminalControlFactory.AddControl(maxDist);

            var minDist = new MyTerminalControlSlider<MyPistonBase>("LowerLimit", MySpaceTexts.BlockPropertyTitle_MinimalDistance, MySpaceTexts.Blank);
            minDist.SetLimits((block) => block.BlockDefinition.Minimum, (block) => block.BlockDefinition.Maximum);
            minDist.DefaultValueGetter = (block) => block.BlockDefinition.Minimum;
            minDist.Getter = (x) => x.MinLimit;
            minDist.Setter = (x, v) => x.SyncObject.SetMin(v);
            minDist.Writer = (x, res) => res.AppendDecimal(x.MinLimit, 1).Append("m");
            minDist.EnableActions();
            MyTerminalControlFactory.AddControl(minDist);
        }
Ejemplo n.º 50
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);

        }
Ejemplo n.º 51
0
        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);
        }