public void CreateControllerElements(IMyTerminalBlock block)
        {
            try
            {
                if (DsControl)
                {
                    return;
                }
                var comp = block?.GameLogic?.GetAs <DefenseShields>();
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep0");
                ToggleShield = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_ToggleShield", Localization.GetText("TerminalToggleShieldTitle"), Localization.GetText("TerminalToggleShieldTooltip"), Localization.GetText("TerminalSwitchUp"), Localization.GetText("TerminalSwitchDown"), DsUi.GetRaiseShield, DsUi.SetRaiseShield);
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep1");
                //ChargeSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_ChargeRate", "Shield Charge Rate", "Percentage Of Power The Shield May Consume", DsUi.GetRate, DsUi.SetRate);
                //ChargeSlider.SetLimits(20, 95);
                PowerScaleSelect = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_PowerScale", Localization.GetText("TerminalPowerScaleSelectTitle"), Localization.GetText("TerminalPowerScaleSelectTooltip"), DsUi.GetPowerScale, DsUi.SetPowerScale, DsUi.ListPowerScale);

                PowerWatts = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_PowerWatts", Localization.GetText("TerminalPowerWattsTitle"), Localization.GetText("TerminalPowerWattsTooltip"), DsUi.GetPowerWatts, DsUi.SetPowerWatts, DsUi.EnablePowerWatts);
                PowerWatts.SetLimits(1, 999);
                if (comp != null && comp.GridIsMobile)
                {
                    TerminalHelpers.Separator(comp.Shield, "DS-C_sep2");
                }

                Fit = TerminalHelpers.AddSlider(comp?.Shield, "DS-CFit", Localization.GetText("TerminalFitTitle"), Localization.GetText("TerminalFitTooltip"), DsUi.GetFit, DsUi.SetFit);
                Fit.SetLimits(0, 22);

                SphereFit     = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_SphereFit", Localization.GetText("TerminalSphereFitTitle"), Localization.GetText("TerminalSphereFitTooltip"), DsUi.GetSphereFit, DsUi.SetSphereFit);
                FortifyShield = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_ShieldFortify", Localization.GetText("TerminalFortifyShieldTitle"), Localization.GetText("TerminalFortifyShieldTooltip"), DsUi.GetFortify, DsUi.SetFortify);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep3");

                WidthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_WidthSlider", Localization.GetText("TerminalWidthSliderTitle"), Localization.GetText("TerminalWidthSliderTooltip"), DsUi.GetWidth, DsUi.SetWidth);
                WidthSlider.SetLimits(30, 1000);

                HeightSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_HeightSlider", Localization.GetText("TerminalHeightSliderTitle"), Localization.GetText("TerminalHeightSliderTooltip"), DsUi.GetHeight, DsUi.SetHeight);
                HeightSlider.SetLimits(30, 1000);

                DepthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_DepthSlider", Localization.GetText("TerminalDepthSliderTitle"), Localization.GetText("TerminalDepthSliderTooltip"), DsUi.GetDepth, DsUi.SetDepth);
                DepthSlider.SetLimits(30, 1000);

                OffsetWidthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetWidthSlider", Localization.GetText("TerminalOffsetWidthSliderTitle"), Localization.GetText("TerminalOffsetWidthSliderTooltip"), DsUi.GetOffsetWidth, DsUi.SetOffsetWidth);
                OffsetWidthSlider.SetLimits(-69, 69);

                OffsetHeightSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetHeightSlider", Localization.GetText("TerminalOffsetHeightSliderTitle"), Localization.GetText("TerminalOffsetHeightSliderTooltip"), DsUi.GetOffsetHeight, DsUi.SetOffsetHeight);
                OffsetHeightSlider.SetLimits(-69, 69);

                OffsetDepthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetDepthSlider", Localization.GetText("TerminalOffsetDepthSliderTitle"), Localization.GetText("TerminalOffsetDepthSliderTooltip"), DsUi.GetOffsetDepth, DsUi.SetOffsetDepth);
                OffsetDepthSlider.SetLimits(-69, 69);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep4");

                BatteryBoostCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_UseBatteries", Localization.GetText("TerminalBatteryBoostCheckBoxTitle"), Localization.GetText("TerminalBatteryBoostCheckBoxTooltip"), DsUi.GetBatteries, DsUi.SetBatteries);
                SendToHudCheckBox    = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HideIcon", Localization.GetText("TerminalSendToHudCheckBoxTitle"), Localization.GetText("TerminalSendToHudCheckBoxTooltip"), DsUi.GetSendToHud, DsUi.SetSendToHud);
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep5");
                ShellSelect = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_ShellSelect", Localization.GetText("TerminalShellSelectTitle"), Localization.GetText("TerminalShellSelectTooltip"), DsUi.GetShell, DsUi.SetShell, DsUi.ListShell);

                ShellVisibility = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_ShellSelect", Localization.GetText("TerminalShellVisibilityTitle"), Localization.GetText("TerminalShellVisibilityTooltip"), DsUi.GetVisible, DsUi.SetVisible, DsUi.ListVisible);

                HideActiveCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HideActive", Localization.GetText("TerminalHideActiveCheckBoxTitle"), Localization.GetText("TerminalHideActiveCheckBoxTooltip"), DsUi.GetHideActive, DsUi.SetHideActive);

                //RefreshAnimationCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_RefreshAnimation", "Show Refresh Animation  ", "Show Random Refresh Animation", DsUi.GetRefreshAnimation, DsUi.SetRefreshAnimation);
                //HitWaveAnimationCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HitWaveAnimation", "Show Hit Wave Animation", "Show Wave Effect On Shield Damage", DsUi.GetHitWaveAnimation, DsUi.SetHitWaveAnimation);
                NoWarningSoundsCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_NoWarningSounds", Localization.GetText("TerminalNoWarningSoundsCheckBoxTitle"), Localization.GetText("TerminalNoWarningSoundsCheckBoxTooltip"), DsUi.GetNoWarningSounds, DsUi.SetNoWarningSounds);
                DimShieldHitsCheckBox   = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_DimShieldHits", Localization.GetText("TerminalDimShieldHitsCheckBoxTitle"), Localization.GetText("TerminalDimShieldHitsCheckBoxTooltip"), DsUi.GetDimShieldHits, DsUi.SetDimShieldHits);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep6");
                SideShunting = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_SideRedirect", Localization.GetText("TerminalSideShuntingTitle"), Localization.GetText("TerminalSideShuntingTooltip"), DsUi.GetSideShunting, DsUi.SetSideShunting);
                ShowShunting = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_ShowRedirect", Localization.GetText("TerminalShowShuntingTitle"), Localization.GetText("TerminalShowShuntingTooltip"), DsUi.GetShowShunting, DsUi.SetShowShunting);

                TopShield    = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_TopShield", Localization.GetText("TerminalTopShieldTitle"), Localization.GetText("TerminalTopShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GeTopShield, DsUi.SetTopShield, DsUi.RedirectEnabled);
                BottomShield = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_BottomShield", Localization.GetText("TerminalBottomShieldTitle"), Localization.GetText("TerminalBottomShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GetBottomShield, DsUi.SetBottomShield, DsUi.RedirectEnabled);
                LeftShield   = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_LeftShield", Localization.GetText("TerminalLeftShieldTitle"), Localization.GetText("TerminalLeftShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GetLeftShield, DsUi.SetLeftShield, DsUi.RedirectEnabled);
                RightShield  = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_RightShield", Localization.GetText("TerminalRightShieldTitle"), Localization.GetText("TerminalRightShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GetRightShield, DsUi.SetRightShield, DsUi.RedirectEnabled);
                FrontShield  = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_FrontShield", Localization.GetText("TerminalFrontShieldTitle"), Localization.GetText("TerminalFrontShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GetFrontShield, DsUi.SetFrontShield, DsUi.RedirectEnabled);
                BackShield   = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_BackShield", Localization.GetText("TerminalBackShieldTitle"), Localization.GetText("TerminalBackShieldTooltip"), Localization.GetText("TerminalSwitchPush"), Localization.GetText("TerminalSwitchPull"), DsUi.GetBackShield, DsUi.SetBackShield, DsUi.RedirectEnabled);


                CreateAction <IMyUpgradeModule>(ToggleShield);

                CreateAction <IMyUpgradeModule>(SphereFit);
                CreateFitAction <IMyUpgradeModule>(Fit);
                CreateAction <IMyUpgradeModule>(FortifyShield);


                CreateAction <IMyUpgradeModule>(HideActiveCheckBox);
                //CreateAction<IMyUpgradeModule>(RefreshAnimationCheckBox);
                //CreateAction<IMyUpgradeModule>(HitWaveAnimationCheckBox);
                CreateAction <IMyUpgradeModule>(SendToHudCheckBox);
                CreateAction <IMyUpgradeModule>(BatteryBoostCheckBox);
                CreateDepthAction <IMyUpgradeModule>(DepthSlider);
                CreateWidthAction <IMyUpgradeModule>(WidthSlider);
                CreateHeightAction <IMyUpgradeModule>(HeightSlider);

                CreateShuntAction <IMyUpgradeModule>(TopShield);
                CreateShuntAction <IMyUpgradeModule>(BottomShield);
                CreateShuntAction <IMyUpgradeModule>(LeftShield);
                CreateShuntAction <IMyUpgradeModule>(RightShield);
                CreateShuntAction <IMyUpgradeModule>(FrontShield);
                CreateShuntAction <IMyUpgradeModule>(BackShield);

                CreateAction <IMyUpgradeModule>(SideShunting);

                DsControl = true;
            }
            catch (Exception ex) { Log.Line($"Exception in CreateControlerUi: {ex}"); }
        }
Beispiel #2
0
        public void CreateControllerElements(IMyTerminalBlock block)
        {
            try
            {
                if (DsControl)
                {
                    return;
                }
                var comp = block?.GameLogic?.GetAs <DefenseShields>();
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep0");
                ToggleShield = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_ToggleShield", "Shield Status", "Raise or Lower Shields", "Up", "Down", DsUi.GetRaiseShield, DsUi.SetRaiseShield);
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep1");
                //ChargeSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_ChargeRate", "Shield Charge Rate", "Percentage Of Power The Shield May Consume", DsUi.GetRate, DsUi.SetRate);
                //ChargeSlider.SetLimits(20, 95);
                PowerScaleSelect = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_PowerScale", "Select Power Scale", "Select the power scale to use", DsUi.GetPowerScale, DsUi.SetPowerScale, DsUi.ListPowerScale);

                PowerWatts = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_PowerWatts", "Power To Use", "Select the maximum scaled power the shield can use", DsUi.GetPowerWatts, DsUi.SetPowerWatts, DsUi.EnablePowerWatts);
                PowerWatts.SetLimits(1, 999);
                if (comp != null && comp.GridIsMobile)
                {
                    TerminalHelpers.Separator(comp.Shield, "DS-C_sep2");
                }

                Fit = TerminalHelpers.AddSlider(comp?.Shield, "DS-CFit", "Shield Fit", "Shield Fit", DsUi.GetFit, DsUi.SetFit);
                Fit.SetLimits(0, 29);

                SphereFit     = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_SphereFit", "Sphere Shield", "Sphere Shield", DsUi.GetSphereFit, DsUi.SetSphereFit);
                FortifyShield = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_ShieldFortify", "Fortify Shield ", "Fortify Shield ", DsUi.GetFortify, DsUi.SetFortify);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep3");

                WidthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_WidthSlider", "Shield Size Width", "Shield Size Width", DsUi.GetWidth, DsUi.SetWidth);
                WidthSlider.SetLimits(30, 1000);

                HeightSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_HeightSlider", "Shield Size Height", "Shield Size Height", DsUi.GetHeight, DsUi.SetHeight);
                HeightSlider.SetLimits(30, 1000);

                DepthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_DepthSlider", "Shield Size Depth", "Shield Size Depth", DsUi.GetDepth, DsUi.SetDepth);
                DepthSlider.SetLimits(30, 1000);

                OffsetWidthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetWidthSlider", "Width Offset", "Width Offset", DsUi.GetOffsetWidth, DsUi.SetOffsetWidth);
                OffsetWidthSlider.SetLimits(-69, 69);

                OffsetHeightSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetHeightSlider", "Height Offset", "Height Offset", DsUi.GetOffsetHeight, DsUi.SetOffsetHeight);
                OffsetHeightSlider.SetLimits(-69, 69);

                OffsetDepthSlider = TerminalHelpers.AddSlider(comp?.Shield, "DS-C_OffsetDepthSlider", "Depth Offset", "Depth Offset", DsUi.GetOffsetDepth, DsUi.SetOffsetDepth);
                OffsetDepthSlider.SetLimits(-69, 69);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep4");

                BatteryBoostCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_UseBatteries", "Ignore battery input power ", "Allow shields to fight with batteries for power", DsUi.GetBatteries, DsUi.SetBatteries);
                SendToHudCheckBox    = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HideIcon", "Broadcast Shield Status To Hud", "Broadcast Shield Status To Nearby Friendly Huds", DsUi.GetSendToHud, DsUi.SetSendToHud);
                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep5");
                ShellSelect = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_ShellSelect", "Select Shield Look", "Select shield's shell texture", DsUi.GetShell, DsUi.SetShell, DsUi.ListShell);

                ShellVisibility = TerminalHelpers.AddCombobox(comp?.Shield, "DS-C_ShellSelect", "Select Shield Visibility", "Determines when the shield is visible", DsUi.GetVisible, DsUi.SetVisible, DsUi.ListVisible);

                HideActiveCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HideActive", "Hide Shield Health On Hit  ", "Hide Shield Health Grid On Hit", DsUi.GetHideActive, DsUi.SetHideActive);

                //RefreshAnimationCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_RefreshAnimation", "Show Refresh Animation  ", "Show Random Refresh Animation", DsUi.GetRefreshAnimation, DsUi.SetRefreshAnimation);
                //HitWaveAnimationCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_HitWaveAnimation", "Show Hit Wave Animation", "Show Wave Effect On Shield Damage", DsUi.GetHitWaveAnimation, DsUi.SetHitWaveAnimation);
                NoWarningSoundsCheckBox = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_NoWarningSounds", "Disable audio warnings    ", "Supress shield audio warnings", DsUi.GetNoWarningSounds, DsUi.SetNoWarningSounds);
                DimShieldHitsCheckBox   = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_DimShieldHits", "Dim Incoming Hit Effects ", "Supress brightness of incoming hit effects", DsUi.GetDimShieldHits, DsUi.SetDimShieldHits);

                TerminalHelpers.Separator(comp?.Shield, "DS-C_sep6");
                SideShunting = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_SideRedirect", "Shunt Shields", "Enable Shield Shunting", DsUi.GetSideShunting, DsUi.SetSideShunting);
                ShowShunting = TerminalHelpers.AddCheckbox(comp?.Shield, "DS-C_ShowRedirect", "Show Shunted Shields", "Enable/Disable showing side shield states", DsUi.GetShowShunting, DsUi.SetShowShunting);

                TopShield    = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_TopShield", "Shunt Top Shield", "Redirect Top shield power to others", "Push", "Pull", DsUi.GeTopShield, DsUi.SetTopShield, DsUi.RedirectEnabled);
                BottomShield = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_BottomShield", "Shunt Bottom Shield", "Redirect bottom shield power to others", "Push", "Pull", DsUi.GetBottomShield, DsUi.SetBottomShield, DsUi.RedirectEnabled);
                LeftShield   = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_LeftShield", "Shunt Left Shield", "Redirect Left shield power to others", "Push", "Pull", DsUi.GetLeftShield, DsUi.SetLeftShield, DsUi.RedirectEnabled);
                RightShield  = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_RightShield", "Shunt Right Shield", "Redirect Right shield power to others", "Push", "Pull", DsUi.GetRightShield, DsUi.SetRightShield, DsUi.RedirectEnabled);
                FrontShield  = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_FrontShield", "Shunt Front Shield", "Redirect Front shield power to others", "Push", "Pull", DsUi.GetFrontShield, DsUi.SetFrontShield, DsUi.RedirectEnabled);
                BackShield   = TerminalHelpers.AddOnOff(comp?.Shield, "DS-C_BackShield", "Shunt Back Shield", "Redirect Back shield power to others", "Push", "Pull", DsUi.GetBackShield, DsUi.SetBackShield, DsUi.RedirectEnabled);


                CreateAction <IMyUpgradeModule>(ToggleShield);

                CreateAction <IMyUpgradeModule>(SphereFit);
                CreateFitAction <IMyUpgradeModule>(Fit);
                CreateAction <IMyUpgradeModule>(FortifyShield);


                CreateAction <IMyUpgradeModule>(HideActiveCheckBox);
                //CreateAction<IMyUpgradeModule>(RefreshAnimationCheckBox);
                //CreateAction<IMyUpgradeModule>(HitWaveAnimationCheckBox);
                CreateAction <IMyUpgradeModule>(SendToHudCheckBox);
                CreateAction <IMyUpgradeModule>(BatteryBoostCheckBox);
                CreateDepthAction <IMyUpgradeModule>(DepthSlider);
                CreateWidthAction <IMyUpgradeModule>(WidthSlider);
                CreateHeightAction <IMyUpgradeModule>(HeightSlider);

                CreateShuntAction <IMyUpgradeModule>(TopShield);
                CreateShuntAction <IMyUpgradeModule>(BottomShield);
                CreateShuntAction <IMyUpgradeModule>(LeftShield);
                CreateShuntAction <IMyUpgradeModule>(RightShield);
                CreateShuntAction <IMyUpgradeModule>(FrontShield);
                CreateShuntAction <IMyUpgradeModule>(BackShield);

                CreateAction <IMyUpgradeModule>(SideShunting);

                DsControl = true;
            }
            catch (Exception ex) { Log.Line($"Exception in CreateControlerUi: {ex}"); }
        }