From f7f0aa9bbfb3e9ef1cea2de2911a7379645f02b3 Mon Sep 17 00:00:00 2001 From: AmazingAlek Date: Fri, 18 Dec 2020 21:41:04 +0100 Subject: [PATCH] v1: IoC, tests, new release pipeline, lots of cleanup/refactoring (#319) * IoC (inversion of control) container - mostly NOT newing up stuff manually, using an IoC container (Unity - not the game engine) for this. Want a new dependendy for your class? Just put it into your constructor, the container handles the rest. * Tests. Not very thorough yet, but laid the groundwork. * Abstractions for processes, Unity Application class and GameObject creation. Needed for testing, as there's no way to run Unity code from outside of Unity, and for mocking Process calls. * Moved all code to src folder. Tests are in tests folder. * Moved sample mods from OWML.SampleMods to SampleMods. * Dependencies that aren't on NuGet.org are moved to lib folders. * Allowing old OW versions. Just outputting nicer errors instead of quitting. * New Utils project. Contains the container, TypeExtensions (moved from Events) and JsonHelper (moved from ModHelper). * Internal NuGet package (OW and Unity dlls for building OWML on GitHub) is moved to new private GitHub repo and has a new GitHub pipeline. * ModHelper project creates the nuget package - no more OWML.Nuget project. * Launcher project + pipeline creates the release zip - no more createrelease.bat. * New GitHub pipeline for OWML - no more Azure DevOps. * Should still be backwards compatible --- .github/workflows/main.yml | 116 +++++ .gitignore | 1 + OWML.Common/Constants.cs | 15 - OWML.Common/Events.cs | 16 - OWML.Common/IHarmonyHelper.cs | 20 - OWML.Common/IModAsset.cs | 14 - OWML.Common/IModAssets.cs | 13 - OWML.Common/IModBehaviour.cs | 14 - OWML.Common/IModConfig.cs | 16 - OWML.Common/IModConsole.cs | 13 - OWML.Common/IModData.cs | 16 - OWML.Common/IModEvents.cs | 19 - OWML.Common/IModFinder.cs | 9 - OWML.Common/IModHelper.cs | 20 - OWML.Common/IModInputCombination.cs | 19 - OWML.Common/IModInputHandler.cs | 21 - OWML.Common/IModInputTextures.cs | 10 - OWML.Common/IModInteraction.cs | 14 - OWML.Common/IModLogger.cs | 8 - OWML.Common/IModManifest.cs | 22 - OWML.Common/IModPlayerEvents.cs | 9 - OWML.Common/IModSceneEvents.cs | 10 - OWML.Common/IModSocket.cs | 8 - OWML.Common/IModSocketMessage.cs | 10 - OWML.Common/IModStorage.cs | 8 - OWML.Common/IModUnityEvents.cs | 15 - OWML.Common/IOwmlConfig.cs | 14 - OWML.Common/Menus/IModButton.cs | 26 -- OWML.Common/Menus/IModButtonBase.cs | 26 -- OWML.Common/Menus/IModComboInput.cs | 9 - OWML.Common/Menus/IModConfigMenu.cs | 8 - OWML.Common/Menus/IModConfigMenuBase.cs | 11 - OWML.Common/Menus/IModFieldInput.cs | 7 - OWML.Common/Menus/IModInput.cs | 10 - OWML.Common/Menus/IModInputBase.cs | 15 - .../Menus/IModInputCombinationElement.cs | 10 - .../Menus/IModInputCombinationElementMenu.cs | 10 - OWML.Common/Menus/IModInputCombinationMenu.cs | 17 - OWML.Common/Menus/IModInputMenu.cs | 10 - OWML.Common/Menus/IModLayoutButton.cs | 7 - OWML.Common/Menus/IModLayoutManager.cs | 18 - OWML.Common/Menus/IModMainMenu.cs | 15 - OWML.Common/Menus/IModMenu.cs | 65 --- OWML.Common/Menus/IModMenuWithSelectables.cs | 9 - OWML.Common/Menus/IModMenus.cs | 11 - OWML.Common/Menus/IModMessagePopup.cs | 10 - OWML.Common/Menus/IModNumberInput.cs | 8 - OWML.Common/Menus/IModOWMenu.cs | 9 - OWML.Common/Menus/IModPauseMenu.cs | 12 - OWML.Common/Menus/IModPopupManager.cs | 13 - OWML.Common/Menus/IModPopupMenu.cs | 28 -- OWML.Common/Menus/IModPromptButton.cs | 8 - OWML.Common/Menus/IModSelectorInput.cs | 10 - OWML.Common/Menus/IModSeparator.cs | 12 - OWML.Common/Menus/IModSliderInput.cs | 12 - OWML.Common/Menus/IModTabMenu.cs | 10 - OWML.Common/Menus/IModTabbedMenu.cs | 19 - OWML.Common/Menus/IModTextInput.cs | 8 - OWML.Common/Menus/IModToggleInput.cs | 11 - OWML.Common/Menus/IModsMenu.cs | 9 - OWML.Common/Menus/InputType.cs | 9 - OWML.Common/MessageType.cs | 13 - OWML.Common/OWML.Common.csproj | 136 ------ OWML.GameFinder/BaseFinder.cs | 30 -- OWML.GameFinder/CurrentPathFinder.cs | 22 - OWML.GameFinder/DefaultLocationFinder.cs | 37 -- OWML.GameFinder/EpicGameFinder.cs | 55 --- OWML.GameFinder/PathFinder.cs | 32 -- OWML.GameFinder/PromptGameFinder.cs | 24 -- OWML.GameFinder/SteamGameFinder.cs | 62 --- OWML.Launcher/App.config | 6 - OWML.Launcher/App.cs | 209 --------- OWML.Launcher/OWML.DefaultConfig.json | 5 - OWML.Launcher/OWML.Manifest.json | 9 - OWML.Launcher/Program.cs | 80 ---- OWML.Launcher/SocketListener.cs | 123 ------ OWML.Logging/ConsoleUtils.cs | 33 -- OWML.Logging/ModConsole.cs | 32 -- OWML.Logging/ModLogger.cs | 40 -- OWML.Logging/ModSocket.cs | 41 -- OWML.Logging/ModSocketMessage.cs | 20 - OWML.Logging/ModSocketOutput.cs | 81 ---- OWML.Logging/OutputWriter.cs | 30 -- OWML.Logging/UnityLogger.cs | 43 -- OWML.ModHelper.Assets/AudioAsset.cs | 8 - OWML.ModHelper.Assets/MeshAsset.cs | 8 - OWML.ModHelper.Assets/ModAsset.cs | 34 -- OWML.ModHelper.Assets/ModAssets.cs | 185 -------- OWML.ModHelper.Assets/ObjImporter.cs | 256 ----------- OWML.ModHelper.Assets/ObjectAsset.cs | 31 -- OWML.ModHelper.Assets/TextureAsset.cs | 8 - OWML.ModHelper.Assets/packages.config | 4 - OWML.ModHelper.Events/HarmonyHelper.cs | 143 ------- OWML.ModHelper.Events/ModEvents.cs | 140 ------ OWML.ModHelper.Events/ModPlayerEvents.cs | 25 -- OWML.ModHelper.Events/ModSceneEvents.cs | 28 -- OWML.ModHelper.Events/ModUnityEvents.cs | 65 --- OWML.ModHelper.Events/Patches.cs | 33 -- OWML.ModHelper.Events/TypeExtensions.cs | 77 ---- OWML.ModHelper.Input/BindingChangeListener.cs | 56 --- OWML.ModHelper.Input/InputInterceptor.cs | 74 ---- OWML.ModHelper.Input/ModCommandListener.cs | 109 ----- OWML.ModHelper.Input/ModCommandUpdater.cs | 24 -- OWML.ModHelper.Input/ModInputCombination.cs | 70 --- OWML.ModHelper.Input/ModInputHandler.cs | 400 ----------------- OWML.ModHelper.Input/ModInputLibrary.cs | 167 -------- OWML.ModHelper.Input/ModInputTextures.cs | 60 --- OWML.ModHelper.Input/RegistrationCode.cs | 10 - .../InterfaceProxyBuilder.cs | 100 ----- .../InterfaceProxyFactory.cs | 45 -- OWML.ModHelper.Interaction/ModInteraction.cs | 103 ----- OWML.ModHelper.Menus/ModButtonBase.cs | 98 ----- OWML.ModHelper.Menus/ModComboInput.cs | 102 ----- OWML.ModHelper.Menus/ModConfigMenu.cs | 61 --- OWML.ModHelper.Menus/ModConfigMenuBase.cs | 162 ------- OWML.ModHelper.Menus/ModFieldInput.cs | 20 - OWML.ModHelper.Menus/ModInput.cs | 63 --- .../ModInputCombinationElement.cs | 185 -------- .../ModInputCombinationElementMenu.cs | 217 ---------- .../ModInputCombinationMenu.cs | 108 ----- .../ModInputCombinationPopup.cs | 195 --------- OWML.ModHelper.Menus/ModInputMenu.cs | 96 ----- OWML.ModHelper.Menus/ModLayoutButton.cs | 32 -- OWML.ModHelper.Menus/ModLayoutManager.cs | 126 ------ OWML.ModHelper.Menus/ModMainMenu.cs | 60 --- OWML.ModHelper.Menus/ModMenu.cs | 367 ---------------- .../ModMenuWithSelectables.cs | 189 -------- OWML.ModHelper.Menus/ModMenus.cs | 51 --- OWML.ModHelper.Menus/ModMessagePopup.cs | 68 --- OWML.ModHelper.Menus/ModNumberInput.cs | 52 --- OWML.ModHelper.Menus/ModOptionsMenu.cs | 94 ---- OWML.ModHelper.Menus/ModPauseMenu.cs | 31 -- OWML.ModHelper.Menus/ModPopupInput.cs | 70 --- OWML.ModHelper.Menus/ModPopupManager.cs | 81 ---- OWML.ModHelper.Menus/ModPopupMenu.cs | 112 ----- OWML.ModHelper.Menus/ModPromptButton.cs | 59 --- OWML.ModHelper.Menus/ModSelectorInput.cs | 68 --- OWML.ModHelper.Menus/ModSeparator.cs | 87 ---- OWML.ModHelper.Menus/ModSliderInput.cs | 82 ---- OWML.ModHelper.Menus/ModTabMenu.cs | 64 --- OWML.ModHelper.Menus/ModTemporaryPopup.cs | 52 --- OWML.ModHelper.Menus/ModTextInput.cs | 51 --- OWML.ModHelper.Menus/ModTitleButton.cs | 75 ---- OWML.ModHelper.Menus/ModToggleInput.cs | 50 --- OWML.ModHelper.Menus/ModUIStyleApplier.cs | 85 ---- OWML.ModHelper.Menus/ModsMenu.cs | 164 ------- OWML.ModHelper.Menus/OwmlConfigMenu.cs | 46 -- OWML.ModHelper/CommandLineArguments.cs | 23 - OWML.ModHelper/DontDestroyOnLoad.cs | 12 - OWML.ModHelper/JsonHelper.cs | 26 -- OWML.ModHelper/ModBehaviour.cs | 37 -- OWML.ModHelper/ModConfig.cs | 98 ----- OWML.ModHelper/ModHelper.cs | 41 -- OWML.ModHelper/ModManifest.cs | 51 --- OWML.ModHelper/ModStorage.cs | 27 -- OWML.ModHelper/OwmlBehaviour.cs | 19 - OWML.ModHelper/OwmlConfig.cs | 32 -- OWML.ModLoader/ModData.cs | 144 ------- OWML.ModLoader/ModFinder.cs | 46 -- OWML.ModLoader/ModLoader.cs | 52 --- OWML.ModLoader/ModSorter.cs | 104 ----- OWML.ModLoader/Owo.cs | 145 ------- OWML.Nuget/OWML.Nuget.csproj | 85 ---- OWML.Nuget/Properties/AssemblyInfo.cs | 35 -- OWML.Patcher/BinaryPatcher.cs | 175 -------- OWML.Patcher/GameVersionReader.cs | 26 -- OWML.Patcher/OWPatcher.cs | 141 ------ OWML.Patcher/VRFilePatcher.cs | 75 ---- OWML.Patcher/VrPatcher.cs | 58 --- .../OWML.EnableDebugMode/EnableDebugMode.cs | 117 ----- .../OWML.EnableDebugMode/default-config.json | 45 -- .../OWML.EnableDebugMode/manifest.json | 10 - .../OWML.LoadCustomAssets/LoadCustomAssets.cs | 184 -------- .../OWML.LoadCustomAssets/SaveFile.cs | 10 - .../OWML.LoadCustomAssets/config.json | 44 -- .../OWML.LoadCustomAssets/default-config.json | 57 --- .../OWML.LoadCustomAssets/manifest.json | 10 - .../OWML.LoadCustomAssets/packages.config | 5 - .../OWML.LoadCustomAssets/savefile.json | 3 - OWML.sln | 168 +++++--- Readme.md | 5 +- createrelease.bat | 48 --- nuget.config | 14 + src/OWML.Abstractions/ApplicationHelper.cs | 16 + src/OWML.Abstractions/GameObjectHelper.cs | 18 + .../OWML.Abstractions.csproj | 72 ++-- src/OWML.Abstractions/ProcessHelper.cs | 14 + .../Properties/AssemblyInfo.cs | 35 ++ .../OWML.Abstractions}/packages.config | 2 +- src/OWML.Common/Constants.cs | 23 + src/OWML.Common/DontDestroyOnLoad.cs | 10 + src/OWML.Common/Events.cs | 25 ++ .../Interfaces/IApplicationHelper.cs | 14 + src/OWML.Common/Interfaces/IArgumentHelper.cs | 13 + src/OWML.Common/Interfaces/IBinaryPatcher.cs | 17 + .../Interfaces/IBindingChangeListener.cs | 7 + .../Interfaces/IGameObjectHelper.cs | 13 + .../Interfaces/IGameVersionHandler.cs | 7 + .../Interfaces/IGameVersionReader.cs | 7 + src/OWML.Common/Interfaces/IHarmonyHelper.cs | 20 + .../Interfaces/IInterfaceProxyFactory.cs | 7 + src/OWML.Common/Interfaces/IModAsset.cs | 14 + src/OWML.Common/Interfaces/IModAssets.cs | 17 + src/OWML.Common/Interfaces/IModBehaviour.cs | 21 + src/OWML.Common/Interfaces/IModConfig.cs | 17 + src/OWML.Common/Interfaces/IModConsole.cs | 14 + src/OWML.Common/Interfaces/IModData.cs | 23 + src/OWML.Common/Interfaces/IModEvents.cs | 21 + src/OWML.Common/Interfaces/IModFinder.cs | 9 + src/OWML.Common/Interfaces/IModHelper.cs | 31 ++ .../Interfaces/IModInputCombination.cs | 26 ++ .../Interfaces/IModInputHandler.cs | 33 ++ .../Interfaces/IModInputTextures.cs | 13 + src/OWML.Common/Interfaces/IModInteraction.cs | 19 + src/OWML.Common/Interfaces/IModLogger.cs | 9 + src/OWML.Common/Interfaces/IModManifest.cs | 31 ++ .../Interfaces/IModPlayerEvents.cs | 11 + src/OWML.Common/Interfaces/IModSceneEvents.cs | 11 + src/OWML.Common/Interfaces/IModSocket.cs | 9 + .../Interfaces/IModSocketMessage.cs | 13 + src/OWML.Common/Interfaces/IModSorter.cs | 9 + src/OWML.Common/Interfaces/IModStorage.cs | 9 + src/OWML.Common/Interfaces/IModUnityEvents.cs | 19 + src/OWML.Common/Interfaces/IOWPatcher.cs | 7 + src/OWML.Common/Interfaces/IObjImporter.cs | 9 + src/OWML.Common/Interfaces/IOwmlConfig.cs | 25 ++ src/OWML.Common/Interfaces/IPathFinder.cs | 7 + src/OWML.Common/Interfaces/IProcessHelper.cs | 9 + src/OWML.Common/Interfaces/ISectorInfo.cs | 11 + src/OWML.Common/Interfaces/IUnityLogger.cs | 7 + src/OWML.Common/Interfaces/IVRFilePatcher.cs | 7 + src/OWML.Common/Interfaces/IVRPatcher.cs | 7 + .../Interfaces/Menus/IModButton.cs | 36 ++ .../Interfaces/Menus/IModButtonBase.cs | 33 ++ .../Interfaces/Menus/IModComboInput.cs | 11 + .../Interfaces/Menus/IModConfigMenu.cs | 9 + .../Interfaces/Menus/IModConfigMenuBase.cs | 16 + .../Interfaces/Menus/IModFieldInput.cs | 7 + src/OWML.Common/Interfaces/Menus/IModInput.cs | 11 + .../Interfaces/Menus/IModInputBase.cs | 21 + .../Menus/IModInputCombinationElement.cs | 13 + .../Menus/IModInputCombinationElementMenu.cs | 19 + .../Menus/IModInputCombinationMenu.cs | 22 + .../Interfaces/Menus/IModInputMenu.cs | 17 + .../Interfaces/Menus/IModLayoutButton.cs | 7 + .../Interfaces/Menus/IModLayoutManager.cs | 24 ++ .../Interfaces/Menus/IModMainMenu.cs | 21 + src/OWML.Common/Interfaces/Menus/IModMenu.cs | 92 ++++ .../Menus/IModMenuWithSelectables.cs | 9 + src/OWML.Common/Interfaces/Menus/IModMenus.cs | 15 + .../Interfaces/Menus/IModMessagePopup.cs | 17 + .../Interfaces/Menus/IModNumberInput.cs | 9 + .../Interfaces/Menus/IModOWMenu.cs | 11 + .../Interfaces/Menus/IModPauseMenu.cs | 15 + .../Interfaces/Menus/IModPopupManager.cs | 14 + .../Interfaces/Menus/IModPopupMenu.cs | 36 ++ .../Interfaces/Menus/IModPromptButton.cs | 9 + .../Interfaces/Menus/IModSelectorInput.cs | 13 + .../Interfaces/Menus/IModSeparator.cs | 13 + .../Interfaces/Menus/IModSliderInput.cs | 15 + .../Interfaces/Menus/IModTabMenu.cs | 13 + .../Interfaces/Menus/IModTabbedMenu.cs | 25 ++ .../Interfaces/Menus/IModTemporaryPopup.cs | 7 + .../Interfaces/Menus/IModTextInput.cs | 9 + .../Interfaces/Menus/IModToggleInput.cs | 15 + src/OWML.Common/Interfaces/Menus/IModsMenu.cs | 11 + src/OWML.Common/Interfaces/Menus/InputType.cs | 10 + src/OWML.Common/MessageType.cs | 19 + src/OWML.Common/ModManifest.cs | 46 ++ src/OWML.Common/OWML.Common.csproj | 172 ++++++++ .../OWML.Common.csproj.DotSettings | 4 + src/OWML.Common/OwmlConfig.cs | 37 ++ .../OWML.Common}/Properties/AssemblyInfo.cs | 4 +- .../OWML.Common}/packages.config | 2 +- src/OWML.GameFinder/BaseFinder.cs | 28 ++ src/OWML.GameFinder/CurrentPathFinder.cs | 23 + src/OWML.GameFinder/DefaultLocationFinder.cs | 38 ++ src/OWML.GameFinder/EpicGameFinder.cs | 53 +++ src/OWML.GameFinder/EpicManifest.cs | 10 + .../OWML.GameFinder}/OWML.GameFinder.csproj | 7 +- src/OWML.GameFinder/PathFinder.cs | 27 ++ src/OWML.GameFinder/PromptGameFinder.cs | 25 ++ .../Properties/AssemblyInfo.cs | 35 ++ src/OWML.GameFinder/SteamGameFinder.cs | 68 +++ .../OWML.GameFinder}/app.config | 0 .../OWML.GameFinder}/packages.config | 2 +- src/OWML.Launcher/App.config | 18 + src/OWML.Launcher/App.cs | 161 +++++++ src/OWML.Launcher/ArgumentHelper.cs | 38 ++ src/OWML.Launcher/GameVersionHandler.cs | 46 ++ src/OWML.Launcher/OWML.DefaultConfig.json | 5 + .../OWML.Launcher}/OWML.Launcher.csproj | 16 +- src/OWML.Launcher/OWML.Manifest.json | 9 + src/OWML.Launcher/Program.cs | 92 ++++ .../OWML.Launcher}/Properties/AssemblyInfo.cs | 4 +- src/OWML.Launcher/SocketListener.cs | 122 ++++++ .../OWML.Launcher}/app.manifest | 0 .../OWML.Launcher}/packages.config | 0 src/OWML.Logging/ConsoleUtils.cs | 33 ++ src/OWML.Logging/ModConsole.cs | 33 ++ src/OWML.Logging/ModLogger.cs | 33 ++ src/OWML.Logging/ModSocket.cs | 53 +++ src/OWML.Logging/ModSocketMessage.cs | 20 + src/OWML.Logging/ModSocketOutput.cs | 78 ++++ .../OWML.Logging}/OWML.Logging.csproj | 37 +- src/OWML.Logging/OutputWriter.cs | 19 + src/OWML.Logging/Properties/AssemblyInfo.cs | 35 ++ src/OWML.Logging/UnityLogger.cs | 46 ++ .../OWML.Logging}/packages.config | 2 +- src/OWML.ModHelper.Assets/AudioAsset.cs | 8 + src/OWML.ModHelper.Assets/MeshAsset.cs | 8 + src/OWML.ModHelper.Assets/ModAsset.cs | 29 ++ src/OWML.ModHelper.Assets/ModAssets.cs | 186 ++++++++ .../OWML.ModHelper.Assets.csproj | 43 +- src/OWML.ModHelper.Assets/ObjImporter.cs | 257 +++++++++++ src/OWML.ModHelper.Assets/ObjectAsset.cs | 30 ++ .../Properties/AssemblyInfo.cs | 8 +- src/OWML.ModHelper.Assets/TextureAsset.cs | 8 + .../lib}/NAudio-Unity.dll | Bin .../OWML.ModHelper.Assets}/packages.config | 2 +- src/OWML.ModHelper.Events/HarmonyHelper.cs | 136 ++++++ src/OWML.ModHelper.Events/ModEvents.cs | 142 ++++++ src/OWML.ModHelper.Events/ModPlayerEvents.cs | 25 ++ src/OWML.ModHelper.Events/ModSceneEvents.cs | 23 + src/OWML.ModHelper.Events/ModUnityEvents.cs | 52 +++ .../OWML.ModHelper.Events.csproj | 45 +- src/OWML.ModHelper.Events/Patches.cs | 45 ++ .../Properties/AssemblyInfo.cs | 8 +- src/OWML.ModHelper.Events/TypeExtensions.cs | 37 ++ .../OWML.ModHelper.Events}/packages.config | 2 +- .../BindingChangeListener.cs | 52 +++ src/OWML.ModHelper.Input/InputInterceptor.cs | 74 ++++ .../ModCommandListener.cs | 106 +++++ src/OWML.ModHelper.Input/ModCommandUpdater.cs | 18 + .../ModInputCombination.cs | 77 ++++ src/OWML.ModHelper.Input/ModInputHandler.cs | 405 ++++++++++++++++++ src/OWML.ModHelper.Input/ModInputLibrary.cs | 169 ++++++++ src/OWML.ModHelper.Input/ModInputTextures.cs | 62 +++ .../OWML.ModHelper.Input.csproj | 41 +- .../Properties/AssemblyInfo.cs | 4 +- src/OWML.ModHelper.Input/RegistrationCode.cs | 10 + .../OWML.ModHelper.Input}/packages.config | 2 +- .../InterfaceProxyBuilder.cs | 100 +++++ .../InterfaceProxyFactory.cs | 46 ++ .../ModInteraction.cs | 94 ++++ .../OWML.ModHelper.Interaction.csproj | 0 .../Properties/AssemblyInfo.cs | 35 ++ src/OWML.ModHelper.Menus/ModButtonBase.cs | 98 +++++ src/OWML.ModHelper.Menus/ModComboInput.cs | 103 +++++ src/OWML.ModHelper.Menus/ModConfigMenu.cs | 62 +++ src/OWML.ModHelper.Menus/ModConfigMenuBase.cs | 163 +++++++ src/OWML.ModHelper.Menus/ModFieldInput.cs | 20 + src/OWML.ModHelper.Menus/ModInput.cs | 63 +++ .../ModInputCombinationElement.cs | 185 ++++++++ .../ModInputCombinationElementMenu.cs | 221 ++++++++++ .../ModInputCombinationMenu.cs | 108 +++++ .../ModInputCombinationPopup.cs | 199 +++++++++ src/OWML.ModHelper.Menus/ModInputMenu.cs | 97 +++++ src/OWML.ModHelper.Menus/ModLayoutButton.cs | 33 ++ src/OWML.ModHelper.Menus/ModLayoutManager.cs | 125 ++++++ src/OWML.ModHelper.Menus/ModMainMenu.cs | 67 +++ src/OWML.ModHelper.Menus/ModMenu.cs | 384 +++++++++++++++++ .../ModMenuWithSelectables.cs | 189 ++++++++ src/OWML.ModHelper.Menus/ModMenus.cs | 87 ++++ src/OWML.ModHelper.Menus/ModMessagePopup.cs | 68 +++ src/OWML.ModHelper.Menus/ModNumberInput.cs | 54 +++ src/OWML.ModHelper.Menus/ModOptionsMenu.cs | 98 +++++ src/OWML.ModHelper.Menus/ModPauseMenu.cs | 33 ++ src/OWML.ModHelper.Menus/ModPopupInput.cs | 71 +++ src/OWML.ModHelper.Menus/ModPopupManager.cs | 91 ++++ src/OWML.ModHelper.Menus/ModPopupMenu.cs | 113 +++++ src/OWML.ModHelper.Menus/ModPromptButton.cs | 62 +++ src/OWML.ModHelper.Menus/ModSelectorInput.cs | 68 +++ src/OWML.ModHelper.Menus/ModSeparator.cs | 88 ++++ src/OWML.ModHelper.Menus/ModSliderInput.cs | 84 ++++ src/OWML.ModHelper.Menus/ModTabMenu.cs | 64 +++ src/OWML.ModHelper.Menus/ModTemporaryPopup.cs | 52 +++ src/OWML.ModHelper.Menus/ModTextInput.cs | 53 +++ src/OWML.ModHelper.Menus/ModTitleButton.cs | 77 ++++ src/OWML.ModHelper.Menus/ModToggleInput.cs | 53 +++ src/OWML.ModHelper.Menus/ModUIStyleApplier.cs | 81 ++++ src/OWML.ModHelper.Menus/ModsMenu.cs | 171 ++++++++ .../OWML.ModHelper.Menus.csproj | 47 +- src/OWML.ModHelper.Menus/OwmlConfigMenu.cs | 48 +++ .../Properties/AssemblyInfo.cs | 4 +- .../OWML.ModHelper.Menus}/packages.config | 2 +- src/OWML.ModHelper/ModBehaviour.cs | 33 ++ src/OWML.ModHelper/ModConfig.cs | 96 +++++ src/OWML.ModHelper/ModHelper.cs | 60 +++ src/OWML.ModHelper/ModStorage.cs | 19 + .../OWML.ModHelper}/OWML.ModHelper.csproj | 71 ++- .../OWML.ModHelper.csproj.DotSettings | 0 .../OWML.ModHelper/OWML.ModHelper.nuspec | 7 +- src/OWML.ModHelper/OwmlBehaviour.cs | 15 + .../Properties/AssemblyInfo.cs | 4 +- .../OWML.ModHelper}/packages.config | 2 +- src/OWML.ModLoader/ModData.cs | 139 ++++++ src/OWML.ModLoader/ModFinder.cs | 49 +++ src/OWML.ModLoader/ModLoader.cs | 75 ++++ src/OWML.ModLoader/ModSorter.cs | 103 +++++ .../OWML.ModLoader}/OWML.ModLoader.csproj | 45 +- src/OWML.ModLoader/Owo.cs | 185 ++++++++ .../Properties/AssemblyInfo.cs | 8 +- src/OWML.ModLoader/packages.config | 5 + src/OWML.Patcher/BinaryPatcher.cs | 159 +++++++ src/OWML.Patcher/GameVersionReader.cs | 25 ++ .../OWML.Patcher}/OWML.Patcher.csproj | 11 + src/OWML.Patcher/OWPatcher.cs | 143 +++++++ .../OWML.Patcher}/Properties/AssemblyInfo.cs | 4 +- src/OWML.Patcher/SectorInfo.cs | 19 + src/OWML.Patcher/VRFilePatcher.cs | 74 ++++ src/OWML.Patcher/VRPatcher.cs | 71 +++ .../VR => src/OWML.Patcher/lib}/OVRPlugin.dll | Bin .../OWML.Patcher/lib}/dnlib.dll | Bin .../OWML.Patcher/lib}/dnpatch.dll | Bin .../OWML.Patcher/lib}/openvr_api.dll | Bin src/OWML.Utils/Container.cs | 30 ++ src/OWML.Utils/JsonHelper.cs | 25 ++ src/OWML.Utils/OWML.Utils.csproj | 58 +++ src/OWML.Utils/Properties/AssemblyInfo.cs | 35 ++ src/OWML.Utils/TypeExtensions.cs | 53 +++ src/OWML.Utils/packages.config | 6 + .../OWML.EnableDebugMode/EnableDebugMode.cs | 117 +++++ .../OWML.EnableDebugMode.csproj | 153 +++++++ .../Properties/AssemblyInfo.cs | 4 +- .../OWML.EnableDebugMode/default-config.json | 45 ++ .../OWML.EnableDebugMode/manifest.json | 10 + .../OWML.EnableDebugMode/packages.config | 6 + .../OWML.LoadCustomAssets/LoadCustomAssets.cs | 185 ++++++++ .../OWML.LoadCustomAssets.csproj | 78 +++- .../Properties/AssemblyInfo.cs | 0 .../OWML.LoadCustomAssets/SaveFile.cs | 10 + .../OWML.LoadCustomAssets/blaster-firing.wav | Bin .../OWML.LoadCustomAssets/config.json | 44 ++ .../OWML.LoadCustomAssets/cubebundle | Bin .../OWML.LoadCustomAssets/cubebundle.manifest | 0 .../OWML.LoadCustomAssets/default-config.json | 57 +++ .../OWML.LoadCustomAssets/duck.obj | 0 .../OWML.LoadCustomAssets/duck.png | Bin .../OWML.LoadCustomAssets/manifest.json | 10 + .../OWML.LoadCustomAssets/packages.config | 6 + .../OWML.LoadCustomAssets/savefile.json | 3 + .../OWML.LoadCustomAssets/spiral-mountain.mp3 | Bin .../OWML.GameFinder.Tests/GameFinderTests.cs | 26 ++ .../OWML.GameFinder.Tests.csproj | 99 +++++ .../Properties/AssemblyInfo.cs | 35 ++ tests/OWML.GameFinder.Tests/packages.config | 15 + tests/OWML.Launcher.Tests/LauncherTests.cs | 51 +++ .../OWML.Launcher.Tests.csproj | 108 +++++ .../Properties/AssemblyInfo.cs | 6 +- tests/OWML.Launcher.Tests/ReleaseTests.cs | 108 +++++ tests/OWML.Launcher.Tests/app.config | 19 + tests/OWML.Launcher.Tests/packages.config | 15 + tests/OWML.ModFinder.Tests/ModFinderTests.cs | 27 ++ .../OWML.ModFinder.Tests.csproj | 99 +++++ .../Properties/AssemblyInfo.cs | 6 +- tests/OWML.ModFinder.Tests/packages.config | 15 + tests/OWML.ModLoader.Tests/ModLoaderTests.cs | 40 ++ .../OWML.ModLoader.Tests.csproj | 150 +++++++ .../Properties/AssemblyInfo.cs | 35 ++ tests/OWML.ModLoader.Tests/packages.config | 16 + .../OWML.Tests.Setup/OWML.Tests.Setup.csproj | 95 ++++ tests/OWML.Tests.Setup/OWMLTests.cs | 77 ++++ .../Properties/AssemblyInfo.cs | 6 +- tests/OWML.Tests.Setup/packages.config | 15 + .../OWML.Utils.Tests/OWML.Utils.Tests.csproj | 99 +++++ .../Properties/AssemblyInfo.cs | 35 ++ tests/OWML.Utils.Tests/TypeExtensionTests.cs | 41 ++ tests/OWML.Utils.Tests/packages.config | 15 + 469 files changed, 12639 insertions(+), 10022 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 OWML.Common/Constants.cs delete mode 100644 OWML.Common/Events.cs delete mode 100644 OWML.Common/IHarmonyHelper.cs delete mode 100644 OWML.Common/IModAsset.cs delete mode 100644 OWML.Common/IModAssets.cs delete mode 100644 OWML.Common/IModBehaviour.cs delete mode 100644 OWML.Common/IModConfig.cs delete mode 100644 OWML.Common/IModConsole.cs delete mode 100644 OWML.Common/IModData.cs delete mode 100644 OWML.Common/IModEvents.cs delete mode 100644 OWML.Common/IModFinder.cs delete mode 100644 OWML.Common/IModHelper.cs delete mode 100644 OWML.Common/IModInputCombination.cs delete mode 100644 OWML.Common/IModInputHandler.cs delete mode 100644 OWML.Common/IModInputTextures.cs delete mode 100644 OWML.Common/IModInteraction.cs delete mode 100644 OWML.Common/IModLogger.cs delete mode 100644 OWML.Common/IModManifest.cs delete mode 100644 OWML.Common/IModPlayerEvents.cs delete mode 100644 OWML.Common/IModSceneEvents.cs delete mode 100644 OWML.Common/IModSocket.cs delete mode 100644 OWML.Common/IModSocketMessage.cs delete mode 100644 OWML.Common/IModStorage.cs delete mode 100644 OWML.Common/IModUnityEvents.cs delete mode 100644 OWML.Common/IOwmlConfig.cs delete mode 100644 OWML.Common/Menus/IModButton.cs delete mode 100644 OWML.Common/Menus/IModButtonBase.cs delete mode 100644 OWML.Common/Menus/IModComboInput.cs delete mode 100644 OWML.Common/Menus/IModConfigMenu.cs delete mode 100644 OWML.Common/Menus/IModConfigMenuBase.cs delete mode 100644 OWML.Common/Menus/IModFieldInput.cs delete mode 100644 OWML.Common/Menus/IModInput.cs delete mode 100644 OWML.Common/Menus/IModInputBase.cs delete mode 100644 OWML.Common/Menus/IModInputCombinationElement.cs delete mode 100644 OWML.Common/Menus/IModInputCombinationElementMenu.cs delete mode 100644 OWML.Common/Menus/IModInputCombinationMenu.cs delete mode 100644 OWML.Common/Menus/IModInputMenu.cs delete mode 100644 OWML.Common/Menus/IModLayoutButton.cs delete mode 100644 OWML.Common/Menus/IModLayoutManager.cs delete mode 100644 OWML.Common/Menus/IModMainMenu.cs delete mode 100644 OWML.Common/Menus/IModMenu.cs delete mode 100644 OWML.Common/Menus/IModMenuWithSelectables.cs delete mode 100644 OWML.Common/Menus/IModMenus.cs delete mode 100644 OWML.Common/Menus/IModMessagePopup.cs delete mode 100644 OWML.Common/Menus/IModNumberInput.cs delete mode 100644 OWML.Common/Menus/IModOWMenu.cs delete mode 100644 OWML.Common/Menus/IModPauseMenu.cs delete mode 100644 OWML.Common/Menus/IModPopupManager.cs delete mode 100644 OWML.Common/Menus/IModPopupMenu.cs delete mode 100644 OWML.Common/Menus/IModPromptButton.cs delete mode 100644 OWML.Common/Menus/IModSelectorInput.cs delete mode 100644 OWML.Common/Menus/IModSeparator.cs delete mode 100644 OWML.Common/Menus/IModSliderInput.cs delete mode 100644 OWML.Common/Menus/IModTabMenu.cs delete mode 100644 OWML.Common/Menus/IModTabbedMenu.cs delete mode 100644 OWML.Common/Menus/IModTextInput.cs delete mode 100644 OWML.Common/Menus/IModToggleInput.cs delete mode 100644 OWML.Common/Menus/IModsMenu.cs delete mode 100644 OWML.Common/Menus/InputType.cs delete mode 100644 OWML.Common/MessageType.cs delete mode 100644 OWML.Common/OWML.Common.csproj delete mode 100644 OWML.GameFinder/BaseFinder.cs delete mode 100644 OWML.GameFinder/CurrentPathFinder.cs delete mode 100644 OWML.GameFinder/DefaultLocationFinder.cs delete mode 100644 OWML.GameFinder/EpicGameFinder.cs delete mode 100644 OWML.GameFinder/PathFinder.cs delete mode 100644 OWML.GameFinder/PromptGameFinder.cs delete mode 100644 OWML.GameFinder/SteamGameFinder.cs delete mode 100644 OWML.Launcher/App.config delete mode 100644 OWML.Launcher/App.cs delete mode 100644 OWML.Launcher/OWML.DefaultConfig.json delete mode 100644 OWML.Launcher/OWML.Manifest.json delete mode 100644 OWML.Launcher/Program.cs delete mode 100644 OWML.Launcher/SocketListener.cs delete mode 100644 OWML.Logging/ConsoleUtils.cs delete mode 100644 OWML.Logging/ModConsole.cs delete mode 100644 OWML.Logging/ModLogger.cs delete mode 100644 OWML.Logging/ModSocket.cs delete mode 100644 OWML.Logging/ModSocketMessage.cs delete mode 100644 OWML.Logging/ModSocketOutput.cs delete mode 100644 OWML.Logging/OutputWriter.cs delete mode 100644 OWML.Logging/UnityLogger.cs delete mode 100644 OWML.ModHelper.Assets/AudioAsset.cs delete mode 100644 OWML.ModHelper.Assets/MeshAsset.cs delete mode 100644 OWML.ModHelper.Assets/ModAsset.cs delete mode 100644 OWML.ModHelper.Assets/ModAssets.cs delete mode 100644 OWML.ModHelper.Assets/ObjImporter.cs delete mode 100644 OWML.ModHelper.Assets/ObjectAsset.cs delete mode 100644 OWML.ModHelper.Assets/TextureAsset.cs delete mode 100644 OWML.ModHelper.Assets/packages.config delete mode 100644 OWML.ModHelper.Events/HarmonyHelper.cs delete mode 100644 OWML.ModHelper.Events/ModEvents.cs delete mode 100644 OWML.ModHelper.Events/ModPlayerEvents.cs delete mode 100644 OWML.ModHelper.Events/ModSceneEvents.cs delete mode 100644 OWML.ModHelper.Events/ModUnityEvents.cs delete mode 100644 OWML.ModHelper.Events/Patches.cs delete mode 100644 OWML.ModHelper.Events/TypeExtensions.cs delete mode 100644 OWML.ModHelper.Input/BindingChangeListener.cs delete mode 100644 OWML.ModHelper.Input/InputInterceptor.cs delete mode 100644 OWML.ModHelper.Input/ModCommandListener.cs delete mode 100644 OWML.ModHelper.Input/ModCommandUpdater.cs delete mode 100644 OWML.ModHelper.Input/ModInputCombination.cs delete mode 100644 OWML.ModHelper.Input/ModInputHandler.cs delete mode 100644 OWML.ModHelper.Input/ModInputLibrary.cs delete mode 100644 OWML.ModHelper.Input/ModInputTextures.cs delete mode 100644 OWML.ModHelper.Input/RegistrationCode.cs delete mode 100644 OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs delete mode 100644 OWML.ModHelper.Interaction/InterfaceProxyFactory.cs delete mode 100644 OWML.ModHelper.Interaction/ModInteraction.cs delete mode 100644 OWML.ModHelper.Menus/ModButtonBase.cs delete mode 100644 OWML.ModHelper.Menus/ModComboInput.cs delete mode 100644 OWML.ModHelper.Menus/ModConfigMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModConfigMenuBase.cs delete mode 100644 OWML.ModHelper.Menus/ModFieldInput.cs delete mode 100644 OWML.ModHelper.Menus/ModInput.cs delete mode 100644 OWML.ModHelper.Menus/ModInputCombinationElement.cs delete mode 100644 OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModInputCombinationMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModInputCombinationPopup.cs delete mode 100644 OWML.ModHelper.Menus/ModInputMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModLayoutButton.cs delete mode 100644 OWML.ModHelper.Menus/ModLayoutManager.cs delete mode 100644 OWML.ModHelper.Menus/ModMainMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModMenuWithSelectables.cs delete mode 100644 OWML.ModHelper.Menus/ModMenus.cs delete mode 100644 OWML.ModHelper.Menus/ModMessagePopup.cs delete mode 100644 OWML.ModHelper.Menus/ModNumberInput.cs delete mode 100644 OWML.ModHelper.Menus/ModOptionsMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModPauseMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModPopupInput.cs delete mode 100644 OWML.ModHelper.Menus/ModPopupManager.cs delete mode 100644 OWML.ModHelper.Menus/ModPopupMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModPromptButton.cs delete mode 100644 OWML.ModHelper.Menus/ModSelectorInput.cs delete mode 100644 OWML.ModHelper.Menus/ModSeparator.cs delete mode 100644 OWML.ModHelper.Menus/ModSliderInput.cs delete mode 100644 OWML.ModHelper.Menus/ModTabMenu.cs delete mode 100644 OWML.ModHelper.Menus/ModTemporaryPopup.cs delete mode 100644 OWML.ModHelper.Menus/ModTextInput.cs delete mode 100644 OWML.ModHelper.Menus/ModTitleButton.cs delete mode 100644 OWML.ModHelper.Menus/ModToggleInput.cs delete mode 100644 OWML.ModHelper.Menus/ModUIStyleApplier.cs delete mode 100644 OWML.ModHelper.Menus/ModsMenu.cs delete mode 100644 OWML.ModHelper.Menus/OwmlConfigMenu.cs delete mode 100644 OWML.ModHelper/CommandLineArguments.cs delete mode 100644 OWML.ModHelper/DontDestroyOnLoad.cs delete mode 100644 OWML.ModHelper/JsonHelper.cs delete mode 100644 OWML.ModHelper/ModBehaviour.cs delete mode 100644 OWML.ModHelper/ModConfig.cs delete mode 100644 OWML.ModHelper/ModHelper.cs delete mode 100644 OWML.ModHelper/ModManifest.cs delete mode 100644 OWML.ModHelper/ModStorage.cs delete mode 100644 OWML.ModHelper/OwmlBehaviour.cs delete mode 100644 OWML.ModHelper/OwmlConfig.cs delete mode 100644 OWML.ModLoader/ModData.cs delete mode 100644 OWML.ModLoader/ModFinder.cs delete mode 100644 OWML.ModLoader/ModLoader.cs delete mode 100644 OWML.ModLoader/ModSorter.cs delete mode 100644 OWML.ModLoader/Owo.cs delete mode 100644 OWML.Nuget/OWML.Nuget.csproj delete mode 100644 OWML.Nuget/Properties/AssemblyInfo.cs delete mode 100644 OWML.Patcher/BinaryPatcher.cs delete mode 100644 OWML.Patcher/GameVersionReader.cs delete mode 100644 OWML.Patcher/OWPatcher.cs delete mode 100644 OWML.Patcher/VRFilePatcher.cs delete mode 100644 OWML.Patcher/VrPatcher.cs delete mode 100644 OWML.SampleMods/OWML.EnableDebugMode/EnableDebugMode.cs delete mode 100644 OWML.SampleMods/OWML.EnableDebugMode/default-config.json delete mode 100644 OWML.SampleMods/OWML.EnableDebugMode/manifest.json delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/SaveFile.cs delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/config.json delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/default-config.json delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/manifest.json delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/packages.config delete mode 100644 OWML.SampleMods/OWML.LoadCustomAssets/savefile.json delete mode 100644 createrelease.bat create mode 100644 nuget.config create mode 100644 src/OWML.Abstractions/ApplicationHelper.cs create mode 100644 src/OWML.Abstractions/GameObjectHelper.cs rename OWML.SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj => src/OWML.Abstractions/OWML.Abstractions.csproj (66%) create mode 100644 src/OWML.Abstractions/ProcessHelper.cs create mode 100644 src/OWML.Abstractions/Properties/AssemblyInfo.cs rename {OWML.Common => src/OWML.Abstractions}/packages.config (53%) create mode 100644 src/OWML.Common/Constants.cs create mode 100644 src/OWML.Common/DontDestroyOnLoad.cs create mode 100644 src/OWML.Common/Events.cs create mode 100644 src/OWML.Common/Interfaces/IApplicationHelper.cs create mode 100644 src/OWML.Common/Interfaces/IArgumentHelper.cs create mode 100644 src/OWML.Common/Interfaces/IBinaryPatcher.cs create mode 100644 src/OWML.Common/Interfaces/IBindingChangeListener.cs create mode 100644 src/OWML.Common/Interfaces/IGameObjectHelper.cs create mode 100644 src/OWML.Common/Interfaces/IGameVersionHandler.cs create mode 100644 src/OWML.Common/Interfaces/IGameVersionReader.cs create mode 100644 src/OWML.Common/Interfaces/IHarmonyHelper.cs create mode 100644 src/OWML.Common/Interfaces/IInterfaceProxyFactory.cs create mode 100644 src/OWML.Common/Interfaces/IModAsset.cs create mode 100644 src/OWML.Common/Interfaces/IModAssets.cs create mode 100644 src/OWML.Common/Interfaces/IModBehaviour.cs create mode 100644 src/OWML.Common/Interfaces/IModConfig.cs create mode 100644 src/OWML.Common/Interfaces/IModConsole.cs create mode 100644 src/OWML.Common/Interfaces/IModData.cs create mode 100644 src/OWML.Common/Interfaces/IModEvents.cs create mode 100644 src/OWML.Common/Interfaces/IModFinder.cs create mode 100644 src/OWML.Common/Interfaces/IModHelper.cs create mode 100644 src/OWML.Common/Interfaces/IModInputCombination.cs create mode 100644 src/OWML.Common/Interfaces/IModInputHandler.cs create mode 100644 src/OWML.Common/Interfaces/IModInputTextures.cs create mode 100644 src/OWML.Common/Interfaces/IModInteraction.cs create mode 100644 src/OWML.Common/Interfaces/IModLogger.cs create mode 100644 src/OWML.Common/Interfaces/IModManifest.cs create mode 100644 src/OWML.Common/Interfaces/IModPlayerEvents.cs create mode 100644 src/OWML.Common/Interfaces/IModSceneEvents.cs create mode 100644 src/OWML.Common/Interfaces/IModSocket.cs create mode 100644 src/OWML.Common/Interfaces/IModSocketMessage.cs create mode 100644 src/OWML.Common/Interfaces/IModSorter.cs create mode 100644 src/OWML.Common/Interfaces/IModStorage.cs create mode 100644 src/OWML.Common/Interfaces/IModUnityEvents.cs create mode 100644 src/OWML.Common/Interfaces/IOWPatcher.cs create mode 100644 src/OWML.Common/Interfaces/IObjImporter.cs create mode 100644 src/OWML.Common/Interfaces/IOwmlConfig.cs create mode 100644 src/OWML.Common/Interfaces/IPathFinder.cs create mode 100644 src/OWML.Common/Interfaces/IProcessHelper.cs create mode 100644 src/OWML.Common/Interfaces/ISectorInfo.cs create mode 100644 src/OWML.Common/Interfaces/IUnityLogger.cs create mode 100644 src/OWML.Common/Interfaces/IVRFilePatcher.cs create mode 100644 src/OWML.Common/Interfaces/IVRPatcher.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModButton.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModButtonBase.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModComboInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModConfigMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModConfigMenuBase.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModFieldInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInputBase.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInputCombinationElement.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInputCombinationElementMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInputCombinationMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModInputMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModLayoutButton.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModLayoutManager.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModMainMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModMenuWithSelectables.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModMenus.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModMessagePopup.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModNumberInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModOWMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModPauseMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModPopupManager.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModPopupMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModPromptButton.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModSelectorInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModSeparator.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModSliderInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModTabMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModTabbedMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModTemporaryPopup.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModTextInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModToggleInput.cs create mode 100644 src/OWML.Common/Interfaces/Menus/IModsMenu.cs create mode 100644 src/OWML.Common/Interfaces/Menus/InputType.cs create mode 100644 src/OWML.Common/MessageType.cs create mode 100644 src/OWML.Common/ModManifest.cs create mode 100644 src/OWML.Common/OWML.Common.csproj create mode 100644 src/OWML.Common/OWML.Common.csproj.DotSettings create mode 100644 src/OWML.Common/OwmlConfig.cs rename {OWML.Common => src/OWML.Common}/Properties/AssemblyInfo.cs (92%) rename {OWML.ModHelper.Menus => src/OWML.Common}/packages.config (69%) create mode 100644 src/OWML.GameFinder/BaseFinder.cs create mode 100644 src/OWML.GameFinder/CurrentPathFinder.cs create mode 100644 src/OWML.GameFinder/DefaultLocationFinder.cs create mode 100644 src/OWML.GameFinder/EpicGameFinder.cs create mode 100644 src/OWML.GameFinder/EpicManifest.cs rename {OWML.GameFinder => src/OWML.GameFinder}/OWML.GameFinder.csproj (90%) create mode 100644 src/OWML.GameFinder/PathFinder.cs create mode 100644 src/OWML.GameFinder/PromptGameFinder.cs create mode 100644 src/OWML.GameFinder/Properties/AssemblyInfo.cs create mode 100644 src/OWML.GameFinder/SteamGameFinder.cs rename {OWML.GameFinder => src/OWML.GameFinder}/app.config (100%) rename {OWML.GameFinder => src/OWML.GameFinder}/packages.config (70%) create mode 100644 src/OWML.Launcher/App.config create mode 100644 src/OWML.Launcher/App.cs create mode 100644 src/OWML.Launcher/ArgumentHelper.cs create mode 100644 src/OWML.Launcher/GameVersionHandler.cs create mode 100644 src/OWML.Launcher/OWML.DefaultConfig.json rename {OWML.Launcher => src/OWML.Launcher}/OWML.Launcher.csproj (86%) create mode 100644 src/OWML.Launcher/OWML.Manifest.json create mode 100644 src/OWML.Launcher/Program.cs rename {OWML.Launcher => src/OWML.Launcher}/Properties/AssemblyInfo.cs (92%) create mode 100644 src/OWML.Launcher/SocketListener.cs rename {OWML.Launcher => src/OWML.Launcher}/app.manifest (100%) rename {OWML.Launcher => src/OWML.Launcher}/packages.config (100%) create mode 100644 src/OWML.Logging/ConsoleUtils.cs create mode 100644 src/OWML.Logging/ModConsole.cs create mode 100644 src/OWML.Logging/ModLogger.cs create mode 100644 src/OWML.Logging/ModSocket.cs create mode 100644 src/OWML.Logging/ModSocketMessage.cs create mode 100644 src/OWML.Logging/ModSocketOutput.cs rename {OWML.Logging => src/OWML.Logging}/OWML.Logging.csproj (71%) create mode 100644 src/OWML.Logging/OutputWriter.cs create mode 100644 src/OWML.Logging/Properties/AssemblyInfo.cs create mode 100644 src/OWML.Logging/UnityLogger.cs rename {OWML.ModLoader => src/OWML.Logging}/packages.config (69%) create mode 100644 src/OWML.ModHelper.Assets/AudioAsset.cs create mode 100644 src/OWML.ModHelper.Assets/MeshAsset.cs create mode 100644 src/OWML.ModHelper.Assets/ModAsset.cs create mode 100644 src/OWML.ModHelper.Assets/ModAssets.cs rename {OWML.ModHelper.Assets => src/OWML.ModHelper.Assets}/OWML.ModHelper.Assets.csproj (68%) create mode 100644 src/OWML.ModHelper.Assets/ObjImporter.cs create mode 100644 src/OWML.ModHelper.Assets/ObjectAsset.cs rename {OWML.ModHelper.Assets => src/OWML.ModHelper.Assets}/Properties/AssemblyInfo.cs (85%) create mode 100644 src/OWML.ModHelper.Assets/TextureAsset.cs rename {OWML.ModHelper.Assets/NAudio-Unity => src/OWML.ModHelper.Assets/lib}/NAudio-Unity.dll (100%) rename {OWML.SampleMods/OWML.EnableDebugMode => src/OWML.ModHelper.Assets}/packages.config (53%) create mode 100644 src/OWML.ModHelper.Events/HarmonyHelper.cs create mode 100644 src/OWML.ModHelper.Events/ModEvents.cs create mode 100644 src/OWML.ModHelper.Events/ModPlayerEvents.cs create mode 100644 src/OWML.ModHelper.Events/ModSceneEvents.cs create mode 100644 src/OWML.ModHelper.Events/ModUnityEvents.cs rename {OWML.ModHelper.Events => src/OWML.ModHelper.Events}/OWML.ModHelper.Events.csproj (66%) create mode 100644 src/OWML.ModHelper.Events/Patches.cs rename {OWML.ModHelper.Events => src/OWML.ModHelper.Events}/Properties/AssemblyInfo.cs (85%) create mode 100644 src/OWML.ModHelper.Events/TypeExtensions.cs rename {OWML.ModHelper.Events => src/OWML.ModHelper.Events}/packages.config (69%) create mode 100644 src/OWML.ModHelper.Input/BindingChangeListener.cs create mode 100644 src/OWML.ModHelper.Input/InputInterceptor.cs create mode 100644 src/OWML.ModHelper.Input/ModCommandListener.cs create mode 100644 src/OWML.ModHelper.Input/ModCommandUpdater.cs create mode 100644 src/OWML.ModHelper.Input/ModInputCombination.cs create mode 100644 src/OWML.ModHelper.Input/ModInputHandler.cs create mode 100644 src/OWML.ModHelper.Input/ModInputLibrary.cs create mode 100644 src/OWML.ModHelper.Input/ModInputTextures.cs rename {OWML.ModHelper.Input => src/OWML.ModHelper.Input}/OWML.ModHelper.Input.csproj (70%) rename {OWML.ModHelper.Input => src/OWML.ModHelper.Input}/Properties/AssemblyInfo.cs (92%) create mode 100644 src/OWML.ModHelper.Input/RegistrationCode.cs rename {OWML.ModHelper.Input => src/OWML.ModHelper.Input}/packages.config (53%) create mode 100644 src/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs create mode 100644 src/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs create mode 100644 src/OWML.ModHelper.Interaction/ModInteraction.cs rename {OWML.ModHelper.Interaction => src/OWML.ModHelper.Interaction}/OWML.ModHelper.Interaction.csproj (100%) create mode 100644 src/OWML.ModHelper.Interaction/Properties/AssemblyInfo.cs create mode 100644 src/OWML.ModHelper.Menus/ModButtonBase.cs create mode 100644 src/OWML.ModHelper.Menus/ModComboInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModConfigMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModConfigMenuBase.cs create mode 100644 src/OWML.ModHelper.Menus/ModFieldInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModInputCombinationElement.cs create mode 100644 src/OWML.ModHelper.Menus/ModInputCombinationElementMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModInputCombinationMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModInputCombinationPopup.cs create mode 100644 src/OWML.ModHelper.Menus/ModInputMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModLayoutButton.cs create mode 100644 src/OWML.ModHelper.Menus/ModLayoutManager.cs create mode 100644 src/OWML.ModHelper.Menus/ModMainMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModMenuWithSelectables.cs create mode 100644 src/OWML.ModHelper.Menus/ModMenus.cs create mode 100644 src/OWML.ModHelper.Menus/ModMessagePopup.cs create mode 100644 src/OWML.ModHelper.Menus/ModNumberInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModOptionsMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModPauseMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModPopupInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModPopupManager.cs create mode 100644 src/OWML.ModHelper.Menus/ModPopupMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModPromptButton.cs create mode 100644 src/OWML.ModHelper.Menus/ModSelectorInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModSeparator.cs create mode 100644 src/OWML.ModHelper.Menus/ModSliderInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModTabMenu.cs create mode 100644 src/OWML.ModHelper.Menus/ModTemporaryPopup.cs create mode 100644 src/OWML.ModHelper.Menus/ModTextInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModTitleButton.cs create mode 100644 src/OWML.ModHelper.Menus/ModToggleInput.cs create mode 100644 src/OWML.ModHelper.Menus/ModUIStyleApplier.cs create mode 100644 src/OWML.ModHelper.Menus/ModsMenu.cs rename {OWML.ModHelper.Menus => src/OWML.ModHelper.Menus}/OWML.ModHelper.Menus.csproj (76%) create mode 100644 src/OWML.ModHelper.Menus/OwmlConfigMenu.cs rename {OWML.ModHelper.Menus => src/OWML.ModHelper.Menus}/Properties/AssemblyInfo.cs (92%) rename {OWML.Logging => src/OWML.ModHelper.Menus}/packages.config (69%) create mode 100644 src/OWML.ModHelper/ModBehaviour.cs create mode 100644 src/OWML.ModHelper/ModConfig.cs create mode 100644 src/OWML.ModHelper/ModHelper.cs create mode 100644 src/OWML.ModHelper/ModStorage.cs rename {OWML.ModHelper => src/OWML.ModHelper}/OWML.ModHelper.csproj (57%) rename {OWML.ModHelper => src/OWML.ModHelper}/OWML.ModHelper.csproj.DotSettings (100%) rename OWML.Nuget/OWML.Nuget.nuspec => src/OWML.ModHelper/OWML.ModHelper.nuspec (87%) create mode 100644 src/OWML.ModHelper/OwmlBehaviour.cs rename {OWML.ModHelper => src/OWML.ModHelper}/Properties/AssemblyInfo.cs (92%) rename {OWML.ModHelper => src/OWML.ModHelper}/packages.config (69%) create mode 100644 src/OWML.ModLoader/ModData.cs create mode 100644 src/OWML.ModLoader/ModFinder.cs create mode 100644 src/OWML.ModLoader/ModLoader.cs create mode 100644 src/OWML.ModLoader/ModSorter.cs rename {OWML.ModLoader => src/OWML.ModLoader}/OWML.ModLoader.csproj (72%) create mode 100644 src/OWML.ModLoader/Owo.cs rename {OWML.ModLoader => src/OWML.ModLoader}/Properties/AssemblyInfo.cs (86%) create mode 100644 src/OWML.ModLoader/packages.config create mode 100644 src/OWML.Patcher/BinaryPatcher.cs create mode 100644 src/OWML.Patcher/GameVersionReader.cs rename {OWML.Patcher => src/OWML.Patcher}/OWML.Patcher.csproj (89%) create mode 100644 src/OWML.Patcher/OWPatcher.cs rename {OWML.Patcher => src/OWML.Patcher}/Properties/AssemblyInfo.cs (92%) create mode 100644 src/OWML.Patcher/SectorInfo.cs create mode 100644 src/OWML.Patcher/VRFilePatcher.cs create mode 100644 src/OWML.Patcher/VRPatcher.cs rename {OWML.Patcher/VR => src/OWML.Patcher/lib}/OVRPlugin.dll (100%) rename {OWML.Patcher/dnpatch => src/OWML.Patcher/lib}/dnlib.dll (100%) rename {OWML.Patcher/dnpatch => src/OWML.Patcher/lib}/dnpatch.dll (100%) rename {OWML.Patcher/VR => src/OWML.Patcher/lib}/openvr_api.dll (100%) create mode 100644 src/OWML.Utils/Container.cs create mode 100644 src/OWML.Utils/JsonHelper.cs create mode 100644 src/OWML.Utils/OWML.Utils.csproj create mode 100644 src/OWML.Utils/Properties/AssemblyInfo.cs create mode 100644 src/OWML.Utils/TypeExtensions.cs create mode 100644 src/OWML.Utils/packages.config create mode 100644 src/SampleMods/OWML.EnableDebugMode/EnableDebugMode.cs create mode 100644 src/SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj rename {OWML.SampleMods => src/SampleMods}/OWML.EnableDebugMode/Properties/AssemblyInfo.cs (92%) create mode 100644 src/SampleMods/OWML.EnableDebugMode/default-config.json create mode 100644 src/SampleMods/OWML.EnableDebugMode/manifest.json create mode 100644 src/SampleMods/OWML.EnableDebugMode/packages.config create mode 100644 src/SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/OWML.LoadCustomAssets.csproj (57%) rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/Properties/AssemblyInfo.cs (100%) create mode 100644 src/SampleMods/OWML.LoadCustomAssets/SaveFile.cs rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/blaster-firing.wav (100%) create mode 100644 src/SampleMods/OWML.LoadCustomAssets/config.json rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/cubebundle (100%) rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/cubebundle.manifest (100%) create mode 100644 src/SampleMods/OWML.LoadCustomAssets/default-config.json rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/duck.obj (100%) rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/duck.png (100%) create mode 100644 src/SampleMods/OWML.LoadCustomAssets/manifest.json create mode 100644 src/SampleMods/OWML.LoadCustomAssets/packages.config create mode 100644 src/SampleMods/OWML.LoadCustomAssets/savefile.json rename {OWML.SampleMods => src/SampleMods}/OWML.LoadCustomAssets/spiral-mountain.mp3 (100%) create mode 100644 tests/OWML.GameFinder.Tests/GameFinderTests.cs create mode 100644 tests/OWML.GameFinder.Tests/OWML.GameFinder.Tests.csproj create mode 100644 tests/OWML.GameFinder.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/OWML.GameFinder.Tests/packages.config create mode 100644 tests/OWML.Launcher.Tests/LauncherTests.cs create mode 100644 tests/OWML.Launcher.Tests/OWML.Launcher.Tests.csproj rename {OWML.Logging => tests/OWML.Launcher.Tests}/Properties/AssemblyInfo.cs (88%) create mode 100644 tests/OWML.Launcher.Tests/ReleaseTests.cs create mode 100644 tests/OWML.Launcher.Tests/app.config create mode 100644 tests/OWML.Launcher.Tests/packages.config create mode 100644 tests/OWML.ModFinder.Tests/ModFinderTests.cs create mode 100644 tests/OWML.ModFinder.Tests/OWML.ModFinder.Tests.csproj rename {OWML.ModHelper.Interaction => tests/OWML.ModFinder.Tests}/Properties/AssemblyInfo.cs (88%) create mode 100644 tests/OWML.ModFinder.Tests/packages.config create mode 100644 tests/OWML.ModLoader.Tests/ModLoaderTests.cs create mode 100644 tests/OWML.ModLoader.Tests/OWML.ModLoader.Tests.csproj create mode 100644 tests/OWML.ModLoader.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/OWML.ModLoader.Tests/packages.config create mode 100644 tests/OWML.Tests.Setup/OWML.Tests.Setup.csproj create mode 100644 tests/OWML.Tests.Setup/OWMLTests.cs rename {OWML.GameFinder => tests/OWML.Tests.Setup}/Properties/AssemblyInfo.cs (88%) create mode 100644 tests/OWML.Tests.Setup/packages.config create mode 100644 tests/OWML.Utils.Tests/OWML.Utils.Tests.csproj create mode 100644 tests/OWML.Utils.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/OWML.Utils.Tests/TypeExtensionTests.cs create mode 100644 tests/OWML.Utils.Tests/packages.config diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..20c17583 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,116 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + workflow_dispatch: + +jobs: + + build: + runs-on: windows-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + INTERNAL_PKG_KEY: ${{ secrets.INTERNAL_PKG_KEY }} + steps: + - uses: actions/checkout@v2 + + - name: get version + id: version + uses: notiz-dev/github-action-json-property@release + with: + path: src\OWML.Launcher\OWML.Manifest.json + prop_path: version + - name: set version - EnableDebugMode + uses: jossef/action-set-json-field@v1 + with: + file: src\SampleMods\OWML.EnableDebugMode\manifest.json + field: version + value: ${{ steps.version.outputs.prop }} + - name: set version - LoadCustomAssets + uses: jossef/action-set-json-field@v1 + with: + file: src\SampleMods\OWML.LoadCustomAssets\manifest.json + field: version + value: ${{ steps.version.outputs.prop }} + - name: set assembly version + uses: rshillington/file-content-replacer@master + with: + files: "**/AssemblyInfo.cs" + from: '\[assembly: AssemblyVersion\("[0-9.]*"\)\]' + to: '[assembly: AssemblyVersion("${{ steps.version.outputs.prop }}")]' + + - name: setup msbuild + uses: microsoft/setup-msbuild@v1 + - name: setup nuget + uses: NuGet/setup-nuget@v1.0.2 + - name: restore + run: nuget restore OWML.sln + - name: build + run: msbuild OWML.sln + + - name: pack + run: nuget pack src\OWML.ModHelper\OWML.ModHelper.csproj + - name: upload nuget + uses: actions/upload-artifact@v2 + with: + name: owml-nuget + path: OWML.*.nupkg + + - name: create zip + run: | + cd src\OWML.Launcher\bin\Debug + mkdir Logs + mkdir Mods + 7z a OWML.zip * + - name: upload zip + uses: actions/upload-artifact@v2 + with: + name: owml-zip + path: src\OWML.Launcher\bin\Debug\OWML.zip + + nuget: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/master' + steps: + - name: download artifact + uses: actions/download-artifact@v2 + with: + name: owml-nuget + - name: publish + uses: myci-actions/publish-nuget@2 # todo untested + with: + filename: OWML.*.nupkg + api-key: ${{ secrets.NUGET_KEY }} + + release: + runs-on: ubuntu-latest + needs: nuget + if: github.ref == 'refs/heads/master' + steps: + - name: download artifact + uses: actions/download-artifact@v2 + with: + name: owml-zip + - name: create release # todo untested + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.prop }} + release_name: ${{ steps.version.outputs.prop }} + draft: true # todo + prerelease: true # todo + - name: upload zip to release # todo untested + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./OWML.zip + asset_name: OWML.zip + asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index b011a110..4c7983ab 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ StyleCopReport.xml *.ilk *.meta *.obj +!duck.obj *.iobj *.pch *.pdb diff --git a/OWML.Common/Constants.cs b/OWML.Common/Constants.cs deleted file mode 100644 index 2dfb4149..00000000 --- a/OWML.Common/Constants.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace OWML.Common -{ - public class Constants - { - public const string OwmlTitle = "OWML"; - public const string ConsolePortArgument = "consolePort"; - public const string OwmlConfigFileName = "OWML.Config.json"; - public const string OwmlDefaultConfigFileName = "OWML.DefaultConfig.json"; - public const string OwmlManifestFileName = "OWML.Manifest.json"; - public const string LocalAddress = "127.0.0.1"; - public const string ModConfigFileName = "config.json"; - public const string ModDefaultConfigFileName = "default-config.json"; - public const string ModManifestFileName = "manifest.json"; - } -} diff --git a/OWML.Common/Events.cs b/OWML.Common/Events.cs deleted file mode 100644 index cef4af8a..00000000 --- a/OWML.Common/Events.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace OWML.Common -{ - public enum Events - { - BeforeAwake = 0, - AfterAwake = 1, - BeforeStart = 2, - AfterStart = 3, - BeforeEnable = 4, - AfterEnable = 5, - BeforeDisable = 6, - AfterDisable = 7, - BeforeDestroy = 8, - AfterDestroy = 9 - } -} diff --git a/OWML.Common/IHarmonyHelper.cs b/OWML.Common/IHarmonyHelper.cs deleted file mode 100644 index d2391027..00000000 --- a/OWML.Common/IHarmonyHelper.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Reflection; - -namespace OWML.Common -{ - public interface IHarmonyHelper - { - void AddPrefix(string methodName, Type patchType, string patchMethodName); - void AddPrefix(MethodBase methodInfo, Type patchType, string patchMethodName); - - void AddPostfix(string methodName, Type patchType, string patchMethodName); - void AddPostfix(MethodBase methodInfo, Type patchType, string patchMethodName); - - void EmptyMethod(string methodName); - void EmptyMethod(MethodBase methodInfo); - - void Transpile(string methodName, Type patchType, string patchMethodName); - void Transpile(MethodBase methodInfo, Type patchType, string patchMethodName); - } -} diff --git a/OWML.Common/IModAsset.cs b/OWML.Common/IModAsset.cs deleted file mode 100644 index 97c924b5..00000000 --- a/OWML.Common/IModAsset.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace OWML.Common -{ - public interface IModAsset - { - event Action Loaded; - - [Obsolete("Use Loaded instead.")] - Action OnLoaded { get; set; } - - T Asset { get; } - } -} diff --git a/OWML.Common/IModAssets.cs b/OWML.Common/IModAssets.cs deleted file mode 100644 index 1db97584..00000000 --- a/OWML.Common/IModAssets.cs +++ /dev/null @@ -1,13 +0,0 @@ -using UnityEngine; - -namespace OWML.Common -{ - public interface IModAssets - { - AssetBundle LoadBundle(string filename); - IModAsset Load3DObject(string objectFilename, string imageFilename); - IModAsset LoadMesh(string objectFilename); - IModAsset LoadTexture(string imageFilename); - IModAsset LoadAudio(string audioFilename); - } -} diff --git a/OWML.Common/IModBehaviour.cs b/OWML.Common/IModBehaviour.cs deleted file mode 100644 index f1b48ba9..00000000 --- a/OWML.Common/IModBehaviour.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModBehaviour - { - IModHelper ModHelper { get; } - object Api { get; } - void Configure(IModConfig config); - IList GetDependants(); - IList GetDependencies(); - object GetApi(); - } -} diff --git a/OWML.Common/IModConfig.cs b/OWML.Common/IModConfig.cs deleted file mode 100644 index 8e37fedb..00000000 --- a/OWML.Common/IModConfig.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModConfig - { - bool Enabled { get; set; } - Dictionary Settings { get; set; } - - T GetSettingsValue(string key); - void SetSettingsValue(string key, object value); - - IModConfig Copy(); - } -} diff --git a/OWML.Common/IModConsole.cs b/OWML.Common/IModConsole.cs deleted file mode 100644 index b92fd8c4..00000000 --- a/OWML.Common/IModConsole.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace OWML.Common -{ - public interface IModConsole - { - [Obsolete("Use WriteLine(string) or WriteLine(string, MessageType) instead.")] - void WriteLine(params object[] objects); - - void WriteLine(string line); - void WriteLine(string line, MessageType type); - } -} diff --git a/OWML.Common/IModData.cs b/OWML.Common/IModData.cs deleted file mode 100644 index be3d2195..00000000 --- a/OWML.Common/IModData.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace OWML.Common -{ - public interface IModData - { - IModManifest Manifest { get; } - IModConfig Config { get; } - IModConfig DefaultConfig { get; } - bool Enabled { get; } - bool RequireVR { get; } - bool RequireReload { get; } - - void UpdateSnapshot(); - void ResetConfigToDefaults(); - bool FixConfigs(); - } -} \ No newline at end of file diff --git a/OWML.Common/IModEvents.cs b/OWML.Common/IModEvents.cs deleted file mode 100644 index d7c8c166..00000000 --- a/OWML.Common/IModEvents.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using UnityEngine; - -namespace OWML.Common -{ - public interface IModEvents - { - IModPlayerEvents Player { get; } - IModSceneEvents Scenes { get; } - IModUnityEvents Unity { get; } - - event Action Event; - - [Obsolete("Use Event instead.")] - Action OnEvent { get; set; } - - void Subscribe(Events ev) where T : MonoBehaviour; - } -} diff --git a/OWML.Common/IModFinder.cs b/OWML.Common/IModFinder.cs deleted file mode 100644 index 8941979b..00000000 --- a/OWML.Common/IModFinder.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModFinder - { - List GetMods(); - } -} diff --git a/OWML.Common/IModHelper.cs b/OWML.Common/IModHelper.cs deleted file mode 100644 index f2cdc352..00000000 --- a/OWML.Common/IModHelper.cs +++ /dev/null @@ -1,20 +0,0 @@ -using OWML.Common.Menus; - -namespace OWML.Common -{ - public interface IModHelper - { - IModLogger Logger { get; } - IModConsole Console { get; } - IModEvents Events { get; } - IHarmonyHelper HarmonyHelper { get; } - IModAssets Assets { get; } - IModStorage Storage { get; } - IModMenus Menus { get; } - IModManifest Manifest { get; } - IModConfig Config { get; } - IOwmlConfig OwmlConfig { get; } - IModInputHandler Input { get; } - IModInteraction Interaction { get; } - } -} diff --git a/OWML.Common/IModInputCombination.cs b/OWML.Common/IModInputCombination.cs deleted file mode 100644 index d5188c0d..00000000 --- a/OWML.Common/IModInputCombination.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.ObjectModel; -using UnityEngine; - -namespace OWML.Common -{ - public interface IModInputCombination - { - float LastPressedMoment { get; } - float PressDuration { get; } - string ModName { get; } - string Name { get; } - string FullName { get; } - ReadOnlyCollection Singles { get; } - ReadOnlyCollection Hashes { get; } - bool IsFirst { get; } - - void InternalSetPressed(bool isPressed = true); - } -} diff --git a/OWML.Common/IModInputHandler.cs b/OWML.Common/IModInputHandler.cs deleted file mode 100644 index 9a33d9f6..00000000 --- a/OWML.Common/IModInputHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModInputHandler - { - IModInputTextures Textures { get; } - - IModInputCombination RegisterCombination(IModBehaviour mod, string name, string combination); - void UnregisterCombination(IModInputCombination combo); - bool IsPressedExact(IModInputCombination combo); - bool IsNewlyPressedExact(IModInputCombination combo); - bool WasTappedExact(IModInputCombination combo); - bool WasNewlyReleasedExact(IModInputCombination combo); - bool IsPressed(IModInputCombination combo); - bool IsNewlyPressed(IModInputCombination combo); - bool WasTapped(IModInputCombination combo); - bool WasNewlyReleased(IModInputCombination combo); - List GetWarningMessages(string combinations); - } -} diff --git a/OWML.Common/IModInputTextures.cs b/OWML.Common/IModInputTextures.cs deleted file mode 100644 index 715146fc..00000000 --- a/OWML.Common/IModInputTextures.cs +++ /dev/null @@ -1,10 +0,0 @@ -using UnityEngine; - -namespace OWML.Common -{ - public interface IModInputTextures - { - Texture2D KeyTexture(string key); - Texture2D KeyTexture(KeyCode key); - } -} diff --git a/OWML.Common/IModInteraction.cs b/OWML.Common/IModInteraction.cs deleted file mode 100644 index acd33266..00000000 --- a/OWML.Common/IModInteraction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModInteraction - { - IList GetMods(); - IList GetDependants(string dependencyUniqueName); - IList GetDependencies(string uniqueName); - IModBehaviour GetMod(string uniqueName); - TInterface GetModApi(string uniqueName) where TInterface : class; - bool ModExists(string uniqueName); - } -} diff --git a/OWML.Common/IModLogger.cs b/OWML.Common/IModLogger.cs deleted file mode 100644 index 03ba733b..00000000 --- a/OWML.Common/IModLogger.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common -{ - public interface IModLogger - { - void Log(string s); - void Log(params object[] s); - } -} diff --git a/OWML.Common/IModManifest.cs b/OWML.Common/IModManifest.cs deleted file mode 100644 index 9724faa6..00000000 --- a/OWML.Common/IModManifest.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; - -namespace OWML.Common -{ - public interface IModManifest - { - string Filename { get; } - string Author { get; } - string Name { get; } - string Version { get; } - string OWMLVersion { get; } - string AssemblyPath { get; } - string UniqueName { get; } - string ModFolderPath { get; set; } - Dictionary AppIds { get; } - string[] Dependencies { get; } - bool PriorityLoad { get; } - bool RequireVR { get; } - string MinGameVersion { get; } - string MaxGameVersion { get; } - } -} diff --git a/OWML.Common/IModPlayerEvents.cs b/OWML.Common/IModPlayerEvents.cs deleted file mode 100644 index 5014c809..00000000 --- a/OWML.Common/IModPlayerEvents.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace OWML.Common -{ - public interface IModPlayerEvents - { - event Action OnPlayerAwake; - } -} diff --git a/OWML.Common/IModSceneEvents.cs b/OWML.Common/IModSceneEvents.cs deleted file mode 100644 index 34810dff..00000000 --- a/OWML.Common/IModSceneEvents.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OWML.Common -{ - public interface IModSceneEvents - { - event Action OnStartSceneChange; - event Action OnCompleteSceneChange; - } -} diff --git a/OWML.Common/IModSocket.cs b/OWML.Common/IModSocket.cs deleted file mode 100644 index a13388ac..00000000 --- a/OWML.Common/IModSocket.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common -{ - public interface IModSocket - { - void WriteToSocket(IModSocketMessage message); - void Close(); - } -} diff --git a/OWML.Common/IModSocketMessage.cs b/OWML.Common/IModSocketMessage.cs deleted file mode 100644 index c738b7f2..00000000 --- a/OWML.Common/IModSocketMessage.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OWML.Common -{ - public interface IModSocketMessage - { - string SenderName { get; } - string SenderType { get; } - MessageType Type { get; } - string Message { get; } - } -} diff --git a/OWML.Common/IModStorage.cs b/OWML.Common/IModStorage.cs deleted file mode 100644 index 59f3d7ab..00000000 --- a/OWML.Common/IModStorage.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common -{ - public interface IModStorage - { - T Load(string filename); - void Save(T obj, string filename); - } -} diff --git a/OWML.Common/IModUnityEvents.cs b/OWML.Common/IModUnityEvents.cs deleted file mode 100644 index 675a2ddc..00000000 --- a/OWML.Common/IModUnityEvents.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace OWML.Common -{ - public interface IModUnityEvents - { - event Action OnUpdate; - event Action OnFixedUpdate; - event Action OnLateUpdate; - - void FireOnNextUpdate(Action action); - void FireInNUpdates(Action action, int n); - void RunWhen(Func predicate, Action action); - } -} diff --git a/OWML.Common/IOwmlConfig.cs b/OWML.Common/IOwmlConfig.cs deleted file mode 100644 index 66597ba5..00000000 --- a/OWML.Common/IOwmlConfig.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace OWML.Common -{ - public interface IOwmlConfig - { - string GamePath { get; set; } - string ManagedPath { get; } - string PluginsPath { get; } - string DataPath { get; } - string OWMLPath { get; set; } - string ModsPath { get; } - bool BlockInput { get; set; } - int SocketPort { get; set; } - } -} diff --git a/OWML.Common/Menus/IModButton.cs b/OWML.Common/Menus/IModButton.cs deleted file mode 100644 index 93b096f8..00000000 --- a/OWML.Common/Menus/IModButton.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using UnityEngine.UI; - -namespace OWML.Common.Menus -{ - public interface IModButton : IModButtonBase - { - event Action OnClick; - int Index { get; set; } - Button Button { get; } - void Initialize(IModMenu menu); - string Title { get; set; } - - new IModButton Copy(); - IModButton Copy(string title); - IModButton Copy(string title, int index); - - IModButton Duplicate(string title); - IModButton Duplicate(string title, int index); - - IModButton Replace(string title); - IModButton Replace(string title, int index); - void Show(); - void Hide(); - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModButtonBase.cs b/OWML.Common/Menus/IModButtonBase.cs deleted file mode 100644 index 2e26a635..00000000 --- a/OWML.Common/Menus/IModButtonBase.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using UnityEngine.UI; - -namespace OWML.Common.Menus -{ - public interface IModButtonBase - { - event Action OnClick; - int Index { get; set; } - Button Button { get; } - bool IsSelected { get; } - void Initialize(IModMenu menu); - - IModButtonBase Copy(); - IModButtonBase Copy(int index); - - IModButtonBase Duplicate(); - IModButtonBase Duplicate(int index); - - IModButtonBase Replace(); - IModButtonBase Replace(int index); - - void Show(); - void Hide(); - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModComboInput.cs b/OWML.Common/Menus/IModComboInput.cs deleted file mode 100644 index 8218e857..00000000 --- a/OWML.Common/Menus/IModComboInput.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModComboInput : IModInput - { - IModLayoutButton Button { get; } - IModComboInput Copy(); - IModComboInput Copy(string key); - } -} diff --git a/OWML.Common/Menus/IModConfigMenu.cs b/OWML.Common/Menus/IModConfigMenu.cs deleted file mode 100644 index 1bab4a3e..00000000 --- a/OWML.Common/Menus/IModConfigMenu.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModConfigMenu : IModConfigMenuBase - { - IModData ModData { get; } - IModBehaviour Mod { get; } - } -} diff --git a/OWML.Common/Menus/IModConfigMenuBase.cs b/OWML.Common/Menus/IModConfigMenuBase.cs deleted file mode 100644 index b8da9322..00000000 --- a/OWML.Common/Menus/IModConfigMenuBase.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModConfigMenuBase : IModPopupMenu - { - IModManifest Manifest { get; } - - void Initialize(Menu modMenuCopy, IModToggleInput toggleTemplate, IModSliderInput sliderTemplate, - IModTextInput textInputTemplate, IModNumberInput numberInputTemplate, - IModComboInput comboInputTemplate, IModSelectorInput selectorTemplate); - } -} diff --git a/OWML.Common/Menus/IModFieldInput.cs b/OWML.Common/Menus/IModFieldInput.cs deleted file mode 100644 index 3c2ca84f..00000000 --- a/OWML.Common/Menus/IModFieldInput.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModFieldInput : IModInput - { - IModButton Button { get; } - } -} diff --git a/OWML.Common/Menus/IModInput.cs b/OWML.Common/Menus/IModInput.cs deleted file mode 100644 index 62eec80d..00000000 --- a/OWML.Common/Menus/IModInput.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OWML.Common.Menus -{ - public interface IModInput : IModInputBase - { - event Action OnChange; - T Value { get; set; } - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModInputBase.cs b/OWML.Common/Menus/IModInputBase.cs deleted file mode 100644 index 56f21064..00000000 --- a/OWML.Common/Menus/IModInputBase.cs +++ /dev/null @@ -1,15 +0,0 @@ -using UnityEngine; - -namespace OWML.Common.Menus -{ - public interface IModInputBase - { - MonoBehaviour Element { get; } - string Title { get; set; } - int Index { get; set; } - bool IsSelected { get; } - void Show(); - void Hide(); - void Initialize(IModMenu menu); - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModInputCombinationElement.cs b/OWML.Common/Menus/IModInputCombinationElement.cs deleted file mode 100644 index 01d0ae46..00000000 --- a/OWML.Common/Menus/IModInputCombinationElement.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModInputCombinationElement : IModToggleInput - { - IModLayoutManager Layout { get; } - void Destroy(); - void DestroySelf(); - new IModInputCombinationElement Copy(string combination); - } -} diff --git a/OWML.Common/Menus/IModInputCombinationElementMenu.cs b/OWML.Common/Menus/IModInputCombinationElementMenu.cs deleted file mode 100644 index 9ac8da44..00000000 --- a/OWML.Common/Menus/IModInputCombinationElementMenu.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OWML.Common.Menus -{ - public interface IModInputCombinationElementMenu : IModMenu - { - event Action OnConfirm; - event Action OnCancel; - } -} diff --git a/OWML.Common/Menus/IModInputCombinationMenu.cs b/OWML.Common/Menus/IModInputCombinationMenu.cs deleted file mode 100644 index 71f37f2b..00000000 --- a/OWML.Common/Menus/IModInputCombinationMenu.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace OWML.Common.Menus -{ - public interface IModInputCombinationMenu : IModPopupMenu - { - event Action OnConfirm; - event Action OnCancel; - - List CombinationElements { get; } - string GenerateCombination(); - void FillMenu(string combination); - void Initialize(Menu menu, IModInputCombinationElement combinationElementTemplate); - void RemoveCombinationElement(IModInputCombinationElement element); - } -} diff --git a/OWML.Common/Menus/IModInputMenu.cs b/OWML.Common/Menus/IModInputMenu.cs deleted file mode 100644 index e494ef6e..00000000 --- a/OWML.Common/Menus/IModInputMenu.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OWML.Common.Menus -{ - public interface IModInputMenu : IModMenu - { - event Action OnConfirm; - event Action OnCancel; - } -} diff --git a/OWML.Common/Menus/IModLayoutButton.cs b/OWML.Common/Menus/IModLayoutButton.cs deleted file mode 100644 index e71f1e2f..00000000 --- a/OWML.Common/Menus/IModLayoutButton.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModLayoutButton : IModButtonBase - { - IModLayoutManager Layout { get; } - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModLayoutManager.cs b/OWML.Common/Menus/IModLayoutManager.cs deleted file mode 100644 index 1452b453..00000000 --- a/OWML.Common/Menus/IModLayoutManager.cs +++ /dev/null @@ -1,18 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace OWML.Common.Menus -{ - public interface IModLayoutManager - { - LayoutGroup LayoutGroup { get; } - int ChildCount { get; } - - void UpdateState(); - void Clear(); - void AddText(string text); - void AddTextAt(string text, int index); - void AddPicture(Texture2D texture, float scale = 1.0f); - void AddPictureAt(Texture2D texture, int index, float scale = 1.0f); - } -} diff --git a/OWML.Common/Menus/IModMainMenu.cs b/OWML.Common/Menus/IModMainMenu.cs deleted file mode 100644 index 8d779031..00000000 --- a/OWML.Common/Menus/IModMainMenu.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModMainMenu : IModOWMenu - { - new IModTabbedMenu OptionsMenu { get; } - new IModButton OptionsButton { get; } - new IModButton QuitButton { get; } - IModButton ResumeExpeditionButton { get; } - IModButton NewExpeditionButton { get; } - IModButton ViewCreditsButton { get; } - IModButton SwitchProfileButton { get; } - - void Initialize(TitleScreenManager titleScreenManager); - } -} diff --git a/OWML.Common/Menus/IModMenu.cs b/OWML.Common/Menus/IModMenu.cs deleted file mode 100644 index a37747a4..00000000 --- a/OWML.Common/Menus/IModMenu.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace OWML.Common.Menus -{ - public interface IModMenu - { - event Action OnInit; - - Menu Menu { get; } - - List BaseButtons { get; } - List Buttons { get; } - List LayoutButtons { get; } - List PromptButtons { get; } - - [Obsolete("Use GetTitleButton instead")] - IModButton GetButton(string title); - IModButton GetTitleButton(string title); - IModPromptButton GetPromptButton(string title); - - [Obsolete("Use AddButton(IModButtonBase) instead.")] - IModButton AddButton(IModButton button); - [Obsolete("Use AddButton(IModButtonBase, int) instead.")] - IModButton AddButton(IModButton button, int index); - IModButtonBase AddButton(IModButtonBase button); - IModButtonBase AddButton(IModButtonBase button, int index); - - List ToggleInputs { get; } - IModToggleInput GetToggleInput(string title); - IModToggleInput AddToggleInput(IModToggleInput input); - IModToggleInput AddToggleInput(IModToggleInput input, int index); - - List SliderInputs { get; } - IModSliderInput GetSliderInput(string title); - IModSliderInput AddSliderInput(IModSliderInput input); - IModSliderInput AddSliderInput(IModSliderInput input, int index); - - List SelectorInputs { get; } - IModSelectorInput GetSelectorInput(string title); - IModSelectorInput AddSelectorInput(IModSelectorInput input); - IModSelectorInput AddSelectorInput(IModSelectorInput input, int index); - - List TextInputs { get; } - IModTextInput GetTextInput(string title); - IModTextInput AddTextInput(IModTextInput input); - IModTextInput AddTextInput(IModTextInput input, int index); - - List NumberInputs { get; } - IModNumberInput GetNumberInput(string title); - IModNumberInput AddNumberInput(IModNumberInput input); - IModNumberInput AddNumberInput(IModNumberInput input, int index); - - List Separators { get; } - IModSeparator AddSeparator(IModSeparator separator); - IModSeparator AddSeparator(IModSeparator separator, int index); - IModSeparator GetSeparator(string title); - - object GetInputValue(string key); - void SetInputValue(string key, object value); - - void SelectFirst(); - void UpdateNavigation(); - } -} diff --git a/OWML.Common/Menus/IModMenuWithSelectables.cs b/OWML.Common/Menus/IModMenuWithSelectables.cs deleted file mode 100644 index eee89a2e..00000000 --- a/OWML.Common/Menus/IModMenuWithSelectables.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace OWML.Common.Menus -{ - public interface IModMenuWithSelectables : IModPopupMenu - { - event Action OnCancel; - } -} diff --git a/OWML.Common/Menus/IModMenus.cs b/OWML.Common/Menus/IModMenus.cs deleted file mode 100644 index 82b036d9..00000000 --- a/OWML.Common/Menus/IModMenus.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModMenus - { - IModMainMenu MainMenu { get; } - IModPauseMenu PauseMenu { get; } - IModsMenu ModsMenu { get; } - IModInputCombinationMenu InputCombinationMenu { get; } - IModPopupManager PopupManager { get; } - } -} diff --git a/OWML.Common/Menus/IModMessagePopup.cs b/OWML.Common/Menus/IModMessagePopup.cs deleted file mode 100644 index 7d396fd2..00000000 --- a/OWML.Common/Menus/IModMessagePopup.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OWML.Common.Menus -{ - public interface IModMessagePopup : IModMenu - { - event Action OnConfirm; - event Action OnCancel; - } -} diff --git a/OWML.Common/Menus/IModNumberInput.cs b/OWML.Common/Menus/IModNumberInput.cs deleted file mode 100644 index 312bb6c3..00000000 --- a/OWML.Common/Menus/IModNumberInput.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModNumberInput : IModFieldInput - { - IModNumberInput Copy(); - IModNumberInput Copy(string key); - } -} diff --git a/OWML.Common/Menus/IModOWMenu.cs b/OWML.Common/Menus/IModOWMenu.cs deleted file mode 100644 index b4f1cfea..00000000 --- a/OWML.Common/Menus/IModOWMenu.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModOWMenu : IModMenu - { - IModTabbedMenu OptionsMenu { get; } - IModButton OptionsButton { get; } - IModButton QuitButton { get; } - } -} diff --git a/OWML.Common/Menus/IModPauseMenu.cs b/OWML.Common/Menus/IModPauseMenu.cs deleted file mode 100644 index 23e541ba..00000000 --- a/OWML.Common/Menus/IModPauseMenu.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModPauseMenu : IModPopupMenu, IModOWMenu - { - new IModTabbedMenu OptionsMenu { get; } - new IModButton OptionsButton { get; } - new IModButton QuitButton { get; } - IModButton ResumeButton { get; } - - void Initialize(SettingsManager settingsManager); - } -} diff --git a/OWML.Common/Menus/IModPopupManager.cs b/OWML.Common/Menus/IModPopupManager.cs deleted file mode 100644 index 26af5ab4..00000000 --- a/OWML.Common/Menus/IModPopupManager.cs +++ /dev/null @@ -1,13 +0,0 @@ -using UnityEngine; - -namespace OWML.Common.Menus -{ - public interface IModPopupManager - { - void Initialize(GameObject popupCanvas); - IModMessagePopup CreateMessagePopup(string message, bool addCancel = false, string okMessage = "OK", string cancelMessage = "Cancel"); - IModInputMenu CreateInputPopup(InputType inputType, string value); - IModInputCombinationElementMenu CreateCombinationInput(string value, string comboName, - IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null); - } -} diff --git a/OWML.Common/Menus/IModPopupMenu.cs b/OWML.Common/Menus/IModPopupMenu.cs deleted file mode 100644 index ef815c72..00000000 --- a/OWML.Common/Menus/IModPopupMenu.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using UnityEngine.UI; - -namespace OWML.Common.Menus -{ - public interface IModPopupMenu : IModMenu - { - event Action OnOpened; - event Action OnClosed; - - [Obsolete("Use OnOpened instead.")] - Action OnOpen { get; set; } - [Obsolete("Use OnClosed instead.")] - Action OnClose { get; set; } - - bool IsOpen { get; } - string Title { get; set; } - - void Open(); - void Close(); - void Toggle(); - - IModPopupMenu Copy(); - IModPopupMenu Copy(string title); - void Initialize(Menu menu); - void Initialize(Menu menu, LayoutGroup layoutGroup); - } -} diff --git a/OWML.Common/Menus/IModPromptButton.cs b/OWML.Common/Menus/IModPromptButton.cs deleted file mode 100644 index 5cf4760c..00000000 --- a/OWML.Common/Menus/IModPromptButton.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModPromptButton : IModButton - { - string DefaultTitle { get; } - ScreenPrompt Prompt { get; set; } - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModSelectorInput.cs b/OWML.Common/Menus/IModSelectorInput.cs deleted file mode 100644 index f3dbd91b..00000000 --- a/OWML.Common/Menus/IModSelectorInput.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModSelectorInput : IModInput - { - int SelectedIndex { get; set; } - void Initialize(string option, string[] options); - IModSelectorInput Copy(); - IModSelectorInput Copy(string title); - } -} diff --git a/OWML.Common/Menus/IModSeparator.cs b/OWML.Common/Menus/IModSeparator.cs deleted file mode 100644 index 4958cae0..00000000 --- a/OWML.Common/Menus/IModSeparator.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine.UI; - -namespace OWML.Common.Menus -{ - public interface IModSeparator : IModInputBase - { - LayoutElement LayoutElement { get; } - - IModSeparator Copy(); - IModSeparator Copy(string title); - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModSliderInput.cs b/OWML.Common/Menus/IModSliderInput.cs deleted file mode 100644 index a842133f..00000000 --- a/OWML.Common/Menus/IModSliderInput.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModSliderInput : IModInput - { - float Min { get; set; } - float Max { get; set; } - bool HasValueText { get; } - - IModSliderInput Copy(); - IModSliderInput Copy(string title); - } -} diff --git a/OWML.Common/Menus/IModTabMenu.cs b/OWML.Common/Menus/IModTabMenu.cs deleted file mode 100644 index 4ef152e2..00000000 --- a/OWML.Common/Menus/IModTabMenu.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModTabMenu : IModPopupMenu - { - void Initialize(TabButton tabButton); - TabButton TabButton { get; } - new IModTabMenu Copy(); - new IModTabMenu Copy(string title); - } -} \ No newline at end of file diff --git a/OWML.Common/Menus/IModTabbedMenu.cs b/OWML.Common/Menus/IModTabbedMenu.cs deleted file mode 100644 index e2327425..00000000 --- a/OWML.Common/Menus/IModTabbedMenu.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModTabbedMenu : IModPopupMenu - { - IModTabMenu GameplayTab { get; } - IModTabMenu AudioTab { get; } - IModTabMenu InputTab { get; } - IModTabMenu GraphicsTab { get; } - - IModButton RebindingButton { get; } - IModPopupMenu RebindingMenu { get; } - - new IModTabbedMenu Copy(); - - void Initialize(TabbedMenu menu); - new TabbedMenu Menu { get; } - void AddTab(IModTabMenu tab); - } -} diff --git a/OWML.Common/Menus/IModTextInput.cs b/OWML.Common/Menus/IModTextInput.cs deleted file mode 100644 index ebbb147e..00000000 --- a/OWML.Common/Menus/IModTextInput.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModTextInput : IModFieldInput - { - IModTextInput Copy(); - IModTextInput Copy(string key); - } -} diff --git a/OWML.Common/Menus/IModToggleInput.cs b/OWML.Common/Menus/IModToggleInput.cs deleted file mode 100644 index de528386..00000000 --- a/OWML.Common/Menus/IModToggleInput.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModToggleInput : IModInput - { - TwoButtonToggleElement Toggle { get; } - IModButton YesButton { get; } - IModButton NoButton { get; } - IModToggleInput Copy(); - IModToggleInput Copy(string key); - } -} diff --git a/OWML.Common/Menus/IModsMenu.cs b/OWML.Common/Menus/IModsMenu.cs deleted file mode 100644 index 134b74d5..00000000 --- a/OWML.Common/Menus/IModsMenu.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace OWML.Common.Menus -{ - public interface IModsMenu : IModPopupMenu - { - void AddMod(IModData modData, IModBehaviour mod); - IModConfigMenu GetModMenu(IModBehaviour modBehaviour); - void Initialize(IModOWMenu mainMenu); - } -} diff --git a/OWML.Common/Menus/InputType.cs b/OWML.Common/Menus/InputType.cs deleted file mode 100644 index 9b714490..00000000 --- a/OWML.Common/Menus/InputType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace OWML.Common.Menus -{ - public enum InputType - { - Text = 0, - Number = 1 - } - -} diff --git a/OWML.Common/MessageType.cs b/OWML.Common/MessageType.cs deleted file mode 100644 index 789c7c0a..00000000 --- a/OWML.Common/MessageType.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace OWML.Common -{ - public enum MessageType - { - Message = 0, - Error = 1, - Warning = 2, - Info = 3, - Success = 4, - Quit = 5, - Fatal = 6 - } -} diff --git a/OWML.Common/OWML.Common.csproj b/OWML.Common/OWML.Common.csproj deleted file mode 100644 index 64666766..00000000 --- a/OWML.Common/OWML.Common.csproj +++ /dev/null @@ -1,136 +0,0 @@ - - - - - Debug - AnyCPU - {3C00626F-B688-4F32-B493-5B7EC1C879A0} - Library - Properties - OWML.Common - OWML.Common - v3.5 - 512 - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\Assembly-CSharp.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\OW.Unity.Dlls.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.AudioModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.CoreModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.IMGUIModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.PhysicsModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.TextRenderingModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UI.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UIModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UnityWebRequestWWWModule.dll - - - - - - - \ No newline at end of file diff --git a/OWML.GameFinder/BaseFinder.cs b/OWML.GameFinder/BaseFinder.cs deleted file mode 100644 index e14921b6..00000000 --- a/OWML.GameFinder/BaseFinder.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO; -using OWML.Common; - -namespace OWML.GameFinder -{ - public abstract class BaseFinder - { - private const string ManagedPath = "OuterWilds_Data/Managed"; - private const string ExePath = "OuterWilds.exe"; - - protected IOwmlConfig Config; - protected IModConsole Writer; - - protected BaseFinder(IOwmlConfig config, IModConsole writer) - { - Config = config; - Writer = writer; - } - - public abstract string FindGamePath(); - - protected bool IsValidGamePath(string gamePath) - { - return !string.IsNullOrEmpty(gamePath) && - Directory.Exists(gamePath) && - Directory.Exists($"{gamePath}/{ManagedPath}") && - File.Exists($"{gamePath}/{ExePath}"); - } - } -} \ No newline at end of file diff --git a/OWML.GameFinder/CurrentPathFinder.cs b/OWML.GameFinder/CurrentPathFinder.cs deleted file mode 100644 index f39beb22..00000000 --- a/OWML.GameFinder/CurrentPathFinder.cs +++ /dev/null @@ -1,22 +0,0 @@ -using OWML.Common; - -namespace OWML.GameFinder -{ - public class CurrentPathFinder : BaseFinder - { - public CurrentPathFinder(IOwmlConfig config, IModConsole writer) : base(config, writer) - { - } - - public override string FindGamePath() - { - if (IsValidGamePath(Config.GamePath)) - { - return Config.GamePath; - } - Writer.WriteLine($"Current game path is not valid: {Config.GamePath}", MessageType.Error); - return null; - } - - } -} diff --git a/OWML.GameFinder/DefaultLocationFinder.cs b/OWML.GameFinder/DefaultLocationFinder.cs deleted file mode 100644 index c0aa9913..00000000 --- a/OWML.GameFinder/DefaultLocationFinder.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Linq; -using OWML.Common; - -namespace OWML.GameFinder -{ - public class DefaultLocationFinder : BaseFinder - { - private static readonly string[] DefaultLocations = - { - $"{AppDomain.CurrentDomain.BaseDirectory}..", - "C:/Program Files (x86)/Outer Wilds", - "D:/Program Files (x86)/Outer Wilds", - "E:/Program Files (x86)/Outer Wilds", - "F:/Program Files (x86)/Outer Wilds", - "C:/Games/Outer Wilds", - "D:/Games/Outer Wilds", - "E:/Games/Outer Wilds", - "F:/Games/Outer Wilds" - }; - - public DefaultLocationFinder(IOwmlConfig config, IModConsole writer) : base(config, writer) - { - } - - public override string FindGamePath() - { - var gamePath = DefaultLocations.FirstOrDefault(IsValidGamePath); - if (!string.IsNullOrEmpty(gamePath)) - { - return gamePath; - } - Writer.WriteLine("Game not found in default locations."); - return null; - } - } -} diff --git a/OWML.GameFinder/EpicGameFinder.cs b/OWML.GameFinder/EpicGameFinder.cs deleted file mode 100644 index b395cc93..00000000 --- a/OWML.GameFinder/EpicGameFinder.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.IO; -using Microsoft.Win32; -using Newtonsoft.Json; -using OWML.Common; - -namespace OWML.GameFinder -{ - public class EpicGameFinder : BaseFinder - { - private const string RegistryPath = @"SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher"; - private const string RegistryName = "AppDataPath"; - private const string ManifestsFolder = "Manifests"; - private const string ManifestPattern = "*.item"; - private const string ManifestGameName = "OuterWilds"; - - public EpicGameFinder(IOwmlConfig config, IModConsole writer) : base(config, writer) - { - } - - public override string FindGamePath() - { - var key = Registry.LocalMachine.OpenSubKey(RegistryPath); - var appDataPath = (string)key?.GetValue(RegistryName); - if (string.IsNullOrEmpty(appDataPath)) - { - Writer.WriteLine("EGS not found in Registry."); - return null; - } - var manifestsPath = $"{appDataPath}{ManifestsFolder}"; - if (!Directory.Exists(manifestsPath)) - { - Writer.WriteLine($"EGS manifests folder not found: {manifestsPath}"); - return null; - } - var manifestPaths = Directory.GetFiles(manifestsPath, ManifestPattern, SearchOption.TopDirectoryOnly); - foreach (var manifestPath in manifestPaths) - { - var json = File.ReadAllText(manifestPath); - var epicManifest = JsonConvert.DeserializeObject(json); - if (epicManifest.InstallLocation.Contains(ManifestGameName) && IsValidGamePath(epicManifest.InstallLocation)) - { - return epicManifest.InstallLocation; - } - } - Writer.WriteLine("Game not found in EGS."); - return null; - } - - private class EpicManifest - { - [JsonProperty("InstallLocation")] - public string InstallLocation { get; set; } - } - } -} diff --git a/OWML.GameFinder/PathFinder.cs b/OWML.GameFinder/PathFinder.cs deleted file mode 100644 index f0ca47ec..00000000 --- a/OWML.GameFinder/PathFinder.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using OWML.Common; - -namespace OWML.GameFinder -{ - public class PathFinder - { - private readonly IOwmlConfig _config; - private readonly IModConsole _writer; - - public PathFinder(IOwmlConfig config, IModConsole writer) - { - _config = config; - _writer = writer; - } - - public string FindGamePath() - { - return FindPathWith() ?? - FindPathWith() ?? - FindPathWith() ?? - FindPathWith() ?? - FindPathWith(); - } - - private string FindPathWith() where T : BaseFinder - { - var gameFinder = (T)Activator.CreateInstance(typeof(T), _config, _writer); - return gameFinder.FindGamePath(); - } - } -} diff --git a/OWML.GameFinder/PromptGameFinder.cs b/OWML.GameFinder/PromptGameFinder.cs deleted file mode 100644 index 25ab4b8a..00000000 --- a/OWML.GameFinder/PromptGameFinder.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using OWML.Common; - -namespace OWML.GameFinder -{ - public class PromptGameFinder : BaseFinder - { - public PromptGameFinder(IOwmlConfig config, IModConsole writer) : base(config, writer) - { - } - - public override string FindGamePath() - { - var gamePath = Config.GamePath; - while (!IsValidGamePath(gamePath)) - { - Writer.WriteLine($"Game not found at {gamePath}"); - Writer.WriteLine("Please enter the correct game path:"); - gamePath = Console.ReadLine()?.Trim(); - } - return gamePath; - } - } -} \ No newline at end of file diff --git a/OWML.GameFinder/SteamGameFinder.cs b/OWML.GameFinder/SteamGameFinder.cs deleted file mode 100644 index 12cf4609..00000000 --- a/OWML.GameFinder/SteamGameFinder.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.IO; -using Gameloop.Vdf; -using Microsoft.Win32; -using OWML.Common; - -namespace OWML.GameFinder -{ - public class SteamGameFinder : BaseFinder - { - private const string RegistryPath = @"SOFTWARE\Valve\Steam"; - private const string RegistryName = "SteamPath"; - private const string GameLocation = "steamapps/common/Outer Wilds"; - private const string LibraryFoldersPath = "steamapps/libraryfolders.vdf"; - private const int MaxLibraryCount = 10; - - public SteamGameFinder(IOwmlConfig config, IModConsole writer) : base(config, writer) - { - } - - public override string FindGamePath() - { - var key = Registry.CurrentUser.OpenSubKey(RegistryPath); - var steamPath = (string)key?.GetValue(RegistryName); - if (string.IsNullOrEmpty(steamPath)) - { - Writer.WriteLine("Steam not found in Registry."); - return null; - } - var defaultLocation = $"{steamPath}/{GameLocation}"; - if (IsValidGamePath(defaultLocation)) - { - return defaultLocation; - } - var libraryFoldersFile = $"{steamPath}/{LibraryFoldersPath}"; - if (!File.Exists(libraryFoldersFile)) - { - Writer.WriteLine($"Steam library folders file not found: {libraryFoldersFile}"); - return null; - } - var libraryFoldersContent = File.ReadAllText(libraryFoldersFile); - var libraryFoldersVdf = VdfConvert.Deserialize(libraryFoldersContent); - for (var i = 1; i < MaxLibraryCount; i++) - { - var libraryName = i.ToString(); - var libraryPath = libraryFoldersVdf.Value[libraryName]?.ToString(); - if (string.IsNullOrEmpty(libraryPath)) - { - Writer.WriteLine("Game not found in custom Steam library."); - return null; - } - var gamePath = $"{libraryPath}/{GameLocation}"; - if (IsValidGamePath(gamePath)) - { - return gamePath; - } - } - Writer.WriteLine("Game not found in Steam."); - return null; - } - - } -} diff --git a/OWML.Launcher/App.config b/OWML.Launcher/App.config deleted file mode 100644 index 07e79507..00000000 --- a/OWML.Launcher/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/OWML.Launcher/App.cs b/OWML.Launcher/App.cs deleted file mode 100644 index 23f928cb..00000000 --- a/OWML.Launcher/App.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using OWML.Common; -using OWML.GameFinder; -using OWML.ModHelper; -using OWML.Patcher; - -namespace OWML.Launcher -{ - public class App - { - private readonly IOwmlConfig _owmlConfig; - private readonly IModManifest _owmlManifest; - private readonly IModConsole _writer; - private readonly IModFinder _modFinder; - private readonly PathFinder _pathFinder; - private readonly OWPatcher _owPatcher; - private readonly VRPatcher _vrPatcher; - - public App(IOwmlConfig owmlConfig, IModManifest owmlManifest, IModConsole writer, IModFinder modFinder, - PathFinder pathFinder, OWPatcher owPatcher, VRPatcher vrPatcher) - { - _owmlConfig = owmlConfig; - _owmlManifest = owmlManifest; - _writer = writer; - _modFinder = modFinder; - _pathFinder = pathFinder; - _owPatcher = owPatcher; - _vrPatcher = vrPatcher; - } - - public void Run(string[] args) - { - _writer.WriteLine($"Started OWML v{_owmlManifest.Version}", MessageType.Info); - - LocateGamePath(); - - CheckGameVersion(); - - CopyGameFiles(); - - CreateLogsDirectory(); - - var mods = _modFinder.GetMods(); - - ShowModList(mods); - - PatchGame(mods); - - StartGame(args); - - var hasPortArgument = CommandLineArguments.HasArgument(Constants.ConsolePortArgument); - if (hasPortArgument) - { - ExitConsole(); - } - - Console.ReadLine(); - } - - private void LocateGamePath() - { - var gamePath = _pathFinder.FindGamePath(); - _writer.WriteLine("Game found in " + gamePath); - if (gamePath != _owmlConfig.GamePath) - { - _owmlConfig.GamePath = gamePath; - JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, _owmlConfig); - } - } - - private void CheckGameVersion() - { - var versionReader = new GameVersionReader(new BinaryPatcher(_owmlConfig, _writer)); - var gameVersionString = versionReader.GetGameVersion(); - _writer.WriteLine($"Game version: {gameVersionString}", MessageType.Info); - var isValidFormat = Version.TryParse(gameVersionString, out var gameVersion); - var minVersion = new Version(_owmlManifest.MinGameVersion); - var maxVersion = new Version(_owmlManifest.MaxGameVersion); - if (!isValidFormat) - { - _writer.WriteLine("Warning - non-standard game version formatting found", MessageType.Warning); - } - if (!isValidFormat || gameVersion > maxVersion) - { - PotentiallyUnsupported(); - return; - } - if (gameVersion < minVersion) - { - _writer.WriteLine("Unsupported game version found", MessageType.Error); - AnyKeyExitConsole(); - } - } - - private void AnyKeyExitConsole() - { - _writer.WriteLine("Press any key to exit...", MessageType.Info); - Console.ReadKey(); - ExitConsole(); - } - - private void PotentiallyUnsupported() - { - _writer.WriteLine("Potentially unsupported game version found, continue at your own risk", MessageType.Warning); - } - - private void CopyGameFiles() - { - var filesToCopy = new[] { "UnityEngine.CoreModule.dll", "Assembly-CSharp.dll" }; - foreach (var fileName in filesToCopy) - { - File.Copy($"{_owmlConfig.ManagedPath}/{fileName}", fileName, true); - } - _writer.WriteLine("Game files copied."); - } - - private void ShowModList(List mods) - { - if (!mods.Any()) - { - _writer.WriteLine("Warning - No mods found.", MessageType.Warning); - return; - } - _writer.WriteLine("Found mods:"); - foreach (var modData in mods) - { - var stateText = modData.Enabled ? "" : "(disabled)"; - var type = modData.Enabled ? MessageType.Message : MessageType.Warning; - _writer.WriteLine($"* {modData.Manifest.UniqueName} v{modData.Manifest.Version} {stateText}", type); - - if (!string.IsNullOrEmpty(modData.Manifest.OWMLVersion) && !IsMadeForSameOwmlMajorVersion(modData.Manifest)) - { - _writer.WriteLine($" Warning - Made for old version of OWML: v{modData.Manifest.OWMLVersion}", MessageType.Warning); - } - } - } - - private bool IsMadeForSameOwmlMajorVersion(IModManifest manifest) - { - var owmlVersionSplit = _owmlManifest.Version.Split('.'); - var modVersionSplit = manifest.OWMLVersion.Split('.'); - return owmlVersionSplit.Length == modVersionSplit.Length && - owmlVersionSplit[0] == modVersionSplit[0] && - owmlVersionSplit[1] == modVersionSplit[1]; - } - - private bool HasVrMod(List mods) - { - var vrMod = mods.FirstOrDefault(x => x.RequireVR && x.Enabled); - var hasVrMod = vrMod != null; - _writer.WriteLine(hasVrMod ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR."); - return hasVrMod; - } - - private void PatchGame(List mods) - { - _owPatcher.PatchGame(); - - try - { - var enableVR = HasVrMod(mods); - _vrPatcher.PatchVR(enableVR); - } - catch (Exception ex) - { - _writer.WriteLine($"Error while applying VR patch: {ex}", MessageType.Error); - } - } - - private void StartGame(string[] args) - { - _writer.WriteLine("Starting game..."); - - if (args.Contains("-consolePort")) - { - var index = Array.IndexOf(args, "-consolePort"); - var list = new List(args); - list.RemoveRange(index, 2); - args = list.ToArray(); - } - - try - { - Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", string.Join(" ", args)); - } - catch (Exception ex) - { - _writer.WriteLine($"Error while starting game: {ex.Message}", MessageType.Error); - } - } - - private void ExitConsole() - { - Environment.Exit(0); - } - - private void CreateLogsDirectory() - { - if (!Directory.Exists("Logs")) - { - Directory.CreateDirectory("Logs"); - } - } - } -} diff --git a/OWML.Launcher/OWML.DefaultConfig.json b/OWML.Launcher/OWML.DefaultConfig.json deleted file mode 100644 index 3306cb01..00000000 --- a/OWML.Launcher/OWML.DefaultConfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "gamePath": "C:/Program Files/Epic Games/OuterWilds", - "combinationsBlockInput": false, - "socketPort": 0 -} diff --git a/OWML.Launcher/OWML.Manifest.json b/OWML.Launcher/OWML.Manifest.json deleted file mode 100644 index 1485cb30..00000000 --- a/OWML.Launcher/OWML.Manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "author": "Alek", - "name": "OWML", - "uniqueName": "Alek.OWML", - "version": "0.7.3", - "description": "The mod loader and mod framework for Outer Wilds", - "minGameVersion": "1.0.7.0", - "maxGameVersion": "1.0.7.481" -} diff --git a/OWML.Launcher/Program.cs b/OWML.Launcher/Program.cs deleted file mode 100644 index 96259188..00000000 --- a/OWML.Launcher/Program.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using OWML.Common; -using OWML.GameFinder; -using OWML.Logging; -using OWML.ModHelper; -using OWML.ModLoader; -using OWML.Patcher; - -namespace OWML.Launcher -{ - public class Program - { - static void Main(string[] args) - { - var owmlConfig = GetOwmlConfig() ?? CreateOwmlConfig(); - var hasConsolePort = CommandLineArguments.HasArgument(Constants.ConsolePortArgument); - SaveConsolePort(owmlConfig, hasConsolePort); - SaveOwmlPath(owmlConfig); - var owmlManifest = GetOwmlManifest(); - var writer = CreateWriter(owmlConfig, owmlManifest, hasConsolePort); - var modFinder = new ModFinder(owmlConfig, writer); - var pathFinder = new PathFinder(owmlConfig, writer); - var owPatcher = new OWPatcher(owmlConfig, writer); - var vrPatcher = new VRPatcher(owmlConfig, writer); - var app = new App(owmlConfig, owmlManifest, writer, modFinder, - pathFinder, owPatcher, vrPatcher); - app.Run(args); - } - - private static void SaveConsolePort(IOwmlConfig owmlConfig, bool hasConsolePort) - { - if (hasConsolePort) - { - var argument = CommandLineArguments.GetArgument(Constants.ConsolePortArgument); - if (!int.TryParse(argument, out var port)) - { - ConsoleUtils.WriteByType(MessageType.Error, "Error - Bad port."); - return; - } - owmlConfig.SocketPort = port; - JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, owmlConfig); - } - else - { - new SocketListener(owmlConfig).Init(); - } - } - - private static IOwmlConfig GetOwmlConfig() - { - return JsonHelper.LoadJsonObject(Constants.OwmlConfigFileName); - } - - private static IOwmlConfig CreateOwmlConfig() - { - var config = JsonHelper.LoadJsonObject(Constants.OwmlDefaultConfigFileName); - JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, config); - return config; - } - - private static void SaveOwmlPath(IOwmlConfig owmlConfig) - { - owmlConfig.OWMLPath = AppDomain.CurrentDomain.BaseDirectory; - JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, owmlConfig); - } - - private static IModManifest GetOwmlManifest() - { - return JsonHelper.LoadJsonObject(Constants.OwmlManifestFileName); - } - - private static IModConsole CreateWriter(IOwmlConfig owmlConfig, IModManifest owmlManifest, bool hasConsolePort) - { - return hasConsolePort - ? new ModSocketOutput(owmlConfig, null, owmlManifest, new ModSocket(owmlConfig.SocketPort)) - : (IModConsole)new OutputWriter(); - } - - } -} diff --git a/OWML.Launcher/SocketListener.cs b/OWML.Launcher/SocketListener.cs deleted file mode 100644 index 28589da6..00000000 --- a/OWML.Launcher/SocketListener.cs +++ /dev/null @@ -1,123 +0,0 @@ -using Newtonsoft.Json; -using OWML.Common; -using OWML.ModHelper; -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading.Tasks; -using OWML.Logging; - -namespace OWML.Launcher -{ - public class SocketListener - { - private const string Separator = "\n--------------------------------"; - private const int BufferSize = 262144; - private static int _port; - private static TcpListener _server; - private static IOwmlConfig _config; - private bool _hasReceivedFatalMessage; - - public SocketListener(IOwmlConfig config) - { - _config = config; - } - - public void Init() - { - var listener = new TcpListener(IPAddress.Loopback, 0); - listener.Start(); - _port = ((IPEndPoint)listener.LocalEndpoint).Port; - listener.Stop(); - _config.SocketPort = _port; - JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, _config); - - new Task(SetupSocketListener).Start(); - } - - private void SetupSocketListener() - { - try - { - ListenToSocket(); - } - catch (SocketException ex) - { - ConsoleUtils.WriteByType(MessageType.Error, $"Error in socket listener: {ex}"); - } - catch (Exception ex) - { - ConsoleUtils.WriteByType(MessageType.Error, $"Error while listening: {ex}"); - } - finally - { - _server?.Stop(); - } - } - - private void ListenToSocket() - { - var localAddress = IPAddress.Parse(Constants.LocalAddress); - - _server = new TcpListener(localAddress, _port); - _server.Start(); - - var bytes = new byte[BufferSize]; - - while (true) - { - var client = _server.AcceptTcpClient(); - - ConsoleUtils.WriteByType(MessageType.Success, "Console connected to socket!"); - - var stream = client.GetStream(); - - int i; - - while ((i = stream.Read(bytes, 0, bytes.Length)) != 0) - { - ProcessMessage(bytes, i); - } - - ConsoleUtils.WriteByType(MessageType.Success, "Closing client!"); - client.Close(); - } - } - - private void ProcessMessage(byte[] bytes, int count) - { - var message = Encoding.UTF8.GetString(bytes, 0, count); - var jsons = message.Split('\n'); - foreach (var json in jsons) - { - if (string.IsNullOrWhiteSpace(json)) - { - continue; - } - ModSocketMessage data; - try - { - data = JsonConvert.DeserializeObject(json); - } - catch (Exception ex) - { - ConsoleUtils.WriteByType(MessageType.Warning, $"Failed to process following message:{Separator}\n{json}{Separator}"); - ConsoleUtils.WriteByType(MessageType.Warning, $"Reason: {ex.Message}"); - continue; - } - - if (data.Type == MessageType.Quit && !_hasReceivedFatalMessage) - { - Environment.Exit(0); - } - if (data.Type == MessageType.Fatal) - { - _hasReceivedFatalMessage = true; - } - ConsoleUtils.WriteByType(data.Type, - $"[{data.SenderName}.{data.SenderType}] : {data.Message}"); - } - } - } -} diff --git a/OWML.Logging/ConsoleUtils.cs b/OWML.Logging/ConsoleUtils.cs deleted file mode 100644 index 910fd04d..00000000 --- a/OWML.Logging/ConsoleUtils.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using OWML.Common; - -namespace OWML.Logging -{ - public static class ConsoleUtils - { - private static Dictionary _messageTypeColors = new Dictionary { - { MessageType.Error, ConsoleColor.Red }, - { MessageType.Warning, ConsoleColor.Yellow }, - { MessageType.Success, ConsoleColor.Green }, - { MessageType.Message, ConsoleColor.Gray }, - { MessageType.Info, ConsoleColor.Cyan }, - { MessageType.Fatal, ConsoleColor.Magenta } - }; - - public static void WriteByType(MessageType type, string line) - { - if (_messageTypeColors.ContainsKey(type)) - { - Console.ForegroundColor = _messageTypeColors[type]; - } - else - { - Console.ForegroundColor = ConsoleColor.Gray; - } - - Console.WriteLine(line); - Console.ForegroundColor = ConsoleColor.Gray; - } - } -} diff --git a/OWML.Logging/ModConsole.cs b/OWML.Logging/ModConsole.cs deleted file mode 100644 index bc348357..00000000 --- a/OWML.Logging/ModConsole.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using OWML.Common; - -namespace OWML.Logging -{ - public abstract class ModConsole : IModConsole - { - public static ModConsole OwmlConsole { get; private set; } - - protected readonly IModLogger Logger; - protected readonly IModManifest Manifest; - protected readonly IOwmlConfig OwmlConfig; - - [Obsolete("Use WriteLine(string) or WriteLine(string, MessageType) instead.")] - public abstract void WriteLine(params object[] objects); - - public abstract void WriteLine(string line); - public abstract void WriteLine(string line, MessageType type); - - protected ModConsole(IOwmlConfig config, IModLogger logger, IModManifest manifest) - { - Logger = logger; - Manifest = manifest; - OwmlConfig = config; - - if (Manifest.Name == Constants.OwmlTitle) - { - OwmlConsole = this; - } - } - } -} diff --git a/OWML.Logging/ModLogger.cs b/OWML.Logging/ModLogger.cs deleted file mode 100644 index 1ea535a7..00000000 --- a/OWML.Logging/ModLogger.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using OWML.Common; - -namespace OWML.Logging -{ - public class ModLogger : IModLogger - { - private static IOwmlConfig _config; - private readonly IModManifest _manifest; - private static string _logFileName; - - public ModLogger(IOwmlConfig config, IModManifest manifest, string logFileName) - { - if (_config == null) - { - _config = config; - } - _manifest = manifest; - _logFileName = logFileName; - } - - public void Log(string s) - { - var message = $"[{_manifest.Name}]: {s}"; - LogInternal(message); - } - - public void Log(params object[] objects) - { - Log(string.Join(" ", objects.Select(o => o.ToString()).ToArray())); - } - - private static void LogInternal(string message) - { - File.AppendAllText(_logFileName, $"{DateTime.Now}: {message}{Environment.NewLine}"); - } - } -} diff --git a/OWML.Logging/ModSocket.cs b/OWML.Logging/ModSocket.cs deleted file mode 100644 index 3311a43b..00000000 --- a/OWML.Logging/ModSocket.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using Newtonsoft.Json; -using OWML.Common; - -namespace OWML.Logging -{ - public class ModSocket : IModSocket - { - private readonly Socket _socket; - private const int _closeWaitSeconds = 1; - - public ModSocket(int port) - { - _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - var ipAddress = IPAddress.Parse(Constants.LocalAddress); - var endPoint = new IPEndPoint(ipAddress, port); - _socket.Connect(endPoint); - } - - public void WriteToSocket(IModSocketMessage message) - { - var json = JsonConvert.SerializeObject(message); - var bytes = Encoding.UTF8.GetBytes(json + Environment.NewLine); - try - { - _socket?.Send(bytes); - } - catch (SocketException) { } - } - - public void Close() - { - Thread.Sleep(TimeSpan.FromSeconds(_closeWaitSeconds)); - _socket.Close(); - } - } -} diff --git a/OWML.Logging/ModSocketMessage.cs b/OWML.Logging/ModSocketMessage.cs deleted file mode 100644 index 582132de..00000000 --- a/OWML.Logging/ModSocketMessage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; -using OWML.Common; - -namespace OWML.Logging -{ - public class ModSocketMessage : IModSocketMessage - { - [JsonProperty("senderName")] - public string SenderName { get; set; } - - [JsonProperty("senderType")] - public string SenderType { get; set; } - - [JsonProperty("type")] - public MessageType Type { get; set; } - - [JsonProperty("message")] - public string Message { get; set; } - } -} diff --git a/OWML.Logging/ModSocketOutput.cs b/OWML.Logging/ModSocketOutput.cs deleted file mode 100644 index d01c6744..00000000 --- a/OWML.Logging/ModSocketOutput.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using OWML.Common; - -namespace OWML.Logging -{ - public class ModSocketOutput : ModConsole - { - private readonly IModSocket _socket; - - public ModSocketOutput(IOwmlConfig config, IModLogger logger, IModManifest manifest, IModSocket socket) - : base(config, logger, manifest) - { - _socket = socket; - } - - [Obsolete("Use WriteLine(string) or WriteLine(string, MessageType) instead.")] - public override void WriteLine(params object[] objects) - { - var line = string.Join(" ", objects.Select(o => o.ToString()).ToArray()); - WriteLine(MessageType.Message, line, GetCallingType(new StackTrace())); - } - - public override void WriteLine(string line) - { - WriteLine(MessageType.Message, line, GetCallingType(new StackTrace())); - } - - public override void WriteLine(string line, MessageType type) - { - WriteLine(type, line, GetCallingType(new StackTrace())); - } - - private void WriteLine(MessageType type, string line, string senderType) - { - Logger?.Log(line); - - var message = new ModSocketMessage - { - SenderName = Manifest.Name, - SenderType = senderType, - Type = type, - Message = line - }; - _socket.WriteToSocket(message); - - if (message.Type == MessageType.Fatal) - { - KillProcess(); - } - } - - private void KillProcess() - { - _socket.Close(); - Process.GetCurrentProcess().Kill(); - } - - private string GetCallingType(StackTrace frame) - { - try - { - return frame.GetFrame(1).GetMethod().DeclaringType.Name; - } - catch (Exception ex) - { - var message = new ModSocketMessage - { - SenderName = Constants.OwmlTitle, - SenderType = nameof(ModSocketOutput), - Type = MessageType.Error, - Message = $"Error while getting calling type : {ex.Message}" - }; - _socket.WriteToSocket(message); - return ""; - } - } - - } -} diff --git a/OWML.Logging/OutputWriter.cs b/OWML.Logging/OutputWriter.cs deleted file mode 100644 index c8f72046..00000000 --- a/OWML.Logging/OutputWriter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Linq; -using OWML.Common; - -namespace OWML.Logging -{ - public class OutputWriter : IModConsole - { - [Obsolete("Use WriteLine(string) or WriteLine(string, MessageType) instead.")] - public void WriteLine(params object[] objects) - { - WriteLine(string.Join(" ", objects.Select(o => o.ToString()).ToArray())); - } - - public void WriteLine(string line) - { - WriteLine(line, MessageType.Message); - } - - public void WriteLine(string line, MessageType type) - { - if (string.IsNullOrEmpty(line)) - { - return; - } - - ConsoleUtils.WriteByType(type, line); - } - } -} diff --git a/OWML.Logging/UnityLogger.cs b/OWML.Logging/UnityLogger.cs deleted file mode 100644 index 4d895da7..00000000 --- a/OWML.Logging/UnityLogger.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Linq; -using OWML.Common; -using UnityEngine; - -namespace OWML.Logging -{ - public class UnityLogger - { - private readonly LogType[] _relevantTypes = { - LogType.Error, - LogType.Exception - }; - - private readonly IModSocket _socket; - - public UnityLogger(IModSocket socket) - { - _socket = socket; - } - - public void Start() - { - Application.logMessageReceived += OnLogMessageReceived; - } - - private void OnLogMessageReceived(string message, string stackTrace, LogType type) - { - if (!_relevantTypes.Contains(type)) - { - return; - } - var line = $"{message}. Stack trace: {stackTrace?.Trim()}"; - _socket.WriteToSocket(new ModSocketMessage - { - Type = MessageType.Error, - Message = line, - SenderName = "Unity", - SenderType = type.ToString() - }); - } - - } -} diff --git a/OWML.ModHelper.Assets/AudioAsset.cs b/OWML.ModHelper.Assets/AudioAsset.cs deleted file mode 100644 index f771ffda..00000000 --- a/OWML.ModHelper.Assets/AudioAsset.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class AudioAsset : ModAsset - { - } -} diff --git a/OWML.ModHelper.Assets/MeshAsset.cs b/OWML.ModHelper.Assets/MeshAsset.cs deleted file mode 100644 index 5be5e113..00000000 --- a/OWML.ModHelper.Assets/MeshAsset.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class MeshAsset : ModAsset - { - } -} diff --git a/OWML.ModHelper.Assets/ModAsset.cs b/OWML.ModHelper.Assets/ModAsset.cs deleted file mode 100644 index c6480f7b..00000000 --- a/OWML.ModHelper.Assets/ModAsset.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class ModAsset : MonoBehaviour, IModAsset - { - public event Action Loaded; - - [Obsolete("Use Loaded instead.")] - public Action OnLoaded { get; set; } - - public T Asset { get; private set; } - - public void SetAsset(T asset) - { - Asset = asset; - OnLoaded?.Invoke(asset); - Loaded?.Invoke(asset); - } - - private void Start() - { - DontDestroyOnLoad(gameObject); - } - - public T1 AddComponent() where T1 : Component - { - return gameObject.AddComponent(); - } - - } -} diff --git a/OWML.ModHelper.Assets/ModAssets.cs b/OWML.ModHelper.Assets/ModAssets.cs deleted file mode 100644 index 30ff2522..00000000 --- a/OWML.ModHelper.Assets/ModAssets.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System.Collections; -using NAudio.Wave; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class ModAssets : IModAssets - { - private readonly IModConsole _console; - private readonly IModManifest _manifest; - private readonly ObjImporter _objImporter; - - public ModAssets(IModConsole console, IModManifest manifest) - { - _console = console; - _manifest = manifest; - _objImporter = new ObjImporter(); - } - - public AssetBundle LoadBundle(string filename) - { - var path = _manifest.ModFolderPath + filename; - _console.WriteLine("Loading asset bundle from " + path); - var bundle = AssetBundle.LoadFromFile(path); - if (bundle == null) - { - _console.WriteLine("Error - Bundle is null.", MessageType.Error); - } - return bundle; - } - - public IModAsset Load3DObject(string objectFilename, string imageFilename) - { - var objectPath = _manifest.ModFolderPath + objectFilename; - var imagePath = _manifest.ModFolderPath + imageFilename; - _console.WriteLine("Loading object from " + objectPath); - - var go = new GameObject(); - var modAsset = go.AddComponent(); - - modAsset.StartCoroutine(LoadMesh(modAsset, objectPath)); - modAsset.StartCoroutine(LoadTexture(modAsset, imagePath)); - - return modAsset; - } - - public IModAsset LoadMesh(string objectFilename) - { - var objectPath = _manifest.ModFolderPath + objectFilename; - _console.WriteLine("Loading mesh from " + objectPath); - - var go = new GameObject(); - var modAsset = go.AddComponent(); - - modAsset.StartCoroutine(LoadMesh(modAsset, objectPath)); - - return modAsset; - } - - public IModAsset LoadTexture(string imageFilename) - { - var imagePath = _manifest.ModFolderPath + imageFilename; - _console.WriteLine("Loading texture from " + imagePath); - - var go = new GameObject(); - var modAsset = go.AddComponent(); - - modAsset.StartCoroutine(LoadTexture(modAsset, imagePath)); - - return modAsset; - } - - public IModAsset LoadAudio(string audioFilename) - { - var audioPath = _manifest.ModFolderPath + audioFilename; - _console.WriteLine("Loading audio from " + audioPath); - - var go = new GameObject(); - var modAsset = go.AddComponent(); - - var loadAudioFrom = audioFilename.EndsWith(".mp3") - ? LoadAudioFromMp3(modAsset, audioPath) - : LoadAudioFromWav(modAsset, audioPath); - modAsset.StartCoroutine(loadAudioFrom); - - return modAsset; - } - - private IEnumerator LoadMesh(ObjectAsset modAsset, string objectPath) - { - var mesh = _objImporter.ImportFile(objectPath); - var meshFilter = modAsset.AddComponent(); - meshFilter.mesh = mesh; - yield return new WaitForEndOfFrame(); - modAsset.SetMeshFilter(meshFilter); - } - - private IEnumerator LoadTexture(ObjectAsset modAsset, string imagePath) - { - var texture = new Texture2D(4, 4, TextureFormat.DXT1, false); - var url = "file://" + imagePath; - using (var www = new WWW(url)) - { - yield return www; - www.LoadImageIntoTexture(texture); - } - if (texture == null) - { - _console.WriteLine("Error - Texture is null.", MessageType.Error); - } - var meshRenderer = modAsset.AddComponent(); - meshRenderer.material.mainTexture = texture; - modAsset.SetMeshRenderer(meshRenderer); - } - - private IEnumerator LoadMesh(MeshAsset modAsset, string objectPath) - { - var mesh = _objImporter.ImportFile(objectPath); - if (mesh == null) - { - _console.WriteLine("Error - Mesh is null.", MessageType.Error); - } - var meshFilter = modAsset.AddComponent(); - meshFilter.mesh = mesh; - yield return new WaitForEndOfFrame(); - modAsset.SetAsset(meshFilter); - } - - private IEnumerator LoadTexture(TextureAsset modAsset, string imagePath) - { - var texture = new Texture2D(4, 4, TextureFormat.DXT1, false); - var url = "file://" + imagePath; - using (var www = new WWW(url)) - { - yield return www; - www.LoadImageIntoTexture(texture); - } - if (texture == null) - { - _console.WriteLine("Error - Texture is null.", MessageType.Error); - } - var meshRenderer = modAsset.AddComponent(); - meshRenderer.material.mainTexture = texture; - yield return new WaitForEndOfFrame(); - modAsset.SetAsset(meshRenderer); - } - - private IEnumerator LoadAudioFromMp3(AudioAsset modAsset, string audioPath) - { - AudioClip clip; - using (var reader = new AudioFileReader(audioPath)) - { - var outputBytes = new float[reader.Length]; - reader.Read(outputBytes, 0, (int)reader.Length); - clip = AudioClip.Create(audioPath, (int)reader.Length, reader.WaveFormat.Channels, reader.WaveFormat.SampleRate, false); - clip.SetData(outputBytes, 0); - } - var audioSource = modAsset.AddComponent(); - audioSource.clip = clip; - yield return new WaitForEndOfFrame(); - modAsset.SetAsset(audioSource); - } - - private IEnumerator LoadAudioFromWav(AudioAsset modAsset, string audioPath) - { - AudioClip clip; - var url = "file://" + audioPath; - using (var www = new WWW(url)) - { - yield return www; - clip = www.GetAudioClip(true); - } - if (clip == null) - { - _console.WriteLine("Error - Audio is null.", MessageType.Error); - } - var audioSource = modAsset.AddComponent(); - audioSource.clip = clip; - yield return new WaitForEndOfFrame(); - modAsset.SetAsset(audioSource); - } - - } -} diff --git a/OWML.ModHelper.Assets/ObjImporter.cs b/OWML.ModHelper.Assets/ObjImporter.cs deleted file mode 100644 index d8e533f2..00000000 --- a/OWML.ModHelper.Assets/ObjImporter.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - // Source: https://wiki.unity3d.com/index.php?title=ObjImporter&oldid=13033 - - /* This version of ObjImporter first reads through the entire file, getting a count of how large - * the final arrays will be, and then uses standard arrays for everything (as opposed to ArrayLists - * or any other fancy things). - */ - - public class ObjImporter - { - - private struct MeshStruct - { - public Vector3[] vertices; - public Vector3[] normals; - public Vector2[] uv; - public Vector2[] uv1; - public Vector2[] uv2; - public int[] triangles; - public int[] faceVerts; - public int[] faceUVs; - public Vector3[] faceData; - public string name; - public string fileName; - } - - // Use this for initialization - public Mesh ImportFile(string filePath) - { - var newMesh = CreateMeshStruct(filePath); - PopulateMeshStruct(ref newMesh); - - var newVerts = new Vector3[newMesh.faceData.Length]; - var newUVs = new Vector2[newMesh.faceData.Length]; - var newNormals = new Vector3[newMesh.faceData.Length]; - var i = 0; - /* The following foreach loops through the facedata and assigns the appropriate vertex, uv, or normal - * for the appropriate Unity mesh array. - */ - foreach (var v in newMesh.faceData) - { - newVerts[i] = newMesh.vertices[(int)v.x - 1]; - if (v.y >= 1) - newUVs[i] = newMesh.uv[(int)v.y - 1]; - - if (v.z >= 1) - newNormals[i] = newMesh.normals[(int)v.z - 1]; - i++; - } - - var mesh = new Mesh - { - vertices = newVerts, - uv = newUVs, - normals = newNormals, - triangles = newMesh.triangles - }; - - mesh.RecalculateBounds(); - //mesh.Optimize(); - - return mesh; - } - - private static MeshStruct CreateMeshStruct(string filename) - { - var triangles = 0; - var vertices = 0; - var vt = 0; - var vn = 0; - var face = 0; - var mesh = new MeshStruct - { - fileName = filename - }; - var stream = File.OpenText(filename); - var entireText = stream.ReadToEnd(); - stream.Close(); - using (var reader = new StringReader(entireText)) - { - var currentText = reader.ReadLine(); - char[] splitIdentifier = { ' ' }; - string[] brokenString; - while (currentText != null) - { - if (!currentText.StartsWith("f ") && !currentText.StartsWith("v ") && !currentText.StartsWith("vt ") - && !currentText.StartsWith("vn ")) - { - currentText = reader.ReadLine(); - if (currentText != null) - { - currentText = currentText.Replace(" ", " "); - } - } - else - { - currentText = currentText.Trim(); //Trim the current line - brokenString = currentText.Split(splitIdentifier, 50); //Split the line into an array, separating the original line by blank spaces - switch (brokenString[0]) - { - case "v": - vertices++; - break; - case "vt": - vt++; - break; - case "vn": - vn++; - break; - case "f": - face = face + brokenString.Length - 1; - triangles = triangles + 3 * (brokenString.Length - 2); /*brokenString.Length is 3 or greater since a face must have at least - 3 vertices. For each additional vertice, there is an additional - triangle in the mesh (hence this formula).*/ - break; - } - currentText = reader.ReadLine(); - if (currentText != null) - { - currentText = currentText.Replace(" ", " "); - } - } - } - } - mesh.triangles = new int[triangles]; - mesh.vertices = new Vector3[vertices]; - mesh.uv = new Vector2[vt]; - mesh.normals = new Vector3[vn]; - mesh.faceData = new Vector3[face]; - return mesh; - } - - private static void PopulateMeshStruct(ref MeshStruct mesh) - { - var stream = File.OpenText(mesh.fileName); - var entireText = stream.ReadToEnd(); - stream.Close(); - using (var reader = new StringReader(entireText)) - { - var currentText = reader.ReadLine(); - - char[] splitIdentifier = { ' ' }; - char[] splitIdentifier2 = { '/' }; - string[] brokenString; - string[] brokenBrokenString; - var f = 0; - var f2 = 0; - var v = 0; - var vn = 0; - var vt = 0; - var vt1 = 0; - var vt2 = 0; - while (currentText != null) - { - if (!currentText.StartsWith("f ") && !currentText.StartsWith("v ") && !currentText.StartsWith("vt ") && - !currentText.StartsWith("vn ") && !currentText.StartsWith("g ") && !currentText.StartsWith("usemtl ") && - !currentText.StartsWith("mtllib ") && !currentText.StartsWith("vt1 ") && !currentText.StartsWith("vt2 ") && - !currentText.StartsWith("vc ") && !currentText.StartsWith("usemap ")) - { - currentText = reader.ReadLine(); - if (currentText != null) - { - currentText = currentText.Replace(" ", " "); - } - } - else - { - currentText = currentText.Trim(); - brokenString = currentText.Split(splitIdentifier, 50); - switch (brokenString[0]) - { - case "g": - break; - case "usemtl": - break; - case "usemap": - break; - case "mtllib": - break; - case "v": - mesh.vertices[v] = new Vector3(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]), - System.Convert.ToSingle(brokenString[3])); - v++; - break; - case "vt": - mesh.uv[vt] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2])); - vt++; - break; - case "vt1": - mesh.uv[vt1] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2])); - vt1++; - break; - case "vt2": - mesh.uv[vt2] = new Vector2(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2])); - vt2++; - break; - case "vn": - mesh.normals[vn] = new Vector3(System.Convert.ToSingle(brokenString[1]), System.Convert.ToSingle(brokenString[2]), - System.Convert.ToSingle(brokenString[3])); - vn++; - break; - case "vc": - break; - case "f": - - var j = 1; - var intArray = new List(); - while (j < brokenString.Length && ("" + brokenString[j]).Length > 0) - { - var temp = new Vector3(); - brokenBrokenString = brokenString[j].Split(splitIdentifier2, 3); //Separate the face into individual components (vert, uv, normal) - temp.x = System.Convert.ToInt32(brokenBrokenString[0]); - if (brokenBrokenString.Length > 1) //Some .obj files skip UV and normal - { - if (brokenBrokenString[1] != "") //Some .obj files skip the uv and not the normal - { - temp.y = System.Convert.ToInt32(brokenBrokenString[1]); - } - temp.z = System.Convert.ToInt32(brokenBrokenString[2]); - } - j++; - - mesh.faceData[f2] = temp; - intArray.Add(f2); - f2++; - } - j = 1; - while (j + 2 < brokenString.Length) //Create triangles out of the face data. There will generally be more than 1 triangle per face. - { - mesh.triangles[f] = intArray[0]; - f++; - mesh.triangles[f] = intArray[j]; - f++; - mesh.triangles[f] = intArray[j + 1]; - f++; - - j++; - } - break; - } - currentText = reader.ReadLine(); - if (currentText != null) - { - currentText = currentText.Replace(" ", " "); //Some .obj files insert double spaces, this removes them. - } - } - } - } - } - } -} diff --git a/OWML.ModHelper.Assets/ObjectAsset.cs b/OWML.ModHelper.Assets/ObjectAsset.cs deleted file mode 100644 index 349e8d90..00000000 --- a/OWML.ModHelper.Assets/ObjectAsset.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class ObjectAsset : ModAsset - { - private MeshRenderer _meshRenderer; - private MeshFilter _meshFilter; - - public void SetMeshRenderer(MeshRenderer meshRenderer) - { - _meshRenderer = meshRenderer; - SetAssetIfComplete(); - } - - public void SetMeshFilter(MeshFilter meshFilter) - { - _meshFilter = meshFilter; - SetAssetIfComplete(); - } - - private void SetAssetIfComplete() - { - if (_meshFilter != null && _meshRenderer != null) - { - SetAsset(gameObject); - } - } - - } -} diff --git a/OWML.ModHelper.Assets/TextureAsset.cs b/OWML.ModHelper.Assets/TextureAsset.cs deleted file mode 100644 index 78f4ab5b..00000000 --- a/OWML.ModHelper.Assets/TextureAsset.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace OWML.ModHelper.Assets -{ - public class TextureAsset : ModAsset - { - } -} diff --git a/OWML.ModHelper.Assets/packages.config b/OWML.ModHelper.Assets/packages.config deleted file mode 100644 index f38d13b9..00000000 --- a/OWML.ModHelper.Assets/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/OWML.ModHelper.Events/HarmonyHelper.cs b/OWML.ModHelper.Events/HarmonyHelper.cs deleted file mode 100644 index c2070f6d..00000000 --- a/OWML.ModHelper.Events/HarmonyHelper.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Reflection; -using Harmony; -using OWML.Common; - -namespace OWML.ModHelper.Events -{ - public class HarmonyHelper : IHarmonyHelper - { - private readonly IModLogger _logger; - private readonly IModConsole _console; - private readonly HarmonyInstance _harmony; - - public HarmonyHelper(IModLogger logger, IModConsole console) - { - _logger = logger; - _console = console; - _harmony = CreateInstance(); - } - - private HarmonyInstance CreateInstance() - { - HarmonyInstance harmony; - try - { - _logger.Log("Creating harmony instance"); - harmony = HarmonyInstance.Create("com.alek.owml"); - _logger.Log("Created harmony instance"); - } - catch (Exception ex) - { - _console.WriteLine($"Exception while creating harmony instance: {ex}", MessageType.Error); - return null; - } - if (harmony == null) - { - _console.WriteLine("Error - Harmony instance is null.", MessageType.Error); - } - return harmony; - } - - private MethodInfo GetMethod(string methodName) - { - var targetType = typeof(T); - MethodInfo result = null; - try - { - _logger.Log($"Getting method {methodName} of {targetType.Name}"); - result = targetType.GetAnyMethod(methodName); - } - catch (Exception ex) - { - _console.WriteLine($"Exception while getting method {methodName} of {targetType.Name}: {ex}", MessageType.Error); - } - if (result == null) - { - _console.WriteLine($"Error - Original method {methodName} of class {targetType} not found.", MessageType.Error); - } - return result; - } - - public void AddPrefix(string methodName, Type patchType, string patchMethodName) - { - AddPrefix(GetMethod(methodName), patchType, patchMethodName); - } - - public void AddPrefix(MethodBase original, Type patchType, string patchMethodName) - { - var prefix = patchType.GetAnyMethod(patchMethodName); - if (prefix == null) - { - _console.WriteLine($"Error in {nameof(AddPrefix)}: {patchType.Name}.{patchMethodName} is null.", MessageType.Error); - return; - } - Patch(original, prefix, null, null); - } - - public void AddPostfix(string methodName, Type patchType, string patchMethodName) - { - AddPostfix(GetMethod(methodName), patchType, patchMethodName); - } - - public void AddPostfix(MethodBase original, Type patchType, string patchMethodName) - { - var postfix = patchType.GetAnyMethod(patchMethodName); - if (postfix == null) - { - _console.WriteLine($"Error in {nameof(AddPostfix)}: {patchType.Name}.{patchMethodName} is null.", MessageType.Error); - return; - } - Patch(original, null, postfix, null); - } - - public void EmptyMethod(string methodName) - { - EmptyMethod(GetMethod(methodName)); - } - - public void EmptyMethod(MethodBase methodInfo) - { - Transpile(methodInfo, typeof(Patches), nameof(Patches.EmptyMethod)); - } - - public void Transpile(string methodName, Type patchType, string patchMethodName) - { - Transpile(GetMethod(methodName), patchType, patchMethodName); - } - - public void Transpile(MethodBase original, Type patchType, string patchMethodName) - { - var patchMethod = patchType.GetAnyMethod(patchMethodName); - if (patchMethod == null) - { - _console.WriteLine($"Error in {nameof(Transpile)}: {patchType.Name}.{patchMethodName} is null.", MessageType.Error); - return; - } - Patch(original, null, null, patchMethod); - } - - private void Patch(MethodBase original, MethodInfo prefix, MethodInfo postfix, MethodInfo transpiler) - { - if (original == null) - { - _console.WriteLine($"Error in {nameof(Patch)}: original MethodInfo is null.", MessageType.Error); - return; - } - var prefixMethod = prefix == null ? null : new HarmonyMethod(prefix); - var postfixMethod = postfix == null ? null : new HarmonyMethod(postfix); - var transpilerMethod = transpiler == null ? null : new HarmonyMethod(transpiler); - var fullName = $"{original.DeclaringType}.{original.Name}"; - try - { - _harmony.Patch(original, prefixMethod, postfixMethod, transpilerMethod); - _logger.Log($"Patched {fullName}!"); - } - catch (Exception ex) - { - _console.WriteLine($"Exception while patching {fullName}: {ex}", MessageType.Error); - } - } - - } -} diff --git a/OWML.ModHelper.Events/ModEvents.cs b/OWML.ModHelper.Events/ModEvents.cs deleted file mode 100644 index a04ac915..00000000 --- a/OWML.ModHelper.Events/ModEvents.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Events -{ - public class ModEvents : IModEvents - { - public IModPlayerEvents Player { get; } - public IModSceneEvents Scenes { get; } - public IModUnityEvents Unity { get; } - - public event Action Event; - - [Obsolete("Use Event instead.")] - public Action OnEvent { get; set; } - - private static readonly List> PatchedEvents = new List>(); - private readonly List> _subscribedEvents = new List>(); - - private readonly IHarmonyHelper _harmonyHelper; - private readonly IModConsole _console; - private readonly IModLogger _logger; - - public ModEvents(IModLogger logger, IModConsole console, IHarmonyHelper harmonyHelper) - { - _logger = logger; - _console = console; - _harmonyHelper = harmonyHelper; - Patches.OnEvent += OnPatchEvent; - - Player = new ModPlayerEvents(this); - Scenes = new ModSceneEvents(); - Unity = new GameObject().AddComponent(); - } - - private void OnPatchEvent(MonoBehaviour behaviour, Common.Events ev) - { - var type = behaviour.GetType(); - if (IsSubscribedTo(type, ev)) - { - _logger.Log($"Got subscribed event: {ev} of {type.Name}"); - OnEvent?.Invoke(behaviour, ev); - Event?.Invoke(behaviour, ev); - } - else - { - _logger.Log($"Not subscribed to: {ev} of {type.Name}"); - } - } - - public void Subscribe(Common.Events ev) where T : MonoBehaviour - { - SubscribeToEvent(ev); - PatchEvent(ev); - } - - private void SubscribeToEvent(Common.Events ev) - { - var type = typeof(T); - if (IsSubscribedTo(type, ev)) - { - _logger.Log($"Already subscribed to {ev} of {type.Name}"); - return; - } - AddToEventList(_subscribedEvents, type, ev); - } - - private void PatchEvent(Common.Events ev) - { - var type = typeof(T); - if (InEventList(PatchedEvents, type, ev)) - { - _logger.Log($"Event is already patched: {ev} of {type.Name}"); - return; - } - AddToEventList(PatchedEvents, type, ev); - - switch (ev) - { - case Common.Events.BeforeAwake: - _harmonyHelper.AddPrefix("Awake", typeof(Patches), nameof(Patches.BeforeAwake)); - break; - case Common.Events.AfterAwake: - _harmonyHelper.AddPostfix("Awake", typeof(Patches), nameof(Patches.AfterAwake)); - break; - - case Common.Events.BeforeStart: - _harmonyHelper.AddPrefix("Start", typeof(Patches), nameof(Patches.BeforeStart)); - break; - case Common.Events.AfterStart: - _harmonyHelper.AddPostfix("Start", typeof(Patches), nameof(Patches.AfterStart)); - break; - - case Common.Events.BeforeEnable: - _harmonyHelper.AddPrefix("OnEnable", typeof(Patches), nameof(Patches.BeforeEnable)); - break; - case Common.Events.AfterEnable: - _harmonyHelper.AddPostfix("OnEnable", typeof(Patches), nameof(Patches.AfterEnable)); - break; - - case Common.Events.BeforeDisable: - _harmonyHelper.AddPrefix("OnDisable", typeof(Patches), nameof(Patches.BeforeDisable)); - break; - case Common.Events.AfterDisable: - _harmonyHelper.AddPostfix("OnDisable", typeof(Patches), nameof(Patches.AfterDisable)); - break; - - case Common.Events.BeforeDestroy: - _harmonyHelper.AddPrefix("OnDestroy", typeof(Patches), nameof(Patches.BeforeDestroy)); - break; - case Common.Events.AfterDestroy: - _harmonyHelper.AddPostfix("OnDestroy", typeof(Patches), nameof(Patches.AfterDestroy)); - break; - - default: - _console.WriteLine($"Error - Unrecognized event: {ev}", MessageType.Error); - throw new ArgumentOutOfRangeException(nameof(ev), ev, null); - } - } - - private bool IsSubscribedTo(Type type, Common.Events ev) - { - return _subscribedEvents.Any(pair => (type == pair.Key || type.IsSubclassOf(pair.Key)) && pair.Value == ev); - } - - private bool InEventList(List> events, Type type, Common.Events ev) - { - return events.Any(pair => type == pair.Key && pair.Value == ev); - } - - private void AddToEventList(List> events, Type type, Common.Events ev) - { - events.Add(new KeyValuePair(type, ev)); - } - - } -} diff --git a/OWML.ModHelper.Events/ModPlayerEvents.cs b/OWML.ModHelper.Events/ModPlayerEvents.cs deleted file mode 100644 index 9994b528..00000000 --- a/OWML.ModHelper.Events/ModPlayerEvents.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Events -{ - public class ModPlayerEvents : IModPlayerEvents - { - public event Action OnPlayerAwake; - - public ModPlayerEvents(IModEvents events) - { - events.Subscribe(Common.Events.AfterAwake); - events.Event += OnEvent; - } - - private void OnEvent(MonoBehaviour behaviour, Common.Events ev) - { - if (behaviour is PlayerBody playerBody && ev == Common.Events.AfterAwake) - { - OnPlayerAwake?.Invoke(playerBody); - } - } - } -} diff --git a/OWML.ModHelper.Events/ModSceneEvents.cs b/OWML.ModHelper.Events/ModSceneEvents.cs deleted file mode 100644 index 2ab21b47..00000000 --- a/OWML.ModHelper.Events/ModSceneEvents.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using OWML.Common; - -namespace OWML.ModHelper.Events -{ - public class ModSceneEvents : IModSceneEvents - { - public event Action OnStartSceneChange; - public event Action OnCompleteSceneChange; - - public ModSceneEvents() - { - LoadManager.OnStartSceneLoad += OnStartSceneLoad; - LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad; - } - - private void OnStartSceneLoad(OWScene originalScene, OWScene newScene) - { - OnStartSceneChange?.Invoke(originalScene, newScene); - } - - private void OnCompleteSceneLoad(OWScene originalScene, OWScene newScene) - { - OnCompleteSceneChange?.Invoke(originalScene, newScene); - } - - } -} diff --git a/OWML.ModHelper.Events/ModUnityEvents.cs b/OWML.ModHelper.Events/ModUnityEvents.cs deleted file mode 100644 index 42a99ee4..00000000 --- a/OWML.ModHelper.Events/ModUnityEvents.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Events -{ - public class ModUnityEvents : MonoBehaviour, IModUnityEvents - { - public event Action OnUpdate; - public event Action OnFixedUpdate; - public event Action OnLateUpdate; - - public void FireOnNextUpdate(Action action) - { - FireInNUpdates(action, 1); - } - - public void FireInNUpdates(Action action, int n) - { - StartCoroutine(WaitForFrames(action, n)); - } - - public void RunWhen(Func predicate, Action action) - { - StartCoroutine(WaitUntil(predicate, action)); - } - - private IEnumerator WaitForFrames(Action action, int n) - { - for (var i = 0; i < n; i++) - { - yield return new WaitForEndOfFrame(); - } - action.Invoke(); - } - - private IEnumerator WaitUntil(Func predicate, Action action) - { - yield return new WaitUntil(predicate); - action(); - } - - private void Start() - { - DontDestroyOnLoad(gameObject); - } - - private void Update() - { - OnUpdate?.Invoke(); - } - - private void FixedUpdate() - { - OnFixedUpdate?.Invoke(); - } - - private void LateUpdate() - { - OnLateUpdate?.Invoke(); - } - - } -} diff --git a/OWML.ModHelper.Events/Patches.cs b/OWML.ModHelper.Events/Patches.cs deleted file mode 100644 index 035fdc10..00000000 --- a/OWML.ModHelper.Events/Patches.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using Harmony; -using UnityEngine; - -namespace OWML.ModHelper.Events -{ - internal static class Patches - { - public static event Action OnEvent; - - public static void BeforeAwake(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeAwake); - public static void AfterAwake(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterAwake); - - public static void BeforeStart(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeStart); - public static void AfterStart(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterStart); - - public static void BeforeEnable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeEnable); - public static void AfterEnable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterEnable); - - public static void BeforeDisable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeDisable); - public static void AfterDisable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterDisable); - - public static void BeforeDestroy(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeDestroy); - public static void AfterDestroy(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterDestroy); - - public static IEnumerable EmptyMethod(IEnumerable instructions) - { - return new List(); - } - - } -} diff --git a/OWML.ModHelper.Events/TypeExtensions.cs b/OWML.ModHelper.Events/TypeExtensions.cs deleted file mode 100644 index 73c108f1..00000000 --- a/OWML.ModHelper.Events/TypeExtensions.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Reflection; - -namespace OWML.ModHelper.Events -{ - public static class TypeExtensions - { - private const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static; - - public static MethodInfo GetAnyMethod(this Type type, string name) - { - return type.GetMethod(name, Flags) ?? - type.BaseType?.GetMethod(name, Flags) ?? - type.BaseType?.BaseType?.GetMethod(name, Flags); - } - - public static PropertyInfo GetAnyProperty(this Type type, string name) - { - return type.GetProperty(name, Flags) ?? - type.BaseType?.GetProperty(name, Flags) ?? - type.BaseType?.BaseType?.GetProperty(name, Flags); - } - - public static FieldInfo GetAnyField(this Type type, string name) - { - return type.GetField(name, Flags) ?? - type.BaseType?.GetField(name, Flags) ?? - type.BaseType?.BaseType?.GetField(name, Flags); - } - - public static T GetValue(this object obj, string name) - { - var type = obj.GetType(); - var field = type.GetAnyField(name); - if (field != null) - { - return (T)field.GetValue(obj); - } - var property = type.GetAnyProperty(name); - if (property != null) - { - return (T)property.GetValue(obj, null); - } - return default; - } - - public static void SetValue(this object obj, string name, object value) - { - var type = obj.GetType(); - var field = type.GetAnyField(name); - if (field != null) - { - field.SetValue(obj, value); - return; - } - var property = type.GetAnyProperty(name); - if (property != null) - { - property.SetValue(obj, value, null); - } - } - - public static void Invoke(this object obj, string name, params object[] parameters) - { - var type = obj.GetType(); - var method = type.GetAnyMethod(name); - method?.Invoke(obj, parameters); - } - - public static T Invoke(this object obj, string name, params object[] parameters) - { - var type = obj.GetType(); - var method = type.GetAnyMethod(name); - return (T)method?.Invoke(obj, parameters); - } - } -} \ No newline at end of file diff --git a/OWML.ModHelper.Input/BindingChangeListener.cs b/OWML.ModHelper.Input/BindingChangeListener.cs deleted file mode 100644 index c9cdda40..00000000 --- a/OWML.ModHelper.Input/BindingChangeListener.cs +++ /dev/null @@ -1,56 +0,0 @@ -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Input -{ - public class BindingChangeListener : MonoBehaviour - { - private ModInputHandler _inputHandler; - private bool _updateInputsNext, _updateInputs; - - internal void Initialize(ModInputHandler inputHandler, IModEvents events) - { - _inputHandler = inputHandler; - events.Subscribe(Common.Events.AfterStart); - events.Event += OnEvent; - } - - private void OnEvent(MonoBehaviour behaviour, Common.Events ev) - { - if (behaviour.GetType() == typeof(TitleScreenManager) && ev == Common.Events.AfterStart) - { - _updateInputsNext = true; - } - } - - private void Start() - { - DontDestroyOnLoad(gameObject); - GlobalMessenger.AddListener("KeyBindingsChanged", PrepareForUpdate); - } - - private void PrepareForUpdate() - { - _updateInputsNext = true; - } - - private void Update() - { - if (_updateInputs) - { - _updateInputs = false; - UpdateInputs(); - } - if (_updateInputsNext) - { - _updateInputs = true; - _updateInputsNext = false; - } - } - - public void UpdateInputs() - { - _inputHandler.UpdateGamesBindings(); - } - } -} diff --git a/OWML.ModHelper.Input/InputInterceptor.cs b/OWML.ModHelper.Input/InputInterceptor.cs deleted file mode 100644 index f3813ac7..00000000 --- a/OWML.ModHelper.Input/InputInterceptor.cs +++ /dev/null @@ -1,74 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; - -namespace OWML.ModHelper.Input -{ - internal class InputInterceptor - { - public static void SingleAxisUpdatePost( - SingleAxisCommand __instance, - ref float ____value, - List ____posKeyCodes, - List ____negKeyCodes - ) - { - foreach (var key in ____posKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value = 0f; - } - } - foreach (var key in ____negKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value = 0f; - } - } - } - - public static void DoubleAxisUpdatePost( - DoubleAxisCommand __instance, - ref Vector2 ____value, - List ____posXKeyCodes, - List ____negXKeyCodes, - List ____posYKeyCodes, - List ____negYKeyCodes - ) - { - if (OWInput.UsingGamepad()) - { - return; - } - foreach (var key in ____posXKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value.x = 0f; - } - } - foreach (var key in ____negXKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value.x = 0f; - } - } - foreach (var key in ____posYKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value.y = 0f; - } - } - foreach (var key in ____negYKeyCodes) - { - if (ModInputHandler.Instance.IsPressedAndIgnored(key)) - { - ____value.y = 0f; - } - } - } - } -} diff --git a/OWML.ModHelper.Input/ModCommandListener.cs b/OWML.ModHelper.Input/ModCommandListener.cs deleted file mode 100644 index 14829c49..00000000 --- a/OWML.ModHelper.Input/ModCommandListener.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using OWML.ModHelper.Events; - -namespace OWML.ModHelper.Input -{ - public class ModCommandListener : MonoBehaviour - { - public event Action OnNewlyPressed; - public event Action OnNewlyReleased; - public event Action OnNewlyHeld; - public event Action OnPressed; - public event Action OnTapped; - public event Action OnHeld; - - public float MinimalPressDuration { get; set; } = 0.1f; - public float MaximalTapDuration { get; set; } = 0.1f; - - private readonly HashSet _commands = new HashSet(); - private readonly HashSet _toRemove = new HashSet(); - private readonly Dictionary _wasPressed = new Dictionary(); - private readonly Dictionary _isPressed = new Dictionary(); - - public void AddToListener(SingleAxisCommand command) - { - if (_commands.Contains(command)) - { - return; - } - _commands.Add(command); - _wasPressed.Add(command, false); - _isPressed.Add(command, false); - } - - public void RemoveFromListener(SingleAxisCommand command) - { - if (_commands.Contains(command) && !_toRemove.Contains(command)) - { - _toRemove.Add(command); - } - } - - public void BlockNextRelease() - { - _commands.Where(x => x.IsPressed()).ToList().ForEach(x => x.BlockNextRelease()); - } - - private void Start() - { - DontDestroyOnLoad(gameObject); - } - - private void Update() - { - foreach (var command in _toRemove) - { - _commands.Remove(command); - _isPressed.Remove(command); - _wasPressed.Remove(command); - } - _toRemove.Clear(); - foreach (var command in _commands) - { - if (_toRemove.Contains(command)) - { - continue; - } - var blockFlag = command.GetValue("_blockNextRelease"); - if (command.IsNewlyPressed()) - { - OnNewlyPressed?.Invoke(command); - } - if (command.IsNewlyHeld(MinimalPressDuration)) - { - OnNewlyHeld?.Invoke(command); - } - if (command.IsPressed()) - { - OnPressed?.Invoke(command); - _isPressed[command] = true; - } - else - { - _wasPressed[command] = _isPressed[command]; - _isPressed[command] = false; - } - if (command.IsNewlyReleased()) - { - OnNewlyReleased?.Invoke(command); - } - if (command.IsHeld(MinimalPressDuration)) - { - OnHeld?.Invoke(command); - } - if (command.IsTapped(MaximalTapDuration)) - { - OnTapped?.Invoke(command); - } - if (blockFlag)//damn you, Mobius Digital - { - var toReblock = _wasPressed[command] || _isPressed[command]; - command.SetValue("_blockNextRelease", toReblock); - } - } - } - } -} diff --git a/OWML.ModHelper.Input/ModCommandUpdater.cs b/OWML.ModHelper.Input/ModCommandUpdater.cs deleted file mode 100644 index 88033abc..00000000 --- a/OWML.ModHelper.Input/ModCommandUpdater.cs +++ /dev/null @@ -1,24 +0,0 @@ -using UnityEngine; - -namespace OWML.ModHelper.Input -{ - public class ModCommandUpdater : MonoBehaviour - { - private InputCommand _command; - - public void Initialize(InputCommand command) - { - _command = command; - } - - private void Start() - { - DontDestroyOnLoad(gameObject); - } - - private void Update() - { - _command?.UpdateInputCommand(); - } - } -} \ No newline at end of file diff --git a/OWML.ModHelper.Input/ModInputCombination.cs b/OWML.ModHelper.Input/ModInputCombination.cs deleted file mode 100644 index 7c06c331..00000000 --- a/OWML.ModHelper.Input/ModInputCombination.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Collections.ObjectModel; -using System.Collections.Generic; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Input -{ - public class ModInputCombination : IModInputCombination - { - public float LastPressedMoment { get; private set; } - public bool IsFirst { get; private set; } - public float PressDuration => LastPressedMoment - _firstPressedMoment; - public string ModName => _manifest.Name; - public string Name { get; } - public string FullName => $"{ModName}.{Name}"; - public ReadOnlyCollection Singles => _singles.AsReadOnly(); - public ReadOnlyCollection Hashes => _hashes.AsReadOnly(); - - private bool _isPressed; - private float _firstPressedMoment; - private readonly List _singles = new List(); - private readonly List _hashes; - - private readonly IModManifest _manifest; - private readonly IModConsole _console; - - internal ModInputCombination(IModManifest manifest, IModConsole console, string name, string combination) - { - _manifest = manifest; - _console = console; - Name = name; - _hashes = StringToHashes(combination); - } - - private List StringToHashes(string combinations) - { - var hashes = new List(); - foreach (var combo in combinations.Split('/')) - { - var hash = ModInputLibrary.StringToHash(combo); - if (hash <= 0) - { - _console.WriteLine($"Warning - Invalid part of combo in {FullName}: {combo}, " + - ModInputLibrary.GetReadableMessage((RegistrationCode)hash), MessageType.Warning); - continue; - } - hashes.Add(hash); - if (hash < ModInputLibrary.MaxUsefulKey) - { - _singles.Add((KeyCode)hash); - } - } - return hashes; - } - - public void InternalSetPressed(bool isPressed = true) - { - IsFirst = isPressed != _isPressed; - if (isPressed) - { - if (IsFirst) - { - _firstPressedMoment = Time.realtimeSinceStartup; - } - LastPressedMoment = Time.realtimeSinceStartup; - } - _isPressed = isPressed; - } - } -} \ No newline at end of file diff --git a/OWML.ModHelper.Input/ModInputHandler.cs b/OWML.ModHelper.Input/ModInputHandler.cs deleted file mode 100644 index e187c9ef..00000000 --- a/OWML.ModHelper.Input/ModInputHandler.cs +++ /dev/null @@ -1,400 +0,0 @@ -using System; -using System.Reflection; -using System.Collections.ObjectModel; -using System.Collections.Generic; -using System.Linq; -using OWML.Common; -using UnityEngine; - -namespace OWML.ModHelper.Input -{ - public class ModInputHandler : IModInputHandler - { - private const float Cooldown = 0.05f; - private const float TapDuration = 0.1f; - private const BindingFlags NonPublic = BindingFlags.NonPublic | BindingFlags.Instance; - - internal static ModInputHandler Instance { get; private set; } - - public IModInputTextures Textures { get; } - - private readonly HashSet _singlesPressed = new HashSet(); - private readonly Dictionary> _comboRegistry = new Dictionary>(); - private readonly HashSet _toResetOnNextFrame = new HashSet(); - private readonly int[] _blockedFrame = new int[ModInputLibrary.MaxUsefulKey]; - private readonly int[] _gameBindingCounter = new int[ModInputLibrary.MaxUsefulKey]; - private HashSet _currentCombinations = new HashSet(); - private int _lastSingleUpdate; - private int _lastCombinationUpdate; - private readonly IModLogger _logger; - private readonly IModConsole _console; - - public ModInputHandler(IModLogger logger, IModConsole console, IHarmonyHelper patcher, IOwmlConfig owmlConfig, IModEvents events) - { - var textures = new ModInputTextures(); - textures.FillTextureLibrary(); - Textures = textures; - - _console = console; - _logger = logger; - - var listenerObject = new GameObject("GameBindingsChangeListener"); - var listener = listenerObject.AddComponent(); - listener.Initialize(this, events); - - if (owmlConfig.BlockInput) - { - patcher.AddPostfix("UpdateInputCommand", typeof(InputInterceptor), nameof(InputInterceptor.SingleAxisUpdatePost)); - patcher.AddPostfix("UpdateInputCommand", typeof(InputInterceptor), nameof(InputInterceptor.DoubleAxisUpdatePost)); - } - Instance = this; - } - - internal bool IsPressedAndIgnored(KeyCode key) - { - UpdateCurrentCombinations(); - var cleanKey = ModInputLibrary.NormalizeKeyCode(key); - return UnityEngine.Input.GetKey(cleanKey) && - _currentCombinations.Count > 0 && - (Time.frameCount - _blockedFrame[(int)cleanKey]) * Time.deltaTime < Cooldown; - } - - private long? GetHashFromKeyboard() - { - long hash = 0; - var keysCount = 0; - var countdownTrigger = true; - for (var code = ModInputLibrary.MinUsefulKey; code < ModInputLibrary.MaxUsefulKey; code++) - { - if (!(Enum.IsDefined(typeof(KeyCode), (KeyCode)code) && UnityEngine.Input.GetKey((KeyCode)code))) - { - continue; - } - keysCount++; - if (keysCount > ModInputLibrary.MaxComboLength) - { - return null; - } - hash = hash * ModInputLibrary.MaxUsefulKey + code; - if ((Time.frameCount - _blockedFrame[code]) * Time.deltaTime > Cooldown) - { - countdownTrigger = false; - } - } - return countdownTrigger ? -hash : hash; - } - - private HashSet GetCombinationsFromKeyboard() - { - var countdownTrigger = false; - var nullableHash = GetHashFromKeyboard(); - if (nullableHash == null) - { - return new HashSet(); - } - var hash = (long)nullableHash; - if (hash < 0) - { - countdownTrigger = true; - hash = -hash; - } - if (!_comboRegistry.ContainsKey(hash)) - { - return new HashSet(); - } - - var combinations = new HashSet(_comboRegistry[hash]); - if (!_currentCombinations.Equals(combinations) && countdownTrigger) - { - combinations.IntersectWith(_currentCombinations); - } - if (combinations.Count == 0) - { - return combinations; - } - - while (hash > 0) - { - _blockedFrame[hash % ModInputLibrary.MaxUsefulKey] = Time.frameCount; - hash /= ModInputLibrary.MaxUsefulKey; - } - return combinations; - } - - private void UpdateCurrentCombinations() - { - if (_lastCombinationUpdate == Time.frameCount) - { - return; - } - _lastCombinationUpdate = Time.frameCount; - foreach (var combo in _toResetOnNextFrame) - { - combo.InternalSetPressed(false); - } - _toResetOnNextFrame.Clear(); - var combinations = GetCombinationsFromKeyboard(); - if (_currentCombinations.Count > 0 && !_currentCombinations.Equals(combinations)) - { - var toUnpress = _currentCombinations; - toUnpress.ExceptWith(combinations); - toUnpress.ToList().ForEach(combination => combination.InternalSetPressed(false)); - _toResetOnNextFrame.UnionWith(toUnpress); - } - _currentCombinations = combinations; - _currentCombinations.ToList().ForEach(combination => combination.InternalSetPressed()); - } - - public bool IsPressedExact(IModInputCombination combination) - { - if (combination == null) - { - return false; - } - UpdateCurrentCombinations(); - return _currentCombinations.Contains(combination); - } - - public bool IsNewlyPressedExact(IModInputCombination combination) - { - return combination != null && - IsPressedExact(combination) && - combination.IsFirst; - } - - public bool WasTappedExact(IModInputCombination combination) - { - return combination != null && - !IsPressedExact(combination) && - combination.PressDuration < TapDuration && - combination.IsFirst; - } - - public bool WasNewlyReleasedExact(IModInputCombination combination) - { - return combination != null && - !IsPressedExact(combination) && - combination.IsFirst; - } - - private void CleanupSinglesPressed() - { - if (_lastSingleUpdate == Time.frameCount) - { - return; - } - _lastSingleUpdate = Time.frameCount; - var toRemove = new List(); - foreach (var combo in _singlesPressed) - { - if (!IsPressedSingle(combo)) - { - toRemove.Add(combo); - } - if (!IsPressed(combo)) - { - combo.InternalSetPressed(false); - _toResetOnNextFrame.Add(combo); - } - } - _singlesPressed.ExceptWith(toRemove); - } - - private bool IsPressedSingle(IModInputCombination combination) - { - CleanupSinglesPressed(); - if (_currentCombinations.Contains(combination)) - { - return true; - } - var single = combination.Singles.FirstOrDefault(key => UnityEngine.Input.GetKey(key) && !IsPressedAndIgnored(key)); - if (single == 0) - { - return false; - } - _singlesPressed.Add(combination); - combination.InternalSetPressed(); - return true; - } - - public bool IsPressed(IModInputCombination combination) - { - return combination != null && - (IsPressedExact(combination) || IsPressedSingle(combination)); - } - - public bool IsNewlyPressed(IModInputCombination combination) - { - return combination != null && - IsPressed(combination) && - combination.IsFirst; - } - - public bool WasTapped(IModInputCombination combination) - { - return combination != null && - !IsPressed(combination) && - combination.PressDuration < TapDuration && - combination.IsFirst; - } - - public bool WasNewlyReleased(IModInputCombination combination) - { - return combination != null && - !IsPressed(combination) && - combination.IsFirst; - } - - private RegistrationCode SwapCombination(IModInputCombination combination, bool toUnregister) - { - var isTaken = false; - if (combination.Hashes.Count == 0) - { - return RegistrationCode.InvalidCombination; - } - foreach (var hash in combination.Hashes) - { - if (toUnregister) - { - if (!_comboRegistry.ContainsKey(hash)) - { - continue; - } - _comboRegistry[hash].Remove(combination); - if (_comboRegistry[hash].Count == 0) - { - _comboRegistry.Remove(hash); - } - continue; - } - if (_comboRegistry.ContainsKey(hash) || hash < ModInputLibrary.MaxUsefulKey && _gameBindingCounter[hash] > 0) - { - isTaken = true; - } - if (!_comboRegistry.ContainsKey(hash)) - { - _comboRegistry.Add(hash, new HashSet()); - } - _comboRegistry[hash].Add(combination); - } - return isTaken ? RegistrationCode.CombinationTaken : RegistrationCode.AllNormal; - } - - private List GetCollisions(ReadOnlyCollection hashes) - { - var combos = new List(); - foreach (var hash in hashes) - { - if (_comboRegistry.ContainsKey(hash)) - { - var toAdd = _comboRegistry[hash].Select(combination => combination.FullName).ToList(); - toAdd.ForEach(combos.Add); - } - if (hash < ModInputLibrary.MaxUsefulKey && _gameBindingCounter[hash] > 0) // let's add both ¯\_(ツ)_/¯ - { - combos.Add("Outer Wilds." + Enum.GetName(typeof(KeyCode), (KeyCode)hash)); - } - } - return combos; - } - - public List GetWarningMessages(string combinations) - { - var hashes = new List(); - var errorMessages = new List(); - foreach (var combo in combinations.Split('/')) - { - var hash = ModInputLibrary.StringToHash(combo); - if (hash <= 0) - { - errorMessages.Add(ModInputLibrary.GetReadableMessage((RegistrationCode)(-hash))); - continue; - } - hashes.Add(hash); - } - var warningMessages = GetCollisions(hashes.AsReadOnly()) - .Select(combination => $"Collides with {combination}").ToList(); - warningMessages.AddRange(errorMessages); - return warningMessages; - } - - public IModInputCombination RegisterCombination(IModBehaviour mod, string name, string combination) - { - var combo = new ModInputCombination(mod.ModHelper.Manifest, _console, name, combination); - switch (SwapCombination(combo, false)) - { - case RegistrationCode.InvalidCombination: - _console.WriteLine($"Failed to register \"{combo.FullName}\": Invalid combination!", MessageType.Error); - return null; - case RegistrationCode.CombinationTooLong: - _console.WriteLine($"Failed to register \"{combo.FullName}\": Too long!", MessageType.Error); - return null; - case RegistrationCode.CombinationTaken: - _console.WriteLine($"Warning - \"{combo.FullName}\" is already in use by the following mods:", MessageType.Warning); - var collisions = GetCollisions(combo.Hashes); - foreach (var collision in collisions) - { - _console.WriteLine($" * \"{collision}\"", MessageType.Warning); - } - return combo; - case RegistrationCode.AllNormal: - return combo; - default: - return null; - } - } - - public void UnregisterCombination(IModInputCombination combination) - { - if (combination == null) - { - _console.WriteLine("Failed to unregister: Null combination!", MessageType.Error); - return; - } - switch (SwapCombination(combination, true)) - { - case RegistrationCode.InvalidCombination: - _console.WriteLine($"Failed to unregister \"{combination.FullName}\": Invalid combination!", MessageType.Error); - return; - case RegistrationCode.CombinationTooLong: - _console.WriteLine($"Failed to unregister \"{combination.FullName}\": Too long!", MessageType.Error); - return; - case RegistrationCode.AllNormal: - _logger.Log($"Successfully unregistered \"{combination.FullName}\"", MessageType.Success); - return; - default: - return; - } - } - - internal void RegisterGamesBinding(InputCommand binding) - { - if (binding == null) - { - return; - } - var fields = binding is SingleAxisCommand ? - typeof(SingleAxisCommand).GetFields(NonPublic) : - typeof(DoubleAxisCommand).GetFields(NonPublic); - foreach (var field in fields.Where(x => x.FieldType == typeof(List))) - { - var keys = (List)field.GetValue(binding); - foreach (var key in keys.Where(x => x != KeyCode.None)) - { - var intKey = (int)ModInputLibrary.NormalizeKeyCode(key); - _gameBindingCounter[intKey]++; - } - } - } - - internal void UpdateGamesBindings() - { - for (var i = ModInputLibrary.MinUsefulKey; i < ModInputLibrary.MaxUsefulKey; i++) - { - _gameBindingCounter[i] = 0; - } - var inputCommands = typeof(InputLibrary).GetFields(BindingFlags.Public | BindingFlags.Static).ToList(); - inputCommands.ForEach(field => RegisterGamesBinding(field.GetValue(null) as InputCommand)); - } - } -} diff --git a/OWML.ModHelper.Input/ModInputLibrary.cs b/OWML.ModHelper.Input/ModInputLibrary.cs deleted file mode 100644 index 1173bb85..00000000 --- a/OWML.ModHelper.Input/ModInputLibrary.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using UnityEngine; - -namespace OWML.ModHelper.Input -{ - public static class ModInputLibrary - { - public const float ScaleDown = 0.75f; - public const string XboxPrefix = "xbox_"; - public const int MinUsefulKey = 8; - public const int MinGamepadKey = 330; - public const int MaxUsefulKey = 350; - public const int MaxComboLength = 7; - public const int GamePadKeyDiff = 20; - - internal static string GetReadableMessage(RegistrationCode code) - { - switch (code) - { - case RegistrationCode.InvalidCombination: - return "contains invalid keys"; - case RegistrationCode.CombinationTooLong: - return "contains too many keys"; - case RegistrationCode.CombinationTaken: - return "similar combination already registered"; - case RegistrationCode.AllNormal: - return "correct combination"; - default: - return "unknown"; - } - } - - public static KeyCode NormalizeKeyCode(KeyCode key) - { - if ((int)key >= MaxUsefulKey) - { - key -= ((int)key - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff * GamePadKeyDiff; - } - return key; - } - - public static JoystickButton XboxButtonToJoystickButton(string xboxKey) - { - switch (xboxKey[0]) - { - case 'a': - return JoystickButton.FaceDown; - case 'b': - return JoystickButton.FaceRight; - case 'x': - return JoystickButton.FaceLeft; - case 'y': - return JoystickButton.FaceUp; - default: - return KeyToKeycode(xboxKey, JoystickButton.None); - } - } - - public static string JoystickButtonToXboxButton(JoystickButton key) - { - switch (key) - { - case JoystickButton.FaceDown: - return "a"; - case JoystickButton.FaceRight: - return "b"; - case JoystickButton.FaceLeft: - return "x"; - case JoystickButton.FaceUp: - return "y"; - default: - return key.ToString(); - } - } - - private static KeyCode StringToKeyCodeKeyboard(string keyboardKey) - { - switch (keyboardKey) - { - case "control": - case "ctrl": - return KeyCode.LeftControl; - case "shift": - return KeyCode.LeftShift; - case "alt": - return KeyCode.LeftAlt; - default: - return KeyToKeycode(keyboardKey, KeyCode.None); - } - } - - private static T KeyToKeycode(string keyboardKey, T defaultValue) - { - try - { - var code = (T)Enum.Parse(typeof(T), keyboardKey, true); - return Enum.IsDefined(typeof(T), code) ? code : defaultValue; - } - catch (Exception) - { - return defaultValue; - } - } - - private static KeyCode StringToKeyCodeGamepad(string xboxKey) - { - var gamepadCode = XboxButtonToJoystickButton(xboxKey); - return gamepadCode == JoystickButton.None ? KeyCode.None : NormalizeKeyCode(InputTranslator.GetButtonKeyCode(gamepadCode)); - } - - public static KeyCode StringToKeyCode(string key) - { - var trimmedKey = key.Trim(); - return trimmedKey.Contains(XboxPrefix) ? - StringToKeyCodeGamepad(trimmedKey.Substring(XboxPrefix.Length)) : - StringToKeyCodeKeyboard(trimmedKey); - } - - private static int[] StringToKeyArray(string stringCombination) - { - var keyCombination = new int[MaxComboLength]; - var i = 0; - foreach (var key in stringCombination.Trim().ToLower().Split('+')) - { - var code = StringToKeyCode(key); - if (code == KeyCode.None) - { - keyCombination[0] = (int)RegistrationCode.InvalidCombination; - return keyCombination; - } - if (i >= MaxComboLength) - { - keyCombination[0] = (int)RegistrationCode.CombinationTooLong; - return keyCombination; - } - keyCombination[i] = (int)code; - i++; - } - Array.Sort(keyCombination); - return keyCombination; - } - - internal static long StringToHash(string stringCombination) - { - var keyCombination = StringToKeyArray(stringCombination); - if (keyCombination[0] < 0) - { - return keyCombination[0]; - } - long hash = 0; - for (var i = 0; i < MaxComboLength; i++) - { - hash = hash * MaxUsefulKey + keyCombination[i]; - } - return hash; - } - - public static string KeyCodeToString(KeyCode key) - { - var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox; - key = NormalizeKeyCode(key); - return (int)key >= MinGamepadKey ? - XboxPrefix + JoystickButtonToXboxButton(InputTranslator.ConvertKeyCodeToButton(key, config)) : - key.ToString(); - } - } -} \ No newline at end of file diff --git a/OWML.ModHelper.Input/ModInputTextures.cs b/OWML.ModHelper.Input/ModInputTextures.cs deleted file mode 100644 index d0e87d76..00000000 --- a/OWML.ModHelper.Input/ModInputTextures.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using OWML.Common; - -namespace OWML.ModHelper.Input -{ - public class ModInputTextures : IModInputTextures - { - private Dictionary _loadedTextures; - - internal void FillTextureLibrary() - { - _loadedTextures = new Dictionary(); - var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox; - for (var code = ModInputLibrary.MinUsefulKey; code < ModInputLibrary.MaxUsefulKey; code++) - { - var key = (KeyCode)code; - if (!Enum.IsDefined(typeof(KeyCode), key)) - { - continue; - } - var keyName = ModInputLibrary.KeyCodeToString(key); - if (_loadedTextures.ContainsKey(keyName)) - { - continue; - } - var button = InputTranslator.ConvertKeyCodeToButton(key, config); - var toStore = (int)key >= ModInputLibrary.MinGamepadKey ? - ButtonPromptLibrary.SharedInstance.GetButtonTexture(button) : - ButtonPromptLibrary.SharedInstance.GetButtonTexture(key); - _loadedTextures.Add(keyName, toStore); - } - } - - public Texture2D KeyTexture(string key) - { - return KeyTexture(ModInputLibrary.StringToKeyCode(key)); - } - - public Texture2D KeyTexture(KeyCode key) - { - if (_loadedTextures == null) - { - FillTextureLibrary(); - } - var keyName = ModInputLibrary.KeyCodeToString(key); - if (_loadedTextures.ContainsKey(keyName)) - { - return _loadedTextures[keyName]; - } - var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox; - var toStore = (int)key >= ModInputLibrary.MinGamepadKey ? - ButtonPromptLibrary.SharedInstance.GetButtonTexture(InputTranslator.ConvertKeyCodeToButton(key, config)) : - ButtonPromptLibrary.SharedInstance.GetButtonTexture(key); - _loadedTextures.Add(keyName, toStore); - return toStore; - } - } -} \ No newline at end of file diff --git a/OWML.ModHelper.Input/RegistrationCode.cs b/OWML.ModHelper.Input/RegistrationCode.cs deleted file mode 100644 index 5634f81a..00000000 --- a/OWML.ModHelper.Input/RegistrationCode.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OWML.ModHelper.Input -{ - internal enum RegistrationCode - { - InvalidCombination = -1, - CombinationTooLong = -2, - CombinationTaken = -3, - AllNormal = 1 - } -} diff --git a/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs b/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs deleted file mode 100644 index 9340eb47..00000000 --- a/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Reflection.Emit; - -// Adapted from SMAPI code : https://github.com/Pathoschild/SMAPI/tree/c4a82418ac8b09a6965052f5c9173928457fba52/src/SMAPI/Framework/Reflection - -namespace OWML.ModHelper.Interaction -{ - internal class InterfaceProxyBuilder - { - private readonly Type _targetType; - private readonly Type _proxyType; - - public InterfaceProxyBuilder(string name, ModuleBuilder moduleBuilder, Type interfaceType, Type targetType) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - if (targetType == null) - { - throw new ArgumentNullException(nameof(targetType)); - } - - var proxyBuilder = moduleBuilder.DefineType(name, TypeAttributes.Public | TypeAttributes.Class); - proxyBuilder.AddInterfaceImplementation(interfaceType); - - var targetField = proxyBuilder.DefineField("__Target", targetType, FieldAttributes.Private); - - CreateConstructor(proxyBuilder, targetField, targetType); - - foreach (var proxyMethod in interfaceType.GetMethods()) - { - var targetMethod = targetType.GetMethod(proxyMethod.Name, proxyMethod.GetParameters().Select(a => a.ParameterType).ToArray()); - if (targetMethod == null) - { - throw new InvalidOperationException($"The {interfaceType.FullName} interface defines method {proxyMethod.Name} which doesn't exist in the API."); - } - ProxyMethod(proxyBuilder, targetMethod, targetField); - } - - _targetType = targetType; - _proxyType = proxyBuilder.CreateType(); - } - - public object CreateInstance(object targetInstance) - { - var constructor = _proxyType.GetConstructor(new[] { _targetType }); - if (constructor == null) - { - throw new InvalidOperationException($"Couldn't find the constructor for generated proxy type '{_proxyType.Name}'."); // should never happen - } - return constructor.Invoke(new[] { targetInstance }); - } - - private void ProxyMethod(TypeBuilder proxyBuilder, MethodInfo target, FieldBuilder instanceField) - { - var argTypes = target.GetParameters().Select(a => a.ParameterType).ToArray(); - - var methodBuilder = proxyBuilder.DefineMethod(target.Name, MethodAttributes.Public | MethodAttributes.Final | MethodAttributes.Virtual); - methodBuilder.SetParameters(argTypes); - methodBuilder.SetReturnType(target.ReturnType); - - CreateProxyMethodBody(methodBuilder, target, instanceField, argTypes); - } - - private void CreateProxyMethodBody(MethodBuilder methodBuilder, MethodInfo target, FieldBuilder instanceField, Type[] argTypes) - { - var il = methodBuilder.GetILGenerator(); - - // load target instance - il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Ldfld, instanceField); - - // invoke target method on instance - for (var i = 0; i < argTypes.Length; i++) - { - il.Emit(OpCodes.Ldarg, i + 1); - } - il.Emit(OpCodes.Call, target); - - // return result - il.Emit(OpCodes.Ret); - } - - private void CreateConstructor(TypeBuilder proxyBuilder, FieldBuilder targetField, Type targetType) - { - var constructor = proxyBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard | CallingConventions.HasThis, new[] { targetType }); - var il = constructor.GetILGenerator(); - - il.Emit(OpCodes.Ldarg_0); // this - il.Emit(OpCodes.Call, typeof(object).GetConstructor(new Type[0])); // call base constructor - il.Emit(OpCodes.Ldarg_0); // this - il.Emit(OpCodes.Ldarg_1); // load argument - il.Emit(OpCodes.Stfld, targetField); // set field to loaded argument - il.Emit(OpCodes.Ret); - } - } -} diff --git a/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs b/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs deleted file mode 100644 index 2d4b958c..00000000 --- a/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; - -// Adapted from SMAPI code : https://github.com/Pathoschild/SMAPI/tree/c4a82418ac8b09a6965052f5c9173928457fba52/src/SMAPI/Framework/Reflection - -namespace OWML.ModHelper.Interaction -{ - public class InterfaceProxyFactory - { - private readonly ModuleBuilder _moduleBuilder; - private readonly IDictionary _builders = new Dictionary(); - - public InterfaceProxyFactory() - { - var assemblyName = new AssemblyName($"OWMLInteraction.Proxies, Version={GetType().Assembly.GetName().Version}, Culture=neutral"); - var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); - _moduleBuilder = assemblyBuilder.DefineDynamicModule("OWMLInteraction.Proxies"); - } - - public TInterface CreateProxy(object instance, string sourceModName, string targetModName) where TInterface : class - { - if (instance == null) - { - throw new InvalidOperationException("Can't proxy access to a null API."); - } - if (!typeof(TInterface).IsInterface) - { - throw new InvalidOperationException("The proxy type must be an interface, not a class."); - } - - var targetType = instance.GetType(); - - var proxyTypeName = $"OWMLInteraction.Proxies.From<{sourceModName}_{typeof(TInterface).FullName}>_To<{targetModName}_{targetType.FullName}>"; - if (!_builders.TryGetValue(proxyTypeName, out var builder)) - { - builder = new InterfaceProxyBuilder(proxyTypeName, _moduleBuilder, typeof(TInterface), targetType); - _builders[proxyTypeName] = builder; - } - - return (TInterface)builder.CreateInstance(instance); - } - } -} diff --git a/OWML.ModHelper.Interaction/ModInteraction.cs b/OWML.ModHelper.Interaction/ModInteraction.cs deleted file mode 100644 index fa4b6280..00000000 --- a/OWML.ModHelper.Interaction/ModInteraction.cs +++ /dev/null @@ -1,103 +0,0 @@ -using OWML.Common; -using System.Collections.Generic; -using System.Linq; - -namespace OWML.ModHelper.Interaction -{ - public class ModInteraction : IModInteraction - { - private readonly IList _modList; - private readonly InterfaceProxyFactory _proxyFactory; - private readonly IModManifest _manifest; - private Dictionary> _dependantDict = new Dictionary>(); - private Dictionary> _dependencyDict = new Dictionary>(); - - public ModInteraction(IList list, InterfaceProxyFactory proxyFactory, IModManifest manifest) - { - _modList = list; - _manifest = manifest; - _proxyFactory = proxyFactory; - RegenerateDictionaries(); - } - - private void RegenerateDictionaries() - { - _dependantDict = new Dictionary>(); - _dependencyDict = new Dictionary>(); - foreach (var mod in _modList) - { - var dependants = new List(); - var dependencies = new List(); - foreach (var dependency in _modList) - { - if (dependency.ModHelper.Manifest.Dependencies.Contains(mod.ModHelper.Manifest.UniqueName)) - { - dependants.Add(dependency); - } - - if (mod.ModHelper.Manifest.Dependencies.Contains(dependency.ModHelper.Manifest.UniqueName)) - { - dependencies.Add(dependency); - } - } - _dependantDict[mod.ModHelper.Manifest.UniqueName] = dependants; - _dependencyDict[mod.ModHelper.Manifest.UniqueName] = dependencies; - } - } - - public IList GetDependants(string dependencyUniqueName) - { - if (_dependantDict.Count != _modList.Count) - { - RegenerateDictionaries(); - } - return _dependantDict[dependencyUniqueName]; - } - - public IList GetDependencies(string uniqueName) - { - if (_dependantDict.Count != _modList.Count) - { - RegenerateDictionaries(); - } - return _dependencyDict[uniqueName]; - } - - public IModBehaviour GetMod(string uniqueName) - { - return _modList.First(m => m.ModHelper.Manifest.UniqueName == uniqueName); - } - - private object GetApi(string uniqueName) - { - var mod = GetMod(uniqueName); - return mod.Api; - } - - public TInterface GetModApi(string uniqueName) where TInterface : class - { - var inter = GetApi(uniqueName); - if (inter == null) - { - return null; - } - - if (inter is TInterface castInter) - { - return castInter; - } - - return _proxyFactory.CreateProxy(inter, _manifest.UniqueName, uniqueName); - } - - public IList GetMods() - { - return _modList; - } - - public bool ModExists(string uniqueName) - { - return _modList.Any(m => m.ModHelper.Manifest.UniqueName == uniqueName); - } - } -} diff --git a/OWML.ModHelper.Menus/ModButtonBase.cs b/OWML.ModHelper.Menus/ModButtonBase.cs deleted file mode 100644 index b0ea4b91..00000000 --- a/OWML.ModHelper.Menus/ModButtonBase.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using OWML.Common.Menus; -using OWML.ModHelper.Events; -using Object = UnityEngine.Object; -using UnityEngine.UI; - -namespace OWML.ModHelper.Menus -{ - public abstract class ModButtonBase : IModButtonBase - { - public event Action OnClick; - - public Button Button { get; } - public IModMenu Menu { get; private set; } - - private int _index; - public int Index - { - get => Button.transform.parent == null ? _index : Button.transform.GetSiblingIndex(); - set - { - _index = value; - Button.transform.SetSiblingIndex(value); - } - } - public bool IsSelected => _uIStyleApplier?.GetValue("_selected") ?? false; - - private readonly UIStyleApplier _uIStyleApplier; - - protected ModButtonBase(Button button, IModMenu menu) - { - _uIStyleApplier = button.GetComponent(); - Button = button; - Button.onClick.AddListener(() => OnClick?.Invoke()); - Initialize(menu); - } - - public IModButtonBase Copy() - { - var button = Object.Instantiate(Button); - Object.Destroy(button.GetComponent()); - var modButton = (IModButtonBase)Activator.CreateInstance(GetType(), button, Menu); - modButton.Index = Index + 1; - return modButton; - } - - public void Initialize(IModMenu menu) - { - Menu = menu; - } - - public IModButtonBase Copy(int index) - { - var copy = Copy(); - copy.Index = index; - return copy; - } - - public IModButtonBase Duplicate() - { - var copy = Copy(); - Menu.AddButton(copy); - return copy; - } - - public IModButtonBase Duplicate(int index) - { - var dupe = Duplicate(); - dupe.Index = index; - return dupe; - } - - public IModButtonBase Replace() - { - var duplicate = Duplicate(); - Hide(); - return duplicate; - } - - public IModButtonBase Replace(int index) - { - var replacement = Replace(); - replacement.Index = index; - return replacement; - } - - public void Show() - { - Button.gameObject.SetActive(true); - } - - public void Hide() - { - Button.gameObject.SetActive(false); - } - - } -} diff --git a/OWML.ModHelper.Menus/ModComboInput.cs b/OWML.ModHelper.Menus/ModComboInput.cs deleted file mode 100644 index be3c82c5..00000000 --- a/OWML.ModHelper.Menus/ModComboInput.cs +++ /dev/null @@ -1,102 +0,0 @@ -using OWML.Common.Menus; -using OWML.ModHelper.Events; -using OWML.ModHelper.Input; -using UnityEngine; -using UnityEngine.UI; -using OWML.Common; - -namespace OWML.ModHelper.Menus -{ - public class ModComboInput : ModPopupInput, IModComboInput - { - public IModLayoutButton Button { get; } - protected readonly IModInputCombinationMenu InputMenu; - - private string _combination; - private readonly IModInputHandler _inputHandler; - - public override string Value - { - get => _combination; - set - { - _combination = value; - UpdateLayout(value); - } - } - - public ModComboInput(TwoButtonToggleElement element, IModMenu menu, IModInputCombinationMenu inputMenu, IModInputHandler inputHandler) - : base(element, menu) - { - _inputHandler = inputHandler; - InputMenu = inputMenu; - - Button = new ModLayoutButton(element.GetValue