[RMMV] Search field in custom menu

Discussion in 'RPG Maker MV' started by Shigekims, Dec 21, 2018.

  1. Shigekims

    Shigekims Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    Any advice on how to implement a search field in a menu, which could return results in another menu window?

    For example, if a player has a large inventory, and they are looking for a specific item, instead of scrolling down their list of items, instead they can filter the items that appear on the list by typing in the beginning of the item name?

    Could this jive well with the built in item lists in RMMV, or would you have to create/populate/maintain a custom List to search and return results from in javascript?

    I'm already familiar with the basic custom menu plugins from SmRndmDde and Yanfly.

    Thank you!
     
    #1
  2. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,257
    Likes Received:
    780
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    The default item scene has three windows: item description, category select, and the item list itself. The contents of the item list window are determined by which category the user has selected: it just filters out items that don't match that category (cf Window_ItemList.prototype.includes). I'm reasonably certain your idea would require a custom plugin: I haven't much experience with SRD's stuff, but I'm pretty sure nothing in Yanfly's library lets you make edits of this scale to existing scenes.

    At minimum, I think it would require something to handle user keypresses, store the input, and use that input to extend (or replace) the built-in item filter. May involve some layout edits too if you want the current search text displayed to the user (generally a good idea!). I've never really tried anything with custom input handling, though, so can't help with the specifics there. :kaoswt2:
     
    #2
  3. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,626
    Likes Received:
    1,047
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Filtering the list would be a piece of cake, basically a one-liner:
    Code:
    // this isn't the exact code but you get the idea
    const newList = oldList.filter(item => item.name.includes(input));
    
    Gathering the input (and the UI/UX with that) would be the tricky part.

    It could be done with an <input> HTML element and an oninput event handler. The nice part is that it would handle the player's language automatically and theoretically work with touchscreens. The bad part is that it would be harder to make it look good (would probably need CSS) and potentially immersion-breaking if it clashes with the rest of the menu design.

    I remember seeing a plugin on these forums that did this, but for inputting passwords or something in battle.

    The other route is to create a custom onKeyUp event handler that detects what key was pressed and prints it to a window in the item scene. I did this for my Notepad plugin (link in signature) and it was... insane haha.

    I don't have any more specifics than that but feel free to look at either example to see how they did it.
     
    #3
    caethyril likes this.
  4. Shigekims

    Shigekims Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you for the input; I'm now at a point where I could see collecting all the items in a players inventory into an array stored in a variable, but stuck on how to then display all of these items into the menu panel without having many many individual statements.
     
    #4

Share This Page