NightmareXIV / ECommons

A library for Dalamud
MIT License
34 stars 40 forks source link

[FEATURE] Add CmdManager to easy init cmd. #19

Closed ArchiDog1998 closed 1 year ago

ArchiDog1998 commented 1 year ago

This is an easy way to init cmd. and create a friendly cmd help panel in IMGUI.

For example, write the code in your IDalamudPlugin file like this. It'll automatically add a handle of your command of it and dispose of course.

    [Cmd("/fulf", "En/Disable FULF with /fulf or change the loot rule with /fulf need | greed or pass .")]
    [SubCmd("need", "Set need for FULF")]
    [SubCmd("greed", "Set greed for FULF")]
    [SubCmd("pass", "Set pass for FULF")]
    void FulfCommand(string command, string arguments)
    {
    }

    [Cmd("/rolling", "Roll for the loot according to the argument and the item's RollResult. /rolling need | greed | pass or passall", showInHelpPanel: false)]
    [SubCmd("need", "Rolling need")]
    [SubCmd("greed", "Rolling greed")]
    [SubCmd("pass", "Rolling pass")]
    void RollingCommand(string command, string arguments)
    {
    }

    [Cmd("/lazy", "Open Lazy Loot config.")]
    void OpenConfigCommand(string command, string arguments)
    {
    }

If you write the code like this in IMGUI drawing method, you'll see something like this.

CmdManager.DrawHelp(100);

image

NOTICE: This feature used the imgui method, however, I didn't move it to IMGUI folder. If you want to do this, please check it.

ArchiDog1998 commented 1 year ago

OMG, I found one thing called EzCmd!

Limiana commented 1 year ago

Thank you!