Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkeys with custom category not working? #276

Open
welles opened this issue Jan 3, 2023 · 2 comments
Open

Hotkeys with custom category not working? #276

welles opened this issue Jan 3, 2023 · 2 comments

Comments

@welles
Copy link

welles commented Jan 3, 2023

Hi, I'm working on converting all my cheat hotkeys to ButterLib's hotkey implementation.
Unfortunately I am unable to create a custom hotkey category. Whenever I try to set a custom category, the hotkeys do not show up or the game freezes on opening the options menu.
I was trying to do something like this:

public class SubModule : MBSubModuleBase
{
    protected override void OnBeforeInitialModuleScreenSetAsRoot()
    {
        base.OnBeforeInitialModuleScreenSetAsRoot();

        var manager = HotKeyManager.CreateWithOwnCategory("BannerlordCheats", "Cheats");
        manager.Add<AddMoneyHotkey>();
        manager.Build();
    }

    ...
}
public class AddMoneyHotkey : HotKeyBase
{
    public AddMoneyHotkey() : base(nameof(AddMoneyHotkey))
    {
        this.Category = "Cheats";
        this.DisplayName = "Add 1.000 Gold";
        this.DefaultKey = InputKey.F10;
        this.Description = "...";
        this.Predicate = () => ScreenManager.TopScreen is GauntletInventoryScreen;
    }

    protected override string DisplayName { get; }

    protected override string Description { get; }

    protected override InputKey DefaultKey { get; }

    protected override string Category { get; }

    ...
}

Am I missing something?

@Aragas
Copy link
Member

Aragas commented Mar 10, 2023

Hey Welles! Sorry for the delayed answer! Didn't notice the issue! Do you still need help with the issue?

@welles
Copy link
Author

welles commented Mar 13, 2023

Hi, I am currently not actively working on my mod, so it's not important right now, but maybe I'll continue with this in the future. Can you see any reason in my code for why the custom category is not working? Are custom hotkey categories even possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants