More widget work.
This commit is contained in:
parent
1df85d0937
commit
0d87786af4
Binary file not shown.
|
@ -268,8 +268,9 @@ enum
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SND_SELECT,
|
SND_MENU_SELECT,
|
||||||
SND_BACK,
|
SND_MENU_BACK,
|
||||||
|
SND_MENU_NAV,
|
||||||
SND_PISTOL,
|
SND_PISTOL,
|
||||||
SND_MACHINE_GUN,
|
SND_MACHINE_GUN,
|
||||||
SND_PLASMA,
|
SND_PLASMA,
|
||||||
|
|
|
@ -451,7 +451,6 @@ typedef struct {
|
||||||
int minEnemySpawnTime, maxEnemySpawnTime;
|
int minEnemySpawnTime, maxEnemySpawnTime;
|
||||||
unsigned long entityCounter;
|
unsigned long entityCounter;
|
||||||
int entityChaseTimer;
|
int entityChaseTimer;
|
||||||
int showingInfoMessage;
|
|
||||||
int allObjectivesComplete;
|
int allObjectivesComplete;
|
||||||
int frameCounter;
|
int frameCounter;
|
||||||
int currentStatus;
|
int currentStatus;
|
||||||
|
|
|
@ -88,8 +88,10 @@ static Mix_Chunk *loadSound(char *filename)
|
||||||
|
|
||||||
static void loadSounds(void)
|
static void loadSounds(void)
|
||||||
{
|
{
|
||||||
sounds[SND_BACK] = loadSound("sound/50557__broumbroum__sf3-sfx-menu-back.ogg");
|
sounds[SND_MENU_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_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_PISTOL] = loadSound("sound/Gun_44magnum-freesoundeffects.ogg");
|
||||||
sounds[SND_MACHINE_GUN] = loadSound("sound/67020__ls__submachinegun2.ogg");
|
sounds[SND_MACHINE_GUN] = loadSound("sound/67020__ls__submachinegun2.ogg");
|
||||||
sounds[SND_PLASMA] = loadSound("sound/93017__cosmicd__60.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_DENIED] = loadSound("sound/142608__autistic-lucario__error.ogg");
|
||||||
sounds[SND_CONFIRMED] = loadSound("sound/39028__wildweasel__cardlock-open.ogg");
|
sounds[SND_CONFIRMED] = loadSound("sound/39028__wildweasel__cardlock-open.ogg");
|
||||||
sounds[SND_HEART_CELL] = loadSound("sound/162467__kastenfrosch__gotitem.ogg");
|
sounds[SND_HEART_CELL] = loadSound("sound/162467__kastenfrosch__gotitem.ogg");
|
||||||
|
|
||||||
sounds[SND_MISSION_COMPLETE] = loadSound("sound/113989__kastenfrosch__gewonnen.ogg");
|
sounds[SND_MISSION_COMPLETE] = loadSound("sound/113989__kastenfrosch__gewonnen.ogg");
|
||||||
sounds[SND_TROPHY] = loadSound("sound/278142__ricemaster__effect-notify.ogg");
|
sounds[SND_TROPHY] = loadSound("sound/278142__ricemaster__effect-notify.ogg");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ void initWidgets(void)
|
||||||
|
|
||||||
numWidgets = 0;
|
numWidgets = 0;
|
||||||
|
|
||||||
|
selectedWidget = NULL;
|
||||||
|
|
||||||
loadWidgets();
|
loadWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,16 +104,15 @@ void drawWidgets(void)
|
||||||
case WT_BUTTON:
|
case WT_BUTTON:
|
||||||
if (w != selectedWidget)
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
drawRect(w->x, w->y, w->w, w->h, 0, 128, 0, 255);
|
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);
|
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;
|
break;
|
||||||
|
|
||||||
case WT_SLIDER:
|
case WT_SLIDER:
|
||||||
|
@ -129,6 +130,8 @@ void drawWidgets(void)
|
||||||
|
|
||||||
static void selectWidget(int dir)
|
static void selectWidget(int dir)
|
||||||
{
|
{
|
||||||
|
int oldWidgetIndex = widgetIndex;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
widgetIndex += dir;
|
widgetIndex += dir;
|
||||||
|
@ -146,6 +149,11 @@ static void selectWidget(int dir)
|
||||||
selectedWidget = &widgets[widgetIndex];
|
selectedWidget = &widgets[widgetIndex];
|
||||||
|
|
||||||
} while (!selectedWidget->enabled && !selectedWidget->visible);
|
} while (!selectedWidget->enabled && !selectedWidget->visible);
|
||||||
|
|
||||||
|
if (oldWidgetIndex != widgetIndex)
|
||||||
|
{
|
||||||
|
playSound(SND_MENU_NAV, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget *getWidget(char *name, char *group)
|
Widget *getWidget(char *name, char *group)
|
||||||
|
@ -197,6 +205,7 @@ void showWidgetGroup(char *group)
|
||||||
if (selectedWidget == NULL)
|
if (selectedWidget == NULL)
|
||||||
{
|
{
|
||||||
selectedWidget = w;
|
selectedWidget = w;
|
||||||
|
widgetIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->visible = 1;
|
w->visible = 1;
|
||||||
|
|
|
@ -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 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 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 float limit(float i, float a, float b);
|
||||||
|
extern void playSound(int snd, int ch);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -36,6 +36,10 @@ static void spawnEnemies(void);
|
||||||
static int canAdd(Unit *u, int mx, int my);
|
static int canAdd(Unit *u, int mx, int my);
|
||||||
static void startMission(void);
|
static void startMission(void);
|
||||||
static void drawInGameWidgets(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 Texture *background;
|
||||||
static int observationIndex;
|
static int observationIndex;
|
||||||
|
@ -69,6 +73,10 @@ void initWorld(void)
|
||||||
|
|
||||||
observationIndex = 0;
|
observationIndex = 0;
|
||||||
|
|
||||||
|
getWidget("resume", "gamePaused")->action = resume;
|
||||||
|
getWidget("options", "gamePaused")->action = options;
|
||||||
|
getWidget("quit", "gamePaused")->action = quit;
|
||||||
|
|
||||||
if (world.missionType == MT_BOSS)
|
if (world.missionType == MT_BOSS)
|
||||||
{
|
{
|
||||||
startMission();
|
startMission();
|
||||||
|
@ -90,10 +98,6 @@ void initWorld(void)
|
||||||
app.delegate.logic = logic;
|
app.delegate.logic = logic;
|
||||||
app.delegate.draw = draw;
|
app.delegate.draw = draw;
|
||||||
|
|
||||||
showWidgetGroup("gamePaused");
|
|
||||||
|
|
||||||
showingWidgets = 1;
|
|
||||||
|
|
||||||
startMission();
|
startMission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +263,7 @@ static void doWorldInProgress(void)
|
||||||
|
|
||||||
doPlayer();
|
doPlayer();
|
||||||
|
|
||||||
if (!world.showingInfoMessage)
|
if (!showingWidgets)
|
||||||
{
|
{
|
||||||
doBob();
|
doBob();
|
||||||
|
|
||||||
|
@ -296,6 +300,13 @@ static void doWorldInProgress(void)
|
||||||
initRadar();
|
initRadar();
|
||||||
clearControl(CONTROL_MAP);
|
clearControl(CONTROL_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_ESCAPE])
|
||||||
|
{
|
||||||
|
app.keyboard[SDL_SCANCODE_ESCAPE] = 0;
|
||||||
|
showWidgetGroup("gamePaused");
|
||||||
|
playSound(SND_MENU_BACK, 0);
|
||||||
|
showingWidgets = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.observationTimer > 0)
|
if (world.observationTimer > 0)
|
||||||
|
@ -307,6 +318,21 @@ static void doWorldInProgress(void)
|
||||||
world.state = WS_OBSERVING;
|
world.state = WS_OBSERVING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handleWidgets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleWidgets(void)
|
||||||
|
{
|
||||||
|
doWidgets();
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_ESCAPE])
|
||||||
|
{
|
||||||
|
resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doWorldObserving(void)
|
static void doWorldObserving(void)
|
||||||
|
@ -616,3 +642,18 @@ void exitRadar(void)
|
||||||
|
|
||||||
endSectionTransition();
|
endSectionTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void resume(void)
|
||||||
|
{
|
||||||
|
app.keyboard[SDL_SCANCODE_ESCAPE] = 0;
|
||||||
|
hideAllWidgets();
|
||||||
|
showingWidgets = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void options(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void quit(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,9 @@ extern void drawWidgets(void);
|
||||||
extern void showWidgetGroup(char *group);
|
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 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 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 App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
Loading…
Reference in New Issue