From cdea5b42fb2037d0eda523d3dfd510bddfbb54b2 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 18 Feb 2018 22:22:05 +0000 Subject: [PATCH] Draw hud widgets. --- src/hub/hub.c | 58 ++++++++++++++++++++++++++++++++++++++++++--------- src/hub/hub.h | 1 + 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/hub/hub.c b/src/hub/hub.c index 1cfdf70..d3ec97d 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -41,6 +41,7 @@ static void quit(void); static void doCursor(void); static void doMissionSelect(void); static void doMissionInfo(void); +static void drawHudWidgets(void); static HubMission hubMissionHead; static HubMission *hubMissionTail; @@ -205,15 +206,29 @@ static void logic(void) animateSprites(); - doCursor(); - - if (selectedMission == NULL) + if (!showingWidgets) { - doMissionSelect(); + doCursor(); + + if (selectedMission == NULL) + { + doMissionSelect(); + } + else + { + doMissionInfo(); + } } else { - doMissionInfo(); + doWidgets(); + + if (app.keyboard[SDL_SCANCODE_ESCAPE]) + { + showingWidgets = 0; + + app.keyboard[SDL_SCANCODE_ESCAPE] = 0; + } } } @@ -258,6 +273,7 @@ static void doMissionSelect(void) { showWidgetGroup("hub"); showingWidgets = 1; + app.keyboard[SDL_SCANCODE_ESCAPE] = 0; } else if (isControl(CONTROL_FIRE) || app.mouse.button[SDL_BUTTON_LEFT]) { @@ -303,14 +319,21 @@ static void draw(void) drawInfoBar(); - if (selectedMission != NULL) + if (!showingWidgets) { - drawMissionInfo(); + if (selectedMission != NULL) + { + drawMissionInfo(); + + drawWidgets(); + } - drawWidgets(); + blitRect(atlasTexture->texture, cursor.x, cursor.y, getCurrentFrame(cursorSpr), 1); + } + else if (showingWidgets) + { + drawHudWidgets(); } - - blitRect(atlasTexture->texture, cursor.x, cursor.y, getCurrentFrame(cursorSpr), 1); } static void drawMissions(void) @@ -359,6 +382,21 @@ static void drawInfoBar(void) drawText(1010, 5, 18, TA_LEFT, colors.white, "Cells : %d / %d", game.stats[STAT_CELLS_FOUND], game.totalCells); } +static void drawHudWidgets(void) +{ + int w, h; + + w = 300; + h = 420; + + drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 64); + + 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); + + drawWidgets(); +} + static void drawMissionInfo(void) { int w, h, x, y, size, mid, i; diff --git a/src/hub/hub.h b/src/hub/hub.h index 635c73c..7186573 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -53,6 +53,7 @@ extern void initWorld(void); extern void drawBackground(SDL_Texture *texture, SDL_Rect *srcRect); extern void scrollBackground(float x, float y); extern double randF(void); +extern void doWidgets(void); extern App app; extern Colors colors;