private static void ErrorPatchingHandler(string logString, string stackTrace, LogType type)
 {
     if (type == LogType.Exception)
     {
         K45DialogControl.ShowModal(new K45DialogControl.BindProperties
         {
             title   = "AN ERROR HAS OCCURRED!",
             message = $"An error happened while trying to patch all code needed to make the <color yellow>{CommonProperties.ModName}</color> work properly. Check output_log.txt file to see details." +
                       (CommonProperties.GitHubRepoPath.IsNullOrWhiteSpace() ? "" : "\nPlease open a issue in GitHub with the output file attached on it to help to fix this problem. Thanks!") +
                       $"\n\n<color #FF00FF>{logString}</color>\n{stackTrace}",
             showButton1        = true,
             showButton2        = true,
             showButton3        = !CommonProperties.GitHubRepoPath.IsNullOrWhiteSpace(),
             textButton1        = "OK",
             textButton2        = "Go to output_log.txt file (WIN)",
             textButton3        = "GitHub: open an issue to fix this",
             useFullWindowWidth = true
         }, (x) =>
         {
             if (x == 2)
             {
                 ColossalFramework.Utils.OpenInFileBrowser("Cities_Data/output_log.txt");
                 return(false);
             }
             if (x == 3)
             {
                 FileSystemUtils.OpenURLInOverlayOrBrowser($"https://github.com/{CommonProperties.GitHubRepoPath}/issues/new");
                 return(false);
             }
             return(true);
         });
         LogUtils.DoErrorLog($"{logString}\n{stackTrace}");
     }
 }
        protected static LIB LoadInstance()
        {
            var newVal = new LIB();

            return(File.Exists(newVal.DefaultXmlFileBaseFullPath)
                ? XmlUtils.DefaultXmlDeserialize <LIB>(File.ReadAllText(newVal.DefaultXmlFileBaseFullPath), (x, y) =>
            {
                K45DialogControl.ShowModal(new K45DialogControl.BindProperties
                {
                    title = Locale.Get("K45_CMNS_LIB_ANERROROCURREDWHILELOADING_TITLE"),
                    message = string.Format(Locale.Get("K45_CMNS_LIB_ANERROROCURREDWHILELOADING_MESSAGE"), newVal.XmlName, y?.Message ?? "InvalidSyntax"),
                    showButton1 = true,
                    textButton1 = Locale.Get("K45_CMNS_LIB_ANERROROCURREDWHILELOADING_OPT_DELETEFILE"),
                    showButton2 = true,
                    textButton2 = Locale.Get("K45_CMNS_LIB_ANERROROCURREDWHILELOADING_OPT_GOTOFILE"),
                    showButton3 = true,
                    textButton3 = Locale.Get("EXCEPTION_OK"),
                }, (z) =>
                {
                    if (z == 1)
                    {
                        File.Delete(newVal.DefaultXmlFileBaseFullPath);
                    }
                    if (z == 2)
                    {
                        ColossalFramework.Utils.OpenInFileBrowser(newVal.DefaultXmlFileBaseFullPath);
                        return false;
                    }
                    return true;
                });
            })
                : newVal);
        }
Esempio n. 3
0
        protected void CreateGroup9(UIHelperExtension helper)
        {
            UIHelperExtension group9 = helper.AddGroupExtended(Locale.Get("K45_BETAS_EXTRA_INFO"));

            Group9SettingsUI(group9);

            group9.AddCheckbox(Locale.Get("K45_DEBUG_MODE"), DebugMode.value, delegate(bool val)
                               { DebugMode.value = val; });
            group9.AddLabel(string.Format(Locale.Get("K45_VERSION_SHOW"), FullVersion));
            group9.AddButton(Locale.Get("K45_RELEASE_NOTES"), delegate()
            {
                ShowVersionInfoPopup(true);
            });
            group9.AddButton("Report-a-bug helper", () => K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
            {
                icon    = IconName,
                title   = "Report-a-bug helper",
                message = "If you find any problem with this mod, please send me the output_log.txt (or player.log on Mac/Linux) in the mod Workshop page. If applies, a printscreen can help too to make a better guess about what is happening wrong here...\n\n" +
                          "There's a link for a Workshop guide by <color #008800>aubergine18</color> explaining how to find your log file, depending of OS you're using.\nFeel free to create a topic at Workshop or just leave a comment linking your files.",
                showButton1 = true,
                textButton1 = "Okay...",
                showButton2 = true,
                textButton2 = "Go to the guide",
                showButton3 = true,
                textButton3 = "Go to mod page"
            }, (x) =>
            {
                if (x == 2)
                {
                    ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=463645931");
                    return(false);
                }
                if (x == 3)
                {
                    ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=" + ModId);
                    return(false);
                }
                return(true);
            }));

            if (m_showLangDropDown)
            {
                UIDropDown dd = null;
                dd = group9.AddDropdownLocalized("K45_MOD_LANG", (new string[] { "K45_GAME_DEFAULT_LANGUAGE" }.Concat(KlyteLocaleManager.locales.Select(x => $"K45_LANG_{x}")).Select(x => Locale.Get(x))).ToArray(), KlyteLocaleManager.GetLoadedLanguage(), delegate(int idx)
                {
                    KlyteLocaleManager.SaveLoadedLanguage(idx);
                    KlyteLocaleManager.ReloadLanguage();
                    KlyteLocaleManager.RedrawUIComponents();
                });
            }
            else
            {
                group9.AddLabel(string.Format(Locale.Get("K45_LANG_CTRL_MOD_INFO"), Locale.Get("K45_MOD_CONTROLLING_LOCALE")));
            }
        }
Esempio n. 4
0
        private void ExportTo(string output, bool isAsset)
        {
            if (EditingInstance?.PropName != null)
            {
                ListWrapper <BoardDescriptorGeneralXml> currentFile;
                if (File.Exists(output))
                {
                    currentFile = DefaultXmlDeserialize <ListWrapper <BoardDescriptorGeneralXml> >(File.ReadAllText(output), (x, y) => currentFile = new ListWrapper <BoardDescriptorGeneralXml>());
                }
                else
                {
                    currentFile = new ListWrapper <BoardDescriptorGeneralXml>();
                }

                var targetLayoutName = EditingInstance.SaveName;
                var assetId          = EditingInstance.PropName.Split('.')[0];
                if (isAsset && targetLayoutName.StartsWith($"{assetId}/"))
                {
                    targetLayoutName = targetLayoutName.Split("/".ToCharArray(), 2)[1];
                }
                assetId += ".";
                var exportableLayouts = new ListWrapper <BoardDescriptorGeneralXml>
                {
                    listVal = currentFile.listVal
                              .Where(x => x.SaveName != targetLayoutName)
                              .Concat(new BoardDescriptorGeneralXml[] { CloneViaXml(EditingInstance) }.Select(x => { x.SaveName = targetLayoutName; return(x); }))
                              .ToList()
                };
                File.WriteAllText(output, DefaultXmlSerialize(exportableLayouts));

                WTSPropLayoutData.Instance.ReloadAllPropsConfigurations();

                K45DialogControl.ShowModal(
                    new K45DialogControl.BindProperties
                {
                    title       = WriteTheSignsMod.Instance.SimpleName,
                    message     = string.Format(Locale.Get("K45_WTS_SAVESUCCESSFULLAT"), output),
                    showButton1 = true,
                    textButton1 = Locale.Get("K45_CMNS_GOTO_FILELOC"),
                    showButton2 = true,
                    textButton2 = Locale.Get("EXCEPTION_OK"),
                }
                    , (x) =>
                {
                    if (x == 1)
                    {
                        ColossalFramework.Utils.OpenInFileBrowser(output);
                        return(false);
                    }
                    return(true);
                });;
            }
        }
        private void ShowModalReport(ACEController.CacheOrder target, int[] cachedStarts = null, int currentPage = 0)
        {
            FormattedReportLine[] reference = Controller.LoadedConfiguration.GetLoadedReport(target);
            if (cachedStarts == null)
            {
                var itemStarts        = reference.Select((x, y) => Tuple.New(y, x)).Where(x => x.Second.Level == 0).Select(x => x.First).ToList();
                var startCacheBuilder = new List <int> {
                    0
                };
                for (int i = 0; i < itemStarts.Count - 1; i++)
                {
                    if (itemStarts[i + 1] - startCacheBuilder.Last() > m_itemsPerReportPage)
                    {
                        startCacheBuilder.Add(itemStarts[i]);
                    }
                }
                if (reference.Length - startCacheBuilder.Last() > m_itemsPerReportPage)
                {
                    startCacheBuilder.Add(itemStarts.Last());
                }
                cachedStarts = startCacheBuilder.ToArray();
            }

            int firstItem = cachedStarts[currentPage];
            int lastItem  = currentPage + 1 >= cachedStarts.Length ? reference.Length - 1 : cachedStarts[currentPage + 1] - 1;

            K45DialogControl.ShowModal(new K45DialogControl.BindProperties
            {
                title       = string.Format(Locale.Get("K45_ACE_REPORTTITLEFORMAT", target.ToString()), currentPage + 1, cachedStarts.Length),
                message     = lastItem < 0 ? Locale.Get("K45_ACE_NOITEMSLOADED") : string.Join("\n", reference.Where((x, y) => y >= firstItem && y <= lastItem).Select(x => x.ToString()).ToArray()),
                showClose   = true,
                showButton1 = currentPage > 0,
                textButton1 = "<<<\n" + Locale.Get("K45_CMNS_PREV"),
                showButton2 = true,
                textButton2 = Locale.Get("K45_CMNS_OK"),
                showButton3 = currentPage < cachedStarts.Length - 1,
                textButton3 = ">>>\n" + Locale.Get("K45_CMNS_NEXT")
            }, (x) =>
            {
                if (x == 1)
                {
                    ShowModalReport(target, cachedStarts, currentPage - 1);
                }
                if (x == 3)
                {
                    ShowModalReport(target, cachedStarts, currentPage + 1);
                }
                return(true);
            });
        }
Esempio n. 6
0
        private void OnDeleteFromCity() => K45DialogControl.ShowModal(new K45DialogControl.BindProperties
        {
            message     = Locale.Get("K45_WTS_PROMPTDELETEBUILDINGLAYOUT"),
            showButton1 = true,
            showButton2 = true,
            textButton1 = Locale.Get("YES"),
            textButton2 = Locale.Get("NO"),
        }, (x) =>
        {
            if (x == 1)
            {
                WTSVehicleData.Instance.CityDescriptors.Remove(CurrentVehicleInfo.name);
                ReloadVehicle();
            }

            return(true);
        });
        private void OnDeleteFromCity() => K45DialogControl.ShowModal(new K45DialogControl.BindProperties
        {
            message     = Locale.Get("K45_WTS_PROMPTDELETEHWSHIELDLAYOUT"),
            showButton1 = true,
            showButton2 = true,
            textButton1 = Locale.Get("YES"),
            textButton2 = Locale.Get("NO"),
        }, (x) =>
        {
            if (x == 1)
            {
                WTSHighwayShieldsData.Instance.CityDescriptors.Remove(CurrentSelection);
                ReloadShield();
            }

            return(true);
        });
Esempio n. 8
0
        public override void LoadDefaults()
        {
            if (File.Exists(ElectricRoadsController.DEFAULT_CONFIG_FILE))
            {
                try
                {
                    if (Deserialize(typeof(ClassesData), File.ReadAllBytes(ElectricRoadsController.DEFAULT_CONFIG_FILE)) is ClassesData defaultData)
                    {
                        m_cachedDictDataSaved = defaultData.m_cachedDictDataSaved;
                        eventAllChanged?.Invoke();
                    }
                }
                catch (Exception e)
                {
                    LogUtils.DoErrorLog($"EXCEPTION WHILE LOADING: {e.GetType()} - {e.Message}\n {e.StackTrace}");

                    K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                    {
                        icon               = ElectricRoadsMod.Instance.IconName,
                        title              = Locale.Get("K45_ER_ERROR_LOADING_DEFAULTS_TITLE"),
                        message            = string.Format(Locale.Get("K45_ER_ERROR_LOADING_DEFAULTS_MESSAGE"), ElectricRoadsController.DEFAULT_CONFIG_FILE, e.GetType(), e.Message, e.StackTrace),
                        showButton1        = true,
                        textButton1        = Locale.Get("K45_ER_OK_BUTTON"),
                        showButton2        = true,
                        textButton2        = Locale.Get("K45_ER_OPEN_FOLDER_ON_EXPLORER_BUTTON"),
                        showButton3        = true,
                        textButton3        = Locale.Get("K45_ER_GO_TO_MOD_PAGE_BUTTON"),
                        useFullWindowWidth = true
                    }, (x) =>
                    {
                        if (x == 2)
                        {
                            ColossalFramework.Utils.OpenInFileBrowser(ElectricRoadsController.FOLDER_PATH);
                            return(false);
                        }
                        else if (x == 3)
                        {
                            ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=1689984220");
                            return(false);
                        }
                        return(true);
                    });
                }
            }
        }
Esempio n. 9
0
        public void LoadAllShieldsConfigurations()
        {
            LogUtils.DoLog("LOADING HW SHIELDS CONFIG START -----------------------------");
            var errorList = new List <string>();

            Data.GlobalDescriptors.Clear();
            LogUtils.DoLog($"DefaultHwShieldsConfigurationFolder = {WTSController.DefaultHwShieldsConfigurationFolder}");
            foreach (string filename in Directory.GetFiles(WTSController.DefaultHwShieldsConfigurationFolder, "*.xml"))
            {
                try
                {
                    if (CommonProperties.DebugMode)
                    {
                        LogUtils.DoLog($"Trying deserialize {filename}:\n{File.ReadAllText(filename)}");
                    }
                    using (FileStream stream = File.OpenRead(filename))
                    {
                        LoadDescriptorsFromXmlCommon(stream);
                    }
                }
                catch (Exception e)
                {
                    LogUtils.DoWarnLog($"Error Loading file \"{filename}\" ({e.GetType()}): {e.Message}\n{e}");
                    errorList.Add($"Error Loading file \"{filename}\" ({e.GetType()}): {e.Message}");
                }
            }

            if (errorList.Count > 0)
            {
                K45DialogControl.ShowModal(new K45DialogControl.BindProperties
                {
                    title              = "WTS - Errors loading vehicle Files",
                    message            = string.Join("\r\n", errorList.ToArray()),
                    useFullWindowWidth = true,
                    showButton1        = true,
                    textButton1        = "Okay...",
                    showClose          = true
                }, (x) => true);
            }
            WriteTheSignsMod.Controller.HighwayShieldsAtlasLibrary.PurgeShields();
            LogUtils.DoLog("LOADING HW SHIELDS CONFIG END -----------------------------");
        }
 private void OnDeleteConfig()
 {
     K45DialogControl.ShowModal(
         new K45DialogControl.BindProperties
     {
         title       = Locale.Get("K45_ADR_EDITOR_CONFIGDELETE_TITLE"),
         message     = string.Format(Locale.Get("K45_ADR_EDITOR_CONFIGDELETE_MESSAGE"), m_configList.text),
         showButton1 = true,
         textButton1 = Locale.Get("YES"),
         showButton2 = true,
         textButton2 = Locale.Get("NO"),
     }
         , (x) =>
     {
         if (x == 1)
         {
             AdrHighwayParentLibDataXml.Instance.Remove(m_configList.text);
             OnRefresh();
         }
         return(true);
     });;
 }
Esempio n. 11
0
        public void LoadImagesFromLocalFolders()
        {
            LocalAtlases.Clear();
            var errors = new List <string>();
            var folders = new string[] { WTSController.ExtraSpritesFolder }.Concat(Directory.GetDirectories(WTSController.ExtraSpritesFolder));

            foreach (var dir in folders)
            {
                bool isRoot       = dir == WTSController.ExtraSpritesFolder;
                var  spritesToAdd = new List <SpriteInfo>();
                WTSAtlasLoadingUtils.LoadAllImagesFromFolderRef(dir, ref spritesToAdd, ref errors, isRoot);
                if (isRoot || spritesToAdd.Count > 0)
                {
                    var atlasName = isRoot ? string.Empty : Path.GetFileNameWithoutExtension(dir);
                    LocalAtlases[atlasName] = new UITextureAtlas
                    {
                        material = new Material(UIView.GetAView().defaultAtlas.material.shader)
                    };
                    if (isRoot)
                    {
                        spritesToAdd.AddRange(UIView.GetAView().defaultAtlas.sprites.Select(x => CloneSpriteInfo(x)).ToList());
                        TextureAtlasUtils.LoadImagesFromResources("commons.UI.Images", ref spritesToAdd);
                        TextureAtlasUtils.LoadImagesFromResources("UI.Images", ref spritesToAdd);
                    }
                    TextureAtlasUtils.RegenerateTextureAtlas(LocalAtlases[atlasName], spritesToAdd);
                }
            }
            LocalAtlasesCache.Clear();
            LocalRenderMaterial.Clear();
            if (errors.Count > 0)
            {
                K45DialogControl.ShowModal(new K45DialogControl.BindProperties
                {
                    message = $"{Locale.Get("K45_WTS_CUSTOMSPRITE_ERRORHEADER")}:\n\t{string.Join("\n\t", errors.ToArray())}"
                }, (x) => true);
            }
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        protected override void StartActions()
        {
            if (m_ghostMode)
            {
                for (ushort a = 1; a < BuildingManager.instance.m_buildings.m_buffer.Length; a++)
                {
                    if (BuildingManager.instance.m_buildings.m_buffer[a].Info.m_buildingAI is PrivateBuildingAI)
                    {
                        Vector3            position     = BuildingManager.instance.m_buildings.m_buffer[a].m_position;
                        int                num          = Mathf.Max((int)((position.x - 35f) / 64f + 135f), 0);
                        int                num2         = Mathf.Max((int)((position.z - 35f) / 64f + 135f), 0);
                        int                num3         = Mathf.Min((int)((position.x + 35f) / 64f + 135f), 269);
                        int                num4         = Mathf.Min((int)((position.z + 35f) / 64f + 135f), 269);
                        Array16 <Building> buildings    = Singleton <BuildingManager> .instance.m_buildings;
                        ushort[]           buildingGrid = Singleton <BuildingManager> .instance.m_buildingGrid;
                        for (int i = num2; i <= num4; i++)
                        {
                            for (int j = num; j <= num3; j++)
                            {
                                ushort num5 = buildingGrid[i * 270 + j];
                                int    num6 = 0;
                                while (num5 != 0)
                                {
                                    ushort         nextGridBuilding = buildings.m_buffer[num5].m_nextGridBuilding;
                                    Building.Flags flags            = buildings.m_buffer[num5].m_flags;
                                    if ((flags & (Building.Flags.Created | Building.Flags.Deleted | Building.Flags.Demolishing | Building.Flags.Collapsed)) == Building.Flags.Created)
                                    {
                                        BuildingInfo info = buildings.m_buffer[num5].Info;
                                        if (info != null && info.m_placementStyle == ItemClass.Placement.Automatic)
                                        {
                                            ItemClass.Zone zone          = info.m_class.GetZone();
                                            ItemClass.Zone secondaryZone = info.m_class.GetSecondaryZone();
                                            if (zone != ItemClass.Zone.None && VectorUtils.LengthSqrXZ(buildings.m_buffer[num5].m_position - position) <= 1225f)
                                            {
                                                buildings.m_buffer[num5].CheckZoning(zone, secondaryZone, true);
                                            }
                                        }
                                    }
                                    num5 = nextGridBuilding;
                                    if (++num6 >= 49152)
                                    {
                                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                for (ushort i = 1; i < ZoneManager.instance.m_blocks.m_buffer.Length; i++)
                {
                    bool changed = false;
                    for (int x = 0; x < 4; x++)
                    {
                        for (int z = 0; z < 8; z++)
                        {
                            changed = ZoneMixerOverrides.GetBlockZoneSanitize(ref ZoneManager.instance.m_blocks.m_buffer[i], x, z) | changed;
                        }
                    }
                    if (changed)
                    {
                        ZoneManager.instance.m_blocks.m_buffer[i].RefreshZoning(i);
                    }
                }

                K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                {
                    icon        = ZoneMixerMod.Instance.IconName,
                    title       = Locale.Get("K45_ZM_GHOST_MODE_MODAL_TITLE"),
                    message     = Locale.Get("K45_ZM_GHOST_MODE_MODAL_MESSAGE"),
                    showButton1 = true,
                    textButton1 = Locale.Get("K45_ZM_OK_BUTTON")
                }, (x) => true);
            }
        }
Esempio n. 15
0
        private static string ShowPatchingInfo(bool force = false, bool showModal = true)
        {
            string text = "????";

            switch (m_currentPatched)
            {
            case 0:
                text = "No patch applied. It should not happen!";
                if (showModal)
                {
                    K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                    {
                        icon    = ElectricRoadsMod.Instance.IconName,
                        title   = "Something got wrong on Hooking",
                        message = "<color #FFFF00>NOTICE: If you just enabled this mod in the mod selection menu, ignore this warning and just close and open again your game to make this mod work properly!</color>\n\n" +
                                  "If not, Electric Roads failed loading code detours. Please send me a print from this screen with the output_log.txt (or player.log on Mac/Linux) in the mod Workshop page.\n\n" +
                                  "There's a link for a Worshop guide by <color #008800>aubergine18</color> explaining how to find your log file, depending of OS you're using." +
                                  "\n\n Technical details: " + ElectricRoadsOverrides.GetAssembliesDebugString(),
                        showButton1        = true,
                        textButton1        = Locale.Get("K45_ER_OK_BUTTON"),
                        showButton2        = true,
                        textButton2        = Locale.Get("K45_ER_GO_TO_THE_GUIDE"),
                        showButton3        = true,
                        textButton3        = Locale.Get("K45_ER_GO_TO_MOD_PAGE_BUTTON"),
                        useFullWindowWidth = true
                    }, (x) =>
                    {
                        if (x == 2)
                        {
                            ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=463645931");
                            return(false);
                        }
                        if (x == 3)
                        {
                            ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=1689984220");
                            return(false);
                        }
                        return(true);
                    });
                }

                break;

            case PatchFlags.RegularGame:
                text = "Regular patch applied. This happens when 81 tiles mod is not enabled.";
                if (force || DebugMode)
                {
                    if (showModal)
                    {
                        K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                        {
                            icon    = ElectricRoadsMod.Instance.IconName,
                            title   = "Hooking successful - Regular game",
                            message = "Electric Roads succeed loading code detours. Regular patch applied. This happens when 81 tiles mod is not found on mod list.\n\n" +
                                      "If you think this is wrong (like if you subscribed 81 tiles mod and the patch wasn't applied), feel free to send me a print from this screen with the output_log.txt (or player.log on Mac/Linux) in the mod Workshop page.\n\n" +
                                      "There's a link for a Worshop guide by <color #008800>aubergine18</color> explaining how to find your log file, depending of OS you're using." +
                                      ((!force && DebugMode) ? "\n\n<color #ffff00>NOTE: To disable this warning when loading the game, just turn off the debug mode in mod options.</color>" : "") +
                                      "\n\n Technical details: " + ElectricRoadsOverrides.GetAssembliesDebugString(),
                            showButton1        = true,
                            textButton1        = Locale.Get("K45_ER_OK_BUTTON"),
                            showButton2        = true,
                            textButton2        = Locale.Get("K45_ER_GO_TO_THE_GUIDE"),
                            showButton3        = true,
                            textButton3        = Locale.Get("K45_ER_GO_TO_MOD_PAGE_BUTTON"),
                            useFullWindowWidth = true
                        }, (x) =>
                        {
                            if (x == 2)
                            {
                                ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=463645931");
                                return(false);
                            }
                            if (x == 3)
                            {
                                ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=1689984220");
                                return(false);
                            }
                            return(true);
                        });
                    }
                }
                break;

            case PatchFlags.Mod81TilesGame:
            case PatchFlags.Mod81TilesGame | PatchFlags.RegularGame:
                text = "Regular AND 81 tiles mod patches applied. This happens when 81 tiles mod is found.";
                if (force || DebugMode)
                {
                    if (showModal)
                    {
                        K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
                        {
                            icon    = ElectricRoadsMod.Instance.IconName,
                            title   = "Hooking successful - Regular game + 81 Tiles Mod",
                            message = "Electric Roads succeed loading code detours. 81 tiles mod patch was applied. This happens when 81 tiles mod is found on mod list. Don't worry, if you desable it, the regular patch will be used.\n\n" +
                                      ((!force && DebugMode) ? "\n\n<color #ffff00>NOTE: To disable this warning when loading the game, just turn off the debug mode in mod options.</color>" : "") +
                                      "\n\n Technical details: " + ElectricRoadsOverrides.GetAssembliesDebugString(),
                            showButton1        = true,
                            textButton1        = Locale.Get("K45_ER_OK_BUTTON"),
                            useFullWindowWidth = true
                        }, (x) =>
                        {
                            if (x == 2)
                            {
                                ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=463645931");
                                return(false);
                            }
                            if (x == 3)
                            {
                                ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=1689984220");
                                return(false);
                            }
                            return(true);
                        });
                    }
                }
                break;
            }
            return(text);
        }