<commit_before>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Linq;

using UnityEngine;
using KSP;
using KSPPluginFramework;

namespace KerbalAlarmClock
{
    public partial class KerbalAlarmClock
    {


        #region "OnGUI Stuff"
        System.Random rnd = new System.Random();
        //public void SetupDrawStuff()
        //{
        //    GUI.skin = HighLogic.Skin;
        //    if (KACResources.styleWindow == null)
        //    {
        //        KACResources.SetStyles();
        //        //styleWindow = new GUIStyle(GUI.skin.window);
        //    }
        //}

        #region "Tooltip Work"
        //Tooltip variables
        //Store the tooltip text from throughout the code
        String strToolTipText = "";
        String strLastTooltipText = "";
        //is it displayed and where
        Boolean blnToolTipDisplayed = false;
        Rect rectToolTipPosition;
        Int32 intTooltipVertOffset = 12;
        Int32 intTooltipMaxWidth = 250;
        //timer so it only displays for a preriod of time
        float fltTooltipTime = 0f;


        private void DrawToolTip()
        {
            if (strToolTipText != "" && (fltTooltipTime < settings.MaxToolTipTimeFloat))
            {
                GUIContent contTooltip = new GUIContent(strToolTipText);
                if (!blnToolTipDisplayed || (strToolTipText != strLastTooltipText))
                {
                    //reset display time if text changed
                    fltTooltipTime = 0f;
                    //Calc the size of the Tooltip
                    rectToolTipPosition = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + intTooltipVertOffset, 0, 0);
                    float minwidth, maxwidth;
                    KACResources.styleTooltipStyle.CalcMinMaxWidth(contTooltip, out minwidth, out maxwidth); // figure out how wide one line would be
                    rectToolTipPosition.width = Math.Min(intTooltipMaxWidth - KACResources.styleTooltipStyle.padding.horizontal, maxwidth); //then work out the height with a max width
                    rectToolTipPosition.height = KACResources.styleTooltipStyle.CalcHeight(contTooltip, rectToolTipPosition.width); // heers the result
                    //Make sure its not off the right of the screen
                    if (rectToolTipPosition.x + rectToolTipPosition.width > Screen.width) rectToolTipPosition.x = Screen.width - rectToolTipPosition.width;
                }
                //Draw the Tooltip
                GUI.Label(rectToolTipPosition, contTooltip, KACResources.styleTooltipStyle);
                //On top of everything
                GUI.depth = 0;

                //update how long the tip has been on the screen and reset the flags
                fltTooltipTime += Time.deltaTime;
                blnToolTipDisplayed = true;
            }
            else
            {
                //clear the flags
                blnToolTipDisplayed = false;
            }
            if (strToolTipText != strLastTooltipText) fltTooltipTime = 0f;
            strLastTooltipText = strToolTipText;
        }

        internal void SetTooltipText()
        {
            if (Event.current.type == EventType.Repaint)
            {
                strToolTipText = GUI.tooltip;
            }
        }
        #endregion

        #region "Stuff to get icon and windows by scene"
        public Boolean IconShowByActiveScene
        {
            get
            {
                switch (HighLogic.LoadedScene)
                {
                    case GameScenes.SPACECENTER: return settings.IconShow_SpaceCenter;
                    case GameScenes.TRACKSTATION: return settings.IconShow_TrackingStation;
                    case GameScenes.EDITOR:
                        if (isEditorVAB) 
                            return settings.IconShow_EditorVAB;
                        else<commit_msg>Fix old bug where MaxTooltipTime is impacted by framerate (specifically more frames rendered per FixedUpdate caused tooltips to expire more quickly)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Linq;

using UnityEngine;
using KSP;
using KSPPluginFramework;

namespace KerbalAlarmClock
{
    public partial class KerbalAlarmClock
    {


        #region "OnGUI Stuff"
        System.Random rnd = new System.Random();
        //public void SetupDrawStuff()
        //{
        //    GUI.skin = HighLogic.Skin;
        //    if (KACResources.styleWindow == null)
        //    {
        //        KACResources.SetStyles();
        //        //styleWindow = new GUIStyle(GUI.skin.window);
        //    }
        //}

        #region "Tooltip Work"
        //Tooltip variables
        //Store the tooltip text from throughout the code
        String strToolTipText = "";
        String strLastTooltipText = "";
        //is it displayed and where
        Boolean blnToolTipDisplayed = false;
        Rect rectToolTipPosition;
        Int32 intTooltipVertOffset = 12;
        Int32 intTooltipMaxWidth = 250;
        //timer so it only displays for a preriod of time
        float fltTooltipTime = 0f;


        private void DrawToolTip()
        {
            //reset display time if text changed
            if (strToolTipText != strLastTooltipText)
                fltTooltipTime = Time.unscaledTime + settings.MaxToolTipTimeFloat;
            if (strToolTipText != "" && (Time.unscaledTime <= fltTooltipTime))
            {
                GUIContent contTooltip = new GUIContent(strToolTipText);
                if (!blnToolTipDisplayed || (strToolTipText != strLastTooltipText))
                {
                    //Calc the size of the Tooltip
                    rectToolTipPosition = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + intTooltipVertOffset, 0, 0);
                    float minwidth, maxwidth;
                    KACResources.styleTooltipStyle.CalcMinMaxWidth(contTooltip, out minwidth, out maxwidth); // figure out how wide one line would be
                    rectToolTipPosition.width = Math.Min(intTooltipMaxWidth - KACResources.styleTooltipStyle.padding.horizontal, maxwidth); //then work out the height with a max width
                    rectToolTipPosition.height = KACResources.styleTooltipStyle.CalcHeight(contTooltip, rectToolTipPosition.width); // heers the result
                    //Make sure its not off the right of the screen
                    if (rectToolTipPosition.x + rectToolTipPosition.width > Screen.width) rectToolTipPosition.x = Screen.width - rectToolTipPosition.width;
                }
                //Draw the Tooltip
                GUI.Label(rectToolTipPosition, contTooltip, KACResources.styleTooltipStyle);
                //On top of everything
                GUI.depth = 0;

                //reset the flags
                blnToolTipDisplayed = true;
            }
            else
            {
                //clear the flags
                blnToolTipDisplayed = false;
            }
            strLastTooltipText = strToolTipText;
        }

        internal void SetTooltipText()
        {
            if (Event.current.type == EventType.Repaint)
            {
                strToolTipText = GUI.tooltip;
            }
        }
        #endregion

        #region "Stuff to get icon and windows by scene"
        public Boolean IconShowByActiveScene
        {
            get
            {
                switch (HighLogic.LoadedScene)
                {
                    case GameScenes.SPACECENTER: return settings.IconShow_SpaceCenter;
                    case GameScenes.TRACKSTATION: return settings.IconShow_TrackingStation;
                    case GameScenes.EDITOR:
                        if (isEditorVAB) 
                            return settings.IconShow_EditorVAB;
                        else
{'fraction_non_alphanumeric': 0.07048458149779736, 'fraction_numerical': 0.003524229074889868, 'mean_word_length': 1.6999660210669385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6877408', 'n_tokens_mistral': 2050, 'n_tokens_neox': 2012, 'n_words': 519}