Start of drawing widgets.
This commit is contained in:
parent
d43523010e
commit
48abf156d8
|
@ -31,6 +31,5 @@ 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 mod(float n, float x);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
extern Game game;
|
||||
|
|
|
@ -78,6 +78,18 @@ void drawWidgets(void)
|
|||
switch (w->type)
|
||||
{
|
||||
case WT_BUTTON:
|
||||
if (w != selectedWidget)
|
||||
{
|
||||
drawRect(w->x, w->y, w->w, w->h, 0, 64, 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);
|
||||
}
|
||||
break;
|
||||
|
||||
case WT_PLAIN_BUTTON:
|
||||
|
@ -220,6 +232,11 @@ static void loadWidgetGroup(char *filename)
|
|||
w->h = cJSON_GetObjectItem(node, "h")->valueint;
|
||||
w->type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
|
||||
if (w->x == -1)
|
||||
{
|
||||
w->x = (SCREEN_WIDTH - w->w) / 2;
|
||||
}
|
||||
|
||||
switch (w->type)
|
||||
{
|
||||
case WT_SPINNER:
|
||||
|
|
|
@ -24,5 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
extern char *readFile(const char *filename);
|
||||
extern char **getFileList(const char *dir, int *count);
|
||||
extern long lookup(const char *name);
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
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 App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -33,7 +33,7 @@ void initAtlasTest(void)
|
|||
|
||||
initHub();
|
||||
|
||||
loadWorld("greenlands5");
|
||||
loadWorld("beachApproach");
|
||||
|
||||
initWorld();
|
||||
|
||||
|
@ -42,4 +42,6 @@ void initAtlasTest(void)
|
|||
initEntities();
|
||||
|
||||
saveConfig();
|
||||
|
||||
/*awardTrophy("BEACH");*/
|
||||
}
|
||||
|
|
|
@ -27,5 +27,6 @@ extern void initGame(void);
|
|||
extern void initEntities(void);
|
||||
extern void loadWorld(char *id);
|
||||
extern void saveConfig(void);
|
||||
extern void awardTrophy(char *id);
|
||||
|
||||
extern Dev dev;
|
||||
|
|
|
@ -35,9 +35,11 @@ static void addHelperItems(void);
|
|||
static void spawnEnemies(void);
|
||||
static int canAdd(Unit *u, int mx, int my);
|
||||
static void startMission(void);
|
||||
static void drawInGameWidgets(void);
|
||||
|
||||
static Texture *background;
|
||||
static int observationIndex;
|
||||
static int showingWidgets;
|
||||
|
||||
void initWorld(void)
|
||||
{
|
||||
|
@ -87,6 +89,12 @@ void initWorld(void)
|
|||
|
||||
app.delegate.logic = logic;
|
||||
app.delegate.draw = draw;
|
||||
|
||||
showWidgetGroup("gamePaused");
|
||||
|
||||
showingWidgets = 1;
|
||||
|
||||
startMission();
|
||||
}
|
||||
|
||||
static void logic(void)
|
||||
|
@ -154,6 +162,26 @@ static void draw(void)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (showingWidgets)
|
||||
{
|
||||
drawInGameWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
static void drawInGameWidgets(void)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = 300;
|
||||
h = 350;
|
||||
|
||||
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 drawNormal(void)
|
||||
|
|
|
@ -72,6 +72,10 @@ extern void playMusic(int loop);
|
|||
extern void initRadar(void);
|
||||
extern void startSectionTransition(void);
|
||||
extern void endSectionTransition(void);
|
||||
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 App app;
|
||||
extern Colors colors;
|
||||
|
|
Loading…
Reference in New Issue