From 7c63bee50dc4165d57abd3e1d4f4bf0963e58fec Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 10 Feb 2026 19:20:38 -0500 Subject: [PATCH] Menu music added. --- draugnorak.nvgt | 87 ++++++++++++++++++++++++++++++++++---- sounds/menu/Draugnorak.ogg | 3 ++ sounds/terrain/stream.ogg | 4 +- src/learn_sounds.nvgt | 4 +- 4 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 sounds/menu/Draugnorak.ogg diff --git a/draugnorak.nvgt b/draugnorak.nvgt index 9ca4b36..a9d7318 100755 --- a/draugnorak.nvgt +++ b/draugnorak.nvgt @@ -1,5 +1,6 @@ #include "sound_pool.nvgt" #include "virtual_dialogs.nvgt" +#include "music.nvgt" // Audio // Increased pool size to 300 to prevent sound cutoffs and missing sounds @@ -41,18 +42,79 @@ sound_pool p(300); #include "src/learn_sounds.nvgt" #include "src/bosses/adventure_system.nvgt" +const string MAIN_MENU_MUSIC_TRACK = "sounds/menu/Draugnorak.ogg; loop; f=1"; +const int MAIN_MENU_MUSIC_FADE_IN_MS = 1; +const int MAIN_MENU_MUSIC_FADE_OUT_MS = 800; +music_manager mainMenuMusic; + +const int MAIN_MENU_NEW_GAME = 0; +const int MAIN_MENU_LOAD_GAME = 1; +const int MAIN_MENU_LEARN_SOUNDS = 2; +const int MAIN_MENU_EXIT = 3; + +void start_main_menu_music() { + if (mainMenuMusic.resume(MAIN_MENU_MUSIC_FADE_IN_MS)) return; + if (mainMenuMusic.playing) { + mainMenuMusic.pause(0); + mainMenuMusic.resume(MAIN_MENU_MUSIC_FADE_IN_MS); + return; + } + mainMenuMusic.play(MAIN_MENU_MUSIC_TRACK); +} + +void stop_main_menu_music() { + if (!mainMenuMusic.playing) return; + mainMenuMusic.pause(MAIN_MENU_MUSIC_FADE_OUT_MS); +} + int run_main_menu() { + start_main_menu_music(); speak_with_history("Draugnorak. Main menu.", true); int selection = 0; string load_label = has_save_game() ? "Load Game" : "Load Game (no saves found)"; - string[] options = {"New Game", load_label, "Learn Sounds", "Exit"}; - int exit_index = options.length() - 1; + string[] options; + string[] entry_paths; + int[] entry_types; // 0 = action, 1 = document + int[] action_ids; + + options.insert_last("New Game"); + entry_paths.insert_last(""); + entry_types.insert_last(0); + action_ids.insert_last(MAIN_MENU_NEW_GAME); + + options.insert_last(load_label); + entry_paths.insert_last(""); + entry_types.insert_last(0); + action_ids.insert_last(MAIN_MENU_LOAD_GAME); + + options.insert_last("Learn Sounds"); + entry_paths.insert_last(""); + entry_types.insert_last(0); + action_ids.insert_last(MAIN_MENU_LEARN_SOUNDS); + + string[] doc_labels; + string[] doc_paths; + int[] doc_types; + add_doc_entries(doc_labels, doc_paths, doc_types); + for (uint i = 0; i < doc_labels.length(); i++) { + options.insert_last(doc_labels[i]); + entry_paths.insert_last(doc_paths[i]); + entry_types.insert_last(1); + action_ids.insert_last(-1); + } + + options.insert_last("Exit"); + entry_paths.insert_last(""); + entry_types.insert_last(0); + action_ids.insert_last(MAIN_MENU_EXIT); + int exit_action = MAIN_MENU_EXIT; speak_with_history(options[selection], true); while(true) { wait(5); + mainMenuMusic.loop(); if (key_pressed(KEY_DOWN)) { play_menu_move_sound(); @@ -70,15 +132,24 @@ int run_main_menu() { if (key_pressed(KEY_RETURN)) { play_menu_select_sound(); - return selection; + if (entry_types[selection] == 1) { + stop_main_menu_music(); + text_reader_file(entry_paths[selection], options[selection], true); + start_main_menu_music(); + speak_with_history(options[selection], true); + continue; + } + stop_main_menu_music(); + return action_ids[selection]; } if (key_pressed(KEY_ESCAPE)) { - return exit_index; + stop_main_menu_music(); + return exit_action; } } - return exit_index; + return exit_action; } void run_game() @@ -97,14 +168,14 @@ void run_game() while (!game_started) { int selection = run_main_menu(); - if (selection == 0) { + if (selection == MAIN_MENU_NEW_GAME) { if (!setup_new_character()) { continue; } start_new_game(); speak_with_history("New game started.", true); game_started = true; - } else if (selection == 1) { + } else if (selection == MAIN_MENU_LOAD_GAME) { if (!has_save_game()) { ui_info_box("Draugnorak", "Load Game", "No saves found."); continue; @@ -121,7 +192,7 @@ void run_game() if (message == "") message = "Unable to load save."; ui_info_box("Draugnorak", "Load Game", message); } - } else if (selection == 2) { + } else if (selection == MAIN_MENU_LEARN_SOUNDS) { run_learn_sounds_menu(); continue; } else { diff --git a/sounds/menu/Draugnorak.ogg b/sounds/menu/Draugnorak.ogg new file mode 100644 index 0000000..6dadd15 --- /dev/null +++ b/sounds/menu/Draugnorak.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bee0180440278e053e2464c3385fd21f0d286d38a658b8a260eddc63e3114b03 +size 1369040 diff --git a/sounds/terrain/stream.ogg b/sounds/terrain/stream.ogg index 7b192ee..20a59e2 100644 --- a/sounds/terrain/stream.ogg +++ b/sounds/terrain/stream.ogg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32af1efdb9ef95d37ab59d7bd4fead71368b1019ff5679fe801909317d8a6da2 -size 29207 +oid sha256:b7ac470ba280cf99324a75792a809f4ce30913b43c2a2713e104f398bf9fdd4e +size 26517 diff --git a/src/learn_sounds.nvgt b/src/learn_sounds.nvgt index b98fb56..9206579 100644 --- a/src/learn_sounds.nvgt +++ b/src/learn_sounds.nvgt @@ -12,6 +12,7 @@ string[] learnSoundSkipList = { "sounds/quests/bone8.ogg", "sounds/actions/fishpole.ogg", "sounds/actions/hit_ground.ogg", + "sounds/menu/", "sounds/nature/" }; @@ -206,9 +207,8 @@ void run_learn_sounds_menu() { string[] labels; string[] entryPaths; - int[] entryTypes; // 0 = sound, 1 = document + int[] entryTypes; // 0 = sound - add_doc_entries(labels, entryPaths, entryTypes); add_sound_entries(labels, entryPaths, entryTypes); if (labels.length() == 0) {