Allow widget select using player controls.

This commit is contained in:
Steve 2018-02-16 08:08:19 +00:00
parent 8ab5ebe819
commit 344460fdf5
2 changed files with 12 additions and 5 deletions

View File

@ -44,33 +44,38 @@ void initWidgets(void)
void doWidgets(void)
{
if (app.keyboard[SDL_SCANCODE_UP])
if (isControl(CONTROL_UP) || app.keyboard[SDL_SCANCODE_UP])
{
selectWidget(-1);
app.keyboard[SDL_SCANCODE_UP] = 0;
clearControl(CONTROL_UP);
}
if (app.keyboard[SDL_SCANCODE_DOWN])
if (isControl(CONTROL_DOWN) || app.keyboard[SDL_SCANCODE_DOWN])
{
selectWidget(1);
app.keyboard[SDL_SCANCODE_DOWN] = 0;
clearControl(CONTROL_DOWN);
}
if (app.keyboard[SDL_SCANCODE_LEFT])
if (isControl(CONTROL_LEFT) || app.keyboard[SDL_SCANCODE_LEFT])
{
updateWidgetValue(-1);
}
if (app.keyboard[SDL_SCANCODE_RIGHT])
if (isControl(CONTROL_RIGHT) || app.keyboard[SDL_SCANCODE_RIGHT])
{
updateWidgetValue(1);
}
if (app.keyboard[SDL_SCANCODE_RETURN])
if (isControl(CONTROL_FIRE) || app.keyboard[SDL_SCANCODE_RETURN])
{
selectedWidget->action();
app.keyboard[SDL_SCANCODE_RETURN] = 0;
clearControl(CONTROL_FIRE);
}
}

View File

@ -29,6 +29,8 @@ extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
extern void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a);
extern float limit(float i, float a, float b);
extern void playSound(int snd, int ch);
extern int isControl(int type);
extern void clearControl(int type);
extern App app;
extern Colors colors;