static int dialog_title_music_vol(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data) { option_t *option = config_get_option("music_volume"); option_select_value_by_index(option, gg_option_get_selected(GG_OPTION(widget))); audio_set_music_volume(option->selected->index); return 1; }
static boolean title_key(context *ctx, int *key) { const struct config_info *conf = get_config(); struct game_context *title = (struct game_context *)ctx; struct world *mzx_world = ctx->world; // NOTE: disabled due to joystick support. See IKEY_RETURN and IKEY_ESCAPE. //int key_status = get_key_status(keycode_internal_wrt_numlock, *key); boolean exit_status = get_exit_status(); boolean reload_curr_file_in_editor = true; boolean confirm_exit = false; switch(*key) { #ifdef CONFIG_HELPSYS case IKEY_h: { // Help system alternate binding. *key = IKEY_F1; break; } #endif case IKEY_s: { // Configure alternate binding. *key = IKEY_F2; break; } case IKEY_F3: case IKEY_l: { if(conf->standalone_mode) return true; load_world_title_selection(title); return true; } case IKEY_F4: { // ALT+F4 - do nothing. if(get_alt_status(keycode_internal)) break; } /* fallthrough */ case IKEY_r: { // Restore saved game if(conf->standalone_mode && !get_counter(mzx_world, "LOAD_MENU", 0)) return true; if(load_savegame_selection(title)) { play_game(ctx, &(title->fade_in)); title->need_reload = true; } return true; } case IKEY_F5: case IKEY_p: { // Play game if(mzx_world->active) { if(mzx_world->only_from_swap) { error("You can only play this game via a swap from another game", ERROR_T_WARNING, ERROR_OPT_OK, 0x3101); return true; } if(load_world_gameplay(title, curr_file)) { play_game(ctx, NULL); title->need_reload = true; } } return true; } case IKEY_F7: case IKEY_u: { if(check_for_updates) { // FIXME this is garbage int current_music_vol = audio_get_music_volume(); int current_pcs_vol = audio_get_pcs_volume(); audio_set_music_volume(0); audio_set_pcs_volume(0); if(mzx_world->active) audio_set_module_volume(0); check_for_updates(ctx, false); audio_set_pcs_volume(current_pcs_vol); audio_set_music_volume(current_music_vol); if(mzx_world->active) audio_set_module_volume(mzx_world->current_board->volume); } return true; } case IKEY_F8: case IKEY_n: { reload_curr_file_in_editor = false; } /* fallthrough */ case IKEY_F9: case IKEY_e: { if(edit_world) { // Editor sfx_clear_queue(); vquick_fadeout(); title->need_reload = true; title->fade_in = true; edit_world(ctx, reload_curr_file_in_editor); } return true; } // Quickload saved game case IKEY_F10: { struct stat file_info; if(conf->standalone_mode && !get_counter(mzx_world, "LOAD_MENU", 0)) return true; if(!stat(curr_sav, &file_info) && load_savegame(title, curr_sav)) { play_game(ctx, &(title->fade_in)); title->need_reload = true; } return true; } case IKEY_RETURN: // Enter { // Ignore if this isn't a fresh press // NOTE: disabled because it breaks the joystick actions. //if(key_status != 1) //return true; if(!conf->standalone_mode || get_counter(mzx_world, "ENTER_MENU", 0)) main_menu(ctx); return true; } case IKEY_ESCAPE: { // Ignore if this isn't a fresh press // NOTE: disabled because it breaks the joystick actions. //if(key_status != 1) //return true; // ESCAPE_MENU (2.90+) only works on the title screen if the // standalone_mode config option is set if(mzx_world->version < V290 || !conf->standalone_mode || get_counter(mzx_world, "ESCAPE_MENU", 0)) confirm_exit = true; break; } } // Quit if(exit_status || confirm_exit) { // Special behaviour in standalone- only escape exits // ask for confirmation. Exit events instead terminate MegaZeux. if(conf->standalone_mode && !confirm_exit) { core_full_exit(ctx); } else { if(!confirm(mzx_world, "Exit MegaZeux - Are you sure?")) destroy_context(ctx); } return true; } return false; }