Caves of Qud

Caves of Qud

Harmony Injector
HawkleyFox  [developer] 5 Aug, 2019 @ 1:12pm
CoQ Update Broke Harmony Injector?
Been debugging the code for Better Ability Bar for a long while now, trying to figure out what happened. I think I finally figured it out.

For context, I've been getting a build error like the following:
`UnityEngine.UIElements.BaseField<TValueType>' must be type definition or nested non-inflated type to MakeGenericType

The code for the `XRL.ModManager.BuildScriptMods` method has changed, and one of the changes includes the following line:
list2.RemoveAll((string e) => e.Contains("UIElements"));

HMMMM... Why is that there? Perhaps it is related? :P

Anyways, I see that you are patching `ModManager.BuildScriptMods` and your patch does not replicate the changes that have been made with the update. I don't know how many Harmony Injector dependent mods are currently broken, but Better Ability Bar certainly is.
< >
Showing 1-6 of 6 comments
HawkleyFox  [developer] 7 Aug, 2019 @ 6:05pm 
Been working on Harmony Injector myself. I just about got it all fixed up with one exception: the new logging system doesn't seem to work when called from the mod-assembly.

Can't for the life of me figure out why, but for the time being, I've just setup a constant that will switch between the two. Maybe it'll work in the future and then you'll just have to change a boolean.

Got a git-repo or something for me to do a pull-request to?
HawkleyFox  [developer] 13 Aug, 2019 @ 4:27am 
Welp, I continued to poke at Harmony Injector; I got a comprehensive list of things what I've done to it.

  • Found a way to inject Harmony that does not require taking over mod-compilation duties from CoQ. This should help reduce the likelihood of the mod breaking again due to the compilation process changing in the future.
  • The injector handles the game's two main threads a little more carefully; it was technically possible for the injector to trigger in either thread, depending on where the game did the initialization of the game's configuration. Now it always performs the actual injection on the UI thread and always after it has finished its last configuration initialization.
  • A hot-reload of the game's configuration is performed after compilation. This ensures CoQ initializes everything using the types from the latest mod assembly (but it does add a sizable delay to start-up).
  • Finally worked out how to show popups! Now the user can be properly informed of problems when they happen. Only the basic message box is implemented, but there's room to add more and maybe spin it off into its own mod in the future.
  • Added more comprehensive error detection and reporting to go with it.
  • An automatic restart now occurs when the mod assembly needs to be recompiled after Harmony was injected. Unlike in HarmonyShim, it is an actual restart and the user is told about this before it happens. The only thing I don't like about it is that it restarts to the resolution dialog and there is no way to suppress this behavior and jump back straight into the main menu.
  • The option to use the new logging system is still there, but due to the aforementioned problem, it is currently disabled.
  • Added a `csproj` file so that VSCode can be used to get full IntelliSense; this even includes types from the game's own assemblies. Gives a lot more feedback while working with the mod; catches those code mistakes without having to run the game and look at the output logs. I may contribute a `csproj` template to the modding wiki, since it worked so damn well.

I've only been able to test things on the Windows version of the game, so certain features, like the auto-restart, may need some tuning for other platforms.

Anyways, people are still waiting to get their Harmony-modded games working again. Tell me how to get this work to you so you can get it on the workshop~!
namkazt  [developer] 14 Aug, 2019 @ 1:46am 
@HawkleyFox you can update it on your github and we can fix from that.
HawkleyFox  [developer] 14 Aug, 2019 @ 2:02am 
Alright. Here is the repo[github.com].
namkazt  [developer] 14 Aug, 2019 @ 10:35am 
please add me as contributor : namkazt [github.com]
edited: overall your source look really good but im not check the new mod manager code in COQ yet so it will take some time. Thanks
Last edited by namkazt; 14 Aug, 2019 @ 10:57am
HawkleyFox  [developer] 14 Aug, 2019 @ 12:24pm 
Done so. And thank you. It went through a number of iterations and different approaches before I arrived at this. Getting the popups going was a big win. I was thinking of adding a progress bar popup to show during injection as well, so that the user at least knows something is happening while the game is apparently frozen.

This was actually a pretty rough time, coding this. The C# compiler built into this version of Mono has a ton of bugs. Generic methods don't work (it compiles, but the IL code generated causes `InvalidProgramException`), generic classes only kinda work but not well enough to be useful, the Exception Filter feature `catch-when` doesn't compile correctly...

It's like I was stepping on every compiler bug present as I worked on this. xD Probably a lot more than that in there, but just this is troubling.

I really wanna see modding improve in Caves of Qud, but man... The devs need to be involved in order for good progress to be made on it.
< >
Showing 1-6 of 6 comments
Per page: 1530 50