Browse Source

Menu changes

- "Don't save" option added to quit menu, replaces hidden reboot
- Added gint info to About menu
master
KBD2 1 month ago
parent
commit
e7af81cf62
6 changed files with 61 additions and 33 deletions
  1. +1
    -1
      .gitignore
  2. +1
    -3
      include/menu.h
  3. +1
    -0
      include/update.h
  4. +21
    -13
      src/main.c
  5. +24
    -15
      src/menu.c
  6. +13
    -1
      src/update.c

+ 1
- 1
.gitignore View File

@ -1,4 +1,4 @@
/copytotesting
/deploy
build-fx
.vscode
*.g1a


+ 1
- 3
include/menu.h View File

@ -47,10 +47,8 @@ void debugMenu();
/* exitMenu
An exit dialog box.
Returns true if the player wishes to exit, false otherwise.
*/
bool exitMenu();
int exitMenu();
/* lowSpaceMenu
A menu to inform the player that they should optimise their storage.


+ 1
- 0
include/update.h View File

@ -8,6 +8,7 @@ Player and keyboard updates.
enum UpdateReturnCodes {
UPDATE_EXIT, // Exit the game
UPDATE_EXIT_NOSAVE, // Exit but don't save the game
UPDATE_CONTINUE // Continue as normal
};


+ 21
- 13
src/main.c View File

@ -73,7 +73,7 @@ void setPlayerSpawn()
player.spawn.y = (playerY << 3) - player.props.height;
}
void gameLoop(volatile int *flag)
bool gameLoop(volatile int *flag)
{
int respawnCounter = 0;
int frames = 0;
@ -85,7 +85,8 @@ void gameLoop(volatile int *flag)
if(!respawnCounter) playerUpdate(frames);
updateRet = keyboardUpdate();
if(updateRet == UPDATE_EXIT) break;
if(updateRet == UPDATE_EXIT) return true;
else if(updateRet == UPDATE_EXIT_NOSAVE) return false;
if(frames & 1) updateExplosion(&world.explosion);
if(frames % 8 == 0) worldUpdate();
@ -142,6 +143,7 @@ int main(void)
int timer;
volatile int flag = 0;
int mediaFree[2];
bool doSave;
switch(gint[HWCALC])
{
@ -308,30 +310,36 @@ int main(void)
registerHeld();
// Do the game
gameLoop(&flag);
doSave = gameLoop(&flag);
timer_stop(timer);
dgray(DGRAY_OFF);
dclear(C_WHITE);
dfont(NULL);
dsize("Saving World...", NULL, &w, &h);
dtext(64 - w / 2, 32 - h / 2, C_BLACK, "Saving World...");
dupdate();
if(doSave)
{
dgray(DGRAY_OFF);
dclear(C_WHITE);
dfont(NULL);
dsize("Saving World...", NULL, &w, &h);
dtext(64 - w / 2, 32 - h / 2, C_BLACK, "Saving World...");
dupdate();
}
free(world.entities);
destroyExplosion(&world.explosion);
craftingCleanup();
gint_switch(&saveGame);
if(doSave) gint_switch(&saveGame);
free(world.chests.chests);
if(save.error != -99) saveFailMenu();
Bfile_GetMediaFree_OS(u"\\\\fls0", mediaFree);
if(mediaFree[1] < 350000) lowSpaceMenu(mediaFree[1]);
if(doSave)
{
Bfile_GetMediaFree_OS(u"\\\\fls0", mediaFree);
if(mediaFree[1] < 350000) lowSpaceMenu(mediaFree[1]);
#ifndef DEBUGMODE
gint_switch(&JumpOptimising);
gint_switch(&JumpOptimising);
#endif
}
return 1;
}

+ 24
- 15
src/menu.c View File

@ -83,20 +83,21 @@ int mainMenu()
}
}
bool exitMenu()
int exitMenu()
{
int width;
extern bopti_image_t img_quit;
key_event_t key;
while(keydown(KEY_MENU)) clearevents();
drect_border(19, 9, 107, 52, C_WHITE, 1, C_BLACK);
drect_border(20, 9, 106, 54, C_WHITE, 1, C_BLACK);
dsize("Quit?", NULL, &width, NULL);
dtext(64 - width / 2, 12, C_BLACK, "Quit?");
dtext(22, 45, C_BLACK, "MENU: Yes");
dtext(64 - width / 2, 11, C_BLACK, "Quit?");
dtext(22, 42, C_BLACK, "MENU: Yes");
dsize("EXIT: No", NULL, &width, NULL);
dtext(105 - width, 45, C_BLACK, "EXIT: No");
dimage(47, 19, &img_quit);
dtext(105 - width, 42, C_BLACK, "EXIT: No");
dtext_opt(64, 48, C_BLACK, C_WHITE, DTEXT_MIDDLE, DTEXT_TOP, "AC/ON: Don't save");
dimage(47, 17, &img_quit);
dupdate();
while(1)
@ -105,13 +106,13 @@ bool exitMenu()
switch(key.key)
{
case KEY_MENU:
return true;
return 1;
case KEY_EXIT:
return false;
return 0;
case KEY_ACON:
RebootOS(); // Don't save/optimize
return 2;
default:
break;
@ -372,14 +373,16 @@ void aboutMenu()
memcpy(timestamp.minute, (char *)0x00300048, 2);
const char *month = months[atoi(timestamp.month) - 1];
sprintf(buffer, "%s %s %s %s:%s", timestamp.day, month, timestamp.year, timestamp.hour, timestamp.minute);
const char *aboutText[] = {
const char *thanksText[] = {
"Special thanks to:",
"Lephenixnoir - Gint",
"Memallox - Newlib",
"Dark Storm",
"Yatis",
"",
"Yatis"
};
const char *versionText[] = {
VERSION,
"gint " GINT_VERSION,
buffer
};
const char *controlsText[] = {
@ -410,7 +413,8 @@ void aboutMenu()
"[SHIFT]: Inventory",
"[ALPHA]: Exit"
};
const int aboutLines = sizeof(aboutText) / sizeof(char*);
const int thanksLines = sizeof(thanksText) / sizeof(char*);
const int versionLines = sizeof(versionText) / sizeof(char*);
const int controlLines = sizeof(controlsText) / sizeof(char*);
int scroll = 0;
bool ingredients = false;
@ -430,10 +434,15 @@ void aboutMenu()
{
case MENU_ABOUT:
dimage(89, 36, &img_confetti);
for(int line = 0; line < aboutLines; line++)
for(int line = 0; line < thanksLines; line++)
{
dtext_opt(64, 7 * line + 1, C_BLACK, C_WHITE, DTEXT_MIDDLE, DTEXT_TOP, thanksText[line]);
}
for(int line = 0; line < versionLines; line++)
{
dtext_opt(64, 7 * line, C_BLACK, C_WHITE, DTEXT_MIDDLE, DTEXT_TOP, aboutText[line]);
dtext_opt(64, 7 * line + 37, C_BLACK, C_WHITE, DTEXT_MIDDLE, DTEXT_TOP, versionText[line]);
}
dline(48, 35, 80, 35, C_LIGHT);
break;
case MENU_CONTROLS:


+ 13
- 1
src/update.c View File

@ -119,6 +119,7 @@ enum UpdateReturnCodes keyboardUpdate()
enum Tiles tile;
bool playerDead = player.combat.health <= 0;
struct Chest* chest;
int ret;
player.inventory.ticksSinceInteracted++;
@ -179,7 +180,18 @@ enum UpdateReturnCodes keyboardUpdate()
break;
case KEY_MENU:
if(exitMenu()) return UPDATE_EXIT;
ret = exitMenu();
switch(ret)
{
case 0:
break;
case 1:
return UPDATE_EXIT;
case 2:
return UPDATE_EXIT_NOSAVE;
}
break;
case KEY_9:


Loading…
Cancel
Save