void Update() { if (!initializedBuildingsPanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); buildingsBufferRefChain = new ReferenceChain(); buildingsBufferRefChain = buildingsBufferRefChain.Add(BuildingManager.instance.gameObject); buildingsBufferRefChain = buildingsBufferRefChain.Add(BuildingManager.instance); buildingsBufferRefChain = buildingsBufferRefChain.Add(typeof(BuildingManager).GetField("m_buildings")); buildingsBufferRefChain = buildingsBufferRefChain.Add(typeof(Array16 <Building>).GetField("m_buffer")); zonedBuildingInfoPanel = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <ZonedBuildingWorldInfoPanel>(); if (zonedBuildingInfoPanel != null) { AddZonedBuildingPanelControls(); initializedBuildingsPanel = true; } } if (zonedBuildingInfoPanel.component.isVisible) { InstanceID instance = Util.GetPrivate <InstanceID>(zonedBuildingInfoPanel, "m_InstanceID"); var building = BuildingManager.instance.m_buildings.m_buffer[instance.Building]; zonedBuildingAssetNameLabel.text = "AssetName: " + building.Info.name; } }
public void Update() { var middleButtonState = MouseButtonState.None; if (Input.GetMouseButtonDown(2)) { middleButtonState = MouseButtonState.Pressed; } else if (Input.GetMouseButtonUp(2)) { middleButtonState = MouseButtonState.Released; } else if (Input.GetMouseButton(2)) { middleButtonState = MouseButtonState.Held; } modalUI.Update(IsMouseOverWindow(), middleButtonState); if (SettingsUI.ConsoleKey.IsKeyUp()) { console.Visible = !console.Visible; } else if (SettingsUI.MainWindowKey.IsKeyUp()) { Visible = !Visible; } else if (SettingsUI.SceneExplorerKey.IsKeyUp()) { SceneExplorer.Visible = !SceneExplorer.Visible; if (SceneExplorer.Visible) { SceneExplorer.RefreshSceneRoots(); } } else if (SettingsUI.DebugRendererKey.IsKeyUp()) { if (!debugRenderer) { debugRenderer = FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>(); } debugRenderer.DrawDebugInfo = !debugRenderer.DrawDebugInfo; } else if (SettingsUI.WatchesKey.IsKeyUp()) { Watches.Visible = !Watches.Visible; } else if (SettingsUI.ScriptEditorKey.IsKeyUp()) { scriptEditor.Visible = !scriptEditor.Visible; } }
private void LoadConfig() { Config = ModConfiguration.Deserialize(ConfigPath); if (Config == null) { Config = new ModConfiguration(); SaveConfig(); } console?.MoveResize(Config.ConsoleRect); Watches.MoveResize(Config.WatchesRect); SceneExplorer.MoveResize(Config.SceneExplorerRect); scriptEditor.ReloadProjectWorkspace(); }
public void Initialize() { if (!loggingInitialized) { Application.logMessageReceivedThreaded += OnApplicationLogMessageReceivedThreaded; loggingInitialized = true; } sceneExplorer = gameObject.AddComponent <SceneExplorer>(); watches = gameObject.AddComponent <Watches>(); colorPicker = gameObject.AddComponent <ColorPicker>(); scriptEditor = gameObject.AddComponent <ScriptEditor>(); scriptEditor.visible = false; sceneExplorerColorConfig = gameObject.AddComponent <SceneExplorerColorConfig>(); LoadConfig(); if (config.useModToolsConsole) { console = gameObject.AddComponent <Console>(); } }
private void Initialize() { if (!initializedZonedBuildingsPanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); buildingsBufferRefChain = new ReferenceChain() .Add(BuildingManager.instance.gameObject) .Add(BuildingManager.instance) .Add(typeof(BuildingManager).GetField("m_buildings")) .Add(typeof(Array16 <Building>).GetField("m_buffer")); zonedBuildingInfoPanel = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <ZonedBuildingWorldInfoPanel>(); if (zonedBuildingInfoPanel != null) { AddBuildingPanelControls(zonedBuildingInfoPanel, out zonedBuildingAssetNameLabel, out zonedBuildingShowExplorerButton, new Vector3(-8.0f, 100.0f, 0.0f), out zonedBuildingDumpMeshTextureButton, new Vector3(-8.0f, 132.0f, 0.0f) ); initializedZonedBuildingsPanel = true; } } if (!initializedServiceBuildingsPanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); serviceBuildingInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>(); if (serviceBuildingInfoPanel != null) { AddBuildingPanelControls(serviceBuildingInfoPanel, out serviceBuildingAssetNameLabel, out serviceBuildingShowExplorerButton, new Vector3(-8.0f, 175.0f, 0.0f), out serviceBuildingDumpMeshTextureButton, new Vector3(-8.0f, 200.0f, 0.0f) ); initializedServiceBuildingsPanel = true; } } if (!initializedCitizenVehiclePanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); vehiclesBufferRefChain = new ReferenceChain() .Add(VehicleManager.instance.gameObject) .Add(VehicleManager.instance) .Add(typeof(VehicleManager).GetField("m_vehicles")) .Add(typeof(Array16 <Vehicle>).GetField("m_buffer")); vehiclesParkedBufferRefChain = new ReferenceChain() .Add(VehicleManager.instance.gameObject) .Add(VehicleManager.instance) .Add(typeof(VehicleManager).GetField("m_parkedVehicles")) .Add(typeof(Array16 <VehicleParked>).GetField("m_buffer")); citizenVehicleInfoPanel = GameObject.Find("(Library) CitizenVehicleWorldInfoPanel").GetComponent <CitizenVehicleWorldInfoPanel>(); if (citizenVehicleInfoPanel != null) { AddVehiclePanelControls( citizenVehicleInfoPanel, out citizenVehicleAssetNameLabel, out citizenVehicleShowExplorerButton, out citizenVehicleDumpTextureMeshButton ); initializedCitizenVehiclePanel = true; } } if (!initializedCityServiceVehiclePanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); cityServiceVehicleInfoPanel = GameObject.Find("(Library) CityServiceVehicleWorldInfoPanel") .GetComponent <CityServiceVehicleWorldInfoPanel>(); if (cityServiceVehicleInfoPanel != null) { AddVehiclePanelControls( cityServiceVehicleInfoPanel, out cityServiceVehicleAssetNameLabel, out cityServiceVehicleShowExplorerButton, out cityServiceVehicleDumpTextureMeshButton); initializedCityServiceVehiclePanel = true; } } if (!initializedPublicTransportVehiclePanel) { sceneExplorer = FindObjectOfType <SceneExplorer>(); publicTransportVehicleInfoPanel = GameObject.Find("(Library) PublicTransportVehicleWorldInfoPanel") .GetComponent <PublicTransportVehicleWorldInfoPanel>(); if (publicTransportVehicleInfoPanel != null) { AddVehiclePanelControls( publicTransportVehicleInfoPanel, out publicTransportVehicleAssetNameLabel, out publicTransportVehicleShowExplorerButton, out publicTransportVehicleDumpTextureMeshButton); initializedPublicTransportVehiclePanel = true; } } if (!initializedAnimalPanel) { citizenInstancesBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_instances")) .Add(typeof(Array16 <CitizenInstance>).GetField("m_buffer")); citizensBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_citizens")) .Add(typeof(Array32 <Citizen>).GetField("m_buffer")); citizensUnitsBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_units")) .Add(typeof(Array32 <CitizenUnit>).GetField("m_buffer")); sceneExplorer = FindObjectOfType <SceneExplorer>(); animalInfoPanel = GameObject.Find("(Library) AnimalWorldInfoPanel").GetComponent <AnimalWorldInfoPanel>(); if (animalInfoPanel != null) { AddCitizenPanelControls(animalInfoPanel, out animalAssetNameLabel, out animalShowExplorerButton, new Vector3(-8.0f, 65.0f, 0.0f), out animalShowInstanceButton, new Vector3(-8.0f, 90.0f, 0.0f), out animalShowUnitButton, new Vector3(-8.0f, 115.0f, 0.0f) ); initializedAnimalPanel = true; } } if (!initializedCitizenPanel) { citizenInstancesBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_instances")) .Add(typeof(Array16 <CitizenInstance>).GetField("m_buffer")); citizensBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_citizens")) .Add(typeof(Array32 <Citizen>).GetField("m_buffer")); citizensUnitsBufferRefChain = new ReferenceChain() .Add(CitizenManager.instance.gameObject) .Add(CitizenManager.instance) .Add(typeof(CitizenManager).GetField("m_units")) .Add(typeof(Array32 <CitizenUnit>).GetField("m_buffer")); sceneExplorer = FindObjectOfType <SceneExplorer>(); citizenInfoPanel = GameObject.Find("(Library) CitizenWorldInfoPanel").GetComponent <HumanWorldInfoPanel>(); if (citizenInfoPanel != null) { AddCitizenPanelControls(citizenInfoPanel, out citizenAssetNameLabel, out citizenShowExplorerButton, new Vector3(-8.0f, 110.0f, 0.0f), out citizenShowInstanceButton, new Vector3(-8.0f, 135.0f, 0.0f), out citizenShowUnitButton, new Vector3(-8.0f, 160.0f, 0.0f) ); initializedCitizenPanel = true; } } }
protected override void DrawWindow() { var newUseConsole = GUILayout.Toggle(Config.UseModToolsConsole, " Use ModTools console"); if (newUseConsole != Config.UseModToolsConsole) { Config.UseModToolsConsole = newUseConsole; if (Config.UseModToolsConsole) { console = gameObject.AddComponent <CustomConsole>(); Logger.SetCustomLogger(console); } else { Destroy(console); console = null; Logger.SetCustomLogger(null); } SaveConfig(); } GUILayout.BeginHorizontal(); GUILayout.Label("Console log level"); var newLogLevel = GUILayout.SelectionGrid(Config.LogLevel, new[] { "Log", "Warn", "Err", "None" }, 4); GUILayout.EndHorizontal(); if (newLogLevel != Config.LogLevel) { Config.LogLevel = newLogLevel; SaveConfig(); } var newLogExceptionsToConsole = GUILayout.Toggle(Config.LogExceptionsToConsole, " Log stack traces to console"); if (newLogExceptionsToConsole != Config.LogExceptionsToConsole) { Config.LogExceptionsToConsole = newLogExceptionsToConsole; SaveConfig(); } var newExtendGamePanels = GUILayout.Toggle(Config.ExtendGamePanels, " Game panel extensions"); if (newExtendGamePanels != Config.ExtendGamePanels) { Config.ExtendGamePanels = newExtendGamePanels; SaveConfig(); if (ToolManager.instance.m_properties.m_mode == ItemClass.Availability.Game) { var gamePanelExtender = gameObject.GetComponent <GamePanelExtension>(); if (Config.ExtendGamePanels) { if (gamePanelExtender == null) { gameObject.AddComponent <GamePanelExtension>(); } } else if (gamePanelExtender != null) { Destroy(gamePanelExtender); } } } if (debugRenderer == null) { debugRenderer = FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>(); } debugRenderer.DrawDebugInfo = GUILayout.Toggle( debugRenderer.DrawDebugInfo, $" Debug Renderer ({SettingsUI.DebugRendererKey})"); var customPrefabsObject = GUILayout.Toggle(Config.CustomPrefabsObject, " ModTools.CustomPrefabs Object"); if (customPrefabsObject != Config.CustomPrefabsObject) { Config.CustomPrefabsObject = customPrefabsObject; if (Config.CustomPrefabsObject) { CustomPrefabs.Bootstrap(); } else { CustomPrefabs.Revert(); } SaveConfig(); } var newSelectionTool = GUILayout.Toggle( Config.SelectionTool, $" Selection Tool ({SettingsUI.SelectionToolKey})"); if (newSelectionTool != Config.SelectionTool) { if (!newSelectionTool) { var tool = ToolsModifierControl.GetTool <SelectionTool>(); if (tool?.enabled == true) { ToolsModifierControl.SetTool <DefaultTool>(); } } Config.SelectionTool = newSelectionTool; SaveConfig(); } GUILayout.Space(Config.TreeIdentSpacing); if (GUILayout.Button($"Debug console ({SettingsUI.ConsoleKey})")) { if (console != null) { console.Visible = true; } else { var debugOutputPanel = GameObject.Find("(Library) DebugOutputPanel").GetComponent <DebugOutputPanel>(); debugOutputPanel.enabled = true; debugOutputPanel.GetComponent <UIPanel>().isVisible = true; } } if (GUILayout.Button($"Watches ({SettingsUI.WatchesKey})")) { Watches.Visible = !Watches.Visible; } if (GUILayout.Button($"Scene explorer ({SettingsUI.SceneExplorerKey})")) { SceneExplorer.Visible = !SceneExplorer.Visible; if (SceneExplorer.Visible) { SceneExplorer.RefreshSceneRoots(); } } if (GUILayout.Button($"Script editor ({SettingsUI.ScriptEditorKey})")) { scriptEditor.Visible = !scriptEditor.Visible; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Appearance settings")) { appearanceConfig.Visible = true; var windowRect = appearanceConfig.WindowRect; windowRect.position = WindowRect.position + new Vector2(32.0f, 32.0f); appearanceConfig.MoveResize(windowRect); } }
public void Initialize(SimulationManager.UpdateMode _updateMode) { updateMode = _updateMode; if (!loggingInitialized) { Application.logMessageReceived += (condition, trace, type) => { if (!logExceptionsToConsole) { return; } if (Instance.console != null) { Instance.console.AddMessage(String.Format("{0} ({1})", condition, trace), type, true); return; } if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert) { Log.Error(condition); } else if (type == LogType.Warning) { Log.Warning(condition); } else { Log.Message(condition); } }; loggingInitialized = true; } sceneExplorer = gameObject.AddComponent <SceneExplorer>(); watches = gameObject.AddComponent <Watches>(); colorPicker = gameObject.AddComponent <ColorPicker>(); sceneExplorerColorConfig = gameObject.AddComponent <SceneExplorerColorConfig>(); LoadConfig(); if (extendGamePanels && (updateMode == SimulationManager.UpdateMode.NewGame || updateMode == SimulationManager.UpdateMode.LoadGame)) { panelExtender = gameObject.AddComponent <GamePanelExtender>(); } if (useModToolsConsole) { console = gameObject.AddComponent <Console>(); } if (config.hookUnityLogging) { UnityLoggingHook.EnableHook(); } if (updateMode == SimulationManager.UpdateMode.Undefined && config.improvedWorkshopIntegration) { ImprovedWorkshopIntegration.Bootstrap(); } }