예제 #1
0
 protected override void CreateTerminalControls()
 {
     if (!MyTerminalControlFactory.AreControlsCreated <MyOreDetector>())
     {
         base.CreateTerminalControls();
         MyTerminalControlSlider <MyOreDetector> slider1 = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange);
         MyTerminalControlSlider <MyOreDetector> slider2 = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange);
         slider2.SetLimits(x => 0f, x => x.m_definition.MaximumRange);
         MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local3 = (MyTerminalValueControl <MyOreDetector, float> .GetterDelegate)slider2;
         local3.DefaultValue = new float?((float)100);
         local3.Getter       = x => (x.Range * x.m_definition.MaximumRange) * 0.01f;
         MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local14 = local3;
         MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local15 = local3;
         local15.Setter = (x, v) => x.Range = (v / x.m_definition.MaximumRange) * 100f;
         MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local12 = local15;
         MyTerminalValueControl <MyOreDetector, float> .GetterDelegate local13 = local15;
         local13.Writer = (x, result) => result.AppendInt32(((int)x.m_oreDetectorComponent.DetectionRadius)).Append(" m");
         MyTerminalControlFactory.AddControl <MyOreDetector>((MyTerminalControl <MyOreDetector>)local13);
         MyStringId?on = null;
         on = null;
         MyTerminalControlCheckbox <MyOreDetector> checkbox1 = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, on, on);
         MyTerminalControlCheckbox <MyOreDetector> checkbox2 = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, on, on);
         checkbox2.Getter = x => x.m_oreDetectorComponent.BroadcastUsingAntennas;
         MyTerminalControlCheckbox <MyOreDetector> local10 = checkbox2;
         MyTerminalControlCheckbox <MyOreDetector> local11 = checkbox2;
         local11.Setter = (x, v) => x.m_broadcastUsingAntennas.Value = v;
         MyTerminalControlCheckbox <MyOreDetector> checkbox = local11;
         checkbox.EnableAction <MyOreDetector>(null);
         MyTerminalControlFactory.AddControl <MyOreDetector>(checkbox);
     }
 }
        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);
        }
예제 #3
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyThrust>())
            {
                return;
            }
            base.CreateTerminalControls();
            float threshold      = 1f;
            var   thrustOverride = new MyTerminalControlSlider <MyThrust>("Override", MySpaceTexts.BlockPropertyTitle_ThrustOverride, MySpaceTexts.BlockPropertyDescription_ThrustOverride);

            thrustOverride.Getter = (x) => x.m_thrustOverride;
            thrustOverride.Setter = (x, v) =>
            {
                x.m_thrustOverride.Value = (v <= threshold ? 0 : v);
                x.RaisePropertiesChanged();
            };

            thrustOverride.DefaultValue = 0;
            thrustOverride.SetLimits((x) => 0f, (x) => 100f);
            thrustOverride.EnableActions();
            thrustOverride.Writer = (x, result) =>
            {
                if (x.ThrustOverride < 1f)
                {
                    result.Append(MyTexts.Get(MyCommonTexts.Disabled));
                }
                else
                {
                    MyValueFormatter.AppendForceInBestUnit(x.ThrustOverride * x.m_thrustComponent.GetLastThrustMultiplier(x), result);
                }
            };
            MyTerminalControlFactory.AddControl(thrustOverride);
        }
예제 #4
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);
        }
        static MyGravityGenerator()
        {
            var fieldWidth = new MyTerminalControlSlider <MyGravityGenerator>("Width", MySpaceTexts.BlockPropertyTitle_GravityFieldWidth, MySpaceTexts.BlockPropertyDescription_GravityFieldWidth);

            fieldWidth.SetLimits(1, 150);
            fieldWidth.DefaultValue = 150;
            fieldWidth.Getter       = (x) => x.m_fieldSize.Value.X;
            fieldWidth.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.X         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.X, NUM_DECIMALS)).Append(" m");
            fieldWidth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidth);

            var fieldHeight = new MyTerminalControlSlider <MyGravityGenerator>("Height", MySpaceTexts.BlockPropertyTitle_GravityFieldHeight, MySpaceTexts.BlockPropertyDescription_GravityFieldHeight);

            fieldHeight.SetLimits(1, 150);
            fieldHeight.DefaultValue = 150;
            fieldHeight.Getter       = (x) => x.m_fieldSize.Value.Y;
            fieldHeight.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Y         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Y, NUM_DECIMALS)).Append(" m");

            fieldHeight.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeight);

            var fieldDepth = new MyTerminalControlSlider <MyGravityGenerator>("Depth", MySpaceTexts.BlockPropertyTitle_GravityFieldDepth, MySpaceTexts.BlockPropertyDescription_GravityFieldDepth);

            fieldDepth.SetLimits(1, 150);
            fieldDepth.DefaultValue = 150;
            fieldDepth.Getter       = (x) => x.m_fieldSize.Value.Z;
            fieldDepth.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Z         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Z, NUM_DECIMALS)).Append(" m");
            fieldDepth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepth);

            var gravityAcceleration = new MyTerminalControlSlider <MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);

            gravityAcceleration.SetLimits(-MyGravityProviderSystem.G, MyGravityProviderSystem.G);
            gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
            gravityAcceleration.Getter       = (x) => x.GravityAcceleration;
            gravityAcceleration.Setter       = (x, v) => x.GravityAcceleration = v;
            gravityAcceleration.Writer       = (x, result) => result.AppendDecimal(x.m_gravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
            gravityAcceleration.EnableActions();
            MyTerminalControlFactory.AddControl(gravityAcceleration);
        }
예제 #6
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyGravityGenerator>())
                return;
            base.CreateTerminalControls();
            var fieldWidth = new MyTerminalControlSlider<MyGravityGenerator>("Width", MySpaceTexts.BlockPropertyTitle_GravityFieldWidth, MySpaceTexts.BlockPropertyDescription_GravityFieldWidth);
            fieldWidth.SetLimits((x) => x.BlockDefinition.MinFieldSize.X, (x) => x.BlockDefinition.MaxFieldSize.X);
            fieldWidth.DefaultValue = 150;
            fieldWidth.Getter = (x) => x.m_fieldSize.Value.X;
            fieldWidth.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.X = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.X, NUM_DECIMALS)).Append(" m");
            fieldWidth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidth);

            var fieldHeight = new MyTerminalControlSlider<MyGravityGenerator>("Height", MySpaceTexts.BlockPropertyTitle_GravityFieldHeight, MySpaceTexts.BlockPropertyDescription_GravityFieldHeight);
            fieldHeight.SetLimits((x) => x.BlockDefinition.MinFieldSize.Y, (x) => x.BlockDefinition.MaxFieldSize.Y);
            fieldHeight.DefaultValue = 150;
            fieldHeight.Getter = (x) => x.m_fieldSize.Value.Y;
            fieldHeight.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Y = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Y, NUM_DECIMALS)).Append(" m");

            fieldHeight.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeight);

            var fieldDepth = new MyTerminalControlSlider<MyGravityGenerator>("Depth", MySpaceTexts.BlockPropertyTitle_GravityFieldDepth, MySpaceTexts.BlockPropertyDescription_GravityFieldDepth);
            fieldDepth.SetLimits((x) => x.BlockDefinition.MinFieldSize.Z, (x) => x.BlockDefinition.MaxFieldSize.Z);
            fieldDepth.DefaultValue = 150;
            fieldDepth.Getter = (x) => x.m_fieldSize.Value.Z;
            fieldDepth.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Z = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Z, NUM_DECIMALS)).Append(" m");
            fieldDepth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepth);

            var gravityAcceleration = new MyTerminalControlSlider<MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);
            gravityAcceleration.SetLimits((x) => x.BlockDefinition.MinGravityAcceleration, (x) => x.BlockDefinition.MaxGravityAcceleration);
            gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
            gravityAcceleration.Getter = (x) => x.GravityAcceleration;
            gravityAcceleration.Setter = (x, v) => x.GravityAcceleration = v;
            gravityAcceleration.Writer = (x, result) => result.AppendDecimal(x.GravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
            gravityAcceleration.EnableActions();
            MyTerminalControlFactory.AddControl(gravityAcceleration);
        }
예제 #7
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyGravityGeneratorSphere>())
            {
                return;
            }

            if (MyFakes.ENABLE_GRAVITY_GENERATOR_SPHERE)
            {
                var fieldRadius = new MyTerminalControlSlider <MyGravityGeneratorSphere>("Radius", MySpaceTexts.BlockPropertyTitle_GravityFieldRadius, MySpaceTexts.BlockPropertyDescription_GravityFieldRadius);
                fieldRadius.DefaultValue = DEFAULT_RADIUS;
                fieldRadius.Getter       = (x) => x.m_radius;
                fieldRadius.Setter       = (x, v) =>
                {
                    if (v < x.BlockDefinition.MinRadius)
                    {
                        v = x.BlockDefinition.MinRadius;
                    }
                    x.Radius = v;
                };
                fieldRadius.Normalizer = (x, v) =>
                {
                    if (v == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return((v - x.BlockDefinition.MinRadius) / (x.BlockDefinition.MaxRadius - x.BlockDefinition.MinRadius));
                    }
                };
                fieldRadius.Denormalizer = (x, v) =>
                {
                    if (v == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(v * (x.BlockDefinition.MaxRadius - x.BlockDefinition.MinRadius) + x.BlockDefinition.MinRadius);
                    }
                };
                fieldRadius.Writer = (x, result) => result.AppendInt32((int)x.m_radius).Append(" m");
                fieldRadius.EnableActions();
                MyTerminalControlFactory.AddControl(fieldRadius);

                var gravityAcceleration = new MyTerminalControlSlider <MyGravityGeneratorSphere>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);
                gravityAcceleration.SetLimits(-MyGravityProviderSystem.G, MyGravityProviderSystem.G);
                gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
                gravityAcceleration.Getter       = (x) => x.GravityAcceleration;
                gravityAcceleration.Setter       = (x, v) => x.GravityAcceleration = v;
                gravityAcceleration.Writer       = (x, result) => result.AppendDecimal(x.m_gravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
                gravityAcceleration.EnableActions();
                MyTerminalControlFactory.AddControl(gravityAcceleration);
            }
        }
예제 #8
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);
        }
        static MyGravityGenerator()
        {
            var fieldWidth = new MyTerminalControlSlider<MyGravityGenerator>("Width", MySpaceTexts.BlockPropertyTitle_GravityFieldWidth, MySpaceTexts.BlockPropertyDescription_GravityFieldWidth);
            fieldWidth.SetLimits(1, 150);
            fieldWidth.DefaultValue = 150;
            fieldWidth.Getter = (x) => x.m_fieldSize.Value.X;
            fieldWidth.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.X = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.X, NUM_DECIMALS)).Append(" m");
            fieldWidth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidth);

            var fieldHeight = new MyTerminalControlSlider<MyGravityGenerator>("Height", MySpaceTexts.BlockPropertyTitle_GravityFieldHeight, MySpaceTexts.BlockPropertyDescription_GravityFieldHeight);
            fieldHeight.SetLimits(1, 150);
            fieldHeight.DefaultValue = 150;
            fieldHeight.Getter = (x) => x.m_fieldSize.Value.Y;
            fieldHeight.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Y = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Y, NUM_DECIMALS)).Append(" m");

            fieldHeight.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeight);

            var fieldDepth = new MyTerminalControlSlider<MyGravityGenerator>("Depth", MySpaceTexts.BlockPropertyTitle_GravityFieldDepth, MySpaceTexts.BlockPropertyDescription_GravityFieldDepth);
            fieldDepth.SetLimits(1, 150);
            fieldDepth.DefaultValue = 150;
            fieldDepth.Getter = (x) => x.m_fieldSize.Value.Z;
            fieldDepth.Setter = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Z = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Z, NUM_DECIMALS)).Append(" m");
            fieldDepth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepth);

            var gravityAcceleration = new MyTerminalControlSlider<MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);
            gravityAcceleration.SetLimits(-MyGravityProviderSystem.G, MyGravityProviderSystem.G);
			gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
            gravityAcceleration.Getter = (x) => x.GravityAcceleration;
            gravityAcceleration.Setter = (x, v) => x.GravityAcceleration = v;
            gravityAcceleration.Writer = (x, result) => result.AppendDecimal(x.m_gravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
            gravityAcceleration.EnableActions();
            MyTerminalControlFactory.AddControl(gravityAcceleration);
        }
예제 #10
0
        static MyMotorSuspension()
        {
            var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);

            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.SyncObject.ChangeSteering(v);
            steering.EnableAction();
            MyTerminalControlFactory.AddControl(steering);

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

            propulsion.Getter = (x) => x.Propulsion;
            propulsion.Setter = (x, v) => x.SyncObject.ChangePropulsion(v);
            propulsion.EnableAction();
            MyTerminalControlFactory.AddControl(propulsion);

            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.SyncObject.ChangeDamping(v * 0.002f);
            damping.Writer = (x, res) => res.AppendInt32((int)(x.Damping / 0.002f)).Append("%");
            damping.EnableActions();
            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.SyncObject.ChangeStrength(v * 0.002f);
            strength.Writer = (x, res) => res.AppendInt32((int)(x.Strength / 0.002f)).Append("%");
            strength.EnableActions();
            MyTerminalControlFactory.AddControl(strength);

            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.SyncObject.ChangeFriction(v / 100);
            friction.Writer       = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            MyTerminalControlFactory.AddControl(friction);

            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.SyncObject.ChangePower(v / 100);
            power.Writer       = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            MyTerminalControlFactory.AddControl(power);
        }
예제 #11
0
        public RotorPicker(IMyTerminalBlock cockpit, string rotorName, ControlRotorParams rotorParams, SetControlRotors onComplete)
        {
            m_block      = cockpit;
            m_onComplete = onComplete;

            IEnumerable <IMyMotorStator> selected;

            rotorParams(out selected, out m_sensitivity, out m_trim);
            m_trim = MathHelper.ToDegrees(m_trim);

            m_listbox              = new MyTerminalControlListbox <MyCockpit>("Arms_RotorPicker", MyStringId.GetOrCompute(rotorName + " Rotors"), MyStringId.NullOrEmpty, true, 14);
            m_listbox.ListContent  = ListContent;
            m_listbox.ItemSelected = ItemSelected;

            m_sensitivitySlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerSensitivity", MyStringId.GetOrCompute("Control Sensitivity"), MyStringId.GetOrCompute("How sensitive the ship will be to input"));
            m_sensitivitySlider.DefaultValue = 1f;
            m_sensitivitySlider.Getter       = b => m_sensitivity;
            m_sensitivitySlider.Setter       = (b, value) => m_sensitivity = value;
            m_sensitivitySlider.SetLogLimits(0.01f, 100f);
            m_sensitivitySlider.Writer = (b, sb) => sb.Append(m_sensitivity);

            m_trimSlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerTrim", MyStringId.GetOrCompute("Trim"), MyStringId.GetOrCompute("Default angle of rotors"));
            m_trimSlider.DefaultValue = 0f;
            m_trimSlider.Getter       = b => m_trim;
            m_trimSlider.Setter       = (b, value) => m_trim = value;
            m_trimSlider.SetLimits(-45f, 45f);
            m_trimSlider.Writer = (b, sb) => {
                sb.Append(m_trim);
                sb.Append('°');
            };

            m_save = new MyTerminalControlButton <MyCockpit>("Arms_RotorPickerSave", MyStringId.GetOrCompute("Save & Exit"), MyStringId.NullOrEmpty, SaveAndExit);

            CubeGridCache cache = CubeGridCache.GetFor(m_block.CubeGrid);

            if (cache == null)
            {
                return;
            }

            foreach (IMyMotorStator stator in cache.BlocksOfType(typeof(MyObjectBuilder_MotorStator)))
            {
                MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(new StringBuilder(stator.DisplayNameText), userData: stator);
                m_allItems.Add(item);
                if (selected.Contains(stator))
                {
                    m_selected.Add(item);
                }
            }

            MyTerminalControls.Static.CustomControlGetter += CustomControlGetter;
            cockpit.RebuildControls();
        }
예제 #12
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);
        }
예제 #13
0
        static MyOreDetector()
        {
            var range = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange);

            range.SetLimits(1, 100);
            range.DefaultValue = 100;
            range.Getter       = (x) => x.Range;
            range.Setter       = (x, v) => x.Range = v;
            range.Writer       = (x, result) => result.AppendInt32((int)x.m_oreDetectorComponent.DetectionRadius).Append(" m");

            var broadcastUsingAntennas = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas);

            broadcastUsingAntennas.Getter = (x) => x.m_oreDetectorComponent.BroadcastUsingAntennas;
            broadcastUsingAntennas.Setter = (x, v) => x.SyncObject.SendChangeOreDetector(v);
            MyTerminalControlFactory.AddControl(broadcastUsingAntennas);
        }
예제 #14
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);
        }
예제 #15
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MySpaceBall>())
            {
                return;
            }
            base.CreateTerminalControls();
            MyTerminalControlFactory.RemoveBaseClass <MySpaceBall, MyTerminalBlock>();

            var mass = new MyTerminalControlSlider <MySpaceBall>("VirtualMass", MySpaceTexts.BlockPropertyDescription_SpaceBallVirtualMass, MySpaceTexts.BlockPropertyDescription_SpaceBallVirtualMass);

            mass.Getter             = (x) => x.VirtualMass;
            mass.Setter             = (x, v) => x.VirtualMass = v;
            mass.DefaultValueGetter = (x) => DEFAULT_MASS;
            mass.SetLimits(x => 0, x => x.BlockDefinition.MaxVirtualMass);
            mass.Writer = (x, result) => MyValueFormatter.AppendWeightInBestUnit(x.VirtualMass, result);
            mass.EnableActions();
            MyTerminalControlFactory.AddControl(mass);

            if (MyPerGameSettings.BallFriendlyPhysics)
            {
                var friction = new MyTerminalControlSlider <MySpaceBall>("Friction", MySpaceTexts.BlockPropertyDescription_SpaceBallFriction, MySpaceTexts.BlockPropertyDescription_SpaceBallFriction);
                friction.Getter             = (x) => x.Friction;
                friction.Setter             = (x, v) => x.Friction = v;
                friction.DefaultValueGetter = (x) => DEFAULT_FRICTION;
                friction.SetLimits(0, 1.0f);
                friction.Writer = (x, result) => result.AppendInt32((int)(x.Friction * 100)).Append("%");
                friction.EnableActions();
                MyTerminalControlFactory.AddControl(friction);

                var restitution = new MyTerminalControlSlider <MySpaceBall>("Restitution", MySpaceTexts.BlockPropertyDescription_SpaceBallRestitution, MySpaceTexts.BlockPropertyDescription_SpaceBallRestitution);
                restitution.Getter             = (x) => x.Restitution;
                restitution.Setter             = (x, v) => x.Restitution = v;
                restitution.DefaultValueGetter = (x) => DEFAULT_RESTITUTION;
                restitution.SetLimits(0, 1.0f);
                restitution.Writer = (x, result) => result.AppendInt32((int)(x.Restitution * 100)).Append("%");
                restitution.EnableActions();
                MyTerminalControlFactory.AddControl(restitution);
            }

            var enableBroadcast = new MyTerminalControlCheckbox <MySpaceBall>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast);

            enableBroadcast.Getter = (x) => x.RadioBroadcaster.Enabled;
            enableBroadcast.Setter = (x, v) => x.m_broadcastSync.Value = v;
            enableBroadcast.EnableAction();
            MyTerminalControlFactory.AddControl(enableBroadcast);
        }
예제 #16
0
        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) => (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<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);
        }
예제 #17
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyOreDetector>())
            {
                return;
            }

            var range = new MyTerminalControlSlider <MyOreDetector>("Range", MySpaceTexts.BlockPropertyTitle_OreDetectorRange, MySpaceTexts.BlockPropertyDescription_OreDetectorRange);

            range.SetLimits(1, 100);
            range.DefaultValue = 100;
            range.Getter       = (x) => x.Range;
            range.Setter       = (x, v) => x.Range = v;
            range.Writer       = (x, result) => result.AppendInt32((int)x.m_oreDetectorComponent.DetectionRadius).Append(" m");

            var broadcastUsingAntennas = new MyTerminalControlCheckbox <MyOreDetector>("BroadcastUsingAntennas", MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas, MySpaceTexts.BlockPropertyDescription_BroadcastUsingAntennas);

            broadcastUsingAntennas.Getter = (x) => x.m_oreDetectorComponent.BroadcastUsingAntennas;
            broadcastUsingAntennas.Setter = (x, v) => x.m_broadcastUsingAntennas.Value = v;
            broadcastUsingAntennas.EnableAction();
            MyTerminalControlFactory.AddControl(broadcastUsingAntennas);
        }
예제 #18
0
        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) => (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 <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);
        }
예제 #19
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);
        }
예제 #20
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MyTextPanel>())
                return;

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

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

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

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

            MyTerminalControlFactory.AddControl(titleField);

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

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

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

            MyTerminalControlFactory.AddControl(showTextOnScreen);

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

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

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

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

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

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

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

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

            var removeSelectedButton = new MyTerminalControlButton<MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection());
            MyTerminalControlFactory.AddControl(removeSelectedButton);
        }
예제 #21
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);
        }
예제 #22
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;
            }
        }
예제 #23
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);
        }
예제 #24
0
        static MyMotorSuspension()
        {
            var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);

            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.SyncObject.ChangeSteering(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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.InvertSteer, (v ? 1 : 0));
            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.SyncObject.ChangePropulsion(v);
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            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.SyncObject.ChangePower(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.SyncObject.ChangeFriction(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.SyncObject.ChangeDamping(v * 0.002f);
            damping.Writer = (x, res) => res.AppendInt32((int)(x.Damping / 0.002f)).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.SyncObject.ChangeStrength(v * 0.002f);
            strength.Writer = (x, res) => res.AppendInt32((int)(x.Strength / 0.002f)).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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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);
        }
예제 #25
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);
        }
        static MyMotorSuspension()
        {
            var steering = new MyTerminalControlCheckbox<MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);
            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.SyncObject.ChangeSteering(v);
            steering.EnableAction();
            MyTerminalControlFactory.AddControl(steering);

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

            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.SyncObject.ChangeDamping(v * 0.002f);
            damping.Writer = (x, res) => res.AppendInt32((int)(x.Damping / 0.002f)).Append("%");
            damping.EnableActions();
            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.SyncObject.ChangeStrength(v * 0.002f);
            strength.Writer = (x, res) => res.AppendInt32((int)(x.Strength / 0.002f)).Append("%");
            strength.EnableActions();
            MyTerminalControlFactory.AddControl(strength);

            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.SyncObject.ChangeFriction(v / 100);
            friction.Writer = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            MyTerminalControlFactory.AddControl(friction);

            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.SyncObject.ChangePower(v / 100);
            power.Writer = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            MyTerminalControlFactory.AddControl(power);

        }
예제 #27
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;
            }
        }
예제 #28
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);
        }
예제 #29
0
        static MyTextPanel()
        {
            var publicTitleField = new MyTerminalControlTextbox <MyTextPanel>("PublicTitle", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank);

            publicTitleField.Getter = (x) => x.PublicTitle;
            publicTitleField.Setter = (x, v) => x.SyncObject.SendChangeTitleMessage(v, true);
            publicTitleField.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(publicTitleField);

            var showPublicButton = new MyTerminalControlButton <MyTextPanel>("ShowPublicTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true));

            showPublicButton.Enabled = (x) => !x.IsOpen;
            showPublicButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showPublicButton);

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

            var titleField = new MyTerminalControlTextbox <MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelTitle, MySpaceTexts.Blank);

            titleField.Getter = (x) => x.PrivateTitle;
            titleField.Setter = (x, v) => x.SyncObject.SendChangeTitleMessage(v, false);
            titleField.SupportsMultipleBlocks = false;

            MyTerminalControlFactory.AddControl(titleField);

            var showButton = new MyTerminalControlButton <MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, false));

            showButton.Enabled = (x) => !x.IsOpen;
            showButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showButton);

            var comboAccess = new MyTerminalControlCombobox <MyTextPanel>("Access", MySpaceTexts.BlockPropertyTitle_TextPanelAccessType, MySpaceTexts.Blank);

            comboAccess.ComboBoxContent = (x) => FillComboBoxContent(x);
            comboAccess.Getter          = (x) => (long)x.AccessFlag;
            comboAccess.Setter          = (x, y) => x.SyncObject.SendChangeAccessFlagMessage((byte)y);
            comboAccess.Enabled         = (x) => x.OwnerId != 0;
            MyTerminalControlFactory.AddControl(comboAccess);
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            var showTextOnScreen = new MyTerminalControlCombobox <MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank);

            showTextOnScreen.ComboBoxContent = (x) => FillShowOnScreenComboBoxContent(x);
            showTextOnScreen.Getter          = (x) => (long)x.ShowTextFlag;
            showTextOnScreen.Setter          = (x, y) => x.SyncObject.SendShowOnScreenChangeRequest((byte)y);
            showTextOnScreen.Enabled         = (x) => x.OwnerId != 0;

            MyTerminalControlFactory.AddControl(showTextOnScreen);

            var changeFontSlider = new MyTerminalControlSlider <MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank);

            changeFontSlider.SetLimits(0.1f, 10.0f);
            changeFontSlider.DefaultValue = 1.0f;
            changeFontSlider.Getter       = (x) => x.FontSize;
            changeFontSlider.Setter       = (x, v) => x.SyncObject.SendFontSizeChangeRequest(v);
            changeFontSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, 1));
            changeFontSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeFontSlider);

            var fontColor = new MyTerminalControlColor <MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor);

            fontColor.Getter = (x) => x.FontColor;
            fontColor.Setter = (x, v) => x.SyncObject.SendChangeFontColorRequest(v);
            MyTerminalControlFactory.AddControl(fontColor);

            var backgroundColor = new MyTerminalControlColor <MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor);

            backgroundColor.Getter = (x) => x.BackgroundColor;
            backgroundColor.Setter = (x, v) => x.SyncObject.SendChangeBackgroundColorRequest(v);
            MyTerminalControlFactory.AddControl(backgroundColor);

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

            var imagesList = new MyTerminalControlListbox <MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true);

            imagesList.ListContent  = (x, list1, list2) => x.FillListContent(list1, list2);
            imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y);
            MyTerminalControlFactory.AddControl(imagesList);

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

            MyTerminalControlFactory.AddControl(addToSelectionButton);

            var changeIntervalSlider = new MyTerminalControlSlider <MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank);

            changeIntervalSlider.SetLimits(0, 30.0f);
            changeIntervalSlider.DefaultValue = 0;
            changeIntervalSlider.Getter       = (x) => x.ChangeInterval;
            changeIntervalSlider.Setter       = (x, v) => x.SyncObject.SendIntervalChangeRequest(v);
            changeIntervalSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s");
            changeIntervalSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeIntervalSlider);

            var selectedImagesList = new MyTerminalControlListbox <MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true);

            selectedImagesList.ListContent  = (x, list1, list2) => x.FillSelectedListContent(list1, list2);
            selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y);
            MyTerminalControlFactory.AddControl(selectedImagesList);

            var removeSelectedButton = new MyTerminalControlButton <MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection());

            MyTerminalControlFactory.AddControl(removeSelectedButton);
        }
예제 #30
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);
        }
예제 #31
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);
        }
예제 #32
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);
        }
예제 #33
0
        static MyLightingBlock()
        {
            var lightColor = new MyTerminalControlColor<MyLightingBlock>("Color", MySpaceTexts.BlockPropertyTitle_LightColor);
            lightColor.Getter = (x) => x.Color;
            lightColor.Setter = (x, v) => x.m_lightColor.Value = v;
            MyTerminalControlFactory.AddControl(lightColor);

            var lightRadius = new MyTerminalControlSlider<MyLightingBlock>("Radius", MySpaceTexts.BlockPropertyTitle_LightRadius, MySpaceTexts.BlockPropertyDescription_LightRadius);
            lightRadius.SetLimits((x) => x.RadiusBounds.Min, (x) => x.RadiusBounds.Max);
            lightRadius.DefaultValueGetter = (x) => x.RadiusBounds.Default;
            lightRadius.Getter = (x) => x.Radius;
            lightRadius.Setter = (x, v) => x.m_lightRadius.Value = v;
            lightRadius.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Range, 1)).Append(" m");
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightRadius);

            var lightFalloff = new MyTerminalControlSlider<MyLightingBlock>("Falloff", MySpaceTexts.BlockPropertyTitle_LightFalloff, MySpaceTexts.BlockPropertyDescription_LightFalloff);
            lightFalloff.SetLimits((x) => x.FalloffBounds.Min, (x) => x.FalloffBounds.Max);
            lightFalloff.DefaultValueGetter = (x) => x.FalloffBounds.Default;
            lightFalloff.Getter = (x) => x.Falloff;
            lightFalloff.Setter = (x, v) => x.m_lightFalloff.Value = v;
            lightFalloff.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Falloff, 1));
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightFalloff);

            var lightIntensity = new MyTerminalControlSlider<MyLightingBlock>("Intensity", MySpaceTexts.BlockPropertyTitle_LightIntensity, MySpaceTexts.BlockPropertyDescription_LightIntensity);
            lightIntensity.SetLimits((x) => x.IntensityBounds.Min, (x) => x.IntensityBounds.Max);
            lightIntensity.DefaultValueGetter = (x) => x.IntensityBounds.Default;
            lightIntensity.Getter = (x) => x.Intensity;
            lightIntensity.Setter = (x, v) => x.Intensity = v;
            lightIntensity.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.Intensity, 1));
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightIntensity);

            var lightBlinkTime = new MyTerminalControlSlider<MyLightingBlock>("Blink Interval", MySpaceTexts.BlockPropertyTitle_LightBlinkInterval, MySpaceTexts.BlockPropertyDescription_LightBlinkInterval);
            lightBlinkTime.SetLimits((x) => x.BlinkIntervalSecondsBounds.Min, (x) => x.BlinkIntervalSecondsBounds.Max);
            lightBlinkTime.DefaultValueGetter = (x) => x.BlinkIntervalSecondsBounds.Default;
            lightBlinkTime.Getter = (x) => x.BlinkIntervalSeconds;
            lightBlinkTime.Setter = (x, v) => x.BlinkIntervalSeconds = v;
            lightBlinkTime.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkIntervalSeconds, NUM_DECIMALS)).Append(" s");
            lightBlinkTime.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkTime);

            var lightBlinkLenght = new MyTerminalControlSlider<MyLightingBlock>("Blink Lenght", MySpaceTexts.BlockPropertyTitle_LightBlinkLenght, MySpaceTexts.BlockPropertyDescription_LightBlinkLenght);
            lightBlinkLenght.SetLimits((x) => x.BlinkLenghtBounds.Min, (x) => x.BlinkLenghtBounds.Max);
            lightBlinkLenght.DefaultValueGetter = (x) => x.BlinkLenghtBounds.Default;
            lightBlinkLenght.Getter = (x) => x.BlinkLength;
            lightBlinkLenght.Setter = (x, v) => x.BlinkLength = v;
            lightBlinkLenght.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkLength, NUM_DECIMALS)).Append(" %");
            lightBlinkLenght.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkLenght);

            var ligthBlinkOffset = new MyTerminalControlSlider<MyLightingBlock>("Blink Offset", MySpaceTexts.BlockPropertyTitle_LightBlinkOffset, MySpaceTexts.BlockPropertyDescription_LightBlinkOffset);
            ligthBlinkOffset.SetLimits((x) => x.BlinkOffsetBounds.Min, (x) => x.BlinkOffsetBounds.Max);
            ligthBlinkOffset.DefaultValueGetter = (x) => x.BlinkOffsetBounds.Default;
            ligthBlinkOffset.Getter = (x) => x.BlinkOffset;
            ligthBlinkOffset.Setter = (x, v) => x.BlinkOffset = v;
            ligthBlinkOffset.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkOffset, NUM_DECIMALS)).Append(" %");
            ligthBlinkOffset.EnableActions();
            MyTerminalControlFactory.AddControl(ligthBlinkOffset);
        }
예제 #34
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);
        }
예제 #35
0
        static MySensorBlock()
        {
            m_openedToolbars = new List <MyToolbar>();

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

            MyTerminalControlFactory.AddControl(toolbarButton);

            var fieldWidthMin = new MyTerminalControlSlider <MySensorBlock>("Left", MySpaceTexts.BlockPropertyTitle_SensorFieldWidthMin, MySpaceTexts.BlockPropertyDescription_SensorFieldLeft);

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

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

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


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

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

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

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

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

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

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

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

            var separatorFilters = new MyTerminalControlSeparator <MySensorBlock>();

            MyTerminalControlFactory.AddControl(separatorFilters);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            var separatorFactionFilters = new MyTerminalControlSeparator <MySensorBlock>();

            MyTerminalControlFactory.AddControl(separatorFactionFilters);

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

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

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

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

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

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

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

            detectEnemySwitch.Getter = (x) => x.DetectEnemy;
            detectEnemySwitch.Setter = (x, v) =>
            {
                x.DetectEnemy = v;
                (x.SyncObject as MySyncSensorBlock).SendFiltersChangedRequest(x.Filters);
            };
            detectEnemySwitch.EnableToggleAction();
            detectEnemySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectEnemySwitch);
        }
예제 #36
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);
        }
예제 #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) => 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);
        }
예제 #38
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyLightingBlock>())
            {
                return;
            }

            var lightColor = new MyTerminalControlColor <MyLightingBlock>("Color", MySpaceTexts.BlockPropertyTitle_LightColor);

            lightColor.Getter = (x) => x.Color;
            lightColor.Setter = (x, v) => x.m_lightColor.Value = v;
            MyTerminalControlFactory.AddControl(lightColor);

            var lightRadius = new MyTerminalControlSlider <MyLightingBlock>("Radius", MySpaceTexts.BlockPropertyTitle_LightRadius, MySpaceTexts.BlockPropertyDescription_LightRadius);

            lightRadius.SetLimits((x) => x.m_light.IsTypeSpot ? x.ReflectorRadiusBounds.Min : x.RadiusBounds.Min,
                                  (x) => x.m_light.IsTypeSpot ? x.ReflectorRadiusBounds.Max : x.RadiusBounds.Max);
            lightRadius.DefaultValueGetter = (x) => x.m_light.IsTypeSpot ? x.ReflectorRadiusBounds.Default : x.RadiusBounds.Default;
            lightRadius.Getter             = (x) => x.m_light.IsTypeSpot ? x.ReflectorRadius : x.Radius;
            lightRadius.Setter             = (x, v) => x.m_lightRadius.Value = v;
            lightRadius.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.IsTypeSpot ? x.m_light.ReflectorRange : x.m_light.Range, 1)).Append(" m");
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightRadius);

            var lightFalloff = new MyTerminalControlSlider <MyLightingBlock>("Falloff", MySpaceTexts.BlockPropertyTitle_LightFalloff, MySpaceTexts.BlockPropertyDescription_LightFalloff);

            lightFalloff.SetLimits((x) => x.FalloffBounds.Min, (x) => x.FalloffBounds.Max);
            lightFalloff.DefaultValueGetter = (x) => x.FalloffBounds.Default;
            lightFalloff.Getter             = (x) => x.Falloff;
            lightFalloff.Setter             = (x, v) => x.m_lightFalloff.Value = v;
            lightFalloff.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.Falloff, 1));
            lightFalloff.EnableActions();
            MyTerminalControlFactory.AddControl(lightFalloff);

            var lightIntensity = new MyTerminalControlSlider <MyLightingBlock>("Intensity", MySpaceTexts.BlockPropertyTitle_LightIntensity, MySpaceTexts.BlockPropertyDescription_LightIntensity);

            lightIntensity.SetLimits((x) => x.IntensityBounds.Min, (x) => x.IntensityBounds.Max);
            lightIntensity.DefaultValueGetter = (x) => x.IntensityBounds.Default;
            lightIntensity.Getter             = (x) => x.Intensity;
            lightIntensity.Setter             = (x, v) => x.Intensity = v;
            lightIntensity.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.Intensity, 1));
            lightIntensity.EnableActions();
            MyTerminalControlFactory.AddControl(lightIntensity);

            var lightBlinkTime = new MyTerminalControlSlider <MyLightingBlock>("Blink Interval", MySpaceTexts.BlockPropertyTitle_LightBlinkInterval, MySpaceTexts.BlockPropertyDescription_LightBlinkInterval);

            lightBlinkTime.SetLimits((x) => x.BlinkIntervalSecondsBounds.Min, (x) => x.BlinkIntervalSecondsBounds.Max);
            lightBlinkTime.DefaultValueGetter = (x) => x.BlinkIntervalSecondsBounds.Default;
            lightBlinkTime.Getter             = (x) => x.BlinkIntervalSeconds;
            lightBlinkTime.Setter             = (x, v) => x.BlinkIntervalSeconds = v;
            lightBlinkTime.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkIntervalSeconds, NUM_DECIMALS)).Append(" s");
            lightBlinkTime.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkTime);

            var lightBlinkLenght = new MyTerminalControlSlider <MyLightingBlock>("Blink Lenght", MySpaceTexts.BlockPropertyTitle_LightBlinkLenght, MySpaceTexts.BlockPropertyDescription_LightBlinkLenght);

            lightBlinkLenght.SetLimits((x) => x.BlinkLenghtBounds.Min, (x) => x.BlinkLenghtBounds.Max);
            lightBlinkLenght.DefaultValueGetter = (x) => x.BlinkLenghtBounds.Default;
            lightBlinkLenght.Getter             = (x) => x.BlinkLength;
            lightBlinkLenght.Setter             = (x, v) => x.BlinkLength = v;
            lightBlinkLenght.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkLength, NUM_DECIMALS)).Append(" %");
            lightBlinkLenght.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkLenght);

            var ligthBlinkOffset = new MyTerminalControlSlider <MyLightingBlock>("Blink Offset", MySpaceTexts.BlockPropertyTitle_LightBlinkOffset, MySpaceTexts.BlockPropertyDescription_LightBlinkOffset);

            ligthBlinkOffset.SetLimits((x) => x.BlinkOffsetBounds.Min, (x) => x.BlinkOffsetBounds.Max);
            ligthBlinkOffset.DefaultValueGetter = (x) => x.BlinkOffsetBounds.Default;
            ligthBlinkOffset.Getter             = (x) => x.BlinkOffset;
            ligthBlinkOffset.Setter             = (x, v) => x.BlinkOffset = v;
            ligthBlinkOffset.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkOffset, NUM_DECIMALS)).Append(" %");
            ligthBlinkOffset.EnableActions();
            MyTerminalControlFactory.AddControl(ligthBlinkOffset);
        }
예제 #39
0
        static MyThrust()
        {
            float threshold = 1f;
            var thrustOverride = new MyTerminalControlSlider<MyThrust>("Override", MySpaceTexts.BlockPropertyTitle_ThrustOverride, MySpaceTexts.BlockPropertyDescription_ThrustOverride);
            thrustOverride.Getter = (x) => x.m_thrustOverride;
            thrustOverride.Setter = (x, v) =>
            {
                x.m_thrustOverride.Value = (v <= threshold ? 0 : v);
                x.RaisePropertiesChanged();
            };

            thrustOverride.DefaultValue = 0;
            thrustOverride.SetLimits((x) => 0f, (x) => 100f);
            thrustOverride.EnableActions();
            thrustOverride.Writer = (x, result) =>
                {
                    if (x.ThrustOverride < 1f)
                        result.Append(MyTexts.Get(MyCommonTexts.Disabled));
                    else
                        MyValueFormatter.AppendForceInBestUnit(x.ThrustOverride * x.m_thrustComponent.GetLastThrustMultiplier(x), result);
                };
            MyTerminalControlFactory.AddControl(thrustOverride);
        }
예제 #40
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);
        }
예제 #41
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyTextPanel>())
            {
                return;
            }
            base.CreateTerminalControls();
            var publicTitleField = new MyTerminalControlTextbox <MyTextPanel>("Title", MySpaceTexts.BlockPropertyTitle_TextPanelPublicTitle, MySpaceTexts.Blank);

            publicTitleField.Getter = (x) => x.PublicTitle;
            publicTitleField.Setter = (x, v) => x.SendChangeTitleMessage(v, true);
            publicTitleField.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(publicTitleField);

            var showPublicButton = new MyTerminalControlButton <MyTextPanel>("ShowTextPanel", MySpaceTexts.BlockPropertyTitle_TextPanelShowPublicTextPanel, MySpaceTexts.Blank, (x) => x.OpenWindow(true, true, true));

            showPublicButton.Enabled = (x) => !x.IsOpen;
            showPublicButton.SupportsMultipleBlocks = false;
            MyTerminalControlFactory.AddControl(showPublicButton);

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

            var showTextOnScreen = new MyTerminalControlOnOffSwitch <MyTextPanel>("ShowTextOnScreen", MySpaceTexts.BlockPropertyTitle_ShowTextOnScreen, MySpaceTexts.Blank);

            showTextOnScreen.Getter = (x) => x.ShowTextFlag != ShowTextOnScreenFlag.NONE;
            showTextOnScreen.Setter = (x, y) => x.ShowTextFlag = y ? ShowTextOnScreenFlag.PUBLIC : ShowTextOnScreenFlag.NONE;

            MyTerminalControlFactory.AddControl(showTextOnScreen);


            var comboFont = new MyTerminalControlCombobox <MyTextPanel>("Font", MySpaceTexts.BlockPropertyTitle_Font, MySpaceTexts.Blank);

            comboFont.ComboBoxContent = (x) => FillFontComboBoxContent(x);
            comboFont.Getter          = (x) => (long)x.Font.SubtypeId;
            comboFont.Setter          = (x, y) => x.Font = new MyDefinitionId(typeof(MyObjectBuilder_FontDefinition), MyStringHash.TryGet((int)y));
            MyTerminalControlFactory.AddControl(comboFont);
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            var changeFontSlider = new MyTerminalControlSlider <MyTextPanel>("FontSize", MySpaceTexts.BlockPropertyTitle_LCDScreenTextSize, MySpaceTexts.Blank);

            changeFontSlider.SetLimits(0.1f, 10.0f);
            changeFontSlider.DefaultValue = 1.0f;
            changeFontSlider.Getter       = (x) => x.FontSize;
            changeFontSlider.Setter       = (x, v) => x.FontSize = v;
            changeFontSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.FontSize, NUM_DECIMALS));
            changeFontSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeFontSlider);

            var fontColor = new MyTerminalControlColor <MyTextPanel>("FontColor", MySpaceTexts.BlockPropertyTitle_FontColor);

            fontColor.Getter = (x) => x.FontColor;
            fontColor.Setter = (x, v) => x.FontColor = v;
            MyTerminalControlFactory.AddControl(fontColor);

            var backgroundColor = new MyTerminalControlColor <MyTextPanel>("BackgroundColor", MySpaceTexts.BlockPropertyTitle_BackgroundColor);

            backgroundColor.Getter = (x) => x.BackgroundColor;
            backgroundColor.Setter = (x, v) => x.BackgroundColor = v;
            MyTerminalControlFactory.AddControl(backgroundColor);

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

            var imagesList = new MyTerminalControlListbox <MyTextPanel>("ImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenDefinitionsTextures, MySpaceTexts.Blank, true);

            imagesList.ListContent  = (x, list1, list2) => x.FillListContent(list1, list2);
            imagesList.ItemSelected = (x, y) => x.SelectImageToDraw(y);
            MyTerminalControlFactory.AddControl(imagesList);

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

            MyTerminalControlFactory.AddControl(addToSelectionButton);

            var changeIntervalSlider = new MyTerminalControlSlider <MyTextPanel>("ChangeIntervalSlider", MySpaceTexts.BlockPropertyTitle_LCDScreenRefreshInterval, MySpaceTexts.Blank);

            changeIntervalSlider.SetLimits(0, 30.0f);
            changeIntervalSlider.DefaultValue = 0;
            changeIntervalSlider.Getter       = (x) => x.ChangeInterval;
            changeIntervalSlider.Setter       = (x, v) => x.ChangeInterval = v;
            changeIntervalSlider.Writer       = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.ChangeInterval, NUM_DECIMALS)).Append(" s");
            changeIntervalSlider.EnableActions();
            MyTerminalControlFactory.AddControl(changeIntervalSlider);

            var selectedImagesList = new MyTerminalControlListbox <MyTextPanel>("SelectedImageList", MySpaceTexts.BlockPropertyTitle_LCDScreenSelectedTextures, MySpaceTexts.Blank, true);

            selectedImagesList.ListContent  = (x, list1, list2) => x.FillSelectedListContent(list1, list2);
            selectedImagesList.ItemSelected = (x, y) => x.SelectImage(y);
            MyTerminalControlFactory.AddControl(selectedImagesList);

            var removeSelectedButton = new MyTerminalControlButton <MyTextPanel>("RemoveSelectedTextures", MySpaceTexts.BlockPropertyTitle_LCDScreenRemoveSelectedTextures, MySpaceTexts.Blank, (x) => x.RemoveImagesFromSelection());

            MyTerminalControlFactory.AddControl(removeSelectedButton);
        }
예제 #42
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);
        }
예제 #43
0
        static void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated<MySensorBlock>())
                return;

            m_openedToolbars = new List<MyToolbar>();

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            var detectEnemySwitch = new MyTerminalControlOnOffSwitch<MySensorBlock>("Detect Enemy", MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy, MySpaceTexts.BlockPropertyTitle_SensorDetectEnemy);
            detectEnemySwitch.Getter = (x) => x.DetectEnemy;
            detectEnemySwitch.Setter = (x, v) =>
            {
                x.DetectEnemy = v;
            };
            detectEnemySwitch.EnableToggleAction();
            detectEnemySwitch.EnableOnOffActions();
            MyTerminalControlFactory.AddControl(detectEnemySwitch);
        }
예제 #44
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);
        }
예제 #45
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);
        }
예제 #46
0
        static MySpaceBall()
        {
            MyTerminalControlFactory.RemoveBaseClass<MySpaceBall, MyTerminalBlock>();

            var mass = new MyTerminalControlSlider<MySpaceBall>("VirtualMass", MySpaceTexts.BlockPropertyDescription_SpaceBallVirtualMass, MySpaceTexts.BlockPropertyDescription_SpaceBallVirtualMass);
            mass.Getter = (x) => x.VirtualMass;
            mass.Setter = (x, v) => x.VirtualMass = v;
            mass.DefaultValueGetter = (x) => DEFAULT_MASS;
            mass.SetLimits(x => 0, x => x.BlockDefinition.MaxVirtualMass);
            mass.Writer = (x, result) => MyValueFormatter.AppendWeightInBestUnit(x.VirtualMass, result);
            mass.EnableActions();
            MyTerminalControlFactory.AddControl(mass);

            if (MyPerGameSettings.BallFriendlyPhysics)
            {
                var friction = new MyTerminalControlSlider<MySpaceBall>("Friction", MySpaceTexts.BlockPropertyDescription_SpaceBallFriction, MySpaceTexts.BlockPropertyDescription_SpaceBallFriction);
                friction.Getter = (x) => x.Friction;
                friction.Setter = (x, v) => x.Friction  = v;
                friction.DefaultValueGetter = (x) => DEFAULT_FRICTION;
                friction.SetLimits(0, 1.0f);
                friction.Writer = (x, result) => result.AppendInt32((int)(x.Friction * 100)).Append("%");
                friction.EnableActions();
                MyTerminalControlFactory.AddControl(friction);

                var restitution = new MyTerminalControlSlider<MySpaceBall>("Restitution", MySpaceTexts.BlockPropertyDescription_SpaceBallRestitution, MySpaceTexts.BlockPropertyDescription_SpaceBallRestitution);
                restitution.Getter = (x) => x.Restitution;
                restitution.Setter = (x, v) => x.Restitution = v;
                restitution.DefaultValueGetter = (x) => DEFAULT_RESTITUTION;
                restitution.SetLimits(0, 1.0f);
                restitution.Writer = (x, result) => result.AppendInt32((int)(x.Restitution * 100)).Append("%");
                restitution.EnableActions();
                MyTerminalControlFactory.AddControl(restitution);  
            }

            var enableBroadcast = new MyTerminalControlCheckbox<MySpaceBall>("EnableBroadCast", MySpaceTexts.Antenna_EnableBroadcast, MySpaceTexts.Antenna_EnableBroadcast);
            enableBroadcast.Getter = (x) => x.RadioBroadcaster.Enabled;
            enableBroadcast.Setter = (x, v) => x.m_broadcastSync.Value = v;
            enableBroadcast.EnableAction();
            MyTerminalControlFactory.AddControl(enableBroadcast);
        }
예제 #47
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);
            //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);
        }
예제 #48
0
        static MyMotorSuspension()
        {
            var steering = new MyTerminalControlCheckbox<MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);
            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.SyncObject.ChangeSteering(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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.InvertSteer, (v ? 1 : 0));
            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.SyncObject.ChangePropulsion(v);
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            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.SyncObject.ChangePower(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.SyncObject.ChangeFriction(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.SyncObject.ChangeDamping(v * 0.002f);
            damping.Writer = (x, res) => res.AppendInt32((int)(x.Damping / 0.002f)).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.SyncObject.ChangeStrength(v * 0.002f);
            strength.Writer = (x, res) => res.AppendInt32((int)(x.Strength / 0.002f)).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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.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);
        }
예제 #49
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyGravityGenerator>())
            {
                return;
            }
            base.CreateTerminalControls();
            var fieldWidth = new MyTerminalControlSlider <MyGravityGenerator>("Width", MySpaceTexts.BlockPropertyTitle_GravityFieldWidth, MySpaceTexts.BlockPropertyDescription_GravityFieldWidth);

            fieldWidth.SetLimits((x) => x.BlockDefinition.MinFieldSize.X, (x) => x.BlockDefinition.MaxFieldSize.X);
            fieldWidth.DefaultValue = 150;
            fieldWidth.Getter       = (x) => x.m_fieldSize.Value.X;
            fieldWidth.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.X         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.X, NUM_DECIMALS)).Append(" m");
            fieldWidth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldWidth);

            var fieldHeight = new MyTerminalControlSlider <MyGravityGenerator>("Height", MySpaceTexts.BlockPropertyTitle_GravityFieldHeight, MySpaceTexts.BlockPropertyDescription_GravityFieldHeight);

            fieldHeight.SetLimits((x) => x.BlockDefinition.MinFieldSize.Y, (x) => x.BlockDefinition.MaxFieldSize.Y);
            fieldHeight.DefaultValue = 150;
            fieldHeight.Getter       = (x) => x.m_fieldSize.Value.Y;
            fieldHeight.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Y         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Y, NUM_DECIMALS)).Append(" m");

            fieldHeight.EnableActions();
            MyTerminalControlFactory.AddControl(fieldHeight);

            var fieldDepth = new MyTerminalControlSlider <MyGravityGenerator>("Depth", MySpaceTexts.BlockPropertyTitle_GravityFieldDepth, MySpaceTexts.BlockPropertyDescription_GravityFieldDepth);

            fieldDepth.SetLimits((x) => x.BlockDefinition.MinFieldSize.Z, (x) => x.BlockDefinition.MaxFieldSize.Z);
            fieldDepth.DefaultValue = 150;
            fieldDepth.Getter       = (x) => x.m_fieldSize.Value.Z;
            fieldDepth.Setter       = (x, v) =>
            {
                Vector3 fieldSize = x.m_fieldSize;
                fieldSize.Z         = v;
                x.m_fieldSize.Value = fieldSize;
            };
            fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Value.Z, NUM_DECIMALS)).Append(" m");
            fieldDepth.EnableActions();
            MyTerminalControlFactory.AddControl(fieldDepth);

            var gravityAcceleration = new MyTerminalControlSlider <MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);

            gravityAcceleration.SetLimits((x) => x.BlockDefinition.MinGravityAcceleration, (x) => x.BlockDefinition.MaxGravityAcceleration);
            gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
            gravityAcceleration.Getter       = (x) => x.GravityAcceleration;
            gravityAcceleration.Setter       = (x, v) => x.GravityAcceleration = v;
            gravityAcceleration.Writer       = (x, result) => result.AppendDecimal(x.GravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
            gravityAcceleration.EnableActions();
            MyTerminalControlFactory.AddControl(gravityAcceleration);
        }
        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);
        }
        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);
        }
예제 #52
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);
        }
        static MyLightingBlock()
        {
            var lightColor = new MyTerminalControlColor <MyLightingBlock>("Color", MySpaceTexts.BlockPropertyTitle_LightColor);

            lightColor.Getter = (x) => x.Color;
            lightColor.Setter = (x, v) => x.SyncObject.SendChangeLightColorRequest(v);
            MyTerminalControlFactory.AddControl(lightColor);

            var lightRadius = new MyTerminalControlSlider <MyLightingBlock>("Radius", MySpaceTexts.BlockPropertyTitle_LightRadius, MySpaceTexts.BlockPropertyDescription_LightRadius);

            lightRadius.SetLimits((x) => x.RadiusBounds.Min, (x) => x.RadiusBounds.Max);
            lightRadius.DefaultValueGetter = (x) => x.RadiusBounds.Default;
            lightRadius.Getter             = (x) => x.Radius;
            lightRadius.Setter             = (x, v) => x.SyncObject.SendChangeLightRadiusRequest(v);
            lightRadius.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Range, 1)).Append(" m");
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightRadius);

            var lightFalloff = new MyTerminalControlSlider <MyLightingBlock>("Falloff", MySpaceTexts.BlockPropertyTitle_LightFalloff, MySpaceTexts.BlockPropertyDescription_LightFalloff);

            lightFalloff.SetLimits((x) => x.FalloffBounds.Min, (x) => x.FalloffBounds.Max);
            lightFalloff.DefaultValueGetter = (x) => x.FalloffBounds.Default;
            lightFalloff.Getter             = (x) => x.Falloff;
            lightFalloff.Setter             = (x, v) => x.SyncObject.SendChangeLightFalloffRequest(v);
            lightFalloff.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_light.Falloff, 1));
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightFalloff);

            var lightIntensity = new MyTerminalControlSlider <MyLightingBlock>("Intensity", MySpaceTexts.BlockPropertyTitle_LightIntensity, MySpaceTexts.BlockPropertyDescription_LightIntensity);

            lightIntensity.SetLimits((x) => x.IntensityBounds.Min, (x) => x.IntensityBounds.Max);
            lightIntensity.DefaultValueGetter = (x) => x.IntensityBounds.Default;
            lightIntensity.Getter             = (x) => x.Intensity;
            lightIntensity.Setter             = (x, v) => x.SyncObject.SendChangeLightIntensityRequest(v);
            lightIntensity.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.Intensity, 1));
            lightRadius.EnableActions();
            MyTerminalControlFactory.AddControl(lightIntensity);

            var lightBlinkTime = new MyTerminalControlSlider <MyLightingBlock>("Blink Interval", MySpaceTexts.BlockPropertyTitle_LightBlinkInterval, MySpaceTexts.BlockPropertyDescription_LightBlinkInterval);

            lightBlinkTime.SetLimits((x) => x.BlinkIntervalSecondsBounds.Min, (x) => x.BlinkIntervalSecondsBounds.Max);
            lightBlinkTime.DefaultValueGetter = (x) => x.BlinkIntervalSecondsBounds.Default;
            lightBlinkTime.Getter             = (x) => x.BlinkIntervalSeconds;
            lightBlinkTime.Setter             = (x, v) => x.SyncObject.SendChangeLightBlinkIntervalRequest(v);
            lightBlinkTime.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkIntervalSeconds, NUM_DECIMALS)).Append(" s");
            lightBlinkTime.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkTime);

            var lightBlinkLenght = new MyTerminalControlSlider <MyLightingBlock>("Blink Lenght", MySpaceTexts.BlockPropertyTitle_LightBlinkLenght, MySpaceTexts.BlockPropertyDescription_LightBlinkLenght);

            lightBlinkLenght.SetLimits((x) => x.BlinkLenghtBounds.Min, (x) => x.BlinkLenghtBounds.Max);
            lightBlinkLenght.DefaultValueGetter = (x) => x.BlinkLenghtBounds.Default;
            lightBlinkLenght.Getter             = (x) => x.BlinkLength;
            lightBlinkLenght.Setter             = (x, v) => x.SyncObject.SendChangeLightBlinkLengthRequest(v);
            lightBlinkLenght.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkLength, NUM_DECIMALS)).Append(" %");
            lightBlinkLenght.EnableActions();
            MyTerminalControlFactory.AddControl(lightBlinkLenght);

            var ligthBlinkOffset = new MyTerminalControlSlider <MyLightingBlock>("Blink Offset", MySpaceTexts.BlockPropertyTitle_LightBlinkOffset, MySpaceTexts.BlockPropertyDescription_LightBlinkOffset);

            ligthBlinkOffset.SetLimits((x) => x.BlinkOffsetBounds.Min, (x) => x.BlinkOffsetBounds.Max);
            ligthBlinkOffset.DefaultValueGetter = (x) => x.BlinkOffsetBounds.Default;
            ligthBlinkOffset.Getter             = (x) => x.BlinkOffset;
            ligthBlinkOffset.Setter             = (x, v) => x.SyncObject.SendChangeLightBlinkOffsetRequest(v);
            ligthBlinkOffset.Writer             = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.BlinkOffset, NUM_DECIMALS)).Append(" %");
            ligthBlinkOffset.EnableActions();
            MyTerminalControlFactory.AddControl(ligthBlinkOffset);
        }
        static MyGravityGeneratorSphere()
        {
            if (MyFakes.ENABLE_GRAVITY_GENERATOR_SPHERE)
            {
                var fieldRadius = new MyTerminalControlSlider<MyGravityGeneratorSphere>("Radius", MySpaceTexts.BlockPropertyTitle_GravityFieldRadius, MySpaceTexts.BlockPropertyDescription_GravityFieldRadius);
                fieldRadius.DefaultValue = DEFAULT_RADIUS;
                fieldRadius.Getter = (x) => x.m_radius;
                fieldRadius.Setter = (x, v) =>
                {
                    if (v < x.BlockDefinition.MinRadius)
                    {
                        v = x.BlockDefinition.MinRadius;
                    }
                    x.SyncObject.SendChangeGravityGeneratorRequest(v, x.GravityAcceleration);
                };
                fieldRadius.Normalizer = (x, v) =>
                {
                    if (v == 0)
                    {
                        return 0;
                    }
                    else
                    {
                        return (v - x.BlockDefinition.MinRadius) / (x.BlockDefinition.MaxRadius - x.BlockDefinition.MinRadius);
                    }
                };
                fieldRadius.Denormalizer = (x, v) =>
                {
                    if (v == 0)
                    {
                        return 0;
                    }
                    else
                    {
                        return v * (x.BlockDefinition.MaxRadius - x.BlockDefinition.MinRadius) + x.BlockDefinition.MinRadius;
                    }
                };
                fieldRadius.Writer = (x, result) => result.AppendInt32((int)x.m_radius).Append(" m");
                fieldRadius.EnableActions();
                MyTerminalControlFactory.AddControl(fieldRadius);

                var gravityAcceleration = new MyTerminalControlSlider<MyGravityGeneratorSphere>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);
                gravityAcceleration.SetLimits(-MyGravityProviderSystem.G, MyGravityProviderSystem.G);
                gravityAcceleration.DefaultValue = MyGravityProviderSystem.G;
                gravityAcceleration.Getter = (x) => x.GravityAcceleration;
                gravityAcceleration.Setter = (x, v) => x.SyncObject.SendChangeGravityGeneratorRequest(x.m_radius, v);
                gravityAcceleration.Writer = (x, result) => result.AppendDecimal(x.m_gravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
                gravityAcceleration.EnableActions();
                MyTerminalControlFactory.AddControl(gravityAcceleration);
            }
        }