本文整理汇总了C#中MyTerminalControlSlider.EnableActions方法的典型用法代码示例。如果您正苦于以下问题:C# MyTerminalControlSlider.EnableActions方法的具体用法?C# MyTerminalControlSlider.EnableActions怎么用?C# MyTerminalControlSlider.EnableActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyTerminalControlSlider
的用法示例。
在下文中一共展示了MyTerminalControlSlider.EnableActions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyBeacon
static MyBeacon()
{
MyTerminalControlFactory.RemoveBaseClass<MyBeacon, MyTerminalBlock>();
var show = new MyTerminalControlOnOffSwitch<MyBeacon>("ShowInTerminal", MySpaceTexts.Terminal_ShowInTerminal, MySpaceTexts.Terminal_ShowInTerminalToolTip);
show.Getter = (x) => x.ShowInTerminal;
show.Setter = (x, v) => x.ShowInTerminal= v;
MyTerminalControlFactory.AddControl(show);
var showConfig = new MyTerminalControlOnOffSwitch<MyBeacon>("ShowInToolbarConfig", MySpaceTexts.Terminal_ShowInToolbarConfig, MySpaceTexts.Terminal_ShowInToolbarConfigToolTip);
showConfig.Getter = (x) => x.ShowInToolbarConfig;
showConfig.Setter = (x, v) => x.ShowInToolbarConfig = v;
MyTerminalControlFactory.AddControl(showConfig);
var customName = new MyTerminalControlTextbox<MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank);
customName.Getter = (x) => x.CustomName;
customName.Setter = (x, v) => x.SetCustomName(v);
customName.SupportsMultipleBlocks = false;
MyTerminalControlFactory.AddControl(customName);
MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyBeacon>());
var broadcastRadius = new MyTerminalControlSlider<MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius);
broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE);
broadcastRadius.DefaultValue = 10000;
broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius;
broadcastRadius.Setter = (x, v) => x.m_radius.Value = v;
broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m"));
broadcastRadius.EnableActions();
MyTerminalControlFactory.AddControl(broadcastRadius);
}
示例2: CreateTerminalControls
static void CreateTerminalControls()
{
if (MyTerminalControlFactory.AreControlsCreated<MyGravityGenerator>())
return;
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);
}
示例3: MyGravityGenerator
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.X;
fieldWidth.Setter = (x, v) =>
{
x.m_fieldSize.X = v;
x.SyncObject.SendChangeGravityGeneratorRequest(ref x.m_fieldSize, x.GravityAcceleration);
};
fieldWidth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.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.Y;
fieldHeight.Setter = (x, v) =>
{
x.m_fieldSize.Y = v;
x.SyncObject.SendChangeGravityGeneratorRequest(ref x.m_fieldSize, x.GravityAcceleration);
};
fieldHeight.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.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.Z;
fieldDepth.Setter = (x, v) =>
{
x.m_fieldSize.Z = v;
x.SyncObject.SendChangeGravityGeneratorRequest(ref x.m_fieldSize, x.GravityAcceleration);
};
fieldDepth.Writer = (x, result) => result.Append(MyValueFormatter.GetFormatedFloat(x.m_fieldSize.Z, NUM_DECIMALS)).Append(" m");
fieldDepth.EnableActions();
MyTerminalControlFactory.AddControl(fieldDepth);
var gravityAcceleration = new MyTerminalControlSlider<MyGravityGenerator>("Gravity", MySpaceTexts.BlockPropertyTitle_GravityAcceleration, MySpaceTexts.BlockPropertyDescription_GravityAcceleration);
gravityAcceleration.SetLimits(-1, 1);
gravityAcceleration.DefaultValue = 1;
gravityAcceleration.Getter = (x) => x.GravityAcceleration / MyGravityProviderSystem.G;
gravityAcceleration.Setter = (x, v) => x.SyncObject.SendChangeGravityGeneratorRequest(ref x.m_fieldSize, v * MyGravityProviderSystem.G);
gravityAcceleration.Writer = (x, result) => result.AppendDecimal(x.m_gravityAcceleration / MyGravityProviderSystem.G, 2).Append(" G");
gravityAcceleration.EnableActions();
MyTerminalControlFactory.AddControl(gravityAcceleration);
}
示例4: MyGyro
static MyGyro()
{
var gyroPower = new MyTerminalControlSlider<MyGyro>("Power", MySpaceTexts.BlockPropertyTitle_GyroPower, MySpaceTexts.BlockPropertyDescription_GyroPower);
gyroPower.Getter = (x) => x.GyroPower;
gyroPower.Setter = (x, v) => { x.GyroPower = v; x.SyncObject.SendChangeGyroPowerRequest(v); };
gyroPower.Writer = (x, result) => result.AppendInt32((int)(x.GyroPower * 100)).Append(" %");
gyroPower.DefaultValue = 1;
gyroPower.EnableActions(MyTerminalActionIcons.INCREASE, MyTerminalActionIcons.DECREASE);
MyTerminalControlFactory.AddControl(gyroPower);
if (MyFakes.ENABLE_GYRO_OVERRIDE)
{
var gyroOverride = new MyTerminalControlCheckbox<MyGyro>("Override", MySpaceTexts.BlockPropertyTitle_GyroOverride, MySpaceTexts.BlockPropertyDescription_GyroOverride);
gyroOverride.Getter = (x) => x.GyroOverride;
gyroOverride.Setter = (x, v) => { x.SetGyroOverride(v); x.SyncObject.SendGyroOverrideRequest(v); };
gyroOverride.EnableAction();
MyTerminalControlFactory.AddControl(gyroOverride);
// Pitch = X axis, Yaw = Y axis, Roll = Z axis
var gyroOverrideSliderY = new MyTerminalControlSlider<MyGyro>("Yaw", MySpaceTexts.BlockPropertyTitle_GyroYawOverride, MySpaceTexts.BlockPropertyDescription_GyroYawOverride);
gyroOverrideSliderY.Getter = (x) => -x.m_gyroOverrideVelocity.Y;
gyroOverrideSliderY.Setter = (x, v) => { SetGyroTorqueYaw(x, -v); x.SyncObject.SendGyroTorqueRequest(x.m_gyroOverrideVelocity); };
gyroOverrideSliderY.Writer = (x, result) => result.AppendDecimal(x.m_gyroOverrideVelocity.Y * MathHelper.RadiansPerSecondToRPM, 2).Append(" RPM");
gyroOverrideSliderY.Enabled = (x) => x.GyroOverride;
gyroOverrideSliderY.DefaultValue = 0;
gyroOverrideSliderY.SetDualLogLimits((x) => 0.01f * MathHelper.RPMToRadiansPerSecond, MaxAngularRadiansPerSecond, 0.05f);
gyroOverrideSliderY.EnableActions(MyTerminalActionIcons.INCREASE, MyTerminalActionIcons.DECREASE);
MyTerminalControlFactory.AddControl(gyroOverrideSliderY);
var gyroOverrideSliderX = new MyTerminalControlSlider<MyGyro>("Pitch", MySpaceTexts.BlockPropertyTitle_GyroPitchOverride, MySpaceTexts.BlockPropertyDescription_GyroPitchOverride);
gyroOverrideSliderX.Getter = (x) => x.m_gyroOverrideVelocity.X;
gyroOverrideSliderX.Setter = (x, v) => { SetGyroTorquePitch(x, v); x.SyncObject.SendGyroTorqueRequest(x.m_gyroOverrideVelocity); };
gyroOverrideSliderX.Writer = (x, result) => result.AppendDecimal(x.m_gyroOverrideVelocity.X * MathHelper.RadiansPerSecondToRPM, 2).Append(" RPM");
gyroOverrideSliderX.Enabled = (x) => x.GyroOverride;
gyroOverrideSliderX.DefaultValue = 0;
gyroOverrideSliderX.SetDualLogLimits((x) => 0.01f * MathHelper.RPMToRadiansPerSecond, MaxAngularRadiansPerSecond, 0.05f);
gyroOverrideSliderX.EnableActions(MyTerminalActionIcons.INCREASE, MyTerminalActionIcons.DECREASE);
MyTerminalControlFactory.AddControl(gyroOverrideSliderX);
var gyroOverrideSliderZ = new MyTerminalControlSlider<MyGyro>("Roll", MySpaceTexts.BlockPropertyTitle_GyroRollOverride, MySpaceTexts.BlockPropertyDescription_GyroRollOverride);
gyroOverrideSliderZ.Getter = (x) => -x.m_gyroOverrideVelocity.Z;
gyroOverrideSliderZ.Setter = (x, v) => { SetGyroTorqueRoll(x, -v); x.SyncObject.SendGyroTorqueRequest(x.m_gyroOverrideVelocity); };
gyroOverrideSliderZ.Writer = (x, result) => result.AppendDecimal(x.m_gyroOverrideVelocity.Z * MathHelper.RadiansPerSecondToRPM, 2).Append(" RPM");
gyroOverrideSliderZ.Enabled = (x) => x.GyroOverride;
gyroOverrideSliderZ.DefaultValue = 0;
gyroOverrideSliderZ.SetDualLogLimits((x) => 0.01f * MathHelper.RPMToRadiansPerSecond, MaxAngularRadiansPerSecond, 0.05f);
gyroOverrideSliderZ.EnableActions(MyTerminalActionIcons.INCREASE, MyTerminalActionIcons.DECREASE);
MyTerminalControlFactory.AddControl(gyroOverrideSliderZ);
}
}
示例5: CreateTerminalControls
static void CreateTerminalControls()
{
if (MyTerminalControlFactory.AreControlsCreated<MyShipConnector>())
return;
var throwOut = new MyTerminalControlOnOffSwitch<MyShipConnector>("ThrowOut", MySpaceTexts.Terminal_ThrowOut);
throwOut.Getter = (block) => block.ThrowOut;
throwOut.Setter = (block, value) => block.ThrowOut.Value = value;
throwOut.EnableToggleAction();
MyTerminalControlFactory.AddControl(throwOut);
var collectAll = new MyTerminalControlOnOffSwitch<MyShipConnector>("CollectAll", MySpaceTexts.Terminal_CollectAll);
collectAll.Getter = (block) => block.CollectAll;
collectAll.Setter = (block, value) => block.CollectAll.Value = value;
collectAll.EnableToggleAction();
MyTerminalControlFactory.AddControl(collectAll);
var lockBtn = new MyTerminalControlButton<MyShipConnector>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.TryConnect());
lockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
lockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
var actionLock = lockBtn.EnableAction();
actionLock.Enabled = (b) => b.m_connectorMode == Mode.Connector;
MyTerminalControlFactory.AddControl(lockBtn);
var unlockBtn = new MyTerminalControlButton<MyShipConnector>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.TryDisconnect());
unlockBtn.Enabled = (b) => b.IsWorking && b.InConstraint;
unlockBtn.Visible = (b) => b.m_connectorMode == Mode.Connector;
var actionUnlock = unlockBtn.EnableAction();
actionUnlock.Enabled = (b) => b.m_connectorMode == Mode.Connector;
MyTerminalControlFactory.AddControl(unlockBtn);
var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
MyTerminalAction<MyShipConnector> switchLockAction = new MyTerminalAction<MyShipConnector>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);
switchLockAction.Action = (b) => b.TrySwitch();
switchLockAction.Writer = (b, sb) => b.WriteLockStateValue(sb);
switchLockAction.Enabled = (b) => b.m_connectorMode == Mode.Connector;
MyTerminalControlFactory.AddAction(switchLockAction);
var strength = new MyTerminalControlSlider<MyShipConnector>("Strength", MySpaceTexts.BlockPropertyTitle_Connector_Strength, MySpaceTexts.BlockPropertyDescription_Connector_Strength);
strength.Getter = (x) => x.Strength;
strength.Setter = (x, v) => x.Strength.Value = v;
strength.DefaultValue = MyObjectBuilder_ShipConnector.DefaultStrength;
strength.SetLogLimits(MinStrength, 1.0f);
strength.EnableActions(enabled: (b) => b.m_connectorMode == Mode.Connector);
strength.Enabled = (b) => b.m_connectorMode == Mode.Connector;
strength.Visible = (b) => b.m_connectorMode == Mode.Connector;
strength.Writer = (x, result) =>
{
if (x.Strength <= MinStrength)
result.Append(MyTexts.Get(MyCommonTexts.Disabled));
else
result.AppendFormatedDecimal("", x.Strength * 100, 4, " %");
};
MyTerminalControlFactory.AddControl(strength);
}
示例6: MyThrust
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);
}
示例7: MyLightingBlock
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);
}
示例8: MyLandingGear
static MyLandingGear()
{
var stateWriter = new MyTerminalControl<MyLandingGear>.WriterDelegate((b, sb) => b.WriteLockStateValue(sb));
var lockBtn = new MyTerminalControlButton<MyLandingGear>("Lock", MySpaceTexts.BlockActionTitle_Lock, MySpaceTexts.Blank, (b) => b.RequestLandingGearLock());
lockBtn.Enabled = (b) => b.IsWorking;
lockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
MyTerminalControlFactory.AddControl(lockBtn);
var unlockBtn = new MyTerminalControlButton<MyLandingGear>("Unlock", MySpaceTexts.BlockActionTitle_Unlock, MySpaceTexts.Blank, (b) => b.RequestLandingGearUnlock());
unlockBtn.Enabled = (b) => b.IsWorking;
unlockBtn.EnableAction(MyTerminalActionIcons.TOGGLE, (MyStringId?)null, stateWriter);
MyTerminalControlFactory.AddControl(unlockBtn);
var title = MyTexts.Get(MySpaceTexts.BlockActionTitle_SwitchLock);
MyTerminalAction<MyLandingGear> switchLockAction = new MyTerminalAction<MyLandingGear>("SwitchLock", title, MyTerminalActionIcons.TOGGLE);
switchLockAction.Action = (b) => b.RequestLandingGearSwitch();
switchLockAction.Writer = stateWriter;
MyTerminalControlFactory.AddAction(switchLockAction);
var autoLock = new MyTerminalControlCheckbox<MyLandingGear>("Autolock", MySpaceTexts.BlockPropertyTitle_LandGearAutoLock, MySpaceTexts.Blank);
autoLock.Getter = (b) => b.m_autoLock;
autoLock.Setter = (b, v) => b.SyncObject.SendAutoLockChange(v);
autoLock.EnableAction();
MyTerminalControlFactory.AddControl(autoLock);
if (MyFakes.LANDING_GEAR_BREAKABLE)
{
var brakeForce = new MyTerminalControlSlider<MyLandingGear>("BreakForce", MySpaceTexts.BlockPropertyTitle_BreakForce, MySpaceTexts.BlockPropertyDescription_BreakForce);
brakeForce.Getter = (x) => x.BreakForce;
brakeForce.Setter = (x, v) => x.SyncObject.SendBrakeForceChange(v);
brakeForce.DefaultValue = 1;
brakeForce.Writer = (x, result) =>
{
if (x.BreakForce >= MaxSolverImpulse) result.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
else MyValueFormatter.AppendForceInBestUnit(x.BreakForce, result);
};
brakeForce.Normalizer = (b, v) => ThresholdToRatio(v);
brakeForce.Denormalizer = (b, v) => RatioToThreshold(v);
brakeForce.EnableActions();
MyTerminalControlFactory.AddControl(brakeForce);
}
}
示例9: CreateTerminalControls
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);
}
示例10: CreateTerminalControls
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);
}
示例11: MySoundBlock
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);
}
示例12: CreateTerminalControls
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)
//.........这里部分代码省略.........
示例13: MyGravityGeneratorSphere
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);
}
}
示例14: CreateTerminalControls
protected override void CreateTerminalControls()
{
if (MyTerminalControlFactory.AreControlsCreated<MyBeacon>())
return;
base.CreateTerminalControls();
//MyTerminalControlFactory.RemoveBaseClass<MyBeacon, MyTerminalBlock>(); // this removed also controls shared with other blocks
//removed unnecessary controls
var controlList = MyTerminalControlFactory.GetList(typeof(MyBeacon)).Controls;
controlList.Remove(controlList[4]);//name
controlList.Remove(controlList[4]);//show on HUD
var customName = new MyTerminalControlTextbox<MyBeacon>("CustomName", MyCommonTexts.Name, MySpaceTexts.Blank);
customName.Getter = (x) => x.CustomName;
customName.Setter = (x, v) => x.SetCustomName(v);
customName.SupportsMultipleBlocks = false;
MyTerminalControlFactory.AddControl(customName);
MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator<MyBeacon>());
var broadcastRadius = new MyTerminalControlSlider<MyBeacon>("Radius", MySpaceTexts.BlockPropertyTitle_BroadcastRadius, MySpaceTexts.BlockPropertyDescription_BroadcastRadius);
broadcastRadius.SetLogLimits(1, MyEnergyConstants.MAX_RADIO_POWER_RANGE);
broadcastRadius.DefaultValue = 10000;
broadcastRadius.Getter = (x) => x.RadioBroadcaster.BroadcastRadius;
broadcastRadius.Setter = (x, v) => x.m_radius.Value = v;
broadcastRadius.Writer = (x, result) => result.Append(new StringBuilder().AppendDecimal(x.RadioBroadcaster.BroadcastRadius, 0).Append(" m"));
broadcastRadius.EnableActions();
MyTerminalControlFactory.AddControl(broadcastRadius);
}
示例15: MyMotorSuspension
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);
}