[1.5] HugsLib (11.0.3) Lightweight modding library

Started by UnlimitedHugs, December 15, 2016, 02:20:14 PM

Previous topic - Next topic


UnlimitedHugs

Quote from: Wishmaster on December 17, 2016, 12:04:14 PM
Isn't there a A15 version of this or a similar mod ?

There is- it used to come packaged with the mods that made use of it. There were some issues with that approach, though, so now it is distributed separately.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Thundercraft


scuba156

I'm trying to use HugsLib WindowReplacer to replace Verse.Page_CreateWorldParams (The window during create a new colony where you select the parameters for world generation) and I'm having a few problems. Once the window is replaced, it breaks the new colony process.

Take the following page that simply changes the windows title for example:

using RimWorld;

namespace Blah
{
    public class Page_CreateWorldParamsExtended : Page_CreateWorldParams
    {
        public override string PageTitle
        {
          get
          {
            return "Blah";
          }
        }
    }
}


It will replace the window fine and show the new title, but pressing back will close the window and return to the main menu instead of going back a page to the story teller selection page, and pressing generate looks like it triggers a world to generate but not show the select landing site page and instead just returns to the main menu. It seems like a scene/scenario issue and I've been trying to find what I'm missing for a bit too long now. Any Ideas?

UnlimitedHugs

Quote from: scuba156 on December 19, 2016, 01:32:21 AM
- WindowReplacer issue -

WindowReplacer is a good choice for basic windows that don't require much setup. Still, you could make it work by restoring the links to the other pages after your window opens.
Take a look at Scenario.GetFirstConfigPage(), where the original window is created. You would likely need a reference to the window you're replacing- I could make the replacer store that, if it helps.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

scuba156

#21
Thanks, but I can already get it. TBH, I'm actually just editing HugsLibs WindowReplacer Class at the moment as it's easier to look for what I need on the OnGUI method. I've added a ReplacePage method to it, and will do a pull request once I have it working since this happens for all page classes.

I checked out Scenario.GetFirstConfigPage() but I could only get Page_ConfigureStartingPawn. I think I know where I might of gone wrong. I'm about to start coding now so I'll test some things. Thank you.

Update: Well I got lazy for now and just decided to detour GetFirstConfigPage and insert my page in the originals place :/. I got GetFirstConfigPage confused with ScenPart.GetConfigPages, but had looked at it before. As I thought I went wrong earlier, I wasn't going through the pages next property. Should be easy enough to get the "GameStartDialog" Part, copy prev/next/next act and replace the page. I may do it soon but I would like to continue on my project for now :)


UnlimitedHugs

Quote from: Wishmaster on December 20, 2016, 09:18:34 AM
How I do make my mod to check for updates ?

Checking for mod updates is not a feature (yet?). The only version the checker looks for is the library itself, since a newer version may be required for that mod to work properly.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Jaxxa

Looks awesome.
At the very least I will be using this for my mods that require Detours.

lllMWNlll

I can't start new game

Exception from asynchronous event: System.MissingMethodException: No constructor found for HugsLib.MapComponent_HugsProxy::.ctor(Verse.Map)
  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0
  at Verse.Map.ConstructComponents () [0x00000] in <filename unknown>:0
  at Verse.MapGenerator.GenerateMap (IntVec3 mapSize, Int32 tile, RimWorld.Planet.MapParent parent, System.Action`1 extraInitBeforeContentGen, Verse.MapGeneratorDef mapGenerator) [0x00000] in <filename unknown>:0
  at Verse.Game.InitNewGame () [0x00000] in <filename unknown>:0
  at Verse.Root_Play.<Start>m__737 () [0x00000] in <filename unknown>:0
  at Verse.LongEventHandler.RunEventFromAnotherThread (System.Action action) [0x00000] in <filename unknown>:0
Verse.Log:Error(String)
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__733()

UnlimitedHugs

Quote from: lllMWNlll on December 22, 2016, 01:53:04 PM
Exception from asynchronous event: System.MissingMethodException: No constructor found for HugsLib.MapComponent_HugsProxy::.ctor(Verse.Map)

Looks like you're trying to run HugsLib for A15 on A16. HugsLib used to come packaged with the mods that use it- look for the file $HugsLib.dll (including the dollar sign), and you can find out which mod forgot to remove it.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

DaemonDeathAngel

Does this assembly make it possible to hide aspects of yhe core files, such as all research and/or structures/buildings?

I have no C# knowledge so I am trying to find a workaround.

UnlimitedHugs

Quote from: DaemonDeathAngel on December 22, 2016, 02:28:18 PM
Does this assembly make it possible to hide aspects of yhe core files, such as all research and/or structures/buildings?

The library wouldn't be required for that. You can already override Core Defs with your own, using xml. If you are looking for more flexibility in that department, there is Mod Friendly Overrides scheduled to be released sometime soon.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

#29
Updated to 2.1.4

Two significant changes:
- Strict detouring checks. Detours will now be checked for parameter and return type compatibility, as well as some other potential issues. These will be displayed as warnings in the interest of compatibility, but are there to help prevent serious and difficult to diagnose problems.
- Shorthash collision resolution. Due to an issue in the vanilla game, modded defs can end up being assigned the same hash. This will cause errors on loading a saved game. The fix resolves these conflicts for all mods (including those not directly referencing the library) by assigning new hashes to offending defs.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam