Plugin strings and keys... (1 Viewer)

TesterBoy

Portal Pro
July 10, 2006
160
3
Lower Hutt
Home Country
New Zealand New Zealand
According to the Plugin tutorial, I can define strings for my GUI either by putting the text in the control's XML (<label>The string</label>), or by specifying a string Id within strings.xml (<label>73</label>).

Are these the only options? Obviously, the former method means that translations won't be possible, and the latter means the user has to mess with their strings.xml(s) when installing the plugin; neither of these is really satisfactory...

Likewise for keymap.xml - I want to override the default actions for some (most!) keys (only for my plugin, of course), but the only way I've found to make this work is for the user to manually cut-and-paste a section into keymap.xml for my plugin's GUI; again, this seems heavy-handed, and makes un/re-installing the plugin rather problematic. Also, each time the user upgrades or reinstalls MP, they will have to go through the same painful process again.

It'd be nice if I could define <keys>...</keys> in the gui xml, and possibly have multiple <string></string> entries (one for each language, maybe defaulting to the first if the user-selected language is not found)...

Or have I just missed the obvious, already present way to do these things? Given that my C# is fairly elementary so far this wouldn't surprise me...
 

Inker

Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Well, for overwriting keys....I don't think you should overwrite them. Generally you would react to ACTIONS (which are caused by the user pressing whatever key, be it on the remote or keyboard, that the user has assigned to that ACTION. In the plugin you then intercept the ACTION (and not a keypress directly) and react accordingly.

    Lets say you wanted to do something when the user presses stop (which defaults to the 'b' button the keyboard, but the user can overwrite this in the configuration to whatever key he/she wants. The code would look something like this:

    Code:
    public override void OnAction(Action action)
    {
      switch (action.wID)
                {
                    case Action.ActionType.ACTION_STOP:
                               // do whatever here
                               break;
                    default:
                              // let MP handle all other actions
                              base.OnAction(action);
                              break;
                }
    }
     

    TesterBoy

    Portal Pro
    July 10, 2006
    160
    3
    Lower Hutt
    Home Country
    New Zealand New Zealand
    The thing is, I don't want the key to actually do anything except be a 'b' - the user is typing text into the plugin, and when the 'b' key is pressed I don't want the video to stop -I just want to get a 'b' so I can add it to the string. If I override the mapping in keymap to -1, this works perfectly (except the '!' still does the frame-rate etc)...
     

    Users who are viewing this thread

    Top Bottom