[RMMV] Search field in custom menu

Shigekims

Villager
Member
Joined
Dec 21, 2018
Messages
6
Reaction score
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!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
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:
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
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.
 

Shigekims

Villager
Member
Joined
Dec 21, 2018
Messages
6
Reaction score
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top