Beispiel #1
0
        private void CreateSsdTabstrip(ref UITabstrip strip, ref Dictionary <CategoryTab, UITabstrip> substrips, UIPanel titleLine, UIComponent parent, bool buildings = false)
        {
            KlyteMonoUtils.CreateUIElement(out strip, parent.transform, "VMCTabstrip", new Vector4(5, 0, parent.width - 10, 40));

            float effectiveOffsetY = strip.height + (titleLine?.height ?? 0);

            KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, parent.transform, "VMCTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width - 10, parent.height - effectiveOffsetY - 50);

            KlyteMonoUtils.CreateUIElement(out UIPanel bodySuper, null);
            bodySuper.name = "Container";
            bodySuper.area = new Vector4(0, 40, parent.width, parent.height - 50);

            var tabsCategories = new Dictionary <CategoryTab, UIComponent>();

            foreach (CategoryTab catTab in Enum.GetValues(typeof(CategoryTab)).Cast <CategoryTab>())
            {
                GameObject tabCategory     = Instantiate(tabTemplate.gameObject);
                GameObject contentCategory = Instantiate(bodySuper.gameObject);
                UIButton   tabButtonSuper  = tabCategory.GetComponent <UIButton>();
                tabButtonSuper.tooltip           = catTab.getCategoryName();
                tabButtonSuper.normalFgSprite    = catTab.getCategoryIcon();
                tabsCategories[catTab]           = strip.AddTab(catTab.ToString(), tabCategory, contentCategory);
                tabsCategories[catTab].isVisible = false;
                KlyteMonoUtils.CreateUIElement(out UITabstrip subStrip, contentCategory.transform, "VMCTabstripCat" + catTab, new Vector4(5, 0, bodySuper.width - 10, 40));
                KlyteMonoUtils.CreateUIElement(out UITabContainer tabSubContainer, contentCategory.transform, "VMCTabContainer" + catTab, new Vector4(5, effectiveOffsetY, bodySuper.width - 10, bodySuper.height - effectiveOffsetY));
                subStrip.tabPages = tabSubContainer;
                substrips[catTab] = subStrip;
            }
            foreach (KeyValuePair <ServiceSystemDefinition, IVMCSysDef> kv in ServiceSystemDefinition.sysDefinitions)
            {
                if (kv.Value.GetSSD().GetDistrictExtension().GetAllBasicAssets().Count == 0)
                {
                    continue;
                }

                GameObject tab  = Instantiate(tabTemplate.gameObject);
                GameObject body = Instantiate(bodyContent.gameObject);
                string     name = kv.Value.GetType().Name;
                LogUtils.DoLog($"kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = kv.Key.IconServiceSystem;
                string   fgIcon    = kv.Key.FgIconServiceSystem;
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip        = kv.Key.NameForServiceSystem;
                tabButton.normalFgSprite = bgIcon;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UISprite sprite, tabButton.transform, "OverSprite", new Vector4(0, 0, 40, 40));
                    sprite.spriteName = fgIcon;
                }
                Type[] components;
                Type   targetType;
                if (buildings)
                {
                    try
                    {
                        targetType = ReflectionUtils.GetImplementationForGenericType(typeof(VMCTabControllerBuildingList <>), kv.Value.GetType());
                        components = new Type[] { targetType };
                    }
                    catch
                    {
                        continue;
                    }
                }
                else
                {
                    try
                    {
                        targetType = ReflectionUtils.GetImplementationForGenericType(typeof(VMCTabControllerDistrictList <>), kv.Value.GetType());
                        components = new Type[] { targetType };
                    }
                    catch
                    {
                        continue;
                    }
                }
                CategoryTab catTab = kv.Key.Category;
                substrips[catTab].AddTab(name, tab, body, components);

                body.GetComponent <UIComponent>().eventVisibilityChanged += (x, y) =>
                {
                    if (y)
                    {
                        //   m_directionLabel.isVisible = kv.Key.outsideConnection;
                    }
                };
                tabsCategories[catTab].isVisible = 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 #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", "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)]));
        }
Beispiel #4
0
        public void Awake()
        {
            LogUtils.DoLog("AWAKE TLMTicketPriceTimeChart!");
            UIPanel panel = transform.gameObject.AddComponent <UIPanel>();

            panel.width           = 370;
            panel.height          = 70;
            panel.autoLayout      = false;
            panel.useCenter       = true;
            panel.wrapLayout      = false;
            panel.tooltipLocaleID = "K45_TLM_TICKET_PRICE_CLOCK";

            KlyteMonoUtils.CreateUIElement(out m_container, transform, "ClockContainer");
            m_container.relativePosition = new Vector3((panel.width / 2f) - 70, 0);
            m_container.width            = 140;
            m_container.height           = 70;
            m_container.autoLayout       = false;
            m_container.useCenter        = true;
            m_container.wrapLayout       = false;
            m_container.tooltipLocaleID  = "K45_TLM_TICKET_PRICE_CLOCK";

            KlyteMonoUtils.CreateUIElement(out m_clock, m_container.transform, "Clock");
            m_clock.spriteName       = "K45_24hClock";
            m_clock.relativePosition = new Vector3(0, 0);
            m_clock.width            = 70;
            m_clock.height           = 70;

            KlyteMonoUtils.CreateUIElement(out m_minutePointer, m_container.transform, "Minute");
            m_minutePointer.width            = 2;
            m_minutePointer.height           = 27;
            m_minutePointer.pivot            = UIPivotPoint.TopCenter;
            m_minutePointer.relativePosition = new Vector3(35, 35);
            m_minutePointer.spriteName       = "EmptySprite";
            m_minutePointer.color            = new Color32(35, 35, 35, 255);

            KlyteMonoUtils.CreateUIElement(out m_hourPointer, m_container.transform, "Hour");
            m_hourPointer.width            = 3;
            m_hourPointer.height           = 14;
            m_hourPointer.pivot            = UIPivotPoint.TopCenter;
            m_hourPointer.relativePosition = new Vector3(35, 35);
            m_hourPointer.spriteName       = "EmptySprite";
            m_hourPointer.color            = new Color32(5, 5, 5, 255);

            KlyteMonoUtils.CreateUIElement(out UILabel titleEffective, m_container.transform, "TitleEffective");
            titleEffective.width  = 70;
            titleEffective.height = 30;
            KlyteMonoUtils.LimitWidth(titleEffective, 70, true);
            titleEffective.relativePosition = new Vector3(70, 0);
            titleEffective.textScale        = 0.8f;
            titleEffective.color            = Color.white;
            titleEffective.isLocalized      = true;
            titleEffective.localeID         = "K45_TLM_EFFECTIVE_TICKET_PRICE_NOW";
            titleEffective.textAlignment    = UIHorizontalAlignment.Center;

            KlyteMonoUtils.CreateUIElement(out UIPanel effectiveContainer, m_container.transform, "ValueEffectiveContainer");
            effectiveContainer.width            = 70;
            effectiveContainer.height           = 40;
            effectiveContainer.relativePosition = new Vector3(70, 30);
            effectiveContainer.color            = Color.white;
            effectiveContainer.autoLayout       = false;

            KlyteMonoUtils.CreateUIElement(out m_effectiveLabel, effectiveContainer.transform, "BarLabel");
            m_effectiveLabel.width             = 70;
            m_effectiveLabel.height            = 40;
            m_effectiveLabel.relativePosition  = new Vector3(0, 0);
            m_effectiveLabel.color             = Color.white;
            m_effectiveLabel.isLocalized       = false;
            m_effectiveLabel.textAlignment     = UIHorizontalAlignment.Center;
            m_effectiveLabel.verticalAlignment = UIVerticalAlignment.Middle;
            m_effectiveLabel.useOutline        = true;
            m_effectiveLabel.backgroundSprite  = "PlainWhite";
            m_effectiveLabel.padding.top       = 3;
            KlyteMonoUtils.LimitWidth(m_effectiveLabel, 70, true);

            AwakeActionButtons();
        }
Beispiel #5
0
        protected sealed override void OnLevelLoadedInherit(LoadMode mode)
        {
            base.OnLevelLoadedInherit(mode);
            if (LoadUI)
            {
                m_modsPanel = UIView.Find <UIPanel>("K45_ModsPanel");
                if (m_modsPanel == 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;
                }

                AddTab();
            }
        }
        public void Awake()
        {
            m_container                     = GetComponent <UIPanel>();
            m_container.width               = m_container.parent.width;
            m_container.height              = 30;
            m_container.autoLayout          = true;
            m_container.autoLayoutDirection = LayoutDirection.Horizontal;
            m_container.autoLayoutPadding   = new RectOffset(2, 2, 2, 2);
            m_container.wrapLayout          = false;
            m_container.name                = "AzimuthInputLine";

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

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

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

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


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

            DefaultEditorUILib.AddButtonInEditorRow(m_generatedName, CommonsSpriteNames.K45_Reload, () =>
            {
                AdrNeighborhoodExtension.SetSeed(m_id, new Randomizer(new System.Random().Next()).UInt32(0xFEFFFFFF));
                OnRegenerate?.Invoke();
            }, "K45_ADR_REGENERATE_NAME", false, 30);
        }
Beispiel #7
0
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            ushort lineID = GetLineID();

            if (lineID != 0)
            {
                LineType lineType = GetLineType(lineID);
                bool     isTour   = (lineType == LineType.WalkingTour);
                m_mapModeDropDown.isVisible = !isTour;
                m_vehiclesLabel.isVisible   = !isTour && m_currentMode != MapMode.CONNECTIONS;
                m_connectionLabel.isVisible = !isTour || m_currentMode == MapMode.CONNECTIONS;


                if (isTour)
                {
                    m_currentMode = MapMode.CONNECTIONS;
                    m_stopsLabel.relativePosition      = new Vector3(215f, 12f, 0f);
                    m_stopsLineSprite.relativePosition = m_kLineSSpritePositionForWalkingTours;
                    m_actualStopsX = m_kstopsXForWalkingTours;
                }
                else
                {
                    m_stopsLabel.relativePosition      = new Vector3(215f, 12f, 0f);
                    m_stopsLineSprite.relativePosition = m_kLineSSpritePosition;
                    m_actualStopsX = m_kstopsX;
                }
                m_lineStringLabel.text  = TLMLineUtils.GetIconString(lineID);
                m_stopsLineSprite.color = Singleton <TransportManager> .instance.GetLineColor(lineID);

                NetManager instance      = Singleton <NetManager> .instance;
                int        stopsCount    = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].CountStops(lineID);
                float[]    stopPositions = new float[stopsCount];
                m_cachedStopOrder = new ushort[stopsCount];
                float     minDistance  = float.MaxValue;
                float     lineLength   = 0f;
                UIPanel[] stopsButtons = m_stopButtons.SetItemCount(stopsCount);
                ushort    firstStop    = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_stops;
                ushort    currentStop  = firstStop;
                int       idx          = 0;
                while (currentStop != 0 && idx < stopsButtons.Length)
                {
                    stopsButtons[idx].GetComponentInChildren <UIButton>().objectUserData = currentStop;

                    m_cachedStopOrder[idx] = currentStop;
                    UILabel uilabel = stopsButtons[idx].Find <UILabel>("PassengerCount");

                    uilabel.prefix = TLMLineUtils.getFullStationName(currentStop, lineID, TransportSystemDefinition.GetDefinitionForLine(lineID).SubService);
                    uilabel.text   = "";

                    UILabel dist = stopsButtons[idx].Find <UILabel>("Distance");
                    dist.text = "(???)";

                    KlyteMonoUtils.LimitWidth(uilabel, 180, true);


                    CreateConnectionPanel(instance, stopsButtons[idx], currentStop);
                    UIButton button = stopsButtons[idx].GetComponentInChildren <UIButton>();

                    if (uilabel.objectUserData == null)
                    {
                        UITextField stopNameField = stopsButtons[idx].Find <UITextField>("StopNameField");
                        uilabel.eventMouseEnter += (c, r) => uilabel.backgroundSprite = "TextFieldPanelHovered";
                        uilabel.eventMouseLeave += (c, r) => uilabel.backgroundSprite = string.Empty;
                        uilabel.eventClick      += (c, r) =>
                        {
                            uilabel.Hide();
                            stopNameField.Show();
                            stopNameField.text = TLMLineUtils.getStationName((ushort)button.objectUserData, GetLineID(), TransportSystemDefinition.GetDefinitionForLine(GetLineID()).SubService);
                            stopNameField.Focus();
                        };
                        stopNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
                        {
                            stopNameField.Hide();
                            uilabel.Show();
                        };
                        stopNameField.eventTextSubmitted += (x, y) => TLMLineUtils.setStopName(y.Trim(), (ushort)button.objectUserData, GetLineID(), () => uilabel.prefix = $"<color white>{TLMLineUtils.getFullStationName((ushort)button.GetComponentInChildren<UIButton>().objectUserData, GetLineID(), TransportSystemDefinition.GetDefinitionForLine(GetLineID()).SubService)}</color>");
                        uilabel.objectUserData            = true;
                    }
                    for (int i = 0; i < 8; i++)
                    {
                        ushort segmentId = instance.m_nodes.m_buffer[currentStop].GetSegment(i);
                        if (segmentId != 0 && instance.m_segments.m_buffer[segmentId].m_startNode == currentStop)
                        {
                            currentStop = instance.m_segments.m_buffer[segmentId].m_endNode;
                            dist.text   = (instance.m_segments.m_buffer[segmentId].m_averageLength).ToString("0");
                            float segmentSize = m_unscaledMode ? m_kminStopDistance : instance.m_segments.m_buffer[segmentId].m_averageLength;
                            if (segmentSize == 0f)
                            {
                                CODebugBase <LogChannel> .Error(LogChannel.Core, "Two transport line stops have zero distance");

                                segmentSize = 100f;
                            }
                            stopPositions[idx] = segmentSize;
                            if (segmentSize < minDistance)
                            {
                                minDistance = segmentSize;
                            }
                            lineLength += stopPositions[idx];
                            break;
                        }
                    }

                    if (stopsCount > 2 && currentStop == firstStop)
                    {
                        break;
                    }
                    if (stopsCount == 2 && idx > 0)
                    {
                        break;
                    }
                    if (stopsCount == 1)
                    {
                        break;
                    }
                    if (++idx >= 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                float stopDistanceFactor = m_kminStopDistance / minDistance;
                m_uILineLength = stopDistanceFactor * lineLength;
                if (m_uILineLength < m_kminUILineLength)
                {
                    m_uILineLength     = m_kminUILineLength;
                    stopDistanceFactor = m_uILineLength / lineLength;
                }
                else if (m_uILineLength > m_kmaxUILineLength)
                {
                    m_uILineLength     = m_kmaxUILineLength;
                    stopDistanceFactor = m_uILineLength / lineLength;
                }
                if (stopsCount <= 2)
                {
                    m_uILineOffset = (stopDistanceFactor * stopPositions[stopPositions.Length - 1]) - 30f;
                }
                if (m_uILineOffset < 20f || stopsCount > 2)
                {
                    m_uILineOffset = stopDistanceFactor * stopPositions[stopPositions.Length - 1] / 2f;
                }
                m_uILineLength          += 20;
                m_stopsLineSprite.height = m_uILineLength;
                m_stopsContainer.height  = m_uILineLength + m_kvehicleButtonHeight;
                Vector3 relativePosition = m_lineEnd.relativePosition;
                relativePosition.y         = m_uILineLength + 13f;
                relativePosition.x         = m_stopsLineSprite.relativePosition.x + 4f;
                m_lineEnd.relativePosition = relativePosition;
                float num8 = 0f;
                for (int j = 0; j < stopsCount; j++)
                {
                    Vector3 relativePosition2 = m_stopButtons.items[j].relativePosition;
                    relativePosition2.x = m_actualStopsX;
                    relativePosition2.y = ShiftVerticalPosition(num8);
                    m_stopButtons.items[j].relativePosition = relativePosition2;
                    num8 += stopPositions[j] * stopDistanceFactor;
                }
                RefreshVehicleButtons(lineID);
                if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None)
                {
                    m_labelLineIncomplete.isVisible = false;
                    m_stopsContainer.isVisible      = true;
                }
                else
                {
                    m_labelLineIncomplete.isVisible = true;
                    m_stopsContainer.isVisible      = false;
                }
            }
        }
        public void Awake()
        {
            MainContainer = GetComponent <UIPanel>();

            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 2, 2);
            m_uiHelperGlobal = new UIHelperExtension(MainContainer);

            CreateGroupFileSelect("K45_ADR_DISTRICT_GEN_PREFIX_FILE", OnChangeSelectedDistrictPrefix, ReloadDistrictPrefixesFiles, out m_districtPrefixGenFile);
            CreateGroupFileSelect("K45_ADR_DISTRICT_GEN_NAME_FILE", OnChangeSelectedDistrictName, ReloadDistrictNamesFiles, out m_districtNameGenFile);
            isLoading = true;

            AddIntField(Locale.Get("K45_ADR_DISTRICT_POSTAL_CODE"), out m_prefixPostalCodeCity, m_uiHelperGlobal, OnChangePostalCodePrefixCity, false);
            m_prefixPostalCodeCity.maxLength = 3;

            AddTextField(Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_2"), out m_postalCodeFormat, m_uiHelperGlobal, OnChangePostalCodeFormat, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.PostalCodeFormat);
            AddButtonInEditorRow(m_postalCodeFormat, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(new K45DialogControl.BindProperties
            {
                showButton1 = true,
                textButton1 = Locale.Get("EXCEPTION_OK"),
                title       = Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_LEGEND_TITLE"),
                message     = GetPostalCodeLegendText()
            }, (x) => true), null, true, 30);


            AddLabel(Locale.Get("K45_ADR_ADDRESS_LINES"), m_uiHelperGlobal, out _, out _);
            AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE1"), out m_addressLine1Format, m_uiHelperGlobal, OnChangeAddressLine1, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine1);
            AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE2"), out m_addressLine2Format, m_uiHelperGlobal, OnChangeAddressLine2, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine2);
            AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE3"), out m_addressLine3Format, m_uiHelperGlobal, OnChangeAddressLine3, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine3);
            var commonPopupConfigHelpAddress = new K45DialogControl.BindProperties
            {
                showButton1 = true,
                textButton1 = Locale.Get("EXCEPTION_OK"),
                title       = Locale.Get("K45_ADR_ADDRESS_LINES_FORMAT_LEGEND_TITLE"),
                message     = GetAddressLegendText()
            };

            AddButtonInEditorRow(m_addressLine1Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30);
            AddButtonInEditorRow(m_addressLine2Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30);
            AddButtonInEditorRow(m_addressLine3Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30);

            m_uiHelperGlobal.AddSpace(15);

            var nameGenConfig = AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig;

            AdrStationNamesGenerationConfig getGenConfig() => AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig;
            AdrRicoNamesGenerationConfig getRicoGenConfig() => AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig;

            KlyteMonoUtils.CreateUIElement(out UIPanel buildingTogglePanel, m_uiHelperGlobal.Self.transform);
            buildingTogglePanel.width                     = MainContainer.width;
            buildingTogglePanel.autoLayout                = true;
            buildingTogglePanel.autoLayoutPadding         = new RectOffset(2, 2, 2, 2);
            buildingTogglePanel.autoLayoutDirection       = LayoutDirection.Horizontal;
            buildingTogglePanel.autoFitChildrenVertically = true;
            buildingTogglePanel.wrapLayout                = true;

            var buildingTogglePanelHelper = new UIHelperExtension(buildingTogglePanel);

            void AddBuildingCheckbox(string icon, string locale, Action <bool> onChange, Func <bool> getCurrentVal) => AddIconCheckbox(icon, locale, out _, buildingTogglePanelHelper, (x) => { onChange(x); AdrFacade.TriggerBuildingNameStrategyChanged(); }, new Vector2(45, 30), getCurrentVal());

            AddLabel(Locale.Get("K45_ADR_BUILDING_PASSENGERS"), buildingTogglePanelHelper, out UILabel lbl, out _);
            lbl.padding.top    = 5;
            lbl.padding.bottom = 5;
            KlyteMonoUtils.LimitWidthAndBox(lbl, 200, out UIPanel panel);
            panel.maximumSize = new Vector2(210, 0);
            panel.minimumSize = new Vector2(210, 0);
            AddBuildingCheckbox("SubBarPublicTransportBus", "K45_ADR_AUTONAME_BUS_STATIONS", x => getGenConfig().Bus = x, () => getGenConfig().Bus);
            AddBuildingCheckbox("IconPolicyFreePublicTransport", "K45_ADR_AUTONAME_INTERCITYBUS_STATIONS", x => getGenConfig().IntercityBus = x, () => getGenConfig().IntercityBus);
            AddBuildingCheckbox("SubBarPublicTransportTrolleybus", "K45_ADR_AUTONAME_TROLLEYBUS_STATIONS", x => getGenConfig().Trolleybus   = x, () => getGenConfig().Trolleybus);
            AddBuildingCheckbox("SubBarPublicTransportTram", "K45_ADR_AUTONAME_TRAM_STATIONS", x => getGenConfig().Tram = x, () => getGenConfig().Tram);
            AddBuildingCheckbox("SubBarPublicTransportTrain", "K45_ADR_AUTONAME_TRAIN_STATIONS", x => getGenConfig().TrainsPassenger = x, () => getGenConfig().TrainsPassenger);
            AddBuildingCheckbox("SubBarPublicTransportMonorail", "K45_ADR_AUTONAME_MONORAIL_STATIONS", x => getGenConfig().Monorail  = x, () => getGenConfig().Monorail);
            AddBuildingCheckbox("SubBarPublicTransportMetro", "K45_ADR_AUTONAME_METRO_STATIONS", x => getGenConfig().Metro           = x, () => getGenConfig().Metro);
            AddBuildingCheckbox("SubBarPublicTransportCableCar", "K45_ADR_AUTONAME_CABLE_CAR_STATIONS", x => getGenConfig().CableCar = x, () => getGenConfig().CableCar);
            AddBuildingCheckbox("FeatureFerry", "K45_ADR_AUTONAME_FERRY_STATIONS", x => getGenConfig().Ferry = x, () => getGenConfig().Ferry);
            AddBuildingCheckbox("SubBarPublicTransportShip", "K45_ADR_AUTONAME_SHIP_STATIONS", x => getGenConfig().ShipPassenger       = x, () => getGenConfig().ShipPassenger);
            AddBuildingCheckbox("IconPolicyHelicopterPriority", "K45_ADR_AUTONAME_HELICOPTER_STATIONS", x => getGenConfig().Helicopter = x, () => getGenConfig().Helicopter);
            AddBuildingCheckbox("FeatureBlimp", "K45_ADR_AUTONAME_BLIMP_STATIONS", x => getGenConfig().Blimp = x, () => getGenConfig().Blimp);
            AddBuildingCheckbox("SubBarPublicTransportPlane", "K45_ADR_AUTONAME_AIRPLANE_STATIONS", x => getGenConfig().AirplanePassenger = x, () => getGenConfig().AirplanePassenger);

            buildingTogglePanelHelper.AddSpace(5);
            AddLabel(Locale.Get("K45_ADR_BUILDING_CARGO"), buildingTogglePanelHelper, out lbl, out _);
            lbl.padding.top    = 5;
            lbl.padding.bottom = 5;
            KlyteMonoUtils.LimitWidthAndBox(lbl, 260, out panel);
            panel.maximumSize = new Vector2(270, 0);
            panel.minimumSize = new Vector2(270, 0);
            AddBuildingCheckbox("SubBarPublicTransportShip", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_SHIP", x => getGenConfig().ShipCargo          = x, () => getGenConfig().ShipCargo);
            AddBuildingCheckbox("SubBarPublicTransportTrain", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_TRAIN", x => getGenConfig().TrainsCargo      = x, () => getGenConfig().TrainsCargo);
            AddBuildingCheckbox("SubBarPublicTransportPlane", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_AIRPLANE", x => getGenConfig().AirplaneCargo = x, () => getGenConfig().AirplaneCargo);

            buildingTogglePanelHelper.AddSpace(5);
            AddLabel(Locale.Get("K45_ADR_BUILDING_USE_ADDRESS"), buildingTogglePanelHelper, out lbl, out _);
            lbl.padding.top    = 5;
            lbl.padding.bottom = 5;
            KlyteMonoUtils.LimitWidthAndBox(lbl, 260, out panel);
            panel.maximumSize = new Vector2(270, 0);
            panel.minimumSize = new Vector2(270, 0);
            AddBuildingCheckbox("SubBarDistrictSpecializationResidential", "K45_ADR_ENABLE_ADDRESS_NAMING_RES", x => getRicoGenConfig().Residence = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Residence == GenerationMethod.ADDRESS);
            AddBuildingCheckbox("SubBarDistrictSpecializationIndustrial", "K45_ADR_ENABLE_ADDRESS_NAMING_IND", x => getRicoGenConfig().Industry   = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Industry == GenerationMethod.ADDRESS);
            AddBuildingCheckbox("SubBarDistrictSpecializationCommercial", "K45_ADR_ENABLE_ADDRESS_NAMING_COM", x => getRicoGenConfig().Commerce   = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Commerce == GenerationMethod.ADDRESS);
            AddBuildingCheckbox("SubBarDistrictSpecializationOffice", "K45_ADR_ENABLE_ADDRESS_NAMING_OFF", x => getRicoGenConfig().Office         = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Office == GenerationMethod.ADDRESS);
            isLoading = false;
            ReloadDistrictPrefixesFiles();
            ReloadDistrictNamesFiles();
        }
 public static UIButton ConfigureActionButton(UIComponent parent, CommonsSpriteNames sprite, MouseEventHandler onClicked, string tooltipLocale, float size = 40)
 {
     KlyteMonoUtils.InitCircledButton(parent, out UIButton actionButton, sprite, onClicked, tooltipLocale, size);
     return(actionButton);
 }
Beispiel #10
0
        public static void RenderSpriteLine(DynamicFontRenderer renderer, UIMarkupToken token, Vector3 position, UIRenderData destination)
        {
            string[] args = token.GetAttribute(0)?.m_Value?.value?.Split(new char[] { ',' }, 3);
            if (args == null || args.Length != 3)
            {
                LogUtils.DoErrorLog($"INVALID ARGUMENT: {token.GetAttribute(0)?.m_Value?.value ?? "<NULL>"}");
                return;
            }

            UITextureAtlas.SpriteInfo spriteInfo = renderer.spriteAtlas[args[0]];
            if (spriteInfo == null)
            {
                CODebugBase <InternalLogChannel> .Warn(InternalLogChannel.UI, "Missing sprite " + args[0] + " in " + renderer.spriteAtlas.name);
            }
            else
            {
                var midLine = new Vector3(position.x, position.y - (((UIDynamicFont)renderer.font).baseline * renderer.textScale / 2));

                Texture2D texture        = renderer.spriteAtlas.texture;
                float     calcHeight     = ((UIDynamicFont)renderer.font).baseline * renderer.textScale * 2f;
                float     calcProportion = spriteInfo.region.width * texture.width / (spriteInfo.region.height * texture.height);
                float     calcWidth      = Mathf.CeilToInt(calcHeight * calcProportion);

                int height = Mathf.CeilToInt(calcHeight);
                int width  = Mathf.CeilToInt(calcWidth);

                Color32 bgColor        = ColorExtensions.FromRGB(args[1]);
                Color32 color2         = ApplyOpacity(renderer, bgColor);
                var     size           = new Vector3(width, height);
                Vector2 textDimensions = MeasureTextWidth(renderer, args[2], renderer.textScale, out Vector2 yBounds);

                float imageProportions = width / spriteInfo.width;

                float borderWidth = renderer.textScale * 2;

                float textBoundHeight = height - (spriteInfo.border.vertical * imageProportions) - borderWidth;
                float textBoundWidth  = width - (spriteInfo.border.horizontal * imageProportions) - borderWidth;

                var textAreaSize = new Vector4((spriteInfo.border.left * imageProportions) + (borderWidth / 2), (-spriteInfo.border.top + spriteInfo.border.bottom) * imageProportions / 2, textBoundWidth, textBoundHeight);

                float textScale = renderer.textScale;
                float multipler = Mathf.Min(Mathf.Min(3.5f, textAreaSize.z / textDimensions.x), Mathf.Min(3.5f, textAreaSize.w / textDimensions.y));
                if (multipler > 1)
                {
                    textScale     *= 1 + ((multipler - 1) / 2.1f);
                    multipler      = 1;
                    textDimensions = MeasureTextWidth(renderer, args[2], textScale, out yBounds);
                }
                float midLineOffset = (((UIDynamicFont)renderer.font).baseline / 2 * renderer.textScale);

                Color contrastColor = KlyteMonoUtils.ContrastColor(bgColor);

                RenderSprite(renderer.spriteBuffer, new RenderOptions
                {
                    atlas         = renderer.spriteAtlas,
                    color         = contrastColor,
                    fillAmount    = 1f,
                    flip          = UISpriteFlip.None,
                    offset        = position - new Vector3(0, -(height / 2) + midLineOffset),
                    pixelsToUnits = renderer.pixelRatio,
                    size          = size,
                    spriteInfo    = spriteInfo
                });

                RenderSprite(renderer.spriteBuffer, new RenderOptions
                {
                    atlas         = renderer.spriteAtlas,
                    color         = color2,
                    fillAmount    = 1f,
                    flip          = UISpriteFlip.None,
                    offset        = position - new Vector3(0, -(height / 2) + midLineOffset) + (new Vector3(borderWidth, -borderWidth) / 2),
                    pixelsToUnits = renderer.pixelRatio,
                    size          = size - new Vector3(borderWidth, borderWidth),
                    spriteInfo    = spriteInfo
                });
                midLineOffset = ((UIDynamicFont)renderer.font).baseline * textScale;
                Vector3 targetTextPos = midLine + VectorUtils.XY_(textAreaSize) + (new Vector3(textAreaSize.z - (textDimensions.x * multipler), -textDimensions.y) / 2);
                RenderText(renderer, args[2], targetTextPos, multipler, destination, textScale, contrastColor, bgColor);
            }
        }
 public static void AddIntField(string label, out UITextField field, out UILabel labelUI, UIHelperExtension parentHelper, Action <int> onChange, bool acceptNegative)
 {
     field = parentHelper.AddIntField(label, 0, onChange, out labelUI, acceptNegative);
     KlyteMonoUtils.LimitWidthAndBox(field.parent.GetComponentInChildren <UILabel>(), (parentHelper.Self.width / 2) - 10, true);
     field.eventMouseWheel += RollInteger;
 }
 public static void AddColorField(UIHelperExtension helper, string text, out UIColorField m_colorEditor, OnColorChanged onSelectedColorChanged, out UILabel label)
 {
     m_colorEditor = helper.AddColorPicker(text, Color.white, onSelectedColorChanged);
     label         = m_colorEditor.parent.GetComponentInChildren <UILabel>();
     KlyteMonoUtils.LimitWidthAndBox(label, helper.Self.width / 2, true);
 }
Beispiel #13
0
        protected override void AwakeActions()
        {
            controlContainer           = GetComponent <UIPanel>();
            controlContainer.area      = new Vector4(0, 0, 0, 0);
            controlContainer.isVisible = false;
            controlContainer.name      = "VMCPanel";

            KlyteMonoUtils.CreateUIElement(out mainPanel, controlContainer.transform, "VMCListPanel", new Vector4(0, 0, 875, 550));
            mainPanel.backgroundSprite = "MenuPanel2";

            CreateTitleBar();


            //KlyteMonoUtils.CreateUIElement(out m_StripMain, mainPanel.transform, "VMCTabstrip", new Vector4(5, 40, mainPanel.width - 10, 40));

            //KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, mainPanel.transform, "VMCTabContainer", new Vector4(0, 80, mainPanel.width, mainPanel.height - 80));
            //m_StripMain.tabPages = tabContainer;

            //UIButton tabPerBuilding = CreateTabTemplate();
            //tabPerBuilding.normalFgSprite = "ToolbarIconMonuments";
            //tabPerBuilding.tooltip = Locale.Get("K45_VMC_CONFIG_PER_BUILDING_TAB");

            //KlyteMonoUtils.CreateUIElement(out UIPanel contentContainerPerBuilding, null);
            //contentContainerPerBuilding.name = "Container";
            //contentContainerPerBuilding.area = new Vector4(0, 40, mainPanel.width, mainPanel.height - 80);

            //m_StripMain.AddTab("VMCPerBuilding", tabPerBuilding.gameObject, contentContainerPerBuilding.gameObject);
            //CreateTitleRowBuilding(ref m_titleLineBuildings, contentContainerPerBuilding);
            //CreateSsdTabstrip(ref m_StripBuilings, ref m_StripBuilingsStrips, m_titleLineBuildings, contentContainerPerBuilding, true);

            //UIButton tabPerDistrict = CreateTabTemplate();
            //tabPerDistrict.normalFgSprite = "ToolbarIconDistrict";
            //tabPerDistrict.tooltip = Locale.Get("K45_VMC_CONFIG_PER_DISTRICT_TAB");

            KlyteMonoUtils.CreateUIElement(out UIPanel contentContainerPerDistrict, mainPanel.transform);
            contentContainerPerDistrict.name = "Container2";
            contentContainerPerDistrict.area = new Vector4(0, 50, mainPanel.width, mainPanel.height - 50);

            //m_StripMain.AddTab("VMCPerDistrict", tabPerDistrict.gameObject, contentContainerPerDistrict.gameObject);
            CreateSsdTabstrip(ref m_StripDistricts, ref m_StripDistrictsStrips, null, contentContainerPerDistrict);

            m_cachedDistricts = DistrictUtils.GetValidDistricts();

            m_selectDistrict = UIHelperExtension.CloneBasicDropDownLocalized("K45_VMC_DISTRICT_TITLE", m_cachedDistricts.Keys.OrderBy(x => x).ToArray(), OnDistrictSelect, 0, contentContainerPerDistrict);
            UIPanel container = m_selectDistrict.GetComponentInParent <UIPanel>();

            container.autoLayoutDirection         = LayoutDirection.Horizontal;
            container.autoFitChildrenHorizontally = true;
            container.autoFitChildrenVertically   = true;
            container.pivot            = UIPivotPoint.TopRight;
            container.anchor           = UIAnchorStyle.Top | UIAnchorStyle.Right;
            container.relativePosition = new Vector3(contentContainerPerDistrict.width - container.width - 10, 0);
            UILabel label = container.GetComponentInChildren <UILabel>();

            label.padding.top   = 10;
            label.padding.right = 10;

            VehiclesMasterControlMod.Controller.eventOnDistrictChanged += ReloadDistricts;

            //   m_StripMain.selectedIndex = -1;
            //   m_StripBuilings.selectedIndex = -1;
            m_StripDistricts.selectedIndex = -1;

            foreach (UITabstrip strip in m_StripDistrictsStrips.Values)
            {
                strip.selectedIndex = -1;
            }
            //foreach (UITabstrip strip in m_StripBuilingsStrips.Values)
            //{
            //    strip.selectedIndex = -1;
            //}

            mainPanel.eventVisibilityChanged += (x, y) =>
            {
                if (y)
                {
                    VehiclesMasterControlMod.Instance.ShowVersionInfoPopup();
                }
            };
        }
Beispiel #14
0
        protected override void AwakeActions()
        {
            CreateTopButton(MainPanel, "ExportAsDefault", "K45_ER_EXPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Save.ToString(), new Vector2(10, 50), (x, y) => ClassesData.Instance.SaveAsDefault());
            CreateTopButton(MainPanel, "ImportDefault", "K45_ER_IMPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Load.ToString(), new Vector2(95, 50), (x, y) => ClassesData.Instance.LoadDefaults());
            CreateTopButton(MainPanel, "SelectAll", "K45_ER_SELECT_ALL_BTN", "check-checked", new Vector2(180, 50), (x, y) => ClassesData.Instance.SelectAll());
            CreateTopButton(MainPanel, "SelectNone", "K45_ER_SELECT_NONE_BTN", "check-unchecked", new Vector2(265, 50), (x, y) => ClassesData.Instance.UnselectAll());
            CreateTopButton(MainPanel, "Reset", "K45_ER_RESET_BTN", CommonsSpriteNames.K45_Reload.ToString(), new Vector2(350, 50), (x, y) => ClassesData.Instance.SafeCleanAll(m_allClasses.Keys));

            KlyteMonoUtils.CreateScrollPanel(MainPanel, out UIScrollablePanel scrollPanel, out _, MainPanel.width - 25, MainPanel.height - 105, new Vector3(5, 100));
            scrollPanel.autoLayout          = true;
            scrollPanel.autoLayoutDirection = LayoutDirection.Vertical;
            scrollPanel.autoLayoutPadding   = new RectOffset(0, 0, 5, 5);
            scrollPanel.backgroundSprite    = "ScrollbarTrack";
            scrollPanel.scrollPadding       = new RectOffset(5, 5, 5, 5);

            m_allClasses = ((FastList <PrefabCollection <NetInfo> .PrefabData>) typeof(PrefabCollection <NetInfo>).GetField("m_scenePrefabs", RedirectorUtils.allFlags).GetValue(null))
                           .m_buffer
                           .Select(x => x.m_prefab)
                           .Where(x => x?.m_class != null && (x.m_class.m_layer == ItemClass.Layer.Default || x.m_class.m_layer == ItemClass.Layer.MetroTunnels || x.m_class.m_layer == ItemClass.Layer.WaterPipes || x.m_class.m_layer == ItemClass.Layer.WaterStructures))
                           .GroupBy(x => x.m_class.name)
                           .ToDictionary(x => x.First().m_class, x => x.ToList());

            foreach (KeyValuePair <ItemClass, List <NetInfo> > clazz in m_allClasses)
            {
                List <NetInfo> itemList  = clazz.Value;
                ItemClass      clazzKey  = clazz.Key;
                string         className = clazzKey.name;

                KlyteMonoUtils.CreateUIElement(out UIPanel row, scrollPanel.transform, $"{clazz.Key.name}", new Vector4(0, 0, scrollPanel.width, 20));
                row.autoLayout     = true;
                row.padding        = new RectOffset(5, 5, 0, 0);
                row.stringUserData = className;

                UICheckBox uiCheckbox = UIHelperExtension.AddCheckbox(row, $"{clazz.Key.name}", ClassesData.Instance.GetConductibility(clazzKey));
                uiCheckbox.name   = "ClassCheckbox";
                uiCheckbox.height = 20f;
                uiCheckbox.width  = 335f;
                uiCheckbox.label.processMarkup = true;
                uiCheckbox.label.textScale     = 0.8f;
                uiCheckbox.objectUserData      = clazzKey;
                uiCheckbox.eventCheckChanged  += SetItemClassValue;
                KlyteMonoUtils.LimitWidthAndBox(uiCheckbox.label, 325);
                ClassesData.Instance.eventOnValueChanged += (x, y) =>
                {
                    if (x == className && y is bool b)
                    {
                        SetNewValue(uiCheckbox, b);
                    }
                };
                ClassesData.Instance.eventAllChanged += () => SetNewValue(uiCheckbox, ClassesData.Instance.GetConductibility(clazzKey));

                KlyteMonoUtils.CreateUIElement(out UIButton help, row.transform, "?", new Vector4(0, 0, 20, 20));
                help.text             = "?";
                help.hoveredTextColor = Color.blue;
                KlyteMonoUtils.InitButtonFull(help, false, "OptionBase");

                help.eventClicked += (x, y) =>
                {
                    K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                    {
                        icon         = ElectricRoadsMod.Instance.IconName,
                        messageAlign = UIHorizontalAlignment.Left,
                        showButton1  = true,
                        showButton2  = true,
                        showButton3  = true,
                        showClose    = true,
                        textButton1  = Locale.Get("K45_ER_ACTIVATE_CLASS_BTN"),
                        textButton2  = Locale.Get("K45_ER_DEACTIVATE_CLASS_BTN"),
                        textButton3  = Locale.Get("K45_ER_RETURN_BTN"),
                        title        = string.Format(Locale.Get("K45_ER_TITLE_NET_LIST_WINDOW"), className),
                        message      = string.Format(Locale.Get(itemList.Count <= 20 ? "K45_ER_PATTERN_NET_LIST_FEW" : "K45_ER_PATTERN_NET_LIST_FULL"), string.Join("\n", itemList.Take(20).Select(x => $"\t- {x.GetLocalizedTitle()}").ToArray()), itemList.Count - 20)
                    }, (x) =>
                    {
                        if (x == 1)
                        {
                            uiCheckbox.isChecked = true;
                        }
                        else if (x == 2)
                        {
                            uiCheckbox.isChecked = false;
                        }
                        return(true);
                    });
                };
            }
            Quicksort(scrollPanel.components, new Comparison <UIComponent>(CompareNames), false);
        }
Beispiel #15
0
        public void Awake()
        {
            Instance = this;

            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(5, 5, 5, 5);
            MainContainer.clipChildren        = true;


            KlyteMonoUtils.CreateUIElement(out m_topBar, MainContainer.transform, "topBar", new UnityEngine.Vector4(0, 0, MainContainer.width - MainContainer.padding.horizontal, 50));
            m_topBar.autoLayout                = true;
            m_topBar.autoLayoutDirection       = LayoutDirection.Vertical;
            m_topBar.padding                   = new RectOffset(5, 5, 5, 5);
            m_topBar.autoFitChildrenVertically = true;
            var m_topHelper = new UIHelperExtension(m_topBar);

            AddFilterableInput(Locale.Get("K45_WTS_VEHICLEEDITOR_SELECTMODEL"), m_topHelper, out m_vehicleSearch, out _, VehiclesIndexes.instance.BasicInputFiltering, OnVehicleNameSelected);
            AddButtonInEditorRow(m_vehicleSearch, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Dropper, EnableVehiclePicker, null, true, 30);
            AddButtonInEditorRow(m_vehicleSearch, Commons.UI.SpriteNames.CommonsSpriteNames.K45_QuestionMark, Help_VehicleModel, null, true, 30);

            AddLabel("", m_topHelper, out m_labelSelectionDescription, out m_containerSelectionDescription);
            KlyteMonoUtils.LimitWidthAndBox(m_labelSelectionDescription, (m_topHelper.Self.width / 2), out UIPanel containerBoxDescription, true);
            m_labelSelectionDescription.prefix = Locale.Get("K45_WTS_CURRENTSELECTION") + ": ";
            m_btnReload          = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Reload, OnReloadDescriptors, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_RELOADDESCRIPTORS", false);
            m_btnSteam           = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Steam, OnExportAsAsset, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_EXPORTTOASSETFOLDER", false);
            m_btnExport          = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Export, OnExportAsGlobal, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_EXPORTASGLOBAL", false);
            m_btnLoad            = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Load, OnOpenGlobalFolder, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_OPENGLOBALSFOLDER", false);
            m_btnDelete          = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Delete, OnDeleteFromCity, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_DELETEFROMCITY", false);
            m_btnCopyToCity      = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Import, OnCopyToCity, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_COPYTOCITY", false);
            m_btnNew             = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_New, OnCreateNewCity, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_NEWINCITY", false);
            m_btnCopy            = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Copy, OnCopyToClipboard, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_COPYTOCLIPBOARD", false);
            m_btnPaste           = AddButtonInEditorRow(containerBoxDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Paste, OnPasteFromClipboard, "K45_WTS_BUILDINGEDITOR_BUTTONROWACTION_PASTEFROMCLIPBOARD", false);
            m_btnPaste.isVisible = false;


            KlyteMonoUtils.CreateUIElement(out m_middleBar, MainContainer.transform, "previewBar", new Vector4(0, 0, MainContainer.width - MainContainer.padding.horizontal, 300));
            m_middleBar.autoLayout          = true;
            m_middleBar.autoLayoutDirection = LayoutDirection.Horizontal;


            KlyteMonoUtils.CreateUIElement(out UIPanel previewContainer, m_middleBar.transform, "previewContainer", new UnityEngine.Vector4(0, 0, m_middleBar.width * .6f, m_middleBar.height - m_middleBar.padding.vertical));
            Preview = previewContainer.gameObject.AddComponent <WTSVehicleLayoutEditorPreview>();


            KlyteMonoUtils.CreateScrollPanel(m_middleBar, out m_editTabstrip, out _, m_middleBar.width - previewContainer.width - m_middleBar.padding.horizontal - (m_middleBar.autoLayoutPadding.horizontal * 2) - 20, 300);
            m_editTabstrip.autoLayout          = true;
            m_editTabstrip.autoLayoutDirection = LayoutDirection.Vertical;

            InitTabButton(m_editTabstrip, out _, Locale.Get("K45_WTS_BASIC_INFO_TAB_TITLE"), new Vector2(m_editTabstrip.size.x, 30), (x, y) => OnTabChange(x.zOrder));
            KlyteMonoUtils.CreateUIElement(out m_orderedRulesList, m_editTabstrip.transform, "GenTabs", new Vector4(0, 0, m_editTabstrip.width, 0));
            m_orderedRulesList.autoFitChildrenVertically = true;
            m_orderedRulesList.autoLayout          = true;
            m_orderedRulesList.autoLayoutDirection = LayoutDirection.Vertical;
            InitTabButton(m_editTabstrip, out m_plusButton, Locale.Get("K45_WTS_ADD_NEW_TEXT_ENTRY"), new Vector2(m_editTabstrip.size.x, 30), null);
            m_plusButton.eventClicked += AddTabToItem;

            m_tabs = new UITemplateList <UIButton>(m_orderedRulesList, TAB_TEMPLATE_NAME);
            KlyteMonoUtils.CreateUIElement(out m_cantEditText, MainContainer.transform, "text", new UnityEngine.Vector4(0, 0, MainContainer.width - MainContainer.padding.horizontal, 315));
            m_cantEditText.text          = Locale.Get("K45_WTS_VEHICLEEDITOR_CANTEDITTEXT");
            m_cantEditText.textAlignment = UIHorizontalAlignment.Center;
            m_cantEditText.wordWrap      = true;

            KlyteMonoUtils.CreateUIElement(out m_editArea, MainContainer.transform, "editArea", new UnityEngine.Vector4(0, 0, MainContainer.width - MainContainer.padding.horizontal, MainContainer.height - m_middleBar.height - m_topBar.height - MainContainer.padding.vertical - (MainContainer.autoLayoutPadding.vertical * 2) - 5));
            m_editArea.padding = new RectOffset(5, 5, 5, 5);


            KlyteMonoUtils.CreateUIElement(out m_basicInfoEditor, m_editArea.transform, "basicTab", new UnityEngine.Vector4(0, 0, m_editArea.width - m_editArea.padding.horizontal, m_editArea.height - m_editArea.padding.vertical));
            m_basicInfoEditor.gameObject.AddComponent <WTSVehicleLayoutEditorBasics>();
            KlyteMonoUtils.CreateUIElement(out m_textInfoEditor, m_editArea.transform, "textTab", new UnityEngine.Vector4(0, 0, m_editArea.width - m_editArea.padding.horizontal, m_editArea.height - m_editArea.padding.vertical));
            m_textInfoEditor.gameObject.AddComponent <WTSVehicleLayoutEditorTexts>();
            CreateTabTemplate();

            ReloadVehicle();
            OnTabChange(0);
        }
        public void Awake()
        {
            m_isLoading = true;
            if (!(Instance is null))
            {
                Destroy(Instance);
            }
            Instance = this;

            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.clipChildren        = true;

            m_uiHelperNeighbors = new UIHelperExtension(MainContainer);

            AddDropdown(Locale.Get("K45_ADR_REGION_CITIES_FILE"), out m_neighborFileSelect, m_uiHelperNeighbors, new string[0], OnChangeSelectedNeighborFile);
            AddButtonInEditorRow(m_neighborFileSelect, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Reload, ReloadOptionsFilesNeighbor, "K45_ADR_ROAD_NAME_FILES_RELOAD");


            m_uiHelperNeighbors.AddSpace(10);

            KlyteMonoUtils.CreateUIElement(out UIPanel parentContainer, transform, "ParentContainer");
            parentContainer.width  = MainContainer.width - MainContainer.padding.left - MainContainer.padding.right;
            parentContainer.height = MainContainer.height - 70f;
            parentContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            parentContainer.autoLayout          = true;

            KlyteMonoUtils.CreateUIElement(out m_borderChartContainer, parentContainer.transform, "NeighborhoodContainer");
            m_borderChartContainer.width           = (parentContainer.width / 2f);
            m_borderChartContainer.height          = parentContainer.height;
            m_borderChartContainer.autoLayout      = false;
            m_borderChartContainer.useCenter       = true;
            m_borderChartContainer.wrapLayout      = false;
            m_borderChartContainer.tooltipLocaleID = "K45_ADR_CITY_NEIGHBORHOOD";
            m_borderChart = m_borderChartContainer.gameObject.AddComponent <AdrMapBordersChart>();

            //UILabel titleLabel = m_uiHelperNeighbors.AddLabel("");
            //titleLabel.autoSize = true;
            //titleLabel.textAlignment = UIHorizontalAlignment.Center;
            //titleLabel.minimumSize = new Vector2(DefaultWidth, 0);
            //KlyteMonoUtils.LimitWidth(titleLabel, DefaultWidth);
            //titleLabel.localeID = "K45_ADR_AZIMUTH_EDITOR_TITLE";



            KlyteMonoUtils.CreateUIElement(out UIPanel m_neighborEntryListPanel, parentContainer.transform, "NeighborhoodContainer");
            m_neighborEntryListPanel.width               = (parentContainer.width / 2f);
            m_neighborEntryListPanel.height              = parentContainer.height;
            m_neighborEntryListPanel.autoLayout          = true;
            m_neighborEntryListPanel.autoLayoutDirection = LayoutDirection.Vertical;


            KlyteMonoUtils.CreateUIElement(out UIPanel titleItem, m_neighborEntryListPanel.transform, "NeighborhoodContainer");
            titleItem.gameObject.AddComponent <AdrAzimuthTitleLineNeighbor>();

            UIHelperExtension.AddSpace(m_neighborEntryListPanel, 5);
            KlyteMonoUtils.CreateUIElement(out UIPanel listContainer, m_neighborEntryListPanel.transform, "listContainer");
            listContainer.autoLayout          = true;
            listContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            listContainer.width  = m_neighborEntryListPanel.width;
            listContainer.height = m_neighborEntryListPanel.height - 35;

            KlyteMonoUtils.CreateScrollPanel(listContainer, out m_neighborsList, out _, listContainer.width - 17.5f, listContainer.height);
            m_isLoading = false;
            ReloadOptionsFilesNeighbor();
        }
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            TransportSystemDefinition tsd = TransportSystem;

            if (!tsd.HasVehicles())
            {
                MainPanel.isVisible = false;
                return;
            }
            m_isLoading = true;
            LogUtils.DoLog("tsd = {0}", tsd);
            IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(GetLineID());

            if (TransportSystem != m_lastSystem)
            {
                m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssetsForLine(0);
                UIPanel[] depotChecks = m_checkboxTemplateList.SetItemCount(m_defaultAssets.Count);

                LogUtils.DoLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
                for (int i = 0; i < m_defaultAssets.Count; i++)
                {
                    string     assetName = m_defaultAssets.Keys.ElementAt(i);
                    UICheckBox checkbox  = depotChecks[i].GetComponentInChildren <UICheckBox>();
                    checkbox.objectUserData = assetName;
                    UITextField capacityEditor = depotChecks[i].GetComponentInChildren <UITextField>();
                    capacityEditor.text = VehicleUtils.GetCapacity(PrefabCollection <VehicleInfo> .FindLoaded(assetName)).ToString("0");
                    if (checkbox.label.objectUserData == null)
                    {
                        checkbox.eventCheckChanged += (x, y) =>
                        {
                            if (m_isLoading)
                            {
                                return;
                            }

                            ushort          lineId    = GetLineID();
                            IBasicExtension extension = TLMLineUtils.GetEffectiveExtensionForLine(lineId);

                            LogUtils.DoLog($"checkbox event: {x.objectUserData} => {y} at {extension}[{lineId}]");
                            if (y)
                            {
                                extension.AddAssetToLine(lineId, x.objectUserData.ToString());
                            }
                            else
                            {
                                extension.RemoveAssetFromLine(lineId, x.objectUserData.ToString());
                            }
                        };
                        CreateModelCheckBox(checkbox);
                        KlyteMonoUtils.LimitWidthAndBox(checkbox.label, 280);
                        capacityEditor.eventTextSubmitted += CapacityEditor_eventTextSubmitted;;

                        capacityEditor.eventMouseEnter += (x, y) =>
                        {
                            m_lastInfo = PrefabCollection <VehicleInfo> .FindLoaded(checkbox.objectUserData.ToString());

                            RedrawModel();
                        };
                        checkbox.label.objectUserData = true;
                    }
                    checkbox.text = m_defaultAssets[assetName];
                }
                m_lastSystem = TransportSystem;
            }
            else
            {
                List <string> allowedAssets = config.GetAssetListForLine(GetLineID());
                for (int i = 0; i < m_checkboxTemplateList.items.Count; i++)
                {
                    UICheckBox checkbox = m_checkboxTemplateList.items[i].GetComponentInChildren <UICheckBox>();
                    checkbox.isChecked = allowedAssets.Contains(checkbox.objectUserData.ToString());
                }
            }

            if (TransportLinesManagerMod.DebugMode)
            {
                List <string> allowedAssets = config.GetAssetListForLine(GetLineID());
                LogUtils.DoLog($"selectedAssets Size = {allowedAssets?.Count} ({ string.Join(",", allowedAssets?.ToArray() ?? new string[0])}) {config?.GetType()}");
            }

            if (config is TLMTransportLineConfiguration)
            {
                m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE"), TLMLineUtils.GetLineStringId(GetLineID()));
            }
            else
            {
                int prefix = (int)TLMPrefixesUtils.GetPrefix(GetLineID());
                m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? NumberingUtils.GetStringFromNumber(TLMPrefixesUtils.GetStringOptionsForPrefix(tsd), prefix + 1) : Locale.Get("K45_TLM_UNPREFIXED"), tsd.GetTransportName());
            }

            m_isLoading = false;
        }
Beispiel #18
0
        private static void AddNewStopTemplate()
        {
            var     go    = new GameObject();
            UIPanel panel = go.AddComponent <UIPanel>();

            panel.size = new Vector2(36, 36);
            UIButton button = UITemplateManager.Get <UIButton>("StopButton");

            panel.AttachUIComponent(button.gameObject).transform.localScale = Vector3.one;
            button.relativePosition   = Vector2.zero;
            button.name               = "StopButton";
            button.scaleFactor        = 1f;
            button.spritePadding.top  = 2;
            button.isTooltipLocalized = true;
            KlyteMonoUtils.InitButtonFg(button, false, "DistrictOptionBrushMedium");
            KlyteMonoUtils.InitButtonSameSprite(button, "");

            UILabel uilabel = button.Find <UILabel>("PassengerCount");

            panel.AttachUIComponent(uilabel.gameObject).transform.localScale = Vector3.one;
            uilabel.relativePosition  = new Vector3(38, 12);
            uilabel.processMarkup     = true;
            uilabel.isVisible         = true;
            uilabel.minimumSize       = new Vector2(175, 50);
            uilabel.verticalAlignment = UIVerticalAlignment.Middle;
            KlyteMonoUtils.LimitWidthAndBox(uilabel, 175, true);


            UIPanel connectionPanel = panel.AddUIComponent <UIPanel>();

            connectionPanel.name                = "ConnectionPanel";
            connectionPanel.relativePosition    = new Vector3(-50, 5);
            connectionPanel.size                = new Vector3(50, 40);
            connectionPanel.autoLayout          = true;
            connectionPanel.wrapLayout          = true;
            connectionPanel.autoLayoutDirection = LayoutDirection.Vertical;
            connectionPanel.autoLayoutStart     = LayoutStart.TopRight;


            UILabel distLabel = panel.AddUIComponent <UILabel>();

            distLabel.name             = "Distance";
            distLabel.relativePosition = new Vector3(-12, 37);
            distLabel.textAlignment    = UIHorizontalAlignment.Center;
            distLabel.textScale        = 0.65f;
            distLabel.suffix           = "m";
            distLabel.useOutline       = true;
            distLabel.minimumSize      = new Vector2(60, 0);
            distLabel.outlineColor     = Color.black;

            KlyteMonoUtils.CreateUIElement(out UITextField lineNameField, panel.transform, "StopNameField", new Vector4(38, -6, 175, 50));
            lineNameField.maxLength            = 256;
            lineNameField.isVisible            = false;
            lineNameField.verticalAlignment    = UIVerticalAlignment.Middle;
            lineNameField.horizontalAlignment  = UIHorizontalAlignment.Left;
            lineNameField.selectionSprite      = "EmptySprite";
            lineNameField.builtinKeyNavigation = true;
            lineNameField.textScale            = uilabel.textScale;
            lineNameField.padding.top          = 18;
            lineNameField.padding.left         = 5;
            lineNameField.padding.bottom       = 14;
            KlyteMonoUtils.InitButtonFull(lineNameField, false, "TextFieldPanel");


            TLMUiTemplateUtils.GetTemplateDict()["StopButtonPanel"] = panel;
        }
Beispiel #19
0
 public override void LoadSettings() => m_redirector = KlyteMonoUtils.CreateElement <Redirector>(null, "VCE");
        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 #21
0
        private void createInfoView()
        {
            //line info painel

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



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

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

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

            KlyteMonoUtils.CreateUIElement(out vehiclesInUseLabel, m_buildingInfoPanel.transform);
            vehiclesInUseLabel.autoSize         = false;
            vehiclesInUseLabel.relativePosition = new Vector3(10f, 60f);
            vehiclesInUseLabel.textAlignment    = UIHorizontalAlignment.Left;
            vehiclesInUseLabel.text             = "";
            vehiclesInUseLabel.width            = 550;
            vehiclesInUseLabel.height           = 25;
            vehiclesInUseLabel.name             = "VehiclesInUseLabel";
            vehiclesInUseLabel.textScale        = 0.8f;
            vehiclesInUseLabel.prefix           = Locale.Get("K45_VMC_VEHICLE_CAPACITY_LABEL") + ": ";

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

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

            workerChart = new TLMWorkerChartPanel(panelTransform, new Vector3(400f, 90f));
            m_uiHelper  = new UIHelperExtension(m_buildingInfoPanel);
        }
Beispiel #22
0
        public void Awake()
        {
            MainContainer    = GetComponent <UIComponent>();
            m_uiHelperGlobal = new UIHelperExtension(MainContainer);

            ((UIScrollablePanel)m_uiHelperGlobal.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIScrollablePanel)m_uiHelperGlobal.Self).wrapLayout          = true;
            ((UIScrollablePanel)m_uiHelperGlobal.Self).width = 370;

            m_districtPrefixGenFile       = m_uiHelperGlobal.AddDropdownLocalized("K45_ADR_DISTRICT_GEN_PREFIX_FILE", new string[0], -1, OnChangeSelectedDistrictPrefix);
            m_districtPrefixGenFile.width = 370;
            m_uiHelperGlobal.AddSpace(1);
            KlyteMonoUtils.LimitWidth((UIButton)m_uiHelperGlobal.AddButton(Locale.Get("K45_ADR_DISTRICT_GEN_PREFIX_FILES_RELOAD"), ReloadDistrictPrefixesFiles), 380);
            m_uiHelperGlobal.AddSpace(20);

            m_districtNameGenFile       = m_uiHelperGlobal.AddDropdownLocalized("K45_ADR_DISTRICT_GEN_NAME_FILE", new string[0], -1, OnChangeSelectedDistrictName);
            m_districtNameGenFile.width = 370;
            m_uiHelperGlobal.AddSpace(1);
            KlyteMonoUtils.LimitWidth((UIButton)m_uiHelperGlobal.AddButton(Locale.Get("K45_ADR_DISTRICT_GEN_NAME_FILES_RELOAD"), ReloadDistrictNamesFiles), 380);
            m_uiHelperGlobal.AddSpace(20);

            ReloadDistrictPrefixesFiles();
            ReloadDistrictNamesFiles();

            m_prefixPostalCodeCity = m_uiHelperGlobal.AddTextField(Locale.Get("K45_ADR_CITY_POSTAL_CODE"), null, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.ZipcodeCityPrefix.ToString("D3"), OnChangePostalCodePrefixCity);
            m_prefixPostalCodeCity.numericalOnly = true;
            m_prefixPostalCodeCity.maxLength     = 3;

            m_postalCodeFormat = m_uiHelperGlobal.AddTextField(Locale.Get("K45_ADR_POSTAL_CODE_FORMAT"), null, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.ZipcodeFormat, OnChangePostalCodeFormat);
            m_prefixPostalCodeCity.maxLength = 3;

            string[] formatExplain = new string[12];
            for (int i = 0; i < formatExplain.Length; i++)
            {
                formatExplain[i] = Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_LEGEND", i);
            }

            KlyteMonoUtils.CreateUIElement(out UILabel formatExplanation, m_uiHelperGlobal.Self.transform, "FormatText");
            formatExplanation.wordWrap   = true;
            formatExplanation.textScale  = 0.65f;
            formatExplanation.textColor  = Color.yellow;
            formatExplanation.autoSize   = false;
            formatExplanation.autoHeight = true;
            formatExplanation.width      = 370;

            string[] obs = new string[2];
            for (int i = 0; i < obs.Length; i++)
            {
                obs[i] = Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_OBSERVATION", i);
            }

            KlyteMonoUtils.CreateUIElement(out UILabel obsExplanation, m_uiHelperGlobal.Self.transform, "ObsText");
            obsExplanation.wordWrap   = true;
            obsExplanation.textScale  = 0.65f;
            obsExplanation.textColor  = Color.gray;
            obsExplanation.autoSize   = false;
            obsExplanation.autoHeight = true;
            obsExplanation.width      = 370;


            formatExplanation.text = "∙ " + string.Join(Environment.NewLine + "∙ ", formatExplain);
            obsExplanation.text    = string.Join(Environment.NewLine, obs);

            m_uiHelperGlobal.AddSpace(20);
            m_uiHelperGlobal.AddLabel(Locale.Get("K45_ADR_ADDRESS_LINES"));
            m_addressLine1Format = m_uiHelperGlobal.AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE1"), null, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine1, OnChangeAddressLine1);
            m_addressLine2Format = m_uiHelperGlobal.AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE2"), null, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine2, OnChangeAddressLine2);
            m_addressLine3Format = m_uiHelperGlobal.AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE3"), null, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine3, OnChangeAddressLine3);
            string[] formatExplainAddress = new string[6];
            for (int i = 0; i < formatExplainAddress.Length; i++)
            {
                formatExplainAddress[i] = Locale.Get("K45_ADR_ADDRESS_FORMAT_LEGEND", i);
            }

            KlyteMonoUtils.CreateUIElement(out UILabel formatExplainAddressLabel, m_uiHelperGlobal.Self.transform, "FormatText");
            formatExplainAddressLabel.wordWrap   = true;
            formatExplainAddressLabel.textScale  = 0.65f;
            formatExplainAddressLabel.textColor  = Color.yellow;
            formatExplainAddressLabel.autoSize   = false;
            formatExplainAddressLabel.autoHeight = true;
            formatExplainAddressLabel.width      = 370;

            formatExplainAddressLabel.text = "∙ " + string.Join(Environment.NewLine + "∙ ", formatExplainAddress);


            m_uiHelperGlobal.AddSpace(20);
            m_uiHelperGlobal.AddLabel(Locale.Get("K45_ADR_BUILDING_CONFIGURATIONS"));

            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_TRAIN_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.TrainsPassenger, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.TrainsPassenger = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_MONORAIL_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Monorail, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Monorail = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_METRO_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Metro, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Metro = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_CABLE_CAR_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.CableCar, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.CableCar = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_FERRY_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Ferry, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Ferry = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_SHIP_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.ShipPassenger, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.ShipPassenger = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_BLIMP_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Blimp, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.Blimp = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_AUTONAME_AIRPLANE_STATIONS", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.AirplanePassenger, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.AirplanePassenger = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });

            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_SHIP", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.ShipCargo, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.ShipCargo = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_TRAIN", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.TrainsCargo, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.TrainsCargo = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_AIRPLANE", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.AirplaneCargo, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig.AirplaneCargo = x; AdrEvents.TriggerBuildingNameStrategyChanged(); });



            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_ADDRESS_NAMING_RES", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Residence == GenerationMethod.ADDRESS, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Residence = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_ADDRESS_NAMING_IND", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Industry == GenerationMethod.ADDRESS, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Industry = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_ADDRESS_NAMING_COM", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Commerce == GenerationMethod.ADDRESS, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Commerce = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE; AdrEvents.TriggerBuildingNameStrategyChanged(); });
            m_uiHelperGlobal.AddCheckboxLocale("K45_ADR_ENABLE_ADDRESS_NAMING_OFF", AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Office == GenerationMethod.ADDRESS, (x) => { AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Office = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE; AdrEvents.TriggerBuildingNameStrategyChanged(); });
        }
        public void Awake()
        {
            Instance = this;

            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.autoLayoutPadding   = new RectOffset(5, 5, 5, 5);
            MainContainer.width               = MainContainer.parent.width;
            MainContainer.clipChildren        = true;

            var mainContainerHelper = new UIHelperExtension(MainContainer);


            AddFilterableInput("AAAA", mainContainerHelper, out m_configList, out _, OnFilterLayouts, OnConfigSelectionChange);
            m_configList.width += m_configList.parent.GetComponentInChildren <UILabel>().width;
            GameObject.Destroy(m_configList.parent.GetComponentInChildren <UILabel>());
            m_configList.tooltipLocaleID = "K45_ADR_TOOLTIP_LAYOUTSELECTOR";
            AddLabel("", mainContainerHelper, out m_scopeInfo, out _);
            m_scopeInfo.processMarkup = true;

            m_deleteButton = AddButtonInEditorRow(m_configList, CommonsSpriteNames.K45_Delete, OnDeleteConfig, "K45_ADR_DELETE_SELECTED_CONFIG", true, 30);
            m_importButton = AddButtonInEditorRow(m_configList, CommonsSpriteNames.K45_Import, OnImportIntoCity, "K45_ADR_IMPORTINTOCITY_CONFIG", false, 30);
            m_exportButton = AddButtonInEditorRow(m_configList, CommonsSpriteNames.K45_Export, OnExportAsGlobal, "K45_ADR_EXPORTASGLOBAL_CONFIG", true, 30);
            AddButtonInEditorRow(m_configList, CommonsSpriteNames.K45_New, ShowNewConfigModal, "K45_ADR_CREATE_NEW_CONFIG", true, 30);
            AddButtonInEditorRow(m_configList, CommonsSpriteNames.K45_Reload, OnRefresh, "K45_ADR_RELOADFILES", true, 30);

            m_importButton.color = Color.green;
            m_deleteButton.color = Color.red;
            m_exportButton.color = Color.cyan;

            KlyteMonoUtils.CreateUIElement(out m_editArea, MainContainer.transform, "editArea", new UnityEngine.Vector4(0, 0, MainContainer.width - MainContainer.padding.horizontal, MainContainer.height - 80 - MainContainer.padding.vertical - (MainContainer.autoLayoutPadding.vertical * 2) - 5));
            m_editArea.padding             = new RectOffset(5, 5, 5, 5);
            m_editArea.autoLayout          = true;
            m_editArea.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);
            m_editArea.autoLayoutDirection = LayoutDirection.Vertical;

            var editAreaHelper = new UIHelperExtension(m_editArea);

            AddTextField(Locale.Get("K45_ADR_HW_DETTACHEDPREFIX"), out m_dettachedPrefix, out UILabel dettachedLbl, editAreaHelper, OnEditDettachedPrefix);
            AddTextField(Locale.Get("K45_ADR_HW_SHORTPREFIX"), out m_shortPrefix, out UILabel shortLbl, editAreaHelper, OnEditShortPrefix);
            AddCheckboxLocale("K45_ADR_HW_SHORTINVERT", out m_shortInvert, editAreaHelper, OnSetInvertConcatenateShort);
            AddCheckboxLocale("K45_ADR_HW_SHORTADDSPACE", out m_shortAddSpace, editAreaHelper, OnSetSpaceShort);
            AddTextField(Locale.Get("K45_ADR_HW_FULLPREFIX"), out m_fullPrefix, out UILabel longLbl, editAreaHelper, OnEditLongPrefix);
            AddCheckboxLocale("K45_ADR_HW_FULLINVERT", out m_fullInvert, editAreaHelper, OnSetInvertConcatenateLong);
            AddCheckboxLocale("K45_ADR_HW_FULLADDSPACE", out m_fullAddSpace, editAreaHelper, OnSetSpaceLong);

            AddLabel(Locale.Get("K45_ADR_HW_EXAMPLETITLE"), editAreaHelper, out UILabel exampleTitle, out _, true);
            AddLabel("Example", editAreaHelper, out m_exampleShort, out _, false);
            AddLabel("Example", editAreaHelper, out m_exampleLong, out _, false);
            m_exampleShort.textAlignment = UIHorizontalAlignment.Center;
            m_exampleLong.textAlignment  = UIHorizontalAlignment.Center;
            m_exampleShort.textScale     = 3f;
            m_exampleLong.textScale      = 3f;
            m_exampleShort.processMarkup = true;
            m_exampleLong.processMarkup  = true;
            exampleTitle.processMarkup   = true;
            shortLbl.processMarkup       = true;
            longLbl.processMarkup        = true;
            dettachedLbl.processMarkup   = true;

            OnConfigSelectionChange("", -1, new string[0]);
        }
Beispiel #24
0
        protected void CreateTitleRow(out UIPanel titleLine, UIComponent parent)
        {
            LogUtils.DoLog("Creating Title Row ");
            KlyteMonoUtils.CreateUIElement(out titleLine, parent.transform, "TLMtitleline", new Vector4(5, 0, parent.width - 10, 40));
            titleLine.padding  = new RectOffset(0, 0, 50, 0);
            m_createdTitleLine = titleLine;

            KlyteMonoUtils.CreateUIElement(out UILabel codColor, titleLine.transform, "codColor");
            codColor.minimumSize = new Vector2(60, 0);
            codColor.area        = new Vector4(80, 10, codColor.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(codColor, (uint)codColor.width);
            codColor.textAlignment = UIHorizontalAlignment.Center;
            codColor.prefix        = Locale.Get("PUBLICTRANSPORT_LINECOLOR");
            codColor.text          = "/";
            codColor.suffix        = Locale.Get("K45_TLM_CODE_SHORT");
            codColor.eventClicked += CodColor_eventClicked;

            KlyteMonoUtils.CreateUIElement(out UILabel lineName, titleLine.transform, "lineName");
            lineName.minimumSize = new Vector2(200, 0);
            lineName.area        = new Vector4(140, 10, lineName.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(lineName, (uint)lineName.width);
            lineName.textAlignment = UIHorizontalAlignment.Center;
            lineName.text          = Locale.Get("PUBLICTRANSPORT_LINENAME");
            lineName.eventClicked += LineName_eventClicked;

            KlyteMonoUtils.CreateUIElement(out UILabel stops, titleLine.transform, "stops");
            stops.minimumSize = new Vector2(80, 0);
            stops.area        = new Vector4(340, 10, stops.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(stops, (uint)stops.width);
            stops.textAlignment = UIHorizontalAlignment.Center;
            stops.text          = Locale.Get("PUBLICTRANSPORT_LINESTOPS");
            stops.eventClicked += Stops_eventClicked;

            KlyteMonoUtils.CreateUIElement(out UILabel vehicles, titleLine.transform, "vehicles");
            vehicles.minimumSize = new Vector2(110, 0);
            vehicles.area        = new Vector4(430, 10, vehicles.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(vehicles, (uint)vehicles.width);
            vehicles.textAlignment = UIHorizontalAlignment.Center;
            vehicles.text          = Locale.Get("PUBLICTRANSPORT_VEHICLES");
            vehicles.eventClicked += Vehicles_eventClicked;

            KlyteMonoUtils.CreateUIElement(out UILabel passengers, titleLine.transform, "passengers");
            passengers.minimumSize = new Vector2(80, 0);
            passengers.area        = new Vector4(540, 10, passengers.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(passengers, (uint)passengers.width);
            passengers.textAlignment = UIHorizontalAlignment.Center;
            passengers.text          = Locale.Get("PUBLICTRANSPORT_PASSENGERS");
            passengers.eventClicked += Passengers_eventClicked;

            KlyteMonoUtils.CreateUIElement(out UILabel profitLW, titleLine.transform, "profit");
            profitLW.minimumSize = new Vector2(150, 0);
            profitLW.area        = new Vector4(625, 10, profitLW.minimumSize.x, 18);
            KlyteMonoUtils.LimitWidthAndBox(profitLW, (uint)profitLW.width);
            profitLW.textAlignment = UIHorizontalAlignment.Center;
            profitLW.text          = Locale.Get(TLMController.IsRealTimeEnabled ? "K45_TLM_BALANCE_LAST_HOUR_HALF" : "K45_TLM_BALANCE_LAST_WEEK");
            profitLW.eventClicked += Profit_eventClicked;

            AwakeShowLineButton();

            LogUtils.DoLog("End creating Title Row ");
        }
Beispiel #25
0
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            TransportSystemDefinition tsd = TransportSystem;

            if (!tsd.HasVehicles())
            {
                MainPanel.isVisible = false;
                return;
            }
            m_isLoading = true;

            var           lineId        = GetLineID();
            List <ushort> cityDepotList = TLMDepotUtils.GetAllDepotsFromCity(tsd);

            Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            List <ushort> targetDepotList     = config.GetAllowedDepots(tsd, lineId);

            UIPanel[] depotChecks = m_checkboxTemplateList.SetItemCount(cityDepotList.Count);
            LogUtils.DoLog($"depotChecks = {depotChecks.Length}");
            for (int idx = 0; idx < cityDepotList.Count; idx++)
            {
                ushort     buildingID = cityDepotList[idx];
                UICheckBox uiCheck    = depotChecks[idx].GetComponentInChildren <UICheckBox>();
                uiCheck.objectUserData = buildingID;
                uiCheck.isChecked      = targetDepotList.Contains(buildingID);

                UILabel uilabel = uiCheck.label;

                uilabel.prefix = BuildingUtils.GetBuildingName(buildingID, out _, out _);
                ref Building depotBuilding = ref BuildingManager.instance.m_buildings.m_buffer[buildingID];
                Vector3      sidewalk      = depotBuilding.CalculateSidewalkPosition();
                TransportLinesManagerMod.Controller.ConnectorADR.GetAddressStreetAndNumber(sidewalk, depotBuilding.m_position, out int number, out string streetName);
                byte districtId = DistrictManager.instance.GetDistrict(sidewalk);
                uilabel.text = $"\n<color gray>{streetName}, {number} - {(districtId == 0 ? SimulationManager.instance.m_metaData.m_CityName : DistrictManager.instance.GetDistrictName(districtId))}</color>";



                if (uilabel.objectUserData == null)
                {
                    uiCheck.eventCheckChanged += (x, y) =>
                    {
                        if (!m_isLoading)
                        {
                            if (y)
                            {
                                TLMLineUtils.GetEffectiveExtensionForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).AddDepotForLine(UVMPublicTransportWorldInfoPanel.GetLineID(), (ushort)x.objectUserData);
                            }
                            else
                            {
                                TLMLineUtils.GetEffectiveExtensionForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).RemoveDepotForLine(UVMPublicTransportWorldInfoPanel.GetLineID(), (ushort)x.objectUserData);
                            }
                        }
                    };
                    KlyteMonoUtils.LimitWidthAndBox(uiCheck.label, 280, true);
                    UIButton gotoButton = depotChecks[idx].Find <UIButton>("GoTo");
                    gotoButton.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
                    {
                        ushort buildingId = (ushort)uiCheck.objectUserData;
                        if (buildingId != 0)
                        {
                            Vector3 position = BuildingManager.instance.m_buildings.m_buffer[buildingId].m_position;
                            ToolsModifierControl.cameraController.SetTarget(new InstanceID()
                            {
                                Building = buildingId
                            }, position, true);
                        }
                    };
                    uilabel.objectUserData = true;
                }
            }
Beispiel #26
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();
        }
        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)]));
        }