Merged config branch.
This commit is contained in:
parent
b136a6bb6c
commit
b6012a2e21
|
@ -10,7 +10,7 @@ DEPS += defs.h structs.h
|
||||||
|
|
||||||
OBJS += ai.o
|
OBJS += ai.o
|
||||||
OBJS += battle.o bullets.o
|
OBJS += battle.o bullets.o
|
||||||
OBJS += capitalShips.o challengeHome.o challenges.o cJSON.o
|
OBJS += capitalShips.o challengeHome.o challenges.o cJSON.o controls.o
|
||||||
OBJS += debris.o dev.o draw.o
|
OBJS += debris.o dev.o draw.o
|
||||||
OBJS += effects.o entities.o extractionPoint.o
|
OBJS += effects.o entities.o extractionPoint.o
|
||||||
OBJS += fighters.o
|
OBJS += fighters.o
|
||||||
|
@ -24,7 +24,7 @@ OBJS += player.o
|
||||||
OBJS += quadtree.o
|
OBJS += quadtree.o
|
||||||
OBJS += radar.o resources.o rope.o
|
OBJS += radar.o resources.o rope.o
|
||||||
OBJS += save.o script.o sound.o starfield.o starSystems.o stats.o
|
OBJS += save.o script.o sound.o starfield.o starSystems.o stats.o
|
||||||
OBJS += testMission.o textures.o text.o title.o transition.o
|
OBJS += testMission.o textures.o text.o title.o transition.o trophies.o
|
||||||
OBJS += util.o
|
OBJS += util.o
|
||||||
OBJS += waypoints.o widgets.o
|
OBJS += waypoints.o widgets.o
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,29 @@
|
||||||
{
|
{
|
||||||
"winWidth" : 1280,
|
"winWidth" : 1280,
|
||||||
"winHeight" : 720,
|
"winHeight" : 720,
|
||||||
"vSync" : 1,
|
|
||||||
"fullscreen" : 0,
|
"fullscreen" : 0,
|
||||||
"musicVolume" : 8,
|
"musicVolume" : 8,
|
||||||
"soundVolume" : 10
|
"soundVolume" : 10,
|
||||||
|
"controls" : {
|
||||||
|
"keys": {
|
||||||
|
"CONTROL_BOOST" : 26,
|
||||||
|
"CONTROL_ECM" : 7,
|
||||||
|
"CONTROL_BRAKE" : 22,
|
||||||
|
"CONTROL_TARGET" : 4,
|
||||||
|
"CONTROL_MISSILE" : 44,
|
||||||
|
"CONTROL_GUNS" : 29,
|
||||||
|
"CONTROL_RADAR" : 27,
|
||||||
|
"CONTROL_NEXT_FIGHTER": 7,
|
||||||
|
"CONTROL_PREV_FIGHTER": 4
|
||||||
|
},
|
||||||
|
"mouse" : {
|
||||||
|
"CONTROL_BOOST" : -1,
|
||||||
|
"CONTROL_ECM" : -1,
|
||||||
|
"CONTROL_BRAKE" : -1,
|
||||||
|
"CONTROL_TARGET" : -1,
|
||||||
|
"CONTROL_MISSILE" : -1,
|
||||||
|
"CONTROL_GUNS" : -1,
|
||||||
|
"CONTROL_RADAR" : -1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id" : "READY_DUTY",
|
||||||
|
"title" : "Ready for duty",
|
||||||
|
"description" : "Complete all the training missions at Sol",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "EPIC",
|
||||||
|
"title" : "Truly epic",
|
||||||
|
"description" : "Survive an epic battle",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "BIGGER_FALL",
|
||||||
|
"title" : "The bigger they are",
|
||||||
|
"description" : "Destroy an enemy capital ship",
|
||||||
|
"value" : "TROPHY_SILVER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "CAMPAIGN_COYOTE",
|
||||||
|
"title" : "Coyote Ugly",
|
||||||
|
"description" : "Complete all missions at Coyote",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "PANDORAN_FIRST",
|
||||||
|
"title" : "Plenty more where that came from",
|
||||||
|
"description" : "Engage the Pandorans in battle",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "ATAF_FIRST",
|
||||||
|
"title" : "Man, I gotta get me one of these!",
|
||||||
|
"description" : "Pilot an ATAF during the campaign",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "CHALLENGE_25",
|
||||||
|
"title" : "",
|
||||||
|
"description" : "Complete 25% of all challenges",
|
||||||
|
"value" : "TROPHY_BRONZE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "CHALLENGE_50",
|
||||||
|
"title" : "",
|
||||||
|
"description" : "Complete 50% of all challenges",
|
||||||
|
"value" : "TROPHY_SILVER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "CHALLENGE_100",
|
||||||
|
"title" : "",
|
||||||
|
"description" : "Complete 100% of all challenges",
|
||||||
|
"value" : "TROPHY_GOLD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "FIRE_10000",
|
||||||
|
"title" : "Your name's on one of these!",
|
||||||
|
"description" : "Fire 10,000 shots",
|
||||||
|
"value" : "TROPHY_SILVER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "MISSILE_1000",
|
||||||
|
"title" : "Dodge this!",
|
||||||
|
"description" : "Launch 1,000 missiles",
|
||||||
|
"value" : "TROPHY_SILVER"
|
||||||
|
}
|
||||||
|
]
|
|
@ -43,6 +43,16 @@
|
||||||
"w" : 400,
|
"w" : 400,
|
||||||
"h": 34
|
"h": 34
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name" : "controls",
|
||||||
|
"group" : "options",
|
||||||
|
"type" : "WT_BUTTON",
|
||||||
|
"text" : "Controls ...",
|
||||||
|
"x" : -1,
|
||||||
|
"y" : 475,
|
||||||
|
"w" : 400,
|
||||||
|
"h": 34
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name" : "ok",
|
"name" : "ok",
|
||||||
"group" : "options",
|
"group" : "options",
|
||||||
|
|
|
@ -9,7 +9,7 @@ OBJS += unixInit.o
|
||||||
|
|
||||||
include common.mk
|
include common.mk
|
||||||
|
|
||||||
CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\"
|
CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\" -DFIXED_RESOLUTION=1
|
||||||
CXXFLAGS += -ansi -Wstrict-prototypes
|
CXXFLAGS += -ansi -Wstrict-prototypes
|
||||||
CXXFLAGS += -g -lefence -flto -flto-odr-type-merging
|
CXXFLAGS += -g -lefence -flto -flto-odr-type-merging
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ static void handleKeyboard(void)
|
||||||
{
|
{
|
||||||
if (battle.status == MS_IN_PROGRESS)
|
if (battle.status == MS_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
if (app.keyboard[SDL_SCANCODE_W])
|
if (isKeyControl(CONTROL_BOOST))
|
||||||
{
|
{
|
||||||
if (battle.boostTimer == BOOST_RECHARGE_TIME)
|
if (battle.boostTimer == BOOST_RECHARGE_TIME)
|
||||||
{
|
{
|
||||||
|
@ -186,17 +186,17 @@ static void handleKeyboard(void)
|
||||||
playSound(SND_GUI_DENIED);
|
playSound(SND_GUI_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_W] = 0;
|
clearControl(CONTROL_BOOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_A])
|
if (isKeyControl(CONTROL_TARGET))
|
||||||
{
|
{
|
||||||
selectTarget();
|
selectTarget();
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_A] = 0;
|
clearControl(CONTROL_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_D])
|
if (isKeyControl(CONTROL_ECM))
|
||||||
{
|
{
|
||||||
if (battle.ecmTimer == ECM_RECHARGE_TIME)
|
if (battle.ecmTimer == ECM_RECHARGE_TIME)
|
||||||
{
|
{
|
||||||
|
@ -209,33 +209,33 @@ static void handleKeyboard(void)
|
||||||
playSound(SND_GUI_DENIED);
|
playSound(SND_GUI_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_D] = 0;
|
clearControl(CONTROL_ECM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_S])
|
if (isKeyControl(CONTROL_BRAKE))
|
||||||
{
|
{
|
||||||
applyFighterBrakes();
|
applyFighterBrakes();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_Z])
|
if (isKeyControl(CONTROL_GUNS))
|
||||||
{
|
{
|
||||||
switchGuns();
|
switchGuns();
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_Z] = 0;
|
clearControl(CONTROL_GUNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_X])
|
if (isKeyControl(CONTROL_RADAR))
|
||||||
{
|
{
|
||||||
cycleRadarZoom();
|
cycleRadarZoom();
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_X] = 0;
|
clearControl(CONTROL_RADAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_SPACE])
|
if (isKeyControl(CONTROL_MISSILE))
|
||||||
{
|
{
|
||||||
preFireMissile();
|
preFireMissile();
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_SPACE] = 0;
|
clearControl(CONTROL_MISSILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,6 +37,9 @@ extern float getAngle(int x1, int y1, int x2, int y2);
|
||||||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||||
extern char *getTranslatedString(char *string);
|
extern char *getTranslatedString(char *string);
|
||||||
extern void addECMEffect(Entity *ent);
|
extern void addECMEffect(Entity *ent);
|
||||||
|
extern int isKeyControl(int type);
|
||||||
|
extern int isMouseControl(int type);
|
||||||
|
extern void clearControl(int type);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
|
22
src/defs.h
22
src/defs.h
|
@ -26,6 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define DATA_DIR ""
|
#define DATA_DIR ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FIXED_RESOLUTION
|
||||||
|
#define FIXED_RESOLUTION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _(string) getTranslatedString(string)
|
#define _(string) getTranslatedString(string)
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
#define PI 3.14159265358979323846
|
||||||
|
@ -39,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define SCREEN_HEIGHT 720
|
#define SCREEN_HEIGHT 720
|
||||||
|
|
||||||
#define MAX_KEYBOARD_KEYS 350
|
#define MAX_KEYBOARD_KEYS 350
|
||||||
#define MAX_MOUSE_BUTTONS 8
|
#define MAX_MOUSE_BUTTONS 5
|
||||||
|
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
#define LOGIC_RATE (1000 / FPS)
|
#define LOGIC_RATE (1000 / FPS)
|
||||||
|
@ -113,6 +117,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define BOOST_FINISHED_TIME (FPS * 0.75)
|
#define BOOST_FINISHED_TIME (FPS * 0.75)
|
||||||
#define ECM_RECHARGE_TIME (FPS * 7)
|
#define ECM_RECHARGE_TIME (FPS * 7)
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CONTROL_FIRE,
|
||||||
|
CONTROL_ACCELERATE,
|
||||||
|
CONTROL_BOOST,
|
||||||
|
CONTROL_ECM,
|
||||||
|
CONTROL_BRAKE,
|
||||||
|
CONTROL_TARGET,
|
||||||
|
CONTROL_MISSILE,
|
||||||
|
CONTROL_GUNS,
|
||||||
|
CONTROL_RADAR,
|
||||||
|
CONTROL_NEXT_FIGHTER,
|
||||||
|
CONTROL_PREV_FIGHTER,
|
||||||
|
CONTROL_MAX
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MD_NONE,
|
MD_NONE,
|
||||||
|
|
|
@ -19,11 +19,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
#include "../json/cJSON.h"
|
|
||||||
|
|
||||||
extern long lookup(char *name);
|
extern long lookup(char *name);
|
||||||
extern char *readFile(char *filename);
|
extern char *readFile(char *filename);
|
||||||
extern SDL_Texture *getTexture(char *filename);
|
extern SDL_Texture *getTexture(char *filename);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015-2016 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "controls.h"
|
||||||
|
|
||||||
|
int isKeyControl(int type)
|
||||||
|
{
|
||||||
|
return app.keyboard[app.keyControls[type]];
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearControl(int type)
|
||||||
|
{
|
||||||
|
app.keyboard[app.keyControls[type]] = 0;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015-2016 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
extern App app;
|
||||||
|
extern Game game;
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015-2016 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "trophies.h"
|
||||||
|
|
||||||
|
static int recentlyAwarded;
|
||||||
|
static void loadTrophyData(char *filename);
|
||||||
|
|
||||||
|
void initTrophies(void)
|
||||||
|
{
|
||||||
|
recentlyAwarded = 0;
|
||||||
|
|
||||||
|
loadTrophyData("data/trophies/trophies.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
void awardTrophy(char *id)
|
||||||
|
{
|
||||||
|
Trophy *t;
|
||||||
|
|
||||||
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||||
|
{
|
||||||
|
if (!t->awarded && strcmp(t->id, id) == 0)
|
||||||
|
{
|
||||||
|
t->awarded = 1;
|
||||||
|
t->awardDate = time(NULL);
|
||||||
|
t->notify = 1;
|
||||||
|
|
||||||
|
recentlyAwarded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawTrophyAlerts(void)
|
||||||
|
{
|
||||||
|
Trophy *t;
|
||||||
|
|
||||||
|
if (recentlyAwarded)
|
||||||
|
{
|
||||||
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||||
|
{
|
||||||
|
if (t->notify)
|
||||||
|
{
|
||||||
|
/* handle notification */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawTrophies(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Trophy *getTrophy(char *id)
|
||||||
|
{
|
||||||
|
Trophy *t;
|
||||||
|
|
||||||
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||||
|
{
|
||||||
|
if (strcmp(t->id, id) == 0)
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadTrophyData(char *filename)
|
||||||
|
{
|
||||||
|
cJSON *root, *node;
|
||||||
|
char *text;
|
||||||
|
Trophy *t, *tail;
|
||||||
|
|
||||||
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||||
|
|
||||||
|
text = readFile(getFileLocation(filename));
|
||||||
|
root = cJSON_Parse(text);
|
||||||
|
|
||||||
|
tail = &game.trophyHead;
|
||||||
|
|
||||||
|
for (node = root->child ; node != NULL ; node = node->next)
|
||||||
|
{
|
||||||
|
t = malloc(sizeof(Trophy));
|
||||||
|
memset(t, 0, sizeof(Trophy));
|
||||||
|
|
||||||
|
STRNCPY(t->id, cJSON_GetObjectItem(node, "id")->valuestring, MAX_NAME_LENGTH);
|
||||||
|
STRNCPY(t->title, cJSON_GetObjectItem(node, "title")->valuestring, MAX_DESCRIPTION_LENGTH);
|
||||||
|
STRNCPY(t->description, cJSON_GetObjectItem(node, "description")->valuestring, MAX_DESCRIPTION_LENGTH);
|
||||||
|
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
||||||
|
|
||||||
|
tail->next = t;
|
||||||
|
tail = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON_Delete(root);
|
||||||
|
free(text);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015-2016 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
extern char *getFileLocation(char *filename);
|
||||||
|
extern long lookup(char *name);
|
||||||
|
extern char *readFile(char *filename);
|
||||||
|
|
||||||
|
extern Game game;
|
|
@ -39,6 +39,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
init18N(argc, argv);
|
init18N(argc, argv);
|
||||||
|
|
||||||
|
initLookups();
|
||||||
|
|
||||||
initSDL();
|
initSDL();
|
||||||
|
|
||||||
initGameSystem();
|
initGameSystem();
|
||||||
|
|
|
@ -44,6 +44,8 @@ extern void loadGame(void);
|
||||||
extern int fileExists(char *filename);
|
extern int fileExists(char *filename);
|
||||||
extern char *getSaveFilePath(char *filename);
|
extern char *getSaveFilePath(char *filename);
|
||||||
extern void init18N(int argc, char *argv[]);
|
extern void init18N(int argc, char *argv[]);
|
||||||
|
extern void initLookups(void);
|
||||||
|
extern void initGame(void);
|
||||||
|
|
||||||
App app;
|
App app;
|
||||||
Colors colors;
|
Colors colors;
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef struct GridCell GridCell;
|
||||||
typedef struct ScriptRunner ScriptRunner;
|
typedef struct ScriptRunner ScriptRunner;
|
||||||
typedef struct Location Location;
|
typedef struct Location Location;
|
||||||
typedef struct Bucket Bucket;
|
typedef struct Bucket Bucket;
|
||||||
|
typedef struct Trophy Trophy;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int debug;
|
int debug;
|
||||||
|
@ -261,6 +262,7 @@ struct Mission {
|
||||||
char pilot[MAX_NAME_LENGTH];
|
char pilot[MAX_NAME_LENGTH];
|
||||||
char squadron[MAX_NAME_LENGTH];
|
char squadron[MAX_NAME_LENGTH];
|
||||||
char craft[MAX_NAME_LENGTH];
|
char craft[MAX_NAME_LENGTH];
|
||||||
|
char trophyId[MAX_NAME_LENGTH];
|
||||||
int available;
|
int available;
|
||||||
int completed;
|
int completed;
|
||||||
int completedChallenges;
|
int completedChallenges;
|
||||||
|
@ -336,6 +338,17 @@ struct ScriptRunner {
|
||||||
ScriptRunner *next;
|
ScriptRunner *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Trophy {
|
||||||
|
char id[MAX_NAME_LENGTH];
|
||||||
|
char title[MAX_DESCRIPTION_LENGTH];
|
||||||
|
char description[MAX_DESCRIPTION_LENGTH];
|
||||||
|
int value;
|
||||||
|
int awarded;
|
||||||
|
unsigned long awardDate;
|
||||||
|
int notify;
|
||||||
|
Trophy *next;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
StarSystem starSystemHead;
|
StarSystem starSystemHead;
|
||||||
Mission challengeMissionHead;
|
Mission challengeMissionHead;
|
||||||
|
@ -345,6 +358,7 @@ typedef struct {
|
||||||
int availableMissions;
|
int availableMissions;
|
||||||
int totalMissions;
|
int totalMissions;
|
||||||
unsigned int stats[STAT_MAX];
|
unsigned int stats[STAT_MAX];
|
||||||
|
Trophy trophyHead;
|
||||||
} Game;
|
} Game;
|
||||||
|
|
||||||
struct Widget {
|
struct Widget {
|
||||||
|
@ -408,6 +422,8 @@ typedef struct {
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
Delegate delegate;
|
Delegate delegate;
|
||||||
ModalDialog modalDialog;
|
ModalDialog modalDialog;
|
||||||
|
int keyControls[CONTROL_MAX];
|
||||||
|
int mouseControls[CONTROL_MAX];
|
||||||
} App;
|
} App;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -120,7 +120,6 @@ void initGameSystem(void)
|
||||||
void (*initFuncs[]) (void) = {
|
void (*initFuncs[]) (void) = {
|
||||||
initFonts,
|
initFonts,
|
||||||
initInput,
|
initInput,
|
||||||
initLookups,
|
|
||||||
initResources,
|
initResources,
|
||||||
initSounds,
|
initSounds,
|
||||||
initWidgets,
|
initWidgets,
|
||||||
|
@ -202,7 +201,8 @@ static void initColor(SDL_Color *c, int r, int g, int b)
|
||||||
|
|
||||||
static void loadConfig(void)
|
static void loadConfig(void)
|
||||||
{
|
{
|
||||||
cJSON *root;
|
int i;
|
||||||
|
cJSON *root, *controlsJSON, *node;
|
||||||
char *text, *configFilename;
|
char *text, *configFilename;
|
||||||
|
|
||||||
configFilename = getSaveFilePath("config.json");
|
configFilename = getSaveFilePath("config.json");
|
||||||
|
@ -224,6 +224,30 @@ static void loadConfig(void)
|
||||||
app.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint;
|
app.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint;
|
||||||
app.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint;
|
app.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint;
|
||||||
|
|
||||||
|
controlsJSON = cJSON_GetObjectItem(root, "controls");
|
||||||
|
if (controlsJSON)
|
||||||
|
{
|
||||||
|
node = cJSON_GetObjectItem(controlsJSON, "keys")->child;
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
i = lookup(node->string);
|
||||||
|
|
||||||
|
app.keyControls[i] = node->valueint;
|
||||||
|
|
||||||
|
node = node->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = cJSON_GetObjectItem(controlsJSON, "mouse")->child;
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
i = lookup(node->string);
|
||||||
|
|
||||||
|
app.mouseControls[i] = node->valueint;
|
||||||
|
|
||||||
|
node = node->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
free(text);
|
free(text);
|
||||||
|
|
||||||
|
@ -233,8 +257,9 @@ static void loadConfig(void)
|
||||||
|
|
||||||
void saveConfig(void)
|
void saveConfig(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
char *out, *configFilename;
|
char *out, *configFilename;
|
||||||
cJSON *root;
|
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON;
|
||||||
|
|
||||||
configFilename = getSaveFilePath("config.json");
|
configFilename = getSaveFilePath("config.json");
|
||||||
|
|
||||||
|
@ -247,11 +272,29 @@ void saveConfig(void)
|
||||||
cJSON_AddNumberToObject(root, "musicVolume", app.musicVolume);
|
cJSON_AddNumberToObject(root, "musicVolume", app.musicVolume);
|
||||||
cJSON_AddNumberToObject(root, "soundVolume", app.soundVolume);
|
cJSON_AddNumberToObject(root, "soundVolume", app.soundVolume);
|
||||||
|
|
||||||
|
keysJSON = cJSON_CreateObject();
|
||||||
|
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||||
|
{
|
||||||
|
cJSON_AddNumberToObject(keysJSON, getLookupName("CONTROL_", i), app.keyControls[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
mouseJSON = cJSON_CreateObject();
|
||||||
|
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||||
|
{
|
||||||
|
cJSON_AddNumberToObject(mouseJSON, getLookupName("CONTROL_", i), app.mouseControls[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
controlsJSON = cJSON_CreateObject();
|
||||||
|
cJSON_AddItemToObject(controlsJSON, "keys", keysJSON);
|
||||||
|
cJSON_AddItemToObject(controlsJSON, "mouse", mouseJSON);
|
||||||
|
|
||||||
|
cJSON_AddItemToObject(root, "controls", controlsJSON);
|
||||||
|
|
||||||
out = cJSON_Print(root);
|
out = cJSON_Print(root);
|
||||||
|
|
||||||
if (!writeFile(configFilename, out))
|
if (!writeFile(configFilename, out))
|
||||||
{
|
{
|
||||||
printf("Failed to save config\n");
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Failed to save config");
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
|
|
|
@ -40,7 +40,6 @@ extern void loadCapitalShipDefs(void);
|
||||||
extern void loadItemDefs(void);
|
extern void loadItemDefs(void);
|
||||||
extern void initFonts(void);
|
extern void initFonts(void);
|
||||||
extern void initBulletDefs(void);
|
extern void initBulletDefs(void);
|
||||||
extern void initLookups(void);
|
|
||||||
extern void initBattle(void);
|
extern void initBattle(void);
|
||||||
extern void initGame(void);
|
extern void initGame(void);
|
||||||
extern void initStats(void);
|
extern void initStats(void);
|
||||||
|
@ -69,6 +68,9 @@ extern void initModalDialog(void);
|
||||||
extern void createSaveFolder(void);
|
extern void createSaveFolder(void);
|
||||||
extern char *getFileLocation(char *filename);
|
extern char *getFileLocation(char *filename);
|
||||||
extern void setLanguage(char *applicationName, char *languageCode);
|
extern void setLanguage(char *applicationName, char *languageCode);
|
||||||
|
extern char *getLookupName(char *prefix, long num);
|
||||||
|
extern long lookup(char *name);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
extern Game game;
|
||||||
|
|
|
@ -32,15 +32,24 @@ void initInput(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void doMouseDown(SDL_MouseButtonEvent *event)
|
void doMouseDown(SDL_MouseButtonEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button >= 0 && event->button < MAX_MOUSE_BUTTONS)
|
||||||
{
|
{
|
||||||
app.mouse.button[event->button] = 1;
|
app.mouse.button[event->button] = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void doMouseUp(SDL_MouseButtonEvent *event)
|
void doMouseUp(SDL_MouseButtonEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button >= 0 && event->button < MAX_MOUSE_BUTTONS)
|
||||||
{
|
{
|
||||||
app.mouse.button[event->button] = 0;
|
app.mouse.button[event->button] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: the following assumes that SDL_BUTTON_X1 and SDL_BUTTON_X2 are 4 and 5, respectively. They usually are.
|
||||||
|
*/
|
||||||
void doMouseWheel(SDL_MouseWheelEvent *event)
|
void doMouseWheel(SDL_MouseWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (event->y == -1)
|
if (event->y == -1)
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "load.h"
|
#include "load.h"
|
||||||
|
|
||||||
static void loadStats(cJSON *stats);
|
static void loadStats(cJSON *statsJSON);
|
||||||
static void loadStarSystems(cJSON *starSystemsJSON);
|
static void loadStarSystems(cJSON *starSystemsJSON);
|
||||||
static void loadMissions(cJSON *missionsCJSON);
|
static void loadMissions(cJSON *missionsCJSON);
|
||||||
static void loadChallenges(cJSON *challengesCJSON);
|
static void loadChallenges(cJSON *challengesCJSON);
|
||||||
|
@ -103,7 +103,7 @@ static void loadChallenges(cJSON *missionsJSON)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadStats(cJSON *stats)
|
static void loadStats(cJSON *statsJSON)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *statName;
|
char *statName;
|
||||||
|
@ -112,9 +112,9 @@ static void loadStats(cJSON *stats)
|
||||||
{
|
{
|
||||||
statName = getLookupName("STAT_", i);
|
statName = getLookupName("STAT_", i);
|
||||||
|
|
||||||
if (statName && cJSON_GetObjectItem(stats, statName))
|
if (statName && cJSON_GetObjectItem(statsJSON, statName))
|
||||||
{
|
{
|
||||||
game.stats[i] = cJSON_GetObjectItem(stats, statName)->valueint;
|
game.stats[i] = cJSON_GetObjectItem(statsJSON, statName)->valueint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,18 @@ void initLookups(void)
|
||||||
memset(&head, 0, sizeof(Lookup));
|
memset(&head, 0, sizeof(Lookup));
|
||||||
tail = &head;
|
tail = &head;
|
||||||
|
|
||||||
|
addLookup("CONTROL_FIRE", CONTROL_FIRE);
|
||||||
|
addLookup("CONTROL_ACCELERATE", CONTROL_ACCELERATE);
|
||||||
|
addLookup("CONTROL_BOOST", CONTROL_BOOST);
|
||||||
|
addLookup("CONTROL_ECM", CONTROL_ECM);
|
||||||
|
addLookup("CONTROL_BRAKE", CONTROL_BRAKE);
|
||||||
|
addLookup("CONTROL_TARGET", CONTROL_TARGET);
|
||||||
|
addLookup("CONTROL_MISSILE", CONTROL_MISSILE);
|
||||||
|
addLookup("CONTROL_GUNS", CONTROL_GUNS);
|
||||||
|
addLookup("CONTROL_RADAR", CONTROL_RADAR);
|
||||||
|
addLookup("CONTROL_NEXT_FIGHTER", CONTROL_NEXT_FIGHTER);
|
||||||
|
addLookup("CONTROL_PREV_FIGHTER", CONTROL_PREV_FIGHTER);
|
||||||
|
|
||||||
addLookup("ET_WAYPOINT", ET_WAYPOINT);
|
addLookup("ET_WAYPOINT", ET_WAYPOINT);
|
||||||
addLookup("ET_EXTRACTION_POINT", ET_EXTRACTION_POINT);
|
addLookup("ET_EXTRACTION_POINT", ET_EXTRACTION_POINT);
|
||||||
addLookup("ET_CAPITAL_SHIP", ET_CAPITAL_SHIP);
|
addLookup("ET_CAPITAL_SHIP", ET_CAPITAL_SHIP);
|
||||||
|
|
|
@ -51,6 +51,11 @@ void initOptions(void (*rtn)(void))
|
||||||
|
|
||||||
setWidgetOption("fullscreen", "options", app.fullscreen ? "On" : "Off");
|
setWidgetOption("fullscreen", "options", app.fullscreen ? "On" : "Off");
|
||||||
|
|
||||||
|
#if FIXED_RESOLUTION
|
||||||
|
getWidget("windowSize", "options")->enabled = 0;
|
||||||
|
getWidget("fullscreen", "options")->enabled = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
returnFromOptions = rtn;
|
returnFromOptions = rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +86,12 @@ void drawOptions(void)
|
||||||
drawWidgets("options");
|
drawWidgets("options");
|
||||||
|
|
||||||
limitTextWidth(r.w - 100);
|
limitTextWidth(r.w - 100);
|
||||||
|
#if !FIXED_RESOLUTION
|
||||||
drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, _("Note: you must restart the game for window size and fullscreen options to take effect."));
|
drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, _("Note: you must restart the game for window size and fullscreen options to take effect."));
|
||||||
|
#else
|
||||||
|
drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, _("Note: this device does not support changing the screen resolution."));
|
||||||
|
#endif
|
||||||
|
|
||||||
limitTextWidth(0);
|
limitTextWidth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue