private void CreateAssetLineTemplate()
        {
            var     go    = new GameObject();
            UIPanel panel = go.AddComponent <UIPanel>();

            panel.size                = new Vector2(m_scrollablePanel.width - 40f, 36);
            panel.autoLayout          = true;
            panel.wrapLayout          = false;
            panel.autoLayoutDirection = LayoutDirection.Horizontal;

            UICheckBox uiCheckbox = UIHelperExtension.AddCheckbox(panel, "AAAAAA", false);

            uiCheckbox.name   = "AssetCheckbox";
            uiCheckbox.height = 29f;
            uiCheckbox.width  = 290f;
            uiCheckbox.label.processMarkup = true;
            uiCheckbox.label.textScale     = 0.8f;

            KlyteMonoUtils.CreateUIElement(out UITextField capEditField, panel.transform, "Cap", new Vector4(0, 0, 50, 30));
            KlyteMonoUtils.UiTextFieldDefaults(capEditField);
            KlyteMonoUtils.InitButtonFull(capEditField, false, "OptionsDropboxListbox");
            capEditField.isTooltipLocalized = true;
            capEditField.tooltipLocaleID    = "K45_TLM_ASSET_CAPACITY_FIELD_DESCRIPTION";
            capEditField.numericalOnly      = true;
            capEditField.maxLength          = 6;
            capEditField.padding            = new RectOffset(2, 2, 4, 2);

            TLMUiTemplateUtils.GetTemplateDict()["K45_TLM_AssetSelectionTabLineTemplate"] = panel;
        }
        public void Awake()
        {
            m_container                     = transform.gameObject.AddComponent <UIPanel>();
            m_container.width               = transform.parent.gameObject.GetComponent <UIComponent>().width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthInputLine";

            KlyteMonoUtils.CreateUIElement(out m_cityId, m_container.transform, "CityId");
            m_cityId.autoSize         = false;
            m_cityId.relativePosition = new Vector3(0, 0);
            m_cityId.backgroundSprite = "EmptySprite";
            m_cityId.width            = 30;
            m_cityId.height           = 30;
            m_cityId.textScale        = 1.3f;
            m_cityId.padding          = new RectOffset(3, 3, 4, 3);
            m_cityId.useOutline       = true;
            m_cityId.textAlignment    = UIHorizontalAlignment.Center;

            KlyteMonoUtils.CreateUIElement(out m_azimuthInput, m_container.transform, "StartAzimuth");
            KlyteMonoUtils.UiTextFieldDefaults(m_azimuthInput);
            m_azimuthInput.normalBgSprite    = "OptionsDropboxListbox";
            m_azimuthInput.width             = 50;
            m_azimuthInput.height            = 28;
            m_azimuthInput.textScale         = 1.6f;
            m_azimuthInput.maxLength         = 3;
            m_azimuthInput.numericalOnly     = true;
            m_azimuthInput.text              = "0";
            m_azimuthInput.eventTextChanged += SendText;

            KlyteMonoUtils.CreateUIElement(out m_direction, m_container.transform, "Direction");
            m_direction.autoSize      = false;
            m_direction.width         = 60;
            m_direction.height        = 30;
            m_direction.textScale     = 1.125f;
            m_direction.textAlignment = UIHorizontalAlignment.Center;
            m_direction.padding       = new RectOffset(3, 3, 5, 3);

            KlyteMonoUtils.CreateUIElement(out UIPanel nameContainer, m_container.transform, "GenNameContainer");
            nameContainer.autoSize            = false;
            nameContainer.width               = 150;
            nameContainer.height              = 30;
            nameContainer.autoLayout          = true;
            nameContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out m_generatedName, nameContainer.transform, "GenName");
            m_generatedName.autoSize      = true;
            m_generatedName.height        = 30;
            m_generatedName.textScale     = 1.125f;
            m_generatedName.padding       = new RectOffset(3, 3, 5, 3);
            m_generatedName.text          = "???";
            m_generatedName.textAlignment = UIHorizontalAlignment.Center;
            m_generatedName.minimumSize   = new Vector2(150, 0);
            KlyteMonoUtils.LimitWidth(m_generatedName, 150);

            KlyteMonoUtils.CreateUIElement(out m_regenerateName, m_container.transform, "RegenName");
            m_regenerateName.textScale = 1f;
            m_regenerateName.width     = 30;
            m_regenerateName.height    = 30;
            m_regenerateName.tooltip   = Locale.Get("K45_ADR_REGENERATE_NAME");
            KlyteMonoUtils.InitButton(m_regenerateName, true, "ButtonMenu");
            m_regenerateName.isVisible   = true;
            m_regenerateName.text        = "R";
            m_regenerateName.eventClick += (component, eventParam) =>
            {
                AdrNeighborhoodExtension.SetSeed(m_id, new Randomizer(new System.Random().Next()).UInt32(0xFEFFFFFF));
                OnRegenerate?.Invoke();
            };

            KlyteMonoUtils.CreateUIElement(out m_die, m_container.transform, "Delete");
            m_die.textScale = 1f;
            m_die.width     = 30;
            m_die.height    = 30;
            m_die.tooltip   = Locale.Get("K45_ADR_DELETE_STOP_NEIGHBOR");
            KlyteMonoUtils.InitButton(m_die, true, "ButtonMenu");
            m_die.isVisible   = true;
            m_die.text        = "X";
            m_die.eventClick += (component, eventParam) =>
            {
                AdrNeighborhoodExtension.SafeCleanEntry(m_id);
                OnDie?.Invoke();
            };
        }
        public void Awake()
        {
            m_container                     = GetComponent <UIPanel>();
            m_container.width               = m_container.parent.width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthInputLine";

            KlyteMonoUtils.CreateUIElement(out m_cityId, m_container.transform, "CityId");
            m_cityId.autoSize         = false;
            m_cityId.relativePosition = new Vector3(0, 0);
            m_cityId.backgroundSprite = "EmptySprite";
            m_cityId.width            = 30;
            m_cityId.height           = 30;
            m_cityId.textScale        = 1.3f;
            m_cityId.padding          = new RectOffset(3, 3, 4, 3);
            m_cityId.useOutline       = true;
            m_cityId.textAlignment    = UIHorizontalAlignment.Center;

            KlyteMonoUtils.CreateUIElement(out m_azimuthInput, m_container.transform, "StartAzimuth");
            KlyteMonoUtils.UiTextFieldDefaults(m_azimuthInput);
            m_azimuthInput.normalBgSprite    = "OptionsDropboxListbox";
            m_azimuthInput.width             = 50;
            m_azimuthInput.height            = 28;
            m_azimuthInput.textScale         = 1.6f;
            m_azimuthInput.maxLength         = 3;
            m_azimuthInput.numericalOnly     = true;
            m_azimuthInput.allowNegative     = true;
            m_azimuthInput.text              = "0";
            m_azimuthInput.eventTextChanged += SendText;
            m_azimuthInput.eventMouseWheel  += DefaultEditorUILib.RollInteger;

            KlyteMonoUtils.CreateUIElement(out m_direction, m_container.transform, "Direction");
            m_direction.autoSize      = false;
            m_direction.width         = 60;
            m_direction.height        = 30;
            m_direction.textScale     = 1.125f;
            m_direction.textAlignment = UIHorizontalAlignment.Center;
            m_direction.padding       = new RectOffset(3, 3, 5, 3);

            KlyteMonoUtils.CreateUIElement(out m_generatedName, m_container.transform, "GenName");
            KlyteMonoUtils.UiTextFieldDefaults(m_generatedName);
            m_generatedName.autoSize            = true;
            m_generatedName.height              = 30;
            m_generatedName.textScale           = 1.125f;
            m_generatedName.padding             = new RectOffset(3, 3, 5, 3);
            m_generatedName.text                = "???";
            m_generatedName.horizontalAlignment = UIHorizontalAlignment.Center;
            m_generatedName.width               = m_container.width - 235;
            m_generatedName.eventTextSubmitted += SetFixedName;
            m_generatedName.submitOnFocusLost   = true;


            m_die = DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_X, () =>
            {
                AdrNeighborhoodExtension.SafeCleanEntry(m_id);
                OnDie?.Invoke();
            }, "K45_ADR_DELETE_STOP_NEIGHBOR", false, 30);

            DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_Reload, () =>
            {
                AdrNeighborhoodExtension.SetSeed(m_id, new Randomizer(new System.Random().Next()).UInt32(0xFEFFFFFF));
                OnRegenerate?.Invoke();
            }, "K45_ADR_REGENERATE_NAME", false, 30);
        }
예제 #4
0
        private void createInfoView()
        {
            //line info painel

            KlyteMonoUtils.CreateUIElement(out m_buildingInfoPanel, gameObject.transform);
            m_buildingInfoPanel.Hide();
            m_buildingInfoPanel.relativePosition  = new Vector3(394.0f, 70.0f);
            m_buildingInfoPanel.width             = 650;
            m_buildingInfoPanel.height            = 290;
            m_buildingInfoPanel.zOrder            = 50;
            m_buildingInfoPanel.color             = new Color32(255, 255, 255, 255);
            m_buildingInfoPanel.backgroundSprite  = "MenuPanel2";
            m_buildingInfoPanel.name              = "BuildingInfoPanel";
            m_buildingInfoPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10);
            m_buildingInfoPanel.autoLayout        = false;
            m_buildingInfoPanel.useCenter         = true;
            m_buildingInfoPanel.wrapLayout        = false;
            m_buildingInfoPanel.canFocus          = true;
            KlyteMonoUtils.CreateDragHandle(m_buildingInfoPanel, m_buildingInfoPanel, 35f);



            KlyteMonoUtils.CreateUIElement(out buildingTypeIcon, m_buildingInfoPanel.transform);
            buildingTypeIcon.autoSize             = false;
            buildingTypeIcon.relativePosition     = new Vector3(10f, 7f);
            buildingTypeIcon.width                = 30;
            buildingTypeIcon.height               = 30;
            buildingTypeIcon.name                 = "BuildingTypeIcon";
            buildingTypeIcon.clipChildren         = true;
            buildingTypeIcon.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
            KlyteMonoUtils.CreateDragHandle(buildingTypeIcon, m_buildingInfoPanel);

            KlyteMonoUtils.CreateUIElement(out buildingTypeIconFg, buildingTypeIcon.transform);
            buildingTypeIconFg.autoSize         = false;
            buildingTypeIconFg.relativePosition = new Vector3(0, 0);
            buildingTypeIconFg.width            = 30;
            buildingTypeIconFg.height           = 30;
            buildingTypeIconFg.name             = "BuildingTypeIconFg";
            buildingTypeIconFg.clipChildren     = true;
            KlyteMonoUtils.CreateDragHandle(buildingTypeIconFg, m_buildingInfoPanel);

            KlyteMonoUtils.CreateUIElement(out buildingNameField, m_buildingInfoPanel.transform);
            buildingNameField.autoSize            = false;
            buildingNameField.relativePosition    = new Vector3(160f, 10f);
            buildingNameField.horizontalAlignment = UIHorizontalAlignment.Center;
            buildingNameField.text      = "NOME";
            buildingNameField.width     = 450;
            buildingNameField.height    = 25;
            buildingNameField.name      = "BuildingNameLabel";
            buildingNameField.maxLength = 256;
            buildingNameField.textScale = 1.5f;
            KlyteMonoUtils.UiTextFieldDefaults(buildingNameField);
            buildingNameField.eventGotFocus += (component, eventParam) =>
            {
                lastDepotName = buildingNameField.text;
            };
            buildingNameField.eventTextSubmitted += (component, eventParam) =>
            {
                if (lastDepotName != buildingNameField.text)
                {
                    saveBuildingName(buildingNameField);
                }
            };

            KlyteMonoUtils.CreateUIElement(out vehiclesInUseLabel, m_buildingInfoPanel.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;
            vehiclesInUseLabel.prefix           = Locale.Get("K45_VMC_VEHICLE_CAPACITY_LABEL") + ": ";

            KlyteMonoUtils.CreateUIElement(out upkeepCost, m_buildingInfoPanel.transform);
            upkeepCost.autoSize         = false;
            upkeepCost.relativePosition = new Vector3(10f, 75);
            upkeepCost.textAlignment    = UIHorizontalAlignment.Left;
            upkeepCost.width            = 250;
            upkeepCost.height           = 25;
            upkeepCost.name             = "UpkeepLabel";
            upkeepCost.textScale        = 0.8f;

            KlyteMonoUtils.CreateUIElement(out UIButton voltarButton2, m_buildingInfoPanel.transform);
            voltarButton2.relativePosition = new Vector3(m_buildingInfoPanel.width - 33f, 5f);
            voltarButton2.width            = 28;
            voltarButton2.height           = 28;
            KlyteMonoUtils.InitButton(voltarButton2, true, "DeleteLineButton");
            voltarButton2.name        = "LineInfoCloseButton";
            voltarButton2.eventClick += closeBuildingInfo;

            workerChart = new TLMWorkerChartPanel(panelTransform, new Vector3(400f, 90f));
            m_uiHelper  = new UIHelperExtension(m_buildingInfoPanel);
        }