From 35be8fcf674d5153ce2719583f33b9879298e2d8 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 28 Oct 2024 23:18:57 +0000 Subject: [PATCH] Added support for all three Gen 4 location sign styles, minor tweaks to other code --- Data/Scripts/001_Settings.rb | 10 +- .../002_Save data/005_Game_SaveConversions.rb | 12 ++ Data/Scripts/003_New_UI_Settings.rb | 40 +++++++ .../010_Data/002_PBS data/018_MapMetadata.rb | 4 + .../004_Scene/005_Battle_Scene_Menus.rb | 4 +- .../002_Overworld_Overlays.rb | 111 ++++++++++++++++-- Data/Scripts/012_Overworld/001_Overworld.rb | 26 ++-- .../016b_UI redesign/001_UI_PauseMenu.rb | 2 +- Data/Scripts/016b_UI redesign/005_UI_Party.rb | 11 +- .../016b_UI redesign/012_UI_TrainerCard.rb | 1 - Data/Scripts/016b_UI redesign/013_UI_Load.rb | 110 +++++++++-------- Data/Scripts/016b_UI redesign/014_UI_Save.rb | 58 ++------- PBS/map_metadata.txt | 36 +++++- 13 files changed, 286 insertions(+), 139 deletions(-) diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 7fb6b5de9..5a3e05608 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -88,13 +88,13 @@ module Settings SAFARI_STEPS = 600 # The number of seconds a Bug-Catching Contest lasts for (0=infinite). BUG_CONTEST_TIME = 20 * 60 # 20 minutes - # Pairs of map IDs, where the location signpost isn't shown when moving from - # one of the maps in a pair to the other (and vice versa). Useful for single - # long routes/towns that are spread over multiple maps. + # Pairs of map IDs, where the location sign isn't shown when moving from one + # of the maps in a pair to the other (and vice versa). Useful for single long + # routes/towns that are spread over multiple maps. # e.g. [4,5,16,17,42,43] will be map pairs 4,5 and 16,17 and 42,43. # Moving between two maps that have the exact same name won't show the - # location signpost anyway, so you don't need to list those maps here. - NO_SIGNPOSTS = [] + # location sign anyway, so you don't need to list those maps here. + NO_LOCATION_SIGNS = [] # Whether poisoned Pokémon will lose HP while walking around in the field. POISON_IN_FIELD = (MECHANICS_GENERATION <= 4) # Whether poisoned Pokémon will faint while walking around in the field diff --git a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb index 30ee4ec49..6f2b4dde9 100644 --- a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb +++ b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb @@ -72,6 +72,18 @@ end #=============================================================================== +SaveData.register_conversion(:v22_add_adventure_magic_number) do + essentials_version 22 + display_title "Adding adventure ID" + to_value :game_system do |game_system| + game_system.instance_eval do + @adventure_magic_number ||= rand(2**32) + end + end +end + +#=============================================================================== + SaveData.register_conversion(:v22_add_new_stats) do essentials_version 22 display_title "Adding some more stats" diff --git a/Data/Scripts/003_New_UI_Settings.rb b/Data/Scripts/003_New_UI_Settings.rb index 7d4f31d7e..ce2d4dc2c 100644 --- a/Data/Scripts/003_New_UI_Settings.rb +++ b/Data/Scripts/003_New_UI_Settings.rb @@ -5,4 +5,44 @@ module Settings # :one, :adventure, :multiple SAVE_SLOTS = :multiple + + # Whether the main color of a move's name in the Fight menu in battle matches + # the pixel at coordinate (10,34) in cursor_fight.png for that move's type + # (true), or whether the move name's color is the default black (false). + BATTLE_MOVE_NAME_COLOR_FROM_GRAPHIC = true + + # Whether "Town Map" will show as an option in the pause menu if the player + # has that item in the Bag and doesn't have a Pokégear. + SHOW_TOWN_MAP_IN_PAUSE_MENU = true + + # The filename of a location sign graphic to be used if the map metadata for a + # map doesn't define one. Make this nil to use the default menu windowskin. + DEFAULT_LOCATION_SIGN_GRAPHIC = "Pt default" + # Assigns location sign graphics to text styles (numbers). These are used in + # class LocationWindow to display the text appropriately for the graphic being + # used. Style :none is reserved for the "no graphic" style. A filename may + # instead be an array of [filename, text base color, text shadow color]. + LOCATION_SIGN_GRAPHIC_STYLES = { + :dp => [["DP", Color.new(72, 80, 72), Color.new(144, 160, 160)]], + :hgss => [["HGSS cave", Color.new(232, 232, 232), Color.new(120, 144, 160)], + ["HGSS city", Color.new(56, 64, 72), Color.new(152, 152, 144)], + ["HGSS default", Color.new(48, 64, 72), Color.new(144, 144, 96)], + ["HGSS forest", Color.new(232, 232, 232), Color.new(120, 176, 144)], + ["HGSS lake", Color.new(40, 48, 56), Color.new(104, 144, 192)], + ["HGSS park", Color.new(40, 48, 56), Color.new(120, 136, 152)], + ["HGSS route", Color.new(48, 64, 72), Color.new(136, 136, 104)], + ["HGSS sea", Color.new(216, 240, 248), Color.new(24, 96, 144)], + ["HGSS town", Color.new(48, 56, 64), Color.new(144, 120, 80)]], + :platinum => ["Pt cave", "Pt city", "Pt default", "Pt forest", "Pt lake", + "Pt park", "Pt route", "Pt sea", "Pt town"] + } + + # TODO: Allow renaming a Pokémon from the party screen/summary screen (not + # sure which). Gen 9 feature. + # TODO: Allow forgetting/remembering moves from the summary screen. Gen 9 + # feature. + # TODO: Show usability party balls in the Bag. Maybe? + # TODO: Replace Run with Call in battle; don't have this depend on the Shadow + # type existing? + # TODO: Whether new items go at the top or bottom of its Bag pocket? end diff --git a/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb b/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb index d938d4555..49f953905 100644 --- a/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb +++ b/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb @@ -7,6 +7,7 @@ module GameData attr_reader :real_name attr_reader :outdoor_map attr_reader :announce_location + attr_reader :location_sign attr_reader :can_bicycle attr_reader :always_bicycle attr_reader :teleport_destination @@ -37,6 +38,7 @@ module GameData "Name" => [:real_name, "s"], "Outdoor" => [:outdoor_map, "b"], "ShowArea" => [:announce_location, "b"], + "LocationSign" => [:location_sign, "s"], "Bicycle" => [:can_bicycle, "b"], "BicycleAlways" => [:always_bicycle, "b"], "HealingSpot" => [:teleport_destination, "vuu"], @@ -68,6 +70,7 @@ module GameData ["Name", StringProperty, _INTL("The name of the map, as seen by the player. Can be different to the map's name as seen in RMXP.")], ["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")], ["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")], + ["LocationSign", StringProperty, _INTL("Filename in 'Graphics/UI/Location/' to be used as the location sign.")], ["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")], ["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")], ["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")], @@ -98,6 +101,7 @@ module GameData @real_name = hash[:real_name] @outdoor_map = hash[:outdoor_map] @announce_location = hash[:announce_location] + @location_sign = hash[:location_sign] @can_bicycle = hash[:can_bicycle] @always_bicycle = hash[:always_bicycle] @teleport_destination = hash[:teleport_destination] diff --git a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb index 3c5965de6..eee21b5a4 100644 --- a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb +++ b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb @@ -199,8 +199,6 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase attr_reader :battler attr_reader :shiftMode - GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON = true - # If true, displays graphics from Graphics/UI/Battle/overlay_fight.png # and Graphics/UI/Battle/cursor_fight.png. # If false, just displays text and the command window over the graphic @@ -350,7 +348,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase x = button.x - self.x + (button.src_rect.width / 2) y = button.y - self.y + 14 moveNameBase = TEXT_BASE_COLOR - if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler) + if Settings::BATTLE_MOVE_NAME_COLOR_FROM_GRAPHIC && moves[i].display_type(@battler) # NOTE: This takes a color from a particular pixel in the button # graphic and makes the move name's base color that same color. # The pixel is at coordinates 10,34 in the button box. If you diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb index 6d93c37eb..b0cc0f449 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb @@ -1,20 +1,98 @@ #=============================================================================== -# Location signpost +# Location sign. #=============================================================================== class LocationWindow APPEAR_TIME = 0.4 # In seconds; is also the disappear time LINGER_TIME = 1.6 # In seconds; time during which self is fully visible - def initialize(name) + def initialize(name, graphic_name = nil) + initialize_viewport + initialize_graphic(graphic_name) + initialize_text_window(name) + apply_style(graphic_name) + @current_map = $game_map.map_id + @timer_start = System.uptime + @delayed = !$game_temp.fly_destination.nil? + end + + def initialize_viewport + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + end + + def initialize_graphic(graphic_name) + return if graphic_name.nil? || !pbResolveBitmap("Graphics/UI/Location/#{graphic_name}") + @graphic = Sprite.new(@viewport) + @graphic.bitmap = RPG::Cache.ui("Location/#{graphic_name}") + @graphic.x = 0 + @graphic.y = -@graphic.height + end + + def initialize_text_window(name) @window = Window_AdvancedTextPokemon.new(name) @window.resizeToFit(name, Graphics.width) @window.x = 0 @window.y = -@window.height - @window.viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) - @window.viewport.z = 99999 - @currentmap = $game_map.map_id - @timer_start = System.uptime - @delayed = !$game_temp.fly_destination.nil? + @window.z = 1 + @window.viewport = @viewport + end + + def apply_style(graphic_name) + # Set up values to be used elsewhere + @graphic_offset = [0, 0] + @window_offset = [0, 0] + @y_distance = @window.height + return if graphic_name.nil? + # Determine the style and base/shadow colors + style = :none + base_color = nil + shadow_color = nil + Settings::LOCATION_SIGN_GRAPHIC_STYLES.each_pair do |val, filenames| + filenames.each do |filename| + if filename.is_a?(Array) + next if filename[0] != graphic_name + base_color = filename[1] + shadow_color = filename[2] + else + next if filename != graphic_name + end + style = val + break + end + break if style != :none + end + return if style == :none + # Apply the style + @y_distance = @graphic&.height || @window.height + @window.back_opacity = 0 + case style + when :dp + @window.baseColor = base_color if base_color + @window.shadowColor = shadow_color if shadow_color + @window.text = @window.text # Because the text colors were changed + @window_offset = [8, -10] + @graphic&.dispose + @graphic = Window_AdvancedTextPokemon.new("") + @graphic.setSkin("Graphics/UI/Location/#{graphic_name}") + @graphic.width = @window.width + (@window_offset[0] * 2) - 4 + @graphic.height = 48 + @graphic.x = 0 + @graphic.y = -@graphic.height + @graphic.z = 0 + @graphic.viewport = @viewport + @y_distance = @graphic.height + when :hgss + @window.baseColor = base_color if base_color + @window.shadowColor = shadow_color if shadow_color + @window.width = @graphic.width + @window.text = "" + @window.text + when :platinum + @window.baseColor = base_color || Color.black + @window.shadowColor = shadow_color || Color.new(144, 144, 160) + @window.text = @window.text # Because the text colors were changed + @window_offset = [10, 16] + end + @window.x = @window_offset[0] end def disposed? @@ -22,25 +100,32 @@ class LocationWindow end def dispose + @graphic&.dispose @window.dispose + @viewport.dispose end def update - return if @window.disposed? || $game_temp.fly_destination + return if disposed? || $game_temp.fly_destination if @delayed @timer_start = System.uptime @delayed = false end + @graphic&.update @window.update - if $game_temp.message_window_showing || @currentmap != $game_map.map_id - @window.dispose + if $game_temp.message_window_showing || @current_map != $game_map.map_id + dispose return end if System.uptime - @timer_start >= APPEAR_TIME + LINGER_TIME - @window.y = lerp(0, -@window.height, APPEAR_TIME, @timer_start + APPEAR_TIME + LINGER_TIME, System.uptime) - @window.dispose if @window.y + @window.height <= 0 + y_pos = lerp(0, -@y_distance, APPEAR_TIME, @timer_start + APPEAR_TIME + LINGER_TIME, System.uptime) + @window.y = y_pos + @window_offset[1] + @graphic&.y = y_pos + @graphic_offset[1] + dispose if y_pos <= -@y_distance else - @window.y = lerp(-@window.height, 0, APPEAR_TIME, @timer_start, System.uptime) + y_pos = lerp(-@y_distance, 0, APPEAR_TIME, @timer_start, System.uptime) + @window.y = y_pos + @window_offset[1] + @graphic&.y = y_pos + @graphic_offset[1] end end end diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index 31669e3aa..40d9a70ad 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -319,23 +319,27 @@ EventHandlers.add(:on_map_or_spriteset_change, :show_darkness, } ) -# Show location signpost. -EventHandlers.add(:on_map_or_spriteset_change, :show_location_window, +# Show location sign. +EventHandlers.add(:on_map_or_spriteset_change, :show_location_sign, proc { |scene, map_changed| next if !scene || !scene.spriteset next if !map_changed || !$game_map.metadata&.announce_location - nosignpost = false + no_sign = false if $PokemonGlobal.mapTrail[1] - (Settings::NO_SIGNPOSTS.length / 2).times do |i| - nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] && - Settings::NO_SIGNPOSTS[(2 * i) + 1] == $game_map.map_id - nosignpost = true if Settings::NO_SIGNPOSTS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] && - Settings::NO_SIGNPOSTS[2 * i] == $game_map.map_id - break if nosignpost + (Settings::NO_LOCATION_SIGNS.length / 2).times do |i| + no_sign = true if Settings::NO_LOCATION_SIGNS[2 * i] == $PokemonGlobal.mapTrail[1] && + Settings::NO_LOCATION_SIGNS[(2 * i) + 1] == $game_map.map_id + no_sign = true if Settings::NO_LOCATION_SIGNS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] && + Settings::NO_LOCATION_SIGNS[2 * i] == $game_map.map_id + break if no_sign end - nosignpost = true if $game_map.name == pbGetMapNameFromId($PokemonGlobal.mapTrail[1]) + no_sign = true if $game_map.name == pbGetMapNameFromId($PokemonGlobal.mapTrail[1]) end - scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost + next if no_sign + map_name = $game_map.name + location_sign_graphic = $game_map.metadata&.location_sign || Settings::DEFAULT_LOCATION_SIGN_GRAPHIC + location_sign_graphic = Settings::DEFAULT_LOCATION_SIGN_GRAPHIC + scene.spriteset.addUserSprite(LocationWindow.new(map_name, location_sign_graphic)) } ) diff --git a/Data/Scripts/016b_UI redesign/001_UI_PauseMenu.rb b/Data/Scripts/016b_UI redesign/001_UI_PauseMenu.rb index 6c813339b..087cfe7ee 100644 --- a/Data/Scripts/016b_UI redesign/001_UI_PauseMenu.rb +++ b/Data/Scripts/016b_UI redesign/001_UI_PauseMenu.rb @@ -252,7 +252,7 @@ MenuHandlers.add(:pause_menu, :pokegear, { MenuHandlers.add(:pause_menu, :town_map, { "name" => _INTL("Town Map"), "order" => 40, - "condition" => proc { next !$player.has_pokegear && $bag.has?(:TOWNMAP) }, + "condition" => proc { next Settings::SHOW_TOWN_MAP_IN_PAUSE_MENU && !$player.has_pokegear && $bag.has?(:TOWNMAP) }, "effect" => proc { |menu| pbPlayDecisionSE pbFadeOutIn do diff --git a/Data/Scripts/016b_UI redesign/005_UI_Party.rb b/Data/Scripts/016b_UI redesign/005_UI_Party.rb index 40059c953..406216ccc 100644 --- a/Data/Scripts/016b_UI redesign/005_UI_Party.rb +++ b/Data/Scripts/016b_UI redesign/005_UI_Party.rb @@ -751,7 +751,7 @@ class UI::Party < UI::BaseScreen # :battle_use_item For battle. # :use_item Like :choose_pokemon but with a different help text # :teach_pokemon Like :choose_pokemon but with a different help text - # :choose_entry_order Battle Frontier thing + # :choose_entry_order Battle Frontier thing def initialize(party, mode: :normal) @party = (party.is_a?(Array)) ? party : [party] @mode = mode @@ -880,14 +880,7 @@ class UI::Party < UI::BaseScreen @visuals.refresh_party end - # TODO: Get rid of this method once storage screen and PokemonDebugPartyScreen - # have been rewritten. - def pbRefreshSingle(_party_index) - refresh - end - - # TODO: Get rid of this method once storage screen and PokemonDebugPartyScreen - # have been rewritten. + # TODO: Get rid of this method once ItemHandlers have been rewritten. def pbHardRefresh refresh_party refresh diff --git a/Data/Scripts/016b_UI redesign/012_UI_TrainerCard.rb b/Data/Scripts/016b_UI redesign/012_UI_TrainerCard.rb index 67494c7ab..2dd350274 100644 --- a/Data/Scripts/016b_UI redesign/012_UI_TrainerCard.rb +++ b/Data/Scripts/016b_UI redesign/012_UI_TrainerCard.rb @@ -3,7 +3,6 @@ #=============================================================================== class UI::TrainerCardVisuals < UI::BaseVisuals GRAPHICS_FOLDER = "Trainer Card/" # Subfolder in Graphics/UI - BADGE_SIZE = [32, 32] # [width, height] of a Gym Badge BADGE_SPACING = 16 # Size of gap between adjacent Gym Badges FIRST_BADGE_X = 72 # Left edge of the first Gym Badge diff --git a/Data/Scripts/016b_UI redesign/013_UI_Load.rb b/Data/Scripts/016b_UI redesign/013_UI_Load.rb index ad7b04fbd..e7c9a9234 100644 --- a/Data/Scripts/016b_UI redesign/013_UI_Load.rb +++ b/Data/Scripts/016b_UI redesign/013_UI_Load.rb @@ -1,3 +1,47 @@ +module UI::LoadSaveDataMixin + def load_all_save_data + @save_data = [] + files = SaveData.all_save_files + files.each do |file| + this_save_data = load_save_file(SaveData::DIRECTORY, file) + @save_data.push([file, this_save_data]) + end + end + + def load_save_file(directory, filename) + ret = SaveData.read_from_file(directory + filename) + if !SaveData.valid?(ret) + if File.file?(directory + filename + ".bak") + show_message(_INTL("The save file is corrupt. A backup will be loaded.")) + ret = load_save_file(directory, filename + ".bak") + end + if prompt_corrupted_save_deletion(filename) + delete_save_data(filename) + $PokemonSystem = PokemonSystem.new if self.is_a?(UI::Load) + else + exit + end + end + return ret + end + + def prompt_corrupted_save_deletion(filename) + show_message(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1") + pbPlayDecisionSE + return show_confirm_serious_message(_INTL("Do you want to delete the save file and start anew?")) + end + + def delete_save_data(filename) + begin + SaveData.delete_file(filename) + yield if block_given? + show_message(_INTL("The save file was deleted.")) + rescue SystemCallError + show_message(_INTL("The save file could not be deleted.")) + end + end +end + #=============================================================================== # #=============================================================================== @@ -380,7 +424,7 @@ class UI::LoadVisuals < UI::BaseVisuals # Set the options, and change the language if relevant old_language = $PokemonSystem.language SaveData.load_bootup_values(@save_data[@slot_index][1], true) - if $PokemonSystem.language != old_language + if $PokemonSystem.language != old_language && Settings::LANGUAGES[$PokemonSystem.language] MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1]) full_refresh end @@ -502,6 +546,16 @@ class UI::LoadVisuals < UI::BaseVisuals return :delete_save end return update_interaction(Input::USE) + elsif Input.trigger?(Input::JUMPUP) + if @index != @commands.keys[0] + pbPlayCursorSE + set_index(@commands.keys[0]) + end + elsif Input.trigger?(Input::JUMPDOWN) + if @index != @commands.keys[@commands.length - 1] + pbPlayCursorSE + set_index(@commands.keys[@commands.length - 1]) + end end return nil end @@ -524,8 +578,11 @@ class UI::Load < UI::BaseScreen SCREEN_ID = :load_screen + include UI::LoadSaveDataMixin + def initialize load_all_save_data + determine_default_save_file if $DEBUG && !FileTest.exist?("Game.rgssad") && Settings::SKIP_CONTINUE_SCREEN @disposed = true perform_action((@save_data.empty?) ? :new_game : :continue) @@ -554,49 +611,18 @@ class UI::Load < UI::BaseScreen #----------------------------------------------------------------------------- - # TODO: Move this kind of code into module SaveData. - def load_all_save_data - @save_data = [] + def determine_default_save_file @default_slot_index = 0 last_edited_time = nil - files = SaveData.all_save_files - files.each do |file| - # Load the save file - this_save_data = load_save_file(SaveData::DIRECTORY, file) - @save_data.push([file, this_save_data]) - # Find the most recently edited save file; default to selecting that one - save_time = this_save_data[:stats].real_time_saved || 0 + @save_data.each_with_index do |data, i| + save_time = data[1][:stats].real_time_saved || 0 if !last_edited_time || save_time > last_edited_time last_edited_time = save_time - @default_slot_index = @save_data.length - 1 + @default_slot_index = i end end SaveData.load_bootup_values(@save_data[@default_slot_index][1], true) if !@save_data.empty? - MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1]) - end - - # TODO: Move this kind of code into module SaveData. - def load_save_file(directory, filename) - ret = SaveData.read_from_file(directory + filename) - if !SaveData.valid?(ret) - if File.file?(directory + filename + ".bak") - show_message(_INTL("The save file is corrupt. A backup will be loaded.")) - ret = load_save_file(directory, filename + ".bak") - end - if prompt_corrupted_save_deletion(filename) - delete_save_data(filename) - $PokemonSystem = PokemonSystem.new - else - exit - end - end - return ret - end - - def prompt_corrupted_save_deletion(filename) - show_message(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1") - pbPlayDecisionSE - return show_confirm_serious_message(_INTL("Do you want to delete the save file and start anew?")) + MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1]) if Settings::LANGUAGES[$PokemonSystem.language] end def prompt_save_deletion(filename) @@ -612,16 +638,6 @@ class UI::Load < UI::BaseScreen end end - def delete_save_data(filename) - begin - SaveData.delete_file(filename) - yield if block_given? - show_message(_INTL("The save file was deleted.")) - rescue SystemCallError - show_message(_INTL("The save file could not be deleted.")) - end - end - #----------------------------------------------------------------------------- def full_refresh diff --git a/Data/Scripts/016b_UI redesign/014_UI_Save.rb b/Data/Scripts/016b_UI redesign/014_UI_Save.rb index 8bed7402b..9a81e9d49 100644 --- a/Data/Scripts/016b_UI redesign/014_UI_Save.rb +++ b/Data/Scripts/016b_UI redesign/014_UI_Save.rb @@ -323,12 +323,16 @@ class UI::SaveVisuals < UI::BaseVisuals if @save_data[index][1][:game_system].adventure_magic_number == $game_system.adventure_magic_number save_time = @save_data[index][1][:stats].real_play_time delta_time = ($stats.play_time - save_time).to_i - hour = (delta_time / 60) / 60 - min = (delta_time / 60) % 60 - if hour > 0 - draw_text(_INTL("Play time since save: {1}h {2}m", hour, min), 8, 4) + if delta_time >= 0 + hour = (delta_time / 60) / 60 + min = (delta_time / 60) % 60 + if hour > 0 + draw_text(_INTL("Play time since save: {1}h {2}m", hour, min), 8, 4) + else + draw_text(_INTL("Play time since save: {1}m", min), 8, 4) + end else - draw_text(_INTL("Play time since save: {1}m", min), 8, 4) + draw_text(_INTL("Alternate version of your adventure!"), 8, 4) end else draw_text(_INTL("Different adventure!"), 8, 4) @@ -411,9 +415,12 @@ class UI::Save < UI::BaseScreen SCREEN_ID = :save_screen + include UI::LoadSaveDataMixin + def initialize create_current_save_data load_all_save_data + determine_default_save_file super end @@ -439,14 +446,7 @@ class UI::Save < UI::BaseScreen }] end - def load_all_save_data - # Load the save file - @save_data = [] - files = SaveData.all_save_files - files.each do |file| - this_save_data = load_save_file(SaveData::DIRECTORY, file) - @save_data.push([file, this_save_data]) - end + def determine_default_save_file # Find the save file index matching the current game's filename number if $stats.save_filename_number && $stats.save_filename_number >= 0 expected_filename = SaveData.filename_from_index($stats.save_filename_number) @@ -457,38 +457,6 @@ class UI::Save < UI::BaseScreen end end - def load_save_file(directory, filename) - ret = SaveData.read_from_file(directory + filename) - if !SaveData.valid?(ret) - if File.file?(directory + filename + ".bak") - show_message(_INTL("The save file is corrupt. A backup will be loaded.")) - ret = load_save_file(directory, filename + ".bak") - end - if prompt_corrupted_save_deletion(filename) - delete_save_data(filename) - else - exit - end - end - return ret - end - - def prompt_corrupted_save_deletion(filename) - show_message(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1") - pbPlayDecisionSE - return show_confirm_serious_message(_INTL("Do you want to delete the save file and start anew?")) - end - - def delete_save_data(filename) - begin - SaveData.delete_file(filename) - yield if block_given? - show_message(_INTL("The save file was deleted.")) - rescue SystemCallError - show_message(_INTL("The save file could not be deleted.")) - end - end - def different_adventure?(slot_index) return false if !@save_data[slot_index] return false if !@save_data[slot_index][1][:game_system].adventure_magic_number diff --git a/PBS/map_metadata.txt b/PBS/map_metadata.txt index 6b4c16df5..3c9b6ad80 100644 --- a/PBS/map_metadata.txt +++ b/PBS/map_metadata.txt @@ -7,6 +7,7 @@ Name = Intro Name = Lappet Town Outdoor = true ShowArea = true +LocationSign = Pt town MapPosition = 0,13,12 BattleBack = field #------------------------------- @@ -23,6 +24,7 @@ MapPosition = 0,13,12 Name = Route 1 Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,13,11 BattleBack = field #------------------------------- @@ -34,6 +36,7 @@ MapPosition = 0,13,11 Name = Cedolan City Outdoor = true ShowArea = true +LocationSign = Pt city MapPosition = 0,13,10 MapSize = 2,11 #------------------------------- @@ -97,6 +100,7 @@ MapPosition = 0,13,10 Name = Route 2 Outdoor = true ShowArea = true +LocationSign = Pt route Weather = Rain,100 MapPosition = 0,14,8 BattleBack = field @@ -106,6 +110,7 @@ MapSize = 1,11 Name = Lerucean Town Outdoor = true ShowArea = true +LocationSign = Pt town MapPosition = 0,15,8 #------------------------------- [024] # Lerucean Town Poké Center @@ -129,6 +134,7 @@ MapPosition = 0,15,8 Name = Natural Park Outdoor = true ShowArea = true +LocationSign = Pt park MapPosition = 0,16,8 BattleBack = field Flags = MossRock,BugContest @@ -148,12 +154,15 @@ Flags = BugContestReception Name = Route 3 Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,14,6 BattleBack = field MapSize = 2,1101 #------------------------------- [034] # Ice Cave -Name = Route 3 +Name = Ice Cave +ShowArea = true +LocationSign = Pt cave Bicycle = true MapPosition = 0,15,6 BattleBack = cave1 @@ -164,6 +173,7 @@ Flags = IceRock Name = Ingido Plateau Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,13,6 #------------------------------- [036] # Pokémon League entrance @@ -186,6 +196,7 @@ Flags = DisableBoxLink Name = Route 4 Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,11,6 BattleBack = field MapSize = 2,11 @@ -194,6 +205,7 @@ MapSize = 2,11 Name = Route 4 Outdoor = true ShowArea = true +LocationSign = Pt route BicycleAlways = true MapPosition = 0,11,6 #------------------------------- @@ -201,6 +213,7 @@ MapPosition = 0,11,6 Name = Route 5 Outdoor = true ShowArea = true +LocationSign = Pt route BicycleAlways = true MapPosition = 0,11,7 MapSize = 1,111 @@ -209,6 +222,7 @@ MapSize = 1,111 Name = Route 6 Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,11,10 BattleBack = field MapSize = 2,11 @@ -217,6 +231,7 @@ MapSize = 2,11 Name = Route 6 Outdoor = true ShowArea = true +LocationSign = Pt route BicycleAlways = true MapPosition = 0,11,10 #------------------------------- @@ -229,6 +244,7 @@ MapPosition = 0,12,6 Name = Route 7 Outdoor = true ShowArea = true +LocationSign = Pt route Weather = Rain,0 MapPosition = 0,15,10 BattleBack = rocky @@ -236,7 +252,9 @@ MapSize = 2,11 Environment = Rock #------------------------------- [049] # Rock Cave 1F -Name = Route 7 +Name = Rock Cave +ShowArea = true +LocationSign = Pt cave Bicycle = true MapPosition = 0,16,10 BattleBack = cave1 @@ -244,7 +262,9 @@ Environment = Cave Flags = Magnetic,DistortionWorld #------------------------------- [050] # Rock Cave B1F -Name = Route 7 +Name = Rock Cave +ShowArea = true +LocationSign = Pt cave Bicycle = true MapPosition = 0,16,10 DarkMap = true @@ -253,7 +273,9 @@ Environment = Cave Flags = Magnetic,DistortionWorld #------------------------------- [051] # Dungeon -Name = Route 7 +Name = Rock Cave +ShowArea = true +LocationSign = Pt cave Bicycle = true MapPosition = 0,16,10 Dungeon = true @@ -265,6 +287,7 @@ Flags = Magnetic,DistortionWorld,ScaleWildEncounterLevels Name = Battle Frontier Outdoor = true ShowArea = true +LocationSign = Pt city MapPosition = 0,17,10 #------------------------------- [053] # Battle Frontier Poké Center @@ -335,6 +358,7 @@ Flags = DisableBoxLink Name = Safari Zone Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,12,12 BattleBack = field #------------------------------- @@ -346,6 +370,7 @@ MapPosition = 0,12,12 Name = Safari Zone Outdoor = true ShowArea = true +LocationSign = Pt forest MapPosition = 0,12,12 SafariMap = true BattleBack = forest @@ -355,6 +380,7 @@ Environment = Forest Name = Route 8 Outdoor = true ShowArea = true +LocationSign = Pt route MapPosition = 0,13,13 DiveMap = 70 BattleBack = field @@ -373,6 +399,7 @@ MapPosition = 0,13,13 Name = Berth Island Outdoor = true ShowArea = true +LocationSign = Pt lake Weather = Storm,50 MapPosition = 0,18,17 BattleBack = field @@ -382,6 +409,7 @@ Flags = DistortionWorld Name = Faraday Island Outdoor = true ShowArea = true +LocationSign = Pt lake MapPosition = 0,22,16 BattleBack = field Flags = DistortionWorld