Dedicated autosave slot + much improved menu code.
I found it kind of odd to be able to manually save to the autosave slot, *and* have no reliable way to even know what the autosave slot is. I noticed that it's an actual problem when my brothers played Starfighter; one of them used an autosave slot, and the other unwittingly ended up erasing the first one's save because of this. To fix this, I have replaced the behavior of allowing the player to define a slot as autosave, with a dedicated autosave slot. While I was there, I had no choice but to vastly improve on this game's *atrocious* menu system. Granted, I didn't do much more than replace the magic numbers with enums, but it makes the code much more clear and more easy to edit.
This commit is contained in:
parent
39254f42bb
commit
1f2ef8ac50
41
src/defs.h
41
src/defs.h
|
@ -85,7 +85,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define MAX_SHIPSHAPES 120
|
#define MAX_SHIPSHAPES 120
|
||||||
#define MAX_SOUNDS 17
|
#define MAX_SOUNDS 17
|
||||||
#define MAX_ALIENS 25
|
#define MAX_ALIENS 25
|
||||||
#define MAX_TEXTSHAPES 70
|
#define MAX_TEXTSHAPES 150
|
||||||
#define MAX_FONTSHAPES 6
|
#define MAX_FONTSHAPES 6
|
||||||
#define MAX_SHOPSHAPES 6
|
#define MAX_SHOPSHAPES 6
|
||||||
#define MAX_DEFALIENS 40
|
#define MAX_DEFALIENS 40
|
||||||
|
@ -246,6 +246,45 @@ enum {
|
||||||
CD_URSULA
|
CD_URSULA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Text shapes
|
||||||
|
enum {
|
||||||
|
|
||||||
|
TS_PRESENTS,
|
||||||
|
TS_AN_SDL_GAME,
|
||||||
|
TS_START_NEW_GAME,
|
||||||
|
TS_LOAD_GAME,
|
||||||
|
TS_CONTINUE_CURRENT_GAME,
|
||||||
|
TS_OPTIONS,
|
||||||
|
TS_CHEAT_OPTIONS,
|
||||||
|
TS_QUIT,
|
||||||
|
TS_SOUND,
|
||||||
|
TS_MUSIC,
|
||||||
|
TS_FULLSCREEN,
|
||||||
|
TS_BACK_TO_MAIN_MENU,
|
||||||
|
TS_SAVESLOT_0,
|
||||||
|
TS_SAVESLOT_1,
|
||||||
|
TS_SAVESLOT_2,
|
||||||
|
TS_SAVESLOT_3,
|
||||||
|
TS_SAVESLOT_4,
|
||||||
|
TS_SAVESLOT_5,
|
||||||
|
TS_UNLIMITED_SHIELD,
|
||||||
|
TS_UNLIMITED_AMMO,
|
||||||
|
TS_UNLIMITED_CASH,
|
||||||
|
TS_UNLIMITED_TIME,
|
||||||
|
TS_START_GAME,
|
||||||
|
TS_DIFFICULTY
|
||||||
|
};
|
||||||
|
|
||||||
|
// Menu types
|
||||||
|
enum {
|
||||||
|
|
||||||
|
MENU_MAIN,
|
||||||
|
MENU_DIFFICULTY,
|
||||||
|
MENU_LOAD,
|
||||||
|
MENU_OPTIONS,
|
||||||
|
MENU_CHEAT
|
||||||
|
};
|
||||||
|
|
||||||
// Font Colors
|
// Font Colors
|
||||||
enum {
|
enum {
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ void newGame()
|
||||||
engine.useMusic = false;
|
engine.useMusic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentGame.autoSaveSlot = -1;
|
|
||||||
|
|
||||||
currentGame.cash = 0;
|
currentGame.cash = 0;
|
||||||
currentGame.cashEarned = 0;
|
currentGame.cashEarned = 0;
|
||||||
currentGame.shots = 0;
|
currentGame.shots = 0;
|
||||||
|
@ -338,8 +336,7 @@ int mainGameLoop()
|
||||||
{
|
{
|
||||||
updateSystemStatus();
|
updateSystemStatus();
|
||||||
|
|
||||||
if (currentGame.autoSaveSlot > -1)
|
saveGame(0);
|
||||||
saveGame(currentGame.autoSaveSlot + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rtn = 1;
|
rtn = 1;
|
||||||
|
|
|
@ -389,21 +389,6 @@ static void createOptions(SDL_Surface *optionsSurface)
|
||||||
drawString("ON", 207, 150, FONT_WHITE, optionsSurface);
|
drawString("ON", 207, 150, FONT_WHITE, optionsSurface);
|
||||||
drawString("OFF", 263, 150, FONT_WHITE, optionsSurface);
|
drawString("OFF", 263, 150, FONT_WHITE, optionsSurface);
|
||||||
drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
|
drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
|
||||||
|
|
||||||
blevelRect(optionsSurface, 20, 195, 150, 22, 0x00, 0x00, 0x00);
|
|
||||||
blevelRect(optionsSurface, 190, 195, 110, 22, 0x00, 0x00, 0x00);
|
|
||||||
if (currentGame.autoSaveSlot == -1)
|
|
||||||
{
|
|
||||||
drawString("NONE", 225, 200, FONT_WHITE, optionsSurface);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char string[] = "Slot %d";
|
|
||||||
sprintf(string, "Slot %d", currentGame.autoSaveSlot + 1);
|
|
||||||
blevelRect(optionsSurface, 190, 195, 110, 22, 0xff, 0x00, 0x00);
|
|
||||||
drawString(string, 225, 200, FONT_WHITE, optionsSurface);
|
|
||||||
}
|
|
||||||
drawString("AUTOSAVE SLOT", 30, 200, FONT_WHITE, optionsSurface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showOptions(SDL_Surface *optionsSurface)
|
static void showOptions(SDL_Surface *optionsSurface)
|
||||||
|
@ -454,12 +439,6 @@ static void showOptions(SDL_Surface *optionsSurface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 322, 100, 22))
|
|
||||||
{
|
|
||||||
wrapChar(&(++currentGame.autoSaveSlot), -1, 4);
|
|
||||||
engine.keyState[KEY_FIRE] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
createOptions(optionsSurface);
|
createOptions(optionsSurface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,33 +40,45 @@ int initSaveSlots()
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
//READ SAVE GAME DATA
|
//READ SAVE GAME DATA
|
||||||
for (int i = 0 ; i < 5 ; i++)
|
for (int i = 0 ; i <= 5 ; i++)
|
||||||
{
|
{
|
||||||
sprintf(fileName, "%ssave%.2d.dat", engine.userHomeDirectory, (i + 1));
|
sprintf(fileName, "%ssave%.2d.dat", engine.userHomeDirectory, i);
|
||||||
|
|
||||||
fp = fopen(fileName, "rb");
|
fp = fopen(fileName, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
sprintf(saveSlot[i], "%.2d - Empty", (i + 1));
|
sprintf(saveSlot[i], (i == 0 ? "AUTOSAVE (Empty)" : "Empty"));
|
||||||
if (engine.gameSection == SECTION_TITLE)
|
if (engine.gameSection == SECTION_TITLE)
|
||||||
textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
|
textSurface(TS_SAVESLOT_0 + i, saveSlot[i], -1, imagePos,
|
||||||
|
FONT_WHITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
sprintf(saveSlot[i], "AUTOSAVE");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fread(&tempGame, sizeof(Game), 1, fp) != 1)
|
if (fread(&tempGame, sizeof(Game), 1, fp) != 1)
|
||||||
{
|
{
|
||||||
sprintf(saveSlot[i], "%.2d - Corrupt Game Data", (i + 1));
|
sprintf(saveSlot[i], "Corrupt Game Data");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(saveSlot[i], "%.2d - %s, %s", (i + 1), systemNames[tempGame.system], tempGame.stationedName);
|
sprintf(saveSlot[i], "%s, %s", systemNames[tempGame.system],
|
||||||
if (engine.gameSection == SECTION_TITLE)
|
tempGame.stationedName);
|
||||||
textSurface(13 + i, saveSlot[i], -1, imagePos, FONT_WHITE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engine.gameSection == SECTION_TITLE)
|
||||||
|
textSurface(TS_SAVESLOT_0 + i, saveSlot[i], -1,
|
||||||
|
imagePos, FONT_WHITE);
|
||||||
|
|
||||||
if (stat(fileName, &fileInfo) != -1)
|
if (stat(fileName, &fileInfo) != -1)
|
||||||
{
|
{
|
||||||
if (fileInfo.st_mtime > modTime)
|
if (fileInfo.st_mtime > modTime)
|
||||||
{modTime = fileInfo.st_mtime; continueSaveIndex = (i + 1);}
|
{modTime = fileInfo.st_mtime; continueSaveIndex = i;}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -118,9 +130,9 @@ bool loadGame(int slot)
|
||||||
|
|
||||||
void saveGame(int slot)
|
void saveGame(int slot)
|
||||||
{
|
{
|
||||||
if ((slot < 1) || (slot > 5))
|
if ((slot < 0) || (slot > 5))
|
||||||
{
|
{
|
||||||
printf("Error - Saves may only be 1 to 5\n");
|
printf("Error - Saves may only be 0 to 5\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +171,7 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
|
||||||
|
|
||||||
int y = 10;
|
int y = 10;
|
||||||
|
|
||||||
for (int i = 0 ; i < 5 ; i++)
|
for (int i = 1 ; i <= 5 ; i++)
|
||||||
{
|
{
|
||||||
if (clickedSlot == i)
|
if (clickedSlot == i)
|
||||||
blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
|
blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
|
||||||
|
@ -173,11 +185,11 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
|
||||||
|
|
||||||
switch (clickedSlot)
|
switch (clickedSlot)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
|
case 5:
|
||||||
blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
|
blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
|
||||||
blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
|
blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
|
||||||
blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
|
blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
|
||||||
|
@ -186,11 +198,14 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
|
||||||
drawString("DELETE", 270, 270, FONT_WHITE, savesSurface);
|
drawString("DELETE", 270, 270, FONT_WHITE, savesSurface);
|
||||||
|
|
||||||
drawString("SAVE will save the game", 17, 200, FONT_WHITE, savesSurface);
|
drawString("SAVE will save the game", 17, 200, FONT_WHITE, savesSurface);
|
||||||
drawString("CANCEL will unselect that slot", 17, 220, FONT_WHITE, savesSurface);
|
drawString("CANCEL will unselect that slot", 17, 220, FONT_WHITE,
|
||||||
drawString("DELETE will remove the save", 17, 240, FONT_WHITE, savesSurface);
|
savesSurface);
|
||||||
|
drawString("DELETE will remove the save", 17, 240, FONT_WHITE,
|
||||||
|
savesSurface);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
drawString("First click a Save game slot to use", 17, 200, FONT_WHITE, savesSurface);
|
drawString("First click a Save game slot to use", 17, 200,
|
||||||
|
FONT_WHITE, savesSurface);
|
||||||
break;
|
break;
|
||||||
case -10:
|
case -10:
|
||||||
drawString("Game Saved", 130, 200, FONT_WHITE, savesSurface);
|
drawString("Game Saved", 130, 200, FONT_WHITE, savesSurface);
|
||||||
|
@ -220,9 +235,10 @@ int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot)
|
||||||
|
|
||||||
if ((engine.keyState[KEY_FIRE]))
|
if ((engine.keyState[KEY_FIRE]))
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < 5 ; i++)
|
for (int i = 1 ; i <= 5 ; i++)
|
||||||
{
|
{
|
||||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, r.x, r.y, r.w, r.h))
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6,
|
||||||
|
r.x, r.y, r.w, r.h))
|
||||||
{
|
{
|
||||||
clickedSlot = i;
|
clickedSlot = i;
|
||||||
createSavesSurface(savesSurface, i);
|
createSavesSurface(savesSurface, i);
|
||||||
|
@ -230,19 +246,23 @@ int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot)
|
||||||
r.y += 30;
|
r.y += 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 215, 365, 100, 25))
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 215,
|
||||||
|
365, 100, 25))
|
||||||
{
|
{
|
||||||
saveGame(saveSlot + 1);
|
saveGame(saveSlot);
|
||||||
createSavesSurface(savesSurface, -10);
|
createSavesSurface(savesSurface, -10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 335, 365, 100, 25))
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 335,
|
||||||
|
365, 100, 25))
|
||||||
createSavesSurface(savesSurface, -1);
|
createSavesSurface(savesSurface, -1);
|
||||||
|
|
||||||
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 453, 365, 100, 25))
|
if (collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 453,
|
||||||
|
365, 100, 25))
|
||||||
{
|
{
|
||||||
char filename[PATH_MAX];
|
char filename[PATH_MAX];
|
||||||
sprintf(filename, "%ssave%.2d.dat", engine.userHomeDirectory, (saveSlot + 1));
|
sprintf(filename, "%ssave%.2d.dat", engine.userHomeDirectory,
|
||||||
|
saveSlot);
|
||||||
remove(filename);
|
remove(filename);
|
||||||
initSaveSlots();
|
initSaveSlots();
|
||||||
createSavesSurface(savesSurface, -11);
|
createSavesSurface(savesSurface, -11);
|
||||||
|
|
|
@ -130,8 +130,6 @@ struct Game {
|
||||||
signed char saveFormat;
|
signed char saveFormat;
|
||||||
signed char difficulty;
|
signed char difficulty;
|
||||||
|
|
||||||
signed char autoSaveSlot;
|
|
||||||
|
|
||||||
unsigned int cash;
|
unsigned int cash;
|
||||||
unsigned int cashEarned;
|
unsigned int cashEarned;
|
||||||
unsigned int shots;
|
unsigned int shots;
|
||||||
|
|
257
src/title.cpp
257
src/title.cpp
|
@ -21,23 +21,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
static signed char showGameMenu(signed char continueSaveSlot)
|
static signed char showGameMenu(signed char continueSaveSlot)
|
||||||
{
|
{
|
||||||
blitText(2);
|
blitText(TS_START_NEW_GAME);
|
||||||
if (continueSaveSlot != 0)
|
if (continueSaveSlot != -1)
|
||||||
{
|
{
|
||||||
blitText(3);
|
blitText(TS_LOAD_GAME);
|
||||||
blitText(4);
|
blitText(TS_CONTINUE_CURRENT_GAME);
|
||||||
}
|
}
|
||||||
blitText(5);
|
blitText(TS_OPTIONS);
|
||||||
if (engine.cheat)
|
if (engine.cheat)
|
||||||
{
|
{
|
||||||
textShape[7].y = 450;
|
textShape[TS_QUIT].y = 450;
|
||||||
blitText(6);
|
blitText(TS_CHEAT_OPTIONS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
textShape[7].y = 430;
|
textShape[TS_QUIT].y = 430;
|
||||||
}
|
}
|
||||||
blitText(7);
|
blitText(TS_QUIT);
|
||||||
|
|
||||||
if (engine.cheat)
|
if (engine.cheat)
|
||||||
return 6;
|
return 6;
|
||||||
|
@ -49,41 +49,41 @@ static signed char showLoadMenu()
|
||||||
{
|
{
|
||||||
signed char rtn = 1;
|
signed char rtn = 1;
|
||||||
|
|
||||||
for (int i = 13 ; i < 18 ; i++)
|
for (int i = TS_SAVESLOT_0 ; i <= TS_SAVESLOT_5 ; i++)
|
||||||
{
|
{
|
||||||
|
rtn++;
|
||||||
if (textShape[i].image != NULL)
|
if (textShape[i].image != NULL)
|
||||||
{
|
{
|
||||||
blitText(i);
|
blitText(i);
|
||||||
rtn++;
|
textShape[TS_BACK_TO_MAIN_MENU].y = textShape[i].y + 40;
|
||||||
textShape[12].y = textShape[i].y + 40;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blitText(12);
|
blitText(TS_BACK_TO_MAIN_MENU);
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createDifficultyMenu()
|
static void createDifficultyMenu()
|
||||||
{
|
{
|
||||||
textSurface(23, "START GAME", -1, 350, FONT_WHITE);
|
textSurface(TS_START_GAME, "START GAME", -1, 350, FONT_WHITE);
|
||||||
|
|
||||||
if (currentGame.difficulty == DIFFICULTY_EASY)
|
if (currentGame.difficulty == DIFFICULTY_EASY)
|
||||||
textSurface(24, "DIFFICULTY - EASY", -1, 370, FONT_WHITE);
|
textSurface(TS_DIFFICULTY, "DIFFICULTY - EASY", -1, 370, FONT_WHITE);
|
||||||
else if (currentGame.difficulty == DIFFICULTY_HARD)
|
else if (currentGame.difficulty == DIFFICULTY_HARD)
|
||||||
textSurface(24, "DIFFICULTY - HARD", -1, 370, FONT_WHITE);
|
textSurface(TS_DIFFICULTY, "DIFFICULTY - HARD", -1, 370, FONT_WHITE);
|
||||||
else if (currentGame.difficulty == DIFFICULTY_NIGHTMARE)
|
else if (currentGame.difficulty == DIFFICULTY_NIGHTMARE)
|
||||||
textSurface(24, "DIFFICULTY - NIGHTMARE", -1, 370, FONT_WHITE);
|
textSurface(TS_DIFFICULTY, "DIFFICULTY - NIGHTMARE", -1, 370, FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(24, "DIFFICULTY - NORMAL", -1, 370, FONT_WHITE);
|
textSurface(TS_DIFFICULTY, "DIFFICULTY - NORMAL", -1, 370, FONT_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static signed char showDifficultyMenu()
|
static signed char showDifficultyMenu()
|
||||||
{
|
{
|
||||||
textShape[12].y = 410;
|
textShape[TS_BACK_TO_MAIN_MENU].y = 410;
|
||||||
|
|
||||||
blitText(23);
|
blitText(TS_START_GAME);
|
||||||
blitText(24);
|
blitText(TS_DIFFICULTY);
|
||||||
blitText(12);
|
blitText(TS_BACK_TO_MAIN_MENU);
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
@ -91,72 +91,73 @@ static signed char showDifficultyMenu()
|
||||||
static void createOptionsMenu()
|
static void createOptionsMenu()
|
||||||
{
|
{
|
||||||
if (engine.useSound)
|
if (engine.useSound)
|
||||||
textSurface(8, "SOUND - ON", -1, 350, FONT_WHITE);
|
textSurface(TS_SOUND, "SOUND - ON", -1, 350, FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(8, "SOUND - OFF", -1, 350, FONT_WHITE);
|
textSurface(TS_SOUND, "SOUND - OFF", -1, 350, FONT_WHITE);
|
||||||
|
|
||||||
if (engine.useMusic)
|
if (engine.useMusic)
|
||||||
textSurface(9, "MUSIC - ON", -1, 370, FONT_WHITE);
|
textSurface(TS_MUSIC, "MUSIC - ON", -1, 370, FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(9, "MUSIC - OFF", -1, 370, FONT_WHITE);
|
textSurface(TS_MUSIC, "MUSIC - OFF", -1, 370, FONT_WHITE);
|
||||||
|
|
||||||
if (engine.fullScreen)
|
if (engine.fullScreen)
|
||||||
textSurface(10, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
|
textSurface(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(10, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
|
textSurface(TS_FULLSCREEN, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
|
||||||
|
|
||||||
char string[50];
|
|
||||||
strcpy(string, "AUTO SAVE SLOT - NONE");
|
|
||||||
if (currentGame.autoSaveSlot > -1)
|
|
||||||
sprintf(string, "AUTO SAVE SLOT - #%d", currentGame.autoSaveSlot + 1);
|
|
||||||
textSurface(11, string, -1, 410, FONT_WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static signed char showOptionsMenu()
|
static signed char showOptionsMenu()
|
||||||
{
|
{
|
||||||
textShape[12].y = 450;
|
textShape[TS_BACK_TO_MAIN_MENU].y = 430;
|
||||||
|
|
||||||
blitText(8);
|
blitText(TS_SOUND);
|
||||||
blitText(9);
|
blitText(TS_MUSIC);
|
||||||
blitText(10);
|
blitText(TS_FULLSCREEN);
|
||||||
blitText(11);
|
blitText(TS_BACK_TO_MAIN_MENU);
|
||||||
blitText(12);
|
|
||||||
|
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createCheatMenu()
|
static void createCheatMenu()
|
||||||
{
|
{
|
||||||
if (engine.cheatShield)
|
if (engine.cheatShield)
|
||||||
textSurface(18, "UNLIMITED SHIELD - ON", -1, 350, FONT_WHITE);
|
textSurface(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - ON", -1, 350,
|
||||||
|
FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(18, "UNLIMITED SHIELD - OFF", -1, 350, FONT_WHITE);
|
textSurface(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - OFF", -1, 350,
|
||||||
|
FONT_WHITE);
|
||||||
|
|
||||||
if (engine.cheatAmmo)
|
if (engine.cheatAmmo)
|
||||||
textSurface(19, "UNLIMITED AMMO - ON", -1, 370, FONT_WHITE);
|
textSurface(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - ON", -1, 370,
|
||||||
|
FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(19, "UNLIMITED AMMO - OFF", -1, 370, FONT_WHITE);
|
textSurface(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - OFF", -1, 370,
|
||||||
|
FONT_WHITE);
|
||||||
|
|
||||||
if (engine.cheatCash)
|
if (engine.cheatCash)
|
||||||
textSurface(20, "UNLIMITED CASH - ON", -1, 390, FONT_WHITE);
|
textSurface(TS_UNLIMITED_CASH, "UNLIMITED CASH - ON", -1, 390,
|
||||||
|
FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(20, "UNLIMITED CASH - OFF", -1, 390, FONT_WHITE);
|
textSurface(TS_UNLIMITED_CASH, "UNLIMITED CASH - OFF", -1, 390,
|
||||||
|
FONT_WHITE);
|
||||||
|
|
||||||
if (engine.cheatTime)
|
if (engine.cheatTime)
|
||||||
textSurface(21, "UNLIMITED TIME - ON", -1, 410, FONT_WHITE);
|
textSurface(TS_UNLIMITED_TIME, "UNLIMITED TIME - ON", -1, 410,
|
||||||
|
FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(21, "UNLIMITED TIME - OFF", -1, 410, FONT_WHITE);
|
textSurface(TS_UNLIMITED_TIME, "UNLIMITED TIME - OFF", -1, 410,
|
||||||
|
FONT_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static signed char showCheatMenu()
|
static signed char showCheatMenu()
|
||||||
{
|
{
|
||||||
textShape[12].y = 450;
|
textShape[TS_BACK_TO_MAIN_MENU].y = 450;
|
||||||
|
|
||||||
blitText(18);
|
blitText(TS_UNLIMITED_SHIELD);
|
||||||
blitText(19);
|
blitText(TS_UNLIMITED_AMMO);
|
||||||
blitText(20);
|
blitText(TS_UNLIMITED_CASH);
|
||||||
blitText(21);
|
blitText(TS_UNLIMITED_TIME);
|
||||||
blitText(12);
|
blitText(TS_BACK_TO_MAIN_MENU);
|
||||||
|
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
@ -201,18 +202,19 @@ int doTitle()
|
||||||
int sfx = ((screen->w - sflogo->w) / 2);
|
int sfx = ((screen->w - sflogo->w) / 2);
|
||||||
int sfy = ((screen->h - sflogo->h) / 2);
|
int sfy = ((screen->h - sflogo->h) / 2);
|
||||||
|
|
||||||
textSurface(0, "PRESENTS", -1, 300, FONT_WHITE);
|
textSurface(TS_PRESENTS, "PRESENTS", -1, 300, FONT_WHITE);
|
||||||
textSurface(1, "AN SDL GAME", -1, 300, FONT_WHITE);
|
textSurface(TS_AN_SDL_GAME, "AN SDL GAME", -1, 300, FONT_WHITE);
|
||||||
textSurface(2, "START NEW GAME", -1, 350, FONT_WHITE);
|
textSurface(TS_START_NEW_GAME, "START NEW GAME", -1, 350, FONT_WHITE);
|
||||||
textSurface(3, "LOAD GAME", -1, 370, FONT_WHITE);
|
textSurface(TS_LOAD_GAME, "LOAD GAME", -1, 370, FONT_WHITE);
|
||||||
textSurface(4, "CONTINUE CURRENT GAME", -1, 390, FONT_WHITE);
|
textSurface(TS_CONTINUE_CURRENT_GAME, "CONTINUE CURRENT GAME", -1, 390,
|
||||||
textSurface(5, "OPTIONS", -1, 410, FONT_WHITE);
|
FONT_WHITE);
|
||||||
textSurface(6, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
|
textSurface(TS_OPTIONS, "OPTIONS", -1, 410, FONT_WHITE);
|
||||||
textSurface(7, "QUIT", -1, 430, FONT_WHITE);
|
textSurface(TS_CHEAT_OPTIONS, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
|
||||||
|
textSurface(TS_QUIT, "QUIT", -1, 430, FONT_WHITE);
|
||||||
|
|
||||||
createOptionsMenu();
|
createOptionsMenu();
|
||||||
createDifficultyMenu();
|
createDifficultyMenu();
|
||||||
textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
|
textSurface(TS_BACK_TO_MAIN_MENU, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
|
||||||
|
|
||||||
createCheatMenu();
|
createCheatMenu();
|
||||||
|
|
||||||
|
@ -251,12 +253,12 @@ int doTitle()
|
||||||
optionRec.w = 215;
|
optionRec.w = 215;
|
||||||
|
|
||||||
signed char selectedOption = 1;
|
signed char selectedOption = 1;
|
||||||
if (continueSaveSlot > 0)
|
if (continueSaveSlot > -1)
|
||||||
{selectedOption = 3; optionRec.y += 40;}
|
{selectedOption = 3; optionRec.y += 40;}
|
||||||
|
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
signed char listLength = 5; // menu list length
|
signed char listLength = 5; // menu list length
|
||||||
signed char menuType = 0;
|
signed char menuType = MENU_MAIN;
|
||||||
|
|
||||||
drawBackGround();
|
drawBackGround();
|
||||||
|
|
||||||
|
@ -296,11 +298,11 @@ int doTitle()
|
||||||
}
|
}
|
||||||
else if ((now - then > 9000) && (now - then < 15000) && (!skip))
|
else if ((now - then > 9000) && (now - then < 15000) && (!skip))
|
||||||
{
|
{
|
||||||
blitText(0);
|
blitText(TS_PRESENTS);
|
||||||
}
|
}
|
||||||
else if ((now - then > 16000) && (now - then < 21000) && (!skip))
|
else if ((now - then > 16000) && (now - then < 21000) && (!skip))
|
||||||
{
|
{
|
||||||
blitText(1);
|
blitText(TS_AN_SDL_GAME);
|
||||||
}
|
}
|
||||||
else if ((now - then > 25500) || (skip))
|
else if ((now - then > 25500) || (skip))
|
||||||
{
|
{
|
||||||
|
@ -308,27 +310,27 @@ int doTitle()
|
||||||
|
|
||||||
if ((now - then >= 27500) || (skip))
|
if ((now - then >= 27500) || (skip))
|
||||||
{
|
{
|
||||||
addBuffer(280, 345, 235, 145);
|
addBuffer(0, 0, screen->w, screen->h);
|
||||||
|
|
||||||
blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
|
blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
|
||||||
|
|
||||||
switch(menuType)
|
switch(menuType)
|
||||||
{
|
{
|
||||||
case 0:
|
case MENU_MAIN:
|
||||||
listLength = showGameMenu(continueSaveSlot);
|
listLength = showGameMenu(continueSaveSlot);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case MENU_DIFFICULTY:
|
||||||
|
listLength = showDifficultyMenu();
|
||||||
|
break;
|
||||||
|
case MENU_LOAD:
|
||||||
listLength = showLoadMenu();
|
listLength = showLoadMenu();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case MENU_OPTIONS:
|
||||||
listLength = showOptionsMenu();
|
listLength = showOptionsMenu();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MENU_CHEAT:
|
||||||
listLength = showCheatMenu();
|
listLength = showCheatMenu();
|
||||||
break;
|
break;
|
||||||
case 4:
|
|
||||||
listLength = showDifficultyMenu();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redGlow += redDir;
|
redGlow += redDir;
|
||||||
|
@ -339,23 +341,23 @@ int doTitle()
|
||||||
{
|
{
|
||||||
engine.keyState[KEY_UP] = 0;
|
engine.keyState[KEY_UP] = 0;
|
||||||
wrapChar(&(--selectedOption), 1, listLength + 1);
|
wrapChar(&(--selectedOption), 1, listLength + 1);
|
||||||
if (menuType == 0)
|
if (menuType == MENU_MAIN)
|
||||||
if ((selectedOption == 2) || (selectedOption == 3))
|
if ((selectedOption == 2) || (selectedOption == 3))
|
||||||
if (continueSaveSlot == 0)
|
if (continueSaveSlot == -1)
|
||||||
selectedOption = 1;
|
selectedOption = 1;
|
||||||
}
|
}
|
||||||
if (engine.keyState[KEY_DOWN])
|
if (engine.keyState[KEY_DOWN])
|
||||||
{
|
{
|
||||||
engine.keyState[KEY_DOWN] = 0;
|
engine.keyState[KEY_DOWN] = 0;
|
||||||
wrapChar(&(++selectedOption), 0, listLength);
|
wrapChar(&(++selectedOption), 0, listLength);
|
||||||
if (menuType == 0)
|
if (menuType == MENU_MAIN)
|
||||||
if ((selectedOption == 2) || (selectedOption == 3))
|
if ((selectedOption == 2) || (selectedOption == 3))
|
||||||
if (continueSaveSlot == 0)
|
if (continueSaveSlot == -1)
|
||||||
selectedOption = 4;
|
selectedOption = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
optionRec.y = 326 + (20 * selectedOption);
|
optionRec.y = 326 + (20 * selectedOption);
|
||||||
if (menuType > 0)
|
if (menuType > MENU_MAIN)
|
||||||
if (selectedOption == listLength)
|
if (selectedOption == listLength)
|
||||||
optionRec.y += 20;
|
optionRec.y += 20;
|
||||||
|
|
||||||
|
@ -393,19 +395,31 @@ int doTitle()
|
||||||
{
|
{
|
||||||
switch (menuType)
|
switch (menuType)
|
||||||
{
|
{
|
||||||
case 0: // Main menu
|
case MENU_MAIN:
|
||||||
if (selectedOption == 1)
|
if (selectedOption == 1)
|
||||||
{menuType = 4; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_DIFFICULTY;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
else if (selectedOption == 2)
|
else if (selectedOption == 2)
|
||||||
{menuType = 1; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_LOAD;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
else if (selectedOption == 3)
|
else if (selectedOption == 3)
|
||||||
engine.done = 1;
|
engine.done = 1;
|
||||||
else if (selectedOption == 4)
|
else if (selectedOption == 4)
|
||||||
{menuType = 2; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_OPTIONS;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
else if (selectedOption == 5)
|
else if (selectedOption == 5)
|
||||||
{
|
{
|
||||||
if (engine.cheat)
|
if (engine.cheat)
|
||||||
{menuType = 3; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_CHEAT;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
engine.done = 1;
|
engine.done = 1;
|
||||||
}
|
}
|
||||||
|
@ -413,14 +427,38 @@ int doTitle()
|
||||||
engine.done = 1;
|
engine.done = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // Load game menu
|
case MENU_DIFFICULTY:
|
||||||
if (selectedOption != listLength)
|
if (selectedOption == 1)
|
||||||
{engine.done = 1; continueSaveSlot = selectedOption; selectedOption = 3;}
|
engine.done = 1;
|
||||||
else
|
else if (selectedOption == 2)
|
||||||
{menuType = 0; selectedOption = 1;}
|
{
|
||||||
|
currentGame.difficulty++;
|
||||||
|
if (currentGame.difficulty > DIFFICULTY_NIGHTMARE)
|
||||||
|
currentGame.difficulty = DIFFICULTY_EASY;
|
||||||
|
}
|
||||||
|
else if (selectedOption == listLength)
|
||||||
|
{
|
||||||
|
menuType = MENU_MAIN;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
|
createDifficultyMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // Options menu
|
case MENU_LOAD:
|
||||||
|
if (selectedOption != listLength)
|
||||||
|
{
|
||||||
|
engine.done = 1;
|
||||||
|
continueSaveSlot = selectedOption - 1;
|
||||||
|
selectedOption = 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menuType = MENU_MAIN;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MENU_OPTIONS:
|
||||||
if ((selectedOption == 1) && (engine.useAudio))
|
if ((selectedOption == 1) && (engine.useAudio))
|
||||||
engine.useSound = !engine.useSound;
|
engine.useSound = !engine.useSound;
|
||||||
else if ((selectedOption == 2) && (engine.useAudio))
|
else if ((selectedOption == 2) && (engine.useAudio))
|
||||||
|
@ -442,16 +480,19 @@ int doTitle()
|
||||||
else if (selectedOption == 3)
|
else if (selectedOption == 3)
|
||||||
{
|
{
|
||||||
engine.fullScreen = !engine.fullScreen;
|
engine.fullScreen = !engine.fullScreen;
|
||||||
SDL_SetWindowFullscreen(window, engine.fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(window,
|
||||||
|
(engine.fullScreen ?
|
||||||
|
SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
|
||||||
}
|
}
|
||||||
else if (selectedOption == 4)
|
|
||||||
wrapChar(&(++currentGame.autoSaveSlot), -1, 4);
|
|
||||||
else if (selectedOption == listLength)
|
else if (selectedOption == listLength)
|
||||||
{menuType = 0; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_MAIN;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
createOptionsMenu();
|
createOptionsMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // Cheat menu
|
case MENU_CHEAT:
|
||||||
if (selectedOption == 1)
|
if (selectedOption == 1)
|
||||||
engine.cheatShield = !engine.cheatShield;
|
engine.cheatShield = !engine.cheatShield;
|
||||||
else if (selectedOption == 2)
|
else if (selectedOption == 2)
|
||||||
|
@ -461,26 +502,16 @@ int doTitle()
|
||||||
else if (selectedOption == 4)
|
else if (selectedOption == 4)
|
||||||
engine.cheatTime = !engine.cheatTime;
|
engine.cheatTime = !engine.cheatTime;
|
||||||
else if (selectedOption == listLength)
|
else if (selectedOption == listLength)
|
||||||
{menuType = 0; selectedOption = 1;}
|
{
|
||||||
|
menuType = MENU_MAIN;
|
||||||
|
selectedOption = 1;
|
||||||
|
}
|
||||||
createCheatMenu();
|
createCheatMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // Difficulty menu
|
|
||||||
if (selectedOption == 1)
|
|
||||||
engine.done = 1;
|
|
||||||
else if (selectedOption == 2)
|
|
||||||
{
|
|
||||||
currentGame.difficulty++;
|
|
||||||
if (currentGame.difficulty > DIFFICULTY_NIGHTMARE)
|
|
||||||
currentGame.difficulty = DIFFICULTY_EASY;
|
|
||||||
}
|
|
||||||
else if (selectedOption == listLength)
|
|
||||||
{menuType = 0; selectedOption = 1;}
|
|
||||||
createDifficultyMenu();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
menuType = 0, selectedOption = 1;
|
menuType = MENU_MAIN;
|
||||||
|
selectedOption = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue