예제 #1
0
        //More button hiding.
        private void descriptionButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            Debug.LogError("Hi a button was clicked!");

            //  BuildingInfo infoMGR = Singleton<InfoManager>.instance.m_properties;

            // try to get the Building name displaied on the dialog

            /*
             * (Library) ZonedBuildingWorldInfoPanel -> Caption
             */

            var buildingInfo = UIView.Find <UIPanel>("(Library) ZonedBuildingWorldInfoPanel");

            if (buildingInfo != null)
            {
                var Caption = buildingInfo.Find("Caption");
                if (Caption)
                {
                    var buildingName = Caption.Find("BuildingName");
                    if (buildingName)
                    {
                        UITextField txtBuildingName = buildingName.GetComponent <UITextField>();
                        if (txtBuildingName)
                        {
                            Debug.LogWarning(txtBuildingName.text);
                        }
                    }
                }
            }
            showDescription = !showDescription;
            //GameObject _buildingManagerGO = GameObject.Find("BuildingManager");
            //BuildingManager _bm = _buildingManagerGO.GetComponent<BuildingManager>();

            //JSON json = JSON.Serialize(_bm.m_buildings.m_buffer[selectedBuilding]);

            //string jsonString = json.CreateString();

            BuildingManager instance = Singleton <BuildingManager> .instance;

            // this.UpdateBuildingInfo(selectedBuilding, instance.m_buildings.m_buffer[(int)selectedBuilding]);

            Debug.Log(instance.m_buildings.m_buffer[(int)selectedBuilding].m_children);

            JSON   json       = JSON.Serialize(instance.m_buildings.m_buffer[(int)selectedBuilding]);
            string jsonString = json.CreateString();

            Debug.Log(jsonString);
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Mnns Dialog", jsonString, false);
        }
예제 #2
0
        internal static void CleanGhostNodes()
        {
            if (!MoveItLoader.IsGameLoaded)
            {
                ExceptionPanel notLoaded = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                notLoaded.SetMessage("Not In-Game", "Use this button when in-game to remove ghost nodes (nodes with no segments attached, which were previously created by Move It)", false);
                return;
            }

            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
            string         message;
            int            count = 0;

            for (ushort nodeId = 0; nodeId < Singleton <NetManager> .instance.m_nodes.m_buffer.Length; nodeId++)
            {
                NetNode node = Singleton <NetManager> .instance.m_nodes.m_buffer[nodeId];
                if ((node.m_flags & NetNode.Flags.Created) == NetNode.Flags.None)
                {
                    continue;
                }
                if ((node.m_flags & NetNode.Flags.Untouchable) != NetNode.Flags.None)
                {
                    continue;
                }
                bool hasSegments = false;

                for (int i = 0; i < 8; i++)
                {
                    if (node.GetSegment(i) > 0)
                    {
                        hasSegments = true;
                        break;
                    }
                }

                if (!hasSegments)
                {
                    count++;
                    Singleton <NetManager> .instance.ReleaseNode(nodeId);
                }
            }
            if (count > 0)
            {
                ActionQueue.instance.Clear();
                message = $"Removed {count} ghost node{(count == 1 ? "" : "s")}!";
            }
            else
            {
                message = "No ghost nodes found, nothing has been changed.";
            }
            panel.SetMessage("Removing Ghost Nodes", message, false);
        }
예제 #3
0
 public void OnEnabled()
 {
     Debug.Log($"Testmod enabled. Version");
     if (UIView.GetAView() != null)
     {
         ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
         panel.SetMessage("Reminder", "Be sure to change the road texture in the settings!", false);
     }
     else
     {
         Debug.Log($"elseload");
     }
 }
예제 #4
0
        internal static void FixTreeFixedHeightFlag()
        {
            if (!MoveItLoader.IsGameLoaded)
            {
                ExceptionPanel notLoaded = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                notLoaded.SetMessage("Not In-Game", "If Tree Snapping is causing tree heights to be off, click this straight after loading your city to fix the issue.", false);
                return;
            }

            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
            string         message;
            int            count = 0, total = 0;

            for (uint treeId = 0; treeId < Singleton <TreeManager> .instance.m_trees.m_buffer.Length; treeId++)
            {
                TreeInstance tree = Singleton <TreeManager> .instance.m_trees.m_buffer[treeId];
                if ((tree.m_flags & (ushort)TreeInstance.Flags.Created) == (ushort)TreeInstance.Flags.None)
                {
                    continue;
                }
                total++;

                if (tree.FixedHeight)
                {
                    continue;
                }

                // check if it should have FixedHeight flag
                float terrainHeight = TerrainManager.instance.SampleDetailHeight(tree.Position);
                if (tree.Position.y < terrainHeight - 0.075f || tree.Position.y > terrainHeight + 0.075f)
                {
                    Singleton <TreeManager> .instance.m_trees.m_buffer[treeId].FixedHeight = true;
                    count++;
                }

                if (treeId > 100_000_000)
                {
                    throw new Exception("Scanning too many trees, aborting");
                }
            }
            if (count > 0)
            {
                ActionQueue.instance.Clear();
                message = $"Adjusted {count} tree{(count == 1 ? "" : "s")} out of {total}!";
            }
            else
            {
                message = $"No unflagged floating trees out of {total}, nothing has been changed.";
            }
            panel.SetMessage("Flagging Trees", message, false);
        }
예제 #5
0
        public static void ExportBinaryFbx2(this Mesh mesh, string path)
        {
            string tempPath = path.Replace(".fbx", ".ascii.fbx");

            mesh.ExportAsciiFbx(tempPath);
            ConvertBinary(tempPath, path);
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage(
                "Dump FBX successful",
                $"Dumped mesh as {path}\n" +
                $"Dumped mesh as {tempPath}\n",
                false);
        }
예제 #6
0
        /// <summary>
        /// Производит добавление панели с информацией об ошибке.
        /// </summary>
        /// <param name="exc">Исключение, которое должно отображаться на добавляемой панели.</param>
        /// <param name="controlId">Идентификатор конрола.</param>
        /// <param name="hidden">Флаг: показыает должна ли панель быть скрытой.</param>
        /// <param name="showDetails">Флаг: показыает нужно ли отображать подробности об ошибке.</param>
        /// <returns>ClientID главной панели контрола.</returns>
        private string AddNewExceptionPanel(Exception exc, string controlId, bool hidden, bool showDetails)
        {
            var ctrl = new ExceptionPanel
            {
                ID = controlId,
                ExceptionToShow = exc,
                ShowDetails     = showDetails,
                EnableViewState = false,
                Hidden          = hidden
            };

            Panel4Controls.Controls.Add(ctrl);

            return(ctrl.MainPanelClientID);
        }
예제 #7
0
        /// <summary>
        /// Динамически добавить панель с информацией об ошибке
        /// </summary>
        /// <param name="exc"> Исключение, которое отображается на этой панели </param>
        /// <param name="controlId"> controlId контрола </param>
        /// <param name="hidden"> скрыть или нет </param>
        /// <param name="showDetails"> Показывать детали </param>
        /// <returns> ClientID главной панели контрола </returns>
        private string AddNewExceptionPanel(Exception exc, string controlId, bool hidden, bool showDetails)
        {
            var ctrl = new ExceptionPanel
            {
                ID = controlId,
                ExceptionToShow = exc,
                ShowDetails     = showDetails,
                EnableViewState = false,
                Hidden          = hidden
            };

            this.Panel4Controls.Controls.Add(ctrl);
            this.ScriptHolder.Text += ctrl.Script + Environment.NewLine;
            return(ctrl.MainPanelClientID);
        }
예제 #8
0
        /// <summary>
        /// Export the configuration file
        /// </summary>
        public static void ExportVehicleDataConfig(bool isManual)
        {
            // display a message for the user in the panel, if Autosave is not active and button was pressed manually

            if ((AutoSaveVehicleConfig == true) && (isManual == false))
            {
                Logging.Message("Vehicle Configuration will be auto-exported to Filename: " + m_VehicleSettingsFile);
                config.Serialize(m_VehicleSettingsFile);
            }

            if (isManual == true)
            {
                Logging.Message("Vehicle Configuration will be exported to Filename: " + m_VehicleSettingsFile);
                config.Serialize(m_VehicleSettingsFile);
                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                panel.SetMessage("Advanced Vehicle Options", Translations.Translate("AVO_MOD_AV01") + m_VehicleSettingsFile, false);
            }
        }
예제 #9
0
 // Resets the config file to a blank default
 public static void ResetConfig()
 {
     try
     {
         StreamWriter writer = new StreamWriter(configPath);
         writer.WriteLine("# Dynamic Asset Sorter configuration file");
         writer.WriteLine("# See the steam workshop page for configuration help");
         writer.Close();
     }
     catch (Exception ex)
     {
         if (IsUIAvailable())
         {
             ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
             panel.SetMessage("Dynamic Asset Sorter", "Unable to write to config file! \n" + ex.Message, false);
         }
         Debug.Log($"{modName}: Unable to write to config file!");
         Debug.Log(ex.Message);
     }
 }
예제 #10
0
        public void DumpPillar()
        {
            try
            {
                string extraType = "Pillar";

                NetInfo elevatedNet = AssetEditorRoadUtils.TryGetElevated(loadedPrefab);
                DumpBuildingInfo(GetActivePillar(elevatedNet, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(elevatedNet, PillarType.MiddlePillar));

                NetInfo bridgeNet = AssetEditorRoadUtils.TryGetBridge(loadedPrefab);
                DumpBuildingInfo(GetActivePillar(bridgeNet, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(bridgeNet, PillarType.MiddlePillar));

                //check ground elevation for things such as monorail net pillars etc
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar2));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.BridgePillar3));
                DumpBuildingInfo(GetActivePillar(loadedPrefab, PillarType.MiddlePillar));

                if (pillarsDumped != 0)
                {
                    string         importFolder = Path.Combine(DataLocation.addonsPath, "Import");
                    ExceptionPanel panel        = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    panel.SetMessage("Pillar Dumping Successful", "Network Name: " + networkName_init + "\nExported To: " + importFolder + propDumpedMesssage + "\nPillars Dumped: " + pillarsDumped, false);
                    //explain how to replace after that not that straightfoward (restart the game or reload the asset editor with no workshop on!)

                    RoadExtrasAlert.instance.setExtraType(extraType);
                    RoadExtrasAlert.instance.Show();
                }
                else
                {
                    Lib.ExtraUtils.ShowErrorWindow("Pillar Dumping Failed", "No Pillars Found");
                }
            }
            catch (Exception e)
            {
                Lib.ExtraUtils.ShowErrorWindow("Pillar Dumping Failed", e.ToString());
            }
        }
        public void OnLevelLoaded(LoadMode mode)
        {
            if (!roadAnarchyDetected)
            {
                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                panel.SetMessage("Smart Intersection Builder", "Mod 'Smart Intersection Builder' requires mod 'Fine Road Anarchy' or 'Fine Road Anarchy 2' as dependency. " +
                                 "Make sure it is installed and enabled in content manager. (If you are using local version of Fine Road Anarchy, make sure it is located in a folder " +
                                 "called 'FineRoadAnarchy')", true);
            }

            if (SmartIntersections.instance == null)
            {
                // Creating the instance
                SmartIntersections.instance = new GameObject("SmartIntersections").AddComponent <SmartIntersections> ();
            }

            //instatiate UI
            if (UIWindow.instance == null)
            {
                UIView.GetAView().AddUIComponent(typeof(UIWindow));
            }
        }
        /* Inspired by Move It */
        public static void RemoveGlitchedRoads()
        {
            if (!ModLoadingExtension.LevelLoaded)
            {
                ExceptionPanel notLoaded = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                notLoaded.SetMessage("Not In-Game", "Use this button when in-game to remove glitched roads", false);
                return;
            }

            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
            string         message;

            count = 0;
            unhandledExceptions = 0;

            for (ushort segmentId = 0; segmentId < NetManager.instance.m_segments.m_buffer.Length; segmentId++)
            {
                NetSegment segment = NetManager.instance.m_segments.m_buffer[segmentId];

                if ((segment.m_flags & NetSegment.Flags.Created) == NetSegment.Flags.None)
                {
                    continue;
                }

                try
                {
                    if (segment.m_startNode == 0 || segment.m_endNode == 0)
                    {
                        Release(segmentId);
                        continue;
                    }

                    try
                    {
                        NetNode node1 = NetManager.instance.m_nodes.m_buffer[segment.m_startNode];
                        NetNode node2 = NetManager.instance.m_nodes.m_buffer[segment.m_endNode];

                        if ((node1.m_flags & NetNode.Flags.Created) == NetNode.Flags.None || (node2.m_flags & NetNode.Flags.Created) == NetNode.Flags.None)
                        {
                            Release(segmentId);
                            continue;
                        }

                        // Teasing methods
                        node1.CountSegments();
                        node2.CountSegments();
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Invalid node. Has thrown exception: ");
                        Debug.Log(e);
                        Release(segmentId);
                    }
                }
                catch (Exception e)
                {
                    unhandledExceptions++;
                    Debug.LogError(e);
                }
            }
            if (unhandledExceptions > 0)
            {
                message = "ERROR: Unhandled exceptions: " + unhandledExceptions + ". Maybe something went VERY VERY wrong. You should reload last save. (Segments removed: " + count + ")";
            }
            else if (count > 0)
            {
                message = $"Removed {count} segment{(count == 1 ? "" : "s")}! Please check that nothing unpleasant has happened to your game. Save it in a new file.";
            }
            else
            {
                message = "No glitched segments found.";
            }

            panel.SetMessage("Removing glitched segments", message, false);
        }
예제 #13
0
        public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            //Debug.Log(_processed);
            if (Input.GetKeyDown(KeyCode.F11))
            {
                //Debug.Log("---> Running SerializeAndDeserialize.SerializePlayerObjectToString()");
                //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "---> Running SerializeAndDeserialize.SerializePlayerObjectToString()");
                //string jsonString = SerializePlayerObjectToString();
                //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, jsonString);

                GameObject _buildingManagerGO = GameObject.Find("BuildingManager");
                if (_buildingManagerGO)
                {
                    //Debug.Log("bingo _buildingManagerGO");
                    BuildingManager _bm = _buildingManagerGO.GetComponent <BuildingManager>();
                    if (_bm)
                    {
                        //Debug.Log("bingo _bm");
                        Debug.Log(_bm.m_buildings.m_buffer.ToString());


                        // Output JSON
                        Debug.Log(_bm.m_buildings.m_buffer[0]);
                        JSON   json       = JSON.Serialize(_bm.m_buildings.m_buffer[0]);
                        string jsonString = json.CreateString();
                        Debug.Log(jsonString);
                    }
                    else
                    {
                        Debug.Log("_bm = null");
                    }
                }
                else
                {
                    Debug.Log("_buildingManagerGO = null");
                }
                Debug.Log("f12 is pressed");
            }

            if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKey(KeyCode.D))
            {
                if (_processed)
                {
                    return;
                }

                _processed = true;
                int rDemand = ZoneManager.instance.m_actualResidentialDemand;
                int cDemand = ZoneManager.instance.m_actualCommercialDemand;
                int wDemand = ZoneManager.instance.m_actualWorkplaceDemand;

                string message = $"Residential: {rDemand}\nCommercial: {cDemand}\nWorkplace: {wDemand}";

                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                panel.SetMessage("Mnns Dialog", message, false);
            }

            else
            {
                _processed = false;
            }
        }
        public void GenerateLodImages(string filepath)
        {
            Texture2D texture1;

            string[] textureFileExtensions = { "_d.png", "_a.png", "_p.png", "_r.png" };

            try
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "filename: " + filepath);
                if (filepath == "")
                {
                    if (NetDumpPanel.instance.GetCustomFilePrefix() != "")
                    {
                        string importFolder = Path.Combine(DataLocation.addonsPath, "Import");
                        filepath = Path.Combine(importFolder, NetDumpPanel.instance.GetCustomFilePrefix());
                    }
                    else
                    {
                        throw new System.Exception("No File Path Found! \nDump a network first or put a custom filename in the custom file prefix field\n");
                    }
                }
                for (int i = 0; i < textureFileExtensions.Length; i++)
                {
                    if (File.Exists(filepath + textureFileExtensions[i]))
                    {
                        texture1 = new Texture2D(1, 1);
                        texture1.LoadImage(File.ReadAllBytes(filepath + textureFileExtensions[i]));
                        texture1.anisoLevel = 16;
                        texture1.MakeReadable();
                        TextureScaler.scale(texture1, 64, 64);
                        //turn off if elevated?
                        if (NetDumpPanel.instance.GetNetEleIndex == 0)
                        {
                            texture1 = FlipTexture(texture1, false);
                            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "flipped texture1!");
                        }
                        string fileExt     = "_lod" + textureFileExtensions[i];
                        string lodFilepath = filepath + fileExt;

                        DumpTexture2D(texture1, lodFilepath);
                        filePathsLog += lodFilepath + "\n";
                        NetDumpPanel.instance.dumpedFiles += lodFilepath + "\n";
                    }
                    else
                    { //make this try/catch?
                        Debug.Log(textureFileExtensions[i] + " failed");
                    }
                }

                if (NetDumpPanel.instance.GetNetEleIndex != 0)
                {
                    //bit of hack since for some reason uv maps are often completely different on lod meshes than main mesh on some vanilla elevations - ok since elevated sections are not used that much on a map anyway for custom roads. - do properly later maybe?
                    File.Copy(filepath + ".obj", filepath + "_lod.obj", true);
                }

                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                panel.SetMessage("LOD File Generation Successful", "Files Exported:\n" + filePathsLog, false);
            }
            catch (Exception e)
            {
                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                panel.SetMessage("LOD File Generation Failed", "" + e, false);
                panel.GetComponentInChildren <UISprite>().spriteName = "IconError";
            }
        }
예제 #15
0
        public void ThrowError(string message)
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Net Picker", message, false);
        }
예제 #16
0
        // Reads and parses the config file
        public static void ReadConfig()
        {
            // Reset the config storage
            prefabRules.Clear();
            hiddenIcons.Clear();

            // Store current line for exception handling
            int currentLine = 0;

            try
            {
                // Read the Config File
                string       line;
                StreamReader reader = new StreamReader(configPath);
                while ((line = reader.ReadLine()) != null)
                {
                    currentLine++;

                    // Skip comments and empty lines
                    if (line.StartsWith("#") || line.Equals(""))
                    {
                        continue;
                    }

                    // Split the line into 3 parts
                    string[] delimiter = { ", " };
                    string[] splitLine = line.Split(delimiter, 3, StringSplitOptions.RemoveEmptyEntries);
                    if (splitLine.Length == 3)
                    {
                        if (line.StartsWith("HideIcon", StringComparison.InvariantCultureIgnoreCase))
                        {
                            string iconName        = splitLine[2].Trim();
                            string iconGrandparent = splitLine[1].Trim();
                            hiddenIcons.Add(new IconInfo(iconName, iconGrandparent));
                            continue;
                        }

                        // Skip a line if it's first value can't be converted to an integer
                        int priority;
                        if (!int.TryParse(splitLine[0].Trim(), out priority))
                        {
                            Debug.Log($"{modName}: Invalid config entry. Entries must start with a number or the prefix \"HideIcon, \"");
                            continue;
                        }

                        // The last part of the line will be the prefab name
                        string prefabName = splitLine[2].Trim();

                        // Assign a line to the correct dictionary
                        string prefabType = splitLine[1].Trim();
                        if (prefabType == "Network" ||
                            prefabType == "Building" ||
                            prefabType == "Transport" ||
                            prefabType == "Tree" ||
                            prefabType == "Prop")
                        {
                            prefabRules.Add(new SortRule(prefabName, prefabType, priority));
                        }
                        else
                        {
                            Debug.Log($"{modName}: Invalid prefab type: \"{prefabType}\" for prefab \"{prefabName}\" in config file.");
                        }
                    }
                    else
                    {
                        Debug.Log($"{modName}: \"{line}\" is an invalid config entry. Check that you aren't missing any commas.");
                        Debug.Log($"{modName}: Example Format: \"[Number], [PrefabType], [PrefabName]\"");
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                if (IsUIAvailable())
                {
                    ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    panel.SetMessage(
                        "Dynamic Asset Sorter",
                        "Unable to read config file! \n" +
                        "Please check line number " + currentLine + "\n " +
                        ex.Message, false);
                }
                Debug.Log($"{modName}: Unable to read config file!");
                Debug.Log(ex.Message);
            }
        }
예제 #17
0
 public Bulldoze(ExceptionPanel panel)
 {
     PowerLineAI plAI = new PowerLineAI();
 }//end bulldoze
예제 #18
0
        public void ThrowErrorMsg(string content, bool error = false)
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Roundabout builder", content, error);
        }
예제 #19
0
        public static void ExportUsed(bool exportAllUsed)
        {
            // get steam id of all workship assets
            HashSet <ulong> steamIds = new HashSet <ulong>();

            if (exportAllUsed)
            {
                foreach (Asset asset in AssetTagList.instance.assets.Values)
                {
                    if (!asset.prefab.m_isCustomContent)
                    {
                        continue;
                    }
                    if (asset.steamID == 0)
                    {
                        continue;
                    }
                    steamIds.Add(asset.steamID);
                }
            }

            else // only export assets from last search
            {
                foreach (Asset asset in UISearchBox.instance.matches)
                {
                    if (!asset.prefab.m_isCustomContent)
                    {
                        continue;
                    }
                    if (asset.steamID == 0)
                    {
                        continue;
                    }
                    steamIds.Add(asset.steamID);
                }
            }

            // update instance count
            AssetTagList.instance.UpdatePrefabInstanceCount(UISearchBox.DropDownOptions.All);
            if (FindIt.isPOEnabled)
            {
                ProceduralObjectsTool.UpdatePOInfoList();
            }

            // filter out unused assets
            Dictionary <ulong, int> usedIDs = new Dictionary <ulong, int>();

            foreach (Asset asset in AssetTagList.instance.assets.Values)
            {
                if (!asset.prefab.m_isCustomContent)
                {
                    continue;
                }
                if (asset.steamID == 0)
                {
                    continue;
                }
                AssetTagList.instance.UpdateAssetInstanceCount(asset, true);
                if (asset.instanceCount > 0 || asset.poInstanceCount > 0)
                {
                    if (usedIDs.ContainsKey(asset.steamID))
                    {
                        usedIDs[asset.steamID] += 1;
                    }
                    else
                    {
                        usedIDs.Add(asset.steamID, 1);
                    }
                }
            }

            string currentTime = GetFormattedDateTime();
            string path        = Path.Combine(DataLocation.localApplicationData, $"FindItExportUsedWorkshopID_{currentTime}.html");

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true))
            {
                file.WriteLine($"City Name: {GetCityName()}<br>");
                file.WriteLine($"Export Date: {currentTime}<br>");
                file.WriteLine($"<br>This list only considers asset types that are monitored by Find It 2<br>");
                file.WriteLine($"<br>Some mods are bundled with assets for other purpose. Ignore mods in the list<br>");
                file.WriteLine($"<br>If you ever copied assets from the workshop download folder to the local asset folder, the information here can be inaccurate<br>");
                if (FindIt.isPOEnabled)
                {
                    file.WriteLine($"<br>It seems like you're using Procedural Objects. This list already considers POs<br>");
                }

                foreach (ulong id in steamIds)
                {
                    if (usedIDs.ContainsKey(id))
                    {
                        file.WriteLine($"<br><a href=\"https://steamcommunity.com/sharedfiles/filedetails/?id={id}\">{id}</a><br>\n");
                        file.WriteLine($"This workshop ID contains {usedIDs[id]} used asset(s).<br>\n");
                    }
                }

                if (steamIds.Count == 0)
                {
                    file.WriteLine($"Can't find any used workshop asset.<br>\n");
                }
            }

            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Find It 2", $"FindItExportUsedWorkshopID.html is exported.\n\nIt only considers asset types that are monitored by Find It 2.\n\n{path}", false);
        }
예제 #20
0
        public void ErrorFormat()
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Date Changer", "Invalid Date Format\nMake sure to format as dd/mm/yyyy\ne.g 31/01/2019", false);
        }
예제 #21
0
        public static void ShowAlertWindow(string header, string message)
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage(header, message, false);
        }
예제 #22
0
 /// <summary>
 /// Динамически добавить панель с информацией об ошибке
 /// </summary>
 /// <param name="exc"> Исключение, которое отображается на этой панели </param>
 /// <param name="controlId"> controlId контрола </param>
 /// <param name="hidden"> скрыть или нет </param>
 /// <param name="showDetails"> Показывать детали </param>
 /// <returns> ClientID главной панели контрола </returns>
 private string AddNewExceptionPanel(Exception exc, string controlId, bool hidden, bool showDetails)
 {
     var ctrl = new ExceptionPanel
         {
             ID = controlId,
             ExceptionToShow = exc,
             ShowDetails = showDetails,
             EnableViewState = false,
             Hidden = hidden
         };
     this.Panel4Controls.Controls.Add(ctrl);
     this.ScriptHolder.Text += ctrl.Script + Environment.NewLine;
     return ctrl.MainPanelClientID;
 }
예제 #23
0
        public string[] DumpNetworks(bool endPopup = true)
        {
            try
            {
                string networkName_init = sim.m_editPrefabInfo.name;
                FindMesh(networkName_init);
                var source = material.GetTexture("_MainTex") as Texture2D;
                var target = new Texture2D(source.width, source.height, TextureFormat.RGBAFloat, true);
                target.SetPixels(source.GetPixels());
                target.anisoLevel = source.anisoLevel; target.filterMode = source.filterMode;
                target.wrapMode   = source.wrapMode; target.Apply();
                UnityEngine.Object.FindObjectOfType <NetProperties>().m_downwardDiffuse = target;

                bool      flippingTextures = NetDumpPanel.instance.GetIfFlippedTextures;
                Texture2D aprsource        = aprmaterial.GetTexture("_APRMap") as Texture2D;

                if (NetDumpPanel.instance.GetDumpMeshOnly && NetDumpPanel.instance.GetDumpDiffuseOnly)
                {
                    DumpTexture2D(FlipTexture(target, false, flippingTextures), diffuseTexturePath);
                    DumpMeshToOBJ(roadMesh, meshPath, loadedPrefab);
                    DumpMeshToOBJ(roadMeshLod, lodMeshPath, loadedPrefab);
                }
                else if (NetDumpPanel.instance.GetDumpDiffuseOnly)
                {
                    DumpTexture2D(FlipTexture(target, false, flippingTextures), diffuseTexturePath);
                }
                else if (NetDumpPanel.instance.GetDumpMeshOnly)
                {
                    DumpMeshToOBJ(roadMesh, meshPath, loadedPrefab);
                    DumpMeshToOBJ(roadMeshLod, lodMeshPath, loadedPrefab);
                }
                else
                {
                    DumpTexture2D(FlipTexture(target, false, flippingTextures), diffuseTexturePath);
                    DumpAPR(filename, FlipTexture(aprsource, false, flippingTextures), aFilePath, pFilePath, rFilePath, true);
                    //dump meshes
                    DumpMeshToOBJ(roadMesh, meshPath, loadedPrefab);
                    DumpMeshToOBJ(roadMeshLod, lodMeshPath, loadedPrefab);
                    DumpAPR(filename, FlipTexture(aprsource, false, flippingTextures), aFilePath, pFilePath, rFilePath, true);
                }
                //for workshop roads display disclaimer!
                //also add log for apr textures!
                if (!NetDumpPanel.instance.roadexportnames.Contains(filename))
                {
                    NetDumpPanel.instance.roadexportnames.Add(filename);
                }
                else
                {
                    NetDumpPanel.instance.roadexportnames.Add(filename + "_node");
                }
                //make sure to clear for each button?

                ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

                string[] combinedPaths = { diffuseTexturePath, meshPath, lodMeshPath, aFilePath, pFilePath, rFilePath };
                exportedFilePaths = "";

                if (NetDumpPanel.instance.GetDumpMeshOnly)
                {
                    exportedFilePaths = "Mesh Dump Only\n" + meshPath + "\n" + lodMeshPath;
                    filesExported    += 2;
                }
                else
                {
                    for (int i = 0; i < combinedPaths.Length; i++)
                    {
                        if (File.Exists(combinedPaths[i]))
                        {
                            exportedFilePaths += "\n" + combinedPaths[i];
                            filesExported     += 1;
                        }
                    }
                }

                if (endPopup == true)
                {
                    panel.SetMessage("Network Dump Successful", "Network Name: " + networkName + "\n\nDumped Items:\n" + exportedFilePaths, false);
                }
            }
            catch (Exception e)
            {
                if (endPopup == true)
                {
                    ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    panel.SetMessage("Network Dump Failed", "" + e, false);
                    panel.GetComponentInChildren <UISprite>().spriteName = "IconError";
                    filesExported = 0;
                }
                else
                {
                    bulkErrorText = e.ToString();
                }
            }

            var lodFilepathPart = diffuseTexturePath.Substring(0, diffuseTexturePath.LastIndexOf("_"));

            string[] returnArray = { filesExported.ToString(), exportedFilePaths, lodFilepathPart };


            if (NetDumpPanel.instance.autoExportLodImages.isChecked)
            {
                Debug.Log("Dump with LOD pngs Checked!");
                LodImageGenerator lodgen = new LodImageGenerator();
                lodgen.GenerateLodImages(lodFilepathPart);
            }

            return(returnArray);
        }
        private void SetupControls()
        {
            float offset = 40f;

            //Beta Testing Timestamp
            //DateTime now = DateTime.Now;
            //m_title.title = "Advanced Vehicle Options " + ModInfo.version + " " + now;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = "Advanced Vehicle Options " + ModInfo.version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = "Category :";

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster";
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = "Type the name of a vehicle type";
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = "Actions for Vehicle Configuration:";
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = "Import";
            m_import.width            = 80;
            m_import.tooltip          = "Import the configuration";
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = "Export";
            m_export.width            = 80;
            m_export.tooltip          = "Export the configuration";
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = "Reset all";
            m_resetall.width            = 80;
            m_resetall.tooltip          = "Reset full configuration";
            m_resetall.relativePosition = new Vector3(180, height - 45);

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = "Click here to cycle through the existing vehicles of that type.\nHold Shift Key down for zooming directly to vehicle.";
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = "Click here to remove the selected vehicle.";
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;
            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptionsUID.ImportConfig();
                optionList = AdvancedVehicleOptionsUID.config.options;
            };
            m_export.eventClick += (c, t) => AdvancedVehicleOptionsUID.ExportConfig();

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal("Confirm Reset Configuration", "Customized settings for all vehicles will be reset.\n\n" +
                                       "Proceed with Configuration reset ?", (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptionsUID.ResetConfig();
                    optionList = AdvancedVehicleOptionsUID.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", "All vehicle configuration and customized settings\n" +
                                          "have been reset to the Game Defaults.", false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
예제 #25
0
        internal void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = AVOMod.ModName + " " + AVOMod.Version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = Translations.Translate("AVO_MOD_MP56");

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = Translations.Translate("AVO_MOD_MP39");
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = Translations.Translate("AVO_MOD_MP40");
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = Translations.Translate("AVO_MOD_MP55");

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = Translations.Translate("AVO_MOD_MP41");
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = Translations.Translate("AVO_MOD_MP42");
            m_import.width            = 80;
            m_import.tooltip          = Translations.Translate("AVO_MOD_MP43");
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = Translations.Translate("AVO_MOD_MP44");
            m_export.width            = 80;
            m_export.tooltip          = Translations.Translate("AVO_MOD_MP45");
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = Translations.Translate("AVO_MOD_MP46");
            m_resetall.width            = 80;
            m_resetall.tooltip          = Translations.Translate("AVO_MOD_MP47");
            m_resetall.relativePosition = new Vector3(180, height - 45);

            m_autosave                  = AddUIComponent <UILabel>();
            m_autosave.textScale        = 0.6f;
            m_autosave.text             = Translations.Translate("AVO_MOD_MP48");
            m_autosave.relativePosition = new Vector3(275, height - 40);
            m_autosave.autoSize         = true;
            m_autosave.textAlignment    = UIHorizontalAlignment.Center;
            m_autosave.textColor        = Color.green;
            m_autosave.tooltip          = Translations.Translate("AVO_MOD_MP49");
            m_autosave.isVisible        = AdvancedVehicleOptions.AutoSaveVehicleConfig;

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = Translations.Translate("AVO_MOD_MP50");
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = Translations.Translate("AVO_MOD_MP51");
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;

            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportVehicleDataConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };

            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportVehicleDataConfig(true);

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal(Translations.Translate("AVO_MOD_MP52"), Translations.Translate("AVO_MOD_MP53"), (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptions.ResetVehicleDataConfig();
                    optionList = AdvancedVehicleOptions.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", Translations.Translate("AVO_MOD_MP54"), false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
예제 #26
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            // do base processing
            base.OnLevelLoaded(mode);

            try
            {
                // initialize only if user has Industries DLC
                if (SteamHelper.IsDLCOwned(SteamHelper.DLC.IndustryDLC))
                {
                    // check for new or loaded game
                    if (mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario || mode == LoadMode.LoadGame)
                    {
                        // initialize Harmony
                        ExcludeMail.harmony = HarmonyInstance.Create("com.github.rcav8tr.ExcludeMail");
                        if (ExcludeMail.harmony == null)
                        {
                            Debug.LogError("Unable to create Harmony instance.");
                            return;
                        }

                        // find Ingame atlas
                        UITextureAtlas   ingameAtlas = null;
                        UITextureAtlas[] atlases     = Resources.FindObjectsOfTypeAll(typeof(UITextureAtlas)) as UITextureAtlas[];
                        for (int i = 0; i < atlases.Length; i++)
                        {
                            if (atlases[i] != null)
                            {
                                if (atlases[i].name == "Ingame")
                                {
                                    ingameAtlas = atlases[i];
                                    break;
                                }
                            }
                        }
                        if (ingameAtlas == null)
                        {
                            Debug.LogError("Unable to find atlas [Ingame].");
                            return;
                        }

                        // get the OutsideConnectionsInfoViewPanel panel (displayed when the user clicks on the Outside Connections info view button)
                        OutsideConnectionsInfoViewPanel ocPanel = UIView.library.Get <OutsideConnectionsInfoViewPanel>(typeof(OutsideConnectionsInfoViewPanel).Name);
                        if (ocPanel == null)
                        {
                            Debug.LogError("Unable to find [OutsideConnectionsInfoViewPanel].");
                            return;
                        }

                        // find the import and export legend mail panels
                        UIPanel importLegendMailPanel = ocPanel.Find <UIPanel>("ResourceLegendMail");
                        if (importLegendMailPanel == null)
                        {
                            Debug.LogError($"Unable to find panel [ResourceLegendMail] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }
                        UIPanel exportLegendMailPanel = ocPanel.Find <UIPanel>("ResourceLegendMail2");
                        if (exportLegendMailPanel == null)
                        {
                            Debug.LogError($"Unable to find panel [ResourceLegendMail2] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }

                        // find the import and export legend mail boxes
                        _importLegendMailBox = importLegendMailPanel.Find <UISprite>("MailColor");
                        if (_importLegendMailBox == null)
                        {
                            Debug.LogError($"Unable to find import sprite [MailColor] on [ResourceLegendMail] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }
                        _exportLegendMailBox = exportLegendMailPanel.Find <UISprite>("MailColor");
                        if (_exportLegendMailBox == null)
                        {
                            Debug.LogError($"Unable to find export sprite [MailColor] on [ResourceLegendMail2] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }

                        // find the import and export legend mail labels
                        _importLegendMailLabel = importLegendMailPanel.Find <UILabel>("Type");
                        if (_importLegendMailLabel == null)
                        {
                            Debug.LogError($"Unable to find import label [Type] on [ResourceLegendMail] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }
                        _exportLegendMailLabel = exportLegendMailPanel.Find <UILabel>("Type");
                        if (_exportLegendMailLabel == null)
                        {
                            Debug.LogError($"Unable to find export label [Type] on [ResourceLegendMail2] on [OutsideConnectionsInfoViewPanel]");
                            return;
                        }

                        // find import total label
                        UILabel totalLabel = ocPanel.Find <UILabel>("ImportTotal");
                        if (totalLabel == null)
                        {
                            Debug.LogError("Unable to find label [ImportTotal] on [OutsideConnectionsInfoViewPanel].");
                            return;
                        }

                        // create the check box (i.e. a sprite)
                        _includeMailCheckBox = ocPanel.component.AddUIComponent <UISprite>();
                        if (_includeMailCheckBox == null)
                        {
                            Debug.LogError("Unable to create check box sprite on [OutsideConnectionsInfoViewPanel].");
                            return;
                        }
                        _includeMailCheckBox.name             = "IncludeMailCheckBox";
                        _includeMailCheckBox.autoSize         = false;
                        _includeMailCheckBox.size             = new Vector2(totalLabel.size.y, totalLabel.size.y); // width is same as height
                        _includeMailCheckBox.relativePosition = new Vector3(8f, 82f);
                        _includeMailCheckBox.atlas            = ingameAtlas;
                        SetCheckBox(_includeMailCheckBox, true);
                        _includeMailCheckBox.isVisible = true;
                        _includeMailCheckBox.BringToFront();
                        _includeMailCheckBox.eventClicked += CheckBox_eventClicked;

                        // create the label and right align it to the info view
                        _includeMailLabel = ocPanel.component.AddUIComponent <UILabel>();
                        if (_includeMailLabel == null)
                        {
                            Debug.LogError("Unable to create label on [OutsideConnectionsInfoViewPanel].");
                            return;
                        }
                        _includeMailLabel.name              = "IncludeMailLabel";
                        _includeMailLabel.text              = "Include Mail";
                        _includeMailLabel.textAlignment     = UIHorizontalAlignment.Left;
                        _includeMailLabel.verticalAlignment = UIVerticalAlignment.Top;
                        _includeMailLabel.font              = totalLabel.font;
                        _includeMailLabel.textScale         = totalLabel.textScale;
                        _includeMailLabel.textColor         = totalLabel.textColor;
                        _includeMailLabel.autoSize          = true;
                        _includeMailLabel.relativePosition  = new Vector3(_includeMailCheckBox.relativePosition.x + _includeMailCheckBox.size.x + 5f, _includeMailCheckBox.relativePosition.y + 2.5f);
                        _includeMailLabel.isVisible         = true;
                        _includeMailLabel.BringToFront();
                        _includeMailLabel.eventClicked += Label_eventClicked;

                        // create the patches
                        PostOfficeAIPatch.CreateGetColorPatch();
                        PostVanAIPatch.CreateGetColorPatch();
                        OutsideConnectionsInfoViewPanelPatch.CreateUpdatePanelPatch();

                        // legend colors are not initialized
                        _legendColorsInitialized = false;
                    }
                }
                else
                {
                    // show a nice message
                    ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel", true);
                    panel.SetMessage(
                        "Exclude Mail Mod",
                        "Industries DLC is not installed.  Having the Exclude Mail mod enabled without Industries DLC will not cause an error in the mod, but the functionality of the mod will not be available.",
                        false);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
예제 #27
0
        public static void ThrowErrorMsg(string content, bool error = false)
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Adjust Pathfinding", content, error);
        }
예제 #28
0
 private void OnLocationChanged(string url)
 {
     UpdateMainMenuVisible(false);
     ExceptionPanel.Hide();
 }
예제 #29
0
        // attempt to export whole roads (multisegment) but it doesn't work properly - not used
        public void ExportRoads()
        {
            Debug.Log("EXPORT ROADS");

            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
            string         msg   = "";

            if (!File.Exists("Files/import_export.conf"))
            {
                panel.SetMessage("Jan's mod", "no conf file provided!", false);
                return;
            }

            StreamReader confSr = File.OpenText("Files/import_export.conf");
            Dictionary <string, string> conf = new Dictionary <string, string>();

            while (!confSr.EndOfStream)
            {
                string[] keyVal = confSr.ReadLine().Split(':');
                if (keyVal.Length == 2)
                {
                    conf.Add(keyVal[0], keyVal[1]);
                }
            }

            double centerLat = double.Parse(conf["CenterLatitude"]);
            double centerLon = double.Parse(conf["CenterLongitude"]);

            WGS84_UTM convertor  = new WGS84_UTM(null);
            UTMResult centerUTM  = convertor.convertLatLngToUtm(centerLat, centerLon);
            string    ZoneLetter = "S";

            if (centerLat > 0)
            {
                ZoneLetter = "N";
            }

            string columns = "Id,Name,Geometry";

            var a_type     = typeof(NetSegment);
            var properties = a_type.GetProperties();

            foreach (var prop in properties)
            {
                columns = columns + string.Format(",{0}", prop.Name);
            }

            List <string> txtLines = new List <string>
            {
                columns
            };

            NetManager net_manager = NetManager.instance;

            NetSegment[] segments = net_manager.m_segments.m_buffer;
            Dictionary <string, List <NetSegment> > roadsCs = new Dictionary <string, List <NetSegment> >();

            for (int i = 0; i < segments.Length; i++)
            {
                var a_seg = segments[i];
                if (a_seg.Info.ToString().Contains("Highway"))
                {
                    continue;
                }
                var road_name = net_manager.GetSegmentName((ushort)i);
                if (road_name == null || road_name == "")
                {
                    continue; //road_name = "no name " + i.ToString();
                }
                if (!roadsCs.ContainsKey(road_name))
                {
                    roadsCs.Add(road_name, new List <NetSegment>());
                }
                roadsCs[road_name].Add(a_seg);
            }

            int cnt = 0;

            foreach (KeyValuePair <string, List <NetSegment> > road in roadsCs)
            {
                cnt++;
                var road_name = road.Key;
                //string debug_msg = "";
                //debug_msg += "road_name: " + road_name + " | ";
                bool   set_field_info = false;
                string field_info     = "";
                //Dictionary<ushort, ushort> start_end_nodes = new Dictionary<ushort, ushort>();
                Dictionary <string, HashSet <string> > segments_order = new Dictionary <string, HashSet <string> >();
                List <string> road_ends = new List <string>();
                foreach (var a_seg in road.Value)
                {
                    if (!set_field_info)
                    {
                        foreach (var prop in properties)
                        {
                            var prop_val = prop.GetValue(a_seg, null);
                            if (prop_val.ToString().Contains(","))
                            {
                                prop_val = "\"" + prop_val.ToString() + "\"";
                            }
                            field_info += string.Format(",{0}", prop_val);
                        }
                        set_field_info = true;
                    }

                    //debug_msg += "a_seg.m_buildIndex: " + a_seg.m_buildIndex.ToString() + " | ";
                    //debug_msg += "a_seg.m_startNode: " + a_seg.m_startNode.ToString() + ", a_seg.m_endNode: " + a_seg.m_endNode.ToString() + "; ";
                    //debug_msg += "\n";

                    var    startPos   = net_manager.m_nodes.m_buffer[a_seg.m_startNode].m_position;
                    var    startRwoX  = startPos.x + centerUTM.Easting;
                    var    startRwoY  = startPos.z + centerUTM.Northing;
                    LatLng startRwoLL = convertor.convertUtmToLatLng(startRwoX, startRwoY, centerUTM.ZoneNumber, ZoneLetter);

                    var    endPos   = net_manager.m_nodes.m_buffer[a_seg.m_endNode].m_position;
                    var    endRwoX  = endPos.x + centerUTM.Easting;
                    var    endRwoY  = endPos.z + centerUTM.Northing;
                    LatLng endRwoLL = convertor.convertUtmToLatLng(startRwoX, startRwoY, centerUTM.ZoneNumber, ZoneLetter);

                    string startLLid = string.Format("{0} {1}", startRwoLL.Lat, startRwoLL.Lng);
                    string endLLid   = string.Format("{0} {1}", endRwoLL.Lat, endRwoLL.Lng);

                    if (!segments_order.ContainsKey(startLLid))
                    {
                        segments_order[startLLid] = new HashSet <string>();
                        segments_order[startLLid].Add(startLLid);
                        segments_order[startLLid].Add(endLLid);
                        road_ends.Add(startLLid);
                    }
                    else
                    {
                        segments_order[startLLid].Add(startLLid);
                        segments_order[startLLid].Add(endLLid);
                        road_ends.Remove(startLLid);
                    }

                    if (!segments_order.ContainsKey(endLLid))
                    {
                        segments_order[endLLid] = new HashSet <string>();
                        segments_order[endLLid].Add(startLLid);
                        segments_order[endLLid].Add(endLLid);
                        road_ends.Add(endLLid);
                    }
                    else
                    {
                        segments_order[endLLid].Add(startLLid);
                        segments_order[endLLid].Add(endLLid);
                        road_ends.Remove(endLLid);
                    }

                    //if (start_end_nodes.Keys.Contains(a_seg.m_startNode) || start_end_nodes.Values.Contains(a_seg.m_endNode))
                    //    start_end_nodes[a_seg.m_endNode] = a_seg.m_startNode;
                    //else
                    //    start_end_nodes[a_seg.m_startNode] = a_seg.m_endNode;
                }

                string tmp_msg = "road ends(" + road_ends.Count.ToString() + "): ";
                foreach (var road_end in road_ends)
                {
                    tmp_msg += road_end + " | ";
                }
                tmp_msg += "segments_order (" + segments_order.Count.ToString() + "): ";
                foreach (KeyValuePair <string, HashSet <string> > seg_o in segments_order)
                {
                    tmp_msg += seg_o.Key + ": ";
                    foreach (var llid in seg_o.Value)
                    {
                        tmp_msg += llid + " | ";
                    }
                    tmp_msg += "\n";
                }


                panel.SetMessage("GeoSkylines", tmp_msg, false);
                return;



                //IEnumerable<ushort> keys_not_values = start_end_nodes.Keys.AsQueryable().Except(start_end_nodes.Values);
                //debug_msg += "Keys not in values: ";
                //foreach (var key in keys_not_values)
                //    Debug.Log(key);
                //foreach (var key in start_end_nodes.Keys)
                //{
                //    if (!start_end_nodes.Values.Contains(key))
                //        debug_msg += key.ToString();
                //}
                //debug_msg += "\n";
                //debug_msg += "Values not in Keys: ";
                //IEnumerable<ushort> values_not_keys = start_end_nodes.Values.AsQueryable().Except(start_end_nodes.Keys);
                //foreach (var val in values_not_keys)
                //    Debug.Log(val);
                //foreach (var val in start_end_nodes.Values)
                //{
                //    if (!start_end_nodes.Keys.Contains(val))
                //        debug_msg += val.ToString();
                //}
                //debug_msg += "\n";
                //ushort nodeId = res.First();



                //    ushort nodeId = start_end_nodes.Keys.First();
                //    foreach (var key in start_end_nodes.Keys)
                //    {
                //        if (!start_end_nodes.Values.Contains(key))
                //        {
                //            nodeId = key;
                //            break;
                //        }
                //    }
                //    List<LatLng> listOfPositions = new List<LatLng>();
                //    bool end = false;
                //    while (!end)
                //    {
                //        //Debug.Log("Is it going here?");
                //        var pos = net_manager.m_nodes.m_buffer[nodeId].m_position;
                //        var rwoX = pos.x + centerUTM.Easting;
                //        var rwoY = pos.z + centerUTM.Northing;
                //        LatLng rwoLL = convertor.convertUtmToLatLng(rwoX, rwoY, centerUTM.ZoneNumber, ZoneLetter);
                //        listOfPositions.Add(rwoLL);

                //        if (start_end_nodes.ContainsKey(nodeId))
                //            nodeId = start_end_nodes[nodeId];
                //        else
                //            end = true;
                //    }
                //    //Debug.Log("listOfPositions.Count: " + listOfPositions.Count.ToString());
                //    var roadLineWkt = createWkt(listOfPositions.ToArray());

                //    string rowTxt = string.Format("{0},{1},{2},{3}", cnt, road_name, roadLineWkt, field_info);
                //    txtLines.Add(rowTxt);
                //    //Debug.Log(debug_msg);
                //}

                //StreamWriter outputFile = new StreamWriter("Files/roads_cs.csv", false, new UTF8Encoding(true));
                //foreach (var lineTxt in txtLines)
                //{
                //    outputFile.WriteLine(lineTxt);
                //}
                //outputFile.Close();

                //panel.SetMessage("Jan's mod", msg, false);
            }
        }
        public void ThrowError(string message)
        {
            ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");

            panel.SetMessage("Segment Slope Smoother", message, false);
        }