Beispiel #1
0
 protected override void AddColumns(ref float xAdvance)
 {
     xAdvance += InitField(out m_income, "Income", "K45_TLM_FINANCE_REPORT_TITLE_INCOME", xAdvance, TOTAL_DATA_COLUMNS_SPACE / 3);
     xAdvance += InitField(out m_expense, "Expense", "K45_TLM_FINANCE_REPORT_TITLE_EXPENSE", xAdvance, TOTAL_DATA_COLUMNS_SPACE / 3);
     xAdvance += InitField(out m_balance, "Balance", "K45_TLM_FINANCE_REPORT_TITLE_BALANCE", xAdvance, TOTAL_DATA_COLUMNS_SPACE / 3);
     m_balance.backgroundSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon);
 }
Beispiel #2
0
        private void CreateTsdTabstrip()
        {
            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false);

            foreach (var targetType in ReflectionUtils.GetSubtypesRecursive(typeof(UVMLinesPanel), GetType()))
            {
                TransportSystemDefinition tsd = (targetType.GetConstructor(new Type[0]).Invoke(null) as UVMLinesPanel).TSD;
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                string     name      = tsd.GetTransportName();
                string     bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMPrefixesUtils.GetLineIcon(0, tsd), true);
                string     fgIcon    = tsd.GetTransportTypeIcon();
                UIButton   tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = name;
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                m_stripMain.AddTab(name, tab, body, new Type[] { targetType });
            }
        }
Beispiel #3
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, 315));
            m_tabSettings = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "PrpSettings");
            m_tabLib      = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Load), "K45_WTS_PROP_ITEM_LIB_TITLE", "PrpLib");

            m_tabSettings.clipChildren = true;
            m_tabLib.clipChildren      = true;

            var helperSettings = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperLib      = new UIHelperExtension(m_tabLib, LayoutDirection.Vertical);

            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_fontSelect, helperSettings, OnSetFont);
            AddColorField(helperSettings, Locale.Get("K45_WTS_BACKGROUND_COLOR"), out m_bgColor, OnBgColorChanged);
            AddCheckboxLocale("K45_WTS_USEHWCOLOR", out m_useHwColor, helperSettings, OnUseHwColorChanged);

            IEnumerator OnFilter(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterParamImages(WTSHighwayShieldEditor.Instance.Preview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_BGSPRITE_NAME"), helperSettings, out m_spriteFilter, out UIListBox lb2, OnFilter, OnBgSpriteNameChanged);
            lb2.size                      = new Vector2(MainContainer.width - 20, 220);
            lb2.processMarkup             = true;
            m_spriteFilter.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb2.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb2.items.Length)
                {
                    WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim();
                }
            };
            lb2.eventVisibilityChanged += (x, y) => WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.parent.isVisible = y;
            WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.parent.isVisible = false;


            WTSHighwayShieldEditor.Instance.CurrentTabChanged += OnTabChanged;

            AddLibBox <WTSLibHighwayShieldLayout, HighwayShieldDescriptor>(helperLib, out UIButton m_copyButtonText,
                                                                           DoCopyText, out m_pasteButton,
                                                                           DoPasteText, out _,
                                                                           null, LoadIntoCurrentConfig,
                                                                           () => XmlUtils.DefaultXmlSerialize(WTSHighwayShieldEditor.Instance.EditingInstance));
            m_pasteButton.isVisible = m_clipboard != null;
        }
Beispiel #4
0
 protected static UIButton ConfigureActionButton(UIComponent parent, CommonsSpriteNames spriteName)
 {
     KlyteMonoUtils.CreateUIElement(out UIButton actionButton, parent.transform, "Btn");
     KlyteMonoUtils.InitButton(actionButton, false, "ButtonMenu");
     actionButton.focusedBgSprite      = "";
     actionButton.autoSize             = false;
     actionButton.width                = 20;
     actionButton.height               = 20;
     actionButton.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
     actionButton.normalFgSprite       = KlyteResourceLoader.GetDefaultSpriteNameFor(spriteName);
     return(actionButton);
 }
Beispiel #5
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);


            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            m_tabSettings = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "PrpSettings");
            m_tabLib      = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Load), "K45_WTS_PROP_ITEM_LIB_TITLE", "PrpLib");

            m_tabSettings.clipChildren = true;
            m_tabLib.clipChildren      = true;

            var helperSettings = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperLib      = new UIHelperExtension(m_tabLib, LayoutDirection.Vertical);



            AddFilterableInput(Locale.Get("K45_WTS_PROP_MODEL_SELECT"), helperSettings, out m_propFilter, out _, PropIndexes.instance.BasicInputFiltering, OnSetProp);


            AddTextField(Locale.Get("K45_WTS_PROP_TAB_TITLE"), out m_name, helperSettings, OnSetName);
            AddColorField(helperSettings, Locale.Get("K45_WTS_PROP_COLOR"), out m_fixedColor, OnSetPropColor);

            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_fontSelect, helperSettings, OnSetFont);

            AddDropdown(Locale.Get("K45_WTS_TEXT_AVAILABILITY"), out m_dropdownTextContent, helperSettings, ddOrder.GetDropdownOptions("K45_WTS_BOARD_TEXT_AVAILABILITY_DESC"), OnSetTextOwnNameContent);



            WTSPropLayoutEditor.Instance.CurrentTabChanged += (x) =>
            {
                ReloadInfo(x);
            };



            AddLibBox <WTSLibPropSettings, BoardDescriptorGeneralXml>(helperLib, out UIButton m_copyButtonText,
                                                                      DoCopyText, out m_pasteButton,
                                                                      DoPasteText, out _,
                                                                      null, LoadIntoCurrentConfig,
                                                                      () => XmlUtils.DefaultXmlSerialize(WTSPropLayoutEditor.Instance.EditingInstance));
            m_pasteButton.isVisible = m_clipboard != null;

            m_exportAsGlobal            = (UIButton)helperLib.AddButton(Locale.Get("K45_WTS_PROPEDIT_EXPORTGLOBAL"), OnExportAsGlobal);
            m_exportAsAsset             = (UIButton)helperLib.AddButton(Locale.Get("K45_WTS_PROPEDIT_EXPORTASSET"), OnExportAsAsset);
            helperLib.Self.clipChildren = false;
        }
Beispiel #6
0
        private void Awake()
        {
            parent = GetComponentInParent <UIComponent>();
            var group6 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>());

            ((UIScrollablePanel)group6.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIScrollablePanel)group6.Self).wrapLayout          = true;
            ((UIScrollablePanel)group6.Self).width = 730;

            group6.AddLabel(Locale.Get("K45_TLM_CUSTOM_PALETTE_CONFIG"));
            group6.AddSpace(15);

            FileInfo fiPalette = FileUtils.EnsureFolderCreation(TLMController.palettesFolder);

            group6.AddLabel(Locale.Get("K45_TLM_PALETTE_FOLDER_LABEL") + ":");
            var namesFilesButton = ((UIButton)group6.AddButton("/", () => ColossalFramework.Utils.OpenInFileBrowser(fiPalette.FullName)));

            namesFilesButton.textColor = Color.yellow;
            KlyteMonoUtils.LimitWidth(namesFilesButton, 710);
            namesFilesButton.text = fiPalette.FullName + Path.DirectorySeparatorChar;
            ((UIButton)group6.AddButton(Locale.Get("K45_TLM_RELOAD_PALETTES"), delegate()
            {
                TLMAutoColorPalettes.Reload();
                string idxSel = editorSelector.selectedValue;
                editorSelector.items = TLMAutoColorPalettes.paletteListForEditing;
                editorSelector.selectedIndex = TLMAutoColorPalettes.paletteListForEditing.ToList().IndexOf(idxSel);
                TLMConfigOptions.instance.updateDropDowns();
                onPaletteReloaded?.Invoke();
            })).width = 710;

            NumberedColorList colorList = null;

            editorSelector = group6.AddDropdown(Locale.Get("K45_TLM_PALETTE_VIEW"), TLMAutoColorPalettes.paletteListForEditing, 0, delegate(int sel)
            {
                if (sel <= 0 || sel >= TLMAutoColorPalettes.paletteListForEditing.Length)
                {
                    colorList.Disable();
                }
                else
                {
                    colorList.ColorList = TLMAutoColorPalettes.getColors(TLMAutoColorPalettes.paletteListForEditing[sel]);
                    colorList.Enable();
                }
            }) as UIDropDown;
            editorSelector.GetComponentInParent <UIPanel>().width = 710;
            editorSelector.width = 710;

            colorList = group6.AddNumberedColorList(null, new List <Color32>(), (c) => { }, null, null);
            colorList.m_spriteName = KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon, true);
            colorList.Size         = new Vector2(750, colorList.Size.y);
        }
Beispiel #7
0
        private void Awake()
        {
            parent = GetComponentInChildren <UIScrollablePanel>();

            int parentWidth = 730;

            KlyteMonoUtils.CreateUIElement(out UITabstrip strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parentWidth - 10, 40));
            KlyteMonoUtils.CreateUIElement(out tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parentWidth - 10, 660));

            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(parentWidth, 660, false);

            foreach (var kv in ReflectionUtils.GetSubtypesRecursive(typeof(TLMShowConfigTab), GetType()))
            {
                var tsd = (kv.GetConstructor(new Type[0]).Invoke(null) as TLMShowConfigTab).TSD;


                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                string     name      = tsd.GetTransportName();
                string     bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(tsd.DefaultIcon, true);
                string     fgIcon    = tsd.GetTransportTypeIcon();
                UIButton   tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = name;
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.white;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, new Type[] { kv });
            }
            strip.selectedIndex = -1;
            strip.selectedIndex = 0;
        }
Beispiel #8
0
        private void CreateTsdTabstrip()
        {
            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false);

            foreach (KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = ReflectionUtils.GetImplementationForGenericType(typeof(UVMLinesPanel <>), kv.Value().GetType());
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }
                TransportSystemDefinition tsd = kv.Key;
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.ToConfigIndex();
                string     name      = kv.Value().GetType().Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true);
                string   fgIcon    = kv.Key.GetTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                m_stripMain.AddTab(name, tab, body, components);
            }
        }
Beispiel #9
0
        protected void Start()
        {
            m_lastSortCriterionLines = LineSortCriterion.DEFAULT;

            UIComponent parent = GetComponent <UIComponent>();

            KlyteMonoUtils.CreateUIElement(out m_autoNameAll, parent.transform);
            m_autoNameAll.relativePosition = new Vector3(parent.width - 50f, -5);
            m_autoNameAll.textScale        = 0.6f;
            m_autoNameAll.width            = 40;
            m_autoNameAll.height           = 40;
            m_autoNameAll.tooltip          = Locale.Get("K45_TLM_AUTO_NAME_ALL_TOOLTIP");
            KlyteMonoUtils.InitButton(m_autoNameAll, true, "ButtonMenu");
            m_autoNameAll.name           = "AutoNameAll";
            m_autoNameAll.isVisible      = true;
            m_autoNameAll.normalFgSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon);
            m_autoNameAll.eventClick    += (component, eventParam) =>
            {
                foreach (UVMLineListItem item in mainPanel.GetComponentsInChildren <UVMLineListItem>())
                {
                    item.DoAutoName();
                }
            };

            KlyteMonoUtils.CreateUIElement(out m_autoColorAll, parent.transform);
            m_autoColorAll.relativePosition = new Vector3(parent.width - 90f, -5);
            m_autoColorAll.textScale        = 0.6f;
            m_autoColorAll.width            = 40;
            m_autoColorAll.height           = 40;
            m_autoColorAll.tooltip          = Locale.Get("K45_TLM_AUTO_COLOR_ALL_TOOLTIP");
            KlyteMonoUtils.InitButton(m_autoColorAll, true, "ButtonMenu");
            m_autoColorAll.name           = "AutoColorAll";
            m_autoColorAll.isVisible      = true;
            m_autoColorAll.normalFgSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon);
            m_autoColorAll.eventClick    += (component, eventParam) =>
            {
                foreach (UVMLineListItem item in mainPanel.GetComponentsInChildren <UVMLineListItem>())
                {
                    item.DoAutoColor();
                }
            };
        }
Beispiel #10
0
        protected override void AwakeActions()
        {
            KlyteMonoUtils.CreateUIElement(out m_stripMain, MainPanel.transform, "WTSTabstrip", new Vector4(5, 40, MainPanel.width - 10, 40));
            m_stripMain.startSelectedIndex = -1;
            m_stripMain.selectedIndex      = -1;

            KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, MainPanel.transform, "WTSTabContainer", new Vector4(0, 80, MainPanel.width, MainPanel.height - 80));
            m_stripMain.tabPages = tabContainer;

            //m_stripMain.CreateTabLocalized<WTSPropPlacingTab2>("InfoIconEscapeRoutes", "K45_WTS_HIGHWAY_SIGN_CONFIG_TAB", "WTSHighwaySign");
            //m_stripMain.CreateTabLocalized<WTSMileageMarkerTab3>("LocationMarkerNormal", "K45_WTS_MILEAGE_MARKERS_CONFIG_TAB", "WTSMileageMarkerTab");
            //m_stripMain.CreateTabLocalized<WTSBuildingEditorTab2>("IconAssetBuilding", "K45_WTS_BUILDING_CONFIG_TAB", "WTSBuildingEditorTab");
            m_stripMain.CreateTabLocalized <WTSPropLayoutEditor>("IconAssetProp", "K45_WTS_PROP_LIBRARY_EDITOR_TAB", "WTSBuildingEditorTab", false);
            m_stripMain.CreateTabLocalized <WTSRoadCornerEditor>("InfoIconTrafficRoutes", "K45_WTS_STREET_SIGN_CONFIG_TAB", "WTSStreetSign", false);
            m_stripMain.CreateTabLocalized <WTSBuildingLayoutEditor>("IconAssetBuilding", "K45_WTS_BUILDING_CONFIG_TAB", "WTSBuildingSettings", false);
            m_stripMain.CreateTabLocalized <WTSVehicleLayoutEditor>("IconAssetVehicle", "K45_WTS_VEHICLE_CONFIG_TAB", "WTSVehicleLayoutEditor", false);
            m_stripMain.CreateTabLocalized <WTSFontsSettings>(KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_FONT_CONFIG_TAB", "WTSFontSettings", false);



            KlyteMonoUtils.CreateElement <WTSOnNetLiteUI>(UIView.GetAView().transform.Find("TSBar").gameObject.transform);
        }
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);



            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, 315));
            m_tabSettings = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "PrpSettings");
            m_tabLib      = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Load), "K45_WTS_PROP_ITEM_LIB_TITLE", "PrpLib");

            m_tabSettings.clipChildren = true;
            m_tabLib.clipChildren      = true;

            var helperSettings = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperLib      = new UIHelperExtension(m_tabLib, LayoutDirection.Vertical);

            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_fontSelect, helperSettings, OnSetFont);

            WTSVehicleLayoutEditor.Instance.CurrentTabChanged += (x) =>
            {
                if (x == 0 && EditingInstance != null)
                {
                    m_fontSelect.selectedIndex = EditingInstance.FontName == null ? 0 : EditingInstance.FontName == WTSController.DEFAULT_FONT_KEY ? 1 : Array.IndexOf(m_fontSelect.items, EditingInstance.FontName);
                }
                MainContainer.isVisible = x == 0 && EditingInstance != null;
            };

            AddLibBox <WTSLibVehicleLayout, LayoutDescriptorVehicleXml>(helperLib, out UIButton m_copyButtonText,
                                                                        DoCopyText, out m_pasteButton,
                                                                        DoPasteText, out _,
                                                                        null, LoadIntoCurrentConfig,
                                                                        () => XmlUtils.DefaultXmlSerialize(WTSVehicleLayoutEditor.Instance.EditingInstance));
            m_pasteButton.isVisible = m_clipboard != null;
        }
Beispiel #12
0
        private void Awake()
        {
            instance                      = this;
            mainPanel                     = GetComponent <UIPanel>();
            mainPanel.autoLayout          = true;
            mainPanel.autoLayoutDirection = LayoutDirection.Vertical;
            m_uiHelper                    = new UIHelperExtension(mainPanel);

            var transportType = m_tsd.ToConfigIndex();


            m_uiHelper.AddLabel(string.Format(Locale.Get("K45_TLM_CONFIGS_FOR"), TLMConfigWarehouse.getNameForTransportType(transportType)));
            UIPanel panel = m_uiHelper.Self.GetComponentInParent <UIPanel>();

            ((UIPanel)m_uiHelper.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIPanel)m_uiHelper.Self).backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MenuPanel_color);
            ((UIPanel)m_uiHelper.Self).wrapLayout          = true;
            ((UIPanel)m_uiHelper.Self).padding             = new RectOffset(10, 10, 10, 15);
            ((UIPanel)m_uiHelper.Self).color = TLMConfigWarehouse.getColorForTransportType(transportType);
            ((UIPanel)m_uiHelper.Self).width = 730;
            m_uiHelper.AddSpace(30);
            prefixDD           = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_PREFIX"), m_tlmCo.namingOptionsPrefixo, transportType | TLMConfigWarehouse.ConfigIndex.PREFIX);
            separatorContainer = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SEPARATOR"), m_tlmCo.namingOptionsSeparador, transportType | TLMConfigWarehouse.ConfigIndex.SEPARATOR).transform.parent.GetComponent <UIPanel>();
            suffixDD           = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SUFFIX"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.SUFFIX);
            suffixDDContainer  = suffixDD.transform.parent.GetComponent <UIPanel>();
            nonPrefixDD        = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_IDENTIFIER_NON_PREFIXED"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.NON_PREFIX);
            paletteContainer   = m_tlmCo.generateDropdownStringValueConfig(m_uiHelper, Locale.Get("K45_TLM_PALETTE"), TLMAutoColorPalettes.paletteList, transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_MAIN).transform.parent.GetComponent <UIPanel>();
            m_tlmCo.generateDropdownEnumStringValueConfig <LineIconSpriteNames>(m_uiHelper, Locale.Get("K45_TLM_ICON"), TLMLineIconExtension.getDropDownOptions(), transportType | TLMConfigWarehouse.ConfigIndex.TRANSPORT_ICON_TLM);
            zerosContainer          = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LEADING_ZEROS_SUFFIX"), transportType | TLMConfigWarehouse.ConfigIndex.LEADING_ZEROS);
            prefixAsSuffixContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_INVERT_PREFIX_SUFFIX_ORDER"), transportType | TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX);
            m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_RANDOM_ON_PALETTE_OVERFLOW"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW);
            autoColorBasedContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_AUTO_COLOR_BASED_ON_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_PREFIX_BASED);
            prefixIncrement         = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LINENUMBERING_BASED_IN_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);

            prefixDD.eventSelectedIndexChanged += OnPrefixOptionChange;
            suffixDD.eventSelectedIndexChanged += OnSuffixOptionChange;
            OnPrefixOptionChange(prefixDD, prefixDD.selectedIndex);
        }
Beispiel #13
0
 private void ToggleLock()
 {
     m_viewLocked = !m_viewLocked;
     if (m_viewLocked)
     {
         m_lockToSelection.normalFgSprite  = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Lock);
         m_lockToSelection.hoveredFgSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Unlock);
         m_lockToSelection.color           = Color.red;
         m_lockToSelection.focusedColor    = Color.red;
         m_lockToSelection.textColor       = Color.yellow;
         m_lockToSelection.hoveredColor    = Color.green;
         ResetCamera();
     }
     else
     {
         m_lockToSelection.normalFgSprite  = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Unlock);
         m_lockToSelection.hoveredFgSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Lock);
         m_lockToSelection.color           = Color.white;
         m_lockToSelection.focusedColor    = Color.white;
         m_lockToSelection.textColor       = Color.white;
         m_lockToSelection.hoveredColor    = Color.red;
     }
 }
        private void CreateRemoveUndesiredModelsButton()
        {
            KlyteMonoUtils.CreateUIElement <UIButton>(out UIButton removeUndesired, MainPanel.transform);
            removeUndesired.relativePosition = new Vector3(MainPanel.width - 25f, 0f);
            removeUndesired.textScale        = 0.6f;
            removeUndesired.width            = 20;
            removeUndesired.height           = 20;
            removeUndesired.tooltip          = Locale.Get("K45_TLM_REMOVE_UNWANTED_TOOLTIP");
            KlyteMonoUtils.InitButton(removeUndesired, true, "ButtonMenu");
            removeUndesired.name        = "DeleteLineButton";
            removeUndesired.isVisible   = true;
            removeUndesired.eventClick += (component, eventParam) =>
            {
                TLMVehicleUtils.RemoveAllUnwantedVehicles();
            };

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

            icon.relativePosition = new Vector3(2, 2);
            icon.width            = 18;
            icon.height           = 18;
            icon.spriteName       = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_RemoveUnwantedIcon);
        }
Beispiel #15
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out m_previewPanel, MainContainer.transform, "previewPanel", new UnityEngine.Vector4(0, 0, 0, 300));
            m_previewPanel.autoLayout    = false;
            m_previewPanel.disabledColor = Color.black;
            m_previewPanel.clipChildren  = false;

            KlyteMonoUtils.CreateUIElement(out m_bg, m_previewPanel.transform, "previewSubPanel", new UnityEngine.Vector4(75, 0, WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT, WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT));
            m_bg.autoSize             = false;
            m_bg.transform.localScale = Vector3.one * Mathf.Min(MainContainer.width, MainContainer.height) / WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT;
            m_bg.clipChildren         = true;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteContainer, MainContainer.transform, "overrideSpriteContainer", new UnityEngine.Vector4(0, 0, MainContainer.width - 66, 300));
            overrideSpriteContainer.autoLayout          = true;
            overrideSpriteContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteSubContainer, overrideSpriteContainer.transform, "overrideSpriteSubContainer", new UnityEngine.Vector4(0, 0, overrideSpriteContainer.width, overrideSpriteContainer.height));
            overrideSpriteSubContainer.backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon, true);
            overrideSpriteSubContainer.autoLayout          = false;
            overrideSpriteSubContainer.color               = Color.gray;
            overrideSpriteSubContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            OverrideSprite                       = overrideSpriteSubContainer.AddUIComponent <UISprite>();
            OverrideSprite.size                  = new Vector2(300, 300);
            OverrideSprite.relativePosition      = new Vector2(75, 0);
            overrideSpriteSubContainer.isVisible = false;

            RegisterTemplate();
            m_layers = new UITemplateList <UITextureSprite>(m_bg, TEMPLATE_PREVIEW_LAYER_NAME);

            WTSHighwayShieldEditor.Instance.CurrentTabChanged += (x) => ReloadData();
        }
Beispiel #16
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            MainContainer.padding             = new RectOffset(8, 8, 8, 8);

            KlyteMonoUtils.CreateUIElement(out m_previewPanel, MainContainer.transform, "previewPanel", new UnityEngine.Vector4(0, 0, 0, 300));
            m_previewPanel.autoLayout    = true;
            m_previewPanel.disabledColor = Color.black;

            KlyteMonoUtils.CreateUIElement(out UIPanel subPreviewPanel, m_previewPanel.transform, "previewSubPanel", new UnityEngine.Vector4(0, 0, MainContainer.width - 66, m_previewPanel.height));
            subPreviewPanel.backgroundSprite = "GenericPanel";
            subPreviewPanel.autoLayout       = true;
            subPreviewPanel.disabledColor    = Color.black;


            KlyteMonoUtils.CreateUIElement(out m_preview, subPreviewPanel.transform, "preview", new UnityEngine.Vector4(0, 0, subPreviewPanel.width, subPreviewPanel.height));
            KlyteMonoUtils.CreateElement(out m_previewRenderer, MainContainer.transform);
            m_previewRenderer.Size     = m_preview.size * 2f;
            m_preview.texture          = m_previewRenderer.Texture;
            m_preview.eventMouseWheel += ChangeViewZoom;
            m_preview.eventMouseMove  += OnMouseMove;
            m_previewRenderer.Zoom     = TargetZoom;
            m_preview.disabledColor    = Color.black;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteContainer, MainContainer.transform, "overrideSpriteContainer", new UnityEngine.Vector4(0, 0, MainContainer.width - 66, 300));
            overrideSpriteContainer.autoLayout          = true;
            overrideSpriteContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteSubContainer, overrideSpriteContainer.transform, "overrideSpriteSubContainer", new UnityEngine.Vector4(0, 0, overrideSpriteContainer.width, overrideSpriteContainer.height));
            overrideSpriteSubContainer.backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon, true);
            overrideSpriteSubContainer.autoLayout          = true;
            overrideSpriteSubContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            OverrideSprite      = overrideSpriteSubContainer.AddUIComponent <UISprite>();
            OverrideSprite.size = overrideSpriteContainer.size;
            overrideSpriteSubContainer.isVisible = false;


            KlyteMonoUtils.CreateUIElement(out m_previewControls, MainContainer.transform, "controls", new UnityEngine.Vector4(0, 0, 50, 300));
            m_previewControls.padding             = new RectOffset(5, 5, 5, 5);
            m_previewControls.autoLayout          = true;
            m_previewControls.autoLayoutDirection = LayoutDirection.Vertical;


            KlyteMonoUtils.InitCircledButton(m_previewControls, out m_lockToSelection, CommonsSpriteNames.K45_Unlock, (x, y) => ToggleLock(), "K45_WTS_LOCK_UNLOCK_TO_CURRENT_ITEM");
            m_lockToSelection.focusedBgSprite = null;
            m_viewLocked = true;
            ToggleLock();

            KlyteMonoUtils.InitCircledButton(m_previewControls, out UIButton resetView, CommonsSpriteNames.K45_Reload, (x, y) => ResetCamera(), "K45_WTS_RESET_VIEW");

            UIHelperExtension.AddSpace(m_previewControls, 10);

            KlyteMonoUtils.InitCircledButton(m_previewControls, out UIButton useCurrentText, CommonsSpriteNames.K45_FontIcon, (x, y) => m_overrideText = null, "K45_WTS_USE_CURRENT_TEXT");
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use1lText, "x1", (x, y) => m_overrideText     = "1", Locale.Get("K45_WTS_USE_1LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use10lText, "x10", (x, y) => m_overrideText   = "Á" + new string('X', 8) + "j", Locale.Get("K45_WTS_USE_10LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use50lText, "x50", (x, y) => m_overrideText   = "Á" + new string('L', 48) + "j", Locale.Get("K45_WTS_USE_50LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use100lText, "x200", (x, y) => m_overrideText = "Á" + new string('C', 198) + "j", Locale.Get("K45_WTS_USE_200LENGHT_TEXT"));

            WTSPropLayoutEditor.Instance.CurrentTabChanged += (x) => ResetCamera();
        }
Beispiel #17
0
        private void Awake()
        {
            parent = GetComponentInChildren <UIScrollablePanel>();

            int parentWidth = 730;

            KlyteMonoUtils.CreateUIElement(out UITabstrip strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parentWidth - 10, 40));
            float effectiveOffsetY = strip.height;

            KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parentWidth - 10, 320));
            tabContainer.autoSize = true;
            strip.tabPages        = tabContainer;

            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(parentWidth, 320, false);

            foreach (System.Collections.Generic.KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = ReflectionUtils.GetImplementationForGenericType(typeof(TLMShowConfigTab <>), kv.Value().GetType());
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }

                GameObject tab                = Instantiate(tabTemplate.gameObject);
                GameObject body               = Instantiate(bodyContent.gameObject);
                var        configIdx          = kv.Key.ToConfigIndex();
                TransportSystemDefinition tsd = kv.Key;
                string name = kv.Value().GetType().Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true);
                string   fgIcon    = kv.Key.GetTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.white;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, components);
            }
            strip.selectedIndex = -1;
            strip.selectedIndex = 0;
        }
Beispiel #18
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, 315));
            m_tabSettings     = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "TxtSettings");
            m_tabSize         = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MoveCross), "K45_WTS_TEXT_SIZE_ATTRIBUTES", "TxtSize");
            m_tabAppearence   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_TEXT_APPEARANCE_ATTRIBUTES", "TxtApp");
            m_tabFrame        = TabCommons.CreateScrollableTabLocalized(m_tabstrip, "frame", "K45_WTS_TEXT_CONTAINERFRAME_ATTRIBUTES", "TxtFrm");
            m_tabIllumination = TabCommons.CreateScrollableTabLocalized(m_tabstrip, "SubBarPropsCommonLights", "K45_WTS_TEXT_ILLUMINATION_ATTRIBUTES", "TxtIll");
            m_tabConfig       = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_TEXT_CONFIGURATION_ATTRIBUTES", "TxtCnf");

            var helperSettings     = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperSize         = new UIHelperExtension(m_tabSize, LayoutDirection.Vertical);
            var helperAppearance   = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperFrame        = new UIHelperExtension(m_tabFrame, LayoutDirection.Vertical);
            var helperIllumination = new UIHelperExtension(m_tabIllumination, LayoutDirection.Vertical);
            var helperConfig       = new UIHelperExtension(m_tabConfig, LayoutDirection.Vertical);

            AddTextField(Locale.Get("K45_WTS_TEXT_TAB_TITLE"), out m_tabName, helperSettings, OnTabNameChanged);

            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_POS"), out m_arrayCoord, helperSize, OnPositionChange);
            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_ROT"), out m_arrayRotation, helperSize, OnRotationChange);
            AddFloatField(Locale.Get("K45_WTS_TEXT_SCALE"), out m_textScale, helperSize, OnScaleSubmit, false);
            AddFloatField(Locale.Get("K45_WTS_MAX_WIDTH_METERS"), out m_maxWidth, helperSize, OnMaxWidthChange, false);
            AddCheckboxLocale("K45_WTS_RESIZE_Y_TEXT_OVERFLOW", out m_applyScaleOnY, helperSize, OnChangeApplyRescaleOnY);
            AddCheckboxLocale("K45_WTS_CREATE_CLONE_180DEG", out m_create180degSimmetricClone, helperSize, OnChangeCreateSimmetricClone);
            AddCheckboxLocale("K45_WTS_CLONE_180DEG_INVERT_TEXT_HOR_ALIGN", out m_invertTextHorizontalAlignClone, helperSize, OnChangeInvertCloneTextHorizontalAlignment);

            AddVector2Field(Locale.Get("K45_WTS_TEXTBACKGROUNDSIZEGENERATED"), out m_bgSize, helperAppearance, OnBgSizeChanged); m_bgSize.ForEach(x => x.allowNegative = false);
            AddColorField(helperAppearance, Locale.Get("K45_WTS_BG_COLOR"), out m_bgColor, OnBgColorChanged);
            helperAppearance.AddSpace(5);
            AddColorField(helperAppearance, Locale.Get("K45_WTS_TEXT_COLOR"), out m_textFixedColor, OnFixedColorChanged);
            AddCheckboxLocale("K45_WTS_USE_CONTRAST_COLOR", out m_useContrastColor, helperAppearance, OnContrastColorChange);
            helperAppearance.AddSpace(5);
            AddSlider(Locale.Get("K45_WTS_TEXT_DEPTH"), out m_sliderDepth, helperAppearance, OnChangeDepth, -1, 1, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_ALIGN_HOR"), out m_dropdownTextAlignHorizontal, helperAppearance, ColossalUIExtensions.GetDropdownOptions <UIHorizontalAlignment>("K45_ALIGNMENT"), OnSetTextAlignmentHorizontal);

            AddCheckboxLocale("K45_WTS_TEXT_USEFRAME", out m_useFrame, helperFrame, OnUseFrameChange);
            AddCheckboxLocale("K45_WTS_TEXT_CONTAINERUSEVEHICLECOLOR", out m_frameUseVehicleColor, helperFrame, OnFrameUseVehicleColorChange);
            AddColorField(helperFrame, Locale.Get("K45_WTS_TEXT_CONTAINEROUTERCOLOR"), out m_frameColor, OnFrameColorChanged);
            AddSlider(Locale.Get("K45_WTS_TEXT_CONTAINEROUTERSPECULARITY"), out m_frameOuterSpecularLevel, helperFrame, OnFrameOuterSpecularLevelChanged, 0, 1, 0.01f, (x) => (x * 100).ToString("F0") + "%");
            AddVector2Field(Locale.Get("K45_WTS_TEXT_CONTAINERBACKSIZE"), out m_frameBackSize, helperFrame, OnFrameBackSizeChanged, true, false, false);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_CONTAINERBACKOFFSET"), out m_frameBackOffset, helperFrame, OnFrameBackOffsetChanged);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_CONTAINERDEPTHFRONTBACK"), out m_frameDepths, helperFrame, OnFrameDepthsChanged, true, false, false);
            AddFloatField(Locale.Get("K45_WTS_TEXT_CONTAINERFRONTBORDERTHICKNESS"), out m_frameFrontBorder, helperFrame, OnFrameBorderThicknessChanged, false);
            AddColorField(helperFrame, Locale.Get("K45_WTS_TEXT_CONTAINERGLASSCOLOR"), out m_frameGlassColor, OnFrameGlassColorChanged);
            AddSlider(Locale.Get("K45_WTS_TEXT_CONTAINERGLASSTRANSPARENCY"), out m_frameGlassTransparency, helperFrame, OnFrameGlassTransparencyChanged, 0, 1, 0.01f, (x) => (x * 100).ToString("F0") + "%");
            AddSlider(Locale.Get("K45_WTS_TEXT_CONTAINERGLASSSPECULARITY"), out m_frameGlassSpecularLevel, helperFrame, OnFrameGlassSpecularLevelChanged, 0, 1, 0.01f, (x) => (x * 100).ToString("F0") + "%");

            AddDropdown(Locale.Get("K45_WTS_TEXT_MATERIALTYPE"), out m_dropdownMaterialType, helperIllumination, ColossalUIExtensions.GetDropdownOptions <MaterialType>("K45_WTS_TEXTMATERIALTYPE"), OnSetMaterialType);
            AddSlider(Locale.Get("K45_WTS_TEXT_ILLUMINATIONSTRENGTH"), out m_sliderIllumination, helperIllumination, OnChangeIlluminationStrength, 0, 10, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_BLINKTYPE"), out m_dropdownBlinkType, helperIllumination, ColossalUIExtensions.GetDropdownOptions <BlinkType>("K45_WTS_BLINKTYPE"), OnSetBlinkType);
            AddVector4Field(Locale.Get("K45_WTS_TEXT_CUSTOMBLINKPARAMS"), out m_arrayCustomBlink, helperIllumination, OnCustomBlinkChange);



            m_flagsState = new Dictionary <Vehicle.Flags, UIMultiStateButton>();
            var flagsCheck = helperIllumination.AddGroupExtended(Locale.Get("K45_WTS_FLAGSREQUREDFORBIDDEN"));

            m_flagsContainer = flagsCheck.Self.parent;
            ((UIPanel)flagsCheck.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIPanel)flagsCheck.Self).wrapLayout          = true;

            (Enum.GetValues(typeof(Vehicle.Flags)) as Vehicle.Flags[]).ForEach(f =>
            {
                AddMultistateButton(f.ToString(), flagsCheck.Self, out UIMultiStateButton button, out _, out _, flagsCheck.Self.width / 4.1f, new string[] { "AchievementCheckedFalse", "AchievementCheckedTrue", "AchievementCheckedTrueNegative", }, (x, y) => OnSetStateFlag(f, y), new Vector2(20, 20));
                m_flagsState[f] = button;
            });


            AddDropdown(Locale.Get("K45_WTS_TEXT_CONTENT"), out m_dropdownTextContent, helperConfig, WTSDynamicTextRenderingRules.ALLOWED_TYPES_VEHICLE.GetDropdownOptions("K45_WTS_BOARD_TEXT_TYPE_DESC_VEHICLE"), OnSetTextOwnNameContent);
            AddTextField(Locale.Get("K45_WTS_CUSTOM_TEXT"), out m_customText, helperConfig, OnSetTextCustom);

            IEnumerator OnFilter(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterSprites(WTSVehicleLayoutEditor.Instance.Preview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_SPRITE_NAME"), helperConfig, out m_spriteFilter, out UIListBox lb2, OnFilter, OnSpriteNameChanged);
            lb2.size                      = new Vector2(MainContainer.width - 20, 220);
            lb2.processMarkup             = true;
            m_spriteFilter.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSVehicleLayoutEditor.Instance.Preview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb2.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb2.items.Length)
                {
                    WTSVehicleLayoutEditor.Instance.Preview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim();
                }
            };
            lb2.eventVisibilityChanged += (x, y) => WTSVehicleLayoutEditor.Instance.Preview.OverrideSprite.parent.isVisible = y;
            WTSVehicleLayoutEditor.Instance.Preview.OverrideSprite.parent.isVisible = false;

            helperConfig.AddSpace(5);
            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_overrideFontSelect, helperConfig, OnSetOverrideFont);
            AddDropdown(Locale.Get("K45_WTS_CLASS_FONT"), out m_fontClassSelect, helperConfig, ColossalUIExtensions.GetDropdownOptions <FontClass>("K45_WTS_FONTCLASS"), OnSetFontClass);
            AddTextField(Locale.Get("K45_WTS_PREFIX"), out m_textPrefix, helperConfig, OnSetPrefix);
            AddTextField(Locale.Get("K45_WTS_SUFFIX"), out m_textSuffix, helperConfig, OnSetSuffix);
            AddCheckboxLocale("K45_WTS_TEXT_ALL_CAPS", out m_allCaps, helperConfig, OnSetAllCaps);
            AddCheckboxLocale("K45_WTS_TEXT_APPLYABBREVIATIONS", out m_applyAbbreviations, helperConfig, OnSetApplyAbbreviations);

            WTSUtils.ReloadFontsOf(m_overrideFontSelect, null, true, true);

            WTSVehicleLayoutEditor.Instance.CurrentTabChanged += (newVal) =>
            {
                int targetTab = newVal - 1;
                SafeObtain(OnSetData, targetTab);
            };
            m_isEditing = false;


            AddLibBox <WTSLibVehicleTextItem, BoardTextDescriptorGeneralXml>(helperSettings, out UIButton m_copyButtonText,
                                                                             DoCopyText, out m_pasteButtonText,
                                                                             DoPasteText, out UIButton m_deleteButtonText,
                                                                             DoDeleteText, (loadedItem) => SafeObtain((ref BoardTextDescriptorGeneralXml x) =>
            {
                string name = x.SaveName;
                x           = XmlUtils.DefaultXmlDeserialize <BoardTextDescriptorGeneralXml>(loadedItem);
                x.SaveName  = name;
                OnSetData(ref x);
                x.SaveName = name;
            }),
                                                                             () => XmlUtils.DefaultXmlSerialize(WTSVehicleLayoutEditor.Instance.EditingInstance.TextDescriptors[Math.Max(0, TabToEdit)]));
        }
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out UITabContainer m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, 315));
            m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "TxtSettings");
            m_tabSize       = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MoveCross), "K45_WTS_TEXT_SIZE_ATTRIBUTES", "TxtSize");
            m_tabAppearence = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_TEXT_APPEARANCE_ATTRIBUTES", "TxtApp");
            m_tabConfig     = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_TEXT_CONFIGURATION_ATTRIBUTES", "TxtCnf");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperSize       = new UIHelperExtension(m_tabSize, LayoutDirection.Vertical);
            var helperAppearance = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperConfig     = new UIHelperExtension(m_tabConfig, LayoutDirection.Vertical);

            AddTextField(Locale.Get("K45_WTS_TEXT_TAB_TITLE"), out m_tabName, helperSettings, OnTabNameChanged);

            AddVector2Field(Locale.Get("K45_WTS_RELATIVE_OFFSET"), out m_arrayCoord, helperSize, OnPositionChange);
            AddVector2Field(Locale.Get("K45_WTS_PIVOT_OFFSET"), out m_arrayPivot, helperSize, OnPivotChange);
            AddFloatField(Locale.Get("K45_WTS_TEXT_SCALE"), out m_textScale, helperSize, OnScaleSubmit, false);
            AddFloatField(Locale.Get("K45_WTS_CHARACTER_SPACING"), out m_charSpacingFactor, helperSize, OnSpacingFactorChanged, false);
            AddIntField(Locale.Get("K45_WTS_MAX_WIDTH_PIXELS"), out m_maxWidth, helperSize, OnMaxWidthChange, false);
            AddIntField(Locale.Get("K45_WTS_FIXED_HEIGHT_PIXELS"), out m_fixedHeight, helperSize, OnFixedHeightChange, false);
            AddCheckboxLocale("K45_WTS_RESIZE_Y_TEXT_OVERFLOW", out m_applyScaleOnY, helperSize, OnChangeApplyRescaleOnY);

            helperAppearance.AddSpace(5);
            AddColorField(helperAppearance, Locale.Get("K45_WTS_TEXT_COLOR"), out m_textFixedColor, OnFixedColorChanged);
            AddDropdown(Locale.Get("K45_WTS_COLOR_SOURCE"), out m_colorSource, helperAppearance, Enum.GetValues(typeof(ColoringSource)).Cast <ColoringSource>().Select(x => Tuple.New(Locale.Get("K45_WTS_COLORSRC", x.ToString()), x)).ToArray(), OnSetColorSource);
            helperAppearance.AddSpace(5);

            AddDropdown(Locale.Get("K45_WTS_TEXT_CONTENT"), out m_dropdownTextContent, helperConfig, WTSDynamicTextRenderingRules.ALLOWED_TYPES_HIGHWAY_SHIELDS.Select(x => Tuple.New(Locale.Get("K45_WTS_BOARD_TEXT_TYPE_DESC_HWSHIELD", x.ToString()), x)).ToArray(), OnSetTextOwnNameContent);
            AddTextField(Locale.Get("K45_WTS_CUSTOM_TEXT"), out m_customText, helperConfig, OnSetTextCustom);
            IEnumerator OnFilter(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterSprites(WTSHighwayShieldEditor.Instance.Preview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_SPRITE_NAME"), helperConfig, out m_spriteFilter, out UIListBox lb2, OnFilter, OnSpriteNameChanged);
            lb2.size                      = new Vector2(MainContainer.width - 20, 220);
            lb2.processMarkup             = true;
            m_spriteFilter.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb2.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb2.items.Length)
                {
                    WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim();
                }
            };
            lb2.eventVisibilityChanged += (x, y) => WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.parent.isVisible = y;
            WTSHighwayShieldEditor.Instance.Preview.OverrideSprite.parent.isVisible = false;

            helperConfig.AddSpace(5);
            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_overrideFontSelect, helperConfig, OnSetOverrideFont);
            AddDropdown(Locale.Get("K45_WTS_CLASS_FONT"), out m_fontClassSelect, helperConfig, ColossalUIExtensions.GetDropdownOptions <FontClass>("K45_WTS_FONTCLASS"), OnSetFontClass);
            AddTextField(Locale.Get("K45_WTS_PREFIX"), out m_textPrefix, helperConfig, OnSetPrefix);
            AddTextField(Locale.Get("K45_WTS_SUFFIX"), out m_textSuffix, helperConfig, OnSetSuffix);

            WTSUtils.ReloadFontsOf(m_overrideFontSelect, null, true, true);

            WTSHighwayShieldEditor.Instance.CurrentTabChanged += (newVal) =>
            {
                int targetTab = newVal - 1;
                SafeObtain(OnSetData, targetTab);
            };
            m_isEditing = false;

            AddLibBox <WTSLibHighwayShieldTextLayer, ImageLayerTextDescriptorXml>(helperSettings, out UIButton m_copyButtonText,
                                                                                  DoCopyText, out m_pasteButtonText,
                                                                                  DoPasteText, out UIButton m_deleteButtonText,
                                                                                  DoDeleteText, (loadedItem) => SafeObtain((ref ImageLayerTextDescriptorXml x) =>
            {
                string name = x.SaveName;
                x           = XmlUtils.DefaultXmlDeserialize <ImageLayerTextDescriptorXml>(loadedItem);
                x.SaveName  = name;
                OnSetData(ref x);
                x.SaveName = name;
            }),
                                                                                  () => XmlUtils.DefaultXmlSerialize(WTSHighwayShieldEditor.Instance.EditingInstance.TextDescriptors[Math.Max(0, TabToEdit)]));
            m_pasteButtonText.isVisible = false;
        }
        private void Awake()
        {
            instance                      = this;
            mainPanel                     = GetComponent <UIPanel>();
            mainPanel.autoLayout          = true;
            mainPanel.autoLayoutDirection = LayoutDirection.Vertical;
            m_uiHelper                    = new UIHelperExtension(mainPanel);

            m_uiHelper.AddLabel(string.Format(Locale.Get("K45_TLM_CONFIGS_FOR"), TSD.GetTransportName()));
            UIPanel panel = m_uiHelper.Self.GetComponentInParent <UIPanel>();

            ((UIPanel)m_uiHelper.Self).autoLayoutDirection = LayoutDirection.Vertical;
            ((UIPanel)m_uiHelper.Self).backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MenuPanel_color);
            ((UIPanel)m_uiHelper.Self).wrapLayout          = true;
            ((UIPanel)m_uiHelper.Self).padding             = new RectOffset(10, 10, 10, 15);
            ((UIPanel)m_uiHelper.Self).color = TSD.Color;
            ((UIPanel)m_uiHelper.Self).width = 730;
            m_uiHelper.AddSpace(30);


            AddDropdown(Locale.Get("K45_TLM_PREFIX"), out m_prefixDD, m_uiHelper, TLMConfigOptions.namingOptionsPrefix.Select(x => x.GetName()).ToArray(), (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().Prefix = TLMConfigOptions.namingOptionsPrefix[x];
                    OnPrefixOptionChange();
                }
            });
            AddDropdown(Locale.Get("K45_TLM_SEPARATOR"), out m_separatorDD, m_uiHelper, TLMConfigOptions.namingOptionsSeparator.Select(x => x.GetName()).ToArray(), (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().Separator = TLMConfigOptions.namingOptionsSeparator[x];
                }
            });
            AddDropdown(Locale.Get("K45_TLM_SUFFIX"), out m_suffixDD, m_uiHelper, TLMConfigOptions.namingOptionsSuffix.Select(x => x.GetName()).ToArray(), (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().Suffix = TLMConfigOptions.namingOptionsSuffix[x];
                    OnSuffixOptionChange();
                }
            });
            AddDropdown(Locale.Get("K45_TLM_IDENTIFIER_NON_PREFIXED"), out m_nonPrefixDD, m_uiHelper, TLMConfigOptions.namingOptionsSuffix.Select(x => x.GetName()).ToArray(), (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().NonPrefixedNaming = TLMConfigOptions.namingOptionsSuffix[x];
                }
            });
            AddDropdown(Locale.Get("K45_TLM_PALETTE"), out m_paletteDD, m_uiHelper, TLMAutoColorPaletteContainer.PaletteList, (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().Palette = x == 0 ? null : TLMAutoColorPaletteContainer.PaletteList[x];
                }
            });
            AddDropdown(Locale.Get("K45_TLM_ICON"), out m_iconDD, m_uiHelper, Enum.GetValues(typeof(LineIconSpriteNames)).OfType <LineIconSpriteNames>().Select(x => x.GetNameForTLM()).ToArray(), (x) =>
            {
                if (x >= 0)
                {
                    TSD.GetConfig().DefaultLineIcon = (LineIconSpriteNames)x;
                }
            });
            m_uiHelper.AddSpace(5);

            AddCheckbox(Locale.Get("K45_TLM_USE_AUTO_NAME"), out m_useInAutoName, m_uiHelper, (x) => TSD.GetConfig().UseInAutoName = x);
            AddTextField(Locale.Get("K45_TLM_PREFIX_BUILDING_NAMES"), out m_namingPrefix, m_uiHelper, (x) => TSD.GetConfig().DefaultTicketPrice = int.TryParse(x, out int val) ? val : 0, TSD.GetConfig().DefaultTicketPrice.ToString());
            m_uiHelper.AddSpace(5);

            if (TSD.VehicleType != VehicleInfo.VehicleType.None)
            {
                AddTextField(Locale.Get("K45_TLM_NUMBERVEHICLEPATTERN_LOCAL"), out m_vehicleNumberFormatLocal, m_uiHelper, (x) => TSD.GetConfig().VehicleIdentifierFormatLocal       = x ?? "");
                AddTextField(Locale.Get("K45_TLM_NUMBERVEHICLEPATTERN_FOREIGN"), out m_vehicleNumberFormatForeign, m_uiHelper, (x) => TSD.GetConfig().VehicleIdentifierFormatForeign = x ?? "");
                m_uiHelper.AddSpace(5);

                AddIntField(Locale.Get("K45_TLM_COST_PER_PASSENGER_CONFIG"), out m_defaultCost, out m_defaultCostLbl, m_uiHelper, (x) => TSD.GetConfig().DefaultCostPerPassenger = x, false);
                AddIntField(Locale.Get("K45_TLM_DEFAULT_PRICE"), out m_defaultTicketPrice, m_uiHelper, (x) => TSD.GetConfig().DefaultTicketPrice = x, false);
                m_uiHelper.AddSpace(5);

                AddButtonInEditorRow(m_vehicleNumberFormatLocal, CommonsSpriteNames.K45_QuestionMark, Help_VehicleNumberFormat, null, true, 30);
                AddButtonInEditorRow(m_vehicleNumberFormatForeign, CommonsSpriteNames.K45_QuestionMark, Help_VehicleNumberFormat, null, true, 30);
            }

            AddCheckboxLocale("K45_TLM_NEAR_LINES_SHOW", out m_zerosContainer, m_uiHelper, (x) => TSD.GetConfig().ShowInLinearMap      = x);
            AddCheckboxLocale("K45_TLM_LEADING_ZEROS_SUFFIX", out m_zerosContainer, m_uiHelper, (x) => TSD.GetConfig().UseLeadingZeros = x);
            AddCheckboxLocale("K45_TLM_INVERT_PREFIX_SUFFIX_ORDER", out m_prefixAsSuffixContainer, m_uiHelper, (x) => TSD.GetConfig().InvertPrefixSuffix      = x);
            AddCheckboxLocale("K45_TLM_RANDOM_ON_PALETTE_OVERFLOW", out m_randomPaletteOnOverflow, m_uiHelper, (x) => TSD.GetConfig().PaletteRandomOnOverflow = x);
            AddCheckboxLocale("K45_TLM_AUTO_COLOR_BASED_ON_PREFIX", out m_autoColorBasedContainer, m_uiHelper, (x) => TSD.GetConfig().PalettePrefixBased      = x);
            AddCheckboxLocale("K45_TLM_LINENUMBERING_BASED_IN_PREFIX", out m_prefixIncrement, m_uiHelper, (x) => TSD.GetConfig().IncrementPrefixOnNewLine     = x);
        }
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.clipChildren        = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 4, 4);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out UITabContainer m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            UIPanel m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_ROADCORNER_BASIC_SETTINGS", "RcSettings");
            UIPanel m_tabRoads      = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, "ToolbarIconRoads", "K45_WTS_ROADCORNER_ALLOWTITLE", "RcRoad");
            UIPanel m_tabSpawning   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Reload), "K45_WTS_ROADCORNER_SPAWNING_SETTINGS", "RcSpawning");
            UIPanel m_tabAppearence = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_ROADCORNER_APPEARANCE_SETTINGS", "RcAppearence");
            UIPanel m_tabDistricts  = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, "ToolbarIconDistrict", "K45_WTS_ROADCORNER_DISTRICT_SETTINGS", "RcDistricts");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperSpawning   = new UIHelperExtension(m_tabSpawning, LayoutDirection.Vertical);
            var helperAppearence = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperDistricts  = new UIHelperExtension(m_tabDistricts, LayoutDirection.Vertical);

            var helperRoads = new UIHelperExtension(m_tabRoads, LayoutDirection.Vertical);


            AddTextField(Locale.Get("K45_WTS_ROADCORNER_NAME"), out m_name, helperSettings, OnSetName);

            helperSettings.AddSpace(5);

            AddFilterableInput(Locale.Get("K45_WTS_ROADCORNER_PROPLAYOUT"), helperSettings, out m_propLayoutSelect, out _, OnFilterLayouts, OnPropLayoutChange);

            AddVector3Field(Locale.Get("K45_WTS_ROADCORNER_POSITION"), out m_position, helperSettings, OnPositionChanged);
            AddVector3Field(Locale.Get("K45_WTS_ROADCORNER_ROTATION"), out m_rotation, helperSettings, OnRotationChanged);
            AddVector3Field(Locale.Get("K45_WTS_ROADCORNER_SCALE"), out m_scale, helperSettings, OnScaleChanged);
            AddLibBox <WTSLibRoadCornerRule, BoardInstanceRoadNodeXml>(helperSettings, out m_copySettings, OnCopyRule, out m_pasteSettings, OnPasteRule, out _, null, OnLoadRule, GetRuleSerialized);

            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_DIRTROADS", out m_allowDirty, helperRoads, (x) => ToggleAllow(Level.Level1, x));
            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_ALLEYS", out m_allowAlleys, helperRoads, (x) => ToggleAllow((Level)5, x));
            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_SMALLROADS", out m_allowSmallRoads, helperRoads, (x) => ToggleAllow(Level.Level2, x));
            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_MEDIUMROADS", out m_allowMediumRoads, helperRoads, (x) => ToggleAllow(Level.Level3, x));
            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_LARGEROADS", out m_allowLargeRoads, helperRoads, (x) => ToggleAllow(Level.Level4, x));
            AddCheckboxLocale("K45_WTS_ROADCORNER_ALLOW_HIGHWAYS", out m_allowHighways, helperRoads, (x) => ToggleAllow(Level.Level5, x));

            AddSlider(Locale.Get("K45_WTS_ROADCORNER_SPAWN_CHANCE"), out m_spawnChance, helperSpawning, OnChangeSpawnChance, 0, 255, 1, (x) => (x / 255).ToString("P0"));
            AddVector2Field(Locale.Get("K45_WTS_ROADCORNER_MINMAXHALFWIDTH"), out m_minMaxHalfWidth, helperSpawning, OnSetMinMaxHalfWidth);
            AddCheckboxLocale("K45_WTS_ROADCORNER_IGNOREEMPTYNAMES", out m_ignoreEmpty, helperSpawning, OnChangeIgnoreEmpty);

            KlyteMonoUtils.CreateUIElement(out m_spawnInCornerOptions, m_tabSpawning.transform, "spawnInCorner", new Vector4(0, 0, 620, 0));
            var helperSpawningCorner = new UIHelperExtension(m_spawnInCornerOptions, LayoutDirection.Vertical);

            helperSpawningCorner.Self.width = 620;
            AddCheckboxLocale("K45_WTS_ROADCORNER_PLACEALSOONDISTRICTBORDER", out m_placeDistrictBorder, helperSpawningCorner, OnChangeSpawnOnDistrictBorder);
            AddCheckboxLocale("K45_WTS_ROADCORNER_PLACEONTUNNELBRIDGESTART", out m_placeRoadTransition, helperSpawningCorner, OnChangePlaceRoadTransition);

            AddCheckboxLocale("K45_WTS_ROADCORNER_USEDISTRICTCOLOR", out m_useDistrictColor, helperAppearence, OnChangeUseDistrictColor);

            AddCheckboxLocale("K45_WTS_ROADCORNER_DISTRICTSELECTIONASWHITELIST", out m_districtWhiteList, helperDistricts, OnSetDistrictsAsWhitelist);
            AddCheckboxLocale("K45_WTS_ROADCORNER_DISTRICTSELECTIONASBLACKLIST", out m_districtBlackList, helperDistricts, OnSetDistrictsAsBlacklist);
            AddDropdown(Locale.Get("K45_WTS_ROADCORNER_DISTRICTRESTRICTIONSOLVEORDER"), out m_districtResolutionOrder, helperDistricts, ColossalUIExtensions.GetDropdownOptions <DistrictRestrictionOrder>("K45_WTS_DISTRICTRESTRICTIONORDER"), OnChangeDistrictRestrictionOrder);
            KlyteMonoUtils.CreateUIElement(out m_listContainer, helperDistricts.Self.transform, "previewPanel", new UnityEngine.Vector4(0, 0, helperDistricts.Self.width, helperDistricts.Self.height - 160));
            KlyteMonoUtils.CreateScrollPanel(m_listContainer, out m_districtList, out _, m_listContainer.width - 20, m_listContainer.height);
            m_districtList.backgroundSprite    = "OptionsScrollbarTrack";
            m_districtList.autoLayout          = true;
            m_districtList.autoLayoutDirection = LayoutDirection.Vertical;

            CreateTemplateDistrict();
            m_checkboxTemplateList = new UITemplateList <UIPanel>(m_districtList, DISTRICT_SELECTOR_TEMPLATE);


            WTSRoadCornerEditor.Instance.RuleList.EventSelectionChanged += OnChangeTab;
            MainContainer.isVisible   = false;
            m_pasteSettings.isVisible = false;
        }
Beispiel #22
0
 private void UpdateTerminalStatus(ushort lineID, ushort currentStop, UIButton button) => button.normalBgSprite =
     TransportSystemDefinition.From(lineID).CanHaveTerminals() && (currentStop == Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops || TLMStopDataContainer.Instance.SafeGet(currentStop).IsTerminal)
                         ? KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_S05StarIcon, true)
                         : "";// KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_CircleIcon, true);
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.clipChildren        = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 4, 4);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out UITabContainer m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            UIPanel m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_ACE_BASICTAB_BASIC_SETTINGS", "RcSettings");
            UIPanel m_tabAppearence = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_ACE_BASICTAB_APPEARANCE_SETTINGS", "RcAppearence");
            UIPanel m_tabDistricts  = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, "ToolbarIconDistrict", "K45_ACE_BASICTAB_DISTRICT_SETTINGS", "RcDistricts");
            UIPanel m_tabLib        = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Load), "K45_ACE_BASICTAB_LIB_SETTINGS", "RcLib");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperAppearence = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperDistricts  = new UIHelperExtension(m_tabDistricts, LayoutDirection.Vertical);
            var helperLib        = new UIHelperExtension(m_tabLib, LayoutDirection.Vertical);


            AddTextField(Locale.Get("K45_ACE_BASICTAB_NAME"), out m_name, helperSettings, OnSetName);
            helperSettings.AddSpace(5);

            AddDropdown(Locale.Get("K45_ACE_BASICTAB_RULEFILTER"), out m_ruleFilter, helperSettings, Enum.GetNames(typeof(RuleCheckTypeProp)).Select(x => Locale.Get("K45_ACE_RULECHECKTYPE", x)).ToArray(), OnChangeRuleCheckType);
            AddButtonInEditorRow(m_ruleFilter, CommonsSpriteNames.K45_QuestionMark, Help_RuleFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_SERVICEFILTER"), out m_service, helperSettings, (Enum.GetValues(typeof(ItemClass.Service)) as ItemClass.Service[]).OrderBy(x => (int)x).Select(x => x == 0 ? Locale.Get("K45_ACE_ANYSERVICE_OPTION") : $"{x}").ToArray(), OnChangeServiceFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_SUBSERVICEFILTER"), out m_subService, helperSettings, Enum.GetNames(typeof(ItemClass.SubService)).Select(x => $"{x}").ToArray(), OnChangeSubServiceFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_LEVELFILTER"), out m_level, helperSettings, (Enum.GetValues(typeof(ItemClass.Level)) as ItemClass.Level[]).OrderBy(x => (int)x).Select(x => $"{x}").ToArray(), OnChangeLevelFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_CLASSFILTER"), out m_class, helperSettings, new string[0], OnChangeClassFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_CLASSFILTER"), out m_parentClass, helperSettings, new string[0], OnChangeParentClassFilter);
            AddTextField(Locale.Get("K45_ACE_PROPRULES_ASSETSELECT_BUILDING"), out m_assetFilterBuilding, helperSettings, null);

            KlyteMonoUtils.UiTextFieldDefaultsForm(m_assetFilterBuilding);
            m_popupBuilding        = ConfigureListSelectionPopupForUITextField(m_assetFilterBuilding, (text) => AssetColorExpanderMod.Controller?.AssetsCache.FilterBuildingsByText(text), OnAssetSelectedBuildingChanged);
            m_popupBuilding.height = 290;
            m_popupBuilding.width -= 20;

            AddTextField(Locale.Get("K45_ACE_PROPRULES_ASSETSELECT_NET"), out m_assetFilterNet, helperSettings, null);

            KlyteMonoUtils.UiTextFieldDefaultsForm(m_assetFilterNet);
            m_popupNet        = ConfigureListSelectionPopupForUITextField(m_assetFilterNet, (text) => AssetColorExpanderMod.Controller?.AssetsCache.FilterNetsByText(text), OnAssetSelectedNetChanged);
            m_popupNet.height = 290;
            m_popupNet.width -= 20;

            AddTextField(Locale.Get("K45_ACE_PROPRULES_ASSETSELECT"), out m_assetFilter, helperSettings, null);

            KlyteMonoUtils.UiTextFieldDefaultsForm(m_assetFilter);
            m_popup        = ConfigureListSelectionPopupForUITextField(m_assetFilter, (text) => AssetColorExpanderMod.Controller?.AssetsCache.FilterPropsByText(text), OnAssetSelectedChanged);
            m_popup.height = 290;
            m_popup.width -= 20;

            GenerateExportButtons(helperSettings, "Building",
                                  out m_exportButtonContainer, out m_exportButton, OnExport,
                                  out m_exportButtonContainerLocal, out m_exportButtonLocal, OnExportLocal);

            AddLibBox <ACEPropRuleLib, PropCityDataRuleXml>(helperLib, out m_copySettings, OnCopyRule, out m_pasteSettings, OnPasteRule, out _, null, OnLoadRule, GetRuleSerialized);

            AddDropdown(Locale.Get("K45_ACE_COLORMODE"), out m_colorMode, helperAppearence, Enum.GetNames(typeof(ColoringMode)).Select(x => Locale.Get("K45_ACE_COLORINGMODE", x)).ToArray(), OnChangeColoringMode);
            AddButtonInEditorRow(m_colorMode, CommonsSpriteNames.K45_QuestionMark, Help_ColorMode);

            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWREDTONES", out m_allowRed, helperAppearence, OnAllowRedChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWGREENTONES", out m_allowGreen, helperAppearence, OnAllowGreenChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWBLUETONES", out m_allowBlues, helperAppearence, OnAllowBlueChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWNEUTRALTONES", out m_allowNeutral, helperAppearence, OnAllowNeutralChanged);


            KlyteMonoUtils.CreateUIElement(out m_listColorContainer, helperAppearence.Self.transform, "listColors", new UnityEngine.Vector4(0, 0, helperAppearence.Self.width, helperAppearence.Self.height - 80));
            KlyteMonoUtils.CreateScrollPanel(m_listColorContainer, out m_colorListScroll, out _, m_listColorContainer.width - 20, m_listColorContainer.height);
            m_colorListScroll.backgroundSprite    = "OptionsScrollbarTrack";
            m_colorListScroll.autoLayout          = true;
            m_colorListScroll.autoLayoutDirection = LayoutDirection.Horizontal;
            m_colorListScroll.wrapLayout          = true;
            CreateTemplateColorItem();
            m_colorFieldTemplateListColors = new UITemplateList <UIPanel>(m_colorListScroll, COLOR_SELECTOR_TEMPLATE);

            KlyteMonoUtils.InitCircledButton(m_colorListScroll, out m_addColor, CommonsSpriteNames.K45_Plus, (x, y) => AddColor(), "", 36);


            AddCheckboxLocale("K45_ACE_BASICTAB_DISTRICTSELECTIONASWHITELIST", out m_districtWhiteList, helperDistricts, OnSetDistrictsAsWhitelist);
            AddCheckboxLocale("K45_ACE_BASICTAB_DISTRICTSELECTIONASBLACKLIST", out m_districtBlackList, helperDistricts, OnSetDistrictsAsBlacklist);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_DISTRICTRESTRICTIONSOLVEORDER"), out m_districtResolutionOrder, helperDistricts, Enum.GetNames(typeof(DistrictRestrictionOrder)).Select(x => Locale.Get("K45_ACE_DISTRICTRESTRICTIONORDER", x)).ToArray(), OnChangeDistrictRestrictionOrder);
            AddButtonInEditorRow(m_districtResolutionOrder, CommonsSpriteNames.K45_QuestionMark, Help_DistrictFilter);
            KlyteMonoUtils.CreateUIElement(out m_listContainer, helperDistricts.Self.transform, "previewPanel", new UnityEngine.Vector4(0, 0, helperDistricts.Self.width, helperDistricts.Self.height - 160));
            KlyteMonoUtils.CreateScrollPanel(m_listContainer, out m_districtList, out _, m_listContainer.width - 20, m_listContainer.height);
            m_districtList.backgroundSprite    = "OptionsScrollbarTrack";
            m_districtList.autoLayout          = true;
            m_districtList.autoLayoutDirection = LayoutDirection.Vertical;

            CreateTemplateDistrict();
            m_checkboxTemplateListDistrict = new UITemplateList <UIPanel>(m_districtList, DISTRICT_SELECTOR_TEMPLATE);


            MainContainer.isVisible   = false;
            m_pasteSettings.isVisible = false;
        }
Beispiel #24
0
        private static void DrawTextBri(ushort refID, int boardIdx, int secIdx, Matrix4x4 propMatrix, BoardTextDescriptorGeneralXml textDescriptor,
                                        MaterialPropertyBlock materialPropertyBlock, BasicRenderInformation renderInfo, Color colorToSet, Vector3 targetPos, Vector3 targetRotation,
                                        Vector3 baseScale, bool placeClone180Y, UIHorizontalAlignment targetTextAlignment, float maxWidth, int instanceFlags, Color parentColor,
                                        PrefabInfo srcInfo, ref int defaultCallsCounter, Camera targetCamera = null)
        {
            var textMatrixes = CalculateTextMatrix(targetPos, targetRotation, baseScale, targetTextAlignment, maxWidth, textDescriptor, renderInfo, placeClone180Y);

            foreach (var textMatrixTuple in textMatrixes)
            {
                Matrix4x4 matrix = propMatrix * textMatrixTuple.First;

                materialPropertyBlock.Clear();

                Material    targetMaterial = renderInfo.m_generatedMaterial;
                PropManager instance       = CalculateIllumination(refID, boardIdx, secIdx, textDescriptor, materialPropertyBlock, ref colorToSet, instanceFlags);


                defaultCallsCounter++;
                Graphics.DrawMesh(renderInfo.m_mesh, matrix, targetMaterial, 10, targetCamera, 0, materialPropertyBlock, false);

                if (((Vector2)textDescriptor.BackgroundMeshSettings.Size).sqrMagnitude != 0)
                {
                    BasicRenderInformation bgBri = WriteTheSignsMod.Controller.AtlasesLibrary.GetFromLocalAtlases(null, KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon));
                    if (bgBri != null)
                    {
                        Matrix4x4 containerMatrix = DrawBgMesh(ref propMatrix, textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, targetTextAlignment, targetCamera, textMatrixTuple, instance, bgBri, ref defaultCallsCounter);
                        if (textDescriptor.BackgroundMeshSettings.UseFrame)
                        {
                            DrawTextFrame(textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, ref parentColor, srcInfo, targetCamera, ref containerMatrix, ref defaultCallsCounter);
                        }
                    }
                }
            }
        }
        protected sealed override void OnLevelLoadedInherit(LoadMode mode)
        {
            base.OnLevelLoadedInherit(mode);
            if (LoadUI && IsValidLoadMode(mode))
            {
                m_modsPanel = UIView.Find <UIPanel>("K45_ModsPanel");
                if (m_modsPanel is null)
                {
                    UIComponent uicomponent = UIView.Find("TSBar");
                    m_bg                  = uicomponent.AddUIComponent <UIPanel>();
                    m_bg.name             = "K45_MB";
                    m_bg.absolutePosition = new Vector2(ButtonPosX.value, ButtonPosY.value);
                    m_bg.width            = 40f;
                    m_bg.height           = 40f;
                    m_bg.zOrder           = 1;
                    UIButton doneButton = m_bg.AddUIComponent <UIButton>();
                    doneButton.normalBgSprite   = "GenericPanel";
                    doneButton.width            = 100f;
                    doneButton.height           = 50f;
                    doneButton.relativePosition = new Vector2(0f, -52);
                    doneButton.text             = "Done";
                    doneButton.hoveredTextColor = new Color32(0, byte.MaxValue, byte.MaxValue, 1);
                    doneButton.Hide();
                    doneButton.zOrder = 99;
                    UIDragHandle handle = m_bg.AddUIComponent <UIDragHandle>();
                    handle.name             = "K45_DragHandle";
                    handle.relativePosition = Vector2.zero;
                    handle.width            = m_bg.width - 5f;
                    handle.height           = m_bg.height - 5f;
                    handle.zOrder           = 0;
                    handle.target           = m_bg;
                    handle.Start();
                    handle.enabled = false;
                    m_bg.zOrder    = 9;

                    m_bg.isInteractive     = false;
                    handle.zOrder          = 10;
                    doneButton.eventClick += (component, ms) =>
                    {
                        doneButton.Hide();
                        handle.zOrder    = 10000;
                        handle.enabled   = false;
                        ButtonPosX.value = (int)m_bg.absolutePosition.x;
                        ButtonPosY.value = (int)m_bg.absolutePosition.y;
                    };
                    m_bg.color       = new Color32(96, 96, 96, byte.MaxValue);
                    m_modPanelButton = m_bg.AddUIComponent <UIButton>();
                    m_modPanelButton.disabledTextColor = new Color32(128, 128, 128, byte.MaxValue);
                    KlyteMonoUtils.InitButton(m_modPanelButton, false, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_K45Button), false);
                    m_modPanelButton.relativePosition        = new Vector3(10, 4f);
                    m_modPanelButton.size                    = new Vector2(32, 32);
                    m_modPanelButton.name                    = "K45_ModsButton";
                    m_modPanelButton.zOrder                  = 11;
                    m_modPanelButton.textScale               = 1.3f;
                    m_modPanelButton.textVerticalAlignment   = UIVerticalAlignment.Middle;
                    m_modPanelButton.textHorizontalAlignment = UIHorizontalAlignment.Center;
                    m_modPanelButton.tooltip                 = "Double click to move the button!";
                    m_modPanelButton.eventDoubleClick       += (component, ms) =>
                    {
                        handle.zOrder = 13;
                        doneButton.Show();
                        handle.enabled = true;
                    };

                    m_modsPanel                  = m_bg.AddUIComponent <UIPanel>();
                    m_modsPanel.name             = "K45_ModsPanel";
                    m_modsPanel.size             = new Vector2(875, 550);
                    m_modsPanel.relativePosition = new Vector3(0f, 7f);
                    m_modsPanel.isInteractive    = false;
                    m_modsPanel.Hide();

                    m_modPanelButton.eventClicked += TogglePanel;

                    KlyteMonoUtils.CreateTabsComponent(out m_modsTabstrip, out UITabContainer container, m_modsPanel.transform, "K45", new Vector4(52, -8, m_modsPanel.width - 52, 40), new Vector4(0, 32, m_modsPanel.width, m_modsPanel.height));
                    m_modsTabstrip.isInteractive = false;
                    container.isInteractive      = false;
                }
                else
                {
                    m_modPanelButton             = UIView.Find <UIButton>("K45_ModsButton");
                    m_modsTabstrip               = UIView.Find <UITabstrip>("K45_Tabstrip");
                    m_modsTabstrip.isInteractive = false;
                    m_modsTabstrip.tabContainer.isInteractive = false;
                }

                if (m_modPanelButton.color != (UseLowSaturationButton ? Color.gray : Color.white))
                {
                    ApplyButtonColor();
                }

                AddTab();
            }
        }
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.clipChildren        = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 4, 4);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out UITabContainer m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            UIPanel m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_ACE_BASICTAB_BASIC_SETTINGS", "RcSettings");
            UIPanel m_tabAppearence = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_ACE_BASICTAB_APPEARANCE_SETTINGS", "RcAppearence");
            UIPanel m_tabLib        = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Load), "K45_ACE_BASICTAB_LIB_SETTINGS", "RcLib");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperAppearence = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperLib        = new UIHelperExtension(m_tabLib, LayoutDirection.Vertical);


            AddTextField(Locale.Get("K45_ACE_BASICTAB_NAME"), out m_name, helperSettings, OnSetName);
            helperSettings.AddSpace(5);

            AddDropdown(Locale.Get("K45_ACE_BASICTAB_RULEFILTER"), out m_ruleFilter, helperSettings, Enum.GetNames(typeof(RuleCheckTypeVehicle)).Select(x => Locale.Get("K45_ACE_RULECHECKTYPE", x)).ToArray(), OnChangeRuleCheckType);
            AddButtonInEditorRow(m_ruleFilter, CommonsSpriteNames.K45_QuestionMark, Help_RuleFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_SERVICEFILTER"), out m_service, helperSettings, (Enum.GetValues(typeof(ItemClass.Service)) as ItemClass.Service[]).OrderBy(x => (int)x).Select(x => x == 0 ? Locale.Get("K45_ACE_ANYSERVICE_OPTION") : $"{x}").ToArray(), OnChangeServiceFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_SUBSERVICEFILTER"), out m_subService, helperSettings, Enum.GetNames(typeof(ItemClass.SubService)).Select(x => $"{x}").ToArray(), OnChangeSubServiceFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_LEVELFILTER"), out m_level, helperSettings, (Enum.GetValues(typeof(ItemClass.Level)) as ItemClass.Level[]).OrderBy(x => (int)x).Select(x => $"{x}").ToArray(), OnChangeLevelFilter);
            AddDropdown(Locale.Get("K45_ACE_BASICTAB_CLASSFILTER"), out m_class, helperSettings, new string[0], OnChangeClassFilter);
            AddTextField(Locale.Get("K45_ACE_VEHICLERULES_ASSETSELECTSELF"), out m_assetFilterSelf, helperSettings, null);

            KlyteMonoUtils.UiTextFieldDefaultsForm(m_assetFilterSelf);
            m_popupSelf        = ConfigureListSelectionPopupForUITextField(m_assetFilterSelf, (text) => AssetColorExpanderMod.Controller?.AssetsCache.FilterVehiclesByText(text), OnAssetSelectedSelfChanged);
            m_popupSelf.height = 290;
            m_popupSelf.width -= 20;
            AddTextField(Locale.Get("K45_ACE_VEHICLERULES_ASSETSELECTOWNER"), out m_assetFilterOwner, helperSettings, null);

            KlyteMonoUtils.UiTextFieldDefaultsForm(m_assetFilterOwner);
            m_popupOwner        = ConfigureListSelectionPopupForUITextField(m_assetFilterOwner, (text) => AssetColorExpanderMod.Controller?.AssetsCache.FilterBuildingsByText(text), OnAssetSelectedOwnerChanged);
            m_popupOwner.height = 290;
            m_popupOwner.width -= 20;


            ACECommonsUI.GenerateExportButtons(helperSettings, "Vehicle",
                                               out m_exportButtonContainer, out m_exportButton, OnExport,
                                               out m_exportButtonContainerLocal, out m_exportButtonLocal, OnExportLocal);

            AddLibBox <ACEVehcileRuleLib, VehicleCityDataRuleXml>(helperLib, out m_copySettings, OnCopyRule, out m_pasteSettings, OnPasteRule, out _, null, OnLoadRule, GetRuleSerialized);

            AddCheckboxLocale("K45_ACE_VEHICLERULES_ALLOWWAGONWITHDIFFERENTCOLORS", out m_allowWagonDifferentColors, helperAppearence, OnAllowWagonDifferentColors);
            AddCheckboxLocale("K45_ACE_VEHICLERULES_OVERRIDELINEPREFIXCOLOR", out m_overrideLineColor, helperAppearence, OnOverrideLineColorChange);

            AddDropdown(Locale.Get("K45_ACE_COLORMODE"), out m_colorMode, helperAppearence, Enum.GetNames(typeof(ColoringMode)).Select(x => Locale.Get("K45_ACE_COLORINGMODE", x)).ToArray(), OnChangeColoringMode);
            AddButtonInEditorRow(m_colorMode, CommonsSpriteNames.K45_QuestionMark, Help_ColorMode);

            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWREDTONES", out m_allowRed, helperAppearence, OnAllowRedChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWGREENTONES", out m_allowGreen, helperAppearence, OnAllowGreenChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWBLUETONES", out m_allowBlues, helperAppearence, OnAllowBlueChanged);
            AddCheckboxLocale("K45_ACE_COLORMODE_ALLOWNEUTRALTONES", out m_allowNeutral, helperAppearence, OnAllowNeutralChanged);


            KlyteMonoUtils.CreateUIElement(out m_listColorContainer, helperAppearence.Self.transform, "listColors", new UnityEngine.Vector4(0, 0, helperAppearence.Self.width, helperAppearence.Self.height - 120));
            KlyteMonoUtils.CreateScrollPanel(m_listColorContainer, out m_colorListScroll, out _, m_listColorContainer.width - 20, m_listColorContainer.height);
            m_colorListScroll.backgroundSprite    = "OptionsScrollbarTrack";
            m_colorListScroll.autoLayout          = true;
            m_colorListScroll.autoLayoutDirection = LayoutDirection.Horizontal;
            m_colorListScroll.wrapLayout          = true;
            CreateTemplateColorItem();
            m_colorFieldTemplateListColors = new UITemplateList <UIPanel>(m_colorListScroll, COLOR_SELECTOR_TEMPLATE);

            KlyteMonoUtils.InitCircledButton(m_colorListScroll, out m_addColor, CommonsSpriteNames.K45_Plus, (x, y) => AddColor(), "", 36);

            MainContainer.isVisible   = false;
            m_pasteSettings.isVisible = false;
        }
Beispiel #27
0
 public static string GetIconForLine(ushort lineIdx, bool noBorder = true) =>
 KlyteResourceLoader.GetDefaultSpriteNameFor(TLMPrefixesUtils.GetLineIcon(TransportManager.instance.m_lines.m_buffer[lineIdx].m_lineNumber, TransportSystemDefinition.GetDefinitionForLine(lineIdx)), noBorder);
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "TxtSettings");
            m_tabSize       = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MoveCross), "K45_WTS_TEXT_SIZE_ATTRIBUTES", "TxtSize");
            m_tabAppearence = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_TEXT_APPEARANCE_ATTRIBUTES", "TxtApp");
            m_tabConfig     = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_TEXT_CONFIGURATION_ATTRIBUTES", "TxtCnf");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperSize       = new UIHelperExtension(m_tabSize, LayoutDirection.Vertical);
            var helperAppearance = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperConfig     = new UIHelperExtension(m_tabConfig, LayoutDirection.Vertical);

            AddTextField(Locale.Get("K45_WTS_TEXT_TAB_TITLE"), out m_tabName, helperSettings, OnTabNameChanged);

            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_POS"), out m_arrayCoord, helperSize, OnPositionChange);
            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_ROT"), out m_arrayRotation, helperSize, OnRotationChange);
            AddFloatField(Locale.Get("K45_WTS_TEXT_SCALE"), out m_textScale, helperSize, OnScaleSubmit, false);
            AddFloatField(Locale.Get("K45_WTS_MAX_WIDTH_METERS"), out m_maxWidth, helperSize, OnMaxWidthChange, false);
            AddCheckboxLocale("K45_WTS_RESIZE_Y_TEXT_OVERFLOW", out m_applyScaleOnY, helperSize, OnChangeApplyRescaleOnY);
            AddCheckboxLocale("K45_WTS_CREATE_CLONE_180DEG", out m_create180degSimmetricClone, helperSize, OnChangeCreateSimmetricClone);
            AddCheckboxLocale("K45_WTS_CLONE_180DEG_INVERT_TEXT_HOR_ALIGN", out m_invertTextHorizontalAlignClone, helperSize, OnChangeInvertCloneTextHorizontalAlignment);

            //      AddCheckboxLocale("K45_WTS_MIRRORED", out m_mirrored, helperSize, OnChangeMirrored);

            AddDropdown(Locale.Get("K45_WTS_TEXT_ALIGN_HOR"), out m_dropdownTextAlignHorizontal, helperAppearance, ColossalUIExtensions.GetDropdownOptions <UIHorizontalAlignment>("K45_ALIGNMENT"), OnSetTextAlignmentHorizontal);
            helperAppearance.AddSpace(5);
            AddCheckboxLocale("K45_WTS_USE_CONTRAST_COLOR", out m_useContrastColor, helperAppearance, OnContrastColorChange);
            AddColorField(helperAppearance, Locale.Get("K45_WTS_TEXT_COLOR"), out m_textFixedColor, OnFixedColorChanged);
            AddSlider(Locale.Get("K45_WTS_TEXT_DEPTH"), out m_sliderDepth, helperAppearance, OnChangeDepth, -1, 1, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_MATERIALTYPE"), out m_dropdownMaterialType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <MaterialType>("K45_WTS_TEXTMATERIALTYPE"), OnSetMaterialType);
            AddSlider(Locale.Get("K45_WTS_TEXT_ILLUMINATIONSTRENGTH"), out m_sliderIllumination, helperAppearance, OnChangeIlluminationStrength, 0, 10, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_BLINKTYPE"), out m_dropdownBlinkType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <BlinkType>("K45_WTS_BLINKTYPE"), OnSetBlinkType);
            AddVector4Field(Locale.Get("K45_WTS_TEXT_CUSTOMBLINKPARAMS"), out m_arrayCustomBlink, helperAppearance, OnCustomBlinkChange);


            AddEmptyDropdown(Locale.Get("K45_WTS_TEXT_CONTENT"), out m_dropdownTextContent, helperConfig, OnSetTextOwnNameContent);
            AddTextField(Locale.Get("K45_WTS_CUSTOM_TEXT"), out m_customText, helperConfig, OnSetTextCustom);

            IEnumerator OnFilter(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_SPRITE_NAME"), helperConfig, out m_spriteFilter, out UIListBox lb2, OnFilter, OnSpriteNameChanged);
            lb2.size                      = new Vector2(MainContainer.width - 20, 220);
            lb2.processMarkup             = true;
            m_spriteFilter.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb2.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb2.items.Length)
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim();
                }
            };
            lb2.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y;
            WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false;

            AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_DESTINATIONREFERENCE"), out m_destinationRef, helperConfig, ColossalUIExtensions.GetDropdownOptions <DestinationReference>("K45_WTS_ONNETTEXT_DESTINATION_DESC"), OnChangeDestinationRef);
            AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERIDX"), out m_parameterIdx, helperConfig, ColossalUIExtensions.GetDropdownOptionsUnlocalized(new string[BoardInstanceOnNetXml.TEXT_PARAMETERS_COUNT].Select((x, i) => $"#{i}").ToArray()), OnChangeTextParameterIdx);
            AddTextField(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERNAME"), out m_parameterDisplayName, helperConfig, OnSetParameterDisplayName);
            IEnumerator OnFilter2(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERDEFAULTVAL"), helperConfig, out m_defaultParameterValue, out UIListBox lb, OnFilter2, OnChangedDefaultTextParam);
            lb.processMarkup = true;
            lb.size          = new Vector2(MainContainer.width - 20, 220);
            m_defaultParameterValue.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb.items.Length)
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb.items[y].Split('/').Last().Trim();
                }
            };
            lb.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y;
            WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false;

            AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_ITEMDURATIONFRAMES"), out m_slideDurationFrames, helperConfig, OnSetDurationFrames, false);
            AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_DESYNCFRAMES"), out m_slideDesync, helperConfig, OnSetDesyncOffset, false);
            helperConfig.AddSpace(5);
            AddDropdown(Locale.Get("K45_WTS_CLASS_FONT"), out m_fontClassSelect, helperConfig, ColossalUIExtensions.GetDropdownOptions <FontClass>("K45_WTS_FONTCLASS"), OnSetFontClass);
            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_overrideFontSelect, helperConfig, OnSetOverrideFont);
            AddTextField(Locale.Get("K45_WTS_PREFIX"), out m_textPrefix, helperConfig, OnSetPrefix);
            AddTextField(Locale.Get("K45_WTS_SUFFIX"), out m_textSuffix, helperConfig, OnSetSuffix);
            AddCheckboxLocale("K45_WTS_TEXT_ALL_CAPS", out m_allCaps, helperConfig, OnSetAllCaps);
            AddCheckboxLocale("K45_WTS_TEXT_APPLYABBREVIATIONS", out m_applyAbbreviations, helperConfig, OnSetApplyAbbreviations);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS"), out m_arrayRowColumnsCount, helperConfig, OnRowColumnCountChanged, true, true);
            m_arrayRowColumnsCount.ForEach(x => x.allowNegative = false);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS_SPACING"), out m_arrayRowColumnsSpacing, helperConfig, OnRowColumnSpacingChanged);
            AddDropdown(Locale.Get("K45_WTS_VERTICAL_ALIGNMENT"), out m_verticalAlignDD, helperConfig, ColossalUIExtensions.GetDropdownOptions <UIVerticalAlignment>("K45_VERT_ALIGNMENT"), OnSetVerticalAlign);
            AddCheckboxLocale("K45_WTS_TEXT_FILLCOLUMNSFIRST", out m_checkboxVerticalFirst, helperConfig, OnColumnsFirstChanged);

            WTSUtils.ReloadFontsOf(m_overrideFontSelect, null, true, true);

            WTSPropLayoutEditor.Instance.CurrentTabChanged += (newVal) =>
            {
                int targetTab = newVal - 1;
                SafeObtain(OnSetData, targetTab);
                if (WTSPropLayoutEditor.Instance.EditingInstance?.m_configurationSource == ConfigurationSource.CITY)
                {
                    m_tabContainer.Enable();
                }
                else
                {
                    m_tabContainer.Disable();
                }
            };
            m_isEditing = false;


            AddLibBox <WTSLibPropTextItem, BoardTextDescriptorGeneralXml>(helperSettings, out UIButton m_copyButtonText,
                                                                          DoCopyText, out m_pasteButtonText,
                                                                          DoPasteText, out UIButton m_deleteButtonText,
                                                                          DoDeleteText, (loadedItem) => SafeObtain((ref BoardTextDescriptorGeneralXml x) =>
            {
                string name = x.SaveName;
                x           = XmlUtils.DefaultXmlDeserialize <BoardTextDescriptorGeneralXml>(loadedItem);
                x.SaveName  = name;
                OnSetData(ref x);
                x.SaveName = name;
            }),
                                                                          () => XmlUtils.DefaultXmlSerialize(WTSPropLayoutEditor.Instance.EditingInstance.TextDescriptors[Math.Max(0, TabToEdit)]));
        }
        public override Tuple <string, Color, string> GetLineLogoParameters(WTSLine lineObj)
        {
            if (!lineObj.regional)
            {
                Color lineColor = TransportManager.instance.GetLineColor((ushort)lineObj.lineId);
                LineIconSpriteNames lineIcon;
                switch (TransportManager.instance.m_lines.m_buffer[lineObj.lineId].Info.m_transportType)
                {
                case TransportInfo.TransportType.Bus:
                    lineIcon = LineIconSpriteNames.K45_HexagonIcon;
                    break;

                case TransportInfo.TransportType.Trolleybus:
                    lineIcon = LineIconSpriteNames.K45_OvalIcon;
                    break;

                case TransportInfo.TransportType.Helicopter:
                    lineIcon = LineIconSpriteNames.K45_S05StarIcon;
                    break;

                case TransportInfo.TransportType.Metro:
                    lineIcon = LineIconSpriteNames.K45_SquareIcon;
                    break;

                case TransportInfo.TransportType.Train:
                    lineIcon = LineIconSpriteNames.K45_CircleIcon;
                    break;

                case TransportInfo.TransportType.Ship:
                    if (TransportManager.instance.m_lines.m_buffer[lineObj.lineId].Info.m_vehicleType == VehicleInfo.VehicleType.Ferry)
                    {
                        lineIcon = LineIconSpriteNames.K45_S08StarIcon;
                    }
                    else
                    {
                        lineIcon = LineIconSpriteNames.K45_DiamondIcon;
                    }
                    break;

                case TransportInfo.TransportType.Airplane:
                    if (TransportManager.instance.m_lines.m_buffer[lineObj.lineId].Info.m_vehicleType == VehicleInfo.VehicleType.Blimp)
                    {
                        lineIcon = LineIconSpriteNames.K45_ParachuteIcon;
                    }
                    else
                    {
                        lineIcon = LineIconSpriteNames.K45_PentagonIcon;
                    }
                    break;

                case TransportInfo.TransportType.Tram:
                    lineIcon = LineIconSpriteNames.K45_TrapezeIcon;
                    break;

                case TransportInfo.TransportType.EvacuationBus:
                    lineIcon = LineIconSpriteNames.K45_CrossIcon;
                    break;

                case TransportInfo.TransportType.Monorail:
                    lineIcon = LineIconSpriteNames.K45_RoundedSquareIcon;
                    break;

                case TransportInfo.TransportType.Pedestrian:
                    lineIcon = LineIconSpriteNames.K45_MountainIcon;
                    break;

                case TransportInfo.TransportType.TouristBus:
                    lineIcon = LineIconSpriteNames.K45_CameraIcon;
                    break;

                default:
                    lineIcon = LineIconSpriteNames.K45_S05StarIcon;
                    break;
                }

                return(Tuple.New(KlyteResourceLoader.GetDefaultSpriteNameFor(lineIcon), lineColor, TransportManager.instance.m_lines.m_buffer[lineObj.lineId].m_lineNumber.ToString()));
            }
            else
            {
                ref NetNode node = ref NetManager.instance.m_nodes.m_buffer[lineObj.lineId];
                return(Tuple.New(KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_S10StarIcon), Color.gray, lineObj.lineId.ToString("00\n000")));
            }