コード例 #1
0
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        private static void Create()
        {
            try
            {
                // We're now visible - create our gameobject, and give it a unique name for easy finding with ModTools.
                optionsGameObject = new GameObject("RealPopOptionsPanel");

                // Attach to game options panel.
                optionsGameObject.transform.parent = optionsPanel.transform;

                // Create a base panel attached to our game object, perfectly overlaying the game options panel.
                UIPanel basePanel = optionsGameObject.AddComponent <UIPanel>();
                basePanel.absolutePosition = optionsPanel.absolutePosition;
                basePanel.size             = optionsPanel.size;

                // Add tabstrip.
                UITabstrip tabStrip = basePanel.AddUIComponent <UITabstrip>();
                tabStrip.relativePosition = new Vector3(0, 0);
                tabStrip.size             = new Vector2(744, 713);

                // Tab container (the panels underneath each tab).
                UITabContainer tabContainer = basePanel.AddUIComponent <UITabContainer>();
                tabContainer.relativePosition = new Vector3(0, 40);
                tabContainer.size             = new Vector3(744, 713);
                tabStrip.tabPages             = tabContainer;

                // Add tabs and panels.
                new ModOptionsPanel(tabStrip, 0);
                new ResidentialPanel(tabStrip, 1);
                new IndustrialPanel(tabStrip, 2);
                new CommercialPanel(tabStrip, 3);
                new OfficePanel(tabStrip, 4);
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates the panel object in-game.
        /// </summary>
        public void Create()
        {
            try
            {
                // Destroy existing (if any) instances.
                uiGameObject = GameObject.Find("RealPopUpgradeNotification");
                if (uiGameObject != null)
                {
                    Debugging.Message("found existing upgrade notification instance");
                    GameObject.Destroy(uiGameObject);
                }

                // Create new instance.
                // Give it a unique name for easy finding with ModTools.
                uiGameObject = new GameObject("RealPopUpgradeNotification");
                uiGameObject.transform.parent = UIView.GetAView().transform;
                _instance = uiGameObject.AddComponent <UpdateNotification>();
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
コード例 #3
0
        /// <summary>
        /// Create the update notification panel; called by Unity just before any of the Update methods is called for the first time.
        /// </summary>
        public override void Start()
        {
            base.Start();

            try
            {
                // Basic setup.
                isVisible        = true;
                canFocus         = true;
                isInteractive    = true;
                width            = panelWidth;
                height           = panelHeight;
                relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));
                backgroundSprite = "UnlockingPanel2";

                // Title.
                UILabel title = this.AddUIComponent <UILabel>();
                title.relativePosition = new Vector3(0, spacing);
                title.textAlignment    = UIHorizontalAlignment.Center;
                title.text             = "Realistic Population Revisited 1.3 update";
                title.textScale        = 1.0f;
                title.autoSize         = false;
                title.width            = this.width;

                // Note 1.
                UILabel note1 = this.AddUIComponent <UILabel>();
                note1.relativePosition = new Vector3(spacing, 40);
                note1.textAlignment    = UIHorizontalAlignment.Left;
                note1.text             = "Realistic Population Revisited has been updated to 1.3.  This update adds a mod options panel (accessible through the options menu) that enables direct editing of all key configuration options for population, jobs, and consumption calculations.";
                note1.textScale        = 0.8f;
                note1.autoSize         = false;
                note1.autoHeight       = true;
                note1.width            = this.width - (spacing * 2);
                note1.wordWrap         = true;

                // Close button.
                UIButton closeButton = UIUtils.CreateButton(this, 200);
                closeButton.relativePosition = new Vector3(spacing, this.height - closeButton.height - spacing);
                closeButton.text             = "Close";
                closeButton.Enable();

                // Event handler.
                closeButton.eventClick += (c, p) =>
                {
                    // Just hide this panel and destroy the game object - nothing more to do this load.
                    this.Hide();
                    GameObject.Destroy(uiGameObject);
                };

                // "Don't show again" button.
                UIButton noShowButton = UIUtils.CreateButton(this, 200);
                noShowButton.relativePosition = new Vector3(this.width - noShowButton.width - spacing, this.height - closeButton.height - spacing);
                noShowButton.text             = "Don't show again";
                noShowButton.Enable();

                // Event handler.
                noShowButton.eventClick += (c, p) =>
                {
                    // Save settings.
                    notificationVersion = 2;
                    SettingsUtils.SaveSettings();

                    // Just hide this panel and destroy the game object - nothing more to do.
                    this.Hide();
                    GameObject.Destroy(uiGameObject);
                };
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
コード例 #4
0
        /// <summary>
        /// Create the building editor panel; we no longer use Start() as that's not sufficiently reliable (race conditions), and is no longer needed, with the new create/destroy process.
        /// </summary>
        internal void Setup()
        {
            try
            {
                // Basic setup.
                isVisible        = false;
                canFocus         = true;
                isInteractive    = true;
                width            = LeftWidth + MiddleWidth + RightWidth + (Spacing * 4);
                height           = PanelHeight + TitleHeight + FilterHeight + (Spacing * 2) + BottomMargin;
                relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));
                backgroundSprite = "UnlockingPanel2";

                // Titlebar.
                titleBar = AddUIComponent <UITitleBar>();
                titleBar.Setup();

                // Filter.
                filterBar                  = AddUIComponent <UIBuildingFilter>();
                filterBar.width            = width - (Spacing * 2);
                filterBar.height           = FilterHeight;
                filterBar.relativePosition = new Vector3(Spacing, TitleHeight);

                filterBar.eventFilteringChanged += (c, i) =>
                {
                    if (i == -1)
                    {
                        return;
                    }

                    int   listCount = buildingSelection.rowsData.m_size;
                    float position  = buildingSelection.listPosition;

                    buildingSelection.selectedIndex = -1;

                    buildingSelection.rowsData = GenerateFastList();
                };

                // Set up panels.
                // Left panel - list of buildings.
                UIPanel leftPanel = AddUIComponent <UIPanel>();
                leftPanel.width            = LeftWidth;
                leftPanel.height           = PanelHeight;
                leftPanel.relativePosition = new Vector3(Spacing, TitleHeight + FilterHeight + Spacing);

                // Middle panel - building preview and edit panels.
                UIPanel middlePanel = AddUIComponent <UIPanel>();
                middlePanel.width            = MiddleWidth;
                middlePanel.height           = PanelHeight;
                middlePanel.relativePosition = new Vector3(LeftWidth + (Spacing * 2), TitleHeight + FilterHeight + Spacing);

                previewPanel                  = middlePanel.AddUIComponent <UIPreviewPanel>();
                previewPanel.width            = middlePanel.width;
                previewPanel.height           = (PanelHeight - Spacing) / 2;
                previewPanel.relativePosition = Vector3.zero;
                previewPanel.Setup();

                editPanel                  = middlePanel.AddUIComponent <UIEditPanel>();
                editPanel.width            = middlePanel.width;
                editPanel.height           = (PanelHeight - Spacing) / 2;
                editPanel.relativePosition = new Vector3(0, previewPanel.height + Spacing);
                editPanel.Setup();

                // Right panel - mod calculations.
                UIPanel rightPanel = AddUIComponent <UIPanel>();
                rightPanel.width            = RightWidth;
                rightPanel.height           = PanelHeight;
                rightPanel.relativePosition = new Vector3(LeftWidth + MiddleWidth + (Spacing * 3), TitleHeight + FilterHeight + Spacing);

                modCalcs                  = rightPanel.AddUIComponent <UIModCalcs>();
                modCalcs.width            = RightWidth;
                modCalcs.height           = PanelHeight;
                modCalcs.relativePosition = Vector3.zero;
                modCalcs.Setup();

                // Building selection list.
                buildingSelection = UIFastList.Create <UIBuildingRow>(leftPanel);
                buildingSelection.backgroundSprite  = "UnlockingPanel";
                buildingSelection.width             = leftPanel.width;
                buildingSelection.height            = leftPanel.height;
                buildingSelection.canSelect         = true;
                buildingSelection.rowHeight         = 40;
                buildingSelection.autoHideScrollbar = true;
                buildingSelection.relativePosition  = Vector3.zero;
                buildingSelection.rowsData          = new FastList <object>();
                buildingSelection.selectedIndex     = -1;

                // Set up filterBar to make sure selection filters are properly initialised before calling GenerateFastList.
                filterBar.Setup();

                // Populate the list.
                buildingSelection.rowsData = GenerateFastList();
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
コード例 #5
0
        /// <param name="doc"></param>
        public override void readXML(XmlDocument doc)
        {
            XmlElement root = doc.DocumentElement;

            try
            {
                //DataStore.enableExperimental = Convert.ToBoolean(root.Attributes["experimental"].InnerText);
                //DataStore.timeBasedRealism = Convert.ToBoolean(root.Attributes["enableTimeVariation"].InnerText);
            }
            catch (Exception)
            {
                DataStore.enableExperimental = false;
            }

            foreach (XmlNode node in root.ChildNodes)
            {
                try
                {
                    if (node.Name.Equals(popNodeName))
                    {
                        ReadPopulationNode(node);
                    }
                    else if (node.Name.Equals(consumeNodeName))
                    {
                        ReadConsumptionNode(node);
                    }
                    else if (node.Name.Equals(visitNodeName))
                    {
                        ReadVisitNode(node);
                    }
                    else if (node.Name.Equals(pollutionNodeName))
                    {
                        ReadPollutionNode(node);
                    }
                    else if (node.Name.Equals(productionNodeName))
                    {
                        ReadProductionNode(node);
                    }
                    else if (node.Name.Equals(overrideHouseName))
                    {
                        ReadOverrideHouseNode(node);
                    }
                    else if (node.Name.Equals(overrideWorkName))
                    {
                        ReadOverrideWorkers(node);
                    }
                    else if (node.Name.Equals(bonusHouseName))
                    {
                        ReadBonusHouseNode(node);
                    }
                    else if (node.Name.Equals(bonusWorkName))
                    {
                        ReadBonusWorkers(node);
                    }
                    else if (node.Name.Equals(printHouseName))
                    {
                        ReadPrintHouseNode(node);
                    }
                    else if (node.Name.Equals(printWorkName))
                    {
                        ReadPrintWorkers(node);
                    }
                }
                catch (Exception e)
                {
                    Debugging.LogException(e);
                }
            }
        } // end readXML