[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,058
Reaction score
1,483
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

Been scratching away at my game and making progress, but just had a revelation. I'm working in full screen and adjusting all my pictures accordingly, but will they resize if someone's screen is smaller?? I hope this doesn't turn out to be a problem later.
Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.

Forum statistics

Threads
105,625
Messages
1,015,052
Members
137,285
Latest member
AndrewRobertson
Top