Split metadata.txt into metadata.txt and map_metadata.txt, fixed bug when writing certain PBS files

This commit is contained in:
Maruno17
2021-10-09 23:34:45 +01:00
parent 166a289a60
commit a090f50bc5
20 changed files with 818 additions and 666 deletions

View File

@@ -235,6 +235,7 @@ module GameData
TrainerType.load
Trainer.load
Metadata.load
PlayerMetadata.load
MapMetadata.load
end
end

View File

@@ -9,14 +9,6 @@ module GameData
attr_reader :wild_capture_ME
attr_reader :surf_BGM
attr_reader :bicycle_BGM
attr_reader :player_A
attr_reader :player_B
attr_reader :player_C
attr_reader :player_D
attr_reader :player_E
attr_reader :player_F
attr_reader :player_G
attr_reader :player_H
DATA = {}
DATA_FILENAME = "metadata.dat"
@@ -29,15 +21,7 @@ module GameData
"TrainerVictoryME" => [5, "s"],
"WildCaptureME" => [6, "s"],
"SurfBGM" => [7, "s"],
"BicycleBGM" => [8, "s"],
"PlayerA" => [9, "esssssss", :TrainerType],
"PlayerB" => [10, "esssssss", :TrainerType],
"PlayerC" => [11, "esssssss", :TrainerType],
"PlayerD" => [12, "esssssss", :TrainerType],
"PlayerE" => [13, "esssssss", :TrainerType],
"PlayerF" => [14, "esssssss", :TrainerType],
"PlayerG" => [15, "esssssss", :TrainerType],
"PlayerH" => [16, "esssssss", :TrainerType]
"BicycleBGM" => [8, "s"]
}
extend ClassMethodsIDNumbers
@@ -52,15 +36,7 @@ module GameData
["TrainerVictoryME", MEProperty, _INTL("Default ME played after winning a Trainer battle.")],
["WildCaptureME", MEProperty, _INTL("Default ME played after catching a Pokémon.")],
["SurfBGM", BGMProperty, _INTL("BGM played while surfing.")],
["BicycleBGM", BGMProperty, _INTL("BGM played while on a bicycle.")],
["PlayerA", PlayerProperty, _INTL("Specifies player A.")],
["PlayerB", PlayerProperty, _INTL("Specifies player B.")],
["PlayerC", PlayerProperty, _INTL("Specifies player C.")],
["PlayerD", PlayerProperty, _INTL("Specifies player D.")],
["PlayerE", PlayerProperty, _INTL("Specifies player E.")],
["PlayerF", PlayerProperty, _INTL("Specifies player F.")],
["PlayerG", PlayerProperty, _INTL("Specifies player G.")],
["PlayerH", PlayerProperty, _INTL("Specifies player H.")]
["BicycleBGM", BGMProperty, _INTL("BGM played while on a bicycle.")]
]
end
@@ -68,20 +44,6 @@ module GameData
return DATA[0]
end
def self.get_player(id)
case id
when 0 then return self.get.player_A
when 1 then return self.get.player_B
when 2 then return self.get.player_C
when 3 then return self.get.player_D
when 4 then return self.get.player_E
when 5 then return self.get.player_F
when 6 then return self.get.player_G
when 7 then return self.get.player_H
end
return nil
end
def initialize(hash)
@id = hash[:id]
@home = hash[:home]
@@ -92,14 +54,6 @@ module GameData
@wild_capture_ME = hash[:wild_capture_ME]
@surf_BGM = hash[:surf_BGM]
@bicycle_BGM = hash[:bicycle_BGM]
@player_A = hash[:player_A]
@player_B = hash[:player_B]
@player_C = hash[:player_C]
@player_D = hash[:player_D]
@player_E = hash[:player_E]
@player_F = hash[:player_F]
@player_G = hash[:player_G]
@player_H = hash[:player_H]
end
def property_from_string(str)
@@ -112,14 +66,6 @@ module GameData
when "WildCaptureME" then return @wild_capture_ME
when "SurfBGM" then return @surf_BGM
when "BicycleBGM" then return @bicycle_BGM
when "PlayerA" then return @player_A
when "PlayerB" then return @player_B
when "PlayerC" then return @player_C
when "PlayerD" then return @player_D
when "PlayerE" then return @player_E
when "PlayerF" then return @player_F
when "PlayerG" then return @player_G
when "PlayerH" then return @player_H
end
return nil
end

View File

@@ -0,0 +1,95 @@
module GameData
class PlayerMetadata
attr_reader :id
attr_reader :trainer_type
attr_reader :walk_charset
DATA = {}
DATA_FILENAME = "player_metadata.dat"
SCHEMA = {
"TrainerType" => [1, "e", :TrainerType],
"WalkCharset" => [2, "s"],
"RunCharset" => [3, "s"],
"CycleCharset" => [4, "s"],
"SurfCharset" => [5, "s"],
"DiveCharset" => [6, "s"],
"FishCharset" => [7, "s"],
"SurfFishCharset" => [8, "s"]
}
extend ClassMethodsIDNumbers
include InstanceMethods
def self.editor_properties
return [
["TrainerType", TrainerTypeProperty, _INTL("Trainer type of this player.")],
["WalkCharset", CharacterProperty, _INTL("Charset used while the player is still or walking.")],
["RunCharset", CharacterProperty, _INTL("Charset used while the player is running. Uses WalkCharset if undefined.")],
["CycleCharset", CharacterProperty, _INTL("Charset used while the player is cycling. Uses RunCharset if undefined.")],
["SurfCharset", CharacterProperty, _INTL("Charset used while the player is surfing. Uses CycleCharset if undefined.")],
["DiveCharset", CharacterProperty, _INTL("Charset used while the player is diving. Uses SurfCharset if undefined.")],
["FishCharset", CharacterProperty, _INTL("Charset used while the player is fishing. Uses WalkCharset if undefined.")],
["SurfFishCharset", CharacterProperty, _INTL("Charset used while the player is fishing while surfing. Uses FishCharset if undefined.")]
]
end
# @param player_id [Integer]
# @return [self, nil]
def self.get(player_id = 1)
validate player_id => Integer
return self::DATA[player_id] if self::DATA.has_key?(player_id)
return self::DATA[1]
end
def initialize(hash)
@id = hash[:id]
@trainer_type = hash[:trainer_type]
@walk_charset = hash[:walk_charset]
@run_charset = hash[:run_charset]
@cycle_charset = hash[:cycle_charset]
@surf_charset = hash[:surf_charset]
@dive_charset = hash[:dive_charset]
@fish_charset = hash[:fish_charset]
@surf_fish_charset = hash[:surf_fish_charset]
end
def run_charset
return @run_charset || @walk_charset
end
def cycle_charset
return @cycle_charset || run_charset
end
def surf_charset
return @surf_charset || cycle_charset
end
def dive_charset
return @dive_charset || surf_charset
end
def fish_charset
return @fish_charset || @walk_charset
end
def surf_fish_charset
return @surf_fish_charset || fish_charset
end
def property_from_string(str)
case str
when "TrainerType" then return @trainer_type
when "WalkCharset" then return @walk_charset
when "RunCharset" then return @run_charset
when "CycleCharset" then return @cycle_charset
when "SurfCharset" then return @surf_charset
when "DiveCharset" then return @dive_charset
when "FishCharset" then return @fish_charset
when "SurfFishCharset" then return @surf_fish_charset
end
return nil
end
end
end