Example #1
0
        public void updateText(List <string> TextFields)
        {
            if (!initialized)
            {
                init();
            }
            if (running)
            {
                return;
            }
            running = true;
            string s = ""; bool usesinglefield = false; // <-- work around uses a single label

            for (int i = 0; i < TextFields.Count; i++)
            {
                if (i >= m_textfields.Count && (!usesinglefield || i == 0))
                {
                    m_textfields.Add(this.AddUIComponent <CSLStatsPanelLabel>());
                    m_textfields[i].name = "CSLStatsLabel_" + i.ToString();
                }
                else if (usesinglefield)
                {
                    s += TextFields[i] + "\n";
                }

                if (!usesinglefield)
                {
                    m_textfields[i].text = TextFields[i];
                }
            }

            if (usesinglefield)
            {
                m_textfields[0].text = s;
            }
            if (this.m_issubpanel)  //&& labelsadded)
            {
                if (spritepanel != null)
                {
                    if (firstrun)
                    {
                        spritepanel.FitChildrenHorizontally();
                        spritepanel.FitToContents();
                    }
                }
                //this.FitChildrenVertically();
                if (firstrun)
                {
                    this.FitToContents();
                }
            }
            running = false;
        }
Example #2
0
        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]);
            }
        }