From a13e22fb850ca702126e807e5d2a2f274483c626 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 25 Feb 2018 12:23:00 +0000 Subject: [PATCH] Play menu sounds. --- src/game/stats.c | 2 ++ src/game/stats.h | 1 + src/game/trophies.c | 2 ++ src/game/trophies.h | 1 + src/hub/hub.c | 12 +++++------- src/hub/hub.h | 2 ++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/game/stats.c b/src/game/stats.c index e01e8e0..b7344e6 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -62,6 +62,7 @@ void doStats(void) { if (isControl(CONTROL_LEFT) || app.keyboard[SDL_SCANCODE_LEFT]) { + playSound(SND_MENU_NAV, 0); page = limit(page - 1, 0, maxPages - 1); app.keyboard[SDL_SCANCODE_LEFT] = 0; clearControl(CONTROL_LEFT); @@ -69,6 +70,7 @@ void doStats(void) if (isControl(CONTROL_RIGHT) || app.keyboard[SDL_SCANCODE_RIGHT]) { + playSound(SND_MENU_NAV, 0); page = limit(page + 1, 0, maxPages - 1); app.keyboard[SDL_SCANCODE_RIGHT] = 0; clearControl(CONTROL_RIGHT); diff --git a/src/game/stats.h b/src/game/stats.h index 9a5d592..b17afde 100644 --- a/src/game/stats.h +++ b/src/game/stats.h @@ -34,6 +34,7 @@ extern Atlas *getImageFromAtlas(char *filename); extern Texture *getTexture(const char *filename); extern void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center); extern void doWidgets(void); +extern void playSound(int snd, int ch); extern App app; extern Colors colors; diff --git a/src/game/trophies.c b/src/game/trophies.c index 07020e9..cf0822e 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -81,6 +81,7 @@ void doTrophies(void) { if (isControl(CONTROL_LEFT) || app.keyboard[SDL_SCANCODE_LEFT]) { + playSound(SND_MENU_NAV, 0); page = limit(page - 1, 0, maxPages - 1); app.keyboard[SDL_SCANCODE_LEFT] = 0; clearControl(CONTROL_LEFT); @@ -88,6 +89,7 @@ void doTrophies(void) if (isControl(CONTROL_RIGHT) || app.keyboard[SDL_SCANCODE_RIGHT]) { + playSound(SND_MENU_NAV, 0); page = limit(page + 1, 0, maxPages - 1); app.keyboard[SDL_SCANCODE_RIGHT] = 0; clearControl(CONTROL_RIGHT); diff --git a/src/game/trophies.h b/src/game/trophies.h index 54778bf..c2c6b61 100644 --- a/src/game/trophies.h +++ b/src/game/trophies.h @@ -44,6 +44,7 @@ extern int isControl(int type); extern void clearControl(int type); extern void doWidgets(void); extern char *timeToDate(long millis); +extern void playSound(int snd, int ch); extern App app; extern Colors colors; diff --git a/src/hub/hub.c b/src/hub/hub.c index b332d55..297773d 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -236,6 +236,7 @@ static void logic(void) doWidgets(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) { + playSound(SND_MENU_BACK, 0); showing = SHOW_NONE; app.keyboard[SDL_SCANCODE_ESCAPE] = 0; } @@ -245,6 +246,7 @@ static void logic(void) doStats(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) { + playSound(SND_MENU_BACK, 0); returnFromTrophyStats(); } break; @@ -253,6 +255,7 @@ static void logic(void) doTrophies(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) { + playSound(SND_MENU_BACK, 0); returnFromTrophyStats(); } break; @@ -301,6 +304,7 @@ static void doMissionSelect(void) if (app.keyboard[SDL_SCANCODE_ESCAPE]) { + playSound(SND_MENU_BACK, 0); showWidgetGroup("hub"); showing = SHOW_WIDGETS; app.keyboard[SDL_SCANCODE_ESCAPE] = 0; @@ -422,15 +426,9 @@ static void drawInfoBar(void) static void drawHudWidgets(void) { - int w, h; - - w = 300; - h = 420; - drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128); - drawRect((SCREEN_WIDTH - w) / 2, (SCREEN_HEIGHT - h) / 2, w, h, 0, 0, 0, 192); - drawOutlineRect((SCREEN_WIDTH - w) / 2, (SCREEN_HEIGHT - h) / 2, w, h, 255, 255, 255, 255); + drawWidgetFrame(); drawWidgets(); } diff --git a/src/hub/hub.h b/src/hub/hub.h index 6fd39aa..357957c 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -69,6 +69,8 @@ extern void doTrophies(void); extern void drawTrophies(void); extern void initOptions(void (*callback)(void)); extern int getMissionStatus(char *id); +extern void drawWidgetFrame(void); +extern void playSound(int snd, int ch); extern App app; extern Colors colors;