private void CreateMainPanel()
        {
            TLMUtils.createUIElement(out m_mainPanel, m_parent.transform);
            m_mainPanel.Hide();
            m_mainPanel.relativePosition  = new Vector3(m_parent.width, 0.0f);
            m_mainPanel.width             = 250;
            m_mainPanel.height            = m_parent.height;
            m_mainPanel.zOrder            = 50;
            m_mainPanel.color             = new Color32(255, 255, 255, 255);
            m_mainPanel.backgroundSprite  = "MenuPanel2";
            m_mainPanel.name              = "AssetSelectorWindow";
            m_mainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10);
            m_mainPanel.autoLayout        = false;
            m_mainPanel.useCenter         = true;
            m_mainPanel.wrapLayout        = false;
            m_mainPanel.canFocus          = true;
            TLMUtils.createDragHandle(m_mainPanel, m_mainPanel, 35f);
            m_parent.eventVisibilityChanged += (component, value) =>
            {
                m_mainPanel.isVisible = value;
            };

            TLMUtils.createUIElement(out m_title, m_mainPanel.transform);
            m_title.textAlignment    = UIHorizontalAlignment.Center;
            m_title.autoSize         = false;
            m_title.autoHeight       = true;
            m_title.width            = m_mainPanel.width - 30f;
            m_title.relativePosition = new Vector3(5, 5);
            m_title.textScale        = 0.9f;
        }
Exemplo n.º 2
0
        private void AddVehicleToLinearMap(Color lineColor, ushort vehicleId)
        {
            TLMLineUtils.GetVehicleCapacityAndFill(vehicleId, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId], out int fill, out int cap);

            TLMUtils.createUIElement(out UILabel vehicleLabel, lineStationsPanel.transform);
            vehicleLabel.autoSize          = false;
            vehicleLabel.text              = string.Format("{0}/{1}", fill, cap);
            vehicleLabel.useOutline        = true;
            vehicleLabel.width             = 50;
            vehicleLabel.height            = 33;
            vehicleLabel.pivot             = UIPivotPoint.TopCenter;
            vehicleLabel.verticalAlignment = UIVerticalAlignment.Middle;
            vehicleLabel.atlas             = TLMController.taLineNumber;

            vehicleLabel.padding          = new RectOffset(0, 0, 2, 0);
            vehicleLabel.textScale        = 0.6f;
            vehicleLabel.backgroundSprite = "VehicleLinearMap";
            vehicleLabel.color            = lineColor;
            vehicleLabel.textAlignment    = UIHorizontalAlignment.Center;
            vehicleLabel.tooltip          = Singleton <VehicleManager> .instance.GetVehicleName(vehicleId);

            vehicleLabel.eventClick += (x, y) =>
            {
                InstanceID id = default(InstanceID);
                id.Vehicle = vehicleId;
                Camera.main.GetComponent <CameraController>().SetTarget(id, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].GetLastFramePosition(), true);
            };
            UIDragHandle dh = TLMUtils.createDragHandle(vehicleLabel, vehicleLabel);

            TLMUtils.createUIElement(out DraggableVehicleInfo dvi, vehicleLabel.transform);
            dvi.vehicleId = vehicleId;
            dvi.name      = "Vehicle" + vehicleId;

            vehicleLabel.eventMouseLeave += vehicleHover;
            vehicleLabel.eventMouseUp    += vehicleHover;
            vehicleLabel.eventMouseDown  += vehicleHover;
            vehicleLabel.eventDragStart  += draggingVehicle;
            vehicleLabel.eventMouseHover += vehicleHover;

            updateVehiclePosition(vehicleLabel);

            lineVehicles.Add(vehicleId, vehicleLabel);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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 createToolbox()
        {
            TLMUtils.createUIElement(out mainContainer, m_controller.TransformLinearMap);
            mainContainer.absolutePosition = new Vector3(2f, TLMController.instance.uiView.fixedHeight - 300f);
            mainContainer.name             = "TLMLineCreationToolbox";
            mainContainer.height           = 190;
            mainContainer.width            = 180;
            mainContainer.backgroundSprite = "MenuPanel2";
            mainContainer.relativePosition = new Vector3(320f, 57f);

            uiHelper = new UIHelperExtension(mainContainer);

            TLMUtils.createUIElement(out UILabel title, mainContainer.transform);
            title.autoSize          = false;
            title.width             = mainContainer.width;
            title.height            = 30;
            title.color             = new Color(1, 0, 0, 1);
            title.pivot             = UIPivotPoint.MiddleLeft;
            title.textAlignment     = UIHorizontalAlignment.Center;
            title.verticalAlignment = UIVerticalAlignment.Middle;
            title.name             = "Title";
            title.relativePosition = new Vector3(0, 5);
            title.atlas            = TLMController.taLineNumber;
            title.localeID         = "TLM_PREFIX_SELECTOR_WIN_TITLE";
            TLMUtils.createDragHandle(title, mainContainer);


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

            linePrefixDropDown                            = lpddgo.GetComponent <UIDropDown>();
            linePrefixDropDown.isLocalized                = false;
            linePrefixDropDown.autoSize                   = false;
            linePrefixDropDown.horizontalAlignment        = UIHorizontalAlignment.Center;
            linePrefixDropDown.text                       = "";
            linePrefixDropDown.width                      = 75;
            linePrefixDropDown.height                     = 30;
            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 += setNextLinePrefix;
            linePrefixDropDown.relativePosition           = new Vector3(5f, 45f);
            linePrefixDropDown.normalBgSprite             = "OptionsDropboxListbox";
            linePrefixDropDown.horizontalAlignment        = UIHorizontalAlignment.Center;

            TLMUtils.createUIElement(out lineNumberTxtBox, mainContainer.transform);
            lineNumberTxtBox.autoSize            = false;
            lineNumberTxtBox.relativePosition    = new Vector3(85f, 45f);
            lineNumberTxtBox.horizontalAlignment = UIHorizontalAlignment.Center;
            lineNumberTxtBox.text           = "";
            lineNumberTxtBox.width          = 90;
            lineNumberTxtBox.height         = 30;
            lineNumberTxtBox.name           = "LineNumberLabel";
            lineNumberTxtBox.normalBgSprite = "EmptySprite";
            lineNumberTxtBox.textScale      = 1.6f;
            lineNumberTxtBox.padding        = new RectOffset(0, 0, 0, 0);
            lineNumberTxtBox.color          = new Color(0, 0, 0, 1);
            TLMUtils.uiTextFieldDefaults(lineNumberTxtBox);
            lineNumberTxtBox.numericalOnly   = true;
            lineNumberTxtBox.maxLength       = 4;
            lineNumberTxtBox.eventLostFocus += setNextLineNumber;;
            lineNumberTxtBox.zOrder          = 10;
            lineNumberTxtBox.text            = "0";

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

            TLMUtils.createUIElement(out lineNumber, lineFormat.transform);
            lineNumber.autoSize          = false;
            lineNumber.width             = lineFormat.width;
            lineNumber.pivot             = UIPivotPoint.MiddleCenter;
            lineNumber.name              = "LineNumber";
            lineNumber.width             = 80;
            lineNumber.height            = 80;
            lineNumber.relativePosition  = new Vector3(-0.5f, 0.5f);
            lineNumber.autoHeight        = false;
            lineNumber.textAlignment     = UIHorizontalAlignment.Center;
            lineNumber.verticalAlignment = UIVerticalAlignment.Middle;

            prefixIncrementChk = uiHelper.AddCheckboxLocale("TLM_AUTOINCREMENT_PREFIX", false, delegate(bool value)
            {
                if (TLMSingleton.debugMode)
                {
                    TLMUtils.doLog("Type = " + TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) + "|prop=" + (TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT) + "|valToSet = " + value);
                }
                TLMConfigWarehouse.setCurrentConfigBool(TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT, value);
            });
            prefixIncrementChk.relativePosition = new Vector3(5f, 162.5f);
        }
Exemplo n.º 8
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();
        }