Ejemplo n.º 1
0
        internal static IMyTerminalControlCheckbox AddCheckbox <T>(Session session, int id, string name, string title, string tooltip, Func <IMyTerminalBlock, bool> getter, Action <IMyTerminalBlock, bool> setter, bool allowGroup, Func <IMyTerminalBlock, bool> visibleGetter = null) where T : IMyTerminalBlock
        {
            var c = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, T>("WC_" + name);

            c.Title   = MyStringId.GetOrCompute(title);
            c.Tooltip = MyStringId.GetOrCompute(tooltip);
            c.Getter  = getter;
            c.Setter  = setter;
            c.Visible = visibleGetter;
            c.Enabled = Istrue;

            MyAPIGateway.TerminalControls.AddControl <T>(c);
            session.CustomControls.Add(c);

            CreateCustomActions <T> .CreateOnOffActionSet(session, c, name, id, visibleGetter, allowGroup);

            return(c);
        }
Ejemplo n.º 2
0
        internal static IMyTerminalControlOnOffSwitch AddWeaponOnOff <T>(Session session, int id, string name, string title, string tooltip, string onText, string offText, Func <IMyTerminalBlock, int, bool> getter, Action <IMyTerminalBlock, bool> setter, Func <IMyTerminalBlock, bool> visibleGetter) where T : IMyTerminalBlock
        {
            var c = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, T>($"WC_{id}_Enable");

            c.Title   = MyStringId.GetOrCompute(title);
            c.Tooltip = MyStringId.GetOrCompute(tooltip);
            c.OnText  = MyStringId.GetOrCompute(onText);
            c.OffText = MyStringId.GetOrCompute(offText);
            c.Enabled = Istrue;
            c.Visible = visibleGetter;
            c.Getter  = Istrue;
            c.Setter  = setter;
            MyAPIGateway.TerminalControls.AddControl <T>(c);
            session.CustomControls.Add(c);

            CreateCustomActions <T> .CreateOnOffActionSet(session, c, name, id, visibleGetter, false);

            return(c);
        }