Exemple #1
0
 /// <summary>
 /// Gets actions for blocks implementing IMyWarhead.
 /// </summary>
 public static void GetWarheadActions(PropertyBlock block, List <BlockMemberBase> members)
 {
     members.Add(GetBlockAction(
                     // Name
                     MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown),
                     // Status
                     x =>
     {
         x.Clear();
         x.Append('(');
         x.Append(Math.Truncate(block.Warhead.CountdownTime));
         x.Append("s)");
     },
                     block.Warhead.StartCountdown, block));
     members.Add(GetBlockAction(
                     MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown), null,
                     block.Warhead.StopCountdown, block));
     members.Add(GetBlockAction(
                     MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_Detonate), null,
                     block.Warhead.Detonate, block));
 }
            public FloatProperty(string name, ITerminalProperty <float> prop, PropertyBlock block)
            {
                this.prop   = prop;
                this.pBlock = block;
                this.name   = name;
                minValue    = this.prop.GetMinimum(pBlock.TBlock);
                maxValue    = this.prop.GetMaximum(pBlock.TBlock);

                if (float.IsInfinity(minValue) || float.IsInfinity(maxValue))
                {
                    incr0 = 1f;
                }
                else
                {
                    double range = Math.Abs(maxValue - minValue), exp;

                    if (range > maxValue)
                    {
                        exp = Math.Truncate(Math.Log10(range));
                    }
                    else
                    {
                        exp = Math.Truncate(Math.Log10(2 * range));
                    }

                    incr0 = (float)(Math.Pow(10d, exp) / cfg.floatDiv);
                }

                if (incr0 == 0)
                {
                    incr0 = 1f;
                }

                incrC = incr0 * cfg.floatMult.Z; // x64
                incrB = incr0 * cfg.floatMult.Y; // x16
                incrA = incr0 * cfg.floatMult.X; // x8
            }
            public static TextProperty GetProperty(StringBuilder name, ITerminalProperty <StringBuilder> property, PropertyBlock block)
            {
                TextProperty prop = block.textPropPool.Get();

                prop.SetProperty(name, property, block);

                return(prop);
            }
            public override void SetProperty(StringBuilder name, ITerminalProperty <StringBuilder> property, PropertyBlock block)
            {
                base.SetProperty(name, property, block);

                if (poolParent == null)
                {
                    poolParent = block.textPropPool;
                }
            }
Exemple #5
0
            public override void SetProperty(StringBuilder name, ITerminalProperty <bool> property, PropertyBlock block)
            {
                base.SetProperty(name, property, block);

                if (poolParent == null)
                {
                    poolParent = block.boolPropPool;
                }

                if (property.Id == "OnOff" && block.SubtypeId.UsesSubtype(TBlockSubtypes.Powered)) // Insert power draw / output info
                {
                    GetPostfixFunc = GetPowerDisplayFunc;
                }
                else if (property.Id == "Stockpile" && block.SubtypeId.UsesSubtype(TBlockSubtypes.GasTank)) // Insert gas tank info
                {
                    GetPostfixFunc = GetTankFillFunc;
                }

                if (property is IMyTerminalControlOnOffSwitch)
                {
                    var onOffSwitch = property as IMyTerminalControlOnOffSwitch;

                    OnText  = onOffSwitch.OnText;
                    OffText = onOffSwitch.OffText;
                }
                else
                {
                    OnText  = MySpaceTexts.SwitchText_On;
                    OffText = MySpaceTexts.SwitchText_Off;
                }
            }
Exemple #6
0
            public static HsvColorProperty GetProperty(StringBuilder name, ITerminalProperty <Vector3> property, PropertyBlock block)
            {
                HsvColorProperty prop = block.hsvPropPool.Get();

                prop.SetProperty(name, property, block);

                return(prop);
            }
Exemple #7
0
            public static BlockAction GetBlockAction(string value, Action <StringBuilder> GetPostfixFunc, Action Action, PropertyBlock block)
            {
                BlockAction blockAction = block.blockActionPool.Get();

                blockAction._propName = value;
                blockAction.SetAction(x => { if (x.Length == 0)
                                             {
                                                 x.Append(value);
                                             }
                                      }, GetPostfixFunc, Action, block);

                return(blockAction);
            }
Exemple #8
0
            public void SetAction(Action <StringBuilder> GetValueFunc, Action <StringBuilder> GetPostfixFunc, Action Action, PropertyBlock block)
            {
                if (poolParent == null)
                {
                    poolParent = block.blockActionPool;
                }

                Name    = null;
                Enabled = true;

                this.GetValueFunc   = GetValueFunc;
                this.GetPostfixFunc = GetPostfixFunc;
                action = Action;
            }
            public override void SetProperty(StringBuilder name, IMyTerminalControlCombobox comboBox, PropertyBlock block)
            {
                base.SetProperty(name, comboBox, block);

                if (poolParent == null)
                {
                    poolParent = block.comboPropPool;
                }

                if (control.Id == "ChargeMode" && block.SubtypeId.UsesSubtype(TBlockSubtypes.Battery)) // Insert bat charge info
                {
                    GetPostfixFunc = GetChargePostfixFunc;
                }
            }
Exemple #10
0
 /// <summary>
 /// Gets actions for blocks implementing IMyDoor.
 /// </summary>
 public static void GetDoorActions(PropertyBlock block, List <BlockMemberBase> members)
 {
     members.Add(GetBlockAction(
                     MyTexts.TrySubstitute("Open / Close"), null,
                     block.Door.ToggleDoor, block));
 }
Exemple #11
0
            public static ColorProperty GetProperty(StringBuilder name, ITerminalProperty <Color> property, PropertyBlock block)
            {
                ColorProperty prop = block.colorPropPool.Get();

                prop.SetProperty(name, property, block);

                return(prop);
            }
Exemple #12
0
 public void SetProperty(StringBuilder name, ITerminalProperty <Vector3> property, PropertyBlock block)
 {
     hsvWrapper.HsvProp = property;
     SetProperty(name, hsvWrapper, block);
 }
Exemple #13
0
 /// <summary>
 /// Updates the menu's current target
 /// </summary>
 public virtual void SetTarget(PropertyBlock target)
 {
     this.target = target;
     visStart    = 0;
     visEnd      = 0;
 }
 public virtual void SetProperty(StringBuilder name, TProp property, PropertyBlock block)
 {
     SetPropertyInternal(name, property, block, property.Getter, property.Setter);
 }
            public override void SetProperty(StringBuilder name, ITerminalProperty <float> property, PropertyBlock block)
            {
                base.SetProperty(name, property, block);

                if (poolParent == null)
                {
                    poolParent = block.floatPropPool;
                }

                var slider = control as IMyTerminalControlSlider;

                SliderWriter = slider?.Writer;

                Flags = BlockPropertyFlags.None;

                if (isBuildAndRepair)
                {
                    MinValue  = -1000f;
                    MaxValue  = 1000f;
                    Increment = 1f;
                    Flags    |= BlockPropertyFlags.CanUseMultipliers;
                }
                else
                {
                    MinValue  = property.GetMinimum(block.TBlock);
                    MaxValue  = property.GetMaximum(block.TBlock);
                    Increment = GetIncrement();
                }

                if (block.SubtypeId.UsesSubtype(TBlockSubtypes.Thruster) && PropName == "Override")
                {
                    GetScaleFunc = GetThrustEffectFunc;
                }
                else
                {
                    GetScaleFunc = GetDefaultScaleFunc;
                }

                if (property.Id == "Velocity")
                {
                    if (block.SubtypeId.UsesSubtype(TBlockSubtypes.Rotor))
                    {
                        GetStatusFunc = GetRotorAngleFunc;
                    }
                    else if (block.SubtypeId.UsesSubtype(TBlockSubtypes.Piston))
                    {
                        GetStatusFunc = GetPistonExtensionFunc;
                    }
                }

                if (property.Id == "X" || property.Id == "Y" || property.Id == "Z" || property.Id.StartsWith("Rot"))
                {
                    Flags |= BlockPropertyFlags.IsIntegral;
                }
            }
            public static FloatProperty GetProperty(StringBuilder name, ITerminalProperty <float> property, PropertyBlock block)
            {
                FloatProperty prop = block.floatPropPool.Get();

                prop.SetProperty(name, property, block);

                return(prop);
            }
            public static ComboBoxProperty GetProperty(StringBuilder name, IMyTerminalControlCombobox comboBox, List <MyTerminalControlComboBoxItem> comboItems, PropertyBlock block)
            {
                ComboBoxProperty prop = block.comboPropPool.Get();

                prop.SetProperty(name, comboBox, block);
                prop.SetComboItems(comboItems);

                return(prop);
            }