X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=9f20487fb0e4f5aebb8bd2108b2f7e19040db114;hp=01394c4eebded67fddf56698fe4f36f00c9d53fa;hb=897c46a2720672a49ce6d0803b08eed23fd2dd90;hpb=a72578211d241dd0282ed9f803e85e027395f27a diff --git a/src/files.c b/src/files.c index 01394c4e..9f20487f 100644 --- a/src/files.c +++ b/src/files.c @@ -8171,18 +8171,19 @@ void SaveTape(int nr) tape.changed = FALSE; } -static boolean SaveTapeCheckedExt(int nr, char *msg_replace, char *msg_saved) +static boolean SaveTapeCheckedExt(int nr, char *msg_replace, char *msg_saved, + unsigned int req_state_added) { char *filename = getTapeFilename(nr); boolean new_tape = !fileExists(filename); boolean tape_saved = FALSE; - if (new_tape || Request(msg_replace, REQ_ASK)) + if (new_tape || Request(msg_replace, REQ_ASK | req_state_added)) { SaveTape(nr); if (new_tape) - Request(msg_saved, REQ_CONFIRM); + Request(msg_saved, REQ_CONFIRM | req_state_added); tape_saved = TRUE; } @@ -8192,13 +8193,13 @@ static boolean SaveTapeCheckedExt(int nr, char *msg_replace, char *msg_saved) boolean SaveTapeChecked(int nr) { - return SaveTapeCheckedExt(nr, "Replace old tape?", "Tape saved!"); + return SaveTapeCheckedExt(nr, "Replace old tape?", "Tape saved!", 0); } boolean SaveTapeChecked_LevelSolved(int nr) { return SaveTapeCheckedExt(nr, "Level solved! Replace old tape?", - "Level solved! Tape saved!"); + "Level solved! Tape saved!", REQ_STAY_OPEN); } void DumpTape(struct TapeInfo *tape) @@ -8351,221 +8352,748 @@ void SaveScore(int nr) #define TOKEN_STR_PLAYER_PREFIX "player_" -static struct SetupInfo si; -static struct SetupAutoSetupInfo sasi; -static struct SetupEditorInfo sei; -static struct SetupEditorCascadeInfo seci; -static struct SetupShortcutInfo ssi; -static struct SetupInputInfo sii; -static struct SetupSystemInfo syi; -static struct SetupInternalInfo sxi; -static struct SetupDebugInfo sdi; -static struct OptionInfo soi; - static struct TokenInfo global_setup_tokens[] = { - { TYPE_STRING, &si.player_name, "player_name" }, - { TYPE_SWITCH, &si.sound, "sound" }, - { TYPE_SWITCH, &si.sound_loops, "repeating_sound_loops" }, - { TYPE_SWITCH, &si.sound_music, "background_music" }, - { TYPE_SWITCH, &si.sound_simple, "simple_sound_effects" }, - { TYPE_SWITCH, &si.toons, "toons" }, - { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" }, - { TYPE_INTEGER,&si.scroll_delay_value, "scroll_delay_value" }, - { TYPE_STRING, &si.engine_snapshot_mode, "engine_snapshot_mode" }, - { TYPE_INTEGER,&si.engine_snapshot_memory, "engine_snapshot_memory" }, - { TYPE_SWITCH, &si.fade_screens, "fade_screens" }, - { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording"}, - { TYPE_SWITCH, &si.show_titlescreen, "show_titlescreen" }, - { TYPE_SWITCH, &si.quick_doors, "quick_doors" }, - { TYPE_SWITCH, &si.team_mode, "team_mode" }, - { TYPE_SWITCH, &si.handicap, "handicap" }, - { TYPE_SWITCH, &si.skip_levels, "skip_levels" }, - { TYPE_SWITCH, &si.increment_levels, "increment_levels" }, - { TYPE_SWITCH, &si.auto_play_next_level, "auto_play_next_level" }, - { TYPE_SWITCH, &si.skip_scores_after_game, "skip_scores_after_game" }, - { TYPE_SWITCH, &si.time_limit, "time_limit" }, - { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, - { TYPE_INTEGER,&si.window_scaling_percent, "window_scaling_percent" }, - { TYPE_STRING, &si.window_scaling_quality, "window_scaling_quality" }, - { TYPE_STRING, &si.screen_rendering_mode, "screen_rendering_mode" }, - { TYPE_STRING, &si.vsync_mode, "vsync_mode" }, - { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, - { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" }, - { TYPE_SWITCH, &si.ask_on_game_over, "ask_on_game_over" }, - { TYPE_SWITCH, &si.quick_switch, "quick_player_switch" }, - { TYPE_SWITCH, &si.input_on_focus, "input_on_focus" }, - { TYPE_SWITCH, &si.prefer_aga_graphics, "prefer_aga_graphics" }, - { TYPE_SWITCH, &si.game_speed_extended, "game_speed_extended" }, - { TYPE_INTEGER,&si.game_frame_delay, "game_frame_delay" }, - { TYPE_SWITCH, &si.sp_show_border_elements, "sp_show_border_elements" }, - { TYPE_SWITCH, &si.small_game_graphics, "small_game_graphics" }, - { TYPE_SWITCH, &si.show_snapshot_buttons, "show_snapshot_buttons" }, - { TYPE_STRING, &si.graphics_set, "graphics_set" }, - { TYPE_STRING, &si.sounds_set, "sounds_set" }, - { TYPE_STRING, &si.music_set, "music_set" }, - { TYPE_SWITCH3,&si.override_level_graphics, "override_level_graphics" }, - { TYPE_SWITCH3,&si.override_level_sounds, "override_level_sounds" }, - { TYPE_SWITCH3,&si.override_level_music, "override_level_music" }, - { TYPE_INTEGER,&si.volume_simple, "volume_simple" }, - { TYPE_INTEGER,&si.volume_loops, "volume_loops" }, - { TYPE_INTEGER,&si.volume_music, "volume_music" }, - { TYPE_SWITCH, &si.network_mode, "network_mode" }, - { TYPE_PLAYER, &si.network_player_nr, "network_player" }, - { TYPE_STRING, &si.network_server_hostname, "network_server_hostname" }, - { TYPE_STRING, &si.touch.control_type, "touch.control_type" }, - { TYPE_INTEGER,&si.touch.move_distance, "touch.move_distance" }, - { TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" }, - { TYPE_INTEGER,&si.touch.transparency, "touch.transparency" }, - { TYPE_INTEGER,&si.touch.draw_outlined, "touch.draw_outlined" }, - { TYPE_INTEGER,&si.touch.draw_pressed, "touch.draw_pressed" }, - { TYPE_INTEGER,&si.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize" }, - { TYPE_INTEGER,&si.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" }, - { TYPE_INTEGER,&si.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" }, - { TYPE_INTEGER,&si.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize" }, + { + TYPE_STRING, + &setup.player_name, "player_name" + }, + { + TYPE_SWITCH, + &setup.sound, "sound" + }, + { + TYPE_SWITCH, + &setup.sound_loops, "repeating_sound_loops" + }, + { + TYPE_SWITCH, + &setup.sound_music, "background_music" + }, + { + TYPE_SWITCH, + &setup.sound_simple, "simple_sound_effects" + }, + { + TYPE_SWITCH, + &setup.toons, "toons" + }, + { + TYPE_SWITCH, + &setup.scroll_delay, "scroll_delay" + }, + { + TYPE_INTEGER, + &setup.scroll_delay_value, "scroll_delay_value" + }, + { + TYPE_STRING, + &setup.engine_snapshot_mode, "engine_snapshot_mode" + }, + { + TYPE_INTEGER, + &setup.engine_snapshot_memory, "engine_snapshot_memory" + }, + { + TYPE_SWITCH, + &setup.fade_screens, "fade_screens" + }, + { + TYPE_SWITCH, + &setup.autorecord, "automatic_tape_recording" + }, + { + TYPE_SWITCH, + &setup.show_titlescreen, "show_titlescreen" + }, + { + TYPE_SWITCH, + &setup.quick_doors, "quick_doors" + }, + { + TYPE_SWITCH, + &setup.team_mode, "team_mode" + }, + { + TYPE_SWITCH, + &setup.handicap, "handicap" + }, + { + TYPE_SWITCH, + &setup.skip_levels, "skip_levels" + }, + { + TYPE_SWITCH, + &setup.increment_levels, "increment_levels" + }, + { + TYPE_SWITCH, + &setup.auto_play_next_level, "auto_play_next_level" + }, + { + TYPE_SWITCH, + &setup.skip_scores_after_game, "skip_scores_after_game" + }, + { + TYPE_SWITCH, + &setup.time_limit, "time_limit" + }, + { + TYPE_SWITCH, + &setup.fullscreen, "fullscreen" + }, + { + TYPE_INTEGER, + &setup.window_scaling_percent, "window_scaling_percent" + }, + { + TYPE_STRING, + &setup.window_scaling_quality, "window_scaling_quality" + }, + { + TYPE_STRING, + &setup.screen_rendering_mode, "screen_rendering_mode" + }, + { + TYPE_STRING, + &setup.vsync_mode, "vsync_mode" + }, + { + TYPE_SWITCH, + &setup.ask_on_escape, "ask_on_escape" + }, + { + TYPE_SWITCH, + &setup.ask_on_escape_editor, "ask_on_escape_editor" + }, + { + TYPE_SWITCH, + &setup.ask_on_game_over, "ask_on_game_over" + }, + { + TYPE_SWITCH, + &setup.quick_switch, "quick_player_switch" + }, + { + TYPE_SWITCH, + &setup.input_on_focus, "input_on_focus" + }, + { + TYPE_SWITCH, + &setup.prefer_aga_graphics, "prefer_aga_graphics" + }, + { + TYPE_SWITCH, + &setup.game_speed_extended, "game_speed_extended" + }, + { + TYPE_INTEGER, + &setup.game_frame_delay, "game_frame_delay" + }, + { + TYPE_SWITCH, + &setup.sp_show_border_elements, "sp_show_border_elements" + }, + { + TYPE_SWITCH, + &setup.small_game_graphics, "small_game_graphics" + }, + { + TYPE_SWITCH, + &setup.show_snapshot_buttons, "show_snapshot_buttons" + }, + { + TYPE_STRING, + &setup.graphics_set, "graphics_set" + }, + { + TYPE_STRING, + &setup.sounds_set, "sounds_set" + }, + { + TYPE_STRING, + &setup.music_set, "music_set" + }, + { + TYPE_SWITCH3, + &setup.override_level_graphics, "override_level_graphics" + }, + { + TYPE_SWITCH3, + &setup.override_level_sounds, "override_level_sounds" + }, + { + TYPE_SWITCH3, + &setup.override_level_music, "override_level_music" + }, + { + TYPE_INTEGER, + &setup.volume_simple, "volume_simple" + }, + { + TYPE_INTEGER, + &setup.volume_loops, "volume_loops" + }, + { + TYPE_INTEGER, + &setup.volume_music, "volume_music" + }, + { + TYPE_SWITCH, + &setup.network_mode, "network_mode" + }, + { + TYPE_PLAYER, + &setup.network_player_nr, "network_player" + }, + { + TYPE_STRING, + &setup.network_server_hostname, "network_server_hostname" + }, + { + TYPE_STRING, + &setup.touch.control_type, "touch.control_type" + }, + { + TYPE_INTEGER, + &setup.touch.move_distance, "touch.move_distance" + }, + { + TYPE_INTEGER, + &setup.touch.drop_distance, "touch.drop_distance" + }, + { + TYPE_INTEGER, + &setup.touch.transparency, "touch.transparency" + }, + { + TYPE_INTEGER, + &setup.touch.draw_outlined, "touch.draw_outlined" + }, + { + TYPE_INTEGER, + &setup.touch.draw_pressed, "touch.draw_pressed" + }, + { + TYPE_INTEGER, + &setup.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize" + }, + { + TYPE_INTEGER, + &setup.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" + }, + { + TYPE_INTEGER, + &setup.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" + }, + { + TYPE_INTEGER, + &setup.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize" + }, }; static struct TokenInfo auto_setup_tokens[] = { - { TYPE_INTEGER,&sasi.editor_zoom_tilesize, "editor.zoom_tilesize" }, + { + TYPE_INTEGER, + &setup.auto_setup.editor_zoom_tilesize, "editor.zoom_tilesize" + }, }; static struct TokenInfo editor_setup_tokens[] = { - { TYPE_SWITCH, &sei.el_classic, "editor.el_classic" }, - { TYPE_SWITCH, &sei.el_custom, "editor.el_custom" }, - { TYPE_SWITCH, &sei.el_user_defined, "editor.el_user_defined" }, - { TYPE_SWITCH, &sei.el_dynamic, "editor.el_dynamic" }, - { TYPE_SWITCH, &sei.el_headlines, "editor.el_headlines" }, - { TYPE_SWITCH, &sei.show_element_token,"editor.show_element_token" }, + { + TYPE_SWITCH, + &setup.editor.el_classic, "editor.el_classic" + }, + { + TYPE_SWITCH, + &setup.editor.el_custom, "editor.el_custom" + }, + { + TYPE_SWITCH, + &setup.editor.el_user_defined, "editor.el_user_defined" + }, + { + TYPE_SWITCH, + &setup.editor.el_dynamic, "editor.el_dynamic" + }, + { + TYPE_SWITCH, + &setup.editor.el_headlines, "editor.el_headlines" + }, + { + TYPE_SWITCH, + &setup.editor.show_element_token, "editor.show_element_token" + }, }; static struct TokenInfo editor_cascade_setup_tokens[] = { - { TYPE_SWITCH, &seci.el_bd, "editor.cascade.el_bd" }, - { TYPE_SWITCH, &seci.el_em, "editor.cascade.el_em" }, - { TYPE_SWITCH, &seci.el_emc, "editor.cascade.el_emc" }, - { TYPE_SWITCH, &seci.el_rnd, "editor.cascade.el_rnd" }, - { TYPE_SWITCH, &seci.el_sb, "editor.cascade.el_sb" }, - { TYPE_SWITCH, &seci.el_sp, "editor.cascade.el_sp" }, - { TYPE_SWITCH, &seci.el_dc, "editor.cascade.el_dc" }, - { TYPE_SWITCH, &seci.el_dx, "editor.cascade.el_dx" }, - { TYPE_SWITCH, &seci.el_mm, "editor.cascade.el_mm" }, - { TYPE_SWITCH, &seci.el_df, "editor.cascade.el_df" }, - { TYPE_SWITCH, &seci.el_chars, "editor.cascade.el_chars" }, - { TYPE_SWITCH, &seci.el_steel_chars, "editor.cascade.el_steel_chars" }, - { TYPE_SWITCH, &seci.el_ce, "editor.cascade.el_ce" }, - { TYPE_SWITCH, &seci.el_ge, "editor.cascade.el_ge" }, - { TYPE_SWITCH, &seci.el_ref, "editor.cascade.el_ref" }, - { TYPE_SWITCH, &seci.el_user, "editor.cascade.el_user" }, - { TYPE_SWITCH, &seci.el_dynamic, "editor.cascade.el_dynamic" }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_bd, "editor.cascade.el_bd" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_em, "editor.cascade.el_em" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_emc, "editor.cascade.el_emc" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_rnd, "editor.cascade.el_rnd" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_sb, "editor.cascade.el_sb" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_sp, "editor.cascade.el_sp" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_dc, "editor.cascade.el_dc" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_dx, "editor.cascade.el_dx" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_mm, "editor.cascade.el_mm" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_df, "editor.cascade.el_df" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_chars, "editor.cascade.el_chars" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_steel_chars, "editor.cascade.el_steel_chars" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_ce, "editor.cascade.el_ce" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_ge, "editor.cascade.el_ge" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_ref, "editor.cascade.el_ref" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_user, "editor.cascade.el_user" + }, + { + TYPE_SWITCH, + &setup.editor_cascade.el_dynamic, "editor.cascade.el_dynamic" + }, }; static struct TokenInfo shortcut_setup_tokens[] = { - { TYPE_KEY_X11, &ssi.save_game, "shortcut.save_game" }, - { TYPE_KEY_X11, &ssi.load_game, "shortcut.load_game" }, - { TYPE_KEY_X11, &ssi.toggle_pause, "shortcut.toggle_pause" }, - { TYPE_KEY_X11, &ssi.focus_player[0], "shortcut.focus_player_1" }, - { TYPE_KEY_X11, &ssi.focus_player[1], "shortcut.focus_player_2" }, - { TYPE_KEY_X11, &ssi.focus_player[2], "shortcut.focus_player_3" }, - { TYPE_KEY_X11, &ssi.focus_player[3], "shortcut.focus_player_4" }, - { TYPE_KEY_X11, &ssi.focus_player_all,"shortcut.focus_player_all" }, - { TYPE_KEY_X11, &ssi.tape_eject, "shortcut.tape_eject" }, - { TYPE_KEY_X11, &ssi.tape_extra, "shortcut.tape_extra" }, - { TYPE_KEY_X11, &ssi.tape_stop, "shortcut.tape_stop" }, - { TYPE_KEY_X11, &ssi.tape_pause, "shortcut.tape_pause" }, - { TYPE_KEY_X11, &ssi.tape_record, "shortcut.tape_record" }, - { TYPE_KEY_X11, &ssi.tape_play, "shortcut.tape_play" }, - { TYPE_KEY_X11, &ssi.sound_simple, "shortcut.sound_simple" }, - { TYPE_KEY_X11, &ssi.sound_loops, "shortcut.sound_loops" }, - { TYPE_KEY_X11, &ssi.sound_music, "shortcut.sound_music" }, - { TYPE_KEY_X11, &ssi.snap_left, "shortcut.snap_left" }, - { TYPE_KEY_X11, &ssi.snap_right, "shortcut.snap_right" }, - { TYPE_KEY_X11, &ssi.snap_up, "shortcut.snap_up" }, - { TYPE_KEY_X11, &ssi.snap_down, "shortcut.snap_down" }, + { + TYPE_KEY_X11, + &setup.shortcut.save_game, "shortcut.save_game" + }, + { + TYPE_KEY_X11, + &setup.shortcut.load_game, "shortcut.load_game" + }, + { + TYPE_KEY_X11, + &setup.shortcut.toggle_pause, "shortcut.toggle_pause" + }, + { + TYPE_KEY_X11, + &setup.shortcut.focus_player[0], "shortcut.focus_player_1" + }, + { + TYPE_KEY_X11, + &setup.shortcut.focus_player[1], "shortcut.focus_player_2" + }, + { + TYPE_KEY_X11, + &setup.shortcut.focus_player[2], "shortcut.focus_player_3" + }, + { + TYPE_KEY_X11, + &setup.shortcut.focus_player[3], "shortcut.focus_player_4" + }, + { + TYPE_KEY_X11, + &setup.shortcut.focus_player_all, "shortcut.focus_player_all" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_eject, "shortcut.tape_eject" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_extra, "shortcut.tape_extra" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_stop, "shortcut.tape_stop" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_pause, "shortcut.tape_pause" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_record, "shortcut.tape_record" + }, + { + TYPE_KEY_X11, + &setup.shortcut.tape_play, "shortcut.tape_play" + }, + { + TYPE_KEY_X11, + &setup.shortcut.sound_simple, "shortcut.sound_simple" + }, + { + TYPE_KEY_X11, + &setup.shortcut.sound_loops, "shortcut.sound_loops" + }, + { + TYPE_KEY_X11, + &setup.shortcut.sound_music, "shortcut.sound_music" + }, + { + TYPE_KEY_X11, + &setup.shortcut.snap_left, "shortcut.snap_left" + }, + { + TYPE_KEY_X11, + &setup.shortcut.snap_right, "shortcut.snap_right" + }, + { + TYPE_KEY_X11, + &setup.shortcut.snap_up, "shortcut.snap_up" + }, + { + TYPE_KEY_X11, + &setup.shortcut.snap_down, "shortcut.snap_down" + }, }; +static struct SetupInputInfo setup_input; static struct TokenInfo player_setup_tokens[] = { - { TYPE_BOOLEAN, &sii.use_joystick, ".use_joystick" }, - { TYPE_STRING, &sii.joy.device_name, ".joy.device_name" }, - { TYPE_INTEGER, &sii.joy.xleft, ".joy.xleft" }, - { TYPE_INTEGER, &sii.joy.xmiddle, ".joy.xmiddle" }, - { TYPE_INTEGER, &sii.joy.xright, ".joy.xright" }, - { TYPE_INTEGER, &sii.joy.yupper, ".joy.yupper" }, - { TYPE_INTEGER, &sii.joy.ymiddle, ".joy.ymiddle" }, - { TYPE_INTEGER, &sii.joy.ylower, ".joy.ylower" }, - { TYPE_INTEGER, &sii.joy.snap, ".joy.snap_field" }, - { TYPE_INTEGER, &sii.joy.drop, ".joy.place_bomb" }, - { TYPE_KEY_X11, &sii.key.left, ".key.move_left" }, - { TYPE_KEY_X11, &sii.key.right, ".key.move_right" }, - { TYPE_KEY_X11, &sii.key.up, ".key.move_up" }, - { TYPE_KEY_X11, &sii.key.down, ".key.move_down" }, - { TYPE_KEY_X11, &sii.key.snap, ".key.snap_field" }, - { TYPE_KEY_X11, &sii.key.drop, ".key.place_bomb" }, + { + TYPE_BOOLEAN, + &setup_input.use_joystick, ".use_joystick" + }, + { + TYPE_STRING, + &setup_input.joy.device_name, ".joy.device_name" + }, + { + TYPE_INTEGER, + &setup_input.joy.xleft, ".joy.xleft" + }, + { + TYPE_INTEGER, + &setup_input.joy.xmiddle, ".joy.xmiddle" + }, + { + TYPE_INTEGER, + &setup_input.joy.xright, ".joy.xright" + }, + { + TYPE_INTEGER, + &setup_input.joy.yupper, ".joy.yupper" + }, + { + TYPE_INTEGER, + &setup_input.joy.ymiddle, ".joy.ymiddle" + }, + { + TYPE_INTEGER, + &setup_input.joy.ylower, ".joy.ylower" + }, + { + TYPE_INTEGER, + &setup_input.joy.snap, ".joy.snap_field" + }, + { + TYPE_INTEGER, + &setup_input.joy.drop, ".joy.place_bomb" + }, + { + TYPE_KEY_X11, + &setup_input.key.left, ".key.move_left" + }, + { + TYPE_KEY_X11, + &setup_input.key.right, ".key.move_right" + }, + { + TYPE_KEY_X11, + &setup_input.key.up, ".key.move_up" + }, + { + TYPE_KEY_X11, + &setup_input.key.down, ".key.move_down" + }, + { + TYPE_KEY_X11, + &setup_input.key.snap, ".key.snap_field" + }, + { + TYPE_KEY_X11, + &setup_input.key.drop, ".key.place_bomb" + }, }; static struct TokenInfo system_setup_tokens[] = { - { TYPE_STRING, &syi.sdl_videodriver, "system.sdl_videodriver" }, - { TYPE_STRING, &syi.sdl_audiodriver, "system.sdl_audiodriver" }, - { TYPE_INTEGER, &syi.audio_fragment_size,"system.audio_fragment_size" }, + { + TYPE_STRING, + &setup.system.sdl_videodriver, "system.sdl_videodriver" + }, + { + TYPE_STRING, + &setup.system.sdl_audiodriver, "system.sdl_audiodriver" + }, + { + TYPE_INTEGER, + &setup.system.audio_fragment_size, "system.audio_fragment_size" + }, }; static struct TokenInfo internal_setup_tokens[] = { - { TYPE_STRING, &sxi.program_title, "program_title" }, - { TYPE_STRING, &sxi.program_version, "program_version" }, - { TYPE_STRING, &sxi.program_author, "program_author" }, - { TYPE_STRING, &sxi.program_email, "program_email" }, - { TYPE_STRING, &sxi.program_website, "program_website" }, - { TYPE_STRING, &sxi.program_copyright, "program_copyright" }, - { TYPE_STRING, &sxi.program_company, "program_company" }, - { TYPE_STRING, &sxi.program_icon_file, "program_icon_file" }, - { TYPE_STRING, &sxi.default_graphics_set, "default_graphics_set" }, - { TYPE_STRING, &sxi.default_sounds_set, "default_sounds_set" }, - { TYPE_STRING, &sxi.default_music_set, "default_music_set" }, - { TYPE_STRING, &sxi.fallback_graphics_file, "fallback_graphics_file"}, - { TYPE_STRING, &sxi.fallback_sounds_file, "fallback_sounds_file" }, - { TYPE_STRING, &sxi.fallback_music_file, "fallback_music_file" }, - { TYPE_STRING, &sxi.default_level_series, "default_level_series" }, - { TYPE_BOOLEAN,&sxi.choose_from_top_leveldir, "choose_from_top_leveldir" }, - { TYPE_BOOLEAN,&sxi.show_scaling_in_title, "show_scaling_in_title" }, - { TYPE_INTEGER,&sxi.default_window_width, "default_window_width" }, - { TYPE_INTEGER,&sxi.default_window_height, "default_window_height" }, + { + TYPE_STRING, + &setup.internal.program_title, "program_title" + }, + { + TYPE_STRING, + &setup.internal.program_version, "program_version" + }, + { + TYPE_STRING, + &setup.internal.program_author, "program_author" + }, + { + TYPE_STRING, + &setup.internal.program_email, "program_email" + }, + { + TYPE_STRING, + &setup.internal.program_website, "program_website" + }, + { + TYPE_STRING, + &setup.internal.program_copyright, "program_copyright" + }, + { + TYPE_STRING, + &setup.internal.program_company, "program_company" + }, + { + TYPE_STRING, + &setup.internal.program_icon_file, "program_icon_file" + }, + { + TYPE_STRING, + &setup.internal.default_graphics_set, "default_graphics_set" + }, + { + TYPE_STRING, + &setup.internal.default_sounds_set, "default_sounds_set" + }, + { + TYPE_STRING, + &setup.internal.default_music_set, "default_music_set" + }, + { + TYPE_STRING, + &setup.internal.fallback_graphics_file, "fallback_graphics_file" + }, + { + TYPE_STRING, + &setup.internal.fallback_sounds_file, "fallback_sounds_file" + }, + { + TYPE_STRING, + &setup.internal.fallback_music_file, "fallback_music_file" + }, + { + TYPE_STRING, + &setup.internal.default_level_series, "default_level_series" + }, + { + TYPE_INTEGER, + &setup.internal.default_window_width, "default_window_width" + }, + { + TYPE_INTEGER, + &setup.internal.default_window_height, "default_window_height" + }, + { + TYPE_BOOLEAN, + &setup.internal.choose_from_top_leveldir, "choose_from_top_leveldir" + }, + { + TYPE_BOOLEAN, + &setup.internal.show_scaling_in_title, "show_scaling_in_title" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_game, "menu_game" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_editor, "menu_editor" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_graphics, "menu_graphics" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_sound, "menu_sound" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_artwork, "menu_artwork" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_input, "menu_input" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_touch, "menu_touch" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_shortcuts, "menu_shortcuts" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_exit, "menu_exit" + }, + { + TYPE_BOOLEAN, + &setup.internal.menu_save_and_exit, "menu_save_and_exit" + }, }; static struct TokenInfo debug_setup_tokens[] = { - { TYPE_INTEGER, &sdi.frame_delay[0], "debug.frame_delay_0" }, - { TYPE_INTEGER, &sdi.frame_delay[1], "debug.frame_delay_1" }, - { TYPE_INTEGER, &sdi.frame_delay[2], "debug.frame_delay_2" }, - { TYPE_INTEGER, &sdi.frame_delay[3], "debug.frame_delay_3" }, - { TYPE_INTEGER, &sdi.frame_delay[4], "debug.frame_delay_4" }, - { TYPE_INTEGER, &sdi.frame_delay[5], "debug.frame_delay_5" }, - { TYPE_INTEGER, &sdi.frame_delay[6], "debug.frame_delay_6" }, - { TYPE_INTEGER, &sdi.frame_delay[7], "debug.frame_delay_7" }, - { TYPE_INTEGER, &sdi.frame_delay[8], "debug.frame_delay_8" }, - { TYPE_INTEGER, &sdi.frame_delay[9], "debug.frame_delay_9" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[0], "debug.key.frame_delay_0" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[1], "debug.key.frame_delay_1" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[2], "debug.key.frame_delay_2" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[3], "debug.key.frame_delay_3" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[4], "debug.key.frame_delay_4" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[5], "debug.key.frame_delay_5" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[6], "debug.key.frame_delay_6" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[7], "debug.key.frame_delay_7" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[8], "debug.key.frame_delay_8" }, - { TYPE_KEY_X11, &sdi.frame_delay_key[9], "debug.key.frame_delay_9" }, - { TYPE_BOOLEAN, &sdi.frame_delay_use_mod_key,"debug.frame_delay.use_mod_key"}, - { TYPE_BOOLEAN, &sdi.frame_delay_game_only, "debug.frame_delay.game_only" }, - { TYPE_BOOLEAN, &sdi.show_frames_per_second, "debug.show_frames_per_second" }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[0], "debug.frame_delay_0" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[1], "debug.frame_delay_1" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[2], "debug.frame_delay_2" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[3], "debug.frame_delay_3" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[4], "debug.frame_delay_4" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[5], "debug.frame_delay_5" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[6], "debug.frame_delay_6" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[7], "debug.frame_delay_7" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[8], "debug.frame_delay_8" + }, + { + TYPE_INTEGER, + &setup.debug.frame_delay[9], "debug.frame_delay_9" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[0], "debug.key.frame_delay_0" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[1], "debug.key.frame_delay_1" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[2], "debug.key.frame_delay_2" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[3], "debug.key.frame_delay_3" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[4], "debug.key.frame_delay_4" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[5], "debug.key.frame_delay_5" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[6], "debug.key.frame_delay_6" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[7], "debug.key.frame_delay_7" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[8], "debug.key.frame_delay_8" + }, + { + TYPE_KEY_X11, + &setup.debug.frame_delay_key[9], "debug.key.frame_delay_9" + }, + { + TYPE_BOOLEAN, + &setup.debug.frame_delay_use_mod_key, "debug.frame_delay.use_mod_key"}, + { + TYPE_BOOLEAN, + &setup.debug.frame_delay_game_only, "debug.frame_delay.game_only" + }, + { + TYPE_BOOLEAN, + &setup.debug.show_frames_per_second, "debug.show_frames_per_second" + }, }; static struct TokenInfo options_setup_tokens[] = { - { TYPE_BOOLEAN, &soi.verbose, "options.verbose" }, + { + TYPE_BOOLEAN, + &setup.options.verbose, "options.verbose" + }, }; static char *get_corrected_login_name(char *login_name) @@ -8882,14 +9410,6 @@ void setHideSetupEntry(void *setup_value) setHashEntry(hide_setup_hash, hide_setup_token, ""); } -static void setHideSetupEntryRaw(char *token_text, void *setup_value_raw) -{ - // !!! DIRTY WORKAROUND; TO BE FIXED AFTER THE MM ENGINE RELEASE !!! - void *setup_value = setup_value_raw - (void *)&si + (void *)&setup; - - setHideSetupEntry(setup_value); -} - boolean hideSetupEntry(void *setup_value) { char *hide_setup_token = getHideSetupToken(setup_value); @@ -8910,7 +9430,7 @@ static void setSetupInfoFromTokenText(SetupFileHash *setup_file_hash, // check if this setup option should be hidden in the setup menu if (token_hide_value != NULL && get_boolean_from_string(token_hide_value)) - setHideSetupEntryRaw(token_text, token_info[token_nr].value); + setHideSetupEntry(token_info[token_nr].value); } static void setSetupInfoFromTokenInfo(SetupFileHash *setup_file_hash, @@ -8931,13 +9451,9 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) if (hide_setup_hash == NULL) hide_setup_hash = newSetupFileHash(); - // global setup - si = setup; for (i = 0; i < ARRAY_SIZE(global_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, global_setup_tokens, i); - setup = si; - // virtual buttons setup setup.touch.grid_initialized = TRUE; for (i = 0; i < 2; i++) { @@ -8976,26 +9492,19 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) } } - // editor setup - sei = setup.editor; for (i = 0; i < ARRAY_SIZE(editor_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, editor_setup_tokens, i); - setup.editor = sei; - // shortcut setup - ssi = setup.shortcut; for (i = 0; i < ARRAY_SIZE(shortcut_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, shortcut_setup_tokens, i); - setup.shortcut = ssi; - // player setup for (pnr = 0; pnr < MAX_PLAYERS; pnr++) { char prefix[30]; sprintf(prefix, "%s%d", TOKEN_STR_PLAYER_PREFIX, pnr + 1); - sii = setup.input[pnr]; + setup_input = setup.input[pnr]; for (i = 0; i < ARRAY_SIZE(player_setup_tokens); i++) { char full_token[100]; @@ -9004,32 +9513,20 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) setSetupInfoFromTokenText(setup_file_hash, player_setup_tokens, i, full_token); } - setup.input[pnr] = sii; + setup.input[pnr] = setup_input; } - // system setup - syi = setup.system; for (i = 0; i < ARRAY_SIZE(system_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, system_setup_tokens, i); - setup.system = syi; - // internal setup - sxi = setup.internal; for (i = 0; i < ARRAY_SIZE(internal_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, internal_setup_tokens, i); - setup.internal = sxi; - // debug setup - sdi = setup.debug; for (i = 0; i < ARRAY_SIZE(debug_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, debug_setup_tokens, i); - setup.debug = sdi; - // options setup - soi = setup.options; for (i = 0; i < ARRAY_SIZE(options_setup_tokens); i++) setSetupInfoFromTokenInfo(setup_file_hash, options_setup_tokens, i); - setup.options = soi; setHideRelatedSetupEntries(); } @@ -9041,13 +9538,10 @@ static void decodeSetupFileHash_AutoSetup(SetupFileHash *setup_file_hash) if (!setup_file_hash) return; - // auto setup - sasi = setup.auto_setup; for (i = 0; i < ARRAY_SIZE(auto_setup_tokens); i++) setSetupInfo(auto_setup_tokens, i, getHashEntry(setup_file_hash, auto_setup_tokens[i].text)); - setup.auto_setup = sasi; } static void decodeSetupFileHash_EditorCascade(SetupFileHash *setup_file_hash) @@ -9057,13 +9551,10 @@ static void decodeSetupFileHash_EditorCascade(SetupFileHash *setup_file_hash) if (!setup_file_hash) return; - // editor cascade setup - seci = setup.editor_cascade; for (i = 0; i < ARRAY_SIZE(editor_cascade_setup_tokens); i++) setSetupInfo(editor_cascade_setup_tokens, i, getHashEntry(setup_file_hash, editor_cascade_setup_tokens[i].text)); - setup.editor_cascade = seci; } void LoadSetupFromFilename(char *filename) @@ -9229,24 +9720,21 @@ void SaveSetup(void) fprintFileHeader(file, SETUP_FILENAME); - // global setup - si = setup; for (i = 0; i < ARRAY_SIZE(global_setup_tokens); i++) { // just to make things nicer :) - if (global_setup_tokens[i].value == &si.sound || - global_setup_tokens[i].value == &si.graphics_set || - global_setup_tokens[i].value == &si.volume_simple || - global_setup_tokens[i].value == &si.network_mode || - global_setup_tokens[i].value == &si.touch.control_type || - global_setup_tokens[i].value == &si.touch.grid_xsize[0] || - global_setup_tokens[i].value == &si.touch.grid_xsize[1]) + if (global_setup_tokens[i].value == &setup.sound || + global_setup_tokens[i].value == &setup.graphics_set || + global_setup_tokens[i].value == &setup.volume_simple || + global_setup_tokens[i].value == &setup.network_mode || + global_setup_tokens[i].value == &setup.touch.control_type || + global_setup_tokens[i].value == &setup.touch.grid_xsize[0] || + global_setup_tokens[i].value == &setup.touch.grid_xsize[1]) fprintf(file, "\n"); fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i)); } - // virtual buttons setup for (i = 0; i < 2; i++) { int grid_xsize = setup.touch.grid_xsize[i]; @@ -9275,19 +9763,14 @@ void SaveSetup(void) } } - // editor setup - sei = setup.editor; fprintf(file, "\n"); for (i = 0; i < ARRAY_SIZE(editor_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(editor_setup_tokens, "", i)); - // shortcut setup - ssi = setup.shortcut; fprintf(file, "\n"); for (i = 0; i < ARRAY_SIZE(shortcut_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(shortcut_setup_tokens, "", i)); - // player setup for (pnr = 0; pnr < MAX_PLAYERS; pnr++) { char prefix[30]; @@ -9295,28 +9778,21 @@ void SaveSetup(void) sprintf(prefix, "%s%d", TOKEN_STR_PLAYER_PREFIX, pnr + 1); fprintf(file, "\n"); - sii = setup.input[pnr]; + setup_input = setup.input[pnr]; for (i = 0; i < ARRAY_SIZE(player_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(player_setup_tokens, prefix, i)); } - // system setup - syi = setup.system; fprintf(file, "\n"); for (i = 0; i < ARRAY_SIZE(system_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(system_setup_tokens, "", i)); - // internal setup // (internal setup values not saved to user setup file) - // debug setup - sdi = setup.debug; fprintf(file, "\n"); for (i = 0; i < ARRAY_SIZE(debug_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(debug_setup_tokens, "", i)); - // options setup - soi = setup.options; fprintf(file, "\n"); for (i = 0; i < ARRAY_SIZE(options_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(options_setup_tokens, "", i)); @@ -9343,7 +9819,6 @@ void SaveSetup_AutoSetup(void) fprintFileHeader(file, AUTOSETUP_FILENAME); - sasi = setup.auto_setup; for (i = 0; i < ARRAY_SIZE(auto_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(auto_setup_tokens, "", i)); @@ -9371,7 +9846,6 @@ void SaveSetup_EditorCascade(void) fprintFileHeader(file, EDITORCASCADE_FILENAME); - seci = setup.editor_cascade; for (i = 0; i < ARRAY_SIZE(editor_cascade_setup_tokens); i++) fprintf(file, "%s\n", getSetupLine(editor_cascade_setup_tokens, "", i)); @@ -9467,6 +9941,399 @@ static int getElementFromToken(char *token) return EL_UNDEFINED; } +void FreeGlobalAnimEventInfo(void) +{ + struct GlobalAnimEventInfo *gaei = &global_anim_event_info; + + if (gaei->event_list == NULL) + return; + + int i; + + for (i = 0; i < gaei->num_event_lists; i++) + { + checked_free(gaei->event_list[i]->event_value); + checked_free(gaei->event_list[i]); + } + + checked_free(gaei->event_list); + + gaei->event_list = NULL; + gaei->num_event_lists = 0; +} + +static int AddGlobalAnimEventList(void) +{ + struct GlobalAnimEventInfo *gaei = &global_anim_event_info; + int list_pos = gaei->num_event_lists++; + + gaei->event_list = checked_realloc(gaei->event_list, gaei->num_event_lists * + sizeof(struct GlobalAnimEventListInfo *)); + + gaei->event_list[list_pos] = + checked_calloc(sizeof(struct GlobalAnimEventListInfo)); + + struct GlobalAnimEventListInfo *gaeli = gaei->event_list[list_pos]; + + gaeli->event_value = NULL; + gaeli->num_event_values = 0; + + return list_pos; +} + +static int AddGlobalAnimEventValue(int list_pos, int event_value) +{ + // do not add empty global animation events + if (event_value == ANIM_EVENT_NONE) + return list_pos; + + // if list position is undefined, create new list + if (list_pos == ANIM_EVENT_UNDEFINED) + list_pos = AddGlobalAnimEventList(); + + struct GlobalAnimEventInfo *gaei = &global_anim_event_info; + struct GlobalAnimEventListInfo *gaeli = gaei->event_list[list_pos]; + int value_pos = gaeli->num_event_values++; + + gaeli->event_value = checked_realloc(gaeli->event_value, + gaeli->num_event_values * sizeof(int *)); + + gaeli->event_value[value_pos] = event_value; + + return list_pos; +} + +int GetGlobalAnimEventValue(int list_pos, int value_pos) +{ + if (list_pos == ANIM_EVENT_UNDEFINED) + return ANIM_EVENT_NONE; + + struct GlobalAnimEventInfo *gaei = &global_anim_event_info; + struct GlobalAnimEventListInfo *gaeli = gaei->event_list[list_pos]; + + return gaeli->event_value[value_pos]; +} + +int GetGlobalAnimEventValueCount(int list_pos) +{ + if (list_pos == ANIM_EVENT_UNDEFINED) + return 0; + + struct GlobalAnimEventInfo *gaei = &global_anim_event_info; + struct GlobalAnimEventListInfo *gaeli = gaei->event_list[list_pos]; + + return gaeli->num_event_values; +} + +// This function checks if a string of the format "string1, string2, ..." +// exactly contains a string . + +static boolean string_has_parameter(char *s, char *s_contained) +{ + char *substring; + + if (s == NULL || s_contained == NULL) + return FALSE; + + if (strlen(s_contained) > strlen(s)) + return FALSE; + + if (strncmp(s, s_contained, strlen(s_contained)) == 0) + { + char next_char = s[strlen(s_contained)]; + + // check if next character is delimiter or whitespace + return (next_char == ',' || next_char == '\0' || + next_char == ' ' || next_char == '\t' ? TRUE : FALSE); + } + + // check if string contains another parameter string after a comma + substring = strchr(s, ','); + if (substring == NULL) // string does not contain a comma + return FALSE; + + // advance string pointer to next character after the comma + substring++; + + // skip potential whitespaces after the comma + while (*substring == ' ' || *substring == '\t') + substring++; + + return string_has_parameter(substring, s_contained); +} + +static int get_anim_parameter_value(char *s) +{ + int event_value[] = + { + ANIM_EVENT_CLICK + }; + char *pattern_1[] = + { + "click:anim_" + }; + char *pattern_2 = ".part_"; + char *matching_char = NULL; + char *s_ptr = s; + int pattern_1_len = 0; + int result = ANIM_EVENT_NONE; + int i; + + for (i = 0; i < ARRAY_SIZE(event_value); i++) + { + matching_char = strstr(s_ptr, pattern_1[i]); + pattern_1_len = strlen(pattern_1[i]); + result = event_value[i]; + + if (matching_char != NULL) + break; + } + + if (matching_char == NULL) + return ANIM_EVENT_NONE; + + s_ptr = matching_char + pattern_1_len; + + // check for main animation number ("anim_X" or "anim_XX") + if (*s_ptr >= '0' && *s_ptr <= '9') + { + int gic_anim_nr = (*s_ptr++ - '0'); + + if (*s_ptr >= '0' && *s_ptr <= '9') + gic_anim_nr = 10 * gic_anim_nr + (*s_ptr++ - '0'); + + if (gic_anim_nr < 1 || gic_anim_nr > MAX_GLOBAL_ANIMS) + return ANIM_EVENT_NONE; + + result |= gic_anim_nr << ANIM_EVENT_ANIM_BIT; + } + else + { + // invalid main animation number specified + + return ANIM_EVENT_NONE; + } + + // check for animation part number ("part_X" or "part_XX") (optional) + if (strPrefix(s_ptr, pattern_2)) + { + s_ptr += strlen(pattern_2); + + if (*s_ptr >= '0' && *s_ptr <= '9') + { + int gic_part_nr = (*s_ptr++ - '0'); + + if (*s_ptr >= '0' && *s_ptr <= '9') + gic_part_nr = 10 * gic_part_nr + (*s_ptr++ - '0'); + + if (gic_part_nr < 1 || gic_part_nr > MAX_GLOBAL_ANIM_PARTS) + return ANIM_EVENT_NONE; + + result |= gic_part_nr << ANIM_EVENT_PART_BIT; + } + else + { + // invalid animation part number specified + + return ANIM_EVENT_NONE; + } + } + + // discard result if next character is neither delimiter nor whitespace + if (!(*s_ptr == ',' || *s_ptr == '\0' || + *s_ptr == ' ' || *s_ptr == '\t')) + return ANIM_EVENT_NONE; + + return result; +} + +static int get_anim_parameter_values(char *s) +{ + int list_pos = ANIM_EVENT_UNDEFINED; + int event_value = ANIM_EVENT_DEFAULT; + + if (string_has_parameter(s, "any")) + event_value |= ANIM_EVENT_ANY; + + if (string_has_parameter(s, "click:self") || + string_has_parameter(s, "click") || + string_has_parameter(s, "self")) + event_value |= ANIM_EVENT_SELF; + + // if animation event found, add it to global animation event list + if (event_value != ANIM_EVENT_NONE) + list_pos = AddGlobalAnimEventValue(list_pos, event_value); + + while (s != NULL) + { + // add optional "click:anim_X" or "click:anim_X.part_X" parameter + event_value = get_anim_parameter_value(s); + + // if animation event found, add it to global animation event list + if (event_value != ANIM_EVENT_NONE) + list_pos = AddGlobalAnimEventValue(list_pos, event_value); + + // continue with next part of the string, starting with next comma + s = strchr(s + 1, ','); + } + + return list_pos; +} + +static int get_anim_action_parameter_value(char *token) +{ + int result = getImageIDFromToken(token); + + if (result == -1) + { + char *gfx_token = getStringCat2("gfx.", token); + + result = getImageIDFromToken(gfx_token); + + checked_free(gfx_token); + } + + if (result == -1) + { + Key key = getKeyFromX11KeyName(token); + + if (key != KSYM_UNDEFINED) + result = -(int)key; + } + + if (result == -1) + result = ANIM_EVENT_ACTION_NONE; + + return result; +} + +int get_parameter_value(char *value_raw, char *suffix, int type) +{ + char *value = getStringToLower(value_raw); + int result = 0; // probably a save default value + + if (strEqual(suffix, ".direction")) + { + result = (strEqual(value, "left") ? MV_LEFT : + strEqual(value, "right") ? MV_RIGHT : + strEqual(value, "up") ? MV_UP : + strEqual(value, "down") ? MV_DOWN : MV_NONE); + } + else if (strEqual(suffix, ".position")) + { + result = (strEqual(value, "left") ? POS_LEFT : + strEqual(value, "right") ? POS_RIGHT : + strEqual(value, "top") ? POS_TOP : + strEqual(value, "upper") ? POS_UPPER : + strEqual(value, "middle") ? POS_MIDDLE : + strEqual(value, "lower") ? POS_LOWER : + strEqual(value, "bottom") ? POS_BOTTOM : + strEqual(value, "any") ? POS_ANY : + strEqual(value, "last") ? POS_LAST : POS_UNDEFINED); + } + else if (strEqual(suffix, ".align")) + { + result = (strEqual(value, "left") ? ALIGN_LEFT : + strEqual(value, "right") ? ALIGN_RIGHT : + strEqual(value, "center") ? ALIGN_CENTER : + strEqual(value, "middle") ? ALIGN_CENTER : ALIGN_DEFAULT); + } + else if (strEqual(suffix, ".valign")) + { + result = (strEqual(value, "top") ? VALIGN_TOP : + strEqual(value, "bottom") ? VALIGN_BOTTOM : + strEqual(value, "middle") ? VALIGN_MIDDLE : + strEqual(value, "center") ? VALIGN_MIDDLE : VALIGN_DEFAULT); + } + else if (strEqual(suffix, ".anim_mode")) + { + result = (string_has_parameter(value, "none") ? ANIM_NONE : + string_has_parameter(value, "loop") ? ANIM_LOOP : + string_has_parameter(value, "linear") ? ANIM_LINEAR : + string_has_parameter(value, "pingpong") ? ANIM_PINGPONG : + string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 : + string_has_parameter(value, "random") ? ANIM_RANDOM : + string_has_parameter(value, "ce_value") ? ANIM_CE_VALUE : + string_has_parameter(value, "ce_score") ? ANIM_CE_SCORE : + string_has_parameter(value, "ce_delay") ? ANIM_CE_DELAY : + string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : + string_has_parameter(value, "vertical") ? ANIM_VERTICAL : + string_has_parameter(value, "centered") ? ANIM_CENTERED : + string_has_parameter(value, "all") ? ANIM_ALL : + ANIM_DEFAULT); + + if (string_has_parameter(value, "once")) + result |= ANIM_ONCE; + + if (string_has_parameter(value, "reverse")) + result |= ANIM_REVERSE; + + if (string_has_parameter(value, "opaque_player")) + result |= ANIM_OPAQUE_PLAYER; + + if (string_has_parameter(value, "static_panel")) + result |= ANIM_STATIC_PANEL; + } + else if (strEqual(suffix, ".init_event") || + strEqual(suffix, ".anim_event")) + { + result = get_anim_parameter_values(value); + } + else if (strEqual(suffix, ".init_event_action") || + strEqual(suffix, ".anim_event_action")) + { + result = get_anim_action_parameter_value(value_raw); + } + else if (strEqual(suffix, ".class")) + { + result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE : + get_hash_from_key(value)); + } + else if (strEqual(suffix, ".style")) + { + result = STYLE_DEFAULT; + + if (string_has_parameter(value, "accurate_borders")) + result |= STYLE_ACCURATE_BORDERS; + + if (string_has_parameter(value, "inner_corners")) + result |= STYLE_INNER_CORNERS; + + if (string_has_parameter(value, "reverse")) + result |= STYLE_REVERSE; + + if (string_has_parameter(value, "passthrough_clicks")) + result |= STYLE_PASSTHROUGH; + + if (string_has_parameter(value, "multiple_actions")) + result |= STYLE_MULTIPLE_ACTIONS; + } + else if (strEqual(suffix, ".fade_mode")) + { + result = (string_has_parameter(value, "none") ? FADE_MODE_NONE : + string_has_parameter(value, "fade") ? FADE_MODE_FADE : + string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : + string_has_parameter(value, "melt") ? FADE_MODE_MELT : + string_has_parameter(value, "curtain") ? FADE_MODE_CURTAIN : + FADE_MODE_DEFAULT); + } + else if (strPrefix(suffix, ".font")) // (may also be ".font_xyz") + { + result = gfx.get_font_from_token_function(value); + } + else // generic parameter of type integer or boolean + { + result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE : + type == TYPE_INTEGER ? get_integer_from_string(value) : + type == TYPE_BOOLEAN ? get_boolean_from_string(value) : + ARG_UNDEFINED_VALUE); + } + + free(value); + + return result; +} + static int get_token_parameter_value(char *token, char *value_raw) { char *suffix; @@ -10263,6 +11130,25 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) } } + // special case: check if network and preview player positions are redefined, + // to compare this later against the main menu level preview being redefined + struct TokenIntPtrInfo menu_config_players[] = + { + { "main.network_players.x", &menu.main.network_players.redefined }, + { "main.network_players.y", &menu.main.network_players.redefined }, + { "main.preview_players.x", &menu.main.preview_players.redefined }, + { "main.preview_players.y", &menu.main.preview_players.redefined }, + { "preview.x", &preview.redefined }, + { "preview.y", &preview.redefined } + }; + + for (i = 0; i < ARRAY_SIZE(menu_config_players); i++) + *menu_config_players[i].value = FALSE; + + for (i = 0; i < ARRAY_SIZE(menu_config_players); i++) + if (getHashEntry(setup_file_hash, menu_config_players[i].token) != NULL) + *menu_config_players[i].value = TRUE; + // read (and overwrite with) values that may be specified in config file for (i = 0; image_config_vars[i].token != NULL; i++) { @@ -11042,30 +11928,26 @@ void CreateLevelSketchImages(void) for (i = 0; i < NUM_FILE_ELEMENTS; i++) { - Bitmap *src_bitmap; - int src_x, src_y; int element = getMappedElement(i); - int graphic = el2edimg(element); char basename1[16]; char basename2[16]; char *filename1; char *filename2; - sprintf(basename1, "%03d.bmp", i); - sprintf(basename2, "%03ds.bmp", i); + sprintf(basename1, "%04d.bmp", i); + sprintf(basename2, "%04ds.bmp", i); filename1 = getPath2(global.create_images_dir, basename1); filename2 = getPath2(global.create_images_dir, basename2); - getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, bitmap1, src_x, src_y, TILEX, TILEY, - 0, 0); + DrawSizedElement(0, 0, element, TILESIZE); + BlitBitmap(drawto, bitmap1, SX, SY, TILEX, TILEY, 0, 0); if (SDL_SaveBMP(bitmap1->surface, filename1) != 0) Error(ERR_EXIT, "cannot save level sketch image file '%s'", filename1); - getMiniGraphicSource(graphic, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, bitmap2, src_x, src_y, MINI_TILEX, MINI_TILEY, 0, 0); + DrawSizedElement(0, 0, element, MINI_TILESIZE); + BlitBitmap(drawto, bitmap2, SX, SY, MINI_TILEX, MINI_TILEY, 0, 0); if (SDL_SaveBMP(bitmap2->surface, filename2) != 0) Error(ERR_EXIT, "cannot save level sketch image file '%s'", filename2); @@ -11073,15 +11955,26 @@ void CreateLevelSketchImages(void) free(filename1); free(filename2); + // create corresponding SQL statements (for normal and small images) + if (i < 1000) + { + printf("insert into phpbb_words values (NULL, '`%03d', '');\n", i, i); + printf("insert into phpbb_words values (NULL, '¸%03d', '');\n", i, i); + } + + printf("insert into phpbb_words values (NULL, '`%04d', '');\n", i, i); + printf("insert into phpbb_words values (NULL, '¸%04d', '');\n", i, i); + + // optional: create content for forum level sketch demonstration post if (options.debug) - printf("%03d `%03d%c", i, i, (i % 10 < 9 ? ' ' : '\n')); + fprintf(stderr, "%03d `%03d%c", i, i, (i % 10 < 9 ? ' ' : '\n')); } FreeBitmap(bitmap1); FreeBitmap(bitmap2); if (options.debug) - printf("\n"); + fprintf(stderr, "\n"); Error(ERR_INFO, "%d normal and small images created", NUM_FILE_ELEMENTS); @@ -11105,7 +11998,7 @@ void CreateCustomElementImages(char *directory) int yoffset_ge = (TILEY * NUM_CUSTOM_ELEMENTS / 16); int i; - SDLInitVideoDisplay(); + InitVideoDefaults(); ReCreateBitmap(&backbuffer, video.width, video.height);