Draw hud widgets.

This commit is contained in:
Steve 2018-02-18 22:22:05 +00:00
parent 03c02c01f9
commit cdea5b42fb
2 changed files with 49 additions and 10 deletions

View File

@ -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;

View File

@ -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;