MenuInputHandler.zh
Overview
Creator:
Moosh
Added: 28 Jan 2026
Tags:
2.55,
Library
Downloads: 8
|
Download Script (1.67 KB) |
Information
This is a small header containing a class for handling inputs in scripted menus. With it you can give your scripts held inputs that repeatedly move the cursor or queue inputs to execute afterwards during an animation.
Description Setup Reviews Comments
Create a MenuInputHandler at the start of your script with your desired settings. You can also give it acceleration with the SetHoldAcceleration() function.
Every frame where you want inputs to be processed, call the Update() function. Then in places where you want to check for inputs, use the ButtonFired() function.
Here's a test menu using the header:
Every frame where you want inputs to be processed, call the Update() function. Then in places where you want to check for inputs, use the ButtonFired() function.
Here's a test menu using the header:
// Basic example menu with an accelerating cursor
ffc script MenuInputHandlerExample
{
using namespace MenuInputHandler;
void run()
{
// Create the menu handler object
// This one will read the directional button, allow repeat inputs by holding for 16 frames, run all directions on a single timer, and allow up to 3 queued directional presses
MenuInputHandler mih = new MenuInputHandler({CB_UP, CB_DOWN, CB_LEFT, CB_RIGHT}, 16, MIHF_SINGLE_TIMER, 3);
// Optional: Set acceleration and minimum delay for the cursor
mih->SetHoldAcceleration(2, 4);
int x;
int y;
while(true)
{
// Update the handler every frame. If you want to queue inputs this frame, call with Update(true)
mih->Update();
for(int i=CB_UP; iPress[i] = false;
Input->Button[i] = false;
// ButtonFired() works just like Press[] and Button[] but handles the held and queued inputs
if(mih->ButtonFired(i))
{
Game->PlaySound(SFX_CURSOR);
x = wrap((x+DirX(i)), 8);
y = wrap((y+DirY(i)), 8);
}
}
// Drawing the menu
for(int xx=0; xx<8; ++xx)
{
for(int yy=0; yyDrawString(6, this->X+xx*16, this->Y+yy*16, FONT_Z1, c, -1, TF_NORMAL, "O", OP_OPAQUE, SHD_OUTLINED8, 0x0F);
}
}
Waitframe();
}
}
}


