static public void DisplayLLOnMouseClick() { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); if (!File.Exists("Files/import_export.conf")) { panel.SetMessage("GeoSkylines", "no conf file provided!", false); return; } string msg = ""; Vector3 screenMousePos = Input.mousePosition; Ray mouseRay = Camera.main.ScreenPointToRay(screenMousePos); var mousePos = GeoSkylinesTool.RaycastMouseLocation(mouseRay); 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"; } var rwoX = mousePos.x + centerUTM.Easting; var rwoY = mousePos.y + centerUTM.Northing; LatLng rwoLL = convertor.convertUtmToLatLng(rwoX, rwoY, centerUTM.ZoneNumber, ZoneLetter); msg += "Screen coordinates (x, y): "; msg += screenMousePos.ToString(); msg += "\n"; msg += "Game coordinates (x, z): "; msg += mousePos.ToString(); msg += "\n"; msg += "World coordinates (lon, lat): "; msg += rwoLL.Lng.ToString() + "," + rwoLL.Lat.ToString(); panel.SetMessage("Coordinates", msg, false); }
public bool ThrowError(string message) { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Road Tools", message, false); return(false); }
private void SuccessModal(string networkName_init) { string importFolder = Path.Combine(DataLocation.addonsPath, "Import"); ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Bulk Network Dump Successful", "Network Name: " + networkName_init + "\nNumber of Files Dumped: " + bulkDumpedSessionItems + "\nExported To: " + importFolder + "\n", false); }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKey(KeyCode.D)) { if (_actionProcessed) { return; } _actionProcessed = true; var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo; if (asset.m_netAI.GetType() == typeof(RoadAI)) { RoadAssetInfo myRoad = new RoadAssetInfo(); myRoad.ReadFromGame(asset); Utils.SaveAsset(myRoad, Path.Combine(Environment.modPath, $"{myRoad.name}.xml"), typeof(RoadAI)); } else if (asset.m_netAI.GetType() == typeof(TrainTrackAI)) { TrainTrackAssetInfo myRoad = new TrainTrackAssetInfo(); myRoad.ReadFromGame(asset); Utils.SaveAsset(myRoad, Path.Combine(Environment.modPath, $"{myRoad.name}.xml"), typeof(TrainTrackAI)); } ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Road Importer", $"Saved NetInfo {asset.name}", false); } else { // not both keys pressed: Reset processed state _actionProcessed = false; } }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKey(KeyCode.I)) { // cancel if they key input was already processed in a previous frame if (_processed) { return; } _processed = true; // compose message int treeCount = TreeManager.instance.m_treeCount; int maxTreeCount = TreeManager.MAX_TREE_COUNT; int buildingCount = BuildingManager.instance.m_buildingCount; int maxBuildingCount = BuildingManager.MAX_BUILDING_COUNT; string message = $"Trees: {treeCount} of {maxTreeCount}\nBuildings: {buildingCount} of {maxBuildingCount}"; // display message ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Item Statistics", message, false); } else { // not both keys pressed: Reset processed state _processed = false; } }
private void ShowError() { if (_errorModalOpened) { return; } string reason = "An error occurred while attempting to automatically subscribe to PatchLoader mod (no network connection?)"; string solution = "You can manually download the PatchLoader mod from github.com/CitiesSkylinesMods/PatchLoader/releases"; if (PlatformService.platformType != PlatformType.Steam) { reason = "Patch Loader mod could not be installed automatically because you are using a platform other than Steam."; } else if (PluginManager.noWorkshop) { reason = "Patch Loader mod could not be installed automatically because you are playing in --noWorkshop mode!"; solution = "Restart without --noWorkshop or manually download the Harmony mod from github.com/CitiesSkylinesMods/PatchLoader/releases"; } else if (!PlatformService.workshop.IsAvailable()) { reason = "Patch Loader mod could not be installed automatically because the Steam workshop is not available (no network connection?)"; } string message = $"FPS Booster require the dependency 'Patch Loader mod' to work correctly!\n\n{reason}\n\n{solution}"; ExceptionPanel exceptionPanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); exceptionPanel.SetMessage("Missing dependency: Patch Loader mod", message, false); exceptionPanel.component.Focus(); }
//future refactor here with other methods? public static void ShowErrorWindow(string header, string message) { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage(header, message, false); panel.GetComponentInChildren <UISprite>().spriteName = "IconError"; }
private void SuccessModal() { string importFolder = Path.Combine(DataLocation.addonsPath, "Import"); ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage(propType + " Prop Dump Successful", "Number of Files Dumped: " + propsDumped + "\nExported To: " + importFolder + "\n", false); }
// called when level is loaded public void OnLevelLoaded(LoadMode mode) { // loads texture container if (!Utils.LoadTextures()) { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel", true); panel.SetMessage("CSUR Loader", "Road texture not found. This indicates that " + $"the asset containing textures for CSUR roads are not loaded into the game. " + $"Please check if the file CSURTextureContainer.crp is present in the workshop" + $"folder for CSUR Loader.", true); return; } OptionUI.LoadSetting(); for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++) { NetInfo asset = PrefabCollection <NetInfo> .GetLoaded(i); if (Utils.IsCSUR(asset)) { Utils.ApplyTexture(asset); Utils.SetOutsideConnection(asset); Utils.ApplyGeneralSkins(asset); if (Utils.IsTwoWayCSUR(asset)) { Utils.ApplyIntersectionSkins(asset); } Utils.SetColor(asset, RoadSkins.roadColor); if (Utils.IsCSURDerivative(asset)) { Utils.LinkDerivative(asset); } else { Utils.LinkBridgeMode(asset); } } else if (asset != null && OptionUI.changeAllRoadColor) { if (asset.m_netAI is RoadAI) { //Debug.Log("Process color change for " + asset.name.ToString()); Utils.SetColor(asset, RoadSkins.roadColor); } } } RoadSkins.SetSidewalkPillars(); //Change All color RoadSkins.ChangeBuiltRoadColor(); //Refresh networks to apply skin change RoadSkins.RefreshNetworks(); if (Utils.LOAD_LOD) { NetManager.instance.RebuildLods(); } OptionUI.levelLoaded = true; }
public override void OnLevelLoaded(LoadMode mode) { // do base processing base.OnLevelLoaded(mode); try { // check for new or loaded game if (mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario || mode == LoadMode.LoadGame) { // determine if Exclude Mail mod is enabled foreach (PluginManager.PluginInfo mod in PluginManager.instance.GetPluginsInfo()) { // ignore builtin mods and camera script if (!mod.isBuiltin && !mod.isCameraScript) { // check against the Exclude Mail workshop ID if (mod.publishedFileID.AsUInt64 == 2093019121) { if (mod.isEnabled) { // create dialog panel ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage( "Enhanced Outside Connections View", "The Enhanced Outside Connections View mod supersedes the Exclude Mail mod. \n\n" + "Please unsubscribe from the Exclude Mail mod.", false); // do not initialize this mod return; } // found it, but not enabled break; } } } // initialize user interface if (!EOCVUserInterface.Initialize()) { return; } // create the Harmony patches if (!HarmonyPatcher.CreatePatches()) { return; } } } catch (Exception ex) { Debug.LogException(ex); } }
private void ShowInfoAboutRestart() { ExceptionPanel exceptionPanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); exceptionPanel.SetMessage( title: "TM:PE Game restart required", message: "List of mods changed (deleted or unsubscribed).\n" + "Please restart the game to complete operation", error: false); }
/// <summary> /// Export the configuration file /// </summary> public static void ExportConfig() { config.Serialize(m_fileName); DebugUtils.Log("Configuration exported"); // display a message for the user in the panel ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Advanced Vehicle Options", "Your configuration has been exported. \n\nThe configuration file can be found here:\n<Steam Install Path>/steamapps/common/\nCities_Skylines/AdvancedVehicleOptionsUID.xml", false); }
public void OnLevelLoaded(LoadMode mode) { NLT_Utils.Log("Loaded map successfully."); // create dialog panel ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); // display a message for the user in the panel panel.SetMessage("Network Lane Tool", "Stuff", false); UI = ToolsModifierControl.toolController.gameObject.AddComponent <NLT_UIBase>(); }
// called when level is loaded public void OnLevelLoaded(LoadMode mode) { Environment.CreateJobs(Path.Combine(Environment.modPath, "imports.txt")); string message = $"Found {Environment.jobs.Length} items to import, press CTRL+L to start\n"; message += File.ReadAllText(Path.Combine(Environment.modPath, "imports.txt")); ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Road Importer", message, false); }
private 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++; //Debug.Log($"#{nodeId}: {node.Info.GetAI()} {node.m_position}\n{node.Info.m_class} ({node.Info.m_class.m_service}.{node.Info.m_class.m_subService})"); 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); }
//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); }
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"); } }
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); }
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); }
/// <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); } }
// 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); } }
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)); } }
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); } }; }
// 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 LoadConfiguration() { if (!File.Exists("Files/import_export.conf")) { panel.SetMessage("GeoSkylines", "No configuration file provided!", false); confloaded = false; } 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]); } } foreach (KeyValuePair <string, string> a_conf in conf) { var val = a_conf.Value; var key = a_conf.Key; if (key == "MapName") { mapName = val; } else if (key == "CenterLatitude") { double.TryParse(val, out centerLat); } else if (key == "CenterLongitude") { double.TryParse(val, out centerLon); } else if (key == "ExportCoordsBox") { var coords = val.Split(',').Select(p => p.Trim()).ToArray(); if (coords.Length == 4) { float exportXMin_tmp; float exportYMin_tmp; float exportXMax_tmp; float exportYMax_tmp; float.TryParse(coords[0], out exportXMin_tmp); if (exportXMin_tmp != 0) { exportXMin = exportXMin_tmp; } float.TryParse(coords[1], out exportYMin_tmp); if (exportYMin_tmp != 0) { exportYMin = exportYMin_tmp; } float.TryParse(coords[2], out exportXMax_tmp); if (exportXMax_tmp != 0) { exportXMax = exportXMax_tmp; } float.TryParse(coords[3], out exportYMax_tmp); if (exportYMax_tmp != 0) { exportYMax = exportYMax_tmp; } } } } confloaded = true; }
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); }
public static void ThrowErrorMsg(string content, bool error = false) { ExceptionPanel panel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); panel.SetMessage("Adjust Pathfinding", content, error); }
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); }
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); }