Added "Name" property to map_metadata.txt, fixed map names not being translated in some cases, fixed minor things from a previous commit

This commit is contained in:
Maruno17
2021-10-13 22:55:29 +01:00
parent a5bbd1fb8a
commit 56c9b69c44
11 changed files with 71 additions and 60 deletions

View File

@@ -110,11 +110,6 @@ def pbSetTextMessages
items.concat(choices) items.concat(choices)
MessageTypes.setMapMessagesAsHash(0,items) MessageTypes.setMapMessagesAsHash(0,items)
mapinfos = pbLoadMapInfos mapinfos = pbLoadMapInfos
mapnames=[]
for id in mapinfos.keys
mapnames[id]=mapinfos[id].name
end
MessageTypes.setMessages(MessageTypes::MapNames,mapnames)
for id in mapinfos.keys for id in mapinfos.keys
if Time.now.to_i - t >= 5 if Time.now.to_i - t >= 5
t = Time.now.to_i t = Time.now.to_i

View File

@@ -98,9 +98,7 @@ class Game_Map
def tileset_id; return @map.tileset_id; end def tileset_id; return @map.tileset_id; end
def name def name
ret = pbGetMessage(MessageTypes::MapNames,@map_id) return pbGetMapNameFromId(@map_id)
ret.gsub!(/\\PN/,$Trainer.name) if $Trainer
return ret
end end
def metadata def metadata

View File

@@ -351,9 +351,10 @@ def pbGetBasicMapNameFromId(id)
end end
def pbGetMapNameFromId(id) def pbGetMapNameFromId(id)
map=pbGetBasicMapNameFromId(id) name = pbGetMessage(MessageTypes::MapNames, id)
map.gsub!(/\\PN/,$Trainer.name) if $Trainer name = pbGetBasicMapNameFromId(id) if nil_or_empty?(name)
return map name.gsub!(/\\PN/, $Trainer.name) if $Trainer
return name
end end
def pbCsvField!(str) def pbCsvField!(str)

View File

@@ -1,6 +1,7 @@
module GameData module GameData
class MapMetadata class MapMetadata
attr_reader :id attr_reader :id
attr_reader :real_name
attr_reader :outdoor_map attr_reader :outdoor_map
attr_reader :announce_location attr_reader :announce_location
attr_reader :can_bicycle attr_reader :can_bicycle
@@ -27,27 +28,28 @@ module GameData
DATA_FILENAME = "map_metadata.dat" DATA_FILENAME = "map_metadata.dat"
SCHEMA = { SCHEMA = {
"Outdoor" => [1, "b"], "Name" => [1, "s"],
"ShowArea" => [2, "b"], "Outdoor" => [2, "b"],
"Bicycle" => [3, "b"], "ShowArea" => [3, "b"],
"BicycleAlways" => [4, "b"], "Bicycle" => [4, "b"],
"HealingSpot" => [5, "vuu"], "BicycleAlways" => [5, "b"],
"Weather" => [6, "eu", :Weather], "HealingSpot" => [6, "vuu"],
"MapPosition" => [7, "uuu"], "Weather" => [7, "eu", :Weather],
"DiveMap" => [8, "v"], "MapPosition" => [8, "uuu"],
"DarkMap" => [9, "b"], "DiveMap" => [9, "v"],
"SafariMap" => [10, "b"], "DarkMap" => [10, "b"],
"SnapEdges" => [11, "b"], "SafariMap" => [11, "b"],
"Dungeon" => [12, "b"], "SnapEdges" => [12, "b"],
"BattleBack" => [13, "s"], "Dungeon" => [13, "b"],
"WildBattleBGM" => [14, "s"], "BattleBack" => [14, "s"],
"TrainerBattleBGM" => [15, "s"], "WildBattleBGM" => [15, "s"],
"WildVictoryME" => [16, "s"], "TrainerBattleBGM" => [16, "s"],
"TrainerVictoryME" => [17, "s"], "WildVictoryME" => [17, "s"],
"WildCaptureME" => [18, "s"], "TrainerVictoryME" => [18, "s"],
"MapSize" => [19, "us"], "WildCaptureME" => [19, "s"],
"Environment" => [20, "e", :Environment], "MapSize" => [20, "us"],
"Flags" => [21, "*s"] "Environment" => [21, "e", :Environment],
"Flags" => [22, "*s"]
} }
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers
@@ -55,6 +57,7 @@ module GameData
def self.editor_properties def self.editor_properties
return [ return [
["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.")], ["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.")], ["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")],
["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")], ["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")],
@@ -81,6 +84,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name]
@outdoor_map = hash[:outdoor_map] @outdoor_map = hash[:outdoor_map]
@announce_location = hash[:announce_location] @announce_location = hash[:announce_location]
@can_bicycle = hash[:can_bicycle] @can_bicycle = hash[:can_bicycle]
@@ -106,6 +110,7 @@ module GameData
def property_from_string(str) def property_from_string(str)
case str case str
when "Name" then return @real_name
when "Outdoor" then return @outdoor_map when "Outdoor" then return @outdoor_map
when "ShowArea" then return @announce_location when "ShowArea" then return @announce_location
when "Bicycle" then return @can_bicycle when "Bicycle" then return @can_bicycle
@@ -131,6 +136,11 @@ module GameData
return nil return nil
end end
# @return [String] the translated name of this map
def name
return pbGetMapNameFromId(@id)
end
def has_flag?(flag) def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase } return @flags.any? { |f| f.downcase == flag.downcase }
end end

View File

@@ -146,7 +146,7 @@ EncounterModifier.register(proc { |encounter|
# Look at each roaming Pokémon in turn and decide whether it's possible to # Look at each roaming Pokémon in turn and decide whether it's possible to
# encounter it # encounter it
currentRegion = pbGetCurrentRegion currentRegion = pbGetCurrentRegion
currentMapName = pbGetMessage(MessageTypes::MapNames, $game_map.map_id) currentMapName = $game_map.name
possible_roamers = [] possible_roamers = []
Settings::ROAMING_SPECIES.each_with_index do |data, i| Settings::ROAMING_SPECIES.each_with_index do |data, i|
# data = [species, level, Game Switch, roamer method, battle BGM, area maps hash] # data = [species, level, Game Switch, roamer method, battle BGM, area maps hash]
@@ -167,7 +167,7 @@ EncounterModifier.register(proc { |encounter|
map_metadata = GameData::MapMetadata.try_get(roamerMap) map_metadata = GameData::MapMetadata.try_get(roamerMap)
next if !map_metadata || !map_metadata.town_map_position || next if !map_metadata || !map_metadata.town_map_position ||
map_metadata.town_map_position[0] != currentRegion map_metadata.town_map_position[0] != currentRegion
next if pbGetMessage(MessageTypes::MapNames, roamerMap) != currentMapName next if pbGetMapNameFromId(roamerMap) != currentMapName
end end
# Check whether the roamer's roamer method is currently possible # Check whether the roamer's roamer method is currently possible
next if !pbRoamingMethodAllowed(data[3]) next if !pbRoamingMethodAllowed(data[3])

View File

@@ -279,7 +279,7 @@ end
def pbTrainerMapName(phonenum) def pbTrainerMapName(phonenum)
return "" if !phonenum[6] || phonenum[6] == 0 return "" if !phonenum[6] || phonenum[6] == 0
return pbGetMessage(MessageTypes::MapNames, phonenum[6]) return pbGetMapNameFromId(phonenum[6])
end end
#=============================================================================== #===============================================================================

View File

@@ -47,7 +47,7 @@ class PokemonPhoneScene
2,-18,128,64,@viewport) 2,-18,128,64,@viewport)
@sprites["header"].baseColor = Color.new(248,248,248) @sprites["header"].baseColor = Color.new(248,248,248)
@sprites["header"].shadowColor = Color.new(0,0,0) @sprites["header"].shadowColor = Color.new(0,0,0)
mapname = (@trainers[0][2]) ? pbGetMessage(MessageTypes::MapNames,@trainers[0][2]) : "" mapname = (@trainers[0][2]) ? pbGetMapNameFromId(@trainers[0][2]) : ""
@sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize("", @sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize("",
162,Graphics.height-64,Graphics.width-158,64,@viewport) 162,Graphics.height-64,Graphics.width-158,64,@viewport)
@sprites["bottom"].text = "<ac>"+mapname @sprites["bottom"].text = "<ac>"+mapname
@@ -117,7 +117,7 @@ class PokemonPhoneScene
@sprites["icon"].x = 86-charwidth/8 @sprites["icon"].x = 86-charwidth/8
@sprites["icon"].y = 134-charheight/8 @sprites["icon"].y = 134-charheight/8
@sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4) @sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
mapname=(trainer[2]) ? pbGetMessage(MessageTypes::MapNames,trainer[2]) : "" mapname = (trainer[2]) ? pbGetMapNameFromId(trainer[2]) : ""
@sprites["bottom"].text = "<ac>"+mapname @sprites["bottom"].text = "<ac>"+mapname
for i in 0...@sprites["list"].page_item_max for i in 0...@sprites["list"].page_item_max
@sprites["rematch[#{i}]"].clearBitmaps @sprites["rematch[#{i}]"].clearBitmaps

View File

@@ -803,7 +803,7 @@ def pbMapMetadataScreen(map_id = 0)
loop do loop do
map_id = pbListScreen(_INTL("SET METADATA"), MapLister.new(map_id)) map_id = pbListScreen(_INTL("SET METADATA"), MapLister.new(map_id))
break if map_id < 0 break if map_id < 0
(map_id == 0) ? pbEditMetadata : pbEditMetadata(map_id) (map_id == 0) ? pbEditMetadata : pbEditMapMetadata(map_id)
end end
end end
@@ -821,27 +821,28 @@ def pbEditMapMetadata(map_id)
# Construct map metadata hash # Construct map metadata hash
metadata_hash = { metadata_hash = {
:id => map_id, :id => map_id,
:outdoor_map => data[0], :name => data[0],
:announce_location => data[1], :outdoor_map => data[1],
:can_bicycle => data[2], :announce_location => data[2],
:always_bicycle => data[3], :can_bicycle => data[3],
:teleport_destination => data[4], :always_bicycle => data[4],
:weather => data[5], :teleport_destination => data[5],
:town_map_position => data[6], :weather => data[6],
:dive_map_id => data[7], :town_map_position => data[7],
:dark_map => data[8], :dive_map_id => data[8],
:safari_map => data[9], :dark_map => data[9],
:snap_edges => data[10], :safari_map => data[10],
:random_dungeon => data[11], :snap_edges => data[11],
:battle_background => data[12], :random_dungeon => data[12],
:wild_battle_BGM => data[13], :battle_background => data[13],
:trainer_battle_BGM => data[14], :wild_battle_BGM => data[14],
:wild_victory_ME => data[15], :trainer_battle_BGM => data[15],
:trainer_victory_ME => data[16], :wild_victory_ME => data[16],
:wild_capture_ME => data[17], :trainer_victory_ME => data[17],
:town_map_size => data[18], :wild_capture_ME => data[18],
:battle_environment => data[19], :town_map_size => data[19],
:flags => data[20] :battle_environment => data[20],
:flags => data[21]
} }
# Add map metadata's data to records # Add map metadata's data to records
GameData::MapMetadata.register(metadata_hash) GameData::MapMetadata.register(metadata_hash)

View File

@@ -263,7 +263,6 @@ class MetadataLister
@commands = [] @commands = []
@player_ids = [] @player_ids = []
GameData::PlayerMetadata.each do |player| GameData::PlayerMetadata.each do |player|
echoln player
@index = @commands.length + 1 if sel_player_id > 0 && player.id == sel_player_id @index = @commands.length + 1 if sel_player_id > 0 && player.id == sel_player_id
@player_ids.push(player.id) @player_ids.push(player.id)
end end

View File

@@ -787,6 +787,7 @@ module Compiler
"encounters.txt", "encounters.txt",
"items.txt", "items.txt",
"map_connections.txt", "map_connections.txt",
"map_metadata.txt",
"metadata.txt", "metadata.txt",
"moves.txt", "moves.txt",
"phone.txt", "phone.txt",

View File

@@ -1469,6 +1469,9 @@ module Compiler
#============================================================================= #=============================================================================
def compile_map_metadata(path = "PBS/map_metadata.txt") def compile_map_metadata(path = "PBS/map_metadata.txt")
GameData::MapMetadata::DATA.clear GameData::MapMetadata::DATA.clear
map_infos = pbLoadMapInfos
map_names = []
map_infos.keys.each { |id| map_names[id] = map_infos[id].name }
# Read from PBS file # Read from PBS file
File.open(path, "rb") { |f| File.open(path, "rb") { |f|
FileLineData.file = path # For error reporting FileLineData.file = path # For error reporting
@@ -1490,6 +1493,7 @@ module Compiler
# Construct map metadata hash # Construct map metadata hash
metadata_hash = { metadata_hash = {
:id => map_id, :id => map_id,
:name => contents["Name"],
:outdoor_map => contents["Outdoor"], :outdoor_map => contents["Outdoor"],
:announce_location => contents["ShowArea"], :announce_location => contents["ShowArea"],
:can_bicycle => contents["Bicycle"], :can_bicycle => contents["Bicycle"],
@@ -1514,10 +1518,12 @@ module Compiler
} }
# Add map metadata's data to records # Add map metadata's data to records
GameData::MapMetadata.register(metadata_hash) GameData::MapMetadata.register(metadata_hash)
map_names[map_id] = metadata_hash[:name] if !nil_or_empty?(metadata_hash[:name])
} }
} }
# Save all data # Save all data
GameData::MapMetadata.save GameData::MapMetadata.save
MessageTypes.setMessages(MessageTypes::MapNames, map_names)
Graphics.update Graphics.update
end end