Ejemplo n.º 1
0
 internal override void OnGUIOnceOnly()
 {
     Styles.InitStyles();
     Styles.InitSkins();
     SkinsLibrary.SetCurrent("SolarizedDark");
     SkinsLibrary.CurrentSkin.label.wordWrap = false;
 }
Ejemplo n.º 2
0
        internal override void OnGUIOnceOnly()
        {
            //Lets get some skins together
            GUISkin skinCustom = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.Unity);

            skinCustom.button = SkinsLibrary.DefKSPSkin.button;
            SkinsLibrary.AddSkin("CustomSkin", skinCustom);

            GUIStyle redButton = new GUIStyle(SkinsLibrary.DefKSPSkin.button);

            redButton.name             = "RedButton";
            redButton.normal.textColor = Color.red;
            redButton.hover.textColor  = Color.red;
            SkinsLibrary.AddStyle(SkinsLibrary.DefSkinType.KSP, redButton);
            SkinsLibrary.AddStyle("CustomSkin", redButton);

            redButton                  = new GUIStyle(SkinsLibrary.DefUnitySkin.button);
            redButton.name             = "RedButton";
            redButton.normal.textColor = Color.red;
            redButton.hover.textColor  = Color.red;
            SkinsLibrary.AddStyle(SkinsLibrary.DefSkinType.Unity, redButton);

            GUIStyle CustomTooltip = new GUIStyle();

            CustomTooltip.name             = "Tooltip";
            CustomTooltip.normal.textColor = Color.yellow;
            SkinsLibrary.AddStyle("CustomSkin", CustomTooltip);
        }
Ejemplo n.º 3
0
 internal override void OnGUIOnceOnly()
 {
     Log("Initializing GUI styles and skins");
     Styles.InitStyles();
     Styles.InitSkins();
     SkinsLibrary.SetCurrent("SolarizedDark");
     SkinsLibrary.CurrentSkin.label.wordWrap = true;
 }
Ejemplo n.º 4
0
        internal override void DrawWindow(int id)
        {
            base.DrawWindow(id);

            GameConfig config = scenarioModule.GetGameConfig();

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("KeepFit v" + Statics.GetDllVersion(this) + " : " + (config.enabled ? "Enabled" : "Disabled"));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button((config.enabled ? "Disable" : "Enable"), GUILayout.Width(80)))
            {
                config.enabled = !config.enabled;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Choose a Skin");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("KSP Style", "Sets the style to be the default KSPStyle")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.KSP);
            }
            if (GUILayout.Button(new GUIContent("Unity Style", "Sets the style to be the default Unity Style")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.Unity);
            }
            GUILayout.EndHorizontal();

            config.wimpMode            = GUILayout.Toggle(config.wimpMode, "WimpMode: ", GUILayout.Width(80));
            config.useBestPartOnVessel = GUILayout.Toggle(config.useBestPartOnVessel, "Use Best Overall Part On Vessel: ", GUILayout.Width(80));
            if (scenarioModule.GetCLS() != null)
            {
                config.applyCLSLimitsIfAvailable = GUILayout.Toggle(config.applyCLSLimitsIfAvailable, "Apply CLS limits: ", GUILayout.Width(80));
            }

            showFloatEditor("Min Gee For Exercising when Landed", ref wipMinimumLandedGeeForExcercising, ref config.minimumLandedGeeForExcercising, ref config, true);
            showFloatEditor("Initial fitness level", ref wipInitialFitnessLevel, ref config.initialFitnessLevel, ref config, true);
            showFloatEditor("Min fitness level", ref wipMinFitnessLevel, ref config.minFitnessLevel, ref config, true);
            showFloatEditor("Max fitness level", ref wipMaxFitnessLevel, ref config.maxFitnessLevel, ref config, true);


            foreach (Period period in Enum.GetValues(typeof(Period)))
            {
                GeeToleranceConfig geeToleranceConfig = config.GetGeeTolerance(period);
                WipValuePair       wipValuePair       = wipGeeTolerances[period];
                showFloatPairEditor("Tolerance (" + period + ")", "Warn", "Fatal", ref wipValuePair, ref geeToleranceConfig.warn, ref geeToleranceConfig.fatal, ref config);
            }

            GUILayout.EndVertical();
        }
Ejemplo n.º 5
0
        internal override void OnGUIOnceOnly()
        {
            //Get the textures we need into Textures
            Resources.LoadTextures();

            //Set up the Styles
            Styles.InitStyles();

            //Set up the Skins
            Styles.InitSkins();

            //Set the current Skin
            SkinsLibrary.SetCurrent(settings.SelectedSkin.ToString());
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Unity: OnGUI is called for rendering and handling GUI events.
    ///
    /// Trigger: This is called multiple times per frame to lay stuff out etc.
    ///          Code here ignores the F2 key that disables user interface. So if you are making something to be user hidable then use the RenderingManager.PostDrawQueue functions in here
    ///          Alternatively you could use the MonoBehaviourWindow Type and its DrawWindow Function
    /// </summary>
    private void OnGUI()
    {
        if (!_OnGUIOnceOnlyHasRun)
        {
            //set theflag so this only runs once
            _OnGUIOnceOnlyHasRun = true;
            //set up the skins library
            if (!SkinsLibrary._Initialized)
            {
                SkinsLibrary.InitSkinList();
            }

            //then pass it on to the downstream derivatives
            OnGUIOnceOnly();
        }

        OnGUIEvery();
    }
Ejemplo n.º 7
0
        internal override void DrawWindow(int id)
        {
            GUILayout.Label("Choose a Skin");

            if (GUILayout.Button(new GUIContent("KSP Style", "Sets the style to be the default KSPStyle")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.KSP);
            }
            if (GUILayout.Button(new GUIContent("Unity Style", "Sets the style to be the default Unity Style")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.Unity);
            }
            if (GUILayout.Button(new GUIContent("Custom Style", "Sets the style to be a custom style I just made up")))
            {
                SkinsLibrary.SetCurrent("CustomSkin");
            }

            GUILayout.Space(20);
            if (GUILayout.Button("Open New Window"))
            {
                SkinsWindow winTemp = gameObject.AddComponent <SkinsWindow>();
                skinsWindows.Add(winTemp);
            }
            if (GUILayout.Button("Destroy a Window"))
            {
                if (skinsWindows.Count > 0)
                {
                    skinsWindows[0].Visible = false;
                    skinsWindows[0]         = null;
                    skinsWindows.RemoveAt(0);
                }
            }
            if (GUILayout.Button("Toggle Drag for all TestWindows"))
            {
                foreach (SkinsWindow sw in skinsWindows)
                {
                    sw.DragEnabled = !sw.DragEnabled;
                }
            }

            GUILayout.Label("Tooltipwidth. 0 means nowrap");
            TooltipMaxWidth = Convert.ToInt32(GUILayout.TextField(TooltipMaxWidth.ToString()));
        }
Ejemplo n.º 8
0
 internal override void OnGUIOnceOnly()
 {
     Styles.InitStyles();
     Styles.InitSkins();
     SkinsLibrary.SetCurrent("SolarizedDark");
 }
Ejemplo n.º 9
0
        protected override void OnGUI_FirstRun()
        {
            GUISkin skinCustom = SkinsLibrary.CopySkin("Unity");

            skinCustom.button = SkinsLibrary.DefKSPSkin.button;
            SkinsLibrary.AddSkin("CustomSkin", skinCustom);

            GUIStyle redButton = new GUIStyle(SkinsLibrary.DefKSPSkin.button);

            redButton.name             = "RedButton";
            redButton.normal.textColor = Color.red;
            redButton.hover.textColor  = Color.red;

            SkinsLibrary.AddStyle(redButton, "KSP");
            SkinsLibrary.AddStyle(redButton, "CustomSkin");

            redButton                  = new GUIStyle(SkinsLibrary.DefUnitySkin.button);
            redButton.name             = "RedButton";
            redButton.normal.textColor = Color.red;
            redButton.hover.textColor  = Color.red;
            //SkinsLibrary.AddStyle(redButton, SkinsLibrary.DefSkinType.Unity);
            SkinsLibrary.AddStyle(redButton, "Unity");

            GUIStyle CustomTooltip = new GUIStyle();

            CustomTooltip.name             = "Tooltip";
            CustomTooltip.normal.textColor = Color.yellow;
            SkinsLibrary.AddStyle(CustomTooltip, "CustomSkin");


            // let's try to manually fix VSlider and HScrollbar in KSP's skin
            var vs           = SkinsLibrary.DefKSPSkin.verticalSlider;
            var vst          = SkinsLibrary.DefKSPSkin.verticalSliderThumb;
            var hSlider      = SkinsLibrary.DefKSPSkin.horizontalSlider;
            var hSliderThumb = SkinsLibrary.DefKSPSkin.horizontalSliderThumb;

            vs.normal   = hSlider.normal;
            vs.border   = hSlider.border;
            vs.padding  = hSlider.padding;
            vs.margin   = hSlider.margin;
            vs.overflow = hSlider.overflow;

            vst.active        = hSliderThumb.active;
            vst.normal        = hSliderThumb.normal;
            vst.hover         = hSliderThumb.hover;
            vst.border        = hSliderThumb.border;
            vst.padding       = hSliderThumb.padding;
            vst.margin        = hSliderThumb.margin;
            vst.overflow      = hSliderThumb.overflow;
            vst.fixedWidth    = 12;
            vst.stretchWidth  = false;
            vst.fixedHeight   = 28.1975f;
            vst.stretchHeight = true;

            var hsb  = SkinsLibrary.DefKSPSkin.horizontalScrollbar;
            var hsbt = SkinsLibrary.DefKSPSkin.horizontalScrollbarThumb;

            hsb.normal   = hSlider.normal;
            hsb.border   = hSlider.border;
            hsb.padding  = hSlider.padding;
            hsb.margin   = hSlider.margin;
            hsb.overflow = hSlider.overflow;

            hsbt.active        = hSliderThumb.active;
            hsbt.normal        = hSliderThumb.normal;
            hsbt.hover         = hSliderThumb.hover;
            hsbt.border        = hSliderThumb.border;
            hsbt.padding       = hSliderThumb.padding;
            hsbt.margin        = hSliderThumb.margin;
            hsbt.overflow      = hSliderThumb.overflow;
            hsbt.fixedWidth    = 28.1975f;
            hsbt.stretchWidth  = true;
            hsbt.fixedHeight   = 12;
            hsbt.stretchHeight = false;

            var vsb  = SkinsLibrary.DefKSPSkin.verticalScrollbar;
            var vsbt = SkinsLibrary.DefKSPSkin.verticalScrollbarThumb;

            vsb.normal   = hSlider.normal;
            vsb.border   = hSlider.border;
            vsb.padding  = hSlider.padding;
            vsb.margin   = hSlider.margin;
            vsb.overflow = hSlider.overflow;

            vsbt.active        = hSliderThumb.active;
            vsbt.normal        = hSliderThumb.normal;
            vsbt.hover         = hSliderThumb.hover;
            vsbt.border        = hSliderThumb.border;
            vsbt.padding       = hSliderThumb.padding;
            vsbt.margin        = hSliderThumb.margin;
            vsbt.overflow      = hSliderThumb.overflow;
            vsbt.fixedWidth    = 12;
            vsbt.stretchWidth  = false;
            vsbt.fixedHeight   = 28.1975f;
            vsbt.stretchHeight = true;
        }
Ejemplo n.º 10
0
        protected override void DrawWindow(int id)
        {
            GUILayout.Label("Choose a Skin");
            if (GUILayout.Button(textWithTT("KSP Style", "Sets the style to be the default KSPStyle.")))
            {
                SkinsLibrary.SetCurrent("KSP");
            }
            if (GUILayout.Button(textWithTT("Unity Style", "Sets the style to be the default Unity Style.")))
            {
                SkinsLibrary.SetCurrent("Unity");
            }
            if (GUILayout.Button(textWithTT("Custom Style", "Sets the style to be a custom style I just made up.")))
            {
                SkinsLibrary.SetCurrent("CustomSkin");
            }


            GUILayout.Space(20);
            if (GUILayout.Button(textWithTT("Open Skins Window", "Opens a window at a random location.")))
            {
                SkinsWindow winTemp = gameObject.AddComponent <SkinsWindow> ();
                skinsWindows.Add(winTemp);
            }
            if (GUILayout.Button(textWithTT("Destroy Skins Window", "Close a window (picks oldest first?).")))
            {
                if (skinsWindows.Count > 0)
                {
                    skinsWindows [0].Visible = false;
                    skinsWindows [0]         = null;
                    skinsWindows.RemoveAt(0);
                }
            }
            if (GUILayout.Button(textWithTT("Open Timer Window", "Opens a window at a random location.")))
            {
                LooperWindow winTemp = gameObject.AddComponent <LooperWindow> ();
                looperWindows.Add(winTemp);
            }
            if (GUILayout.Button(textWithTT("Destroy Timer Window", "Destroy one of the Timer Windows")))
            {
                if (looperWindows.Count > 0)
                {
                    looperWindows [0].Visible = false;
                    looperWindows [0]         = null;
                    looperWindows.RemoveAt(0);
                }
            }

            if (GUILayout.Button(textWithTT("Open Icons Window", "Opens a window at a random location.")))
            {
                IconWindow winTemp = gameObject.AddComponent <IconWindow> ();
                iconWindows.Add(winTemp);
            }
            if (GUILayout.Button(textWithTT("Destroy Icons Window", "Destroy one of the Icon Windows")))
            {
                if (iconWindows.Count > 0)
                {
                    iconWindows [0].Visible = false;
                    iconWindows [0]         = null;
                    iconWindows.RemoveAt(0);
                }
            }

            if (GUILayout.Button(textWithTT("Toggle Drag for all Windows", "Except this window, evidently.")))
            {
                foreach (SkinsWindow sw in skinsWindows)
                {
                    sw.DragEnabled = !sw.DragEnabled;
                }
                foreach (LooperWindow lw in looperWindows)
                {
                    lw.DragEnabled = !lw.DragEnabled;
                }
                foreach (IconWindow iw in iconWindows)
                {
                    iw.DragEnabled = !iw.DragEnabled;
                }
            }
            if (GUILayout.Button(textWithTT("Toggle Resize for all Windows", "This allows you to resize the window down to a minimum size and up to a maximum size.")))
            {
                foreach (SkinsWindow sw in skinsWindows)
                {
                    sw.ResizeEnabled = !sw.ResizeEnabled;
                }
                foreach (LooperWindow lw in looperWindows)
                {
                    lw.ResizeEnabled = !lw.ResizeEnabled;
                }
                foreach (IconWindow iw in iconWindows)
                {
                    iw.ResizeEnabled = !iw.ResizeEnabled;
                }
            }
            if (GUILayout.Button(textWithTT("Toggle Clamping for \" \" ", "Clamping prevents windows from going off of the screen.")))
            {
                foreach (SkinsWindow sw in skinsWindows)
                {
                    sw.ClampEnabled = !sw.ClampEnabled;
                }
                foreach (LooperWindow lw in looperWindows)
                {
                    lw.ClampEnabled = !lw.ClampEnabled;
                }
                foreach (IconWindow iw in iconWindows)
                {
                    iw.ClampEnabled = !iw.ClampEnabled;
                }
            }
            if (GUILayout.Button(textWithTT("Toggle Tooltips for \" \" ", "Tooltips are hovering help boxes which appear on mouseover.")))
            {
                foreach (SkinsWindow sw in skinsWindows)
                {
                    sw.TooltipsEnabled = !sw.TooltipsEnabled;
                }
                foreach (LooperWindow lw in looperWindows)
                {
                    lw.TooltipsEnabled = !lw.TooltipsEnabled;
                }
                foreach (IconWindow iw in iconWindows)
                {
                    iw.TooltipsEnabled = !iw.TooltipsEnabled;
                }
            }

            GUILayout.Label("Tooltipwidth. 0 means nowrap");
            var a = GUILayout.TextField(TooltipMaxWidth.ToString());

            TooltipMaxWidth = Convert.ToInt32(a);
        }
 void ddlSettingsSkin_SelectionChanged(DropDownList sender, int OldIndex, int NewIndex)
 {
     settings.SelectedSkin = (Settings.DisplaySkin)NewIndex;
     SkinsLibrary.SetCurrent(settings.SelectedSkin.ToString());
     settings.Save();
 }
Ejemplo n.º 12
0
 internal override void OnGUIOnceOnly()
 {
     Styles.InitStyles();
     Styles.InitSkins();
     SkinsLibrary.SetCurrent("TestFlightEditor");
 }
        /// <summary>
        /// This one creates the skins, adds em to the skins library and adds needed styles
        /// </summary>
        internal static void InitSkins()
        {
            //Default Skin
            GUISkin DefKSP = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.KSP);

            DefKSP.window = stylePanel;
            DefKSP.font   = SkinsLibrary.DefUnitySkin.font;
            DefKSP.horizontalSlider.margin.top = 8;
            SkinsLibrary.AddSkin("Default", DefKSP);

            //Adjust Default Skins
            SkinsLibrary.List["Default"].button = new GUIStyle(styleButton);
            SkinsLibrary.List["Default"].label  = new GUIStyle(styleText);

            //Add Styles once skin is added
            SkinsLibrary.AddStyle("Default", styleTooltipStyle);
            SkinsLibrary.AddStyle("Default", styleButton);
            SkinsLibrary.AddStyle("Default", styleButtonMain);
            SkinsLibrary.AddStyle("Default", styleButtonSettings);
            SkinsLibrary.AddStyle("Default", styleButtonToggle);
            SkinsLibrary.AddStyle("Default", "DropDownButton", styleDropDownButton);
            SkinsLibrary.AddStyle("Default", "DropDownListBox", styleDropDownListBox);
            SkinsLibrary.AddStyle("Default", "DropDownListItem", styleDropDownListItem);

            //Now a Unity Style one
            GUISkin DefUnity = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.Unity);

            DefUnity.window         = DefUnity.box;
            DefUnity.window.border  = new RectOffset(6, 6, 6, 6);
            DefUnity.window.padding = new RectOffset(8, 3, 7, 0);
            DefUnity.horizontalSlider.margin.top = 8;
            SkinsLibrary.AddSkin("Unity", DefUnity);

            //Adjust Default Skins
            SkinsLibrary.List["Unity"].button = new GUIStyle(styleButtonUnity);
            SkinsLibrary.List["Unity"].label  = new GUIStyle(styleText);

            //Add Styles once skin is added
            GUIStyle styleTooltipUnity = new GUIStyle(styleTooltipStyle);

            styleTooltipUnity.normal.background = GUI.skin.box.normal.background;
            styleTooltipUnity.normal.textColor  = Color.white;
            SkinsLibrary.AddStyle("Unity", styleTooltipUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonMainUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonSettingsUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonToggleUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownButton", styleDropDownButtonUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownListBox", styleDropDownListBoxUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownListItem", styleDropDownListItem);

            ////Now a Unity Style one with KSP buttons
            GUISkin UnityWKSPButtons = SkinsLibrary.CopySkin("Unity");

            UnityWKSPButtons.button = DefKSP.button;
            UnityWKSPButtons.toggle = DefKSP.toggle;
            SkinsLibrary.AddSkin("UnityWKSPButtons", UnityWKSPButtons);

            //Adjust Default Skins
            SkinsLibrary.List["UnityWKSPButtons"].button = new GUIStyle(styleButton);
            SkinsLibrary.List["UnityWKSPButtons"].label  = new GUIStyle(styleText);

            //Add Styles once skin is added
            SkinsLibrary.AddStyle("UnityWKSPButtons", styleTooltipUnity);
            SkinsLibrary.AddStyle("UnityWKSPButtons", styleButton);
            SkinsLibrary.AddStyle("UnityWKSPButtons", styleButtonMain);
            SkinsLibrary.AddStyle("UnityWKSPButtons", styleButtonSettings);
            SkinsLibrary.AddStyle("UnityWKSPButtons", styleButtonToggle);
            SkinsLibrary.AddStyle("UnityWKSPButtons", "DropDownButton", styleDropDownButton);
            SkinsLibrary.AddStyle("UnityWKSPButtons", "DropDownListBox", styleDropDownListBox);
            SkinsLibrary.AddStyle("UnityWKSPButtons", "DropDownListItem", styleDropDownListItem);
        }
Ejemplo n.º 14
0
        internal override void OnGUIOnceOnly()
        {
            styleButton                  = new GUIStyle(HighLogic.Skin.button);
            styleButton.fontSize         = 14;
            styleButton.padding.top      = 2;
            styleButton.padding.bottom   = -2;
            styleButton.normal.textColor = Color.white;

            WindowStyle = new GUIStyle();
            WindowStyle.normal.background = mbTip.texBox;
            //Extra border to prevent bleed of color - actual border is only 1 pixel wide
            WindowStyle.border = new RectOffset(3, 3, 3, 3);

            styleTitle                  = new GUIStyle(HighLogic.Skin.label);
            styleTitle.fontStyle        = FontStyle.Bold;
            styleTitle.normal.textColor = Color.white;
            styleTitle.fontSize         = 14;
            styleTitle.padding.top      = 3;
            styleTitle.padding.bottom   = 4;

            stylePageNums = new GUIStyle(HighLogic.Skin.label);
            stylePageNums.normal.textColor = Color.white;
            stylePageNums.fontSize         = 12;
            stylePageNums.padding.top      = 4;
            stylePageNums.padding.bottom   = 0;

            styleToggle = new GUIStyle(HighLogic.Skin.toggle);
            styleToggle.normal.textColor = Color.white;
            styleToggle.fontSize         = 12;
            styleToggle.padding.top      = 4;
            styleToggle.padding.bottom   = 4;


            stylePage = new GUIStyle();
            //stylePage.fixedWidth = mbTip.debugwin.intTest1;
            //stylePage.fixedHeight = mbTip.debugwin.intTest2;// stylePage.fixedWidth * 2 / 3 - 1;
            stylePage.padding.left   = 1;
            stylePage.padding.right  = -1;
            stylePage.padding.top    = -1;
            stylePage.padding.bottom = 1;

            styleKeyMapTex             = new GUIStyle(stylePage);
            styleKeyMapTex.fixedWidth  = 2560;
            styleKeyMapTex.fixedHeight = 1810;

            styleDropDownGlyph           = new GUIStyle();
            styleDropDownGlyph.alignment = TextAnchor.MiddleCenter;

            styleSeparatorV = new GUIStyle();
            Texture2D texDrop = new Texture2D(10, 10, TextureFormat.ARGB32, false), texSep = new Texture2D(2, 16, TextureFormat.ARGB32, false);

            KSPTips.ExtractToTexture(ref texDrop, "img_DropDown");
            KSPTips.ExtractToTexture(ref texSep, "img_SeparatorVertical");
            styleSeparatorV.normal.background = texSep;
            styleSeparatorV.border            = new RectOffset(0, 0, 6, 6);
            styleSeparatorV.fixedWidth        = 2;


            ddlManager.DropDownGlyphs     = new GUIContentWithStyle(texDrop, styleDropDownGlyph);
            ddlManager.DropDownSeparators = new GUIContentWithStyle("", styleSeparatorV);

            styleDropDownButton               = new GUIStyle(styleButton);
            styleDropDownButton.alignment     = TextAnchor.MiddleLeft;
            styleDropDownButton.padding.right = 26;
            styleDropDownButton.padding.left  = 10;
            styleDropDownButton.fixedWidth    = 245;


            ddlGuide.styleButton = styleDropDownButton;

            styleDropDownWindowButton            = new GUIStyle(styleDropDownButton);
            styleDropDownWindowButton.fixedWidth = 125;
            ddlWindowDisplay.styleButton         = styleDropDownWindowButton;

            styleDropDownListBox = new GUIStyle();
            styleDropDownListBox.normal.background = mbTip.texBox;
            //Extra border to prevent bleed of color - actual border is only 1 pixel wide
            styleDropDownListBox.border   = new RectOffset(3, 3, 3, 3);
            ddlGuide.styleListBox         = styleDropDownListBox;
            ddlWindowDisplay.styleListBox = styleDropDownListBox;

            styleDropDownListItem = new GUIStyle();
            styleDropDownListItem.normal.textColor = new Color(207, 207, 207);
            Texture2D texBack = CreateColorPixel(new Color(207, 207, 207));

            styleDropDownListItem.hover.background   = texBack;
            styleDropDownListItem.onHover.background = texBack;
            styleDropDownListItem.hover.textColor    = Color.black;
            styleDropDownListItem.onHover.textColor  = Color.black;
            styleDropDownListItem.padding            = new RectOffset(4, 4, 3, 4);
            ddlGuide.styleListItem         = styleDropDownListItem;
            ddlWindowDisplay.styleListItem = styleDropDownListItem;

            SkinsLibrary.AddStyle("Default", "DropDownButton", styleDropDownButton);
            SkinsLibrary.AddStyle("Default", "DropDownListBox", styleDropDownListBox);
            SkinsLibrary.AddStyle("Default", "DropDownListItem", styleDropDownListItem);


            SetPageSize();
            WindowRect.x = (Screen.width - WindowRect.width) / 2;
            WindowRect.y = (Screen.height - WindowRect.height) / 2;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This one creates the skins, adds em to the skins library and adds needed styles
        /// </summary>
        internal static void InitSkins()
        {
            //Default Skin
            GUISkin DefKSP = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.KSP);

            DefKSP.window = stylePanel;
            DefKSP.font   = SkinsLibrary.DefUnitySkin.font;
            DefKSP.horizontalSlider.margin.top = 8;
            SkinsLibrary.AddSkin("Default", DefKSP);

            //Adjust Default Skins
            SkinsLibrary.List["Default"].button = new GUIStyle(styleButton);
            SkinsLibrary.List["Default"].label  = new GUIStyle(styleText);

            //Add Styles once skin is added
            SkinsLibrary.AddStyle("Default", styleTooltipStyle);
            SkinsLibrary.AddStyle("Default", styleButton);
            SkinsLibrary.AddStyle("Default", styleButtonMain);
            SkinsLibrary.AddStyle("Default", styleButtonSettings);
            SkinsLibrary.AddStyle("Default", "DropDownButton", styleDropDownButton);
            SkinsLibrary.AddStyle("Default", "DropDownListBox", styleDropDownListBox);
            SkinsLibrary.AddStyle("Default", "DropDownListItem", styleDropDownListItem);

            SkinsLibrary.AddStyle("Default", "SafeText", textStyleSafe);
            SkinsLibrary.AddStyle("Default", "WarningText", textStyleWarning);
            SkinsLibrary.AddStyle("Default", "CriticalText", textStyleCritical);


            //Now a Unity Style one
            GUISkin DefUnity = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.Unity);

            DefUnity.window         = DefUnity.box;
            DefUnity.window.border  = new RectOffset(6, 6, 6, 6);
            DefUnity.window.padding = new RectOffset(8, 3, 7, 0);
            DefUnity.horizontalSlider.margin.top = 8;
            SkinsLibrary.AddSkin("Unity", DefUnity);

            //Adjust Default Skins
            SkinsLibrary.List["Unity"].button = new GUIStyle(styleButtonUnity);
            SkinsLibrary.List["Unity"].label  = new GUIStyle(styleText);

            //Add Styles once skin is added
            GUIStyle styleTooltipUnity = new GUIStyle(styleTooltipStyle);

            styleTooltipUnity.normal.background = GUI.skin.box.normal.background;
            styleTooltipUnity.normal.textColor  = Color.white;
            SkinsLibrary.AddStyle("Unity", styleTooltipUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonMainUnity);
            SkinsLibrary.AddStyle("Unity", styleButtonSettingsUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownButton", styleDropDownButtonUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownListBox", styleDropDownListBoxUnity);
            SkinsLibrary.AddStyle("Unity", "DropDownListItem", styleDropDownListItem);

            SkinsLibrary.AddStyle("Unity", "SafeText", textStyleSafe);
            SkinsLibrary.AddStyle("Unity", "WarningText", textStyleWarning);
            SkinsLibrary.AddStyle("Unity", "CriticalText", textStyleCritical);

            // Solarized Dark theme
            // http://ethanschoonover.com/solarized
            GUISkin solarizedDarkSkin = SkinsLibrary.CopySkin("Unity");

            solarizedDarkSkin.window         = stylePanelSolarizedDark;
            solarizedDarkSkin.label.fontSize = 11;
            SkinsLibrary.AddSkin("SolarizedDark", solarizedDarkSkin);
            SkinsLibrary.AddStyle("SolarizedDark", "HUD", stylePanelSolarizedDarkHUD);
            SkinsLibrary.AddStyle("SolarizedDark", "Tooltip", styleTooltipRequirementsSolarizedDark);
            SkinsLibrary.AddStyle("SolarizedDark", "DropDownButton", styleDropDownButtonUnity);
            SkinsLibrary.AddStyle("SolarizedDark", "DropDownListBox", styleDropDownListBoxUnity);
            SkinsLibrary.AddStyle("SolarizedDark", "DropDownListItem", styleDropDownListItem);

            // Editor window is based on Kerbal Engineer's editor window to provide a more harmonious looks (because *I* use KER)
            GUISkin testFlightEditor = SkinsLibrary.CopySkin("Unity");

            testFlightEditor.window         = styleEditorPanel;
            testFlightEditor.label.fontSize = 11;
            testFlightEditor.label          = styleEditorText;
            SkinsLibrary.AddSkin("TestFlightEditor", testFlightEditor);
        }
Ejemplo n.º 16
0
        internal override void DrawWindow(int id)
        {
            base.DrawWindow(id);

            GameConfig config = scenarioModule.GetGameConfig();

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("KeepFit v" + Statics.GetDllVersion(this) + " : " + (config.enabled ? "Enabled" : "Disabled"));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button((config.enabled ? "Disable" : "Enable"), GUILayout.Width(80)))
            {
                config.enabled = !config.enabled;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Choose a Skin");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("KSP Style", "Sets the style to be the default KSPStyle")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.KSP);
            }
            if (GUILayout.Button(new GUIContent("Unity Style", "Sets the style to be the default Unity Style")))
            {
                SkinsLibrary.SetCurrent(SkinsLibrary.DefSkinType.Unity);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("WimpMode: " + (config.wimpMode ? "Enabled" : "Disabled"));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button((config.wimpMode ? "Disable" : "Enable"), GUILayout.Width(80)))
            {
                config.wimpMode = !config.wimpMode;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Min Gee For Exercising when Landed: " + config.minimumLandedGeeForExcercising);
            GUILayout.FlexibleSpace();
            // TODO - need a float editor widget here for minimumLandedGeeForExcercising
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Initial fitness level:" + config.initialFitnessLevel.ToString());
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("+5", GUILayout.Width(80)))
            {
                config.initialFitnessLevel += 5;
                config.validate();
            }
            if (GUILayout.Button("-5", GUILayout.Width(80)))
            {
                config.initialFitnessLevel -= 5;
                config.validate();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Min fitness level:" + config.minFitnessLevel.ToString());
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("+5", GUILayout.Width(80)))
            {
                config.minFitnessLevel += 5;
                config.validate();
            }
            if (GUILayout.Button("-5", GUILayout.Width(80)))
            {
                config.minFitnessLevel -= 5;
                config.validate();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Max fitness level:" + config.maxFitnessLevel.ToString());
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("+5", GUILayout.Width(80)))
            {
                config.maxFitnessLevel += 5;
                config.validate();
            }
            if (GUILayout.Button("-5", GUILayout.Width(80)))
            {
                config.maxFitnessLevel -= 5;
                config.validate();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        internal override void DrawWindow(Int32 id)
        {
            SetLocalVariables();

            try { GUILayout.BeginVertical(); }
            catch (Exception) { LogFormatted("DrawWindow: GUILayout not ready yet"); return; }

            if (mbARP.lstResourcesToDisplay.Count == 0)
            {
                GUILayout.Label("No current resources configured to display");
            }
            else
            {
                Int32 ResourceID;
                Rect  rectBar;
                for (int i = 0; i < mbARP.lstResourcesToDisplay.Count; i++)
                {
                    ResourceID = mbARP.lstResourcesToDisplay[i];
                    //Is it a separator - draw and skip?
                    if (ResourceID == 0)
                    {
                        GUILayout.Space(3 + settings.SpacerPadding);
                        GUILayout.Label("", Styles.styleSeparatorH, GUILayout.Width(WindowRect.width - 15), GUILayout.Height(2));
                        GUILayout.Space(settings.SpacerPadding);
                        continue;
                    }

                    //add space at top of window
                    if (i > 0)
                    {
                        GUILayout.Space(4);
                    }

                    GUILayout.BeginHorizontal();

                    //add title
                    Rect rectIcon = Drawing.DrawResourceIcon(lstResources[ResourceID].ResourceDef.name);

                    //If the global alarms setting is on
                    if (settings.AlarmsEnabled)
                    {
                        GUILayout.Space(1);
                        //work out the alarm ico to display
                        GUIContent contAlarm = new GUIContent(Resources.btnAlarm);
                        if (settings.Resources[ResourceID].AlarmEnabled)
                        {
                            contAlarm.image = Resources.btnAlarmEnabled;
                            switch (lstResources[ResourceID].MonitorState)
                            {
                            case ARPResource.MonitorStateEnum.Alert:
                                if (lstResources[ResourceID].AlarmState != ARPResource.AlarmStateEnum.Unacknowledged || DateTime.Now.Millisecond < 500)
                                {
                                    contAlarm.image = Resources.btnAlarmAlert;
                                }
                                break;

                            case ARPResource.MonitorStateEnum.Warn:
                                if (lstResources[ResourceID].AlarmState != ARPResource.AlarmStateEnum.Unacknowledged || DateTime.Now.Millisecond < 500)
                                {
                                    contAlarm.image = Resources.btnAlarmWarn;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        //Draw the button - if the alarm is unacknowledged then acknowledge, else toggle alarm status
                        if (GUILayout.Button(contAlarm, Styles.styleAlarmButton))
                        {
                            if (lstResources[ResourceID].AlarmState == ARPResource.AlarmStateEnum.Unacknowledged)
                            {
                                lstResources[ResourceID].SetAlarmAcknowledged();
                            }
                            else
                            {
                                settings.Resources[ResourceID].AlarmEnabled = !settings.Resources[ResourceID].AlarmEnabled;
                            }
                        }
                    }
                    //Is this resource selected
                    Boolean Highlight = SelectedResources.ContainsKey(ResourceID) && SelectedResources[ResourceID].AllVisible;

                    //For resources with no stage specifics - or the Resources is set to split display and values are different for all vessel and flow enabled ones
                    if (!settings.SplitLastStage || !lstResources[ResourceID].ResourceConfig.SplitLastStage || settings.ShowBase ||
                        (lstResources[ResourceID].ResourceDef.resourceFlowMode == ResourceFlowMode.ALL_VESSEL ||
                         lstResources[ResourceID].ResourceDef.resourceFlowMode == ResourceFlowMode.STAGE_PRIORITY_FLOW) &&
                        ((!settings.Resources[ResourceID].ShowReserveLevels) ||
                         (!lstResourcesLastStage.ContainsKey(ResourceID)))
                        )
                    {
                        //full width bar
                        rectBar = Drawing.CalcBarRect(rectIcon, Icon2BarOffset_Left, 275, 15);  //was 245
                        if (Drawing.DrawResourceBar(rectBar, lstResources[ResourceID], Styles.styleBarGreen_Back, Styles.styleBarGreen, Styles.styleBarGreen_Thin, settings.ShowRates, Highlight, Styles.styleBarHighlight))
                        {
                            //MonoBehaviourExtended.LogFormatted_DebugOnly("Clicked");
                            SelectedResources.TogglePartResourceVisible(ResourceID);
                        }
                    }
                    else
                    {
                        Int32 FullVesselBarOffset = settings.StageBarOnRight ? Icon2BarOffset_Left : Icon2BarOffset_Right;
                        Int32 StageBarOffset      = settings.StageBarOnRight ? Icon2BarOffset_Right : Icon2BarOffset_Left;

                        //need full Vessel and current stage bars
                        rectBar = Drawing.CalcBarRect(rectIcon, FullVesselBarOffset, 135, 15);  //was 120
                        if (Drawing.DrawResourceBar(rectBar, lstResources[ResourceID], Styles.styleBarGreen_Back, Styles.styleBarGreen, Styles.styleBarGreen_Thin, settings.ShowRates, Highlight, Styles.styleBarHighlight))
                        {
                            SelectedResources.TogglePartResourceVisible(ResourceID);
                        }

                        //get last stage of this resource and set it
                        if (lstResourcesLastStage.ContainsKey(ResourceID))
                        {
                            Highlight = SelectedResources.ContainsKey(ResourceID) && SelectedResources[ResourceID].LastStageVisible;
                            rectBar   = Drawing.CalcBarRect(rectIcon, StageBarOffset, 135, 15); //was 120
                            if (Drawing.DrawResourceBar(rectBar, lstResourcesLastStage[ResourceID], Styles.styleBarBlue_Back, Styles.styleBarBlue, Styles.styleBarBlue_Thin, settings.ShowRates, Highlight, Styles.styleBarHighlight))
                            {
                                SelectedResources.TogglePartResourceVisible(ResourceID, true);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.BeginHorizontal();
            ////STAGING STUFF
            if (settings.StagingEnabled)
            {
                ////Keyboard Stage Lock
                //GUIContent contLock = new GUIContent(Resources.btnUnlock, "Keyboard Staging Unlocked\r\nClick to toggle");
                //if (FlightInputHandler.fetch.stageLock)
                //    contLock = new GUIContent(Resources.btnLock, "Keyboard Staging Locked\r\nClick to toggle");
                //if (GUILayout.Button(contLock, Styles.styleAlarmButton))
                //    FlightInputHandler.fetch.stageLock = !FlightInputHandler.fetch.stageLock;

                if (!settings.AutoStagingEnabled)
                {
                    //GUILayout.Label("Stage:", Styles.styleStageTextHead, GUILayout.Width(50));
                    if (GUILayout.Button("Stage:", Styles.styleStageTextHead, GUILayout.Width(50)))
                    {
                        settings.AutoStagingEnabled = !settings.AutoStagingEnabled;
                    }
                    GUIStyle   styleStageNum = new GUIStyle(Styles.styleStageTextHead);
                    GUIContent contStageNum  = new GUIContent(StageManager.CurrentStage.ToString());
                    //styleStageNum.normal.textColor=new Color(173,43,43);
                    //GUIContent contStageNum = new GUIContent(StageManager.CurrentStage.ToString(),"NO Active Engines");
                    //if (THERE ARE ACTIVE ENGINES IN STAGE)
                    //{
                    //contStageNum.tooltip="Active Engines";
                    styleStageNum.normal.textColor = new Color(117, 206, 60);
                    //}

                    GUILayout.Label(contStageNum, styleStageNum, GUILayout.Width(20));

                    if (settings.StagingEnabledInMapView || !MapView.MapIsEnabled)
                    {
                        if (mbARP.blnVesselIsControllable)
                        {
                            if (GUILayout.Button("Activate Stage", "ButtonGeneral", GUILayout.Width(100)))
                            {
                                StageManager.ActivateNextStage();
                            }
                            GUILayout.Space(21 + IconAlarmOffset);
                            //GUILayout.Space(51 + IconAlarmOffset);
                        }
                        else
                        {
                            GUILayout.Label("No Vessel Control", GUILayout.Width(120));
                            GUILayout.Space(1 + IconAlarmOffset);
                            //GUILayout.Space(31 + IconAlarmOffset);
                        }
                    }
                    //GUILayout.Space(48 + IconAlarmOffset);
                    //GUILayout.Space(21 + IconAlarmOffset);
                }
                else
                {
                    if (GUILayout.Button("Auto:", Styles.styleStageTextHead, GUILayout.Width(50)))
                    {
                        settings.AutoStagingEnabled = !settings.AutoStagingEnabled;
                    }
                    GUILayout.Label(StageManager.CurrentStage.ToString(), Styles.styleStageTextHead, GUILayout.Width(20));
                    GUILayout.Label("to", Styles.styleStageTextHead, GUILayout.Width(30));
                    GUILayout.Label(mbARP.AutoStagingTerminateAt.ToString(), Styles.styleStageTextHead, GUILayout.Width(30));
                    DrawHorizontalSlider(ref mbARP.AutoStagingTerminateAt, 0, mbARP.AutoStagingMaxStage);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();

                    String   strButtonArm = "Arm";
                    GUIStyle styleArm     = new GUIStyle(SkinsLibrary.CurrentSkin.button)
                    {
                        fontStyle = FontStyle.Bold
                    };
                    if (mbARP.AutoStagingArmed)
                    {
                        strButtonArm = "Disarm";
                        styleArm.normal.textColor = styleArm.hover.textColor = new Color32(207, 31, 31, 255);
                    }
                    else
                    {
                        styleArm.normal.textColor = styleArm.hover.textColor = new Color32(183, 254, 0, 255);
                    }

                    if (GUILayout.Button(strButtonArm, styleArm, GUILayout.Width(75)))
                    {
                        mbARP.AutoStagingArmed = !mbARP.AutoStagingArmed;
                    }

                    GUIStyle StatusStyle = new GUIStyle(SkinsLibrary.CurrentSkin.label);
                    StatusStyle.normal.textColor = mbARP.AutoStagingStatusColor;
                    //GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(147 + IconAlarmOffset));
                    GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(120 + IconAlarmOffset));
                    //GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(150 + IconAlarmOffset));
                }
            }
            else
            {
                //GUILayout.Space(234 + IconAlarmOffset);
                GUILayout.Space(207 + IconAlarmOffset);
                //GUILayout.Space(237 + IconAlarmOffset);
            }

            // ShowBase Button
            Boolean blnShowBase = settings.ShowBase;

            if (DrawToggle(ref blnShowBase, new GUIContent(Resources.btnViewBaseActive, blnShowBase ? "Back to Vessel Display" : "Show Base Display\r\nAll resource within 2km of active vessel"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23)))
            {
                settings.ShowBase = blnShowBase;
            }
            //if (GUILayout.Button(new GUIContent(settings.ShowBase ? Resources.btnViewBaseActive : Resources.btnViewBase, "Toggle Vessel/Base Display"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
            //{
            //    settings.ShowBase = !settings.ShowBase;
            //}

            // ShowTime Button
            Boolean blnShowTimeRem = settings.ShowTimeRem;

            if (DrawToggle(ref blnShowTimeRem, new GUIContent(Resources.btnViewTimes, blnShowTimeRem ? "Hide time Remianing": "Show Time Remaining"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23)))
            {
                settings.ShowTimeRem = blnShowTimeRem;
            }
            //if (GUILayout.Button(new GUIContent(Resources.btnViewTimes, "Toggle Time Remaining"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
            //{
            //    settings.ShowTimeRem = !settings.ShowTimeRem;
            //}

            // ShowAll Button
            Boolean blnToggleHidden = KSPAlternateResourcePanel.ShowAll;

            if (DrawToggle(ref blnToggleHidden, new GUIContent(Resources.btnViewAll, "Toggle Hidden Resources"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23)))
            {
                KSPAlternateResourcePanel.ShowAll = blnToggleHidden;
            }
            //if (GUILayout.Button(new GUIContent(Resources.btnViewAll, "Toggle Hidden Resources"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
            //{
            //    KSPAlternateResourcePanel.ShowAll = !KSPAlternateResourcePanel.ShowAll;
            //}

            //Settings Toggle button
            GUIContent btnMinMax = new GUIContent(Resources.btnChevronDown, "Show Settings...");

            if (windowSettings.Visible)
            {
                btnMinMax.image = Resources.btnChevronUp; btnMinMax.tooltip = "Hide Settings";
            }
            else if (settings.VersionAttentionFlag && DateTime.Now.Millisecond < 500)
            {
                btnMinMax.image = Resources.btnSettingsAttention;
            }

            if (settings.VersionAttentionFlag)
            {
                btnMinMax.tooltip = "Updated Version Available - " + btnMinMax.tooltip;
            }

            if (GUILayout.Button(btnMinMax, "ButtonSettings", GUILayout.Width(23)))
            {
                windowSettings.Visible = !windowSettings.Visible;
                if (windowSettings.Visible && settings.VersionAttentionFlag)
                {
                    windowSettings.ddlSettingsTab.SelectedIndex = (Int32)ARPWindowSettings.SettingsTabs.About;
                    settings.VersionAttentionFlag = false;
                }
                settings.Save();
            }

            GUILayout.EndHorizontal();

            //End window layout
            GUILayout.EndVertical();

            //If settings window is visible then position it accordingly
            if (mbARP.windowSettings.Visible)
            {
                mbARP.windowSettings.UpdateWindowRect();
            }
        }