Beispiel #1
0
        private void Awake()
        {
            TLMUtils.clearAllVisibilityEvents(this.GetComponent <UIPanel>());
            base.component.eventZOrderChanged += delegate(UIComponent c, int r)
            {
                this.SetBackgroundColor();
            };
            GameObject.Destroy(base.Find <UICheckBox>("LineVisible").gameObject);
            GameObject.Destroy(base.Find <UIColorField>("LineColor").gameObject);

            this.m_depotName                        = base.Find <UILabel>("LineName");
            this.m_depotNameField                   = this.m_depotName.Find <UITextField>("LineNameField");
            this.m_depotNameField.maxLength         = 256;
            this.m_depotNameField.eventTextChanged += new PropertyChangedEventHandler <string>(this.OnRename);
            this.m_depotName.eventMouseEnter       += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotName.backgroundSprite = "TextFieldPanelHovered";
            };
            this.m_depotName.eventMouseLeave += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotName.backgroundSprite = string.Empty;
            };
            this.m_depotName.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotNameField.Show();
                this.m_depotNameField.text = this.m_depotName.text;
                this.m_depotNameField.Focus();
            };
            this.m_depotNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
            {
                this.m_depotNameField.Hide();
                this.m_depotName.text = this.m_depotNameField.text;
            };

            GameObject.Destroy(base.Find <UICheckBox>("DayLine").gameObject);
            GameObject.Destroy(base.Find <UICheckBox>("NightLine").gameObject);
            GameObject.Destroy(base.Find <UICheckBox>("DayNightLine").gameObject);


            this.m_prefixOptions = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] { }, onChangePrefixSelected, gameObject.GetComponent <UIPanel>());

            m_prefixOptions.area = new Vector4(600, 3, 80, 33);

            var m_DayLine = base.Find <UICheckBox>("DayLine");

            GameObject.Destroy(base.Find <UICheckBox>("NightLine").gameObject);
            GameObject.Destroy(base.Find <UICheckBox>("DayNightLine").gameObject);
            GameObject.Destroy(m_DayLine.gameObject);

            m_districtName                  = base.Find <UILabel>("LineStops");
            m_districtName.size             = new Vector2(175, 18);
            m_districtName.relativePosition = new Vector3(0, 10);
            m_districtName.pivot            = UIPivotPoint.MiddleCenter;
            m_districtName.wordWrap         = true;
            m_districtName.autoHeight       = true;



            GameObject.Destroy(base.Find <UILabel>("LinePassengers").gameObject);
            this.m_prefixesServed             = base.Find <UILabel>("LineVehicles");
            this.m_prefixesServed.size        = new Vector2(220, 35);
            this.m_prefixesServed.autoHeight  = true;
            this.m_prefixesServed.maximumSize = new Vector2(0, 36);
            this.m_prefixesServed.textScale   = 0.7f;
            this.m_prefixesServed.width       = 170;

            this.m_Background               = base.Find("Background");
            this.m_BackgroundColor          = this.m_Background.color;
            this.m_mouseIsOver              = false;
            base.component.eventMouseEnter += new MouseEventHandler(this.OnMouseEnter);
            base.component.eventMouseLeave += new MouseEventHandler(this.OnMouseLeave);
            GameObject.Destroy(base.Find <UIButton>("DeleteLine").gameObject);
            base.Find <UIButton>("ViewLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_buildingID != 0)
                {
                    Vector3    position   = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)this.m_buildingID].m_position;
                    InstanceID instanceID = default(InstanceID);
                    instanceID.Building = this.m_buildingID;
                    TLMController.instance.depotInfoPanel.openDepotInfo(m_buildingID);
                    ToolsModifierControl.cameraController.SetTarget(instanceID, position, true);
                    TLMController.instance.defaultListingLinesPanel.Hide();
                }
            };
            base.component.eventVisibilityChanged += delegate(UIComponent c, bool v)
            {
                if (v)
                {
                    this.m_prefixOptions.items = new string[] { };
                    this.RefreshData();
                }
            };

            //Buttons
            TLMUtils.createUIElement <UIButton>(ref m_addPrefixButton, transform);
            m_addPrefixButton.pivot            = UIPivotPoint.TopRight;
            m_addPrefixButton.relativePosition = new Vector3(730, 2);
            m_addPrefixButton.text             = Locale.Get("TLM_ADD");
            m_addPrefixButton.textScale        = 0.6f;
            m_addPrefixButton.width            = 50;
            m_addPrefixButton.height           = 15;
            m_addPrefixButton.tooltip          = Locale.Get("TLM_ADD_PREFIX_TOOLTIP");
            TLMUtils.initButton(m_addPrefixButton, true, "ButtonMenu");
            m_addPrefixButton.name        = "Add";
            m_addPrefixButton.isVisible   = true;
            m_addPrefixButton.eventClick += (component, eventParam) =>
            {
                uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex;
                TLMDepotAI.addPrefixToDepot(buildingId, prefix);
                m_addPrefixButton.isVisible    = false;
                m_removePrefixButton.isVisible = true;
            };

            TLMUtils.createUIElement <UIButton>(ref m_removePrefixButton, transform);
            m_removePrefixButton.pivot            = UIPivotPoint.TopRight;
            m_removePrefixButton.relativePosition = new Vector3(780, 2);
            m_removePrefixButton.text             = Locale.Get("TLM_REMOVE");
            m_removePrefixButton.textScale        = 0.6f;
            m_removePrefixButton.width            = 50;
            m_removePrefixButton.height           = 15;
            m_removePrefixButton.tooltip          = Locale.Get("TLM_REMOVE_PREFIX_TOOLTIP");
            TLMUtils.initButton(m_removePrefixButton, true, "ButtonMenu");
            m_removePrefixButton.name        = "Remove";
            m_removePrefixButton.isVisible   = true;
            m_removePrefixButton.eventClick += (component, eventParam) =>
            {
                uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex;
                TLMDepotAI.removePrefixFromDepot(buildingId, prefix);
                m_addPrefixButton.isVisible    = true;
                m_removePrefixButton.isVisible = false;
            };


            TLMUtils.createUIElement <UIButton>(ref m_addAllPrefixesButton, transform);
            m_addAllPrefixesButton.pivot            = UIPivotPoint.TopRight;
            m_addAllPrefixesButton.relativePosition = new Vector3(730, 20);
            m_addAllPrefixesButton.text             = Locale.Get("TLM_ADD_ALL_SHORT");;
            m_addAllPrefixesButton.textScale        = 0.6f;
            m_addAllPrefixesButton.width            = 50;
            m_addAllPrefixesButton.height           = 15;
            m_addAllPrefixesButton.tooltip          = Locale.Get("TLM_ADD_ALL_PREFIX_TOOLTIP");
            TLMUtils.initButton(m_addAllPrefixesButton, true, "ButtonMenu");
            m_addAllPrefixesButton.name        = "AddAll";
            m_addAllPrefixesButton.isVisible   = true;
            m_addAllPrefixesButton.eventClick += (component, eventParam) =>
            {
                TLMDepotAI.addAllPrefixesToDepot(buildingId);
                m_addPrefixButton.isVisible    = false;
                m_removePrefixButton.isVisible = true;
            };


            TLMUtils.createUIElement <UIButton>(ref m_removeAllPrefixesButton, transform);
            m_removeAllPrefixesButton.pivot            = UIPivotPoint.TopRight;
            m_removeAllPrefixesButton.relativePosition = new Vector3(780, 20);
            m_removeAllPrefixesButton.text             = Locale.Get("TLM_REMOVE_ALL_SHORT");
            m_removeAllPrefixesButton.textScale        = 0.6f;
            m_removeAllPrefixesButton.width            = 50;
            m_removeAllPrefixesButton.height           = 15;
            m_removeAllPrefixesButton.tooltip          = Locale.Get("TLM_REMOVE_ALL_PREFIX_TOOLTIP");
            TLMUtils.initButton(m_removeAllPrefixesButton, true, "ButtonMenu");
            m_removeAllPrefixesButton.name        = "RemoveAll";
            m_removeAllPrefixesButton.isVisible   = true;
            m_removeAllPrefixesButton.eventClick += (component, eventParam) =>
            {
                TLMDepotAI.removeAllPrefixesFromDepot(buildingId);
                m_addPrefixButton.isVisible    = true;
                m_removePrefixButton.isVisible = false;
            };
        }
        private void Awake()
        {
            TLMUtils.clearAllVisibilityEvents(this.GetComponent <UIPanel>());
            base.component.eventZOrderChanged += delegate(UIComponent c, int r)
            {
                this.SetBackgroundColor();
            };
            this.m_LineIsVisible = base.Find <UICheckBox>("LineVisible");
            this.m_LineIsVisible.eventCheckChanged += delegate(UIComponent c, bool r)
            {
                if (this.m_LineID != 0)
                {
                    Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        if (r)
                        {
                            TransportLine[] expr_2A_cp_0            = Singleton <TransportManager> .instance.m_lines.m_buffer;
                            ushort expr_2A_cp_1                     = this.m_LineID;
                            expr_2A_cp_0[(int)expr_2A_cp_1].m_flags = (expr_2A_cp_0[(int)expr_2A_cp_1].m_flags & ~TransportLine.Flags.Hidden);
                        }
                        else
                        {
                            TransportLine[] expr_5C_cp_0            = Singleton <TransportManager> .instance.m_lines.m_buffer;
                            ushort expr_5C_cp_1                     = this.m_LineID;
                            expr_5C_cp_0[(int)expr_5C_cp_1].m_flags = (expr_5C_cp_0[(int)expr_5C_cp_1].m_flags | TransportLine.Flags.Hidden);
                        }
                    });
                }
            };
            this.m_LineColor = base.Find <UIColorField>("LineColor");
            this.m_LineColor.normalBgSprite             = "";
            this.m_LineColor.focusedBgSprite            = "";
            this.m_LineColor.hoveredBgSprite            = "";
            this.m_LineColor.width                      = 40;
            this.m_LineColor.height                     = 40;
            this.m_LineColor.atlas                      = TLMController.taLineNumber;
            this.m_LineNumberFormatted                  = this.m_LineColor.GetComponentInChildren <UIButton>();
            m_LineNumberFormatted.textScale             = 1.5f;
            m_LineNumberFormatted.useOutline            = true;
            this.m_LineColor.eventSelectedColorChanged += new PropertyChangedEventHandler <Color>(this.OnColorChanged);
            this.m_LineName                        = base.Find <UILabel>("LineName");
            this.m_LineNameField                   = this.m_LineName.Find <UITextField>("LineNameField");
            this.m_LineNameField.maxLength         = 256;
            this.m_LineNameField.eventTextChanged += new PropertyChangedEventHandler <string>(this.OnRename);
            this.m_LineName.eventMouseEnter       += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineName.backgroundSprite = "TextFieldPanelHovered";
            };
            this.m_LineName.eventMouseLeave += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineName.backgroundSprite = string.Empty;
            };
            this.m_LineName.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineNameField.Show();
                this.m_LineNameField.text = this.m_LineName.text;
                this.m_LineNameField.Focus();
            };
            this.m_LineNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
            {
                this.m_LineNameField.Hide();
                this.m_LineName.text = this.m_LineNameField.text;
            };


            this.m_DayLine      = base.Find <UICheckBox>("DayLine");
            this.m_NightLine    = base.Find <UICheckBox>("NightLine");
            this.m_DayNightLine = base.Find <UICheckBox>("DayNightLine");
            m_DisabledLine      = GameObject.Instantiate(base.Find <UICheckBox>("DayLine"));
            m_DisabledLine.transform.SetParent(m_DayLine.transform.parent);
            this.m_DayLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(true, false);
                    });
                }
            };
            this.m_NightLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(false, true);
                    });
                }
            };
            this.m_DayNightLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(true, true);
                    });
                }
            };


            m_DisabledLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(false, false);
                    });
                }
            };


            m_NightLine.relativePosition    = new Vector3(670, 8);
            m_DayNightLine.relativePosition = new Vector3(702, 8);


            //this.m_noBudgetWarn = GameObject.Instantiate(base.Find<UILabel>("LineName"));
            //m_noBudgetWarn.transform.SetParent(m_DayLine.transform.parent);
            //m_noBudgetWarn.isInteractive = false;
            //m_noBudgetWarn.relativePosition = new Vector3(615, 2);
            //m_noBudgetWarn.width = 145;
            //m_noBudgetWarn.isVisible = false;
            //m_noBudgetWarn.text = "";
            //m_noBudgetWarn.textScale = 0.9f;
            //m_noBudgetWarn.localeID = "TLM_LINE_DISABLED_NO_BUDGET";


            this.m_LineStops      = base.Find <UILabel>("LineStops");
            this.m_LinePassengers = base.Find <UILabel>("LinePassengers");
            this.m_LineVehicles   = base.Find <UILabel>("LineVehicles");
            //m_LinePassengers.relativePosition -= new Vector3(0, 6, 0);
            m_LineVehicles.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 5, 0);
            m_budgetEffective = GameObject.Instantiate(this.m_LineStops);
            m_budgetEffective.transform.SetParent(m_LineStops.transform.parent);
            //m_LineEarnings = GameObject.Instantiate(this.m_LinePassengers);
            //m_LineEarnings.transform.SetParent(m_LineStops.transform.parent);
            //m_LineEarnings.textColor = Color.green;
            this.m_Background               = base.Find("Background");
            this.m_BackgroundColor          = this.m_Background.color;
            this.m_mouseIsOver              = false;
            base.component.eventMouseEnter += new MouseEventHandler(this.OnMouseEnter);
            base.component.eventMouseLeave += new MouseEventHandler(this.OnMouseLeave);
            base.Find <UIButton>("DeleteLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_LineID != 0)
                {
                    ConfirmPanel.ShowModal("CONFIRM_LINEDELETE", delegate(UIComponent comp, int ret)
                    {
                        if (ret == 1)
                        {
                            Singleton <SimulationManager> .instance.AddAction(delegate
                            {
                                Singleton <TransportManager> .instance.ReleaseLine(this.m_LineID);
                            });
                        }
                    });
                }
            };
            base.Find <UIButton>("ViewLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_LineID != 0)
                {
                    Vector3    position   = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_stops].m_position;
                    InstanceID instanceID = default(InstanceID);
                    instanceID.TransportLine = this.m_LineID;
                    TLMController.instance.lineInfoPanel.openLineInfo(lineID);
                    TLMController.instance.defaultListingLinesPanel.Hide();
                }
            };
            base.component.eventVisibilityChanged += delegate(UIComponent c, bool v)
            {
                if (v)
                {
                    this.RefreshData(true, true);
                }
            };

            //Auto color & Auto Name
            UIButton buttonAutoName = null;

            TLMUtils.createUIElement <UIButton>(ref buttonAutoName, transform);
            buttonAutoName.pivot            = UIPivotPoint.TopRight;
            buttonAutoName.relativePosition = new Vector3(164, 2);
            buttonAutoName.text             = "A";
            buttonAutoName.textScale        = 0.6f;
            buttonAutoName.width            = 15;
            buttonAutoName.height           = 15;
            buttonAutoName.tooltip          = Locale.Get("TLM_AUTO_NAME_SIMPLE_BUTTON_TOOLTIP");
            TLMUtils.initButton(buttonAutoName, true, "ButtonMenu");
            buttonAutoName.name        = "AutoName";
            buttonAutoName.isVisible   = true;
            buttonAutoName.eventClick += (component, eventParam) =>
            {
                DoAutoName();
            };

            UIButton buttonAutoColor = null;

            TLMUtils.createUIElement <UIButton>(ref buttonAutoColor, transform);
            buttonAutoColor.pivot            = UIPivotPoint.TopRight;
            buttonAutoColor.relativePosition = new Vector3(80, 2);
            buttonAutoColor.text             = "A";
            buttonAutoColor.textScale        = 0.6f;
            buttonAutoColor.width            = 15;
            buttonAutoColor.height           = 15;
            buttonAutoColor.tooltip          = Locale.Get("TLM_AUTO_COLOR_SIMPLE_BUTTON_TOOLTIP");
            TLMUtils.initButton(buttonAutoColor, true, "ButtonMenu");
            buttonAutoColor.name        = "AutoColor";
            buttonAutoColor.isVisible   = true;
            buttonAutoColor.eventClick += (component, eventParam) =>
            {
                DoAutoColor();
            };
        }
Beispiel #3
0
        private void Awake()
        {
            TLMUtils.clearAllVisibilityEvents(this.GetComponent <UIPanel>());
            base.component.eventZOrderChanged += delegate(UIComponent c, int r)
            {
                this.SetBackgroundColor();
            };
            GameObject.Destroy(base.Find <UICheckBox>("LineVisible").gameObject);
            GameObject.Destroy(base.Find <UIColorField>("LineColor").gameObject);
            GameObject.Destroy(base.Find <UIPanel>("WarningIncomplete"));

            this.m_depotName                        = base.Find <UILabel>("LineName");
            this.m_depotNameField                   = this.m_depotName.Find <UITextField>("LineNameField");
            this.m_depotNameField.maxLength         = 256;
            this.m_depotNameField.eventTextChanged += new PropertyChangedEventHandler <string>(this.OnRename);
            this.m_depotName.eventMouseEnter       += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotName.backgroundSprite = "TextFieldPanelHovered";
            };
            this.m_depotName.eventMouseLeave += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotName.backgroundSprite = string.Empty;
            };
            this.m_depotName.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_depotNameField.Show();
                this.m_depotNameField.text = this.m_depotName.text;
                this.m_depotNameField.Focus();
            };
            this.m_depotNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
            {
                this.m_depotNameField.Hide();
                Singleton <BuildingManager> .instance.StartCoroutine(TLMUtils.setBuildingName(this.m_buildingID, this.m_depotNameField.text, () =>
                {
                    this.m_depotName.text = this.m_depotNameField.text;
                    Invalidate();
                }));
            };

            GameObject.Destroy(base.Find <UICheckBox>("DayLine").gameObject);
            GameObject.Destroy(base.Find <UICheckBox>("NightLine").gameObject);
            GameObject.Destroy(base.Find <UICheckBox>("DayNightLine").gameObject);
            GameObject.Destroy(base.Find <UILabel>("LinePassengers").gameObject);

            m_districtName                  = base.Find <UILabel>("LineStops");
            m_districtName.minimumSize      = new Vector2(140, 18);
            m_districtName.relativePosition = new Vector3(0, 10);
            m_districtName.pivot            = UIPivotPoint.TopLeft;
            m_districtName.wordWrap         = false;
            m_districtName.autoSize         = true;
            TLMUtils.LimitWidth(m_districtName, (uint)m_districtName.minimumSize.x);

            if (Singleton <T> .instance.GetTSD().isShelterAiDepot())
            {
                GameObject.Destroy(base.Find <UILabel>("LineVehicles").gameObject);
            }
            else
            {
                CreatePrefixSelectorUI();
            }

            this.m_Background               = base.Find("Background");
            this.m_BackgroundColor          = this.m_Background.color;
            this.m_mouseIsOver              = false;
            base.component.eventMouseEnter += new MouseEventHandler(this.OnMouseEnter);
            base.component.eventMouseLeave += new MouseEventHandler(this.OnMouseLeave);
            GameObject.Destroy(base.Find <UIButton>("DeleteLine").gameObject);
            base.Find <UIButton>("ViewLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_buildingID != 0)
                {
                    Vector3    position   = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)this.m_buildingID].m_position;
                    InstanceID instanceID = default(InstanceID);
                    instanceID.Building = this.m_buildingID;
                    ToolsModifierControl.cameraController.SetTarget(instanceID, position, true);
                    if (!Singleton <T> .instance.GetTSD().isShelterAiDepot())
                    {
                        TLMController.instance.depotInfoPanel.openDepotInfo(m_buildingID, secondary);
                        TLMController.instance.CloseTLMPanel();
                    }
                }
            };
            base.component.eventVisibilityChanged += delegate(UIComponent c, bool v)
            {
                if (v)
                {
                    if (m_prefixOptions != null)
                    {
                        m_prefixOptions.items = new string[] { }
                    }
                    ;
                    RefreshData();
                }
            };
        }