Fixed file-choosing methods not removing file extensions, fixed typo in Puddle envirnment registration

This commit is contained in:
Maruno17
2022-11-23 22:43:11 +00:00
parent bd04112122
commit 91efb4684b
6 changed files with 64 additions and 26 deletions

View File

@@ -57,9 +57,9 @@ GameData::Environment.register({
}) })
GameData::Environment.register({ GameData::Environment.register({
:id => :Puddle, :id => :Puddle,
:name => _INTL("Puddle"), :name => _INTL("Puddle"),
:battle_basec => "puddle" :battle_base => "puddle"
}) })
GameData::Environment.register({ GameData::Environment.register({

View File

@@ -13,12 +13,19 @@ module GameData
DATA_FILENAME = "trainers.dat" DATA_FILENAME = "trainers.dat"
PBS_BASE_FILENAME = "trainers" 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 = { SCHEMA = {
"Items" => [:items, "*e", :Item], "SectionName" => [:id, "esU", :TrainerType],
"LoseText" => [:lose_text, "q"], "Items" => [:items, "*e", :Item],
"Pokemon" => [:pokemon, "ev", :Species], # Species, level "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"], "Form" => [:form, "u"],
"Name" => [:name, "s"], "Name" => [:real_name, "s"],
"Moves" => [:moves, "*e", :Move], "Moves" => [:moves, "*e", :Move],
"Ability" => [:ability, "e", :Ability], "Ability" => [:ability, "e", :Ability],
"AbilityIndex" => [:ability_index, "u"], "AbilityIndex" => [:ability_index, "u"],
@@ -38,6 +45,10 @@ module GameData
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
def self.sub_schema
return SUB_SCHEMA
end
# @param tr_type [Symbol, String] # @param tr_type [Symbol, String]
# @param tr_name [String] # @param tr_name [String]
# @param tr_version [Integer, nil] # @param tr_version [Integer, nil]
@@ -75,10 +86,10 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@trainer_type = hash[:trainer_type] @trainer_type = hash[:trainer_type]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || ""
@version = hash[:version] || 0 @version = hash[:version] || 0
@items = hash[:items] || [] @items = hash[:items] || []
@real_lose_text = hash[:lose_text] || "..." @real_lose_text = hash[:real_lose_text] || "..."
@pokemon = hash[:pokemon] || [] @pokemon = hash[:pokemon] || []
@pokemon.each do |pkmn| @pokemon.each do |pkmn|
GameData::Stat.each_main do |s| GameData::Stat.each_main do |s|
@@ -156,7 +167,7 @@ module GameData
end end
end end
pkmn.happiness = pkmn_data[:happiness] if pkmn_data[:happiness] 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] if pkmn_data[:shadowness]
pkmn.makeShadow pkmn.makeShadow
pkmn.shiny = false pkmn.shiny = false
@@ -166,5 +177,38 @@ module GameData
end end
return trainer return trainer
end 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
end end

View File

@@ -105,7 +105,7 @@ class PokemonJukeboxScreen
Dir.glob("*.mid") { |f| files.push(f) } Dir.glob("*.mid") { |f| files.push(f) }
Dir.glob("*.midi") { |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.uniq!
files.sort! { |a, b| a.downcase <=> b.downcase } files.sort! { |a, b| a.downcase <=> b.downcase }
@scene.pbSetCommands(files, 0) @scene.pbSetCommands(files, 0)

View File

@@ -49,7 +49,7 @@ def pbSelectAnim(canvas, animwin)
if Input.trigger?(Input::USE) && animfiles.length > 0 if Input.trigger?(Input::USE) && animfiles.length > 0
filename = cmdwin.commands[cmdwin.index] filename = cmdwin.commands[cmdwin.index]
bitmap = AnimatedBitmap.new("Graphics/Animations/" + filename, ctlwin.value(0)).deanimate 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.animation.hue = ctlwin.value(0)
canvas.animbitmap = bitmap canvas.animbitmap = bitmap
animwin.animbitmap = bitmap animwin.animbitmap = bitmap
@@ -544,11 +544,7 @@ def pbSelectSE(canvas, audio)
pbSEStop pbSEStop
end end
if maxsizewindow.changed?(5) # OK if maxsizewindow.changed?(5) # OK
filename = File.basename(filename, ".wav") audio.name = File.basename(filename, ".*")
# filename = File.basename(filename,".mp3")
filename = File.basename(filename, ".ogg")
filename = File.basename(filename, ".wma")
audio.name = filename
audio.volume = maxsizewindow.value(1) audio.volume = maxsizewindow.value(1)
audio.pitch = maxsizewindow.value(2) audio.pitch = maxsizewindow.value(2)
ret = true ret = true
@@ -583,6 +579,9 @@ def pbSelectBG(canvas, timing)
# animfiles.concat(Dir.glob("*.jpeg")) # animfiles.concat(Dir.glob("*.jpeg"))
# animfiles.concat(Dir.glob("*.bmp")) # 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 = pbListWindow(animfiles, 320)
cmdwin.height = 480 cmdwin.height = 480
cmdwin.opacity = 200 cmdwin.opacity = 200

View File

@@ -359,7 +359,7 @@ end
module BGMProperty module BGMProperty
def self.set(settingname, oldsetting) def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MusicFileLister.new(true, oldsetting)) chosenmap = pbListScreen(settingname, MusicFileLister.new(true, oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting
end end
def self.format(value) def self.format(value)
@@ -372,7 +372,7 @@ end
module MEProperty module MEProperty
def self.set(settingname, oldsetting) def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MusicFileLister.new(false, oldsetting)) chosenmap = pbListScreen(settingname, MusicFileLister.new(false, oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting
end end
def self.format(value) def self.format(value)
@@ -385,7 +385,7 @@ end
module WindowskinProperty module WindowskinProperty
def self.set(settingname, oldsetting) def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Windowskins/", oldsetting)) chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Windowskins/", oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting
end end
def self.format(value) def self.format(value)
@@ -653,7 +653,7 @@ end
module CharacterProperty module CharacterProperty
def self.set(settingname, oldsetting) def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Characters/", oldsetting)) chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Characters/", oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting return (chosenmap && chosenmap != "") ? File.basename(chosenmap, ".*") : oldsetting
end end
def self.format(value) def self.format(value)

View File

@@ -148,15 +148,10 @@ class GraphicsLister
@commands.clear @commands.clear
Dir.chdir(@folder) { Dir.chdir(@folder) {
Dir.glob("*.png") { |f| @commands.push(f) } 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("*.GIF") { |f| @commands.push(f) }
# Dir.glob("*.jpg") { |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("*.JPEG") { |f| @commands.push(f) }
# Dir.glob("*.bmp") { |f| @commands.push(f) } # Dir.glob("*.bmp") { |f| @commands.push(f) }
# Dir.glob("*.BMP") { |f| @commands.push(f) }
} }
@commands.sort! @commands.sort!
@commands.length.times do |i| @commands.length.times do |i|