예제 #1
0
        protected override void OnUpdate()
        {
            if (waiting && Planetarium.GetUniversalTime() > completionTime)
            {
                waiting = false;
                SetComplete();
            }
            // Every time the clock ticks over, make an attempt to update the contract window
            // notes.  We do this because otherwise the window will only ever read the notes once,
            // so this is the only way to get our fancy timer to work.
            else if (waiting && trackedVessel != null && Planetarium.GetUniversalTime() - lastUpdate > 1.0f)
            {
                lastUpdate = Planetarium.GetUniversalTime();

                // Go through all the list items in the contracts window
                UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList;
                for (int i = 0; i < list.Count; i++)
                {
                    // Try to find a rich text control that matches the expected text
                    UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i);
                    SpriteTextRich      richText   = listObject.GetComponentInChildren <SpriteTextRich>();
                    if (richText != null && noteTracker.ContainsKey(richText.Text))
                    {
                        // Clear the noteTracker, and replace the text
                        noteTracker.Clear();
                        richText.Text = notePrefix + GetNotes();
                    }
                }
            }
        }
예제 #2
0
파일: xFont.cs 프로젝트: yang7206/KSP_zh
        public bool SetSpriteTextRichFont(SpriteTextRich ST)
        {
            bool result = false;

            if (FontList.Count == 0)
            {
                LoadxFont();
            }
            // if (ST.font.name[0] == 'c' && ST.font.name[1] == 'n') return result;

            //Debug.Log("[xFont2-1]" + ST.font.name + " :: " + ST.text);
            for (int i = 0; i < ST.font.fonts.Length; i++)
            {
                if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n')
                {
                    continue;
                }

                Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name);
                Debug.Log("[xFont2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                ST.font.fonts[i].fontText   = f2f.fontDef;
                ST.font.fonts[i].material   = f2f.fontMat;
                ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef);
                //Debug.Log("[xFont2-2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                result = true;
            }
            ST.font.name = "cn" + ST.font.name;
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Call this any time the title text has changed - this will make an attempt to update
        /// the contract window title.  We do this because otherwise the window will only ever read
        /// the title once.
        /// </summary>
        /// <param name="newTitle">New title to display</param>
        public void UpdateContractWindow(ContractParameter param, string newTitle)
        {
            // Try to find the cascading list in the contracts window.  Note that we may pick up
            // the ones from the Engineer's report in the VAB/SPH instead - but we don't care about
            // title updates in those scenes anyway.
            if (cascadingList == null || !cascadingList.gameObject.activeSelf)
            {
                cascadingList = UnityEngine.Object.FindObjectOfType <GenericCascadingList>();
            }

            // Every time the clock ticks over, make an attempt to update the contract window
            // title.  We do this because otherwise the window will only ever read the title once,
            // so this is the only way to get our fancy timer to work.

            // Go through all the list items in the contracts window
            if (cascadingList != null)
            {
                UIScrollList list = cascadingList.ruiList.cascadingList;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        // Try to find a rich text control that matches the expected text
                        UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i);
                        SpriteTextRich      richText   = listObject.GetComponentInChildren <SpriteTextRich>();
                        if (richText != null)
                        {
                            // Check for any string in titleTracker
                            string found = null;
                            foreach (string title in titles)
                            {
                                if (richText.Text.Contains(title))
                                {
                                    found = title;
                                    break;
                                }
                            }

                            // Clear the titleTracker, and replace the text
                            if (found != null)
                            {
                                titles.Clear();
                                richText.Text = richText.Text.Replace(found, newTitle);
                                titles.Add(newTitle);
                            }
                        }
                    }

                    // Reposition items to account for items where the height increased or decreased
                    list.RepositionItems();
                }
            }

            // Contracts Window + update
            ContractsWindow.SetParameterTitle(param, newTitle);
        }
예제 #4
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            // Every time the clock ticks over, make an attempt to update the contract window
            // title.  We do this because otherwise the window will only ever read the title once,
            // so this is the only way to get our fancy timer to work.
            if (Planetarium.GetUniversalTime() - lastUpdate > 1.0f)
            {
                // Boom!
                if (Planetarium.GetUniversalTime() > endTime)
                {
                    SetFailed();
                }
                lastUpdate = Planetarium.GetUniversalTime();

                // Go through all the list items in the contracts window
                UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        // Try to find a rich text control that matches the expected text
                        UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i);
                        SpriteTextRich      richText   = listObject.GetComponentInChildren <SpriteTextRich>();
                        if (richText != null)
                        {
                            // Check for any string in titleTracker
                            string found = null;
                            foreach (string title in titleTracker)
                            {
                                if (richText.Text.Contains(title))
                                {
                                    found = title;
                                    break;
                                }
                            }

                            // Clear the titleTracker, and replace the text
                            if (found != null)
                            {
                                titleTracker.Clear();
                                richText.Text = richText.Text.Replace(found, GetTitle());
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Call this any time the title text has changed - this will make an attempt to update
        /// the contract window title.  We do this because otherwise the window will only ever read
        /// the title once.
        /// </summary>
        /// <param name="newTitle">New title to display</param>
        public void UpdateContractWindow(string newTitle)
        {
            // Every time the clock ticks over, make an attempt to update the contract window
            // title.  We do this because otherwise the window will only ever read the title once,
            // so this is the only way to get our fancy timer to work.

            // Go through all the list items in the contracts window
            UIScrollList list = ContractsApp.Instance.cascadingList.cascadingList;

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    // Try to find a rich text control that matches the expected text
                    UIListItemContainer listObject = (UIListItemContainer)list.GetItem(i);
                    SpriteTextRich      richText   = listObject.GetComponentInChildren <SpriteTextRich>();
                    if (richText != null)
                    {
                        // Check for any string in titleTracker
                        string found = null;
                        foreach (string title in titles)
                        {
                            if (richText.Text.Contains(title))
                            {
                                found = title;
                                break;
                            }
                        }

                        // Clear the titleTracker, and replace the text
                        if (found != null)
                        {
                            titles.Clear();
                            richText.Text = richText.Text.Replace(found, newTitle);
                            titles.Add(newTitle);
                        }
                    }
                }

                // Reposition items to account for items where the height increased or decreased
                list.RepositionItems();
            }
        }
예제 #6
0
파일: xFont.cs 프로젝트: zoutianxia/KSP_zh
        public void SetSpriteTextRichFont(SpriteTextRich ST)
        {
            if (FontList.Count == 0)
            {
                LoadxFont();
            }

            for (int i = 0; i < ST.font.fonts.Length; i++)
            {
                if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n')
                {
                    return;
                }

                Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name);
                Debug.Log("xFont:" + ST.font.name + "-->>" + f2f.Name);
                ST.font.fonts[i].fontText   = f2f.fontDef;
                ST.font.fonts[i].material   = f2f.fontMat;
                ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef);
            }
        }
예제 #7
0
파일: xFont.cs 프로젝트: baozidai/KSP_zh
        public bool SetSpriteTextRichFont(SpriteTextRich ST)
        {
            bool result = false;
            if (FontList.Count == 0)
            {
                LoadxFont();
            }
               // if (ST.font.name[0] == 'c' && ST.font.name[1] == 'n') return result;

            //Debug.Log("[xFont2-1]" + ST.font.name + " :: " + ST.text);
            for (int i = 0; i < ST.font.fonts.Length; i++)
            {
                if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n') continue;

                Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name);
                Debug.Log("[xFont2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                ST.font.fonts[i].fontText = f2f.fontDef;
                ST.font.fonts[i].material = f2f.fontMat;
                ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef);
                //Debug.Log("[xFont2-2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                result = true;
            }
            ST.font.name = "cn" + ST.font.name;
            return result;
        }
예제 #8
0
파일: xFont.cs 프로젝트: baozidai/KSP_zh
        // Fields
        //private const string Font_10 = "cn10";
        //private const string Font_12 = "cn12";
        //private const string Font_14 = "cn14";
        //private const string Font_14b = "cn14b";
        //private const string Font_16 = "cn16";
        //private const string Font_16b = "cn16b";
        //public static Dictionary<string, Font2Font> FontList = new Dictionary<string, Font2Font>();
        //// Methods
        //public static void loadFontList()
        //{
        //    string[] strArray = new string[] { "cn10", "cn12", "cn14", "cn14b", "cn16", "cn16b" };
        //    foreach (string str in strArray)
        //    {
        //        Font2Font font = new Font2Font();
        //        font.Load(str);
        //        FontList.Add(str, font);
        //    }
        //}
        //private static Dictionary<string, SpriteFontMultiple.SpriteFontInstance> SSList = new Dictionary<string, SpriteFontMultiple.SpriteFontInstance>();
        public static void getFontInfoRich(SpriteTextRich ST)
        {
            return;
               // if (FontList.Count == 0)
               // {
               //     loadFontList();
               // }

               //// Debug.LogWarning("[xFont:getFontInfoRich]font.name:" + ST.font.name);
               // for (int i = 0; i < ST.font.fonts.Length; i++)
               // {

               //     string str = "";
               //     switch (ST.font.fonts[i].fontText.name)
               //     {
               //         case "Arial, Fancy":
               //             str = "cn12";
               //             break;

               //         case "Arial10":
               //             str = "cn10";
               //             break;

               //         case "Arial11":
               //             str = "cn10";
               //             break;

               //         case "Arial12":
               //             str = "cn12";
               //             break;

               //         case "Arial14":
               //             str = "cn14";
               //             break;

               //         case "Arial14Bold":
               //             str = "cn14b";
               //             break;

               //         case "Arial16":
               //             str = "cn16";
               //             break;

               //         case "Arial16_Mk2":
               //             str = "cn16b";
               //             break;

               //         case "Calibri12":
               //             str = "cn12";
               //             break;

               //         case "Calibri14":
               //             str = "cn14";
               //             break;

               //         case "Calibri16":
               //             str = "cn16";
               //             break;

               //         default:
               //             str = "cn12";
               //             Debug.LogWarning("[xFont]" + ST.font.name + " is Null");
               //             break;
               //     }
               //     if (ST.font.fonts[i].fontText.name != str)
               //     {
               //         Debug.Log("[xFont]font[" + i.ToString() + "].name:" + ST.font.fonts[i].name);

               //         Debug.Log("[xFont]font[" + i.ToString() + "].material.name:" + ST.font.fonts[i].material.name);
               //         Debug.Log("[xFont]font[" + i.ToString() + "].fontText.name:" + ST.font.fonts[i].fontText.name);

               //         ST.font.fonts[i].fontText = FontList[str].fontDef;
               //         ST.font.fonts[i].material = FontList[str].fontMat;
               //         //if (SSList.ContainsKey(str) == false)
               //         //{
               //         //    SpriteFont sf = new SpriteFont(FontList[str].fontDef);
               //         //    SpriteFontMultiple.SpriteFontInstance ss = new SpriteFontMultiple.SpriteFontInstance();
               //         //    ss.SpriteFont = sf;
               //         //    ss.material = FontList[str].fontMat;
               //         //    SSList.Add(str, ss);
               //         //}
               //         //ST.font.fonts[i] = SSList[str];

               //         Debug.Log("[xFont]font[" + i.ToString() + "].name:" + str + " - OK");
               //     }
               // }
        }
예제 #9
0
파일: xFont.cs 프로젝트: zoutianxia/KSP_zh
        // Fields
        //private const string Font_10 = "cn10";
        //private const string Font_12 = "cn12";
        //private const string Font_14 = "cn14";
        //private const string Font_14b = "cn14b";
        //private const string Font_16 = "cn16";
        //private const string Font_16b = "cn16b";
        //public static Dictionary<string, Font2Font> FontList = new Dictionary<string, Font2Font>();

        //// Methods
        //public static void loadFontList()
        //{
        //    string[] strArray = new string[] { "cn10", "cn12", "cn14", "cn14b", "cn16", "cn16b" };
        //    foreach (string str in strArray)
        //    {
        //        Font2Font font = new Font2Font();
        //        font.Load(str);
        //        FontList.Add(str, font);
        //    }
        //}


        //private static Dictionary<string, SpriteFontMultiple.SpriteFontInstance> SSList = new Dictionary<string, SpriteFontMultiple.SpriteFontInstance>();

        public static void getFontInfoRich(SpriteTextRich ST)
        {
            return;
            // if (FontList.Count == 0)
            // {
            //     loadFontList();
            // }

            //// Debug.LogWarning("[xFont:getFontInfoRich]font.name:" + ST.font.name);
            // for (int i = 0; i < ST.font.fonts.Length; i++)
            // {

            //     string str = "";
            //     switch (ST.font.fonts[i].fontText.name)
            //     {
            //         case "Arial, Fancy":
            //             str = "cn12";
            //             break;

            //         case "Arial10":
            //             str = "cn10";
            //             break;

            //         case "Arial11":
            //             str = "cn10";
            //             break;

            //         case "Arial12":
            //             str = "cn12";
            //             break;

            //         case "Arial14":
            //             str = "cn14";
            //             break;

            //         case "Arial14Bold":
            //             str = "cn14b";
            //             break;

            //         case "Arial16":
            //             str = "cn16";
            //             break;

            //         case "Arial16_Mk2":
            //             str = "cn16b";
            //             break;

            //         case "Calibri12":
            //             str = "cn12";
            //             break;

            //         case "Calibri14":
            //             str = "cn14";
            //             break;

            //         case "Calibri16":
            //             str = "cn16";
            //             break;

            //         default:
            //             str = "cn12";
            //             Debug.LogWarning("[xFont]" + ST.font.name + " is Null");
            //             break;
            //     }
            //     if (ST.font.fonts[i].fontText.name != str)
            //     {
            //         Debug.Log("[xFont]font[" + i.ToString() + "].name:" + ST.font.fonts[i].name);

            //         Debug.Log("[xFont]font[" + i.ToString() + "].material.name:" + ST.font.fonts[i].material.name);
            //         Debug.Log("[xFont]font[" + i.ToString() + "].fontText.name:" + ST.font.fonts[i].fontText.name);

            //         ST.font.fonts[i].fontText = FontList[str].fontDef;
            //         ST.font.fonts[i].material = FontList[str].fontMat;
            //         //if (SSList.ContainsKey(str) == false)
            //         //{
            //         //    SpriteFont sf = new SpriteFont(FontList[str].fontDef);
            //         //    SpriteFontMultiple.SpriteFontInstance ss = new SpriteFontMultiple.SpriteFontInstance();
            //         //    ss.SpriteFont = sf;
            //         //    ss.material = FontList[str].fontMat;
            //         //    SSList.Add(str, ss);
            //         //}
            //         //ST.font.fonts[i] = SSList[str];

            //         Debug.Log("[xFont]font[" + i.ToString() + "].name:" + str + " - OK");
            //     }
            // }
        }