mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
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:
@@ -110,11 +110,6 @@ def pbSetTextMessages
|
||||
items.concat(choices)
|
||||
MessageTypes.setMapMessagesAsHash(0,items)
|
||||
mapinfos = pbLoadMapInfos
|
||||
mapnames=[]
|
||||
for id in mapinfos.keys
|
||||
mapnames[id]=mapinfos[id].name
|
||||
end
|
||||
MessageTypes.setMessages(MessageTypes::MapNames,mapnames)
|
||||
for id in mapinfos.keys
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
|
||||
@@ -98,9 +98,7 @@ class Game_Map
|
||||
def tileset_id; return @map.tileset_id; end
|
||||
|
||||
def name
|
||||
ret = pbGetMessage(MessageTypes::MapNames,@map_id)
|
||||
ret.gsub!(/\\PN/,$Trainer.name) if $Trainer
|
||||
return ret
|
||||
return pbGetMapNameFromId(@map_id)
|
||||
end
|
||||
|
||||
def metadata
|
||||
|
||||
@@ -351,9 +351,10 @@ def pbGetBasicMapNameFromId(id)
|
||||
end
|
||||
|
||||
def pbGetMapNameFromId(id)
|
||||
map=pbGetBasicMapNameFromId(id)
|
||||
map.gsub!(/\\PN/,$Trainer.name) if $Trainer
|
||||
return map
|
||||
name = pbGetMessage(MessageTypes::MapNames, id)
|
||||
name = pbGetBasicMapNameFromId(id) if nil_or_empty?(name)
|
||||
name.gsub!(/\\PN/, $Trainer.name) if $Trainer
|
||||
return name
|
||||
end
|
||||
|
||||
def pbCsvField!(str)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module GameData
|
||||
class MapMetadata
|
||||
attr_reader :id
|
||||
attr_reader :real_name
|
||||
attr_reader :outdoor_map
|
||||
attr_reader :announce_location
|
||||
attr_reader :can_bicycle
|
||||
@@ -27,27 +28,28 @@ module GameData
|
||||
DATA_FILENAME = "map_metadata.dat"
|
||||
|
||||
SCHEMA = {
|
||||
"Outdoor" => [1, "b"],
|
||||
"ShowArea" => [2, "b"],
|
||||
"Bicycle" => [3, "b"],
|
||||
"BicycleAlways" => [4, "b"],
|
||||
"HealingSpot" => [5, "vuu"],
|
||||
"Weather" => [6, "eu", :Weather],
|
||||
"MapPosition" => [7, "uuu"],
|
||||
"DiveMap" => [8, "v"],
|
||||
"DarkMap" => [9, "b"],
|
||||
"SafariMap" => [10, "b"],
|
||||
"SnapEdges" => [11, "b"],
|
||||
"Dungeon" => [12, "b"],
|
||||
"BattleBack" => [13, "s"],
|
||||
"WildBattleBGM" => [14, "s"],
|
||||
"TrainerBattleBGM" => [15, "s"],
|
||||
"WildVictoryME" => [16, "s"],
|
||||
"TrainerVictoryME" => [17, "s"],
|
||||
"WildCaptureME" => [18, "s"],
|
||||
"MapSize" => [19, "us"],
|
||||
"Environment" => [20, "e", :Environment],
|
||||
"Flags" => [21, "*s"]
|
||||
"Name" => [1, "s"],
|
||||
"Outdoor" => [2, "b"],
|
||||
"ShowArea" => [3, "b"],
|
||||
"Bicycle" => [4, "b"],
|
||||
"BicycleAlways" => [5, "b"],
|
||||
"HealingSpot" => [6, "vuu"],
|
||||
"Weather" => [7, "eu", :Weather],
|
||||
"MapPosition" => [8, "uuu"],
|
||||
"DiveMap" => [9, "v"],
|
||||
"DarkMap" => [10, "b"],
|
||||
"SafariMap" => [11, "b"],
|
||||
"SnapEdges" => [12, "b"],
|
||||
"Dungeon" => [13, "b"],
|
||||
"BattleBack" => [14, "s"],
|
||||
"WildBattleBGM" => [15, "s"],
|
||||
"TrainerBattleBGM" => [16, "s"],
|
||||
"WildVictoryME" => [17, "s"],
|
||||
"TrainerVictoryME" => [18, "s"],
|
||||
"WildCaptureME" => [19, "s"],
|
||||
"MapSize" => [20, "us"],
|
||||
"Environment" => [21, "e", :Environment],
|
||||
"Flags" => [22, "*s"]
|
||||
}
|
||||
|
||||
extend ClassMethodsIDNumbers
|
||||
@@ -55,6 +57,7 @@ module GameData
|
||||
|
||||
def self.editor_properties
|
||||
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.")],
|
||||
["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.")],
|
||||
@@ -81,6 +84,7 @@ module GameData
|
||||
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@real_name = hash[:name]
|
||||
@outdoor_map = hash[:outdoor_map]
|
||||
@announce_location = hash[:announce_location]
|
||||
@can_bicycle = hash[:can_bicycle]
|
||||
@@ -106,6 +110,7 @@ module GameData
|
||||
|
||||
def property_from_string(str)
|
||||
case str
|
||||
when "Name" then return @real_name
|
||||
when "Outdoor" then return @outdoor_map
|
||||
when "ShowArea" then return @announce_location
|
||||
when "Bicycle" then return @can_bicycle
|
||||
@@ -131,6 +136,11 @@ module GameData
|
||||
return nil
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this map
|
||||
def name
|
||||
return pbGetMapNameFromId(@id)
|
||||
end
|
||||
|
||||
def has_flag?(flag)
|
||||
return @flags.any? { |f| f.downcase == flag.downcase }
|
||||
end
|
||||
|
||||
@@ -146,7 +146,7 @@ EncounterModifier.register(proc { |encounter|
|
||||
# Look at each roaming Pokémon in turn and decide whether it's possible to
|
||||
# encounter it
|
||||
currentRegion = pbGetCurrentRegion
|
||||
currentMapName = pbGetMessage(MessageTypes::MapNames, $game_map.map_id)
|
||||
currentMapName = $game_map.name
|
||||
possible_roamers = []
|
||||
Settings::ROAMING_SPECIES.each_with_index do |data, i|
|
||||
# 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)
|
||||
next if !map_metadata || !map_metadata.town_map_position ||
|
||||
map_metadata.town_map_position[0] != currentRegion
|
||||
next if pbGetMessage(MessageTypes::MapNames, roamerMap) != currentMapName
|
||||
next if pbGetMapNameFromId(roamerMap) != currentMapName
|
||||
end
|
||||
# Check whether the roamer's roamer method is currently possible
|
||||
next if !pbRoamingMethodAllowed(data[3])
|
||||
|
||||
@@ -279,7 +279,7 @@ end
|
||||
|
||||
def pbTrainerMapName(phonenum)
|
||||
return "" if !phonenum[6] || phonenum[6] == 0
|
||||
return pbGetMessage(MessageTypes::MapNames, phonenum[6])
|
||||
return pbGetMapNameFromId(phonenum[6])
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
|
||||
@@ -47,7 +47,7 @@ class PokemonPhoneScene
|
||||
2,-18,128,64,@viewport)
|
||||
@sprites["header"].baseColor = Color.new(248,248,248)
|
||||
@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("",
|
||||
162,Graphics.height-64,Graphics.width-158,64,@viewport)
|
||||
@sprites["bottom"].text = "<ac>"+mapname
|
||||
@@ -117,7 +117,7 @@ class PokemonPhoneScene
|
||||
@sprites["icon"].x = 86-charwidth/8
|
||||
@sprites["icon"].y = 134-charheight/8
|
||||
@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
|
||||
for i in 0...@sprites["list"].page_item_max
|
||||
@sprites["rematch[#{i}]"].clearBitmaps
|
||||
|
||||
@@ -803,7 +803,7 @@ 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)
|
||||
(map_id == 0) ? pbEditMetadata : pbEditMapMetadata(map_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -821,27 +821,28 @@ def pbEditMapMetadata(map_id)
|
||||
# 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]
|
||||
:name => data[0],
|
||||
:outdoor_map => data[1],
|
||||
:announce_location => data[2],
|
||||
:can_bicycle => data[3],
|
||||
:always_bicycle => data[4],
|
||||
:teleport_destination => data[5],
|
||||
:weather => data[6],
|
||||
:town_map_position => data[7],
|
||||
:dive_map_id => data[8],
|
||||
:dark_map => data[9],
|
||||
:safari_map => data[10],
|
||||
:snap_edges => data[11],
|
||||
:random_dungeon => data[12],
|
||||
:battle_background => data[13],
|
||||
:wild_battle_BGM => data[14],
|
||||
:trainer_battle_BGM => data[15],
|
||||
:wild_victory_ME => data[16],
|
||||
:trainer_victory_ME => data[17],
|
||||
:wild_capture_ME => data[18],
|
||||
:town_map_size => data[19],
|
||||
:battle_environment => data[20],
|
||||
:flags => data[21]
|
||||
}
|
||||
# Add map metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
|
||||
@@ -263,7 +263,6 @@ class MetadataLister
|
||||
@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
|
||||
|
||||
@@ -787,6 +787,7 @@ module Compiler
|
||||
"encounters.txt",
|
||||
"items.txt",
|
||||
"map_connections.txt",
|
||||
"map_metadata.txt",
|
||||
"metadata.txt",
|
||||
"moves.txt",
|
||||
"phone.txt",
|
||||
|
||||
@@ -1469,6 +1469,9 @@ module Compiler
|
||||
#=============================================================================
|
||||
def compile_map_metadata(path = "PBS/map_metadata.txt")
|
||||
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
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
@@ -1490,6 +1493,7 @@ module Compiler
|
||||
# Construct map metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:name => contents["Name"],
|
||||
:outdoor_map => contents["Outdoor"],
|
||||
:announce_location => contents["ShowArea"],
|
||||
:can_bicycle => contents["Bicycle"],
|
||||
@@ -1514,10 +1518,12 @@ module Compiler
|
||||
}
|
||||
# Add map metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
map_names[map_id] = metadata_hash[:name] if !nil_or_empty?(metadata_hash[:name])
|
||||
}
|
||||
}
|
||||
# Save all data
|
||||
GameData::MapMetadata.save
|
||||
MessageTypes.setMessages(MessageTypes::MapNames, map_names)
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user