Ejemplo n.º 1
0
        /// <summary>
        /// Creates our renderer GameObject.
        /// </summary>
        internal static void Create()
        {
            try
            {
                // If no instance already set, create one.
                if (gameObject == null)
                {
                    // Give it a unique name for easy finding with ModTools.
                    gameObject = new GameObject("RICOThumbnailRenderer");
                    gameObject.transform.parent = UIView.GetAView().transform;

                    // Add our queue manager and renderer directly to the gameobject.
                    _renderer  = gameObject.AddComponent <UIPreviewRenderer>();
                    _generator = new ThumbnailGenerator();
                }
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 2
0
 public static C Load()
 {
     if (instance == null)
     {
         var           configPath    = GetConfigPath();
         XmlSerializer xmlSerializer = new XmlSerializer(typeof(C));
         try
         {
             if (File.Exists(configPath))
             {
                 using (StreamReader streamReader = new System.IO.StreamReader(configPath))
                 {
                     instance = xmlSerializer.Deserialize(streamReader) as C;
                 }
             }
         }
         catch (Exception e)
         {
             Debugging.LogException(e);
         }
     }
     return(instance ?? (instance = new C()));
 }
Ejemplo n.º 3
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("PloppableRICOOptionsPanel");

                // 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 GrowableOptions(tabStrip, 0);
                new ComplaintOptions(tabStrip, 1);
                new ModOptions(tabStrip, 2);
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
        /// <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
            {
                // Y position counter.
                float currentY = 0;

                // 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";

                // Put this behind other panels.
                zOrder = 2;

                // Title.
                AddText("Ploppable RICO Revisited", spacing, spacing, 1.0f);

                // Note 1.
                if (!headerText.IsNullOrWhiteSpace())
                {
                    currentY = AddText(headerText, spacing, 40);
                }

                // Note 2.
                if (!messageText.IsNullOrWhiteSpace())
                {
                    currentY = AddText(messageText, spacing * 2, currentY + 20);
                }

                // Note 3.
                if (!listText.IsNullOrWhiteSpace())
                {
                    currentY = AddText(listText, spacing * 4, currentY + 20);
                }

                // Auto resize panel to accomodate note.
                this.height = currentY + 60;

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

                // Event handler.
                closeButton.eventClick += (control, clickEvent) =>
                {
                    // Just hide this panel and destroy the game object - nothing more to do this load.
                    this.Hide();
                    GameObject.Destroy(uiGameObject);
                };
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Performs initial setup for the 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
            {
                // Hide while we're setting up.
                isVisible = false;

                // Basic setup.
                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);

                // Event handler to dealth with changes to filtering.
                filterBar.eventFilteringChanged += (component, value) =>
                {
                    if (value == -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 - checkFilterHeight;
                leftPanel.relativePosition = new Vector3(spacing, titleHeight + filterHeight + checkFilterHeight + 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();

                savePanel                  = middlePanel.AddUIComponent <UISavePanel>();
                savePanel.width            = middlePanel.width;
                savePanel.height           = (panelHeight - spacing) / 2;
                savePanel.relativePosition = new Vector3(0, previewPanel.height + spacing);
                savePanel.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);

                buildingOptionsPanel                  = rightPanel.AddUIComponent <UIBuildingOptions>();
                buildingOptionsPanel.width            = rightWidth;
                buildingOptionsPanel.height           = panelHeight;
                buildingOptionsPanel.relativePosition = Vector3.zero;
                buildingOptionsPanel.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>();

                // 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);
            }
        }