diff --git a/sound/146721__fins__menu-click.ogg b/sound/146721__fins__menu-click.ogg new file mode 100644 index 0000000..8bd7aed Binary files /dev/null and b/sound/146721__fins__menu-click.ogg differ diff --git a/src/defs.h b/src/defs.h index 8d46c8a..50b955c 100644 --- a/src/defs.h +++ b/src/defs.h @@ -268,8 +268,9 @@ enum enum { - SND_SELECT, - SND_BACK, + SND_MENU_SELECT, + SND_MENU_BACK, + SND_MENU_NAV, SND_PISTOL, SND_MACHINE_GUN, SND_PLASMA, diff --git a/src/structs.h b/src/structs.h index 873ff3a..6cf98aa 100644 --- a/src/structs.h +++ b/src/structs.h @@ -451,7 +451,6 @@ typedef struct { int minEnemySpawnTime, maxEnemySpawnTime; unsigned long entityCounter; int entityChaseTimer; - int showingInfoMessage; int allObjectivesComplete; int frameCounter; int currentStatus; diff --git a/src/system/sound.c b/src/system/sound.c index 8cca88a..36473e1 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -88,8 +88,10 @@ static Mix_Chunk *loadSound(char *filename) static void loadSounds(void) { - sounds[SND_BACK] = loadSound("sound/50557__broumbroum__sf3-sfx-menu-back.ogg"); - sounds[SND_SELECT] = loadSound("sound/50561__broumbroum__sf3-sfx-menu-select.ogg"); + sounds[SND_MENU_BACK] = loadSound("sound/50557__broumbroum__sf3-sfx-menu-back.ogg"); + sounds[SND_MENU_SELECT] = loadSound("sound/50561__broumbroum__sf3-sfx-menu-select.ogg"); + sounds[SND_MENU_NAV] = loadSound("sound/146721__fins__menu-click.ogg"); + sounds[SND_PISTOL] = loadSound("sound/Gun_44magnum-freesoundeffects.ogg"); sounds[SND_MACHINE_GUN] = loadSound("sound/67020__ls__submachinegun2.ogg"); sounds[SND_PLASMA] = loadSound("sound/93017__cosmicd__60.ogg"); @@ -127,6 +129,7 @@ static void loadSounds(void) sounds[SND_DENIED] = loadSound("sound/142608__autistic-lucario__error.ogg"); sounds[SND_CONFIRMED] = loadSound("sound/39028__wildweasel__cardlock-open.ogg"); sounds[SND_HEART_CELL] = loadSound("sound/162467__kastenfrosch__gotitem.ogg"); + sounds[SND_MISSION_COMPLETE] = loadSound("sound/113989__kastenfrosch__gewonnen.ogg"); sounds[SND_TROPHY] = loadSound("sound/278142__ricemaster__effect-notify.ogg"); } diff --git a/src/system/widgets.c b/src/system/widgets.c index df31cc7..336d12d 100644 --- a/src/system/widgets.c +++ b/src/system/widgets.c @@ -37,6 +37,8 @@ void initWidgets(void) numWidgets = 0; + selectedWidget = NULL; + loadWidgets(); } @@ -102,16 +104,15 @@ void drawWidgets(void) case WT_BUTTON: if (w != selectedWidget) { - drawRect(w->x, w->y, w->w, w->h, 0, 64, 0, 255); + drawRect(w->x, w->y, w->w, w->h, 0, 0, 0, 255); drawOutlineRect(w->x, w->y, w->w, w->h, 0, 128, 0, 255); - drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.white, w->label); } else { drawRect(w->x, w->y, w->w, w->h, 0, 128, 0, 255); drawOutlineRect(w->x, w->y, w->w, w->h, 0, 255, 0, 255); - drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.yellow, w->label); } + drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.white, w->label); break; case WT_SLIDER: @@ -129,6 +130,8 @@ void drawWidgets(void) static void selectWidget(int dir) { + int oldWidgetIndex = widgetIndex; + do { widgetIndex += dir; @@ -146,6 +149,11 @@ static void selectWidget(int dir) selectedWidget = &widgets[widgetIndex]; } while (!selectedWidget->enabled && !selectedWidget->visible); + + if (oldWidgetIndex != widgetIndex) + { + playSound(SND_MENU_NAV, 0); + } } Widget *getWidget(char *name, char *group) @@ -197,6 +205,7 @@ void showWidgetGroup(char *group) if (selectedWidget == NULL) { selectedWidget = w; + widgetIndex = i; } w->visible = 1; diff --git a/src/system/widgets.h b/src/system/widgets.h index 6f12dce..8478661 100644 --- a/src/system/widgets.h +++ b/src/system/widgets.h @@ -28,6 +28,7 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char 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 App app; extern Colors colors; diff --git a/src/world/world.c b/src/world/world.c index 077b73e..e6e35db 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -36,6 +36,10 @@ static void spawnEnemies(void); static int canAdd(Unit *u, int mx, int my); static void startMission(void); static void drawInGameWidgets(void); +static void handleWidgets(void); +static void resume(void); +static void options(void); +static void quit(void); static Texture *background; static int observationIndex; @@ -68,6 +72,10 @@ void initWorld(void) world.state = WS_START; observationIndex = 0; + + getWidget("resume", "gamePaused")->action = resume; + getWidget("options", "gamePaused")->action = options; + getWidget("quit", "gamePaused")->action = quit; if (world.missionType == MT_BOSS) { @@ -90,10 +98,6 @@ void initWorld(void) app.delegate.logic = logic; app.delegate.draw = draw; - showWidgetGroup("gamePaused"); - - showingWidgets = 1; - startMission(); } @@ -259,7 +263,7 @@ static void doWorldInProgress(void) doPlayer(); - if (!world.showingInfoMessage) + if (!showingWidgets) { doBob(); @@ -296,16 +300,38 @@ static void doWorldInProgress(void) initRadar(); clearControl(CONTROL_MAP); } - } - - if (world.observationTimer > 0) - { - if (--world.observationTimer == FPS * 1.5) + + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { - world.entityToTrack = world.entitiesToObserve[0]; - - world.state = WS_OBSERVING; + app.keyboard[SDL_SCANCODE_ESCAPE] = 0; + showWidgetGroup("gamePaused"); + playSound(SND_MENU_BACK, 0); + showingWidgets = 1; } + + if (world.observationTimer > 0) + { + if (--world.observationTimer == FPS * 1.5) + { + world.entityToTrack = world.entitiesToObserve[0]; + + world.state = WS_OBSERVING; + } + } + } + else + { + handleWidgets(); + } +} + +static void handleWidgets(void) +{ + doWidgets(); + + if (app.keyboard[SDL_SCANCODE_ESCAPE]) + { + resume(); } } @@ -616,3 +642,18 @@ void exitRadar(void) endSectionTransition(); } + +static void resume(void) +{ + app.keyboard[SDL_SCANCODE_ESCAPE] = 0; + hideAllWidgets(); + showingWidgets = 0; +} + +static void options(void) +{ +} + +static void quit(void) +{ +} diff --git a/src/world/world.h b/src/world/world.h index 19d0964..c9a14eb 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -76,6 +76,9 @@ extern void drawWidgets(void); extern void showWidgetGroup(char *group); 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 void hideAllWidgets(void); +extern void doWidgets(void); +extern Widget *getWidget(char *name, char *group); extern App app; extern Colors colors;