From 91efb4684b4ce1bf7ad1916f85986f59777d4291 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 23 Nov 2022 22:43:11 +0000 Subject: [PATCH] Fixed file-choosing methods not removing file extensions, fixed typo in Puddle envirnment registration --- .../001_Hardcoded data/014_Environment.rb | 6 +- .../010_Data/002_PBS data/015_Trainer.rb | 58 ++++++++++++++++--- Data/Scripts/016_UI/011_UI_Jukebox.rb | 2 +- .../005_AnimEditor_Functions.rb | 11 ++-- .../Scripts/020_Debug/002_Editor_DataTypes.rb | 8 +-- Data/Scripts/020_Debug/003_Editor_Listers.rb | 5 -- 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/Data/Scripts/010_Data/001_Hardcoded data/014_Environment.rb b/Data/Scripts/010_Data/001_Hardcoded data/014_Environment.rb index c7923ac01..9bde07bca 100644 --- a/Data/Scripts/010_Data/001_Hardcoded data/014_Environment.rb +++ b/Data/Scripts/010_Data/001_Hardcoded data/014_Environment.rb @@ -57,9 +57,9 @@ GameData::Environment.register({ }) GameData::Environment.register({ - :id => :Puddle, - :name => _INTL("Puddle"), - :battle_basec => "puddle" + :id => :Puddle, + :name => _INTL("Puddle"), + :battle_base => "puddle" }) GameData::Environment.register({ diff --git a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb index ceebb4044..7192b96ff 100644 --- a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb +++ b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb @@ -13,12 +13,19 @@ module GameData DATA_FILENAME = "trainers.dat" PBS_BASE_FILENAME = "trainers" + # "Pokemon" is specially mentioned in def compile_trainers and def + # write_trainers, and acts as a subheading for a particular Pokémon. SCHEMA = { - "Items" => [:items, "*e", :Item], - "LoseText" => [:lose_text, "q"], - "Pokemon" => [:pokemon, "ev", :Species], # Species, level + "SectionName" => [:id, "esU", :TrainerType], + "Items" => [:items, "*e", :Item], + "LoseText" => [:real_lose_text, "q"], + "Pokemon" => [:pokemon, "ev", :Species] # Species, level + } + # This schema is for definable properties of individual Pokémon (apart from + # species and level which are above). + SUB_SCHEMA = { "Form" => [:form, "u"], - "Name" => [:name, "s"], + "Name" => [:real_name, "s"], "Moves" => [:moves, "*e", :Move], "Ability" => [:ability, "e", :Ability], "AbilityIndex" => [:ability_index, "u"], @@ -38,6 +45,10 @@ module GameData extend ClassMethodsSymbols include InstanceMethods + def self.sub_schema + return SUB_SCHEMA + end + # @param tr_type [Symbol, String] # @param tr_name [String] # @param tr_version [Integer, nil] @@ -75,10 +86,10 @@ module GameData def initialize(hash) @id = hash[:id] @trainer_type = hash[:trainer_type] - @real_name = hash[:name] || "Unnamed" + @real_name = hash[:real_name] || "" @version = hash[:version] || 0 @items = hash[:items] || [] - @real_lose_text = hash[:lose_text] || "..." + @real_lose_text = hash[:real_lose_text] || "..." @pokemon = hash[:pokemon] || [] @pokemon.each do |pkmn| GameData::Stat.each_main do |s| @@ -156,7 +167,7 @@ module GameData end end pkmn.happiness = pkmn_data[:happiness] if pkmn_data[:happiness] - pkmn.name = pkmn_data[:name] if pkmn_data[:name] && !pkmn_data[:name].empty? + pkmn.name = pkmn_data[:real_name] if !nil_or_empty?(pkmn_data[:real_name]) if pkmn_data[:shadowness] pkmn.makeShadow pkmn.shiny = false @@ -166,5 +177,38 @@ module GameData end return trainer end + + alias __orig__get_property_for_PBS get_property_for_PBS unless method_defined?(:__orig__get_property_for_PBS) + def get_property_for_PBS(key, index = 0) + ret = __orig__get_property_for_PBS(key) + case key + when "SectionName" + ret = [@trainer_type, @real_name] if @version == 0 + when "Pokemon" + ret = [@pokemon[index][:species], @pokemon[index][:level]] + end + return ret + end + + def get_pokemon_property_for_PBS(key, index = 0) + return [@pokemon[index][:species], @pokemon[index][:level]] if key == "Pokemon" + ret = @pokemon[index][SUB_SCHEMA[key][0]] + ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0) || ret == "" + case key + when "Gender" + ret = ["male", "female"][ret] if ret + when "IV", "EV" + if ret + new_ret = [] + GameData::Stat.each_main do |s| + new_ret[s.pbs_order] = ret[s.id] if s.pbs_order >= 0 + end + ret = new_ret + end + when "Shiny" + ret = nil if @pokemon[index][:super_shininess] + end + return ret + end end end diff --git a/Data/Scripts/016_UI/011_UI_Jukebox.rb b/Data/Scripts/016_UI/011_UI_Jukebox.rb index a89d10d29..633620660 100644 --- a/Data/Scripts/016_UI/011_UI_Jukebox.rb +++ b/Data/Scripts/016_UI/011_UI_Jukebox.rb @@ -105,7 +105,7 @@ class PokemonJukeboxScreen Dir.glob("*.mid") { |f| files.push(f) } Dir.glob("*.midi") { |f| files.push(f) } } - files.map! { |f| f.chomp(File.extname(f)) } + files.map! { |f| File.basename(f, ".*") } files.uniq! files.sort! { |a, b| a.downcase <=> b.downcase } @scene.pbSetCommands(files, 0) diff --git a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb index 2f0914bbc..70bf6d323 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb @@ -49,7 +49,7 @@ def pbSelectAnim(canvas, animwin) if Input.trigger?(Input::USE) && animfiles.length > 0 filename = cmdwin.commands[cmdwin.index] bitmap = AnimatedBitmap.new("Graphics/Animations/" + filename, ctlwin.value(0)).deanimate - canvas.animation.graphic = File.basename(filename, ".png") + canvas.animation.graphic = File.basename(filename, ".*") canvas.animation.hue = ctlwin.value(0) canvas.animbitmap = bitmap animwin.animbitmap = bitmap @@ -544,11 +544,7 @@ def pbSelectSE(canvas, audio) pbSEStop end if maxsizewindow.changed?(5) # OK - filename = File.basename(filename, ".wav") -# filename = File.basename(filename,".mp3") - filename = File.basename(filename, ".ogg") - filename = File.basename(filename, ".wma") - audio.name = filename + audio.name = File.basename(filename, ".*") audio.volume = maxsizewindow.value(1) audio.pitch = maxsizewindow.value(2) ret = true @@ -583,6 +579,9 @@ def pbSelectBG(canvas, timing) # animfiles.concat(Dir.glob("*.jpeg")) # animfiles.concat(Dir.glob("*.bmp")) } + animfiles.map! { |f| File.basename(f, ".*") } + animfiles.uniq! + animfiles.sort! { |a, b| a.downcase <=> b.downcase } cmdwin = pbListWindow(animfiles, 320) cmdwin.height = 480 cmdwin.opacity = 200 diff --git a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb index 8a5b6d45d..36be2b9a0 100644 --- a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb +++ b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb @@ -359,7 +359,7 @@ end module BGMProperty def self.set(settingname, oldsetting) chosenmap = pbListScreen(settingname, MusicFileLister.new(true, oldsetting)) - return (chosenmap && chosenmap != "") ? chosenmap : oldsetting + return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting end def self.format(value) @@ -372,7 +372,7 @@ end module MEProperty def self.set(settingname, oldsetting) chosenmap = pbListScreen(settingname, MusicFileLister.new(false, oldsetting)) - return (chosenmap && chosenmap != "") ? chosenmap : oldsetting + return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting end def self.format(value) @@ -385,7 +385,7 @@ end module WindowskinProperty def self.set(settingname, oldsetting) chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Windowskins/", oldsetting)) - return (chosenmap && chosenmap != "") ? chosenmap : oldsetting + return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting end def self.format(value) @@ -653,7 +653,7 @@ end module CharacterProperty def self.set(settingname, oldsetting) chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Characters/", oldsetting)) - return (chosenmap && chosenmap != "") ? chosenmap : oldsetting + return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting end def self.format(value) diff --git a/Data/Scripts/020_Debug/003_Editor_Listers.rb b/Data/Scripts/020_Debug/003_Editor_Listers.rb index e00f0fb40..938b92db6 100644 --- a/Data/Scripts/020_Debug/003_Editor_Listers.rb +++ b/Data/Scripts/020_Debug/003_Editor_Listers.rb @@ -148,15 +148,10 @@ class GraphicsLister @commands.clear Dir.chdir(@folder) { Dir.glob("*.png") { |f| @commands.push(f) } - Dir.glob("*.PNG") { |f| @commands.push(f) } Dir.glob("*.gif") { |f| @commands.push(f) } - Dir.glob("*.GIF") { |f| @commands.push(f) } # Dir.glob("*.jpg") { |f| @commands.push(f) } -# Dir.glob("*.JPG") { |f| @commands.push(f) } # Dir.glob("*.jpeg") { |f| @commands.push(f) } -# Dir.glob("*.JPEG") { |f| @commands.push(f) } # Dir.glob("*.bmp") { |f| @commands.push(f) } -# Dir.glob("*.BMP") { |f| @commands.push(f) } } @commands.sort! @commands.length.times do |i|