Ejemplo n.º 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;
            };
        }
Ejemplo n.º 2
0
        private void createInfoView()
        {
            //line info painel

            TLMUtils.createUIElement(out depotInfoPanel, m_controller.mainRef.transform);
            depotInfoPanel.Hide();
            depotInfoPanel.relativePosition  = new Vector3(394.0f, 0.0f);
            depotInfoPanel.width             = 650;
            depotInfoPanel.height            = 290;
            depotInfoPanel.zOrder            = 50;
            depotInfoPanel.color             = new Color32(255, 255, 255, 255);
            depotInfoPanel.backgroundSprite  = "MenuPanel2";
            depotInfoPanel.name              = "DepotInfoPanel";
            depotInfoPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10);
            depotInfoPanel.autoLayout        = false;
            depotInfoPanel.useCenter         = true;
            depotInfoPanel.wrapLayout        = false;
            depotInfoPanel.canFocus          = true;
            TLMUtils.createDragHandle(depotInfoPanel, depotInfoPanel, 35f);



            TLMUtils.createUIElement(out lineTransportIconTypeLabel, depotInfoPanel.transform);
            lineTransportIconTypeLabel.autoSize         = false;
            lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f);
            lineTransportIconTypeLabel.width            = 30;
            lineTransportIconTypeLabel.height           = 20;
            lineTransportIconTypeLabel.name             = "DepotTransportIcon";
            lineTransportIconTypeLabel.clipChildren     = true;
            lineTransportIconTypeLabel.eventClick      += (x, y) => {
                openDepotInfo(m_buildingIdSelecionado.Building, !m_secondary);
            };
            TLMUtils.createDragHandle(lineTransportIconTypeLabel, depotInfoPanel);


            TLMUtils.createUIElement(out depotNameField, depotInfoPanel.transform);
            depotNameField.autoSize            = false;
            depotNameField.relativePosition    = new Vector3(160f, 10f);
            depotNameField.horizontalAlignment = UIHorizontalAlignment.Center;
            depotNameField.text      = "NOME";
            depotNameField.width     = 450;
            depotNameField.height    = 25;
            depotNameField.name      = "DepotNameLabel";
            depotNameField.maxLength = 256;
            depotNameField.textScale = 1.5f;
            TLMUtils.uiTextFieldDefaults(depotNameField);
            depotNameField.eventGotFocus += (component, eventParam) => {
                lastDepotName = depotNameField.text;
            };
            depotNameField.eventLostFocus += (component, eventParam) => {
                if (lastDepotName != depotNameField.text)
                {
                    saveDepotName(depotNameField);
                }
            };

            TLMUtils.createUIElement(out vehiclesInUseLabel, depotInfoPanel.transform);
            vehiclesInUseLabel.autoSize         = false;
            vehiclesInUseLabel.relativePosition = new Vector3(10f, 60f);
            vehiclesInUseLabel.textAlignment    = UIHorizontalAlignment.Left;
            vehiclesInUseLabel.text             = "";
            vehiclesInUseLabel.width            = 550;
            vehiclesInUseLabel.height           = 25;
            vehiclesInUseLabel.name             = "VehiclesInUseLabel";
            vehiclesInUseLabel.textScale        = 0.8f;

            TLMUtils.createUIElement(out passengersLastWeek, depotInfoPanel.transform);
            passengersLastWeek.autoSize         = false;
            passengersLastWeek.relativePosition = new Vector3(10f, 90);
            passengersLastWeek.textAlignment    = UIHorizontalAlignment.Left;
            passengersLastWeek.text             = "";
            passengersLastWeek.width            = 550;
            passengersLastWeek.height           = 25;
            passengersLastWeek.name             = "PassengersLastWeek";
            passengersLastWeek.textScale        = 0.8f;

            TLMUtils.createUIElement(out upkeepCost, depotInfoPanel.transform);
            upkeepCost.autoSize         = false;
            upkeepCost.relativePosition = new Vector3(10f, 75);
            upkeepCost.textAlignment    = UIHorizontalAlignment.Left;
            upkeepCost.width            = 250;
            upkeepCost.height           = 25;
            upkeepCost.name             = "AvoidedTravelsLabel";
            upkeepCost.textScale        = 0.8f;

            TLMUtils.createUIElement(out prefixesSpawned, depotInfoPanel.transform);
            prefixesSpawned.autoSize         = false;
            prefixesSpawned.relativePosition = new Vector3(10f, 120f);
            prefixesSpawned.textAlignment    = UIHorizontalAlignment.Left;
            prefixesSpawned.localeID         = "TLM_PREFIXES_SPAWNED_DEPOT";
            prefixesSpawned.suffix           = ":";
            prefixesSpawned.width            = 350;
            prefixesSpawned.height           = 25;
            prefixesSpawned.name             = "TouristAndPassagersLabel";
            prefixesSpawned.textScale        = 0.8f;

            TLMUtils.createUIElement(out UIPanel prefixesPanel, depotInfoPanel.transform);
            prefixesPanel.autoSize         = false;
            prefixesPanel.relativePosition = new Vector3(10f, 135f);
            prefixesPanel.width            = 630;
            prefixesPanel.height           = 100;
            prefixesPanel.name             = "Prefixes Panel";
            prefixesPanel.autoLayout       = true;
            prefixesPanel.wrapLayout       = true;

            prefixesCheckboxes = new Dictionary <uint, UICheckBox>();
            for (uint i = 0; i <= 65; i++)
            {
                prefixesCheckboxes[i]       = prefixesPanel.AttachUIComponent(UITemplateManager.GetAsGameObject("OptionsCheckBoxTemplate")) as UICheckBox;
                prefixesCheckboxes[i].text  = i == 0 ? Locale.Get("TLM_UNPREFIXED") : i == 65 ? Locale.Get("TLM_REGIONAL") : i.ToString();
                prefixesCheckboxes[i].width = 50;
                prefixesCheckboxes[i].GetComponentInChildren <UILabel>().relativePosition = new Vector3(20, 2);
                uint j = i;
                prefixesCheckboxes[i].eventCheckChanged += (x, y) => {
                    if (TLMSingleton.instance != null && TLMSingleton.debugMode)
                    {
                        TLMUtils.doLog("prefixesCheckboxes[i].eventCheckChanged; j = {0}; check = {1}; loading = {2}", j, y, isLoading);
                    }
                    if (!isLoading)
                    {
                        togglePrefix(j, y, m_secondary);
                    }
                };
            }

            prefixesCheckboxes[0].width   = prefixesPanel.width / 2.1f;
            prefixesCheckboxes[65].width  = prefixesPanel.width / 2.1f;
            prefixesCheckboxes[65].zOrder = 0;

            TLMUtils.createUIElement(out UIButton voltarButton2, depotInfoPanel.transform);
            voltarButton2.relativePosition = new Vector3(depotInfoPanel.width - 33f, 5f);
            voltarButton2.width            = 28;
            voltarButton2.height           = 28;
            TLMUtils.initButton(voltarButton2, true, "DeleteLineButton");
            voltarButton2.name        = "LineInfoCloseButton";
            voltarButton2.eventClick += closeDepotInfo;

            workerChart = new TLMWorkerChartPanel(this.panelTransform, new Vector3(400f, 60f));

            TLMUtils.createUIElement(out UIButton addAllPrefixesButton, panelTransform);
            addAllPrefixesButton.relativePosition = new Vector3(300, 100f);
            addAllPrefixesButton.localeID         = "TLM_ADD_ALL";
            addAllPrefixesButton.isLocalized      = true;
            addAllPrefixesButton.textScale        = 0.6f;
            addAllPrefixesButton.width            = 80;
            addAllPrefixesButton.height           = 15;
            addAllPrefixesButton.tooltipLocaleID  = "TLM_ADD_ALL_PREFIX_TOOLTIP";
            TLMUtils.initButton(addAllPrefixesButton, true, "ButtonMenu");
            addAllPrefixesButton.name        = "AddAll";
            addAllPrefixesButton.isVisible   = true;
            addAllPrefixesButton.eventClick += (component, eventParam) => {
                TLMDepotAI.addAllPrefixesToDepot(m_buildingIdSelecionado.Building, m_secondary);
                updateCheckboxes();
            };

            TLMUtils.createUIElement(out UIButton removeAllPrefixesButton, panelTransform);
            removeAllPrefixesButton.relativePosition = new Vector3(300, 120f);
            removeAllPrefixesButton.localeID         = "TLM_REMOVE_ALL";
            removeAllPrefixesButton.isLocalized      = true;
            removeAllPrefixesButton.textScale        = 0.6f;
            removeAllPrefixesButton.width            = 80;
            removeAllPrefixesButton.height           = 15;
            removeAllPrefixesButton.tooltipLocaleID  = "TLM_REMOVE_ALL_PREFIX_TOOLTIP";
            TLMUtils.initButton(removeAllPrefixesButton, true, "ButtonMenu");
            removeAllPrefixesButton.name        = "RemoveAll";
            removeAllPrefixesButton.isVisible   = true;
            removeAllPrefixesButton.eventClick += (component, eventParam) => {
                TLMDepotAI.removeAllPrefixesFromDepot(m_buildingIdSelecionado.Building, m_secondary);
                updateCheckboxes();
            };
        }
Ejemplo n.º 3
0
        private void CreatePrefixSelectorUI()
        {
            this.m_prefixOptions = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] { }, onChangePrefixSelected, gameObject.GetComponent <UIPanel>());
            m_prefixOptions.area = new Vector4(550, 3, 80, 33);

            m_prefixesServed                   = base.Find <UILabel>("LineVehicles");
            m_prefixesServed.autoSize          = true;
            m_prefixesServed.textScale         = 0.6f;
            m_prefixesServed.pivot             = UIPivotPoint.TopLeft;
            m_prefixesServed.verticalAlignment = UIVerticalAlignment.Middle;
            m_prefixesServed.minimumSize       = new Vector2(210, 35);
            TLMUtils.LimitWidth(m_prefixesServed);


            //Buttons
            TLMUtils.createUIElement(out m_addPrefixButton, transform);
            m_addPrefixButton.pivot            = UIPivotPoint.TopRight;
            m_addPrefixButton.relativePosition = new Vector3(680, 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, secondary);
                m_addPrefixButton.isVisible    = false;
                m_removePrefixButton.isVisible = true;
            };

            TLMUtils.createUIElement(out m_removePrefixButton, transform);
            m_removePrefixButton.pivot            = UIPivotPoint.TopRight;
            m_removePrefixButton.relativePosition = new Vector3(730, 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, secondary);
                m_addPrefixButton.isVisible    = true;
                m_removePrefixButton.isVisible = false;
            };


            TLMUtils.createUIElement(out m_addAllPrefixesButton, transform);
            m_addAllPrefixesButton.pivot            = UIPivotPoint.TopRight;
            m_addAllPrefixesButton.relativePosition = new Vector3(680, 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, secondary);
                m_addPrefixButton.isVisible    = false;
                m_removePrefixButton.isVisible = true;
            };


            TLMUtils.createUIElement(out m_removeAllPrefixesButton, transform);
            m_removeAllPrefixesButton.pivot            = UIPivotPoint.TopRight;
            m_removeAllPrefixesButton.relativePosition = new Vector3(730, 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, secondary);
                m_addPrefixButton.isVisible    = true;
                m_removePrefixButton.isVisible = false;
            };
        }