Merge fixes.
This commit is contained in:
parent
159d36017b
commit
599c4fc338
|
@ -2,7 +2,7 @@ Changelog
|
||||||
|
|
||||||
0.6
|
0.6
|
||||||
|
|
||||||
* Added new game mode: Challenges
|
* New game mode: Challenges
|
||||||
* Add i18n support
|
* Add i18n support
|
||||||
|
|
||||||
0.51
|
0.51
|
||||||
|
|
|
@ -66,3 +66,4 @@ CC BY-NC-SA 3.0, with the following attribution: Copyright 2015-2016, Stephen J
|
||||||
* track-3.mp3, by Alexandr Zhelanov - https://soundcloud.com/alexandr-zhelanov
|
* track-3.mp3, by Alexandr Zhelanov - https://soundcloud.com/alexandr-zhelanov
|
||||||
* track-4.mp3, by Alexandr Zhelanov - https://soundcloud.com/alexandr-zhelanov
|
* track-4.mp3, by Alexandr Zhelanov - https://soundcloud.com/alexandr-zhelanov
|
||||||
* DST-RailJet-LongSeamlessLoop.ogg, by Deceased Superior Technician - http://opengameart.org/content/railjet-long-seamless-loop
|
* DST-RailJet-LongSeamlessLoop.ogg, by Deceased Superior Technician - http://opengameart.org/content/railjet-long-seamless-loop
|
||||||
|
* covert_operations.mp3, by artisticdude - http://opengameart.org/content/covert-operations
|
||||||
|
|
|
@ -270,7 +270,9 @@ enum
|
||||||
WT_BUTTON,
|
WT_BUTTON,
|
||||||
WT_IMG_BUTTON,
|
WT_IMG_BUTTON,
|
||||||
WT_SELECT,
|
WT_SELECT,
|
||||||
WT_SELECT_BUTTON
|
WT_SELECT_BUTTON,
|
||||||
|
WT_KEY_CONFIG,
|
||||||
|
WT_MOUSE_CONFIG
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -311,16 +311,15 @@ static void loadObjectives(cJSON *node)
|
||||||
battle.objectiveTail->next = o;
|
battle.objectiveTail->next = o;
|
||||||
battle.objectiveTail = o;
|
battle.objectiveTail = o;
|
||||||
|
|
||||||
o->active = 1;
|
|
||||||
STRNCPY(o->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH);
|
STRNCPY(o->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH);
|
||||||
STRNCPY(o->targetName, cJSON_GetObjectItem(node, "targetName")->valuestring, MAX_NAME_LENGTH);
|
STRNCPY(o->targetName, cJSON_GetObjectItem(node, "targetName")->valuestring, MAX_NAME_LENGTH);
|
||||||
o->targetValue = cJSON_GetObjectItem(node, "targetValue")->valueint;
|
o->targetValue = cJSON_GetObjectItem(node, "targetValue")->valueint;
|
||||||
o->targetType = lookup(cJSON_GetObjectItem(node, "targetType")->valuestring);
|
o->targetType = lookup(cJSON_GetObjectItem(node, "targetType")->valuestring);
|
||||||
o->active = getJSONValue(node, "active", 0);
|
o->active = getJSONValue(node, "active", 1);
|
||||||
o->isCondition = getJSONValue(node, "isCondition", 0);
|
o->isCondition = getJSONValue(node, "isCondition", 0);
|
||||||
|
|
||||||
o->isEliminateAll = getJSONValue(node, "isEliminateAll", 0);
|
o->isEliminateAll = getJSONValue(node, "isEliminateAll", 0);
|
||||||
if (isEliminateAll)
|
if (o->isEliminateAll)
|
||||||
{
|
{
|
||||||
o->targetValue = 1;
|
o->targetValue = 1;
|
||||||
}
|
}
|
||||||
|
@ -378,9 +377,6 @@ static void loadFighters(cJSON *node)
|
||||||
groupName = NULL;
|
groupName = NULL;
|
||||||
flags = -1;
|
flags = -1;
|
||||||
aiFlags = -1;
|
aiFlags = -1;
|
||||||
scatter = 1;
|
|
||||||
active = 1;
|
|
||||||
number = 1;
|
|
||||||
|
|
||||||
types = toTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
|
types = toTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
|
||||||
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
||||||
|
@ -388,9 +384,9 @@ static void loadFighters(cJSON *node)
|
||||||
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
||||||
name = getJSONValueStr(node, "name", NULL);
|
name = getJSONValueStr(node, "name", NULL);
|
||||||
groupName = getJSONValueStr(node, "groupName", NULL);
|
groupName = getJSONValueStr(node, "groupName", NULL);
|
||||||
number = getJSONValue(node, "number", 0);
|
number = getJSONValue(node, "number", 1);
|
||||||
scatter = getJSONValue(node, "scatter", 0);
|
scatter = getJSONValue(node, "scatter", 1);
|
||||||
active = getJSONValue(node, "active", 0);
|
active = getJSONValue(node, "active", 1);
|
||||||
|
|
||||||
if (cJSON_GetObjectItem(node, "flags"))
|
if (cJSON_GetObjectItem(node, "flags"))
|
||||||
{
|
{
|
||||||
|
@ -484,20 +480,17 @@ static void loadCapitalShips(cJSON *node)
|
||||||
{
|
{
|
||||||
name = NULL;
|
name = NULL;
|
||||||
groupName = NULL;
|
groupName = NULL;
|
||||||
scatter = 1;
|
|
||||||
active = 1;
|
|
||||||
number = 1;
|
|
||||||
flags = -1;
|
flags = -1;
|
||||||
|
|
||||||
types = toTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
|
types = toTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
|
||||||
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
||||||
x = (cJSON_GetObjectItem(node, "x")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_WIDTH;
|
x = (cJSON_GetObjectItem(node, "x")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_WIDTH;
|
||||||
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
||||||
name = cJSON_GetObjectItem(node, "name", NULL);
|
name = getJSONValueStr(node, "name", NULL);
|
||||||
groupName = getJSONValueStr(node, "groupName", NULL);
|
groupName = getJSONValueStr(node, "groupName", NULL);
|
||||||
number = getJSONValueStr(node, "number", 0);
|
number = getJSONValue(node, "number", 1);
|
||||||
scatter = getJSONValueStr(node, "scatter", 0);
|
scatter = getJSONValue(node, "scatter", 1);
|
||||||
active = getJSONValue(node, "active", 0);
|
active = getJSONValue(node, "active", 1);
|
||||||
|
|
||||||
if (cJSON_GetObjectItem(node, "flags"))
|
if (cJSON_GetObjectItem(node, "flags"))
|
||||||
{
|
{
|
||||||
|
@ -576,19 +569,12 @@ static void loadEntities(cJSON *node)
|
||||||
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
||||||
name = NULL;
|
name = NULL;
|
||||||
groupName = NULL;
|
groupName = NULL;
|
||||||
number = 1;
|
|
||||||
active = 1;
|
|
||||||
scatter = 1;
|
|
||||||
|
|
||||||
name = getJSONValueStr(node, "name", NULL);
|
name = getJSONValueStr(node, "name", NULL);
|
||||||
|
|
||||||
groupName = getJSONValueStr(node, "groupName", NULL);
|
groupName = getJSONValueStr(node, "groupName", NULL);
|
||||||
|
number = getJSONValue(node, "number", 1);
|
||||||
number = getJSONValue(node, "number", 0);
|
active = getJSONValue(node, "active", 1);
|
||||||
|
scatter = getJSONValue(node, "scatter", 1);
|
||||||
active = getJSONValue(node, "active", 0);
|
|
||||||
|
|
||||||
scatter = getJSONValue(node, "scatter", 0);
|
|
||||||
|
|
||||||
for (i = 0 ; i < number ; i++)
|
for (i = 0 ; i < number ; i++)
|
||||||
{
|
{
|
||||||
|
@ -659,24 +645,18 @@ static void loadItems(cJSON *node)
|
||||||
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
y = (cJSON_GetObjectItem(node, "y")->valuedouble / BATTLE_AREA_CELLS) * BATTLE_AREA_HEIGHT;
|
||||||
name = NULL;
|
name = NULL;
|
||||||
groupName = NULL;
|
groupName = NULL;
|
||||||
number = 1;
|
|
||||||
active = 1;
|
|
||||||
|
|
||||||
name = getJSONValueStr(node, "name", NULL);
|
name = getJSONValueStr(node, "name", NULL);
|
||||||
|
|
||||||
groupName = getJSONValueStr(node, "groupName", NULL);
|
groupName = getJSONValueStr(node, "groupName", NULL);
|
||||||
|
number = getJSONValue(node, "number", 1);
|
||||||
number = getJSONValue(node, "number", 0);
|
scatter = getJSONValue(node, "scatter", 1);
|
||||||
|
active = getJSONValue(node, "active", 1);
|
||||||
scatter = getJSONValue(node, "scatter", 0);
|
|
||||||
|
|
||||||
if (cJSON_GetObjectItem(node, "flags"))
|
if (cJSON_GetObjectItem(node, "flags"))
|
||||||
{
|
{
|
||||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
active = getJSONValue(node, "active", 0);
|
|
||||||
|
|
||||||
for (i = 0 ; i < number ; i++)
|
for (i = 0 ; i < number ; i++)
|
||||||
{
|
{
|
||||||
e = spawnItem(type);
|
e = spawnItem(type);
|
||||||
|
@ -734,8 +714,6 @@ static void loadLocations(cJSON *node)
|
||||||
|
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
active = 1;
|
|
||||||
|
|
||||||
l = malloc(sizeof(Location));
|
l = malloc(sizeof(Location));
|
||||||
memset(l, 0, sizeof(Location));
|
memset(l, 0, sizeof(Location));
|
||||||
battle.locationTail->next = l;
|
battle.locationTail->next = l;
|
||||||
|
@ -747,7 +725,7 @@ static void loadLocations(cJSON *node)
|
||||||
|
|
||||||
l->size = cJSON_GetObjectItem(node, "size")->valueint;
|
l->size = cJSON_GetObjectItem(node, "size")->valueint;
|
||||||
|
|
||||||
active = getJSONValue(node, "active", 0);
|
active = getJSONValue(node, "active", 1);
|
||||||
|
|
||||||
l->x += (SCREEN_WIDTH / 2);
|
l->x += (SCREEN_WIDTH / 2);
|
||||||
l->y += (SCREEN_HEIGHT / 2);
|
l->y += (SCREEN_HEIGHT / 2);
|
||||||
|
|
|
@ -29,3 +29,43 @@ void clearControl(int type)
|
||||||
{
|
{
|
||||||
app.keyboard[app.keyControls[type]] = 0;
|
app.keyboard[app.keyControls[type]] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initControlsDisplay(void)
|
||||||
|
{
|
||||||
|
getWidget("keyMissile", "controls")->value = app.keyControls[CONTROL_MISSILE];
|
||||||
|
getWidget("keyBoost", "controls")->value = app.keyControls[CONTROL_BOOST];
|
||||||
|
getWidget("keyECM", "controls")->value = app.keyControls[CONTROL_ECM];
|
||||||
|
getWidget("keyBrake", "controls")->value = app.keyControls[CONTROL_BRAKE];
|
||||||
|
getWidget("keyRadar", "controls")->value = app.keyControls[CONTROL_RADAR];
|
||||||
|
getWidget("keyTarget", "controls")->value = app.keyControls[CONTROL_TARGET];
|
||||||
|
getWidget("keyGuns", "controls")->value = app.keyControls[CONTROL_GUNS];
|
||||||
|
getWidget("keyPrevFighter", "controls")->value = app.keyControls[CONTROL_PREV_FIGHTER];
|
||||||
|
getWidget("keyNextFighter", "controls")->value = app.keyControls[CONTROL_NEXT_FIGHTER];
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawControls(void)
|
||||||
|
{
|
||||||
|
SDL_Rect r;
|
||||||
|
|
||||||
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||||
|
SDL_RenderFillRect(app.renderer, NULL);
|
||||||
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
|
r.w = 800;
|
||||||
|
r.h = 650;
|
||||||
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
||||||
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
||||||
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
||||||
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
|
|
||||||
|
drawText(SCREEN_WIDTH / 2, 50, 28, TA_CENTER, colors.white, _("Controls"));
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
|
||||||
|
SDL_RenderDrawLine(app.renderer, r.x, r.y + 65, r.x + r.w, r.y + 65);
|
||||||
|
|
||||||
|
drawWidgets("controls");
|
||||||
|
}
|
||||||
|
|
|
@ -20,5 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
|
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||||
|
extern char *getTranslatedString(char *string);
|
||||||
|
extern Widget *getWidget(const char *name, const char *group);
|
||||||
|
extern void drawWidgets(char *groupName);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
|
extern Colors colors;
|
||||||
extern Game game;
|
extern Game game;
|
||||||
|
|
|
@ -91,6 +91,8 @@ void initLookups(void)
|
||||||
addLookup("WT_BUTTON", WT_BUTTON);
|
addLookup("WT_BUTTON", WT_BUTTON);
|
||||||
addLookup("WT_SELECT", WT_SELECT);
|
addLookup("WT_SELECT", WT_SELECT);
|
||||||
addLookup("WT_IMG_BUTTON", WT_IMG_BUTTON);
|
addLookup("WT_IMG_BUTTON", WT_IMG_BUTTON);
|
||||||
|
addLookup("WT_KEY_CONFIG", WT_KEY_CONFIG);
|
||||||
|
addLookup("WT_MOUSE_CONFIG", WT_MOUSE_CONFIG);
|
||||||
|
|
||||||
addLookup("SIDE_ALLIES", SIDE_ALLIES);
|
addLookup("SIDE_ALLIES", SIDE_ALLIES);
|
||||||
addLookup("SIDE_PIRATE", SIDE_PIRATE);
|
addLookup("SIDE_PIRATE", SIDE_PIRATE);
|
||||||
|
|
|
@ -60,7 +60,7 @@ void showOKDialog(void (*callback)(void), const char *format, ...)
|
||||||
ok->action = callback;
|
ok->action = callback;
|
||||||
|
|
||||||
enableTimer = FPS;
|
enableTimer = FPS;
|
||||||
ok->enabled = okCancelOK = okCancelCancel = 0;
|
ok->enabled = okCancelOK->enabled = okCancelCancel->enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...)
|
void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...)
|
||||||
|
@ -81,7 +81,7 @@ void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void),
|
||||||
okCancelCancel->action = cancelCallback;
|
okCancelCancel->action = cancelCallback;
|
||||||
|
|
||||||
enableTimer = FPS;
|
enableTimer = FPS;
|
||||||
ok->enabled = okCancelOK = okCancelCancel = 0;
|
ok->enabled = okCancelOK->enabled = okCancelCancel->enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doModalDialog(void)
|
void doModalDialog(void)
|
||||||
|
@ -93,7 +93,7 @@ void doModalDialog(void)
|
||||||
enableTimer = MAX(enableTimer - 1, 0);
|
enableTimer = MAX(enableTimer - 1, 0);
|
||||||
if (!enableTimer)
|
if (!enableTimer)
|
||||||
{
|
{
|
||||||
ok->enabled = okCancelOK = okCancelCancel = 1;
|
ok->enabled = okCancelOK->enabled = okCancelCancel->enabled = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,12 @@ static void changeSoundVolume(char *value);
|
||||||
static void changeMusicVolume(char *value);
|
static void changeMusicVolume(char *value);
|
||||||
static void changeFullscreen(char *value);
|
static void changeFullscreen(char *value);
|
||||||
static void ok(void);
|
static void ok(void);
|
||||||
|
static void controlsOK(void);
|
||||||
|
static void drawMain(void);
|
||||||
|
static void controls(void);
|
||||||
|
|
||||||
static void (*returnFromOptions)(void);
|
static void (*returnFromOptions)(void);
|
||||||
|
static int show;
|
||||||
|
|
||||||
void initOptions(void (*rtn)(void))
|
void initOptions(void (*rtn)(void))
|
||||||
{
|
{
|
||||||
|
@ -38,7 +42,9 @@ void initOptions(void (*rtn)(void))
|
||||||
getWidget("soundVolume", "options")->onChange = changeSoundVolume;
|
getWidget("soundVolume", "options")->onChange = changeSoundVolume;
|
||||||
getWidget("musicVolume", "options")->onChange = changeMusicVolume;
|
getWidget("musicVolume", "options")->onChange = changeMusicVolume;
|
||||||
getWidget("fullscreen", "options")->onChange = changeFullscreen;
|
getWidget("fullscreen", "options")->onChange = changeFullscreen;
|
||||||
|
getWidget("controls", "options")->action = controls;
|
||||||
getWidget("ok", "options")->action = ok;
|
getWidget("ok", "options")->action = ok;
|
||||||
|
getWidget("ok", "controls")->action = controlsOK;
|
||||||
|
|
||||||
sprintf(optionStr, "%d x %d", app.winWidth, app.winHeight);
|
sprintf(optionStr, "%d x %d", app.winWidth, app.winHeight);
|
||||||
setWidgetOption("windowSize", "options", optionStr);
|
setWidgetOption("windowSize", "options", optionStr);
|
||||||
|
@ -57,9 +63,25 @@ void initOptions(void (*rtn)(void))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
returnFromOptions = rtn;
|
returnFromOptions = rtn;
|
||||||
|
|
||||||
|
show = SHOW_MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawOptions(void)
|
void drawOptions(void)
|
||||||
|
{
|
||||||
|
switch (show)
|
||||||
|
{
|
||||||
|
case SHOW_MAIN:
|
||||||
|
drawMain();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHOW_CONTROLS:
|
||||||
|
drawControls();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawMain(void)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
|
@ -95,6 +117,13 @@ void drawOptions(void)
|
||||||
limitTextWidth(0);
|
limitTextWidth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void controls(void)
|
||||||
|
{
|
||||||
|
initControlsDisplay();
|
||||||
|
|
||||||
|
show = SHOW_CONTROLS;
|
||||||
|
}
|
||||||
|
|
||||||
static void changeWindowSize(char *value)
|
static void changeWindowSize(char *value)
|
||||||
{
|
{
|
||||||
sscanf(value, "%d x %d", &app.winWidth, &app.winHeight);
|
sscanf(value, "%d x %d", &app.winWidth, &app.winHeight);
|
||||||
|
@ -125,3 +154,8 @@ static void ok(void)
|
||||||
|
|
||||||
returnFromOptions();
|
returnFromOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void controlsOK(void)
|
||||||
|
{
|
||||||
|
show = SHOW_MAIN;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "SDL2/SDL_mixer.h"
|
#include "SDL2/SDL_mixer.h"
|
||||||
|
|
||||||
|
#define SHOW_MAIN 0
|
||||||
|
#define SHOW_CONTROLS 1
|
||||||
|
|
||||||
extern void selectWidget(const char *name, const char *group);
|
extern void selectWidget(const char *name, const char *group);
|
||||||
extern Widget *getWidget(const char *name, const char *group);
|
extern Widget *getWidget(const char *name, const char *group);
|
||||||
extern void drawWidgets(char *groupName);
|
extern void drawWidgets(char *groupName);
|
||||||
|
@ -30,6 +33,8 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
|
||||||
extern void saveConfig(void);
|
extern void saveConfig(void);
|
||||||
extern void limitTextWidth(int width);
|
extern void limitTextWidth(int width);
|
||||||
extern char *getTranslatedString(char *string);
|
extern char *getTranslatedString(char *string);
|
||||||
|
extern void drawControls(void);
|
||||||
|
extern void initControlsDisplay(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void initResources(void)
|
||||||
backgrounds[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
backgrounds[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||||
sprintf(backgrounds[i], "gfx/backgrounds/%s", filenames[i]);
|
sprintf(backgrounds[i], "gfx/backgrounds/%s", filenames[i]);
|
||||||
|
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "'%s' added to AUTO resources list", filenames[i]);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
||||||
|
|
||||||
free(filenames[i]);
|
free(filenames[i]);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void initResources(void)
|
||||||
planets[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
planets[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||||
sprintf(planets[i], "gfx/planets/%s", filenames[i]);
|
sprintf(planets[i], "gfx/planets/%s", filenames[i]);
|
||||||
|
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "'%s' added to AUTO resources list", filenames[i]);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
||||||
|
|
||||||
free(filenames[i]);
|
free(filenames[i]);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ void initResources(void)
|
||||||
musicFiles[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
musicFiles[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||||
sprintf(musicFiles[i], "music/battle/%s", filenames[i]);
|
sprintf(musicFiles[i], "music/battle/%s", filenames[i]);
|
||||||
|
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "'%s' added to AUTO resources list", filenames[i]);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
||||||
|
|
||||||
free(filenames[i]);
|
free(filenames[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
||||||
|
|
||||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||||
|
extern char *getFileLocation(char *filename);
|
||||||
|
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
|
|
|
@ -115,10 +115,17 @@ char *getJSONValueStr(cJSON *node, char *name, char *defValue)
|
||||||
|
|
||||||
int getJSONValue(cJSON *node, char *name, int defValue)
|
int getJSONValue(cJSON *node, char *name, int defValue)
|
||||||
{
|
{
|
||||||
char *result = getJSONValueStr(node, name, defValue);
|
cJSON *child;
|
||||||
|
|
||||||
if (result)
|
if (node)
|
||||||
{
|
{
|
||||||
return aoti(result);
|
child = cJSON_GetObjectItem(node, name);
|
||||||
|
|
||||||
|
if (child)
|
||||||
|
{
|
||||||
|
return child->valueint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
|
@ -19,3 +19,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
#include "../json/cJSON.h"
|
||||||
|
|
|
@ -146,6 +146,18 @@ void drawWidgets(const char *group)
|
||||||
drawText(w->rect.x + 10, w->rect.y + 2, 20, TA_LEFT, colors.white, w->text);
|
drawText(w->rect.x + 10, w->rect.y + 2, 20, TA_LEFT, colors.white, w->text);
|
||||||
drawText(w->rect.x + w->rect.w - 10, w->rect.y + 2, 20, TA_RIGHT, colors.white, w->options[w->currentOption]);
|
drawText(w->rect.x + w->rect.w - 10, w->rect.y + 2, 20, TA_RIGHT, colors.white, w->options[w->currentOption]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WT_KEY_CONFIG:
|
||||||
|
SDL_RenderDrawRect(app.renderer, &w->rect);
|
||||||
|
drawText(w->rect.x + 25, w->rect.y + 2, 20, TA_LEFT, colors.white, w->text);
|
||||||
|
drawText(w->rect.x + w->rect.w - 25, w->rect.y + 2, 20, TA_RIGHT, colors.white, "%d", w->value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WT_MOUSE_CONFIG:
|
||||||
|
SDL_RenderDrawRect(app.renderer, &w->rect);
|
||||||
|
drawText(w->rect.x + 25, w->rect.y + 2, 20, TA_LEFT, colors.white, w->text);
|
||||||
|
drawText(w->rect.x + w->rect.w - 25, w->rect.y + 2, 20, TA_RIGHT, colors.white, "%d", w->value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!w->enabled)
|
if (!w->enabled)
|
||||||
|
@ -322,6 +334,18 @@ static void loadWidgetSet(char *filename)
|
||||||
createSelectButtons(w);
|
createSelectButtons(w);
|
||||||
createOptions(w, cJSON_GetObjectItem(node, "options")->valuestring);
|
createOptions(w, cJSON_GetObjectItem(node, "options")->valuestring);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WT_KEY_CONFIG:
|
||||||
|
case WT_MOUSE_CONFIG:
|
||||||
|
STRNCPY(w->text, _(cJSON_GetObjectItem(node, "text")->valuestring), MAX_NAME_LENGTH);
|
||||||
|
w->rect.w = cJSON_GetObjectItem(node, "w")->valueint;
|
||||||
|
w->rect.h = cJSON_GetObjectItem(node, "h")->valueint;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("Widget type %d not handled\n", w->type);
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tail->next = w;
|
tail->next = w;
|
||||||
|
|
Loading…
Reference in New Issue