Example #1
0
        void setdefaultpos()
        {
            CSLStatsPanelConfigSettings.mySavedFloat windowx  = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.windowx : CSLStatsPanelConfigSettings.miniwindowx,
                                                     windowy  = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.windowy : CSLStatsPanelConfigSettings.miniwindowy,
                                                     windoww  = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.windoww : CSLStatsPanelConfigSettings.miniwindoww,
                                                     windowh  = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.windowh : CSLStatsPanelConfigSettings.miniwindowh;
            CSLStatsPanelConfigSettings.mySavedInt fontchange = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.fontchange : CSLStatsPanelConfigSettings.minifontchange;


            this.position = new Vector3(windowx.value, windowy.value, this.position.z);
            this.width    = windoww.value;
            this.height   = windowh.value;
            if (this.width == 0)
            {
                this.width = 700;
            }
            if (this.height == 0)
            {
                this.height = 400;
            }

            myStatsWindowPanel.width  = this.width;
            myStatsWindowPanel.height = this.height - headerpanel.height - myresizepanel.height;

            if (fontchange.value < minfontsize)
            {
                fontchange.value = minfontsize;
            }
            if (fontchange.value > maxfontsize)
            {
                fontchange.value = maxfontsize;
            }
            foreach (KeyValuePair <string, CSLStatusWindowSubPanel> subpanel in myStatsWindowPanel.m_categories)
            {
                foreach (CSLStatsPanelLabel l in subpanel.Value.m_textfields)
                {
                    l.textScale += fontincr * fontchange.value;
                }
                if (subpanel.Value.spritepanel != null)
                {
                    UIPanel  sp = subpanel.Value.GetComponentInChildren <UIPanel>();
                    UISprite s  = subpanel.Value.GetComponentInChildren <UISprite>();
                    UILabel  l  = subpanel.Value.GetComponentInChildren <UILabel>();
                    l.padding = new RectOffset(l.padding.left + (1 * fontchange.value), l.padding.right, l.padding.top, l.padding.bottom);
                    s.width  += 1 * fontchange.value;
                    s.height += 1 * fontchange.value;
                    //sp.FitChildrenHorizontally();
                    //sp.FitToContents();
                }

                subpanel.Value.FitToContents();
            }
            OnSizeChanged();
        }
Example #2
0
 protected override void OnMouseWheel(UIMouseEventParameter p)
 {
     CSLStatsPanelConfigSettings.mySavedInt fontchange = (!CSLStatsPanelConfigSettings.m_MiniMode.value) ? CSLStatsPanelConfigSettings.fontchange : CSLStatsPanelConfigSettings.minifontchange;
     if (!zooming)
     {
         float wd = p.wheelDelta;
         if (wd < 0)
         {
             if (fontchange.value <= minfontsize)
             {
                 return;
             }
             fontchange.value--;
         }
         if (wd > 0)
         {
             if (fontchange.value >= maxfontsize)
             {
                 return;
             }
             fontchange.value++;
         }
         zooming = true;
         foreach (KeyValuePair <string, CSLStatusWindowSubPanel> subpanel in myStatsWindowPanel.m_categories)
         {
             if (subpanel.Value.spritepanel != null)
             {
                 UISprite s = subpanel.Value.spritepanel.GetComponentInChildren <UISprite>();
                 s.width  += (wd > 0) ? 1 : -1;
                 s.height += (wd > 0) ? 1 : -1;
                 UILabel l = subpanel.Value.GetComponentInChildren <UILabel>();
                 l.padding = new RectOffset(l.padding.left + ((wd > 0) ? 1 : -1), l.padding.right, l.padding.top, l.padding.bottom);
             }
             foreach (CSLStatsPanelLabel l in subpanel.Value.m_textfields)
             {
                 if (wd < 0)
                 {
                     l.textScale -= fontincr;
                 }
                 else
                 {
                     l.textScale += fontincr;
                 }
             }
             subpanel.Value.spritepanel.FitToContents();
             subpanel.Value.FitToContents();
             subpanel.Value.Update();
         }
     }
     this.Update();
     zooming = false;
     base.OnMouseWheel(p);
 }