mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Split metadata.txt into metadata.txt and map_metadata.txt, fixed bug when writing certain PBS files
This commit is contained in:
@@ -710,86 +710,143 @@ end
|
||||
#===============================================================================
|
||||
# Metadata editor
|
||||
#===============================================================================
|
||||
def pbMetadataScreen(map_id = 0)
|
||||
def pbMetadataScreen
|
||||
sel_player = -1
|
||||
loop do
|
||||
map_id = pbListScreen(_INTL("SET METADATA"), MapLister.new(map_id, true))
|
||||
break if map_id < 0
|
||||
pbEditMetadata(map_id)
|
||||
sel_player = pbListScreen(_INTL("SET METADATA"), MetadataLister.new(sel_player, true))
|
||||
break if sel_player == -1
|
||||
case sel_player
|
||||
when -2 # Add new player
|
||||
pbEditPlayerMetadata(-1)
|
||||
when 0 # Edit global metadata
|
||||
pbEditMetadata
|
||||
else # Edit player character
|
||||
pbEditPlayerMetadata(sel_player) if sel_player >= 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbEditMetadata(map_id = 0)
|
||||
def pbEditMetadata
|
||||
data = []
|
||||
metadata = GameData::Metadata.get
|
||||
properties = GameData::Metadata.editor_properties
|
||||
properties.each do |property|
|
||||
data.push(metadata.property_from_string(property[0]))
|
||||
end
|
||||
if pbPropertyList(_INTL("Global Metadata"), data, properties, true)
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => 0,
|
||||
:home => data[0],
|
||||
:wild_battle_BGM => data[1],
|
||||
:trainer_battle_BGM => data[2],
|
||||
:wild_victory_ME => data[3],
|
||||
:trainer_victory_ME => data[4],
|
||||
:wild_capture_ME => data[5],
|
||||
:surf_BGM => data[6],
|
||||
:bicycle_BGM => data[7]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::Metadata.register(metadata_hash)
|
||||
GameData::Metadata.save
|
||||
Compiler.write_metadata
|
||||
end
|
||||
end
|
||||
|
||||
def pbEditPlayerMetadata(player_id = 1)
|
||||
metadata = nil
|
||||
if player_id < 1
|
||||
# Adding new player character; get lowest unused player character ID
|
||||
ids = GameData::PlayerMetadata.keys
|
||||
1.upto(ids.max + 1) do |i|
|
||||
next if ids.include?(i)
|
||||
player_id = i
|
||||
break
|
||||
end
|
||||
metadata = GameData::PlayerMetadata.new({:id => player_id})
|
||||
elsif !GameData::PlayerMetadata.exists?(player_id)
|
||||
pbMessage(_INTL("Metadata for player character {1} was not found.", player_id))
|
||||
return
|
||||
end
|
||||
data = []
|
||||
metadata = GameData::PlayerMetadata.try_get(player_id) if metadata.nil?
|
||||
properties = GameData::PlayerMetadata.editor_properties
|
||||
properties.each do |property|
|
||||
data.push(metadata.property_from_string(property[0]))
|
||||
end
|
||||
if pbPropertyList(_INTL("Player {1}", metadata.id), data, properties, true)
|
||||
# Construct player metadata hash
|
||||
metadata_hash = {
|
||||
:id => player_id,
|
||||
:trainer_type => data[0],
|
||||
:walk_charset => data[1],
|
||||
:run_charset => data[2],
|
||||
:cycle_charset => data[3],
|
||||
:surf_charset => data[4],
|
||||
:dive_charset => data[5],
|
||||
:fish_charset => data[6],
|
||||
:surf_fish_charset => data[7],
|
||||
}
|
||||
# Add player metadata's data to records
|
||||
GameData::PlayerMetadata.register(metadata_hash)
|
||||
GameData::PlayerMetadata.save
|
||||
Compiler.write_metadata
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Map metadata editor
|
||||
#===============================================================================
|
||||
def pbMapMetadataScreen(map_id = 0)
|
||||
loop do
|
||||
map_id = pbListScreen(_INTL("SET METADATA"), MapLister.new(map_id))
|
||||
break if map_id < 0
|
||||
(map_id == 0) ? pbEditMetadata : pbEditMetadata(map_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pbEditMapMetadata(map_id)
|
||||
mapinfos = pbLoadMapInfos
|
||||
data = []
|
||||
if map_id == 0 # Global metadata
|
||||
map_name = _INTL("Global Metadata")
|
||||
metadata = GameData::Metadata.get
|
||||
properties = GameData::Metadata.editor_properties
|
||||
else # Map metadata
|
||||
map_name = mapinfos[map_id].name
|
||||
metadata = GameData::MapMetadata.try_get(map_id)
|
||||
metadata = GameData::Metadata.new({}) if !metadata
|
||||
properties = GameData::MapMetadata.editor_properties
|
||||
end
|
||||
map_name = mapinfos[map_id].name
|
||||
metadata = GameData::MapMetadata.try_get(map_id)
|
||||
metadata = GameData::MapMetadata.new({:id => map_id}) if !metadata
|
||||
properties = GameData::MapMetadata.editor_properties
|
||||
properties.each do |property|
|
||||
data.push(metadata.property_from_string(property[0]))
|
||||
end
|
||||
if pbPropertyList(map_name, data, properties, true)
|
||||
if map_id == 0 # Global metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:home => data[0],
|
||||
:wild_battle_BGM => data[1],
|
||||
:trainer_battle_BGM => data[2],
|
||||
:wild_victory_ME => data[3],
|
||||
:trainer_victory_ME => data[4],
|
||||
:wild_capture_ME => data[5],
|
||||
:surf_BGM => data[6],
|
||||
:bicycle_BGM => data[7],
|
||||
:player_A => data[8],
|
||||
:player_B => data[9],
|
||||
:player_C => data[10],
|
||||
:player_D => data[11],
|
||||
:player_E => data[12],
|
||||
:player_F => data[13],
|
||||
:player_G => data[14],
|
||||
:player_H => data[15]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::Metadata.register(metadata_hash)
|
||||
GameData::Metadata.save
|
||||
else # Map metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:outdoor_map => data[0],
|
||||
:announce_location => data[1],
|
||||
:can_bicycle => data[2],
|
||||
:always_bicycle => data[3],
|
||||
:teleport_destination => data[4],
|
||||
:weather => data[5],
|
||||
:town_map_position => data[6],
|
||||
:dive_map_id => data[7],
|
||||
:dark_map => data[8],
|
||||
:safari_map => data[9],
|
||||
:snap_edges => data[10],
|
||||
:random_dungeon => data[11],
|
||||
:battle_background => data[12],
|
||||
:wild_battle_BGM => data[13],
|
||||
:trainer_battle_BGM => data[14],
|
||||
:wild_victory_ME => data[15],
|
||||
:trainer_victory_ME => data[16],
|
||||
:wild_capture_ME => data[17],
|
||||
:town_map_size => data[18],
|
||||
:battle_environment => data[19],
|
||||
:flags => data[20]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
GameData::MapMetadata.save
|
||||
end
|
||||
Compiler.write_metadata
|
||||
# Construct map metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:outdoor_map => data[0],
|
||||
:announce_location => data[1],
|
||||
:can_bicycle => data[2],
|
||||
:always_bicycle => data[3],
|
||||
:teleport_destination => data[4],
|
||||
:weather => data[5],
|
||||
:town_map_position => data[6],
|
||||
:dive_map_id => data[7],
|
||||
:dark_map => data[8],
|
||||
:safari_map => data[9],
|
||||
:snap_edges => data[10],
|
||||
:random_dungeon => data[11],
|
||||
:battle_background => data[12],
|
||||
:wild_battle_BGM => data[13],
|
||||
:trainer_battle_BGM => data[14],
|
||||
:wild_victory_ME => data[15],
|
||||
:trainer_victory_ME => data[16],
|
||||
:wild_capture_ME => data[17],
|
||||
:town_map_size => data[18],
|
||||
:battle_environment => data[19],
|
||||
:flags => data[20]
|
||||
}
|
||||
# Add map metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
GameData::MapMetadata.save
|
||||
Compiler.write_map_metadata
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ class MapScreenScene
|
||||
end
|
||||
|
||||
def removeOldConnections(ret, mapid)
|
||||
ret.delete_if { |conn| conn[0] == mapid || conn[3] == mapid}
|
||||
ret.delete_if { |conn| conn[0] == mapid || conn[3] == mapid }
|
||||
end
|
||||
|
||||
# Returns the maps within _keys_ that are directly connected to this map, _map_.
|
||||
@@ -385,7 +385,7 @@ class MapScreenScene
|
||||
end
|
||||
|
||||
def onDoubleClick(map_id)
|
||||
pbEditMetadata(map_id) if map_id > 0
|
||||
pbEditMapMetadata(map_id) if map_id > 0
|
||||
end
|
||||
|
||||
def onClick(mapid,x,y)
|
||||
|
||||
@@ -663,30 +663,6 @@ end
|
||||
|
||||
|
||||
|
||||
module PlayerProperty
|
||||
def self.set(settingname,oldsetting)
|
||||
oldsetting = [nil,"xxx","xxx","xxx","xxx","xxx","xxx","xxx"] if !oldsetting
|
||||
properties = [
|
||||
[_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Trainer type of this player.")],
|
||||
[_INTL("Walking"), CharacterProperty, _INTL("Walking character sprite.")],
|
||||
[_INTL("Cycling"), CharacterProperty, _INTL("Cycling character sprite.")],
|
||||
[_INTL("Surfing"), CharacterProperty, _INTL("Surfing character sprite.")],
|
||||
[_INTL("Running"), CharacterProperty, _INTL("Running character sprite.")],
|
||||
[_INTL("Diving"), CharacterProperty, _INTL("Diving character sprite.")],
|
||||
[_INTL("Fishing"), CharacterProperty, _INTL("Fishing character sprite.")],
|
||||
[_INTL("Surf-Fishing"), CharacterProperty, _INTL("Fishing while surfing character sprite.")]
|
||||
]
|
||||
pbPropertyList(settingname,oldsetting,properties,false)
|
||||
return oldsetting
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return value.inspect
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module MapSizeProperty
|
||||
def self.set(settingname,oldsetting)
|
||||
oldsetting = [0,""] if !oldsetting
|
||||
|
||||
@@ -808,24 +808,22 @@ DebugMenuCommands.register("setplayer", {
|
||||
"name" => _INTL("Set Player Character"),
|
||||
"description" => _INTL("Edit the player's character, as defined in \"metadata.txt\"."),
|
||||
"effect" => proc {
|
||||
limit = 0
|
||||
for i in 0...8
|
||||
meta = GameData::Metadata.get_player(i)
|
||||
next if meta
|
||||
limit = i
|
||||
index = 0
|
||||
cmds = []
|
||||
ids = []
|
||||
GameData::PlayerMetadata.each do |player|
|
||||
index = cmds.length if player.id == $Trainer.character_ID
|
||||
cmds.push(player.id.to_s)
|
||||
ids.push(player.id)
|
||||
end
|
||||
if cmds.length == 1
|
||||
pbMessage(_INTL("There is only one player character defined."))
|
||||
break
|
||||
end
|
||||
if limit <= 1
|
||||
pbMessage(_INTL("There is only one player defined."))
|
||||
else
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, limit - 1)
|
||||
params.setDefaultValue($Trainer.character_ID)
|
||||
newid = pbMessageChooseNumber(_INTL("Choose the new player character."), params)
|
||||
if newid != $Trainer.character_ID
|
||||
pbChangePlayer(newid)
|
||||
pbMessage(_INTL("The player character was changed."))
|
||||
end
|
||||
cmd = pbShowCommands(nil, cmds, -1, index)
|
||||
if cmd >= 0 && cmd != index
|
||||
pbChangePlayer(ids[cmd])
|
||||
pbMessage(_INTL("The player character was changed."))
|
||||
end
|
||||
}
|
||||
})
|
||||
@@ -887,10 +885,20 @@ DebugMenuCommands.register("editorsmenu", {
|
||||
DebugMenuCommands.register("setmetadata", {
|
||||
"parent" => "editorsmenu",
|
||||
"name" => _INTL("Edit Metadata"),
|
||||
"description" => _INTL("Edit global and map metadata."),
|
||||
"description" => _INTL("Edit global metadata and player character metadata."),
|
||||
"always_show" => true,
|
||||
"effect" => proc {
|
||||
pbMetadataScreen(pbDefaultMap)
|
||||
pbMetadataScreen
|
||||
}
|
||||
})
|
||||
|
||||
DebugMenuCommands.register("setmapmetadata", {
|
||||
"parent" => "editorsmenu",
|
||||
"name" => _INTL("Edit Map Metadata"),
|
||||
"description" => _INTL("Edit map metadata."),
|
||||
"always_show" => true,
|
||||
"effect" => proc {
|
||||
pbMapMetadataScreen(pbDefaultMap)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1112,6 +1120,7 @@ DebugMenuCommands.register("createpbs", {
|
||||
"encounters.txt",
|
||||
"items.txt",
|
||||
"map_connections.txt",
|
||||
"map_metadata.txt",
|
||||
"metadata.txt",
|
||||
"moves.txt",
|
||||
"phone.txt",
|
||||
@@ -1135,18 +1144,19 @@ DebugMenuCommands.register("createpbs", {
|
||||
when 4 then Compiler.write_encounters
|
||||
when 5 then Compiler.write_items
|
||||
when 6 then Compiler.write_connections
|
||||
when 7 then Compiler.write_metadata
|
||||
when 8 then Compiler.write_moves
|
||||
when 9 then Compiler.write_phone
|
||||
when 10 then Compiler.write_pokemon
|
||||
when 11 then Compiler.write_pokemon_forms
|
||||
when 12 then Compiler.write_regional_dexes
|
||||
when 13 then Compiler.write_ribbons
|
||||
when 14 then Compiler.write_shadow_movesets
|
||||
when 15 then Compiler.write_town_map
|
||||
when 16 then Compiler.write_trainer_types
|
||||
when 17 then Compiler.write_trainers
|
||||
when 18 then Compiler.write_types
|
||||
when 7 then Compiler.write_map_metadata
|
||||
when 8 then Compiler.write_metadata
|
||||
when 9 then Compiler.write_moves
|
||||
when 10 then Compiler.write_phone
|
||||
when 11 then Compiler.write_pokemon
|
||||
when 12 then Compiler.write_pokemon_forms
|
||||
when 13 then Compiler.write_regional_dexes
|
||||
when 14 then Compiler.write_ribbons
|
||||
when 15 then Compiler.write_shadow_movesets
|
||||
when 16 then Compiler.write_town_map
|
||||
when 17 then Compiler.write_trainer_types
|
||||
when 18 then Compiler.write_trainers
|
||||
when 19 then Compiler.write_types
|
||||
else break
|
||||
end
|
||||
pbMessage(_INTL("File written."))
|
||||
|
||||
@@ -254,6 +254,51 @@ class MusicFileLister
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class MetadataLister
|
||||
def initialize(sel_player_id = -1, new_player = false)
|
||||
@index = 0
|
||||
@commands = []
|
||||
@player_ids = []
|
||||
GameData::PlayerMetadata.each do |player|
|
||||
echoln player
|
||||
@index = @commands.length + 1 if sel_player_id > 0 && player.id == sel_player_id
|
||||
@player_ids.push(player.id)
|
||||
end
|
||||
@new_player = new_player
|
||||
end
|
||||
|
||||
def dispose; end
|
||||
|
||||
def setViewport(viewport); end
|
||||
|
||||
def startIndex
|
||||
return @index
|
||||
end
|
||||
|
||||
def commands
|
||||
@commands.clear
|
||||
@commands.push(_INTL("[GLOBAL METADATA]"))
|
||||
@player_ids.each { |id| @commands.push(_INTL("Player {1}", id)) }
|
||||
@commands.push(_INTL("[ADD NEW PLAYER]")) if @new_player
|
||||
return @commands
|
||||
end
|
||||
|
||||
# Cancel: -1
|
||||
# New player: -2
|
||||
# Global metadata: 0
|
||||
# Player character: 1+ (the player ID itself)
|
||||
def value(index)
|
||||
return index if index < 1
|
||||
return -2 if @new_player && index == @commands.length - 1
|
||||
return @player_ids[index - 1]
|
||||
end
|
||||
|
||||
def refresh(index); end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
Reference in New Issue
Block a user