Ejemplo n.º 1
0
        internal void Save()
        {
            try
            {
                w = new StreamWriter(Util.GetFileName(AssetLoader.AssetName(LevelLoader.instance.cityName) + "-AssetsReport", "htm"));
                w.WriteLine(@"<!DOCTYPE html><html><head><meta charset=""UTF-8""><title>Assets Report</title><style>");
                w.WriteLine(@"* {font-family: sans-serif;}");
                w.WriteLine(@".my {display: -webkit-flex; display: flex;}");
                w.WriteLine(@".my div {min-width: 30%; margin: 4px 4px 4px 20px;}");
                w.WriteLine(@"</style></head><body>");

                H1(AssetLoader.AssetName(LevelLoader.instance.cityName));
                Para("To stop saving these files, disable the option \"Save assets report\" in Loading Screen Mod.");
                Para("You can safely delete this file. No-one reads it except you.");

                Save("Assets that failed to load", failed);
                Save("Assets that were not found", notFound);

                if (Settings.settings.loadUsed)
                {
                    H1("The following custom assets were used in this city when it was saved");

                    UsedAssets refs = AssetLoader.instance.refs;
                    Save("Buildings", new List <string>(refs.Buildings));
                    Save("Props", new List <string>(refs.Props));
                    Save("Trees", new List <string>(refs.Trees));
                    Save("Vehicles", new List <string>(refs.Vehicles));
                }
                else
                {
                    Para("Enable the option \"Load used assets\" to track missing assets.");
                    H1("Used assets");
                    Para("To also list the custom assets used in this city, enable the option \"Load used assets\" in Loading Screen Mod.");
                }

                w.WriteLine(@"</body></html>");
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
            finally
            {
                w?.Dispose();
                w = null;
            }
        }
Ejemplo n.º 2
0
        internal void Save()
        {
            try
            {
                string name = AssetLoader.AssetName(LevelLoader.instance.cityName);

                foreach (char c in forbidden)
                {
                    name = name.Replace(c, 'x');
                }

                w = new StreamWriter(Util.GetFileName(name + "-AssetsReport", "htm"));
                w.WriteLine(@"<!DOCTYPE html><html lang=""en""><head><meta charset=""UTF-8""><title>Assets Report</title><style>");
                w.WriteLine(@"* {font-family: sans-serif;}");
                w.WriteLine(@".my {display: -webkit-flex; display: flex;}");
                w.WriteLine(@".my div {min-width: 32%; margin: 5px 5px 5px 20px;}");
                w.WriteLine(@"h1 {margin-top: 40px; border-bottom: 2px solid black;}");
                w.WriteLine(@"</style></head><body>");

                H1(AssetLoader.AssetName(LevelLoader.instance.cityName));
                int    seconds     = Profiling.Millis / 1000 + 4;
                string loadingTime = string.Concat((seconds / 60).ToString(), ":", (seconds % 60).ToString("00"));
                Italics(string.Concat("Report created at loading time ", loadingTime, "."));

                Italics("To stop saving these files, disable the option \"Save assets report\" in Loading Screen Mod.");
                Italics("You can safely delete this file. No-one reads it except you.");

                Save(failed, "Assets that failed to load", "No failed assets.");
                SaveDuplicates("Duplicate assets");
                H2("Assets that were not found");

                if (Settings.settings.loadUsed)
                {
                    SaveNotFound();
                }
                else
                {
                    Italics("Enable the option \"Load used assets\" to track missing assets.");
                }

                if (Settings.settings.loadUsed)
                {
                    H1("The following custom assets are used in this city");
                    Italics("Notice that network assets are not yet supported in this section.");
                    List <string> buildings = new List <string>(UsedAssets.instance.Buildings), props = new List <string>(UsedAssets.instance.Props),
                                  trees = new List <string>(UsedAssets.instance.Trees), vehicles = new List <string>(UsedAssets.instance.Vehicles),
                                  indirectProps = new List <string>(UsedAssets.instance.IndirectProps), indirectTrees = new List <string>(UsedAssets.instance.IndirectTrees);
                    Save(buildings, "Buildings and parks"); Save(props, "Props"); Save(trees, "Trees"); Save(vehicles, "Vehicles");
                    Save(indirectProps, "Props in buildings and parks"); Save(indirectTrees, "Trees in buildings and parks");
                    HashSet <string> paths = GetPackagePaths(buildings, props, trees, vehicles, indirectProps, indirectTrees);

                    H1("The following loaded assets are currently unnecessary (not used in this city)");
                    Italics("There are three reasons why an asset may appear in this section: (a) The asset is enabled but unused (b) The asset is a prop or tree in an enabled but unused building or park (c) The asset is included in an enabled district style but unused.");
                    Italics("Notice that network assets are not yet supported in this section.");
                    Save(AssetLoader.instance.Buildings.Where(s => !AssetLoader.instance.IsIntersection(s) && !Used(s, paths)).ToList(), "Buildings and parks");
                    Save(AssetLoader.instance.Props.Where(s => !Used(s, paths)).ToList(), "Props");
                    Save(AssetLoader.instance.Trees.Where(s => !Used(s, paths)).ToList(), "Trees");
                    Save(AssetLoader.instance.Vehicles.Where(s => !Used(s, paths)).ToList(), "Vehicles");
                }
                else
                {
                    H1("Used assets");
                    Italics("To list the custom assets used in this city, enable the option \"Load used assets\" in Loading Screen Mod.");
                }

                w.WriteLine(@"</body></html>");
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
            finally
            {
                w?.Dispose();
                w = null;
            }
        }