コード例 #1
0
ファイル: ConfigWindow.cs プロジェクト: pilnomi/CSLStatsPanel
        void catsubpanel_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            bool isCatActive = !CSLStatsPanelConfigSettings.isCatActive(component.name);

            CSLStatsPanelConfigSettings.setCatActive(component.name, isCatActive);
            CSLStatsPanelConfigSettings.m_ConfigChanged.value = true;

            UIButton b = (UIButton)component;

            b.textColor    = (isCatActive) ? selectedcolor : deselectedcolor;
            b.focusedColor = (isCatActive) ? selectedcolor : deselectedcolor;
            b.parent.Focus();

            component.color        = (isCatActive) ? selectedcolor : deselectedcolor;
            component.parent.color = component.color;
        }
コード例 #2
0
ファイル: ConfigWindow.cs プロジェクト: pilnomi/CSLStatsPanel
        void statsubpanel_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            string[] mystring     = component.name.Split('|');
            bool     isStatActive = !CSLStatsPanelConfigSettings.isStatActive(mystring[0], mystring[1]);

            CSLStatsPanelConfigSettings.setStatActive(mystring[0], mystring[1], isStatActive);
            CSLStatsPanelConfigSettings.m_ConfigChanged.value = true;

            UIButton b = (UIButton)component;

            b.textColor        = (isStatActive) ? selectedcolor : deselectedcolor;
            b.focusedColor     = b.textColor;
            b.focusedTextColor = b.textColor;
            b.parent.Focus();

            component.color = (isStatActive) ? selectedcolor : deselectedcolor;
            //component.parent.color = component.color;
            //eventStatsConfigChanged(this, EventArgs.Empty);
        }
コード例 #3
0
ファイル: ConfigWindow.cs プロジェクト: pilnomi/CSLStatsPanel
        UIPanel drawstatsconfigpanel(StatisticsCategoryWrapper scw)
        {
            UIPanel catsubpanel = this.AddUIComponent <UIPanel>();

            catpanels.Add(catsubpanel);
            catsubpanel.autoLayout          = true;
            catsubpanel.wrapLayout          = true;
            catsubpanel.autoLayoutDirection = LayoutDirection.Horizontal;
            catsubpanel.width            = this.width - 5;
            catsubpanel.backgroundSprite = "GenericPanel";
            //catsubpanel.height = 15;
            catsubpanel.autoLayoutPadding = new RectOffset(3, 3, 3, 3);

            bool     catisChecked = CSLStatsPanelConfigSettings.isCatActive(scw.m_category);
            UIButton catname      = catsubpanel.AddUIComponent <UIButton>();

            catname.textColor = (catisChecked) ? selectedcolor : deselectedcolor;
            setcommonbuttonprops(catname);
            catname.autoSize  = true;
            catname.text      = scw.m_category;
            catname.name      = scw.m_category;
            catsubpanel.color = (catisChecked) ? selectedcolor : deselectedcolor;

            catsubpanel.autoSize = true;
            catname.eventClick  += new MouseEventHandler(catsubpanel_eventClick);

            for (int x = 0; x < scw.m_scwlist.Count(); x++)
            {
                bool     isStatActive = CSLStatsPanelConfigSettings.isStatActive(scw.m_category, scw.m_scwlist[x].m_desc);
                UIButton statname     = catsubpanel.AddUIComponent <UIButton>();
                statname.name = scw.m_category + "|" + scw.m_scwlist[x].m_desc;

                statname.color     = (isStatActive) ? selectedcolor : deselectedcolor;
                statname.textColor = (isStatActive) ? selectedcolor : deselectedcolor;
                setcommonbuttonprops(statname);
                statname.text        = scw.m_scwlist[x].m_desc;
                statname.eventClick += new MouseEventHandler(statsubpanel_eventClick);
            }
            catsubpanel.FitChildrenVertically();


            return(catsubpanel);
        }
コード例 #4
0
 public static void updateText()
 {
     if (cacheddata == null)
     {
         try
         {
             cacheddata = CSLStatsPanelConfigSettings.Categories(true);
         }
         catch { return; }
     }
     if (myStatsWindowPanel == null)
     {
         if (doReset)
         {
             doReset = false;
             statButton_eventClick(null, null);
         }
         else
         {
             return;
         }
     }
     if (!initialized)
     {
         return;
     }
     if (running)
     {
         return;
     }
     running = true;
     try
     {
         myStatsWindowPanel.updateText(cacheddata);
         myStatsWindowPanel.Update();
     }
     finally
     {
         running = false;
     }
 }
コード例 #5
0
ファイル: ConfigWindow.cs プロジェクト: pilnomi/CSLStatsPanel
 void resetConfig_eventClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     try
     {
         CSLStatsPanelConfigSettings.resetConfig();
         string mydocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
         if (System.IO.File.Exists(mydocs + "\\CSLStatsPanel\\CSLStatsPanelConfig.xml"))
         {
             System.IO.File.Delete(mydocs + "\\CSLStatsPanel\\CSLStatsPanelConfig.xml");
         }
         if (System.IO.Directory.GetFiles(mydocs + "\\CSLStatsPanel").Count() == 0)
         {
             System.IO.Directory.Delete(mydocs + "\\CSLStatsPanel");
         }
         CSLStatsPanelConfigSettings.m_ConfigChanged.value = true;
         UIView.DestroyImmediate(this.parent);
     }
     catch (Exception Ex)
     {
         statlog.log("resetConfig: " + Ex.Message);
     }
 }
コード例 #6
0
 void refreshtimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     refreshtimer.Stop();
     try
     {
         StatusWindowInterface.cacheddata = CSLStatsPanelConfigSettings.Categories(true);
     }
     catch (Exception ex)
     {
         statlog.log("refreshtimer_elapsed: " + ex.Message);
     }
     finally
     {
         int myrefreshrate = CSLStatsPanelConfigSettings.PanelRefreshRate;
         refreshtimer.Interval = myrefreshrate * 1000 - 10;
         if (refreshtimer.Interval < 990)
         {
             refreshtimer.Interval = 990;
         }
         refreshtimer.Start();
     }
 }
コード例 #7
0
ファイル: ConfigWindow.cs プロジェクト: pilnomi/CSLStatsPanel
        void drawstatsconfig()
        {
            UIScrollablePanel p = this.AddUIComponent <UIScrollablePanel>();

            p.autoLayoutDirection = LayoutDirection.Horizontal;
            p.autoLayout          = true;
            p.backgroundSprite    = "GenericPanel";

            refreshIntervalLabel      = p.AddUIComponent <UILabel>();
            refreshIntervalLabel.text = "Refresh Interval (sec): ";
            refreshInterval           = p.AddUIComponent <UITextField>();
            refreshInterval.Enable();
            refreshInterval.text             = CSLStatsPanelConfigSettings.PanelRefreshRate.ToString();
            refreshInterval.numericalOnly    = true;
            refreshInterval.eventLeaveFocus += new FocusEventHandler(refreshInterval_eventLeaveFocus);

            UIButton decrementLabel = p.AddUIComponent <UIButton>();

            setcommonbuttonprops(decrementLabel);
            decrementLabel.width       = 5;
            decrementLabel.text        = "-";
            decrementLabel.eventClick += new MouseEventHandler(decrementLabel_eventClick);
            UIButton incrementLabel = p.AddUIComponent <UIButton>();

            setcommonbuttonprops(incrementLabel);
            incrementLabel.width       = 5;
            incrementLabel.text        = "+";
            incrementLabel.eventClick += new MouseEventHandler(incrementLabel_eventClick);


            p.FitChildrenHorizontally();
            p.FitToContents();

            UIPanel pOptions = this.AddUIComponent <UIPanel>();

            catpanels.Add(pOptions);

            pOptions.autoLayout          = true;
            pOptions.wrapLayout          = true;
            pOptions.autoLayoutDirection = LayoutDirection.Horizontal;
            pOptions.width             = this.width - 5;
            pOptions.autoLayoutPadding = new RectOffset(3, 3, 3, 3);

            useColors = pOptions.AddUIComponent <UIButton>();
            setcommonbuttonprops(useColors);
            useColors.text        = "Use Panel Colors";
            useColors.tooltip     = "Think colors are over-rated?  Toggle them on/off";
            useColors.eventClick += new MouseEventHandler(useColors_eventClick);
            useColors.textColor   = (CSLStatsPanelConfigSettings.m_EnablePanelColors.value) ? selectedcolor : deselectedcolor;

            UIButton displaySummaries = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(displaySummaries);
            displaySummaries.text        = "% Summaries";
            displaySummaries.tooltip     = "Toggle display of % summaries in expanded mode.";
            displaySummaries.textColor   = (CSLStatsPanelConfigSettings.m_EnablePanelSummaries.value) ? selectedcolor : deselectedcolor;
            displaySummaries.eventClick += new MouseEventHandler(displaySummaries_eventClick);

            UIButton miniMode = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(miniMode);
            miniMode.text        = "Mini-Mode";
            miniMode.textColor   = (CSLStatsPanelConfigSettings.m_MiniMode.value) ? selectedcolor : deselectedcolor;
            miniMode.eventClick += new MouseEventHandler(miniMode_eventClick);

            UIButton showLabelsInMiniMode = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(showLabelsInMiniMode);
            showLabelsInMiniMode.text        = "Labels in Mini-Mode";
            showLabelsInMiniMode.tooltip     = "Show service description labels while in mini-mode, turn this off to see only the icons";
            showLabelsInMiniMode.autoSize    = true;
            showLabelsInMiniMode.textColor   = (CSLStatsPanelConfigSettings.m_ShowLabelsInMiniMode.value) ? selectedcolor : deselectedcolor;
            showLabelsInMiniMode.eventClick += new MouseEventHandler(showLabelsInMiniMode_eventClick);

            UIButton enableTransparency = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(enableTransparency);
            enableTransparency.text        = "Transparency";
            enableTransparency.textColor   = (CSLStatsPanelConfigSettings.m_EnableTransparency.value) ? selectedcolor : deselectedcolor;
            enableTransparency.eventClick += new MouseEventHandler(enableTransparency_eventClick);

            UIButton useVehicleStatsInSummaries = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(useVehicleStatsInSummaries);
            useVehicleStatsInSummaries.text        = "Vehicle Usage";
            useVehicleStatsInSummaries.tooltip     = "Use vehicle inuse/total on Summary % when it is higher than default used/capacity (excludes police)";
            useVehicleStatsInSummaries.textColor   = (CSLStatsPanelConfigSettings.m_UseVechileStatsForSummaries.value) ? selectedcolor : deselectedcolor;
            useVehicleStatsInSummaries.eventClick += new MouseEventHandler(useVehicleStatsInSummaries_eventClick);

            UIButton resetConfig = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(resetConfig);
            resetConfig.text        = "Reset Config";
            resetConfig.textColor   = resetConfig.focusedTextColor;
            resetConfig.eventClick += new MouseEventHandler(resetConfig_eventClick);


            UIButton customizeXMLConfig = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(customizeXMLConfig);
            customizeXMLConfig.text        = "Custom XML Config";
            customizeXMLConfig.tooltip     = "Creates or opens a copy config file for you to customize stats further.";
            customizeXMLConfig.autoSize    = true;
            customizeXMLConfig.textColor   = customizeXMLConfig.focusedTextColor;
            customizeXMLConfig.eventClick += customizeXMLConfig_eventClick;

            UIButton reloadXMLConfig = pOptions.AddUIComponent <UIButton>();

            setcommonbuttonprops(reloadXMLConfig);
            reloadXMLConfig.text        = "Reload XML Config";
            reloadXMLConfig.tooltip     = "Reload your custom XML config without having to reload your game.";
            reloadXMLConfig.autoSize    = true;
            reloadXMLConfig.textColor   = customizeXMLConfig.focusedTextColor;
            reloadXMLConfig.eventClick += reloadXMLConfig_eventClick;

            pOptions.autoSize = true;
            pOptions.FitChildrenVertically();

            if (ThreadingCSLStatsMod.xmlconfigerror)
            {
                UIPanel pConfigError = this.AddUIComponent <UIPanel>();
                //catpanels.Add(pWarning);

                pConfigError.autoLayout          = true;
                pConfigError.wrapLayout          = true;
                pConfigError.autoLayoutDirection = LayoutDirection.Horizontal;
                pConfigError.width = this.width - 5;

                pConfigError.autoLayoutPadding = new RectOffset(3, 3, 3, 3);
                UILabel customXmlConfigVersionWarning = pConfigError.AddUIComponent <UILabel>();
                customXmlConfigVersionWarning.text = ""
                                                     + "Error: Unable to load your custom configuration file.  Please check the file for errors, or Reset Config to defaults.";
                customXmlConfigVersionWarning.textColor = customizeXMLConfig.focusedTextColor;
                pConfigError.autoSize = true;
                pConfigError.FitChildrenVertically();
            }

            if (ThreadingCSLStatsMod.loadedXMLConfigVersion != ThreadingCSLStatsMod.defaultXMLConfigVersion)
            {
                UIPanel pWarning = this.AddUIComponent <UIPanel>();
                //catpanels.Add(pWarning);

                pWarning.autoLayout          = true;
                pWarning.wrapLayout          = true;
                pWarning.autoLayoutDirection = LayoutDirection.Horizontal;
                pWarning.width = this.width - 5;

                pWarning.autoLayoutPadding = new RectOffset(3, 3, 3, 3);
                UILabel customXmlConfigVersionWarning = pWarning.AddUIComponent <UILabel>();
                customXmlConfigVersionWarning.text = ""
                                                     + "Warning: Your config file is version \"" + ThreadingCSLStatsMod.loadedXMLConfigVersion + "\""
                                                     + " a new version is available: \"" + ThreadingCSLStatsMod.defaultXMLConfigVersion + "\".";
                customXmlConfigVersionWarning.textColor = customizeXMLConfig.focusedTextColor;
                customXmlConfigVersionWarning           = pWarning.AddUIComponent <UILabel>();
                customXmlConfigVersionWarning.text      = ""
                                                          + " You may be missing new stats / features that have been added, but reseting will remove your customizations";
                customXmlConfigVersionWarning.textColor = customizeXMLConfig.focusedTextColor;
                pWarning.autoSize = true;
                pWarning.FitChildrenVertically();
            }



            List <StatisticsCategoryWrapper> scw = CSLStatsPanelConfigSettings.Categories(false);

            for (int i = 0; i < scw.Count(); i++)
            {
                drawstatsconfigpanel(scw[i]);
            }
        }