예제 #1
0
 protected bool StartLooper(Int32 TimesPerSec)
 {
     Log.Debug("Starting the repeating function");
     StopLooper();                                       // stop it if its running
     SetRepeatTimesPerSecond(TimesPerSec);               // set the new value
     return(StartLooper());                              // start it and return the result
 }
예제 #2
0
 public bool Load(string fileFullName)
 {
     try
     {
         Log.Debug("Loading ConfigNode");
         if (FileExists)
         {
             ConfigNode cnToLoad = GameDatabase.Instance.GetConfigNode(topNodeName);
             ConfigNode.LoadObjectFromConfig(this, cnToLoad);
             return(true);
         }
         else
         {
             Log.Now("File could not be found to load({0})", fileFullName);
             return(false);
         }
     }
     catch (Exception ex)
     {
         Log.Now("Failed to Load ConfigNode from file ({0}) - Error:{1}", fileFullName, ex.Message);
         Log.Now("Storing old config - {0}", fileFullName + ".err-" + timeNow);
         System.IO.File.Copy(fileFullName, fileFullName + ".err-" + timeNow, true);
         return(false);
     }
 }
예제 #3
0
        /*
         * MonoBehavior "LifeCycle"
         *
         * [ Reset ]
         *      v
         * [ Awake ]
         *      v
         * [ OnEnable ]
         *      v>---------v
         *      v		[ Start ]
         *      v<---------<
         * [  FixedUpdate  ]<----o
         *      v				 |	"Physics Loop"
         * [ y4FixedUpdate ] ----o
         *      v
         * [ Update ]
         *      v
         * [ y4null ] -AND-
         * [ y4ForSeconds ] -AND-
         * [ y4StartLooper]
         *      v
         * [ LateUpdate ]
         *      v
         * [ OnWillRenderObject ]
         *      v
         *     ...
         *      v
         * [ OnPostRender ]
         *      v
         * [ OnGUI ]<-----------o	"GUI Loop"
         *      v				|	1. <Layout> and <Repaint>
         *      v				|	2. <Layout> and <Keyboard> and <Mouse>
         *      v---------------o
         * [ y4waitEOF ]
         *      v===========> ^[ FixedUpdate ]	"Frame Loop"
         *      v
         * [ OnDisable ]
         *      v
         * [ OnDestroy ]
         *
         *
         * Some notes:
         *      + These states are **individual** to each gameObject. You can not depend on
         *          all objects having finished [Start] just because one object is in [FixedUpdate].
         *      +
         *      + The "GUI Loop" be run [2..N] times.
         *      + Adapted from: http://www.richardfine.co.uk/2012/10/unity3d-monobehaviour-lifecycle/
         *      + Ref: http://docs.unity3d.com/Manual/ExecutionOrder.html
         */

        #region "Constructor"
        protected SCAN_MBW()
            : base()
        {
            //do the assembly name add so we get different windowIDs for multiple plugins
            WindowID = UnityEngine.Random.Range(1000, 2000000) + Log._AssemblyName.GetHashCode();
            _Visible = false;
            Log.Debug("WindowID:{0}", WindowID);

            //and look for any customattributes
            WindowInitialsAttribute[] attrs = (WindowInitialsAttribute[])Attribute.GetCustomAttributes(GetType(), typeof(WindowInitialsAttribute));
            foreach (WindowInitialsAttribute attr in attrs)
            {
                Visible       = attr.Visible;
                WindowCaption = attr.Caption;

                IsDragging   = attr.IsDragging;
                DragEnabled  = attr.DragEnabled;
                ClampEnabled = attr.ClampEnabled;

                TooltipsEnabled = attr.TooltipsEnabled;

                IsResizing = attr.IsResizing;

                WindowSize_Min = attr.MinSize;
                WindowSize_Max = attr.MaxSize;
            }
        }
예제 #4
0
 public static void AddStyle(GUIStyle NewStyle, string SkinId)
 {
     Log.Debug("in AddStyle(GUIStyle ns,string sid)");
     if (SkinExists(SkinId))
     {
         GUISkin skinTemp = knownSkins[SkinId];
         AddStyle(NewStyle, ref skinTemp);
     }
 }
예제 #5
0
 internal static void RemoveStyle(string SkinID, string StyleID)
 {
     Log.Debug("in RemoveStyle(string SkinID,string StyleID)");
     if (SkinExists(SkinID))
     {
         GUISkin skinTemp = knownSkins[SkinID];
         RemoveStyle(ref skinTemp, StyleID);
     }
 }
예제 #6
0
 protected bool StopLooper()
 {
     try
     {
         Log.Debug("Cancelling the repeating function");
         this.CancelInvoke("LooperWrapper");
         _RepeatRunning = false;
     }
     catch (Exception) { Log.Now("Unable to cancel the repeating function"); }
     return(_RepeatRunning);
 }
예제 #7
0
 internal static void RemoveStyle(ref GUISkin SkinToAction, string StyleID)
 {
     Log.Debug("in RemoveStyle(GUISkin s2a, string StyleID)");
     if (StyleExists(SkinToAction, StyleID))
     {
         List <GUIStyle> lstTemp   = SkinToAction.customStyles.ToList <GUIStyle>();              // convert to a list
         GUIStyle        styleTemp = lstTemp.First(x => x.name == StyleID);                      // find and ...
         lstTemp.Remove(styleTemp);                                                              // ... remove the style
         SkinToAction.customStyles = lstTemp.ToArray <GUIStyle>();                               // write back
     }
 }
예제 #8
0
        protected bool StartLooper()
        {
            try
            {
                Log.Debug("Invoking the repeating function");
                this.InvokeRepeating("LooperWrapper", _RepeatInitialWait, LooperRate);
                _RepeatRunning = true;
            }
            catch (Exception) { Log.Now("Unable to invoke the repeating function"); }

            return(_RepeatRunning);
        }
예제 #9
0
 internal static GUIStyle GetStyle(GUISkin SkinToAction, string StyleID)
 {
     Log.Debug("in GetStyle(GUISkin s2a, string StyleID)");
     if (StyleExists(SkinToAction, StyleID))
     {
         return(SkinToAction.customStyles.First(x => x.name == StyleID));
     }
     else
     {
         return(null);
     }
 }
예제 #10
0
 public static GUISkin CopySkin(string SkinID)
 {
     Log.Debug("in CopySkin(string SkinID)");
     if (knownSkins.ContainsKey(SkinID))
     {
         return((GUISkin)SCAN_MBE.Instantiate(knownSkins[SkinID]));
     }
     else
     {
         Log.Now("CopySkin(): GUISkin {0} not found", SkinID);
         throw new SystemException(string.Format("CopySkin(): GUISkin {0} not found", SkinID));
     }
 }
예제 #11
0
        public static GUIStyle GenDefKSPTooltip()
        {
            Log.Debug("in GenDefKSPTooltip()");
            GUIStyle  retStyle = new GUIStyle(DefKSPSkin.label);                                // build a new style to return
            Texture2D texBack  = new Texture2D(1, 1, TextureFormat.ARGB32, false);              // background texture

            texBack.SetPixel(0, 0, new Color(0.5f, 0.5f, 0.5f, 0.95f));                         // background color
            texBack.Apply();
            retStyle.normal.background = texBack;                                               // put bkg into style
            retStyle.normal.textColor  = new Color32(224, 224, 224, 255);                       // set some text defaults
            retStyle.padding           = new RectOffset(3, 3, 3, 3);                            // set padding defaults
            retStyle.alignment         = TextAnchor.MiddleCenter;                               // set default center alignment
            return(retStyle);
        }
        public static void dumpSkins(this GUISkin s)
        {
            string msg = "";

            Object[] fonts = UnityEngine.Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Font));
            foreach (Object f in fonts)
            {
                msg += "found a font: " + ((UnityEngine.Font)f).name + "\n";
            }

            Log.Debug("----------------------------------\n{0}", msg);

            foreach (KeyValuePair <string, GUISkin> e in SCAN_SkinsLibrary.knownSkins)
            {
                string     k    = e.Key;
                int        hash = e.GetHashCode();
                GUISkin    v    = e.Value;
                GUIStyle[] cs   = e.Value.customStyles;

                string prefix = "#[" + hash.ToString("X8") + "]" + " GUISkin ";

                GUIStyle_.knownStyles.Add(v.box.dumpStyle(prefix + k + ".box"));
                GUIStyle_.knownStyles.Add(v.button.dumpStyle(prefix + k + ".button"));
                GUIStyle_.knownStyles.Add(v.label.dumpStyle(prefix + k + ".label"));
                GUIStyle_.knownStyles.Add(v.scrollView.dumpStyle(prefix + k + ".scrollView"));
                GUIStyle_.knownStyles.Add(v.textArea.dumpStyle(prefix + k + ".textArea"));
                GUIStyle_.knownStyles.Add(v.textField.dumpStyle(prefix + k + ".textField"));
                GUIStyle_.knownStyles.Add(v.toggle.dumpStyle(prefix + k + ".toggle"));
                GUIStyle_.knownStyles.Add(v.horizontalSlider.dumpStyle(prefix + k + ".HSlider"));
                GUIStyle_.knownStyles.Add(v.horizontalSliderThumb.dumpStyle(prefix + k + ".HSliderThumb"));
                GUIStyle_.knownStyles.Add(v.horizontalScrollbar.dumpStyle(prefix + k + ".HScrollbar"));
                GUIStyle_.knownStyles.Add(v.horizontalScrollbarLeftButton.dumpStyle(prefix + k + ".HScrollbarLeftButton"));
                GUIStyle_.knownStyles.Add(v.horizontalScrollbarRightButton.dumpStyle(prefix + k + ".HScrollbarRightButton"));
                GUIStyle_.knownStyles.Add(v.horizontalScrollbarThumb.dumpStyle(prefix + k + ".HScrollbarThumb"));
                GUIStyle_.knownStyles.Add(v.verticalSlider.dumpStyle(prefix + k + ".VSlider"));
                GUIStyle_.knownStyles.Add(v.verticalSliderThumb.dumpStyle(prefix + k + ".VSliderThumb"));
                GUIStyle_.knownStyles.Add(v.verticalScrollbar.dumpStyle(prefix + k + ".VScrollbar"));
                GUIStyle_.knownStyles.Add(v.verticalScrollbarUpButton.dumpStyle(prefix + k + ".VScrollbarLeftButton"));
                GUIStyle_.knownStyles.Add(v.verticalScrollbarDownButton.dumpStyle(prefix + k + ".VScrollbarRightButton"));
                GUIStyle_.knownStyles.Add(v.verticalScrollbarThumb.dumpStyle(prefix + k + ".VScrollbarThumb"));

                int i = 0;
                Log.Debug("GUISkin {0}.customStyles contains {1} custom styles:", k, cs.Length);
                foreach (GUIStyle sty in cs)
                {
                    string csi = ".customStyles[" + i++ + "]";
                    GUIStyle_.knownStyles.Add(sty.dumpStyle(prefix + k + csi));
                }
            }
        }
예제 #13
0
 internal static bool StyleExists(GUISkin SkinToAction, string StyleID)
 {
     Log.Debug("in StyleExists(GUISkin s2a,)");
     if (SkinToAction.customStyles.Any(x => x.name == StyleID))
     {
         return(true);
     }
     else
     {
         //Log.log("Unable to find Style: {0} in Skin: {1}", StyleID, SkinToAction.name);
         return(false);
     }
     //return (SkinToAction.customStyles.Any(x => x.name == StyleID));
 }
예제 #14
0
        public static event TooltipChangedEvent OnTooltipChanged;               //FIXME: unused

        internal static void InitSkinList()
        {
            Log.Debug("in InitSkinList()");
            if (!_Initialized)
            {
                DefUnitySkin = GUI.skin;
                DefKSPSkin   = HighLogic.Skin;

                knownSkins.Add("Unity", DefUnitySkin);
                knownSkins.Add("KSP", DefKSPSkin);
                DefUnitySkin.dumpSkins();
                SetCurrent("KSP");
                _Initialized = true;
            }
        }
        public static GUIStyle dumpStyle(this GUIStyle s, string breadcrumbs)
        {
            var hash = s.GetHashCode();

            if (knownStyles.Contains(s))
            {
                Log.Debug("{0} => #[{2:X8}] {1}  skipped", breadcrumbs, s.ToString(), hash); return(s);
            }



            //Log.Debug("{0} => #[{2:X8}] {1}", breadcrumbs, s.ToString(), s.GetHashCode());
            //Log.Debug("             ------------------------------------------------------------------------------------------------ ");
            //Log.Debug("              -> contentOffset => {0}", s.contentOffset);
            //Log.Debug("             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
            //Log.Debug("              -> border    => {0}", s.border);
            //Log.Debug("              -> padding   => {0}", s.border);
            //Log.Debug("              -> margin    => {0}", s.border);
            //Log.Debug("              -> overflow  => {0}", s.border);
            //// print all of the non-trivialGUIStyleState components
            //Log.Debug("             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
            //s.active.PPP	("              -> active    => ");
            //s.onActive.PPP	("              -> onActive  => ");
            //s.normal.PPP	("              -> normal    => ");
            //s.onNormal.PPP	("              -> onNormal  => ");
            //s.hover.PPP		("              -> hover     => ");
            //s.onHover.PPP	("              -> onHover   => ");
            //s.focused.PPP	("              -> focused   => ");
            //s.onFocused.PPP	("              -> onFocused => ");
            //Log.Debug("             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
            //Log.Debug("              -> alignment => {0}", s.alignment);
            //Log.Debug("              -> wordwrap  => {0}", s.alignment);
            //Log.Debug("              -> clipping  => {0}", s.clipping);
            //Log.Debug("              -> richText? => {0}", s.richText);
            //Log.Debug("              -> lineHeight=> {0}", s.lineHeight);
            //Log.Debug("              -> font      => {0}", s.fontPP());
            //Log.Debug("              -> fontSize  => {0}", s.fontSize);
            //Log.Debug("              -> fontStyle => {0}", s.fontStyle);
            //Log.Debug("             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
            //Log.Debug("              -> fixedW, stretchW?  => {0} ({1})", s.fixedWidth, s.stretchWidth);
            //Log.Debug("              -> fixedH, stretchH?  => {0} ({1})", s.fixedHeight, s.stretchHeight);
            //Log.Debug("              -> isHdepW? => {0}", s.isHeightDependantOnWidth);
            //Log.Debug("             ------------------------------------------------------------------------------------------------ ");

            return(s);
        }
예제 #16
0
        public static void AddSkin(string SkinID, GUISkin NewSkin, bool SetAsCurrent = false)
        {
            Log.Debug("in AddSkin");
            NewSkin.name = SkinID;
            if (knownSkins.ContainsKey(SkinID))
            {
                knownSkins[SkinID] = NewSkin;
            }
            else
            {
                knownSkins.Add(SkinID, NewSkin);
            }

            if (SetAsCurrent)
            {
                SetCurrent(SkinID);
            }
        }
예제 #17
0
        internal static void AddStyle(GUIStyle NewStyle, ref GUISkin SkinToAction)
        {
            Log.Debug("in AddStyle(GUIStyle ns,ref GUISkin)");
            if (string.IsNullOrEmpty(NewStyle.name))
            {
                Log.Now("No Name Provided in the Style to add to {0}. Cannot add this.", SkinToAction.name);
                return;
            }
            List <GUIStyle> lstTemp = SkinToAction.customStyles.ToList <GUIStyle>();           // convert to a list


            if (lstTemp.Any(x => x.name == NewStyle.name))
            {                                   // add or edit the customstyle
                GUIStyle styleTemp = lstTemp.First(x => x.name == NewStyle.name);
                lstTemp.Remove(styleTemp);      // if itexists then remove it first
            }

            lstTemp.Add(NewStyle);                                                      // add the new style
            SkinToAction.customStyles = lstTemp.ToArray <GUIStyle>();                   // write the list back to the array
        }
예제 #18
0
        public static void SetCurrent(string SkinID)
        {
            GUISkin OldSkin = _CurrentSkin;

            Log.Debug("Setting GUISkin(string SkinID) to {0}", SkinID);

            if (knownSkins.ContainsKey(SkinID))
            {
                _CurrentSkin = knownSkins[SkinID];
            }
            else
            {
                Log.Now("SetCurrent: GUISkin {0} not found", SkinID);
            }

            //SetCurrentTooltip(); // Now set the tooltip style as well
            if (OldSkin != CurrentSkin && OnSkinChanged != null)
            {
                OnSkinChanged();
            }
        }
        public static void PPP(this GUIStyleState s, string breadcrumbs)
        {
            string bkg       = "null";
            string colorName = "";

            if (s.textColor == black && s.background == null)
            {
                return;
            }
            if (s.background != null)
            {
                bkg = s.background.ToString();
            }

            if (Color_.knownColors.TryGetValue(s.textColor, out colorName))
            {
                Log.Debug("{0} {{ GUIss: textColor: {1} bkg: {2} }}", breadcrumbs, colorName, bkg);
            }
            else
            {
                Log.Debug("{0} {{ GUIss: textColor: {1} bkg: {2} }}", breadcrumbs, s.textColor.ToString(), bkg);
            }
        }
예제 #20
0
 public static void SetCurrentTooltip()
 {
     //Use the custom skin if it exists
     Log.Debug("in SetCurrentTooltip()");
     if (StyleExists(_CurrentSkin, "SCAN_Tooltip"))
     {
         _CurrentTooltip = GetStyle(_CurrentSkin, "SCAN_Tooltip");
     }
     else
     {              //otherwise lets build a style for the defaults or take the label style otherwise
         if (_CurrentSkin == DefUnitySkin)
         {
             _CurrentTooltip = new GUIStyle(DefUnitySkin.box);
         }
         else if (_CurrentSkin == DefKSPSkin)
         {
             _CurrentTooltip = GenDefKSPTooltip();
         }
         else
         {
             _CurrentTooltip = _CurrentSkin.label;
         }
     }
 }
예제 #21
0
 //See this for info on order of execuction
 //  http://docs.unity3d.com/Documentation/Manual/ExecutionOrder.html
 protected virtual void Awake()
 {
     Log.Debug("MBE Awakened");
 }                                                                               // 1.
예제 #22
0
 public bool Save()
 {
     Log.Debug("Saving ConfigNode");
     return(Save(FilePath));
 }
예제 #23
0
 protected virtual void OnGUI_FirstRun()
 {
     Log.Debug("Running OnGUI OnceOnly Code");
 }
예제 #24
0
        }                                                                               // 1.

        //internal virtual void OnEnable()		{ }								// 2.
        protected virtual void Start()
        {
            Log.Debug("MBE Started");
        }                                                                               // 3.
예제 #25
0
 internal static void AddStyle(GUIStyle NewStyle, ref GUISkin SkinToAction, string StyleID)
 {
     Log.Debug("in AddStyle(GUIStyle ns,ref GUISkin, string StyleID)");
     NewStyle.name = StyleID;                            // set the name
     AddStyle(NewStyle, ref SkinToAction);               // and push to the next method
 }
예제 #26
0
 internal static void AddStyle(GUIStyle NewStyle, string SkinId, string StyleID)
 {
     Log.Debug("in AddStyle(GUIStyle ns,string skinID, string StyleID)");
     NewStyle.name = StyleID;
     AddStyle(NewStyle, SkinId);
 }
예제 #27
0
 //internal virtual void OnDisable()		{ }								// 6.
 protected virtual void OnDestroy()
 {
     Log.Debug("MBE Destroy-ing");
 }                                                                               // 7.
예제 #28
0
 protected override void Awake()
 {
     Log.Debug("New MBWindow Awakened");
 }
예제 #29
0
 internal static bool SkinExists(string SkinID)
 {
     Log.Debug("in SkinExists()"); return(knownSkins.ContainsKey(SkinID));
 }