예제 #1
0
        private void CreateColorSelector()
        {
            TLMUtils.createUIElement(out UIPanel panelColorSelector, m_subpanel.self.transform, "ColorSelector", new Vector4(500, 60, 0, 0));
            panelColorSelector.autoLayout                  = true;
            panelColorSelector.autoLayoutDirection         = LayoutDirection.Horizontal;
            panelColorSelector.autoLayoutPadding           = new RectOffset(3, 3, 0, 0);
            panelColorSelector.autoFitChildrenHorizontally = true;
            panelColorSelector.autoFitChildrenVertically   = true;

            TLMUtils.createUIElement(out UILabel lbl, panelColorSelector.transform, "PrefixColorLabel", new Vector4(5, 12, 250, 40));
            TLMUtils.LimitWidth(lbl, 250, true);
            lbl.localeID          = "TLM_PREFIX_COLOR_LABEL";
            lbl.verticalAlignment = UIVerticalAlignment.Middle;
            lbl.font = UIHelperExtension.defaultFontCheckbox;

            m_prefixColor = KlyteUtils.CreateColorField(panelColorSelector);
            m_prefixColor.eventSelectedColorChanged += onChangePrefixColor;

            TLMUtils.createUIElement(out UIButton resetColor, panelColorSelector.transform, "PrefixColorReset", new Vector4(290, 0, 0, 0));
            TLMUtils.initButton(resetColor, false, "ButtonMenu");
            TLMUtils.LimitWidth(resetColor, 200);
            resetColor.textPadding = new RectOffset(5, 5, 5, 2);
            resetColor.autoSize    = true;
            resetColor.localeID    = "TLM_RESET_COLOR";
            resetColor.eventClick += onResetColor;
        }
예제 #2
0
        private UIButton initDepotShortcutOnWorldInfoPanel(UIPanel parent)
        {
            UIButton saida = parent.AddUIComponent <UIButton>();

            saida.relativePosition = new Vector3(10, parent.height - 50);
            saida.atlas            = taTLM;
            saida.width            = 30;
            saida.height           = 30;
            saida.name             = "TLMDepotShortcut";
            saida.tooltipLocaleID  = "TLM_GOTO_DEPOT_PREFIX_EDIT";
            TLMUtils.initButton(saida, false, "TransportLinesManagerIcon");
            saida.eventClick += (x, y) =>
            {
                var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic
                                                           | System.Reflection.BindingFlags.Instance);
                ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building;
                depotInfoPanel.openDepotInfo(buildingId);
            };

            UILabel prefixes = saida.AddUIComponent <UILabel>();

            prefixes.autoSize         = false;
            prefixes.width            = 200;
            prefixes.wordWrap         = true;
            prefixes.textAlignment    = UIHorizontalAlignment.Left;
            prefixes.prefix           = Locale.Get("TLM_PREFIXES_SERVED") + ":\n";
            prefixes.useOutline       = true;
            prefixes.height           = 60;
            prefixes.textScale        = 0.6f;
            prefixes.relativePosition = new Vector3(40, 10);
            prefixes.name             = "Prefixes";
            return(saida);
        }
예제 #3
0
 private static UIButton CreateTabTemplate()
 {
     TLMUtils.createUIElement(out UIButton tabTemplate, null, "TLMTabTemplate");
     TLMUtils.initButton(tabTemplate, false, "GenericTab");
     tabTemplate.autoSize             = false;
     tabTemplate.width                = 40;
     tabTemplate.height               = 40;
     tabTemplate.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
     return(tabTemplate);
 }
예제 #4
0
        private void CreateTitleBar()
        {
            TLMUtils.createUIElement(out UILabel titlebar, mainPanel.transform, "TLMListPanel", new Vector4(75, 10, mainPanel.width - 150, 20));
            titlebar.autoSize      = false;
            titlebar.text          = "Transport Lines Manager v" + TLMSingleton.version;
            titlebar.textAlignment = UIHorizontalAlignment.Center;
            TLMUtils.createDragHandle(titlebar, KlyteModsPanel.instance.mainPanel);

            TLMUtils.createUIElement(out UIButton closeButton, mainPanel.transform, "CloseButton", new Vector4(mainPanel.width - 37, 5, 32, 32));
            TLMUtils.initButton(closeButton, false, "buttonclose", true);
            closeButton.hoveredBgSprite = "buttonclosehover";
            closeButton.eventClick     += (x, y) =>
            {
                TLMController.instance.CloseTLMPanel();
            };

            TLMUtils.createUIElement(out UISprite logo, mainPanel.transform, "TLMLogo", new Vector4(22, 5f, 32, 32));
            logo.atlas      = TLMController.taTLM;
            logo.spriteName = "TransportLinesManagerIconHovered";
            TLMUtils.createDragHandle(logo, KlyteModsPanel.instance.mainPanel);
        }
        private void CreateRemoveUndesiredModelsButton()
        {
            TLMUtils.createUIElement <UIButton>(out UIButton removeUndesired, m_mainPanel.transform);
            removeUndesired.relativePosition = new Vector3(m_mainPanel.width - 25f, 10f);
            removeUndesired.textScale        = 0.6f;
            removeUndesired.width            = 20;
            removeUndesired.height           = 20;
            removeUndesired.tooltip          = Locale.Get("TLM_REMOVE_UNWANTED_TOOLTIP");
            TLMUtils.initButton(removeUndesired, true, "ButtonMenu");
            removeUndesired.name        = "DeleteLineButton";
            removeUndesired.isVisible   = true;
            removeUndesired.eventClick += (component, eventParam) =>
            {
                TLMTransportExtensionUtils.RemoveAllUnwantedVehicles();
            };

            var icon = removeUndesired.AddUIComponent <UISprite>();

            icon.relativePosition = new Vector3(2, 2);
            icon.atlas            = TLMController.taTLM;
            icon.width            = 18;
            icon.height           = 18;
            icon.spriteName       = "RemoveUnwantedIcon";
        }
예제 #6
0
        private void CreateToggleBudgetButtons(UIPanel reference)
        {
            TLMUtils.createUIElement(out m_enableBudgetPerHour, reference.transform);
            m_enableBudgetPerHour.relativePosition = new Vector3(reference.width - 65f, 0f);
            m_enableBudgetPerHour.textScale        = 0.6f;
            m_enableBudgetPerHour.width            = 40;
            m_enableBudgetPerHour.height           = 40;
            m_enableBudgetPerHour.tooltip          = Locale.Get("TLM_USE_PER_PERIOD_BUDGET");
            TLMUtils.initButton(m_enableBudgetPerHour, true, "ButtonMenu");
            m_enableBudgetPerHour.name        = "EnableBudgetPerHour";
            m_enableBudgetPerHour.isVisible   = true;
            m_enableBudgetPerHour.eventClick += (component, eventParam) =>
            {
                IBudgetableExtension bte;
                uint idx;
                var  tsdRef = tsd;
                bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
                idx = (uint)SelectedPrefix;

                uint[] saveData    = bte.GetBudgetsMultiplier(idx);
                uint[] newSaveData = new uint[8];
                for (int i = 0; i < 8; i++)
                {
                    newSaveData[i] = saveData[0];
                }
                bte.SetBudgetMultiplier(idx, newSaveData);
                updateSliders();
            };

            var icon = m_enableBudgetPerHour.AddUIComponent <UISprite>();

            icon.relativePosition = new Vector3(2, 2);
            icon.atlas            = TLMController.taTLM;
            icon.width            = 36;
            icon.height           = 36;
            icon.spriteName       = "PerHourIcon";


            TLMUtils.createUIElement(out m_disableBudgetPerHour, reference.transform);
            m_disableBudgetPerHour.relativePosition = new Vector3(reference.width - 65f, 0f);
            m_disableBudgetPerHour.textScale        = 0.6f;
            m_disableBudgetPerHour.width            = 40;
            m_disableBudgetPerHour.height           = 40;
            m_disableBudgetPerHour.tooltip          = Locale.Get("TLM_USE_SINGLE_BUDGET");
            TLMUtils.initButton(m_disableBudgetPerHour, true, "ButtonMenu");
            m_disableBudgetPerHour.name        = "DisableBudgetPerHour";
            m_disableBudgetPerHour.isVisible   = true;
            m_disableBudgetPerHour.eventClick += (component, eventParam) =>
            {
                IBudgetableExtension bte;
                uint idx;
                var  tsdRef = tsd;
                bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
                idx = (uint)SelectedPrefix;

                uint[] saveData    = bte.GetBudgetsMultiplier(idx);
                uint[] newSaveData = new uint[] { saveData[0] };
                bte.SetBudgetMultiplier(idx, newSaveData);

                updateSliders();
            };

            icon = m_disableBudgetPerHour.AddUIComponent <UISprite>();
            icon.relativePosition = new Vector3(2, 2);
            icon.atlas            = TLMController.taTLM;
            icon.width            = 36;
            icon.height           = 36;
            icon.spriteName       = "24hLineIcon";
        }
예제 #7
0
        private void Awake()
        {
            base.component.eventZOrderChanged += delegate(UIComponent c, int r)
            {
                this.SetBackgroundColor();
            };
            this.m_LineIsVisible = base.Find <UICheckBox>("LineVisible");
            this.m_LineIsVisible.eventCheckChanged += (x, y) => ChangeLineVisibility(y);
            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_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);
                    });
                }
            };


            if (TLMSingleton.isIPTLoaded)
            {
                m_DisabledLine.isEnabled = false;
                m_DisabledLine.isVisible = false;
            }
            else
            {
                m_NightLine.relativePosition    = new Vector3(678, 8);
                m_DayNightLine.relativePosition = new Vector3(704, 8);
            }

            this.m_LineStops      = base.Find <UILabel>("LineStops");
            this.m_LinePassengers = base.Find <UILabel>("LinePassengers");

            var tsd = Singleton <T> .instance.GetTSD();

            this.m_LineVehicles = base.Find <UILabel>("LineVehicles");
            if (tsd.hasVehicles())
            {
                m_LineVehicles.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 5, 0);
                m_lineBudgetLabel = GameObject.Instantiate(this.m_LineStops, m_LineStops.transform.parent);
            }
            else
            {
                Destroy(m_LineVehicles.gameObject);
            }

            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);
                                GameObject.Destroy(gameObject);
                            });
                        }
                    });
                }
            };
            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.CloseTLMPanel();
                }
            };
            base.component.eventVisibilityChanged += delegate(UIComponent c, bool v)
            {
                if (v)
                {
                    this.RefreshData(true, true);
                }
            };

            //Auto color & Auto Name
            TLMUtils.createUIElement(out UIButton 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();
            };

            TLMUtils.createUIElement(out UIButton buttonAutoColor, transform);
            buttonAutoColor.pivot            = UIPivotPoint.TopRight;
            buttonAutoColor.relativePosition = new Vector3(90, 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();
            };

            m_lineIncompleteWarning = base.Find <UIPanel>("WarningIncomplete");

            if (tsd.hasVehicles())
            {
                TLMUtils.createUIElement(out m_perHourBudgetInfo, transform);
                m_perHourBudgetInfo.name              = "PerHourIndicator";
                m_perHourBudgetInfo.autoSize          = false;
                m_perHourBudgetInfo.autoHeight        = true;
                m_perHourBudgetInfo.anchor            = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
                m_perHourBudgetInfo.width             = 180;
                m_perHourBudgetInfo.height            = m_perHourBudgetInfo.parent.height;
                m_perHourBudgetInfo.verticalAlignment = UIVerticalAlignment.Middle;
                m_perHourBudgetInfo.textAlignment     = UIHorizontalAlignment.Center;
                m_perHourBudgetInfo.textScale         = 1f;
                m_perHourBudgetInfo.localeID          = "TLM_PER_HOUR_BUDGET_ACTIVE_LABEL";
                m_perHourBudgetInfo.wordWrap          = true;
                m_perHourBudgetInfo.eventTextChanged += constraintedScale;
                constraintedScale(m_perHourBudgetInfo, "");
            }
        }
예제 #8
0
        private void createInfoView()
        {
            //line info painel

            TLMUtils.createUIElement <UIPanel>(ref lineInfoPanel, m_controller.mainRef.transform);
            lineInfoPanel.Hide();
            lineInfoPanel.relativePosition  = new Vector3(394.0f, 0.0f);
            lineInfoPanel.width             = 650;
            lineInfoPanel.height            = 290;
            lineInfoPanel.zOrder            = 50;
            lineInfoPanel.color             = new Color32(255, 255, 255, 255);
            lineInfoPanel.backgroundSprite  = "MenuPanel2";
            lineInfoPanel.name              = "LineInfoPanel";
            lineInfoPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10);
            lineInfoPanel.autoLayout        = false;
            lineInfoPanel.useCenter         = true;
            lineInfoPanel.wrapLayout        = false;
            lineInfoPanel.canFocus          = true;
            TLMUtils.createDragHandle(lineInfoPanel, lineInfoPanel, 35f);
            lineInfoPanel.eventVisibilityChanged += (component, value) =>
            {
                if (m_linearMap != null)
                {
                    m_linearMap.isVisible = value;
                }
            };



            TLMUtils.createUIElement <UILabel>(ref lineTransportIconTypeLabel, lineInfoPanel.transform);
            lineTransportIconTypeLabel.autoSize         = false;
            lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f);
            lineTransportIconTypeLabel.width            = 30;
            lineTransportIconTypeLabel.height           = 20;
            lineTransportIconTypeLabel.name             = "LineTransportIcon";
            lineTransportIconTypeLabel.clipChildren     = true;
            TLMUtils.createDragHandle(lineTransportIconTypeLabel, lineInfoPanel);

            GameObject lpddgo = GameObject.Instantiate(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate).GetComponent <UIPanel>().Find <UIDropDown>("Dropdown").gameObject);

            linePrefixDropDown = lpddgo.GetComponent <UIDropDown>();
            lineInfoPanel.AttachUIComponent(linePrefixDropDown.gameObject);
            linePrefixDropDown.isLocalized         = false;
            linePrefixDropDown.autoSize            = false;
            linePrefixDropDown.horizontalAlignment = UIHorizontalAlignment.Center;
            linePrefixDropDown.text                       = "";
            linePrefixDropDown.width                      = 40;
            linePrefixDropDown.height                     = 35;
            linePrefixDropDown.name                       = "LinePrefixDropDown";
            linePrefixDropDown.textScale                  = 1.6f;
            linePrefixDropDown.itemHeight                 = 35;
            linePrefixDropDown.itemPadding                = new RectOffset(2, 2, 2, 2);
            linePrefixDropDown.textFieldPadding           = new RectOffset(2, 2, 2, 2);
            linePrefixDropDown.eventSelectedIndexChanged += saveLineNumber;
            linePrefixDropDown.relativePosition           = new Vector3(70f, 3f);


            TLMUtils.createUIElement <UITextField>(ref lineNumberLabel, lineInfoPanel.transform);
            lineNumberLabel.autoSize            = false;
            lineNumberLabel.relativePosition    = new Vector3(80f, 3f);
            lineNumberLabel.horizontalAlignment = UIHorizontalAlignment.Center;
            lineNumberLabel.text           = "";
            lineNumberLabel.width          = 75;
            lineNumberLabel.height         = 35;
            lineNumberLabel.name           = "LineNumberLabel";
            lineNumberLabel.normalBgSprite = "EmptySprite";
            lineNumberLabel.textScale      = 1.6f;
            lineNumberLabel.padding        = new RectOffset(5, 5, 5, 5);
            lineNumberLabel.color          = new Color(0, 0, 0, 1);
            TLMUtils.uiTextFieldDefaults(lineNumberLabel);
            lineNumberLabel.numericalOnly   = true;
            lineNumberLabel.maxLength       = 4;
            lineNumberLabel.eventLostFocus += saveLineNumber;
            lineNumberLabel.zOrder          = 10;


            TLMUtils.createUIElement <UITextField>(ref lineNameField, lineInfoPanel.transform);
            lineNameField.autoSize            = false;
            lineNameField.relativePosition    = new Vector3(190f, 10f);
            lineNameField.horizontalAlignment = UIHorizontalAlignment.Center;
            lineNameField.text      = "NOME";
            lineNameField.width     = 450;
            lineNameField.height    = 25;
            lineNameField.name      = "LineNameLabel";
            lineNameField.maxLength = 256;
            lineNameField.textScale = 1.5f;
            TLMUtils.uiTextFieldDefaults(lineNameField);
            lineNameField.eventGotFocus += (component, eventParam) =>
            {
                lastLineName = lineNameField.text;
            };
            lineNameField.eventLostFocus += (component, eventParam) =>
            {
                if (lastLineName != lineNameField.text)
                {
                    saveLineName(lineNameField);
                }
                lineNameField.text = m_controller.tm.GetLineName(m_lineIdSelecionado.TransportLine);
            };

            TLMUtils.createUIElement <UILabel>(ref lineLenghtLabel, lineInfoPanel.transform);
            lineLenghtLabel.autoSize         = false;
            lineLenghtLabel.relativePosition = new Vector3(10f, 60f);
            lineLenghtLabel.textAlignment    = UIHorizontalAlignment.Left;
            lineLenghtLabel.text             = "";
            lineLenghtLabel.width            = 550;
            lineLenghtLabel.height           = 25;
            lineLenghtLabel.prefix           = "";
            lineLenghtLabel.suffix           = "";
            lineLenghtLabel.name             = "LineLenghtLabel";
            lineLenghtLabel.textScale        = 0.8f;

            TLMUtils.createUIElement <UILabel>(ref detailedStatsLabel, lineInfoPanel.transform);
            detailedStatsLabel.autoSize         = false;
            detailedStatsLabel.relativePosition = new Vector3(10f, 75f);
            detailedStatsLabel.textAlignment    = UIHorizontalAlignment.Left;
            detailedStatsLabel.width            = 550;
            detailedStatsLabel.height           = 25;
            detailedStatsLabel.name             = "ExtraInfoLabel";
            detailedStatsLabel.textScale        = 0.8f;
            detailedStatsLabel.prefix           = Locale.Get("TLM_LINE_EFFECTIVE_BUDGET") + ": ";

            TLMUtils.createUIElement <UILabel>(ref veiculosLinhaLabel, lineInfoPanel.transform);
            veiculosLinhaLabel.autoSize         = false;
            veiculosLinhaLabel.relativePosition = new Vector3(10f, 90);
            veiculosLinhaLabel.textAlignment    = UIHorizontalAlignment.Left;
            veiculosLinhaLabel.text             = "";
            veiculosLinhaLabel.width            = 550;
            veiculosLinhaLabel.height           = 25;
            veiculosLinhaLabel.name             = "VehiclesLineLabel";
            veiculosLinhaLabel.textScale        = 0.8f;

            TLMUtils.createUIElement <UILabel>(ref viagensEvitadasLabel, lineInfoPanel.transform);
            viagensEvitadasLabel.autoSize         = false;
            viagensEvitadasLabel.relativePosition = new Vector3(10f, 105);
            viagensEvitadasLabel.textAlignment    = UIHorizontalAlignment.Left;
            viagensEvitadasLabel.text             = "";
            viagensEvitadasLabel.width            = 250;
            viagensEvitadasLabel.height           = 25;
            viagensEvitadasLabel.name             = "AvoidedTravelsLabel";
            viagensEvitadasLabel.textScale        = 0.8f;

            TLMUtils.createUIElement <UILabel>(ref passageirosEturistasLabel, lineInfoPanel.transform);
            passageirosEturistasLabel.autoSize         = false;
            passageirosEturistasLabel.relativePosition = new Vector3(10f, 120f);
            passageirosEturistasLabel.textAlignment    = UIHorizontalAlignment.Left;
            passageirosEturistasLabel.text             = "";
            passageirosEturistasLabel.width            = 350;
            passageirosEturistasLabel.height           = 25;
            passageirosEturistasLabel.name             = "TouristAndPassagersLabel";
            passageirosEturistasLabel.textScale        = 0.8f;

            //TLMUtils.createUIElement<UILabel>(ref generalDebugLabel, lineInfoPanel.transform);
            //generalDebugLabel.autoSize = false;
            //generalDebugLabel.relativePosition = new Vector3(10f, 185f);
            //generalDebugLabel.textAlignment = UIHorizontalAlignment.Left;
            //generalDebugLabel.prefix = "DEBUG: DATA AVAIL = ";
            //generalDebugLabel.width = 350;
            //generalDebugLabel.height = 100;
            //generalDebugLabel.name = "CustosLabel";
            //generalDebugLabel.textScale = 0.8f;
            //generalDebugLabel.wordWrap = true;
            //generalDebugLabel.clipChildren = false;
            //generalDebugLabel.enabled = false && TransportLinesManagerMod.debugMode.value;
            TLMUtils.createUIElement <UILabel>(ref vehicleQuantitySetLabel, lineInfoPanel.transform);
            vehicleQuantitySetLabel.autoSize         = false;
            vehicleQuantitySetLabel.relativePosition = new Vector3(10f, 135f);
            vehicleQuantitySetLabel.textAlignment    = UIHorizontalAlignment.Left;
            vehicleQuantitySetLabel.localeID         = "TLM_SET_FIXED_VEHICLE_NUMBER_LINE";
            vehicleQuantitySetLabel.isLocalized      = true;
            vehicleQuantitySetLabel.width            = 300;
            vehicleQuantitySetLabel.height           = 40;
            vehicleQuantitySetLabel.name             = "FixedVehiclesLabel";
            vehicleQuantitySetLabel.textScale        = 0.8f;
            vehicleQuantitySetLabel.clipChildren     = false;
            vehicleQuantitySetLabel.zOrder           = 0;

            vehicleQuantitySet = UITextField.Instantiate(lineNumberLabel);
            vehicleQuantitySet.transform.SetParent(lineInfoPanel.transform);
            vehicleQuantitySet.relativePosition = new Vector3(120f, 165f);
            vehicleQuantitySet.size             = new Vector2(50, 30);
            vehicleQuantitySet.padding          = new RectOffset(0, 0, 0, 0);
            vehicleQuantitySet.textScale        = 0.8f;
            vehicleQuantitySet.numericalOnly    = true;
            vehicleQuantitySet.eventLostFocus  += (x, y) =>
            {
                TLMVehiclesLineManager.instance[this.lineIdSelecionado.TransportLine] = int.Parse(vehicleQuantitySet.text);
            };

            TLMUtils.createUIElement <UILabel>(ref m_autoNameLabel, lineInfoPanel.transform);
            m_autoNameLabel.autoSize         = false;
            m_autoNameLabel.relativePosition = new Vector3(10f, 180f);
            m_autoNameLabel.textAlignment    = UIHorizontalAlignment.Left;
            m_autoNameLabel.prefix           = Locale.Get("TLM_GENERATED_AUTO_NAME") + ": ";
            m_autoNameLabel.width            = 350;
            m_autoNameLabel.height           = 100;
            m_autoNameLabel.name             = "AutoNameLabel";
            m_autoNameLabel.textScale        = 0.8f;
            m_autoNameLabel.wordWrap         = true;
            m_autoNameLabel.clipChildren     = false;

            lineColorPicker = GameObject.Instantiate(PublicTransportWorldInfoPanel.FindObjectOfType <UIColorField>().gameObject).GetComponent <UIColorField>();
            //
            lineInfoPanel.AttachUIComponent(lineColorPicker.gameObject);
            lineColorPicker.name                       = "LineColorPicker";
            lineColorPicker.relativePosition           = new Vector3(50f, 10f);
            lineColorPicker.enabled                    = true;
            lineColorPicker.anchor                     = UIAnchorStyle.Top & UIAnchorStyle.Left;
            lineColorPicker.eventSelectedColorChanged += (UIComponent component, Color value) =>
            {
                TLMUtils.setLineColor(m_lineIdSelecionado.TransportLine, value);
                updateLineUI(value);
            };

            lineTime = UIHelperExtension.CloneBasicDropDown(Locale.Get("TRANSPORT_LINE_ACTIVITY"), new string[] {
                Locale.Get("TRANSPORT_LINE_DAYNNIGHT"),
                Locale.Get("TRANSPORT_LINE_DAY"),
                Locale.Get("TRANSPORT_LINE_NIGHT"),
                Locale.Get("TLM_TRANSPORT_LINE_DISABLED")
            }, changeLineTime, lineInfoPanel, out lineTimeTitle);
            lineTime.parent.relativePosition = new Vector3(120f, 220f);

            UIButton deleteLine = null;

            TLMUtils.createUIElement <UIButton>(ref deleteLine, lineInfoPanel.transform);
            deleteLine.relativePosition = new Vector3(10f, lineInfoPanel.height - 40f);
            deleteLine.localeID         = "LINE_DELETE";
            deleteLine.isLocalized      = true;
            deleteLine.autoSize         = true;
            deleteLine.textPadding      = new RectOffset(3, 3, 3, 3);
            TLMUtils.initButton(deleteLine, true, "ButtonMenu");
            deleteLine.name        = "DeleteLineButton";
            deleteLine.color       = new Color(1, 0, 0, 1);
            deleteLine.eventClick += (UIComponent component, UIMouseEventParameter eventParam) =>
            {
                Singleton <SimulationManager> .instance.AddAction(delegate
                {
                    Singleton <TransportManager> .instance.ReleaseLine(m_lineIdSelecionado.TransportLine);
                });

                closeLineInfo(component, eventParam);
            };
            UIButton voltarButton2 = null;

            TLMUtils.createUIElement <UIButton>(ref voltarButton2, lineInfoPanel.transform);
            voltarButton2.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 40f);
            voltarButton2.localeID         = "CLOSE";
            voltarButton2.isLocalized      = true;
            voltarButton2.width            = 240;
            voltarButton2.height           = 30;
            TLMUtils.initButton(voltarButton2, true, "ButtonMenu");
            voltarButton2.name        = "LineInfoCloseButton";
            voltarButton2.eventClick += closeLineInfo;

            UIButton autoName = null;

            TLMUtils.createUIElement <UIButton>(ref autoName, lineInfoPanel.transform);
            autoName.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 80f);
            autoName.localeID         = "TLM_USE_AUTO_NAME";
            autoName.isLocalized      = true;
            autoName.width            = 240;
            autoName.height           = 30;
            TLMUtils.initButton(autoName, true, "ButtonMenu");
            autoName.name        = "AutoNameButton";
            autoName.eventClick += (component, eventParam) =>
            {
                lineNameField.text = m_linearMap.autoName;
                saveLineName(lineNameField);
            };

            UIButton autoColor = null;

            TLMUtils.createUIElement <UIButton>(ref autoColor, lineInfoPanel.transform);
            autoColor.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 120f);
            autoColor.localeID         = "TLM_PICK_COLOR_FROM_PALETTE";
            autoColor.isLocalized      = true;
            autoColor.tooltipLocaleID  = "TLM_PICK_COLOR_FROM_PALETTE_TOOLTIP";
            autoColor.width            = 240;
            autoColor.height           = 30;
            TLMUtils.initButton(autoColor, true, "ButtonMenu");
            autoColor.name          = "AutoNameButton";
            autoColor.eventMouseUp += (component, eventParam) =>
            {
                lineColorPicker.selectedColor = m_controller.AutoColor(m_lineIdSelecionado.TransportLine);
                updateLineUI(lineColorPicker.selectedColor);
            };


            agesPanel   = new TLMAgesChartPanel(this);
            m_linearMap = new TLMLinearMap(this);
        }
예제 #9
0
        private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections,
                                            string airport, string harbor, string taxi, string regionalTrainStation, string cableCarStation,
                                            ushort stationNodeId, ItemClass.SubService ss, Color lineColor, bool simple)//, out float intersectionPanelHeight)
        {
            ushort           lineID = parent.CurrentSelectedId;
            TransportLine    t      = TLMController.instance.tm.m_lines.m_buffer[(int)lineID];
            TransportManager tm     = Singleton <TransportManager> .instance;

            if (stationName == null)
            {
                stationName = "???";
            }

            TLMUtils.createUIElement(out UIButton stationButton, lineStationsPanel.transform);
            stationButton.relativePosition = new Vector3(offsetX - 13, 15f);
            stationButton.width            = 20;
            stationButton.height           = 20;
            stationButton.color            = lineColor;
            stationButton.name             = "Station [" + stationName + "]";
            stationButton.atlas            = TLMController.taLineNumber;
            stationButton.tooltip          = stationName + "(id:" + stationNodeId + ")";
            TLMUtils.initButton(stationButton, true, "LinearStation");

            TLMUtils.createUIElement(out DroppableStationInfo dsi, stationButton.transform);
            dsi.nodeId = stationNodeId;
            dsi.name   = "DSI Station [" + stationName + "] - " + stationNodeId;

            TLMUtils.createUIElement(out UITextField stationLabel, stationButton.transform);
            stationLabel.autoSize            = true;
            stationLabel.width               = 220;
            stationLabel.height              = 20;
            stationLabel.useOutline          = true;
            stationLabel.pivot               = UIPivotPoint.MiddleLeft;
            stationLabel.horizontalAlignment = UIHorizontalAlignment.Left;
            stationLabel.verticalAlignment   = UIVerticalAlignment.Middle;
            stationLabel.name             = "Station [" + stationName + "] Name";
            stationLabel.relativePosition = new Vector3(23f, -13f);
            stationLabel.text             = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim();
            stationLabel.textScale        = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length));

            TLMUtils.uiTextFieldDefaults(stationLabel);
            stationLabel.color           = new Color(0.3f, 0.3f, 0.3f, 1);
            stationLabel.textColor       = Color.white;
            stationLabel.cursorWidth     = 2;
            stationLabel.cursorBlinkTime = 100;
            stationLabel.eventGotFocus  += (x, y) =>
            {
                stationLabel.text = TLMLineUtils.getStationName(stationNodeId, lineID, ss);
            };
            stationLabel.eventTextSubmitted += (x, y) =>
            {
                TLMLineUtils.setStopName(y, stationNodeId, lineID, () =>
                {
                    stationLabel.text = TLMLineUtils.getFullStationName(stationNodeId, lineID, ss);
                    m_autoName        = TLMLineUtils.calculateAutoName(lineID, true);
                    parent.OnRenameStationAction(autoName);
                });
            };

            stationButton.gameObject.transform.localPosition    = new Vector3(0, 0, 0);
            stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45);
            stationButton.eventClick += (component, eventParam) =>
            {
                GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera");
                if (gameObject != null)
                {
                    var        cameraController = gameObject.GetComponent <CameraController>();
                    InstanceID x = default(InstanceID);
                    x.TransportLine = parent.CurrentSelectedId;
                    cameraController.SetTarget(x, location, false);
                    cameraController.ClearTarget();
                }
            };
            if (!simple)
            {
                if (!stationOffsetX.ContainsKey(stationNodeId))
                {
                    stationOffsetX.Add(stationNodeId, offsetX);
                }
                if (showIntersections)
                {
                    var     otherLinesIntersections = TLMLineUtils.SortLines(intersections, t);
                    UILabel distance          = null;
                    int     intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0) + (cableCarStation != string.Empty ? 1 : 0);

                    if ((TLMSingleton.showDistanceInLinearMap || parent.ForceShowStopsDistances) && offsetX > 0)
                    {
                        NetSegment seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment0];
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment1];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment2];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment3];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment4];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment5];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment6];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment7];
                        }
                        if (seg.m_endNode != stationNodeId)
                        {
                            seg = default(NetSegment);
                        }
                        TLMUtils.createUIElement(out UIPanel distContainer, stationButton.transform);
                        distContainer.size             = new Vector2(0, 0);
                        distContainer.relativePosition = new Vector3(0, 0, 0);
                        TLMUtils.createUIElement(out distance, distContainer.transform);
                        distance.autoSize   = false;
                        distance.useOutline = true;
                        if (seg.Equals(default(NetSegment)))
                        {
                            distance.text  = "???";
                            distance.color = Color.red;
                        }
                        else
                        {
                            distance.text = (int)seg.m_averageLength + "m";
                        }
                        distance.textScale         = 0.7f;
                        distance.textAlignment     = UIHorizontalAlignment.Center;
                        distance.verticalAlignment = UIVerticalAlignment.Middle;
                        distance.name                       = "dist.";
                        distance.font                       = UIHelperExtension.defaultFontCheckbox;
                        distance.width                      = 50f;
                        distance.height                     = 50;
                        distance.relativePosition           = new Vector3(-42, 0);
                        distance.transform.localEulerAngles = new Vector3(0, 0, 45);
                        distance.isInteractive              = false;
                    }

                    if (intersectionCount > 0)
                    {
                        TLMUtils.createUIElement(out UIPanel intersectionsPanel, stationButton.transform);
                        intersectionsPanel.autoSize                  = false;
                        intersectionsPanel.autoLayout                = false;
                        intersectionsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                        intersectionsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                        intersectionsPanel.relativePosition          = new Vector3(-20, 10);
                        intersectionsPanel.wrapLayout                = false;
                        intersectionsPanel.autoFitChildrenVertically = true;

                        TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, cableCarStation, intersectionsPanel, otherLinesIntersections);
                        intersectionsPanel.autoLayout = true;
                        intersectionsPanel.wrapLayout = true;
                        intersectionsPanel.width      = 55;
                        //
                        return(42f);
                    }
                    else
                    {
                        TLMUtils.initButton(stationButton, true, "LinearHalfStation");
                        if (offsetX == 0)
                        {
                            stationButton.relativePosition = new Vector3(offsetX - 13, 15f);
                            return(31f);
                        }
                        else if (distance == null)
                        {
                            stationButton.relativePosition = new Vector3(offsetX - 23, 15f);
                            return(21f);
                        }
                        else
                        {
                            return(42f);
                        }
                    }
                }
                else if (showExtraStopInfo)
                {
                    float normalWidth = 42.5f;

                    NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId];

                    TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out int residents, out int tourists, out int ttb);

                    TLMUtils.createUIElement(out UIPanel stationInfoStatsPanel, stationButton.transform);
                    stationInfoStatsPanel.autoSize   = false;
                    stationInfoStatsPanel.autoLayout = false;
                    stationInfoStatsPanel.autoFitChildrenVertically = true;
                    stationInfoStatsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                    stationInfoStatsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                    stationInfoStatsPanel.relativePosition          = new Vector3(-20, 10);
                    stationInfoStatsPanel.autoLayout = true;
                    stationInfoStatsPanel.wrapLayout = true;
                    stationInfoStatsPanel.width      = normalWidth;

                    TLMUtils.createUIElement(out UILabel residentsWaiting, stationInfoStatsPanel.transform);
                    residentsWaiting.autoSize         = false;
                    residentsWaiting.useOutline       = true;
                    residentsWaiting.text             = residents.ToString();
                    residentsWaiting.tooltipLocaleID  = "TLM_RESIDENTS_WAITING";
                    residentsWaiting.backgroundSprite = "EmptySprite";
                    residentsWaiting.color            = new Color32(0x12, 0x68, 0x34, 255);
                    residentsWaiting.width            = normalWidth;
                    residentsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    residentsWaiting.height           = 20;
                    residentsWaiting.textScale        = 0.7f;
                    residentsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    residentCounters[stationNodeId]   = residentsWaiting;

                    TLMUtils.createUIElement(out UILabel touristsWaiting, stationInfoStatsPanel.transform);
                    touristsWaiting.autoSize         = false;
                    touristsWaiting.text             = tourists.ToString();
                    touristsWaiting.tooltipLocaleID  = "TLM_TOURISTS_WAITING";
                    touristsWaiting.useOutline       = true;
                    touristsWaiting.width            = normalWidth;
                    touristsWaiting.height           = 20;
                    touristsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    touristsWaiting.textScale        = 0.7f;
                    touristsWaiting.backgroundSprite = "EmptySprite";
                    touristsWaiting.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    touristsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    touristCounters[stationNodeId]   = touristsWaiting;

                    TLMUtils.createUIElement(out UILabel timeTilBored, stationInfoStatsPanel.transform);
                    timeTilBored.autoSize         = false;
                    timeTilBored.text             = tourists.ToString();
                    timeTilBored.tooltipLocaleID  = "TLM_TIME_TIL_BORED";
                    timeTilBored.useOutline       = true;
                    timeTilBored.width            = normalWidth;
                    timeTilBored.height           = 20;
                    timeTilBored.padding          = new RectOffset(0, 0, 4, 2);
                    timeTilBored.textScale        = 0.7f;
                    timeTilBored.backgroundSprite = "EmptySprite";
                    timeTilBored.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    timeTilBored.textAlignment    = UIHorizontalAlignment.Center;
                    ttbTimers[stationNodeId]      = timeTilBored;
                    //
                    return(normalWidth);
                }
                else
                {
                    return(30f);
                }
            }
            else
            {
                return(30f);
            }
        }
예제 #10
0
        private void createLineStationsLinearView()
        {
            TLMUtils.createUIElement(out mainContainer, parent.TransformLinearMap);
            mainContainer.absolutePosition = new Vector3(2f, TLMController.instance.uiView.fixedHeight - 300f);
            mainContainer.name             = "LineStationsLinearView";
            mainContainer.height           = 50;
            mainContainer.autoSize         = true;

            TLMUtils.createUIElement(out linearMapLineNumberFormat, mainContainer.transform);
            linearMapLineNumberFormat.autoSize          = false;
            linearMapLineNumberFormat.width             = 50;
            linearMapLineNumberFormat.height            = 50;
            linearMapLineNumberFormat.color             = new Color(1, 0, 0, 1);
            linearMapLineNumberFormat.pivot             = UIPivotPoint.MiddleLeft;
            linearMapLineNumberFormat.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineNumberFormat.verticalAlignment = UIVerticalAlignment.Middle;
            linearMapLineNumberFormat.name             = "LineFormat";
            linearMapLineNumberFormat.relativePosition = new Vector3(0f, 0f);
            linearMapLineNumberFormat.atlas            = TLMController.taLineNumber;
            TLMUtils.createDragHandle(linearMapLineNumberFormat, mainContainer);



            TLMUtils.createUIElement(out linearMapLineNumber, linearMapLineNumberFormat.transform);

            linearMapLineNumber.autoSize          = false;
            linearMapLineNumber.width             = linearMapLineNumberFormat.width;
            linearMapLineNumber.pivot             = UIPivotPoint.MiddleCenter;
            linearMapLineNumber.name              = "LineNumber";
            linearMapLineNumber.width             = 50;
            linearMapLineNumber.height            = 50;
            linearMapLineNumber.relativePosition  = new Vector3(-0.5f, 0.5f);
            linearMapLineNumber.autoHeight        = false;
            linearMapLineNumber.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineNumber.verticalAlignment = UIVerticalAlignment.Middle;


            TLMUtils.createUIElement(out linearMapLineTime, linearMapLineNumberFormat.transform);
            linearMapLineTime.autoSize          = false;
            linearMapLineTime.width             = 50;
            linearMapLineTime.height            = 50;
            linearMapLineTime.color             = new Color(1, 1, 1, 1);
            linearMapLineTime.pivot             = UIPivotPoint.MiddleLeft;
            linearMapLineTime.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineTime.verticalAlignment = UIVerticalAlignment.Middle;
            linearMapLineTime.name             = "LineTime";
            linearMapLineTime.relativePosition = new Vector3(0f, 0f);
            linearMapLineTime.atlas            = TLMController.taLineNumber;

            //if (parent.PrefixSelector)
            //{
            //    prefixSelector = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] { "/", "B" }, (y) =>
            //    {
            //        SetSelectedPrefix(y);
            //    }, linearMapLineNumberFormat
            //    );
            //    prefixSelector.autoSize = false;
            //    prefixSelector.width = linearMapLineNumberFormat.width;
            //    prefixSelector.pivot = UIPivotPoint.MiddleCenter;
            //    prefixSelector.name = "LinePrefixSelector";
            //    prefixSelector.width = 50;
            //    prefixSelector.height = 50;
            //    prefixSelector.relativePosition = new Vector3(-0.5f, 0.5f);
            //    prefixSelector.textScale = 1;
            //    prefixSelector.textFieldPadding.top = 999999;
            //    prefixSelector.textFieldPadding.bottom = 999999;
            //    prefixSelector.textFieldPadding.left = 999999;
            //    prefixSelector.textFieldPadding.right = 999999;
            //    prefixSelector.normalBgSprite = null;
            //    prefixSelector.hoveredBgSprite = null;
            //    prefixSelector.focusedBgSprite = null;
            //    prefixSelector.zOrder = 999;
            //    var dragH = TLMUtils.createDragHandle(prefixSelector, mainContainer);

            //    dragH.eventClicked += (x, y) =>
            //    {
            //        prefixSelector.SimulateClick();
            //    };
            //    TransportManagerOverrides.OnLineRelease += () =>
            //        {
            //            TLMUtils.doLog("OnLineRelease");
            //            if (isVisible)
            //            {
            //                SetSelectedPrefix(prefixSelector.selectedIndex);
            //                UpdatePrefixSelector();
            //            }
            //        };

            //}

            if (parent.CanSwitchView)
            {
                TLMUtils.createUIElement(out infoToggle, mainContainer.transform);
                TLMUtils.initButton(infoToggle, true, "ButtonMenu");
                infoToggle.relativePosition = new Vector3(0f, 60f);
                infoToggle.width            = 50;
                infoToggle.height           = 70;
                infoToggle.wordWrap         = true;
                infoToggle.localeID         = "TLM_SHOW_EXTRA_INFO";
                infoToggle.isLocalized      = true;
                infoToggle.textScale        = 0.8f;
                infoToggle.eventClick      += (x, y) =>
                {
                    showIntersections = !showIntersections;
                    showExtraStopInfo = !showIntersections;
                    if (showIntersections)
                    {
                        infoToggle.localeID      = "TLM_SHOW_EXTRA_INFO";
                        distanceToggle.isVisible = true;
                    }
                    else
                    {
                        infoToggle.localeID      = "TLM_SHOW_LINE_INTEGRATION_SHORT";
                        distanceToggle.isVisible = false;
                    }
                    redrawLine();
                };


                TLMUtils.createUIElement(out distanceToggle, mainContainer.transform);
                TLMUtils.initButton(distanceToggle, true, "ButtonMenu");
                distanceToggle.relativePosition   = new Vector3(0f, 135f);
                distanceToggle.width              = 50;
                distanceToggle.height             = 20;
                distanceToggle.wordWrap           = true;
                distanceToggle.tooltipLocaleID    = "TLM_TOGGLE_DISTANCE_LINEAR_MAP";
                distanceToggle.isTooltipLocalized = true;
                distanceToggle.textScale          = 0.8f;
                distanceToggle.text        = "Δd";
                distanceToggle.eventClick += (x, y) =>
                {
                    TLMSingleton.showDistanceInLinearMap = !TLMSingleton.showDistanceInLinearMap;
                    redrawLine();
                };
            }

            createLineStationsPanel();
        }
예제 #11
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();
            };
        }
        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();
            };
        }
예제 #13
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;
            };
        }
예제 #14
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;
            };
        }
예제 #15
0
        private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections, string airport, string harbor, string taxi, string regionalTrainStation, ushort stationNodeId, ItemClass.SubService ss, bool simple = false)//, out float intersectionPanelHeight)
        {
            ushort           lineID = lineInfoPanel.lineIdSelecionado.TransportLine;
            TransportLine    t      = lineInfoPanel.controller.tm.m_lines.m_buffer[(int)lineID];
            TransportManager tm     = Singleton <TransportManager> .instance;

            UIButton stationButton = null;

            TLMUtils.createUIElement <UIButton>(ref stationButton, lineStationsPanel.transform);
            stationButton.relativePosition = new Vector3(offsetX, 15f);
            stationButton.width            = 20;
            stationButton.height           = 20;
            stationButton.name             = "Station [" + stationName + "]";
            TLMUtils.initButton(stationButton, true, "IconPolicyBaseCircle");

            UITextField stationLabel = null;

            TLMUtils.createUIElement <UITextField>(ref stationLabel, stationButton.transform);
            stationLabel.autoSize            = true;
            stationLabel.width               = 220;
            stationLabel.height              = 20;
            stationLabel.useOutline          = true;
            stationLabel.pivot               = UIPivotPoint.MiddleLeft;
            stationLabel.horizontalAlignment = UIHorizontalAlignment.Left;
            stationLabel.verticalAlignment   = UIVerticalAlignment.Middle;
            stationLabel.name             = "Station [" + stationName + "] Name";
            stationLabel.relativePosition = new Vector3(23f, -13f);
            stationLabel.text             = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim();
            stationLabel.textScale        = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length));

            TLMUtils.uiTextFieldDefaults(stationLabel);
            stationLabel.color           = new Color(0.3f, 0.3f, 0.3f, 1);
            stationLabel.textColor       = Color.white;
            stationLabel.cursorWidth     = 2;
            stationLabel.cursorBlinkTime = 100;
            stationLabel.eventGotFocus  += (x, y) =>
            {
                stationLabel.text = TLMUtils.getStationName(stationNodeId, lineID, ss);
            };
            stationLabel.eventTextSubmitted += (x, y) =>
            {
                TLMUtils.setStopName(y, stationNodeId, lineID, () =>
                {
                    stationLabel.text = TLMUtils.getFullStationName(stationNodeId, lineID, ss);
                    m_autoName        = TLMUtils.calculateAutoName(lineID);
                    lineInfoPanel.autoNameLabel.text = autoName;
                });
            };

            stationButton.gameObject.transform.localPosition    = new Vector3(0, 0, 0);
            stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45);
            stationButton.eventClick += (component, eventParam) =>
            {
                lineInfoPanel.cameraController.SetTarget(lineInfoPanel.lineIdSelecionado, location, false);
                lineInfoPanel.cameraController.ClearTarget();
            };
            if (!simple)
            {
                stationOffsetX.Add(stationNodeId, offsetX);
                if (showIntersections)
                {
                    var otherLinesIntersections = TLMLineUtils.SortLines(intersections, t);

                    int intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0);
                    if (intersectionCount > 0)
                    {
                        UIPanel intersectionsPanel = null;
                        TLMUtils.createUIElement <UIPanel>(ref intersectionsPanel, stationButton.transform);
                        intersectionsPanel.autoSize                  = false;
                        intersectionsPanel.autoLayout                = false;
                        intersectionsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                        intersectionsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                        intersectionsPanel.relativePosition          = new Vector3(-20, 10);
                        intersectionsPanel.wrapLayout                = false;
                        intersectionsPanel.autoFitChildrenVertically = true;

                        TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, intersectionsPanel, otherLinesIntersections);

                        intersectionsPanel.autoLayout = true;
                        intersectionsPanel.wrapLayout = true;
                        intersectionsPanel.width      = 55;
                        //
                        return(42f);
                    }
                    else
                    {
                        return(25f);
                    }
                }
                else if (showExtraStopInfo)
                {
                    float normalWidth = 42.5f;

                    NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId];

                    int residents, tourists;
                    TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out residents, out tourists);

                    UIPanel stationInfoStatsPanel = null;
                    TLMUtils.createUIElement <UIPanel>(ref stationInfoStatsPanel, stationButton.transform);
                    stationInfoStatsPanel.autoSize   = false;
                    stationInfoStatsPanel.autoLayout = false;
                    stationInfoStatsPanel.autoFitChildrenVertically = true;
                    stationInfoStatsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                    stationInfoStatsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                    stationInfoStatsPanel.relativePosition          = new Vector3(-20, 10);
                    stationInfoStatsPanel.autoLayout = true;
                    stationInfoStatsPanel.wrapLayout = true;
                    stationInfoStatsPanel.width      = normalWidth;

                    UILabel residentsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref residentsWaiting, stationInfoStatsPanel.transform);
                    residentsWaiting.autoSize         = false;
                    residentsWaiting.useOutline       = true;
                    residentsWaiting.text             = residents.ToString();
                    residentsWaiting.tooltipLocaleID  = "TLM_RESIDENTS_WAITING";
                    residentsWaiting.backgroundSprite = "EmptySprite";
                    residentsWaiting.color            = new Color32(0x12, 0x68, 0x34, 255);
                    residentsWaiting.width            = normalWidth;
                    residentsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    residentsWaiting.height           = 20;
                    residentsWaiting.textScale        = 0.7f;
                    residentsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    residentCounters[stationNodeId]   = residentsWaiting;

                    UILabel touristsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref touristsWaiting, stationInfoStatsPanel.transform);
                    touristsWaiting.autoSize         = false;
                    touristsWaiting.text             = tourists.ToString();
                    touristsWaiting.tooltipLocaleID  = "TLM_TOURISTS_WAITING";
                    touristsWaiting.useOutline       = true;
                    touristsWaiting.width            = normalWidth;
                    touristsWaiting.height           = 20;
                    touristsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    touristsWaiting.textScale        = 0.7f;
                    touristsWaiting.backgroundSprite = "EmptySprite";
                    touristsWaiting.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    touristsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    touristCounters[stationNodeId]   = touristsWaiting;
                    //
                    return(normalWidth);
                }
                else
                {
                    return(25f);
                }
            }
            else
            {
                return(30f);
            }
        }
예제 #16
0
        private void createLineStationsLinearView()
        {
            TLMUtils.createUIElement <UIPanel>(ref mainContainer, lineInfoPanel.transform);
            mainContainer.absolutePosition = new Vector3(2f, lineInfoPanel.controller.uiView.fixedHeight - 300f);
            mainContainer.name             = "LineStationsLinearView";
            mainContainer.height           = 50;
            mainContainer.autoSize         = true;

            TLMUtils.createUIElement <UILabel>(ref linearMapLineNumberFormat, mainContainer.transform);
            linearMapLineNumberFormat.autoSize          = false;
            linearMapLineNumberFormat.width             = 50;
            linearMapLineNumberFormat.height            = 50;
            linearMapLineNumberFormat.color             = new Color(1, 0, 0, 1);
            linearMapLineNumberFormat.pivot             = UIPivotPoint.MiddleLeft;
            linearMapLineNumberFormat.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineNumberFormat.verticalAlignment = UIVerticalAlignment.Middle;
            linearMapLineNumberFormat.name             = "LineFormat";
            linearMapLineNumberFormat.relativePosition = new Vector3(0f, 0f);
            linearMapLineNumberFormat.atlas            = TLMController.taLineNumber;
            TLMUtils.createDragHandle(linearMapLineNumberFormat, mainContainer);

            TLMUtils.createUIElement <UILabel>(ref linearMapLineNumber, linearMapLineNumberFormat.transform);
            linearMapLineNumber.autoSize          = false;
            linearMapLineNumber.autoHeight        = false;
            linearMapLineNumber.width             = linearMapLineNumberFormat.width;
            linearMapLineNumber.pivot             = UIPivotPoint.MiddleCenter;
            linearMapLineNumber.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineNumber.verticalAlignment = UIVerticalAlignment.Middle;
            linearMapLineNumber.name             = "LineNumber";
            linearMapLineNumber.width            = 50;
            linearMapLineNumber.height           = 50;
            linearMapLineNumber.relativePosition = new Vector3(-0.5f, 0.5f);
            TLMUtils.createDragHandle(linearMapLineNumber, mainContainer);

            TLMUtils.createUIElement <UILabel>(ref linearMapLineTime, linearMapLineNumberFormat.transform);
            linearMapLineTime.autoSize          = false;
            linearMapLineTime.width             = 50;
            linearMapLineTime.height            = 50;
            linearMapLineTime.color             = new Color(1, 1, 1, 1);
            linearMapLineTime.pivot             = UIPivotPoint.MiddleLeft;
            linearMapLineTime.textAlignment     = UIHorizontalAlignment.Center;
            linearMapLineTime.verticalAlignment = UIVerticalAlignment.Middle;
            linearMapLineTime.name             = "LineTime";
            linearMapLineTime.relativePosition = new Vector3(0f, 0f);
            linearMapLineTime.atlas            = TLMController.taLineNumber;
            TLMUtils.createDragHandle(linearMapLineTime, mainContainer);

            TLMUtils.createUIElement <UIButton>(ref infoToggle, mainContainer.transform);
            TLMUtils.initButton(infoToggle, true, "ButtonMenu");
            infoToggle.relativePosition = new Vector3(0f, 60f);
            infoToggle.width            = 50;
            infoToggle.height           = 70;
            infoToggle.wordWrap         = true;
            infoToggle.localeID         = "TLM_SHOW_EXTRA_INFO";
            infoToggle.isLocalized      = true;
            infoToggle.textScale        = 0.8f;
            infoToggle.eventClick      += (x, y) =>
            {
                showIntersections = !showIntersections;
                showExtraStopInfo = !showIntersections;
                if (showIntersections)
                {
                    infoToggle.localeID = "TLM_SHOW_EXTRA_INFO";
                }
                else
                {
                    infoToggle.localeID = "TLM_SHOW_LINE_INTEGRATION_SHORT";
                }
                redrawLine();
            };

            createLineStationsPanel();
        }