Пример #1
0
        void Awake()
        {
            skin = (GUISkin)GUISkin.Instantiate(HighLogic.Skin);
            skin.button.padding    = new RectOffset(2, 2, 2, 2);
            skin.button.margin     = new RectOffset(1, 1, 1, 1);
            skin.box.padding       = new RectOffset(2, 2, 2, 2);
            skin.box.margin        = new RectOffset(1, 1, 1, 1);
            skin.textField.margin  = new RectOffset(3, 1, 1, 1);
            skin.textField.padding = new RectOffset(4, 2, 1, 0);

            if (!RegisterWithFAR())
            {
                this.enabled = false;
            }

            LoadConfig();
            LoadSettings();
            InitializeToolbars();
            OnGuiVisibilityChange();

            simplexNoise = new OpenSimplex2S(HighLogic.CurrentGame.Seed);

            currentWindSpeed = oldWindSpeed = newWindSpeed = 0f;
            currentWindDir   = oldWindDir = newWindDir = -1f;
            blendStart       = 0;
            blendDuration    = 0;
            weatherLat       = -1000f;
            weatherLng       = -1000f;
            weatherTime      = -1f;

            CalculateWeather();
            gustsmodel.Init(config);
            ComputeWindVector();
        }
        private static void SetupElements()
        {
            if (_elementStyles.Count == 0)
            {
                #region Audio
                GUISkin style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.AudioElementTexture;
                style.label.normal.textColor   = new Color32(88, 106, 84, 255);

                _elementStyles.Add(StoryElementTypes.Audio, style);
                #endregion

                #region Character
                style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.CharacterElementTexture;
                style.label.normal.textColor   = new Color32(63, 58, 51, 255);

                _elementStyles.Add(StoryElementTypes.Character, style);
                #endregion

                #region Scenery
                style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.SceneryElementTexture;
                style.label.normal.textColor   = new Color32(63, 60, 48, 255);

                _elementStyles.Add(StoryElementTypes.Scenery, style);
                #endregion

                #region Story
                style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.StoryElementTexture;
                style.label.normal.textColor   = new Color32(63, 48, 48, 255);

                _elementStyles.Add(StoryElementTypes.Story, style);
                #endregion

                #region Utility
                style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.UtilityElementTexture;
                style.label.normal.textColor   = new Color32(83, 87, 110, 255);

                _elementStyles.Add(StoryElementTypes.Utility, style);
                #endregion

                #region Other
                style = GUISkin.Instantiate(EditorSettings.UVNFSkin);

                style.button.normal.background = EditorSettings.OtherElementTexture;
                style.label.normal.textColor   = new Color32(56, 56, 56, 255);

                _elementStyles.Add(StoryElementTypes.Other, style);
                #endregion
            }
        }
Пример #3
0
        void Awake()
        {
            skin = (GUISkin)GUISkin.Instantiate(HighLogic.Skin);
            skin.button.padding    = new RectOffset(2, 2, 2, 2);
            skin.button.margin     = new RectOffset(1, 1, 1, 1);
            skin.box.padding       = new RectOffset(2, 2, 2, 2);
            skin.box.margin        = new RectOffset(1, 1, 1, 1);
            skin.textField.margin  = new RectOffset(3, 1, 1, 1);
            skin.textField.padding = new RectOffset(4, 2, 1, 0);

            if (!RegisterWithFAR())
            {
                this.enabled = false;
            }

            LoadSettings();
            InitializeToolbars();
            OnGuiVisibilityChange();

            gustsmodel.Init(0f);
            ComputeWindVector();
        }
Пример #4
0
        void MakeSkin()
        {
            Color highlight = new Color(20.0f / 255, 207.0f / 255, 248.0f / 255);

            uiSkin = (GUISkin)GUISkin.Instantiate(GUI.skin);
            uiSkin.window.normal.background = ResourceLoader.loadTexture(32, 32, "Materials/UIbg.png");
            uiSkin.window.border            = new RectOffset(16, 16, 16, 16);
            uiSkin.window.padding           = new RectOffset(12, 8, 26, 12);

            uiSkin.window.normal.textColor = highlight;
            uiSkin.window.alignment        = TextAnchor.UpperCenter;
            uiSkin.window.fontSize         = 30;
            uiSkin.window.fontStyle        = FontStyle.Bold;

            uiSkin.window.onNormal  = uiSkin.window.normal;
            uiSkin.window.onFocused = uiSkin.window.onNormal;
            uiSkin.window.onHover   = uiSkin.window.onNormal;
            uiSkin.window.onActive  = uiSkin.window.onNormal;

            uiSkin.button = new GUIStyle();


            uiSkin.label.normal.textColor = Color.white;
            uiSkin.label.fontSize         = 18;
            uiSkin.label.fontStyle        = FontStyle.Bold;
            uiSkin.label.padding          = new RectOffset(0, 0, 5, 5);

            uiSkin.toggle.normal.textColor = Color.white;
            uiSkin.toggle.fontSize         = 18;
            uiSkin.toggle.fontStyle        = FontStyle.Bold;
            uiSkin.toggle.padding          = new RectOffset(20, 0, 0, 10);

            totalStyle = new GUIStyle(uiSkin.label);
            totalStyle.normal.textColor = highlight;
            totalStyle.fontSize         = 20;
            totalStyle.fontStyle        = FontStyle.Bold;
        }
Пример #5
0
    void OnGUI()
    {
        if (this.skin == null)
        {
            this.skin = GUISkin.Instantiate <GUISkin>(GUI.skin);

            int font_size = Mathf.FloorToInt(14.0f * this.screen_scale);

            this.skin.label.fontSize  = font_size;
            this.skin.button.fontSize = font_size;
            this.skin.box.fontSize    = font_size;
            this.skin.toggle.fontSize = font_size;
            //this.skin.window.fontSize = font_size;
        }
        GUI.skin = this.skin;

        // バッファーにたまっているテキストを表示する.

        int x, y;

        foreach (var item in this.items)
        {
            x = item.x;
            y = item.y;

            GUI.Box(new Rect(x, y, item.text.Length * dbPrint.CHARA_W * this.screen_scale + 4, dbPrint.CHARA_H * this.screen_scale), item.text);

            y += (int)(dbPrint.CHARA_H * this.screen_scale);
        }

        // バッファーをクリアーする.

        if (UnityEngine.Event.current.type == UnityEngine.EventType.Repaint)
        {
            this.clear();
        }
    }
        /******************************************************************************
        *                    Implementation Details
        ******************************************************************************/

        protected override Rect Setup()
        {
            // position blocker in front of ApplicationLauncher buttons. The window is going to be drawn on
            // top of them regardless; this will just prevent us from accidentally interacting with them
            backstop.SetZ(ApplicationLauncher.Instance.anchor.transform.position.z - 50f);

            // culture setting
            Log.Normal("Configuring NumberFormatInfo for current locale");
            formatter = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
            formatter.CurrencySymbol        = string.Empty;
            formatter.CurrencyDecimalDigits = 2;
            formatter.NumberDecimalDigits   = 2;
            formatter.PercentDecimalDigits  = 2;


            audio = AudioPlayer.Audio;

            if (audio == null)
            {
                Log.Error("DraggableOptionsWindow: Failed to find AudioPlayer instance");
            }


            var rawIds    = ResearchAndDevelopment.GetExperimentIDs();
            var sortedIds = rawIds.OrderBy(expid => ResearchAndDevelopment.GetExperiment(expid).experimentTitle);

            Log.Debug("OptionsWindow: sorted {0} experiment IDs", sortedIds.Count());

            foreach (var id in sortedIds)
            {
                experimentIds.Add(id, (int)Convert.ChangeType(ProfileManager.ActiveProfile[id].Filter, ProfileManager.ActiveProfile[id].Filter.GetTypeCode()));
                Log.Debug("Settings: experimentId {0} has filter index {1}", id, experimentIds[id]);
            }

            /*
             *  Unresearched = 0,
             *  NotMaxed = 1,
             *  LessThanFiftyPercent = 2,
             *  LessThanNinetyPercent = 3
             */
            filterList.Add(new GUIContent("Unresearched"));
            filterList.Add(new GUIContent("Not maxed"));
            filterList.Add(new GUIContent("< 50% collected"));
            filterList.Add(new GUIContent("< 90% collected"));


            openButton   = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnOpen.png", false);
            saveButton   = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnSave.png", false);
            returnButton = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnReturn.png", false);
            deleteButton = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnDelete.png", false);
            renameButton = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnRename.png", false);

            var tex = ResourceUtil.GetEmbeddedTexture("ScienceAlert.Resources.btnExpand.png", false);

            if (tex == null)
            {
                Log.Error("Failed to retrieve expand button texture from stream");
            }
            else
            {
                Log.Debug("Collapse button texture loaded successfully");
                expandButton = tex;

                collapseButton = UnityEngine.Texture.Instantiate(expandButton) as Texture2D;
                ResourceUtil.FlipTexture(collapseButton, true, true);

                collapseButton.Compress(false);
                expandButton.Compress(false);
            }

            blackPixel.SetPixel(0, 0, Color.black); blackPixel.Apply();
            blackPixel.filterMode = FilterMode.Bilinear;

            whiteLabel = (GUISkin)GUISkin.Instantiate(Settings.Skin);
            whiteLabel.label.onNormal.textColor  = Color.white;
            whiteLabel.toggle.onNormal.textColor = Color.white;
            whiteLabel.label.onActive.textColor  = Color.white;

            submenu = OpenPane.None;
            Title   = "ScienceAlert Options";

            // smaller label for less important text hints
            miniLabelLeft                  = new GUIStyle(Skin.label);
            miniLabelLeft.fontSize         = 10;
            miniLabelLeft.normal.textColor = miniLabelLeft.onNormal.textColor = Color.white;

            miniLabelRight           = new GUIStyle(miniLabelLeft);
            miniLabelRight.alignment = TextAnchor.MiddleRight;

            miniLabelCenter           = new GUIStyle(miniLabelLeft);
            miniLabelCenter.alignment = TextAnchor.MiddleCenter;

            Settings.Instance.OnSave += OnAboutToSave;
            base.OnVisibilityChange  += OnVisibilityChanged;
            GameEvents.onVesselChange.Add(OnVesselChanged);

            LoadFrom(Settings.Instance.additional.GetNode("OptionsWindow") ?? new ConfigNode());

            return(new Rect(windowRect.x, windowRect.y, 324, Screen.height / 5 * 3));
        }