示例#1
0
        /// <summary>
        /// Performs initial setup
        /// </summary>
        /// <param name="parentTransform">Parent transform</param>
        /// <param name="targetPrefabInfo">Currently selected target prefab</param>
        internal override void Setup(Transform parentTransform, PrefabInfo targetPrefabInfo)
        {
            try
            {
                // Perform basic panel setup.
                base.Setup(parentTransform, targetPrefabInfo);

                Logging.Message("commencing InfoPanel setup");

                // Replace all button.
                replaceAllButton = AddIconButton(this, MidControlX + replaceButton.width, ReplaceY, BigIconSize, ReplaceAllTooltipKey, ReplaceAllAtlas);
                replaceAllButton.eventClicked += ReplaceAll;

                // Probability.
                UIPanel probabilityPanel = Sliderpanel(this, MidControlX, ProbabilityY, SliderHeight);
                probabilitySlider                = AddBOBSlider(probabilityPanel, 0f, "BOB_PNL_PRB", 0, 100, 1);
                probabilitySlider.TrueValue      = 100f;
                probabilitySlider.LimitToVisible = true;

                // Angle.
                UIPanel anglePanel = Sliderpanel(this, MidControlX, AngleY, SliderHeight);
                angleSlider = AddBOBSlider(anglePanel, 0f, "BOB_PNL_ANG", -180, 180, 1);

                Logging.Message("Creating offset panel");

                // Offset panel.
                UIPanel offsetPanel = Sliderpanel(this, MidControlX, OffsetPanelY, OffsetPanelHeight);
                UILabel offsetLabel = UIControls.AddLabel(offsetPanel, 0f, OffsetLabelY, Translations.Translate("BOB_PNL_OFF"));
                offsetLabel.textAlignment = UIHorizontalAlignment.Center;
                while (offsetLabel.width > MidControlWidth)
                {
                    offsetLabel.textScale -= 0.05f;
                    offsetLabel.PerformLayout();
                }
                offsetLabel.relativePosition = new Vector2((offsetPanel.width - offsetLabel.width) / 2f, OffsetLabelY);

                // Offset sliders.
                xSlider = AddBOBSlider(offsetPanel, XOffsetY, "BOB_PNL_XOF", -8f, 8f, 0.01f);
                ySlider = AddBOBSlider(offsetPanel, YOffsetY, "BOB_PNL_YOF", -8f, 8f, 0.01f);
                zSlider = AddBOBSlider(offsetPanel, ZOffsetY, "BOB_PNL_ZOF", -8f, 8f, 0.01f);

                // Set initial button states.
                UpdateButtonStates();

                // Normal/random toggle.
                randomCheck = UIControls.LabelledCheckBox((UIComponent)(object)this, hideVanilla.relativePosition.x, hideVanilla.relativePosition.y + hideVanilla.height + (Margin / 2f), Translations.Translate("BOB_PNL_RSW"), 12f, 0.7f);
                randomCheck.eventCheckChanged += RandomCheckChanged;

                // Random settings button.
                UIButton randomButton = UIControls.EvenSmallerButton(this, RightX - 200f, TitleHeight + Margin + 20f, Translations.Translate("BOB_PNL_RST"));
                randomButton.eventClicked += (control, clickEvent) => BOBRandomPanel.Create();

                Logging.Message("InfoPanel setup completed");
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception setting up InfoPanel");
            }
        }
示例#2
0
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        internal static void Create()
        {
            try
            {
                // If no GameObject instance already set, create one.
                if (uiGameObject == null)
                {
                    // Give it a unique name for easy finding with ModTools.
                    uiGameObject = new GameObject("BOBRandomPanel");
                    uiGameObject.transform.parent = UIView.GetAView().transform;

                    // Create new panel instance and add it to GameObject.
                    panel = uiGameObject.AddComponent <BOBRandomPanel>();
                    panel.transform.parent = uiGameObject.transform.parent;
                }
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception creating random panel");
            }
        }
示例#3
0
        /// <summary>
        /// Closes the panel by destroying the object (removing any ongoing UI overhead).
        /// </summary>
        internal static void Close()
        {
            // Don't do anything if no panel.
            if (panel == null)
            {
                return;
            }

            // Save configuration file.
            ConfigurationUtils.SaveConfig();

            /*
             * // Need to do this for each building instance, so iterate through all buildings.
             * Building[] buildings = BuildingManager.instance.m_buildings.m_buffer;
             * for (ushort i = 0; i < buildings.Length; ++i)
             * {
             *      // Local reference.
             *      Building building = buildings[i];
             *
             *      // Check that this is a valid building in the dirty list.
             *      if (building.m_flags != Building.Flags.None)
             *      {
             *              // Match - update building render.
             *              BuildingManager.instance.UpdateBuildingRenderer(i, true);
             *      }
             * }*/


            // Destroy game objects.
            GameObject.Destroy(panel);
            GameObject.Destroy(uiGameObject);

            // Let the garbage collector do its work (and also let us know that we've closed the object).
            panel        = null;
            uiGameObject = null;

            // Show previous window, if any.
            InfoPanelManager.Panel?.Show();
        }