private void ButtonClick(UIComponent uiComponent, UIMouseEventParameter eventParam) {
			if (!_uiShown) {
				Show();
			} else {
				Close();
			}
		}
        public void ChallengeChanged(UIComponent comp, int value)
        {
            m_selectButton.Enable();
            this.m_selectedIndex = value;
            Challenge selectedChallenge = m_challenges [value];
            m_challengeName.text = "Name\n    " + selectedChallenge.Name;
            m_challengeDesc.text = "Description\n    " + selectedChallenge.Description;
            m_challengeBreakdown.text = "Breakdown" + GoalsToString (selectedChallenge.Goals);
            if (selectedChallenge.Rewards != null && selectedChallenge.Rewards.Length >= 0) {
                m_challengeReward.text = "Reward" + RewardsToString (selectedChallenge.Rewards);
            } else {
                m_challengeReward.text = "";
            }

            if (selectedChallenge.Penalties != null && selectedChallenge.Penalties.Length >= 0) {
                m_challengePenalty.text = "Penalty" + RewardsToString (selectedChallenge.Penalties);
            } else {
                m_challengePenalty.text = "";
            }

            if (selectedChallenge.m_hasDeadline){
                m_challengeDeadline.text = "Duration\n    " + selectedChallenge.Years + " years, " + selectedChallenge.Months + " months";
            } else {
                m_challengeDeadline.text = "Duration\n    Unlimited";
            }

            m_challengeName.Enable ();
            m_challengeDesc.Enable ();
            m_challengeBreakdown.Enable ();
            m_challengeReward.Enable ();
            m_challengePenalty.Enable ();
            m_challengeDeadline.Enable ();
            FormatDetails ();
        }
Example #3
0
        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = parent.AddUIComponent<UICheckBox>();

            checkBox.width = parent.width;
            checkBox.height = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent<UISprite>();
            sprite.spriteName = "ToggleBase";
            sprite.size = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent<UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label = checkBox.AddUIComponent<UILabel>();
            checkBox.label.text = " ";
            checkBox.label.textScale = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            return checkBox;
        }
 public static void Init(GameAreaInfoPanel g)
 {
     m_AreaIndex = g.GetType().GetField("m_AreaIndex", BindingFlags.NonPublic | BindingFlags.Instance);
        m_FullscreenContainer = UIView.Find("FullScreenContainer");
        m_Title = g.Find<UILabel>("Title");
        m_BuildableArea = g.Find<UILabel>("BuildableArea");
        m_Price = g.Find<UILabel>("Price");
        m_PurchasePanel = g.Find<UIPanel>("PurchasePanel");
        m_OilResources = g.Find<UIProgressBar>("ResourceBarOil");
        m_OreResources = g.Find<UIProgressBar>("ResourceBarOre");
        m_ForestryResources = g.Find<UIProgressBar>("ResourceBarForestry");
        m_FertilityResources = g.Find<UIProgressBar>("ResourceBarFarming");
        m_OilNoResources = g.Find("ResourceOil").Find<UISprite>("NoNoNo");
        m_OreNoResources = g.Find("ResourceOre").Find<UISprite>("NoNoNo");
        m_ForestryNoResources = g.Find("ResourceForestry").Find<UISprite>("NoNoNo");
        m_FertilityNoResources = g.Find("ResourceFarming").Find<UISprite>("NoNoNo");
        m_Water = g.Find<UISprite>("Water");
        m_NoWater =m_Water.Find<UISprite>("NoNoNo");
        m_Highway = g.Find<UISprite>("Highway");
        m_NoHighway =m_Highway.Find<UISprite>("NoNoNo");
        m_InHighway =m_Highway.Find<UISprite>("Incoming");
        m_OutHighway =m_Highway.Find<UISprite>("Outgoing");
        m_Train = g.Find<UISprite>("Train");
        m_NoTrain =m_Train.Find<UISprite>("NoNoNo");
        m_InTrain =m_Train.Find<UISprite>("Incoming");
        m_OutTrain =m_Train.Find<UISprite>("Outgoing");
        m_Ship = g.Find<UISprite>("Ship");
        m_NoShip =m_Ship.Find<UISprite>("NoNoNo");
        m_InShip =m_Ship.Find<UISprite>("Incoming");
        m_OutShip =m_Ship.Find<UISprite>("Outgoing");
        m_Plane = g.Find<UISprite>("Plane");
        m_NoPlane =m_Plane.Find<UISprite>("NoNoNo");
        m_InPlane =m_Plane.Find<UISprite>("Incoming");
        m_OutPlane = m_Plane.Find<UISprite>("Outgoing");
 }
 public void CheckBoxChanged(UIComponent c, UIMouseEventParameter p)
 {
     UICheckBox cb = c as UICheckBox;
     bAutosaveEnabled = cb.isChecked;
     timer = autoSaveInterval * 60;
     updateLabel(bAutosaveEnabled, autoSaveInterval);
 }
Example #6
0
        public ListBase(UILogic uiLogic, UIComponent parent, TimeSpan creationTime, Rectangle rec, SpriteFont font, bool checkable)
            : base(uiLogic, parent, creationTime)
        {
            this.Font = font;
            this.IsCheckable = checkable;
            recInitial = rec;

            sizeText = font.MeasureString(new String(' ', 40)) + new Vector2(Ribbon.MARGE * 2, Ribbon.MARGE);

            countMaxItem = (rec.Height - 2 * MARGE) / (int)sizeText.Y;

            Rec = new Rectangle(
                recInitial.X,
                recInitial.Y,
                Math.Min((int)sizeText.X, recInitial.Width),
                (int)(countMaxItem * sizeText.Y + 2 * MARGE));

            if (sizeText.X > Rec.Width)
                sizeText.X = Rec.Width - 2 * MARGE;

            //--- Molette de la souris
            MouseManager mouseWheel = AddMouse(MouseButtons.Wheel);
            mouseWheel.MouseWheelChanged += new MouseManager.MouseWheelChangedHandler(mouseWheel_MouseWheelChanged);
            //---
        }
        public static void SetupBrushStrengthPanel(UIComponent brushOptionsPanel)
        {
            var brushStrengthPanel = brushOptionsPanel.AddUIComponent<UIPanel>();
            brushStrengthPanel.size = new Vector2(197, 49);
            brushStrengthPanel.relativePosition = new Vector2(17, 110);
            brushStrengthPanel.name = "Strength";
            var brushStrengthLabel = brushStrengthPanel.AddUIComponent<UILabel>();
            brushStrengthLabel.localeID = "MAPEDITOR_BRUSHSTRENGTH";
            brushStrengthLabel.size = new Vector2(131, 19);
            brushStrengthLabel.relativePosition = new Vector3(-5, 7);
            var brushStrengthText = brushStrengthPanel.AddUIComponent<UITextField>();
            brushStrengthText.name = "BrushStrength";
            brushStrengthText.size = new Vector2(60, 18);
            brushStrengthText.normalBgSprite = "TextFieldPanel";
            brushStrengthText.relativePosition = new Vector3(125, 7, 0);
            brushStrengthText.builtinKeyNavigation = true;
            brushStrengthText.isInteractive = true;
            brushStrengthText.readOnly = false;
            brushStrengthText.selectionSprite = "EmptySprite";
            brushStrengthText.selectionBackgroundColor = new Color32(0, 172, 234, 255);

            var brushStrengthSlider = brushStrengthPanel.AddUIComponent<UISlider>();
            brushStrengthSlider.name = "BrushStrength";
            brushStrengthSlider.relativePosition = new Vector3(13, 30, 0);
            brushStrengthSlider.backgroundSprite = "ScrollbarTrack";
            brushStrengthSlider.size = new Vector2(171, 12);
            brushStrengthSlider.minValue = 0;
            brushStrengthSlider.maxValue = 1;
            brushStrengthSlider.stepSize = 0.01f;
            var brushStrengthSliderThumb = brushStrengthSlider.AddUIComponent<UISlicedSprite>();
            brushStrengthSliderThumb.spriteName = "ScrollbarThumb";
            brushStrengthSliderThumb.size = new Vector2(10, 20);
            brushStrengthSlider.thumbObject = brushStrengthSliderThumb;
        }
 protected override void OnButtonClicked(UIComponent comp)
 {
     int zOrder = comp.zOrder;
     TerrainTool terrainTool = ToolsModifierControl.SetTool<TerrainTool>();
     if (terrainTool == null)
     {
         return;
     }
     var panel = (TerrainPanel)Convert.ChangeType(this, typeof(TerrainPanel));
     ShowUndoTerrainOptionsPanel(panel, true);
     ShowBrushOptionsPanel(panel, true);
     //begin mod
     UIView.library.Show("LandscapingInfoPanel");
     //end mod
     if (zOrder == 1 || zOrder == 3)
         ShowLevelHeightPanel(panel, true);
     else
         ShowLevelHeightPanel(panel, false);
     //begin mod
     if (zOrder < kTools.Length)
     {
         terrainTool.m_mode = TerrainPanelDetour.kTools[zOrder].enumValue;
         TerrainToolDetour.isDitch = false;
     }
     else
     {
         terrainTool.m_mode = TerrainTool.Mode.Shift;
         TerrainToolDetour.isDitch = true;
     }
     //end mod
 }
        private void ApplyGenericProperty(XmlNode node, UIComponent component)
        {
            bool optional = XmlUtil.TryGetBoolAttribute(node, "optional");
            bool sticky = XmlUtil.TryGetBoolAttribute(node, "sticky");
            string aspect = XmlUtil.TryGetStringAttribute(node, "aspect", "any");
            if (aspect != "any")
            {
                if (Util.AspectRatioFromString(aspect) != _currentAspectRatio)
                {
                    return;
                }
            }

            if (sticky)
            {
                _stickyProperties.Add(new StickyProperty
                {
                    ChildNode = node,
                    Component = component,
                    Node = node
                });
            }

            SetPropertyValue(node, node, component, optional, true);
        }
 protected override void OnButtonClicked(UIComponent comp)
 {
     object objectUserData = comp.objectUserData;
     BuildingInfo buildingInfo = objectUserData as BuildingInfo;
     NetInfo netInfo = objectUserData as NetInfo;
     TreeInfo treeInfo = objectUserData as TreeInfo;
     PropInfo propInfo = objectUserData as PropInfo;
     if (buildingInfo != null)
     {
         BuildingTool buildingTool = ToolsModifierControl.SetTool<BuildingTool>();
         if (buildingTool != null)
         {
             if (base.pathsOptionPanel != null)
             {
                 base.pathsOptionPanel.Hide();
             }
             buildingTool.m_prefab = buildingInfo;
             buildingTool.m_relocate = 0;
         }
     }
     if (netInfo != null)
     {
         NetToolFine netTool = ToolsModifierControl.SetTool<NetToolFine>();
         if (netTool != null)
         {
             if (base.pathsOptionPanel != null)
             {
                 base.pathsOptionPanel.Show();
             }
             netTool.m_prefab = netInfo;
         }
     }
     if (treeInfo != null)
     {
         TreeTool treeTool = ToolsModifierControl.SetTool<TreeTool>();
         if (treeTool != null)
         {
             if (base.pathsOptionPanel != null)
             {
                 base.pathsOptionPanel.Hide();
             }
             treeTool.m_prefab = treeInfo;
             treeTool.m_mode = TreeTool.Mode.Single;
         }
     }
     if (propInfo != null)
     {
         PropTool propTool = ToolsModifierControl.SetTool<PropTool>();
         if (propTool != null)
         {
             if (base.pathsOptionPanel != null)
             {
                 base.pathsOptionPanel.Hide();
             }
             propTool.m_prefab = propInfo;
             propTool.m_mode = PropTool.Mode.Single;
         }
     }
 }
 private void AskInfoModalCallback(UIComponent component, int result)
 {
     if (result != 0)
     {
         string workshopUrl = string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", _workshopAssetRowData.WorkshopId);
         Process.Start(workshopUrl);
     }
 }
Example #12
0
 private void ButtonWhatsNew_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
 {
     if(whatsNewPanel != null)
     {
         whatsNewPanel.Show();
         whatsNewPanel.BringToFront();
     }
 }
Example #13
0
        /// <summary>
        /// Logs the components position.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="block">The block.</param>
        /// <param name="component">The component.</param>
        /// <param name="componentName">Name of the component.</param>
        /// <param name="connectedName">Name of the connected control.</param>
        public static void LogPosition(object source, string block, UIComponent component, string componentName = null, string connectedName = null)
        {
            if (String.IsNullOrEmpty(componentName))
            {
                componentName = component.cachedName;
            }

            Log.Debug(source, block, connectedName, componentName, component, "Position", component.absolutePosition, component.relativePosition, component.position, component.width, component.height, component.anchor);
        }
 public void ZonedPanel_eventVisibilityChanged(UIComponent component, bool value)
 {
     if (!value)
     {
         return;
     }
     Tabs.AlignTo(zonedPanelUi, UIAlignAnchor.TopLeft);
     Tabs.relativePosition = new Vector2(13, -25);
 }
        protected void OnClick(UIComponent comp, UIMouseEventParameter p)
        {
            p.Use();
            UIButton uIButton = comp as UIButton;
            if (uIButton != null && uIButton.parent == this.m_strip)
            {

            }
        }
        private void TextField_eventTextSubmitted(UIComponent component, string value)
        {
            if (Populating) return;

            #if DEBUG
            Debug.LogFormat("Changing " + Description + " TextField");
            #endif
            OnTextChanged(value);
        }
        private void DropDown_eventSelectedIndexChanged(UIComponent component, int index)
        {
            if (Populating) return;

            #if DEBUG
            Debug.LogFormat("Changing " + Description);
            #endif
            OnSelectionChanged(index);
        }
		private void clickSwitchTraffic(UIComponent component, UIMouseEventParameter eventParam) {
			if (TrafficLightTool.getToolMode() != ToolMode.SwitchTrafficLight) {
				_buttonSwitchTraffic.focusedBgSprite = "ButtonMenuFocused";
				TrafficLightTool.SetToolMode(ToolMode.SwitchTrafficLight);
			} else {
				_buttonSwitchTraffic.focusedBgSprite = "ButtonMenu";
				TrafficLightTool.SetToolMode(ToolMode.None);
			}
		}
 private void rootPanel_eventVisibilityChanged(UIComponent component, bool value)
 {
     // Only save and apply the configuration if the rootpanel was visible but isn't anymore (meaning the user closed the window)
     if (_wasVisible && !value)
     {
         _configuration.SaveConfiguration();
         _configuration.ApplyConfiguration();
     }
     this._wasVisible = value;
 }
Example #20
0
        public Ribbon(UILogic uiLogic, UIComponent parent, TimeSpan creationTime)
            : base(uiLogic, parent, creationTime)
        {
            CreationTime = creationTime;

            Visible = true;
            Alive = true;

            Init();
        }
        public static UIButton SpawnSubEntry(UITabstrip strip, string name, string localeID, string unlockText, string spriteBase, bool enabled,
            UIComponent m_OptionsBar, UITextureAtlas m_DefaultInfoTooltipAtlas)
        {
            if (strip.Find<UIButton>(name) != null)
            {
                return null;
            }

            Type type1 = Util.FindType(name + "Group" + "Panel");
            if (type1 != null && !type1.IsSubclassOf(typeof(GeneratedGroupPanel)))
                type1 = (Type)null;
            if (type1 == null)
                return (UIButton)null;
            UIButton button;

            GameObject asGameObject1 = UITemplateManager.GetAsGameObject(kMainToolbarButtonTemplate);
            GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kScrollableSubPanelTemplate);
            UITabstrip uiTabstrip = strip;
            string name1 = name;
            GameObject strip1 = asGameObject1;
            GameObject page = asGameObject2;
            Type[] typeArray = new Type[1];
            int index = 0;
            Type type2 = type1;
            typeArray[index] = type2;
            button = uiTabstrip.AddTab(name1, strip1, page, typeArray) as UIButton;

            button.isEnabled = enabled;
            button.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            GeneratedGroupPanel generatedGroupPanel = GameObject.FindObjectOfType(type1) as GeneratedGroupPanel;
            if ((Object)generatedGroupPanel != (Object)null)
            {
                generatedGroupPanel.component.isInteractive = true;
                generatedGroupPanel.m_OptionsBar = m_OptionsBar;
                generatedGroupPanel.m_DefaultInfoTooltipAtlas = m_DefaultInfoTooltipAtlas;
                if (enabled)
                    generatedGroupPanel.RefreshPanel();
            }
            button.normalBgSprite = GetBackgroundSprite(button, spriteBase, name, "Normal");
            button.focusedBgSprite = GetBackgroundSprite(button, spriteBase, name, "Focused");
            button.hoveredBgSprite = GetBackgroundSprite(button, spriteBase, name, "Hovered");
            button.pressedBgSprite = GetBackgroundSprite(button, spriteBase, name, "Pressed");
            button.disabledBgSprite = GetBackgroundSprite(button, spriteBase, name, "Disabled");
            string str = spriteBase + name;
            button.normalFgSprite = str;
            button.focusedFgSprite = str + "Focused";
            button.hoveredFgSprite = str + "Hovered";
            button.pressedFgSprite = str + "Pressed";
            button.disabledFgSprite = str + "Disabled";
            if (unlockText != null)
                button.tooltip = Locale.Get(localeID, name) + " - " + unlockText;
            else
                button.tooltip = Locale.Get(localeID, name);
            return button;
        }
Example #22
0
        private void BottomLabel_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
        {
            if (RoadNamerManager.Instance().HaveMod())
            {

                bool blah = RoadNamerManager.Instance().populateObjects();
                DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("stuff. {0}",blah ));

            }

            //Steam.ActivateGameOverlayToWebPage("https://www.reddit.com/r/Cimtographer");
        }
 protected override void OnButtonClicked(UIComponent comp)
 {
     Logger.logInfo(PanelHelper.LOG_CUSTOM_PANELS, "CustomBasePanel.OnButtonClicked -- Component Clicked: {0}", comp);
     BuildingInfo buildingInfo = comp.objectUserData as BuildingInfo;
     if (!((Object) buildingInfo != (Object) null))
         return;
     BuildingTool buildingTool = ToolsModifierControl.SetTool<BuildingTool>();
     if (!((Object) buildingTool != (Object) null))
         return;
     buildingTool.m_prefab = buildingInfo;
     buildingTool.m_relocate = 0;
 }
 void buildingInfo_eventVisibilityChanged(UIComponent component, bool value)
 {
     this.buildingWindow.isEnabled = value;
     if (value)
     {
         this.buildingWindow.Show();
     }
     else
     {
         this.buildingWindow.Hide();
     }
 }
        public void Start()
        {
            m_view = UIView.GetAView();

            m_selectAIPanel = m_view.FindUIComponent<SelectAIPanel>("SelectAIPanel");
            m_uiContainer = m_view.FindUIComponent("FullScreenContainer");
            m_propPanel = m_uiContainer.Find<UIPanel>("DecorationProperties");

            m_toolController = ToolsModifierControl.toolController;
            m_selectAIPanel.eventValueChanged += OnAIFieldChanged;
            m_toolController.eventEditPrefabChanged += OnEditPrefabChanged;
        }
Example #26
0
        public static UIDropDown CreateDropDown(UIComponent parent)
        {
            UIDropDown dropDown = parent.AddUIComponent<UIDropDown>();
            dropDown.atlas = defaultAtlas;
            dropDown.size = new Vector2(90f, 30f);
            dropDown.listBackground = "GenericPanelLight";
            dropDown.itemHeight = 30;
            dropDown.itemHover = "ListItemHover";
            dropDown.itemHighlight = "ListItemHighlight";
            dropDown.normalBgSprite = "ButtonMenu";
            dropDown.disabledBgSprite = "ButtonMenuDisabled";
            dropDown.hoveredBgSprite = "ButtonMenuHovered";
            dropDown.focusedBgSprite = "ButtonMenu";
            dropDown.listWidth = 90;
            dropDown.listHeight = 500;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor = new Color32(45, 52, 61, 255);
            dropDown.popupTextColor = new Color32(170, 170, 170, 255);
            dropDown.zOrder = 1;
            dropDown.textScale = 0.8f;
            dropDown.verticalAlignment = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment = UIHorizontalAlignment.Left;
            dropDown.selectedIndex = 0;
            dropDown.textFieldPadding = new RectOffset(8, 0, 8, 0);
            dropDown.itemPadding = new RectOffset(14, 0, 8, 0);

            UIButton button = dropDown.AddUIComponent<UIButton>();
            dropDown.triggerButton = button;
            button.atlas = defaultAtlas;
            button.text = "";
            button.size = dropDown.size;
            button.relativePosition = new Vector3(0f, 0f);
            button.textVerticalAlignment = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            button.normalFgSprite = "IconDownArrow";
            button.hoveredFgSprite = "IconDownArrowHovered";
            button.pressedFgSprite = "IconDownArrowPressed";
            button.focusedFgSprite = "IconDownArrowFocused";
            button.disabledFgSprite = "IconDownArrowDisabled";
            button.foregroundSpriteMode = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment = UIHorizontalAlignment.Right;
            button.verticalAlignment = UIVerticalAlignment.Middle;
            button.zOrder = 0;
            button.textScale = 0.8f;

            dropDown.eventSizeChanged += new PropertyChangedEventHandler<Vector2>((c, t) =>
            {
                button.size = t; dropDown.listWidth = (int)t.x;
            });

            return dropDown;
        }
Example #27
0
        public override UIComponent OnClick(UIComponent ui)
        {
            if (ui.GetType() == typeof(UIComponent_Toolbar))
            {
                if (((UIComponent_Toolbar)ui).Diagonal)
                    ((UIComponent_Toolbar)ui).Diagonal = false;
                else
                    ((UIComponent_Toolbar)ui).Diagonal = true;

                diagonal = ((UIComponent_Toolbar)ui).Diagonal;
            }
            return ui;
        }
Example #28
0
        // Figuring all this was a pain (no documentation whatsoever)
        // So if your are using it for your mod consider thanking me (SamsamTS)
        // Extended Public Transport UI's code helped me a lot so thanks a lot AcidFire
        public static UIButton CreateButton(UIComponent parent)
        {
            UIButton button = (UIButton)parent.AddUIComponent<UIButton>();
            button.atlas = defaultAtlas;
            button.size = new Vector2(90f, 30f);
            button.textScale = 0.9f;
            button.normalBgSprite = "ButtonMenu";
            button.hoveredBgSprite = "ButtonMenuHovered";
            button.pressedBgSprite = "ButtonMenuPressed";
            button.canFocus = false;

            return button;
        }
 protected override void OnButtonClicked(UIComponent comp)
 {
     var objectUserData = comp.objectUserData;
     var propInfo = objectUserData as PropInfo;
     if (propInfo == null)
     {
         return;
     }
     var propTool = ToolsModifierControl.SetTool<PropTool>();
     if (propTool != null)
     {
         propTool.m_prefab = propInfo;
     }
 }
Example #30
0
        private void ButtonGenerate_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
        {
            try
            {
                OSMExportNew osmExporter = new OSMExportNew();
                osmExporter.Export();

                buttonGenerate.text = "Generate OSM map";
            }
            catch
            {
                buttonGenerate.text = "Export failed!";
            }
        }
 private void SnappingToggleButtonOnEventCheckChanged(UIComponent component, bool value)
 {
     DebugUtils.Log("Snapping toggle pressed.");
     OnSnappingToggled?.Invoke(component, value);
 }
 private void clickPrintDebugInfo(UIComponent component, UIMouseEventParameter eventParam)
 {
     Constants.ServiceFactory.SimulationService.AddAction(() => {
         UtilityManager.Instance.PrintDebugInfo();
     });
 }
Example #33
0
        public ChatRoomPlayStatus(INotifierQueryable queryer, UIComponent room, UILibrary library)
        {
            _ReleaseHelper = new ReleaseHelper();
            room.Page.RootElement.Visibility = Visibility.Visible;

            _ReleaseHelper.Actions.Add(() => {
                room.Page.RootElement.Visibility = Visibility.Hidden;
            });


            var messageContol = room.Page.RootElement.FindName("Message") as global::Stride.UI.Controls.EditText;
            var targetContol  = room.Page.RootElement.FindName("Target") as global::Stride.UI.Controls.EditText;
            var sendControl   = room.Page.RootElement.FindName("Send") as global::Stride.UI.Controls.Button;
            var quitControl   = room.Page.RootElement.FindName("Quit") as global::Stride.UI.Controls.Button;
            var listPanel     = room.Page.RootElement.FindName("List") as global::Stride.UI.Panels.Grid;



            var sendObs = from handler in sendControl.TouchUpObs()
                          where messageContol.Text.Length > 0 && string.IsNullOrWhiteSpace(targetContol.Text)
                          from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                          from unit in new System.Action(() => player.Send(messageContol.Text)).ReturnVoid()
                          select unit;

            var sendObsDispose = sendObs.Subscribe(_ => messageContol.Text = "");

            _ReleaseHelper.Actions.Add(() => {
                sendObsDispose.Dispose();
            });

            var privateSendObs = from handler in sendControl.TouchUpObs()
                                 where messageContol.Text.Length > 0 && !string.IsNullOrWhiteSpace(targetContol.Text)
                                 from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                                 from target in player.Chatters.SupplyEvent()
                                 where target.Name.Value == targetContol.Text
                                 from unit in new System.Action(() => target.Whisper(messageContol.Text)).ReturnVoid()
                                 select unit;

            var privateSendObsDispose = privateSendObs.Subscribe(_ => messageContol.Text = "");

            _ReleaseHelper.Actions.Add(() => {
                privateSendObsDispose.Dispose();
            });


            var quitObs = from handler in quitControl.TouchUpObs().Take(1)
                          from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                          from unit in new System.Action(() => player.Quit()).ReturnVoid()
                          select unit;

            var quitObsDispose = quitObs.Subscribe(unit => DoneEvent());

            _ReleaseHelper.Actions.Add(() => {
                quitObsDispose.Dispose();
            });


            var publicMessageObs =
                from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                from message in Regulus.Remote.Reactive.Extensions.EventObservable <Common.Message>(h => player.PublicMessageEvent += h, h => player.PublicMessageEvent -= h)
                select message;

            var publicMessageObsDispose = publicMessageObs.Subscribe(msg => _ReceiveMessage(listPanel, $"{msg.Name}:{msg.Context}"));

            _ReleaseHelper.Actions.Add(() => {
                publicMessageObsDispose.Dispose();
            });

            var privateMessageObs =
                from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                from message in Regulus.Remote.Reactive.Extensions.EventObservable <Common.Message>(h => player.PrivateMessageEvent += h, h => player.PrivateMessageEvent -= h)
                select message;

            var privateMessageObsDispose = privateMessageObs.Subscribe(msg => _ReceiveMessage(listPanel, $"<private>{msg.Name}:{msg.Context}"));

            _ReleaseHelper.Actions.Add(() => {
                privateMessageObsDispose.Dispose();
            });
            this.library = library;
        }
 private void clickPrintFlagsDebugInfo(UIComponent component, UIMouseEventParameter eventParam)
 {
     Flags.PrintDebugInfo();
 }
 private void clickCheckDetours(UIComponent component, UIMouseEventParameter eventParam)
 {
     SimulationManager.instance.AddAction(() => {
         PrintTransportStats();
     });
 }
Example #36
0
 public override void setParent(UIComponent parent)
 {
     //ignore: parent is root
 }
 private void clickResetBenchmarks(UIComponent component, UIMouseEventParameter eventParam)
 {
     Constants.ServiceFactory.SimulationService.AddAction(() => {
         BenchmarkProfileProvider.Instance.ClearProfiles();
     });
 }
Example #38
0
 public void closeBuildingInfo(UIComponent component, UIMouseEventParameter eventParam) => Hide();
        private void HandleTagNode(XmlNode node, GameObject parent, BSMLParserParams parserParams, out IEnumerable <ComponentTypeWithData> componentInfo)
        {
            if (!tags.TryGetValue(node.Name, out BSMLTag currentTag))
            {
                throw new Exception("Tag type '" + node.Name + "' not found");
            }

            GameObject currentNode = currentTag.CreateObject(parent.transform);

            List <ComponentTypeWithData> componentTypes = new List <ComponentTypeWithData>();

            foreach (TypeHandler typeHandler in typeHandlers)
            {
                Type      type      = (typeHandler.GetType().GetCustomAttributes(typeof(ComponentHandler), true).FirstOrDefault() as ComponentHandler).type;
                Component component = GetExternalComponent(currentNode, type);
                if (component != null)
                {
                    ComponentTypeWithData componentType = new ComponentTypeWithData();
                    componentType.data        = GetParameters(node, typeHandler.CachedProps, parserParams, out Dictionary <string, BSMLPropertyValue> propertyMap);
                    componentType.propertyMap = propertyMap;
                    componentType.typeHandler = typeHandler;
                    componentType.component   = component;
                    componentTypes.Add(componentType);
                }
            }
            foreach (ComponentTypeWithData componentType in componentTypes)
            {
                componentType.typeHandler.HandleType(componentType, parserParams);
            }

            object host = parserParams.host;

            if (host != null && node.Attributes["id"] != null)
            {
                foreach (FieldInfo fieldInfo in host.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    UIComponent uicomponent = fieldInfo.GetCustomAttributes(typeof(UIComponent), true).FirstOrDefault() as UIComponent;
                    if (uicomponent != null && uicomponent.id == node.Attributes["id"].Value)
                    {
                        fieldInfo.SetValue(host, GetExternalComponent(currentNode, fieldInfo.FieldType));
                    }

                    UIObject uiobject = fieldInfo.GetCustomAttributes(typeof(UIObject), true).FirstOrDefault() as UIObject;
                    if (uiobject != null && uiobject.id == node.Attributes["id"].Value)
                    {
                        fieldInfo.SetValue(host, currentNode);
                    }
                }
            }
            if (node.Attributes["tags"] != null)
            {
                parserParams.AddObjectTags(currentNode, node.Attributes["tags"].Value.Split(','));
            }

            IEnumerable <ComponentTypeWithData> childrenComponents = Enumerable.Empty <ComponentTypeWithData>();

            if (currentTag.AddChildren)
            {
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    HandleNode(childNode, currentNode, parserParams, out IEnumerable <ComponentTypeWithData> children);
                    childrenComponents = childrenComponents.Concat(children);
                }
            }

            foreach (ComponentTypeWithData componentType in componentTypes)
            {
                componentType.typeHandler.HandleTypeAfterChildren(componentType, parserParams);
            }

            componentInfo = componentTypes.Concat(childrenComponents);
        }
Example #40
0
 private void fecharTelaTransportes(UIComponent component, UIFocusEventParameter eventParam)
 {
     fecharTelaTransportes(component, (UIMouseEventParameter)null);
 }
Example #41
0
        protected UIButton CreateButton(string name, string tooltip, string baseIconName, int index, UITextureAtlas atlas, UIComponent tooltipBox, bool enabled, bool grouped)
        {
            UIButton btn;

            if (this.m_scrollablePanel.childCount > this.m_objectIndex)
            {
                btn = (this.m_scrollablePanel.components[this.m_objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject = UITemplateManager.GetAsGameObject(RoadCustomizerPanel.kItemTemplate);
                btn             = (this.m_scrollablePanel.AttachUIComponent(asGameObject) as UIButton);
                btn.eventClick += OnClick;
            }
            btn.gameObject.GetComponent <TutorialUITag>().tutorialTag = name;
            btn.text                = string.Empty;
            btn.name                = name;
            btn.tooltipAnchor       = UITooltipAnchor.Anchored;
            btn.tabStrip            = true;
            btn.horizontalAlignment = UIHorizontalAlignment.Center;
            btn.verticalAlignment   = UIVerticalAlignment.Middle;
            btn.pivot               = UIPivotPoint.TopCenter;
            if (atlas != null)
            {
                btn.atlas = atlas;
                switch (m_panelType)
                {
                case Panel.VehicleRestrictions:
                    SetVehicleButtonsThumbnails(btn);
                    break;

                case Panel.SpeedRestrictions:
                    UIUtils.SetThumbnails("SpeedSignBackground", sm_thumbnailCoords["SpeedSignBackground"], atlas, sm_speedThumbnailStates);
                    SetSpeedButtonsThumbnails(btn);
                    break;

                default:
                    break;
                }
            }
            if (index != -1)
            {
                btn.zOrder = index;
            }
            btn.verticalAlignment    = UIVerticalAlignment.Bottom;
            btn.foregroundSpriteMode = UIForegroundSpriteMode.Fill;

            UIComponent uIComponent = (btn.childCount <= 0) ? null : btn.components[0];

            if (uIComponent != null)
            {
                uIComponent.isVisible = false;
            }
            btn.isEnabled  = enabled;
            btn.state      = UIButton.ButtonState.Disabled;
            btn.tooltip    = tooltip;
            btn.tooltipBox = tooltipBox;
            btn.group      = grouped ? this.m_scrollablePanel : null;
            this.m_objectIndex++;
            return(btn);
        }
Example #42
0
 private void CloseUI()
 {
     UIComponent.RemoveUI(UIType.UIGuess);
     CloseCallback?.Invoke();
 }
        public void AddPauseMenuButton()
        {
            // find library pause menu
            //UIDynamicPanels.DynamicPanelInfo[] libpanels = UIView.library.m_DynamicPanels;

            //foreach (UIDynamicPanels.DynamicPanelInfo dpi in libpanels)
            //{
            //   DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, "panel: " + dpi.name);
            //}

            // create our panel now
            if (PanelWrapperForPauseMenu == null)
            {
                PanelWrapperForPauseMenu = (BetterLoadPanelWrapper)UIView.GetAView().AddUIComponent(typeof(BetterLoadPanelWrapper));

                PanelWrapperForPauseMenu.isVisible = false;
                PanelWrapperForPauseMenu.Initialize();
            }

            UIComponent pMenu = UIView.GetAView().FindUIComponent("Menu");

            //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "uiview instanceid: " + pMenu.GetUIView().GetInstanceID().ToString());
            if (pMenu != null)
            {
                //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("found pause menu UIComponent {0}", pMenu.GetType().FullName));

                UIButton loadGameButton = pMenu.Find <UIButton>("LoadGame");

                if (loadGameButton != null)
                {
                    // we don't want to clone or copy existing button, as it has event handlers we can't get rid of
                    UIButton newButton = UnityEngine.Object.Instantiate <UIButton>(loadGameButton);//mmUIComp.AddUIComponent<UIButton>(); //UnityEngine.Object.Instantiate<UIButton>(loadGameButton);
                    newButton.height      = loadGameButton.height / 2;
                    newButton.width       = loadGameButton.width;
                    loadGameButton.height = loadGameButton.height / 2;
                    newButton.autoSize    = true;
                    //newButton.useGUILayout = true;

                    newButton.name           = "BetterLoadPanel2";
                    newButton.cachedName     = "BetterLoadPanel2";
                    newButton.stringUserData = "BetterLoadPanel2";

                    //pMenu.AttachUIComponent(newButton.gameObject);
                    newButton.transform.parent = loadGameButton.transform.parent.transform;

                    newButton.text                    = string.Format("{0}++", Locale.Get(LocaleID.LOADGAME_TITLE)); // locale is subtly different than what game uses...//loadGameButton.text);//
                    newButton.textColor               = new Color32(0xFF, 0, 0, 0xFF);
                    newButton.relativePosition        = Vector3.zero;
                    newButton.horizontalAlignment     = UIHorizontalAlignment.Center;
                    newButton.textHorizontalAlignment = UIHorizontalAlignment.Center;
                    newButton.verticalAlignment       = UIVerticalAlignment.Middle;
                    newButton.textVerticalAlignment   = UIVerticalAlignment.Middle;

                    newButton.transform.SetSiblingIndex(loadGameButton.transform.GetSiblingIndex());

                    // get rid of click handler that is hooked up as a result of cloning.  Note - probably not necessary, the issue was in the name and cachedname of the new button...
                    RemoveClickEvent(newButton);


                    // when hiding, pop modal that we pushed in eventClick handler
                    PanelWrapperForPauseMenu.eventVisibilityChanged += (component, visible) =>
                    {
                        if (visible)
                        {
                            PanelWrapperForPauseMenu.Refresh(); //need to ensure up to date
                            PanelWrapperForPauseMenu.Focus();
                        }
                    };

                    // hook up our click handler
                    newButton.eventClick += (component, param) =>
                    {
                        UIView.library.Hide(typeof(PauseMenu).Name);
                        PanelWrapperForPauseMenu.Show(true);
                    };
                }
            }
        }
 private void highwaysCheck_eventClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     highways           = !highways;
     highwaysCheck.text = highways.ToString();
 }
Example #45
0
 public DataSettingLogSection(UIComponent component, object value)
     : base(component)
 {
     Message = $"{ActionText} \"{value}\" to {component.ComponentFullName}";
 }
 private void roadsCheck_eventClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     roads           = !roads;
     roadsCheck.text = roads.ToString();
 }
 private void clickPrintBenchmarkReport(UIComponent component, UIMouseEventParameter eventParam)
 {
     Constants.ServiceFactory.SimulationService.AddAction(() => {
         Log.Info(BenchmarkProfileProvider.Instance.CreateReport());
     });
 }
 private void pedestriansCheck_eventClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     peds = !peds;
     pedestriansCheck.text = peds.ToString();
 }
 private void clickTogglePathFindStats(UIComponent component, UIMouseEventParameter eventParam)
 {
     Update();
     showPathFindStats = !showPathFindStats;
 }
Example #50
0
 private void TabStripSelectedIndexChanged(UIComponent component, int index)
 {
     CurrentEditor = SelectEditor(index);
     UpdatePanel();
 }
 private void clickReloadConfig(UIComponent component, UIMouseEventParameter eventParam)
 {
     GlobalConfig.Reload();
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            UIComponent t = (UIComponent)target;

            EditorGUILayout.PropertyField(m_EnableOpenUIFormSuccessEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormFailureEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormUpdateEvent);
            EditorGUILayout.PropertyField(m_EnableOpenUIFormDependencyAssetEvent);
            EditorGUILayout.PropertyField(m_EnableCloseUIFormCompleteEvent);

            float instanceAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Instance Auto Release Interval", m_InstanceAutoReleaseInterval.floatValue);

            if (instanceAutoReleaseInterval != m_InstanceAutoReleaseInterval.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceAutoReleaseInterval = instanceAutoReleaseInterval;
                }
                else
                {
                    m_InstanceAutoReleaseInterval.floatValue = instanceAutoReleaseInterval;
                }
            }

            int instanceCapacity = EditorGUILayout.DelayedIntField("Instance Capacity", m_InstanceCapacity.intValue);

            if (instanceCapacity != m_InstanceCapacity.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceCapacity = instanceCapacity;
                }
                else
                {
                    m_InstanceCapacity.intValue = instanceCapacity;
                }
            }

            float instanceExpireTime = EditorGUILayout.DelayedFloatField("Instance Expire Time", m_InstanceExpireTime.floatValue);

            if (instanceExpireTime != m_InstanceExpireTime.floatValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstanceExpireTime = instanceExpireTime;
                }
                else
                {
                    m_InstanceExpireTime.floatValue = instanceExpireTime;
                }
            }

            int instancePriority = EditorGUILayout.DelayedIntField("Instance Priority", m_InstancePriority.intValue);

            if (instancePriority != m_InstancePriority.intValue)
            {
                if (EditorApplication.isPlaying)
                {
                    t.InstancePriority = instancePriority;
                }
                else
                {
                    m_InstancePriority.intValue = instancePriority;
                }
            }

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                EditorGUILayout.PropertyField(m_InstanceRoot);
                m_UIFormHelperInfo.Draw();
                m_UIGroupHelperInfo.Draw();
                EditorGUILayout.PropertyField(m_UIGroups, true);
            }
            EditorGUI.EndDisabledGroup();

            if (EditorApplication.isPlaying && PrefabUtility.GetPrefabType(t.gameObject) != PrefabType.Prefab)
            {
                EditorGUILayout.LabelField("UI Group Count", t.UIGroupCount.ToString());
            }

            serializedObject.ApplyModifiedProperties();

            Repaint();
        }
Example #53
0
 public RenderUIElement(UIComponent uiComponent, TransformComponent transformComponent)
 {
     UIComponent        = uiComponent;
     TransformComponent = transformComponent;
 }
 public static void CloseUIForm(this UIComponent uiComponent, UGuiForm uiForm)
 {
     uiComponent.CloseUIForm(uiForm.UIForm);
 }
Example #55
0
        private void ShowInPanel(PrefabInfo info)
        {
            UIButton button = FindComponentCached <UIButton>(GetButtonName(info));

            //Debug.Log($"Button for {info.name}:{button?.name} <{(button == null ? "null" : button.GetType().ToString())}>");
            if (button != null)
            {
                // NS2 integration will go here when its menu filter bug is fixed

                UIView.Find("TSCloseButton").SimulateClick();
                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIPanel           filterPanel;
                UIComponent       current = button, parent = button.parent;

                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }

                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null || subMenuTabstrip == null || menuTabstrip == null || menuTabstripIndex == -1 || subMenuTabstripIndex == -1)
                {
                    Debug.Log($"UI Panel not found");
                    return;
                }

                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);

                filterPanel = scrollablePanel.parent.Find <UIPanel>("FilterPanel");
                if (filterPanel != null)
                {
                    foreach (UIMultiStateButton c in filterPanel.GetComponentsInChildren <UIMultiStateButton>())
                    {
                        if (c.isVisible && c.activeStateIndex == 1)
                        {
                            c.activeStateIndex = 0;
                        }
                    }
                }

                StartCoroutine(ShowInPanelProcess(scrollablePanel, button));
            }
            else
            {
                Debug.Log($"Button not found, falling back to FindIt/All");
                FindIt.Find("All", info);
            }
        }
 public static int?OpenUIForm(this UIComponent uiComponent, UIFormId uiFormId, object userData = null)
 {
     return(uiComponent.OpenUIForm((int)uiFormId, userData));
 }
 private void NetListOnOnItemChanged(UIComponent component, NetTypeItemEventArgs value)
 {
     OnItemChanged?.Invoke(this, value);
 }
        public void OnSettingsUI(UIHelperBase helper)
        {
            ExtendedGameOptionsSerializable o = Singleton <ExtendedGameOptionsManager> .instance.values;


            //////////// General ////////////

            helper.AddCheckbox("Enable achievements", o.EnableAchievements, delegate(bool isChecked)
            {
                o.EnableAchievements = isChecked;
                modified             = true;
            });
            helper.AddCheckbox("Info View buttons are always enabled", o.InfoViewButtonsAlwaysEnabled, delegate(bool isChecked)
            {
                o.InfoViewButtonsAlwaysEnabled = isChecked;
                modified = true;
            });

            helper.AddSpace(20);


            //////////// Unlocks ////////////

            UIHelperBase unlockGroup = helper.AddGroup("Unlocks (requires game reload)");

            unlockGroup.AddCheckbox("Basic roads are available from the start", o.BasicRoadsAvailableBromStart, delegate(bool isChecked)
            {
                o.BasicRoadsAvailableBromStart = isChecked;
                modified = true;
            });
            unlockGroup.AddCheckbox("Train tracks can be constructed without a train station", o.TrainTrackUnlock, delegate(bool isChecked)
            {
                o.TrainTrackUnlock = isChecked;
                modified           = true;
            });
            unlockGroup.AddCheckbox("Metro tunnels can be constructed without a metro station", o.MetroTrackUnlock, delegate(bool isChecked)
            {
                o.MetroTrackUnlock = isChecked;
                modified           = true;
            });
            unlockGroup.AddCheckbox("Unlock everything up to the following milestone", o.UnlockMilestone, delegate(bool isChecked)
            {
                o.UnlockMilestone = isChecked;
                modified          = true;
            });
            unlockGroup.AddDropdown("     (select Megalopolis to unlock all)", Milestones.MilestoneLocalizedNames, o.UnlockMilestoneIndex - 1, delegate(int sel)
            {
                o.UnlockMilestoneIndex = sel + 1;
                modified = true;
            });


            //////////// Economy ////////////

            UIHelperBase economyGroup = helper.AddGroup("Economy");

            economyGroup.AddTextfield("Initial money (set blank to not change)",
                                      o.InitialMoney < 0 ? "" : o.InitialMoney.ToString(),
                                      delegate(string text) { },
                                      delegate(string text)
            {
                int value;
                if (int.TryParse(text, out value))
                {
                    value          = Mathf.Clamp(value, 0, 10 * 1000 * 1000);
                    o.InitialMoney = value;
                }
                else
                {
                    o.InitialMoney = -1;
                }

                modified = true;
            });

            economyGroup.AddCheckbox("Bulldozing structures built recently gives full refund", o.FullRefund, delegate(bool isChecked)
            {
                o.FullRefund = isChecked;
                modified     = true;
            });


            //////////// Others ////////////

            if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC))
            {
                helper.AddCheckbox("Enable random disasters for scenarios", o.EnableRandomDisastersForScenarios, delegate(bool isChecked)
                {
                    o.EnableRandomDisastersForScenarios = isChecked;
                    modified = true;
                });
            }
            helper.AddCheckbox("Set number of purchasable areas (uncheck this if using 81 tiles mod)", o.EnableAreasMaxCountOption, delegate(bool isChecked)
            {
                Singleton <ExtendedGameOptionsManager> .instance.values.EnableAreasMaxCountOption = isChecked;

                if (isChecked)
                {
                    Areas.Update();
                }
                else
                {
                    Areas.Reset();
                }

                modified = true;
            });
            UIDropDown areasMaxCountDropdown = (UIDropDown)helper.AddDropdown("Areas", Areas.GetAvailableValuesStr(), o.AreasMaxCount - 1, delegate(int sel)
            {
                o.AreasMaxCount = sel + 1;
                modified        = true;

                if (Singleton <ExtendedGameOptionsManager> .instance.values.EnableAreasMaxCountOption)
                {
                    Areas.Update();
                }
            });

            helper.AddSpace(20);


            //////////// Resources ////////////

            UIHelperBase resourcesHelper = helper.AddGroup("Resources depletion rate");

            addLabelToResourceSlider(resourcesHelper.AddSlider("Oil depletion rate", 0, 100, 1, o.OilDepletionRate, delegate(float val)
            {
                o.OilDepletionRate = (int)val;
                modified           = true;
            }));
            addLabelToResourceSlider(resourcesHelper.AddSlider("Ore depletion rate", 0, 100, 1, o.OreDepletionRate, delegate(float val)
            {
                o.OreDepletionRate = (int)val;
                modified           = true;
            }));


            UIComponent optionPanel = areasMaxCountDropdown.parent.parent;

            optionPanel.eventVisibilityChanged += OptionPanel_eventVisibilityChanged;
        }
 /// <summary>
 /// When the main button is toggled we must update <see cref="_isToolEnabled"/> but NOT <see cref="_isToolActive"/>.
 /// This means that we're not controlling button's visibility here.
 /// </summary>
 /// <param name="component"></param>
 /// <param name="value"></param>
 private void MainWindowOnOnParallelToolToggled(UIComponent component, bool value)
 {
     _isToolEnabled = value;
     ToggleDetours(value);
     _mainWindow.isVisible = value;
 }
 private void MainWindowOnOnSnappingToggled(UIComponent component, bool value)
 {
     IsSnappingEnabled = value;
 }