Stats control update.
This commit is contained in:
parent
e44aad495c
commit
e76cbaedda
|
@ -129,6 +129,10 @@ static void logic(void)
|
|||
case SHOW_STAR_SYSTEM:
|
||||
doStarSystemView();
|
||||
break;
|
||||
|
||||
case SHOW_STATS:
|
||||
doStats();
|
||||
break;
|
||||
}
|
||||
|
||||
doPulses();
|
||||
|
|
|
@ -65,6 +65,7 @@ extern void initStatsDisplay(void);
|
|||
extern void updateStarSystemMissions(void);
|
||||
extern StarSystem *getStarSystem(char *name);
|
||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void doStats(void);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -51,6 +51,7 @@ static int page;
|
|||
static int maxPages;
|
||||
static SDL_Texture *pagePrev;
|
||||
static SDL_Texture *pageNext;
|
||||
static SDL_Rect left, right;
|
||||
|
||||
void initStatsDisplay(void)
|
||||
{
|
||||
|
@ -59,6 +60,32 @@ void initStatsDisplay(void)
|
|||
|
||||
pagePrev = getTexture("gfx/widgets/optionsLeft.png");
|
||||
pageNext = getTexture("gfx/widgets/optionsRight.png");
|
||||
|
||||
left.x = (SCREEN_WIDTH / 2) - 100;
|
||||
left.y = 120;
|
||||
SDL_QueryTexture(pagePrev, NULL, NULL, &left.w, &left.h);
|
||||
|
||||
right.x = (SCREEN_WIDTH / 2) + 100;
|
||||
right.y = 120;
|
||||
SDL_QueryTexture(pageNext, NULL, NULL, &right.w, &right.h);
|
||||
}
|
||||
|
||||
void doStats(void)
|
||||
{
|
||||
if (app.mouse.button[SDL_BUTTON_LEFT])
|
||||
{
|
||||
if (collision(app.mouse.x - (app.mouse.w / 2), app.mouse.y - (app.mouse.h / 2), app.mouse.w, app.mouse.h, left.x - (left.w / 2), left.y - (left.h / 2), left.w, left.h))
|
||||
{
|
||||
page = MAX(0, page - 1);
|
||||
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
||||
}
|
||||
|
||||
if (collision(app.mouse.x - (app.mouse.w / 2), app.mouse.y - (app.mouse.h / 2), app.mouse.w, app.mouse.h, right.x - (right.w / 2), right.y - (right.h / 2), right.w, right.h))
|
||||
{
|
||||
page = MIN(page + 1, maxPages);
|
||||
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawStats(void)
|
||||
|
@ -88,12 +115,12 @@ void drawStats(void)
|
|||
|
||||
if (page > 0)
|
||||
{
|
||||
blit(pagePrev, (SCREEN_WIDTH / 2) - 100, 120, 1);
|
||||
blit(pagePrev, left.x, left.y, 1);
|
||||
}
|
||||
|
||||
if (page < maxPages)
|
||||
{
|
||||
blit(pageNext, (SCREEN_WIDTH / 2) + 100, 120, 1);
|
||||
blit(pageNext, right.x, right.y, 1);
|
||||
}
|
||||
|
||||
y = 170;
|
||||
|
|
|
@ -29,6 +29,7 @@ extern void drawWidgets(char *groupName);
|
|||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern void blit(SDL_Texture *texture, int x, int y, int centered);
|
||||
extern SDL_Texture *getTexture(char *filename);
|
||||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
Loading…
Reference in New Issue