Finally got around to returning to menu on death or exit. I shouldn't have put this off for so long, was painful. Also quest system future proofed if I decide to add anything that might cause death in one of them.
This commit is contained in:
@@ -35,7 +35,9 @@ void run_barricade_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -98,7 +98,9 @@ void run_buildings_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -58,7 +58,9 @@ void run_clothing_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -13,7 +13,9 @@ void run_materials_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -98,7 +98,9 @@ void run_runes_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
@@ -154,7 +156,9 @@ void run_rune_equipment_menu(int rune_type) {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -17,7 +17,9 @@ void run_tools_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -11,7 +11,9 @@ void run_weapons_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -38,7 +38,9 @@ void run_crafting_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
@@ -86,7 +88,9 @@ void simulate_crafting(int item_count) {
|
||||
timer t;
|
||||
while(t.elapsed < 800) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
p.play_stationary("sounds/crafting_complete.ogg", false);
|
||||
|
||||
@@ -136,7 +136,9 @@ void run_fylgja_menu() {
|
||||
|
||||
while (true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
return;
|
||||
|
||||
@@ -263,7 +263,9 @@ void run_action_menu(int x) {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -88,7 +88,9 @@ void run_altar_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -56,7 +56,9 @@ void run_base_info_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -160,7 +160,9 @@ void run_equipment_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -81,7 +81,9 @@ void run_inventory_root_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
@@ -124,7 +126,9 @@ void run_inventory_menu(bool allow_deposit) {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// Menu utility functions
|
||||
// Helper functions used across multiple menu systems
|
||||
|
||||
void menu_background_tick() {
|
||||
bool menu_background_tick() {
|
||||
if (return_to_main_menu_requested) {
|
||||
return true;
|
||||
}
|
||||
if (!menuBackgroundUpdatesEnabled) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Keep this list in sync with the main game loop to avoid pausing ambience/weather/time.
|
||||
update_time();
|
||||
@@ -47,9 +50,12 @@ void menu_background_tick() {
|
||||
if (!try_consume_heal_scroll()) {
|
||||
speak_with_history("You have died.", true);
|
||||
wait(2000);
|
||||
exit();
|
||||
return_to_main_menu_requested = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void play_menu_move_sound() {
|
||||
|
||||
@@ -305,7 +305,9 @@ void run_storage_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -96,6 +96,7 @@ int last_adventure_day = -1;
|
||||
// Pause state
|
||||
bool game_paused = false;
|
||||
bool menuBackgroundUpdatesEnabled = true;
|
||||
bool return_to_main_menu_requested = false;
|
||||
|
||||
// Restart all game timers when resuming from pause
|
||||
// Prevents time from accumulating while paused
|
||||
|
||||
@@ -50,8 +50,8 @@ int get_quest_chance_from_favor() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
void quest_menu_background_tick() {
|
||||
menu_background_tick();
|
||||
bool quest_menu_background_tick() {
|
||||
return menu_background_tick();
|
||||
}
|
||||
|
||||
void quest_boomerang_hit_sound() {
|
||||
@@ -163,6 +163,10 @@ void run_quest(int quest_type) {
|
||||
else if (quest_type == QUEST_ENCHANTED_MELODY) score = run_enchanted_melody();
|
||||
else if (quest_type == QUEST_ESCAPE_FROM_HEL) score = run_escape_from_hel();
|
||||
else if (quest_type == QUEST_SKELETAL_BARD) score = run_skeletal_bard();
|
||||
if (return_to_main_menu_requested) {
|
||||
p.resume_all();
|
||||
return;
|
||||
}
|
||||
apply_quest_reward(score);
|
||||
p.resume_all();
|
||||
}
|
||||
@@ -178,7 +182,9 @@ void run_quest_menu() {
|
||||
|
||||
while(true) {
|
||||
wait(5);
|
||||
menu_background_tick();
|
||||
if (menu_background_tick()) {
|
||||
return;
|
||||
}
|
||||
if (key_pressed(KEY_ESCAPE)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
|
||||
@@ -21,7 +21,9 @@ int select_note_count(int minNotes, int maxNotes, int startValue) {
|
||||
|
||||
while (true) {
|
||||
wait(5);
|
||||
quest_menu_background_tick();
|
||||
if (quest_menu_background_tick()) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (key_pressed(KEY_UP)) {
|
||||
if (selection < maxNotes) selection++;
|
||||
@@ -72,6 +74,9 @@ int run_skeletal_bard() {
|
||||
wait(400);
|
||||
|
||||
int guess = select_note_count(5, 20, 5);
|
||||
if (return_to_main_menu_requested) {
|
||||
return 0;
|
||||
}
|
||||
int diff = length - guess;
|
||||
if (diff < 0) diff = -diff;
|
||||
|
||||
@@ -82,6 +87,9 @@ int run_skeletal_bard() {
|
||||
speak_with_history("You entered " + guess + " notes and the actual number was " + length + ". " + points + " points. Press Enter to continue.", true);
|
||||
while (true) {
|
||||
wait(5);
|
||||
if (return_to_main_menu_requested) {
|
||||
return 0;
|
||||
}
|
||||
if (key_pressed(KEY_RETURN)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user