mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Tidied up, removed unused code
This commit is contained in:
@@ -462,7 +462,7 @@ module MapFactoryHelper
|
|||||||
# Add map to cache if can't be found
|
# Add map to cache if can't be found
|
||||||
if !@@MapDims[id]
|
if !@@MapDims[id]
|
||||||
begin
|
begin
|
||||||
map = pbLoadRxData(sprintf("Data/Map%03d", id))
|
map = load_data(sprintf("Data/Map%03d.rxdata", id))
|
||||||
@@MapDims[id] = [map.width,map.height]
|
@@MapDims[id] = [map.width,map.height]
|
||||||
rescue
|
rescue
|
||||||
@@MapDims[id] = [0,0]
|
@@MapDims[id] = [0,0]
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class Scene_Map
|
|||||||
playingBGM = $game_system.playing_bgm
|
playingBGM = $game_system.playing_bgm
|
||||||
playingBGS = $game_system.playing_bgs
|
playingBGS = $game_system.playing_bgs
|
||||||
return if !playingBGM && !playingBGS
|
return if !playingBGM && !playingBGS
|
||||||
map = pbLoadRxData(sprintf("Data/Map%03d",mapid))
|
map = load_data(sprintf("Data/Map%03d.rxdata", mapid))
|
||||||
if playingBGM && map.autoplay_bgm
|
if playingBGM && map.autoplay_bgm
|
||||||
if (PBDayNight.isNight? rescue false)
|
if (PBDayNight.isNight? rescue false)
|
||||||
pbBGMFade(0.8) if playingBGM.name!=map.bgm.name && playingBGM.name!=map.bgm.name+"_n"
|
pbBGMFade(0.8) if playingBGM.name!=map.bgm.name && playingBGM.name!=map.bgm.name+"_n"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def pbSetTextMessages
|
|||||||
end
|
end
|
||||||
# Must add messages because this code is used by both game system and Editor
|
# Must add messages because this code is used by both game system and Editor
|
||||||
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts,texts)
|
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts,texts)
|
||||||
commonevents=pbLoadRxData("Data/CommonEvents")
|
commonevents = load_data("Data/CommonEvents.rxdata")
|
||||||
items=[]
|
items=[]
|
||||||
choices=[]
|
choices=[]
|
||||||
for event in commonevents.compact
|
for event in commonevents.compact
|
||||||
@@ -96,7 +96,7 @@ def pbSetTextMessages
|
|||||||
choices|=[]
|
choices|=[]
|
||||||
items.concat(choices)
|
items.concat(choices)
|
||||||
MessageTypes.setMapMessagesAsHash(0,items)
|
MessageTypes.setMapMessagesAsHash(0,items)
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
mapnames=[]
|
mapnames=[]
|
||||||
for id in mapinfos.keys
|
for id in mapinfos.keys
|
||||||
mapnames[id]=mapinfos[id].name
|
mapnames[id]=mapinfos[id].name
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ module MessageConfig
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.pbDefaultWindowskin
|
def self.pbDefaultWindowskin
|
||||||
skin=load_data("Data/System.rxdata").windowskin_name rescue nil
|
skin=($data_system) ? $data_system.windowskin_name : nil
|
||||||
if skin && skin!=""
|
if skin && skin!=""
|
||||||
skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || ""
|
skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || ""
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbGetBasicMapNameFromId(id)
|
def pbGetBasicMapNameFromId(id)
|
||||||
begin
|
begin
|
||||||
map = pbLoadRxData("Data/MapInfos")
|
map = load_data("Data/MapInfos.rxdata")
|
||||||
return "" if !map
|
return "" if !map
|
||||||
return map[id].name
|
return map[id].name
|
||||||
rescue
|
rescue
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ class IntroEventScene < EventScene
|
|||||||
@pic2 = addImage(0,0,"") # flashing "Press Enter" picture
|
@pic2 = addImage(0,0,"") # flashing "Press Enter" picture
|
||||||
@pic2.setOpacity(0,0)
|
@pic2.setOpacity(0,0)
|
||||||
@index = 0
|
@index = 0
|
||||||
data_system = pbLoadRxData("Data/System")
|
pbBGMPlay($data_system.title_bgm)
|
||||||
pbBGMPlay(data_system.title_bgm)
|
|
||||||
openPic(self,nil)
|
openPic(self,nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -262,9 +262,8 @@ class PokemonLoadScreen
|
|||||||
$game_system = Game_System.new
|
$game_system = Game_System.new
|
||||||
$PokemonSystem = PokemonSystem.new if !$PokemonSystem
|
$PokemonSystem = PokemonSystem.new if !$PokemonSystem
|
||||||
savefile = RTP.getSaveFileName("Game.rxdata")
|
savefile = RTP.getSaveFileName("Game.rxdata")
|
||||||
data_system = pbLoadRxData("Data/System")
|
mapfile = sprintf("Data/Map%03d.rxdata", $data_system.start_map_id)
|
||||||
mapfile = sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
|
if $data_system.start_map_id == 0 || !pbRgssExists?(mapfile)
|
||||||
if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
|
|
||||||
pbMessage(_INTL("No starting position was set in the map editor.\1"))
|
pbMessage(_INTL("No starting position was set in the map editor.\1"))
|
||||||
pbMessage(_INTL("The game cannot continue."))
|
pbMessage(_INTL("The game cannot continue."))
|
||||||
@scene.pbEndScene
|
@scene.pbEndScene
|
||||||
@@ -431,7 +430,6 @@ class PokemonLoadScreen
|
|||||||
$PokemonStorage = PokemonStorage.new
|
$PokemonStorage = PokemonStorage.new
|
||||||
$PokemonEncounters = PokemonEncounters.new
|
$PokemonEncounters = PokemonEncounters.new
|
||||||
$PokemonTemp.begunNewGame = true
|
$PokemonTemp.begunNewGame = true
|
||||||
$data_system = pbLoadRxData("Data/System")
|
|
||||||
$MapFactory = PokemonMapFactory.new($data_system.start_map_id) # calls setMapChanged
|
$MapFactory = PokemonMapFactory.new($data_system.start_map_id) # calls setMapChanged
|
||||||
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
||||||
$game_player.refresh
|
$game_player.refresh
|
||||||
|
|||||||
@@ -81,139 +81,6 @@ class PokemonMartAdapter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Abstraction layer for RPG Maker XP
|
|
||||||
# Won't be used if $PokemonBag exists
|
|
||||||
#===============================================================================
|
|
||||||
class RpgxpMartAdapter
|
|
||||||
def getMoney
|
|
||||||
return $game_party.gold
|
|
||||||
end
|
|
||||||
|
|
||||||
def getMoneyString
|
|
||||||
return pbGetGoldString
|
|
||||||
end
|
|
||||||
|
|
||||||
def setMoney(value)
|
|
||||||
$game_party.gain_gold(-$game_party.gold)
|
|
||||||
$game_party.gain_gold(value)
|
|
||||||
end
|
|
||||||
|
|
||||||
def getPrice(item, _selling = false)
|
|
||||||
return item.price
|
|
||||||
end
|
|
||||||
|
|
||||||
def getItemIcon(item)
|
|
||||||
return nil if !item
|
|
||||||
if item == 0
|
|
||||||
return sprintf("Graphics/Items/back")
|
|
||||||
elsif item.respond_to?("icon_index")
|
|
||||||
return "Graphics/System/IconSet"
|
|
||||||
else
|
|
||||||
return sprintf("Graphics/Icons/%s", item.icon_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def getItemIconRect(item)
|
|
||||||
if item && item.respond_to?("icon_index")
|
|
||||||
ix = item.icon_index % 16 * 24
|
|
||||||
iy = item.icon_index / 16 * 24
|
|
||||||
return Rect.new(ix, iy, 24, 24)
|
|
||||||
end
|
|
||||||
return Rect.new(0, 0, 32, 32)
|
|
||||||
end
|
|
||||||
|
|
||||||
def getInventory
|
|
||||||
data = []
|
|
||||||
for i in 1...$data_items.size
|
|
||||||
data.push($data_items[i]) if getQuantity($data_items[i]) > 0
|
|
||||||
end
|
|
||||||
for i in 1...$data_weapons.size
|
|
||||||
data.push($data_weapons[i]) if getQuantity($data_weapons[i]) > 0
|
|
||||||
end
|
|
||||||
for i in 1...$data_armors.size
|
|
||||||
data.push($data_armors[i]) if getQuantity($data_armors[i]) > 0
|
|
||||||
end
|
|
||||||
return data
|
|
||||||
end
|
|
||||||
|
|
||||||
def canSell?(item)
|
|
||||||
return item ? item.price > 0 : false
|
|
||||||
end
|
|
||||||
|
|
||||||
def getName(item)
|
|
||||||
return item ? item.name : ""
|
|
||||||
end
|
|
||||||
|
|
||||||
def getDisplayName(item)
|
|
||||||
return item ? item.name : ""
|
|
||||||
end
|
|
||||||
|
|
||||||
def getDescription(item)
|
|
||||||
return item ? item.description : ""
|
|
||||||
end
|
|
||||||
|
|
||||||
def getDisplayPrice(item, _selling = false)
|
|
||||||
price = item.price
|
|
||||||
return price.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def addItem(item)
|
|
||||||
ret = (getQuantity(item) < 99)
|
|
||||||
if $game_party.respond_to?("gain_weapon")
|
|
||||||
case item
|
|
||||||
when RPG::Item
|
|
||||||
$game_party.gain_item(item.id, 1) if ret
|
|
||||||
when RPG::Weapon
|
|
||||||
$game_party.gain_weapon(item.id, 1) if ret
|
|
||||||
when RPG::Armor
|
|
||||||
$game_party.gain_armor(item.id, 1) if ret
|
|
||||||
end
|
|
||||||
else
|
|
||||||
$game_party.gain_item(item, 1) if ret
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
def getQuantity(item)
|
|
||||||
ret = 0
|
|
||||||
if $game_party.respond_to?("weapon_number")
|
|
||||||
case item
|
|
||||||
when RPG::Item
|
|
||||||
ret = $game_party.item_number(item.id)
|
|
||||||
when RPG::Weapon
|
|
||||||
ret = ($game_party.weapon_number(item.id))
|
|
||||||
when RPG::Armor
|
|
||||||
ret = ($game_party.armor_number(item.id))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return $game_party.item_number(item)
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
def showQuantity?(_item)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
def removeItem(item)
|
|
||||||
ret = (getQuantity(item) > 0)
|
|
||||||
if $game_party.respond_to?("lose_weapon")
|
|
||||||
case item
|
|
||||||
when RPG::Item
|
|
||||||
$game_party.lose_item(item.id, 1) if ret
|
|
||||||
when RPG::Weapon
|
|
||||||
$game_party.lose_weapon(item.id, 1) if ret
|
|
||||||
when RPG::Armor
|
|
||||||
$game_party.lose_armor(item.id, 1) if ret
|
|
||||||
end
|
|
||||||
else
|
|
||||||
$game_party.lose_item(item, 1) if ret
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Buy and Sell adapters
|
# Buy and Sell adapters
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -661,7 +528,7 @@ class PokemonMartScreen
|
|||||||
def initialize(scene,stock)
|
def initialize(scene,stock)
|
||||||
@scene=scene
|
@scene=scene
|
||||||
@stock=stock
|
@stock=stock
|
||||||
@adapter=$PokemonBag ? PokemonMartAdapter.new : RpgxpMartAdapter.new
|
@adapter=PokemonMartAdapter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbConfirm(msg)
|
def pbConfirm(msg)
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ def pbSafeLoad(file)
|
|||||||
return load_data(file)
|
return load_data(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbLoadRxData(file) # :nodoc:
|
|
||||||
return load_data(file+".rxdata")
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbChooseLanguage
|
def pbChooseLanguage
|
||||||
commands=[]
|
commands=[]
|
||||||
for lang in LANGUAGES
|
for lang in LANGUAGES
|
||||||
@@ -20,18 +16,6 @@ def pbChooseLanguage
|
|||||||
return pbShowCommands(nil,commands)
|
return pbShowCommands(nil,commands)
|
||||||
end
|
end
|
||||||
|
|
||||||
if !respond_to?("pbSetResizeFactor")
|
|
||||||
def pbSetResizeFactor(dummy); end
|
|
||||||
|
|
||||||
module Graphics
|
|
||||||
def self.snap_to_bitmap; return nil; end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
#############
|
|
||||||
#############
|
|
||||||
|
|
||||||
|
|
||||||
def pbSetUpSystem
|
def pbSetUpSystem
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -48,41 +48,6 @@ def pbEachCombination(array,num)
|
|||||||
end while _pbNextComb(currentComb,array.length)
|
end while _pbNextComb(currentComb,array.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbGetCDID()
|
|
||||||
sendString = proc { |x|
|
|
||||||
mciSendString = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','l')
|
|
||||||
next "" if !mciSendString
|
|
||||||
buffer = "\0"*2000
|
|
||||||
x = mciSendString.call(x,buffer,2000,0)
|
|
||||||
next (x==0) ? buffer.gsub(/\0/,"") : ""
|
|
||||||
}
|
|
||||||
sendString.call("open cdaudio shareable")
|
|
||||||
ret = ""
|
|
||||||
if sendString.call("status cdaudio media present")=="true"
|
|
||||||
ret = sendString.call("info cdaudio identity")
|
|
||||||
if ret==""
|
|
||||||
ret = sendString.call("info cdaudio info identity")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sendString.call("close cdaudio")
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the path of the user's "My Documents" folder.
|
|
||||||
def pbGetMyDocumentsFolder()
|
|
||||||
csidl_personal = 0x0005
|
|
||||||
shGetSpecialFolderLocation = Win32API.new("shell32.dll","SHGetSpecialFolderLocation","llp","i")
|
|
||||||
shGetPathFromIDList = Win32API.new("shell32.dll","SHGetPathFromIDList","lp","i")
|
|
||||||
return "." if !shGetSpecialFolderLocation || !shGetPathFromIDList
|
|
||||||
idl = [0].pack("V")
|
|
||||||
ret = shGetSpecialFolderLocation.call(0,csidl_personal,idl)
|
|
||||||
return "." if ret!=0
|
|
||||||
path = "\0"*512
|
|
||||||
ret = shGetPathFromIDList.call(idl.unpack("V")[0],path)
|
|
||||||
return "." if ret==0
|
|
||||||
return path.gsub(/\0/,"")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a country ID
|
# Returns a country ID
|
||||||
# http://msdn.microsoft.com/en-us/library/dd374073%28VS.85%29.aspx?
|
# http://msdn.microsoft.com/en-us/library/dd374073%28VS.85%29.aspx?
|
||||||
def pbGetCountry()
|
def pbGetCountry()
|
||||||
@@ -181,359 +146,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Linear congruential random number generator
|
|
||||||
#===============================================================================
|
|
||||||
class LinearCongRandom
|
|
||||||
def initialize(mul, add, seed=nil)
|
|
||||||
@s1 = mul
|
|
||||||
@s2 = add
|
|
||||||
@seed = seed
|
|
||||||
@seed = (Time.now.to_i&0xffffffff) if !@seed
|
|
||||||
@seed = (@seed+0xFFFFFFFF)+1 if @seed<0
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.dsSeed
|
|
||||||
t = Time.now
|
|
||||||
seed = (((t.mon*t.mday+t.min+t.sec)&0xFF)<<24) | (t.hour << 16) | (t.year-2000)
|
|
||||||
seed = (seed+0xFFFFFFFF)+1 if seed<0
|
|
||||||
return seed
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.pokemonRNG
|
|
||||||
self.new(0x41c64e6d,0x6073,self.dsSeed)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.pokemonRNGInverse
|
|
||||||
self.new(0xeeb9eb65,0xa3561a1,self.dsSeed)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.pokemonARNG
|
|
||||||
self.new(0x6C078965,0x01,self.dsSeed)
|
|
||||||
end
|
|
||||||
|
|
||||||
def getNext16 # calculates @seed * @s1 + @s2
|
|
||||||
@seed = ((((@seed&0x0000ffff)*(@s1&0x0000ffff))&0x0000ffff) |
|
|
||||||
(((((((@seed&0x0000ffff)*(@s1&0x0000ffff))&0xffff0000)>>16) +
|
|
||||||
((((@seed&0xffff0000)>>16)*(@s1&0x0000ffff))&0x0000ffff) +
|
|
||||||
(((@seed&0x0000ffff)*((@s1&0xffff0000)>>16))&0x0000ffff)) &
|
|
||||||
0x0000ffff)<<16)) + @s2
|
|
||||||
r = (@seed>>16)
|
|
||||||
r = (r+0xFFFFFFFF)+1 if r<0
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
|
|
||||||
def getNext
|
|
||||||
r = (getNext16()<<16) | (getNext16())
|
|
||||||
r = (r+0xFFFFFFFF)+1 if r<0
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Json-related utilities
|
|
||||||
#===============================================================================
|
|
||||||
# Returns true if the given string represents a valid object in JavaScript
|
|
||||||
# Object Notation, and false otherwise.
|
|
||||||
def pbIsJsonString(str)
|
|
||||||
return false if !str || str[/^[\s]*$/]
|
|
||||||
d = /(?:^|:|,)(?: ?\[)+/
|
|
||||||
charEscapes = /\\[\"\\\/nrtubf]/ #"
|
|
||||||
stringLiterals = /"[^"\\\n\r\x00-\x1f\x7f-\x9f]*"/ #"
|
|
||||||
whiteSpace = /[\s]+/
|
|
||||||
str = str.gsub(charEscapes,"@").gsub(stringLiterals,"true").gsub(whiteSpace," ")
|
|
||||||
# prevent cases like "truetrue" or "true true" or "true[true]" or "5-2" or "5true"
|
|
||||||
otherLiterals = /(true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)(?! ?[0-9a-z\-\[\{\"])/ #"
|
|
||||||
str = str.gsub(otherLiterals,"]").gsub(d,"") #"
|
|
||||||
return str[/^[\],:{} ]*$/] ? true : false
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a Ruby object that corresponds to the given string, which is encoded in
|
|
||||||
# JavaScript Object Notation (JSON). Returns nil if the string is not valid JSON.
|
|
||||||
def pbParseJson(str)
|
|
||||||
return nil if !pbIsJsonString(str)
|
|
||||||
stringRE = /(\"(\\[\"\'\\rntbf]|\\u[0-9A-Fa-f]{4,4}|[^\\\"])*\")/ #"
|
|
||||||
strings = []
|
|
||||||
str = str.gsub(stringRE) {
|
|
||||||
sl = strings.length
|
|
||||||
ss = $1
|
|
||||||
if ss.include?("\\u")
|
|
||||||
ss.gsub!(/\\u([0-9A-Fa-f]{4,4})/) {
|
|
||||||
codepoint = $1.to_i(16)
|
|
||||||
if codepoint<=0x7F
|
|
||||||
next sprintf("\\x%02X",codepoint)
|
|
||||||
elsif codepoint<=0x7FF
|
|
||||||
next sprintf("%s%s",
|
|
||||||
(0xC0|((codepoint>>6)&0x1F)).chr,
|
|
||||||
(0x80|(codepoint&0x3F)).chr)
|
|
||||||
else
|
|
||||||
next sprintf("%s%s%s",
|
|
||||||
(0xE0|((codepoint>>12)&0x0F)).chr,
|
|
||||||
(0x80|((codepoint>>6)&0x3F)).chr,
|
|
||||||
(0x80|(codepoint&0x3F)).chr)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
strings.push(eval(ss))
|
|
||||||
next sprintf("strings[%d]",sl)
|
|
||||||
}
|
|
||||||
str = str.gsub(/\:/,"=>")
|
|
||||||
str = str.gsub(/null/,"nil")
|
|
||||||
return eval("("+str+")")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# XML-related utilities
|
|
||||||
#===============================================================================
|
|
||||||
# Represents XML content.
|
|
||||||
class MiniXmlContent
|
|
||||||
attr_reader :value
|
|
||||||
|
|
||||||
def initialize(value)
|
|
||||||
@value = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Represents an XML element.
|
|
||||||
class MiniXmlElement
|
|
||||||
attr_accessor :name,:attributes,:children
|
|
||||||
|
|
||||||
def initialize(name)
|
|
||||||
@name = name
|
|
||||||
@attributes = {}
|
|
||||||
@children = []
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the value of the attribute with the given name, or nil if it doesn't
|
|
||||||
# exist.
|
|
||||||
def a(name)
|
|
||||||
self.attributes[name]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the entire text of this element.
|
|
||||||
def value
|
|
||||||
ret = ""
|
|
||||||
for c in @children
|
|
||||||
ret += c.value
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the first child of this element with the given name, or nil if it
|
|
||||||
# doesn't exist.
|
|
||||||
def e(name)
|
|
||||||
for c in @children
|
|
||||||
return c if c.is_a?(MiniXmlElement) && c.name==name
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def eachElementNamed(name)
|
|
||||||
for c in @children
|
|
||||||
yield c if c.is_a?(MiniXmlElement) && c.name==name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# A small class for reading simple XML documents. Such documents must
|
|
||||||
# meet the following restrictions:
|
|
||||||
# They may contain comments and processing instructions, but they are
|
|
||||||
# ignored.
|
|
||||||
# They can't contain any entity references other than 'gt', 'lt',
|
|
||||||
# 'amp', 'apos', or 'quot'.
|
|
||||||
# They can't contain a DOCTYPE declaration or DTDs.
|
|
||||||
class MiniXmlReader
|
|
||||||
def initialize(data)
|
|
||||||
@root = nil
|
|
||||||
@elements = []
|
|
||||||
@done = false
|
|
||||||
@data = data
|
|
||||||
@content = ""
|
|
||||||
end
|
|
||||||
|
|
||||||
def createUtf8(codepoint) #:nodoc:
|
|
||||||
raise ArgumentError.new("Illegal character") if codepoint<9 ||
|
|
||||||
codepoint==11 || codepoint==12 || (codepoint>=14 && codepoint<32) ||
|
|
||||||
codepoint==0xFFFE || codepoint==0xFFFF || (codepoint>=0xD800 && codepoint<0xE000)
|
|
||||||
return codepoint.chr if codepoint<=0x7F
|
|
||||||
if codepoint<=0x7FF
|
|
||||||
str = (0xC0|((codepoint>>6)&0x1F)).chr
|
|
||||||
str += (0x80|(codepoint &0x3F)).chr
|
|
||||||
return str
|
|
||||||
elsif codepoint<=0xFFFF
|
|
||||||
str = (0xE0|((codepoint>>12)&0x0F)).chr
|
|
||||||
str += (0x80|((codepoint>>6)&0x3F)).chr
|
|
||||||
str += (0x80|(codepoint &0x3F)).chr
|
|
||||||
return str
|
|
||||||
elsif codepoint<=0x10FFFF
|
|
||||||
str = (0xF0|((codepoint>>18)&0x07)).chr
|
|
||||||
str += (0x80|((codepoint>>12)&0x3F)).chr
|
|
||||||
str += (0x80|((codepoint>>6)&0x3F)).chr
|
|
||||||
str += (0x80|(codepoint &0x3F)).chr
|
|
||||||
return str
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("Illegal character")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def unescape(attr) #:nodoc:
|
|
||||||
attr = attr.gsub(/\r(\n|$|(?=[^\n]))/,"\n")
|
|
||||||
raise ArgumentError.new("Attribute value contains '<'") if attr.include?("<")
|
|
||||||
attr = attr.gsub(/&(lt|gt|apos|quot|amp|\#([0-9]+)|\#x([0-9a-fA-F]+));|([\n\r\t])/) {
|
|
||||||
next " " if $4=="\n"||$4=="\r"||$4=="\t"
|
|
||||||
next "<" if $1=="lt"
|
|
||||||
next ">" if $1=="gt"
|
|
||||||
next "'" if $1=="apos"
|
|
||||||
next "\"" if $1=="quot"
|
|
||||||
next "&" if $1=="amp"
|
|
||||||
next createUtf8($2.to_i) if $2
|
|
||||||
next createUtf8($3.to_i(16)) if $3
|
|
||||||
}
|
|
||||||
return attr
|
|
||||||
end
|
|
||||||
|
|
||||||
def readAttributes(attribs) #:nodoc:
|
|
||||||
ret = {}
|
|
||||||
while attribs.length>0
|
|
||||||
if attribs[/(\s+([\w\-]+)\s*\=\s*\"([^\"]*)\")/]
|
|
||||||
attribs = attribs[$1.length,attribs.length]
|
|
||||||
name = $2; value = $3
|
|
||||||
raise ArgumentError.new("Attribute already exists") if ret[name]!=nil
|
|
||||||
ret[name] = unescape(value)
|
|
||||||
elsif attribs[/(\s+([\w\-]+)\s*\=\s*\'([^\']*)\')/]
|
|
||||||
attribs = attribs[$1.length,attribs.length]
|
|
||||||
name = $2; value = $3
|
|
||||||
raise ArgumentError.new("Attribute already exists") if ret[name]!=nil
|
|
||||||
ret[name] = unescape(value)
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("Can't parse attributes")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
# Reads the entire contents of an XML document. Returns the root element of
|
|
||||||
# the document or raises an ArgumentError if an error occurs.
|
|
||||||
def read
|
|
||||||
if @data[/\A((\xef\xbb\xbf)?<\?xml\s+version\s*=\s*(\"1\.[0-9]\"|\'1\.[0-9]\')(\s+encoding\s*=\s*(\"[^\"]*\"|\'[^\']*\'))?(\s+standalone\s*=\s*(\"(yes|no)\"|\'(yes|no)\'))?\s*\?>)/]
|
|
||||||
# Ignore XML declaration
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
end
|
|
||||||
while readOneElement(); end
|
|
||||||
return @root
|
|
||||||
end
|
|
||||||
|
|
||||||
def readOneElement #:nodoc:
|
|
||||||
if @data[/\A\s*\z/]
|
|
||||||
@data = ""
|
|
||||||
if !@root
|
|
||||||
raise ArgumentError.new("Not an XML document.")
|
|
||||||
elsif !@done
|
|
||||||
raise ArgumentError.new("Unexpected end of document.")
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
if @data[/\A(\s*<([\w\-]+)((?:\s+[\w\-]+\s*\=\s*(?:\"[^\"]*\"|\'[^\']*\'))*)\s*(\/>|>))/]
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
elementName = $2
|
|
||||||
attributes = $3
|
|
||||||
endtag = $4
|
|
||||||
raise ArgumentError.new("Element tag at end of document") if @done
|
|
||||||
if @content.length>0 && @elements.length>0
|
|
||||||
@elements[@elements.length-1].children.push(MiniXmlContent.new(@content))
|
|
||||||
@content = ""
|
|
||||||
end
|
|
||||||
element = MiniXmlElement.new(elementName)
|
|
||||||
element.attributes = readAttributes(attributes)
|
|
||||||
if !@root
|
|
||||||
@root = element
|
|
||||||
else
|
|
||||||
@elements[@elements.length-1].children.push(element)
|
|
||||||
end
|
|
||||||
if endtag==">"
|
|
||||||
@elements.push(element)
|
|
||||||
else
|
|
||||||
@done = true if @elements.length==0
|
|
||||||
end
|
|
||||||
elsif @data[/\A(<!--([\s\S]*?)-->)/]
|
|
||||||
# ignore comments
|
|
||||||
raise ArgumentError.new("Incorrect comment") if $2.include?("--")
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
elsif @data[/\A(<\?([\w\-]+)\s+[\s\S]*?\?>)/]
|
|
||||||
# ignore processing instructions
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
if $2.downcase=="xml"
|
|
||||||
raise ArgumentError.new("'xml' processing instruction not allowed")
|
|
||||||
end
|
|
||||||
elsif @data[/\A(<\?([\w\-]+)\?>)/]
|
|
||||||
# ignore processing instructions
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
if $2.downcase=="xml"
|
|
||||||
raise ArgumentError.new("'xml' processing instruction not allowed")
|
|
||||||
end
|
|
||||||
elsif @data[/\A(\s*<\/([\w\-]+)>)/]
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
elementName = $2
|
|
||||||
raise ArgumentError.new("End tag at end of document") if @done
|
|
||||||
if @elements.length==0
|
|
||||||
raise ArgumentError.new("Unexpected end tag")
|
|
||||||
elsif @elements[@elements.length-1].name!=elementName
|
|
||||||
raise ArgumentError.new("Incorrect end tag")
|
|
||||||
else
|
|
||||||
if @content.length>0
|
|
||||||
@elements[@elements.length-1].children.push(MiniXmlContent.new(@content))
|
|
||||||
@content = ""
|
|
||||||
end
|
|
||||||
@elements.pop()
|
|
||||||
@done = true if @elements.length==0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if @elements.length>0
|
|
||||||
# Parse content
|
|
||||||
if @data[/\A([^<&]+)/]
|
|
||||||
content = $1
|
|
||||||
@data = @data[content.length,@data.length]
|
|
||||||
raise ArgumentError.new("Incorrect content") if content.include?("]]>")
|
|
||||||
content.gsub!(/\r(\n|\z|(?=[^\n]))/,"\n")
|
|
||||||
@content += content
|
|
||||||
elsif @data[/\A(<\!\[CDATA\[([\s\S]*?)\]\]>)/]
|
|
||||||
content = $2
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
content.gsub!(/\r(\n|\z|(?=[^\n]))/,"\n")
|
|
||||||
@content += content
|
|
||||||
elsif @data[/\A(&(lt|gt|apos|quot|amp|\#([0-9]+)|\#x([0-9a-fA-F]+));)/]
|
|
||||||
@data = @data[$1.length,@data.length]
|
|
||||||
content = ""
|
|
||||||
if $2=="lt"; content = "<"
|
|
||||||
elsif $2=="gt"; content = ">"
|
|
||||||
elsif $2=="apos"; content = "'"
|
|
||||||
elsif $2=="quot"; content = "\""
|
|
||||||
elsif $2=="amp"; content = "&"
|
|
||||||
elsif $3; content = createUtf8($2.to_i)
|
|
||||||
elsif $4; content = createUtf8($3.to_i(16))
|
|
||||||
end
|
|
||||||
@content += content
|
|
||||||
elsif !@data[/\A</]
|
|
||||||
raise ArgumentError.new("Can't read XML content")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("Can't parse XML")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Event utilities
|
# Event utilities
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ end
|
|||||||
def pbDebugFixInvalidTiles
|
def pbDebugFixInvalidTiles
|
||||||
num_errors = 0
|
num_errors = 0
|
||||||
num_error_maps = 0
|
num_error_maps = 0
|
||||||
@tilesets = pbLoadRxData("Data/Tilesets")
|
@tilesets = load_data("Data/Tilesets.rxdata")
|
||||||
mapData = MapData.new
|
mapData = MapData.new
|
||||||
t = Time.now.to_i
|
t = Time.now.to_i
|
||||||
Graphics.update
|
Graphics.update
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ def pbMetadataScreen(map_id = 0)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbEditMetadata(map_id = 0)
|
def pbEditMetadata(map_id = 0)
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
data = []
|
data = []
|
||||||
if map_id == 0 # Global metadata
|
if map_id == 0 # Global metadata
|
||||||
map_name = _INTL("Global Metadata")
|
map_name = _INTL("Global Metadata")
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def pbAllocateAnimation(animations,name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pbMapTree
|
def pbMapTree
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
maplevels = []
|
maplevels = []
|
||||||
retarray = []
|
retarray = []
|
||||||
for i in mapinfos.keys
|
for i in mapinfos.keys
|
||||||
|
|||||||
@@ -344,8 +344,7 @@ class MapScreenScene
|
|||||||
if $game_map
|
if $game_map
|
||||||
@currentmap=$game_map.map_id
|
@currentmap=$game_map.map_id
|
||||||
else
|
else
|
||||||
system=load_data("Data/System.rxdata")
|
@currentmap=($data_system) ? $data_system.edit_map_id : 1
|
||||||
@currentmap=system.edit_map_id
|
|
||||||
end
|
end
|
||||||
putSprite(@currentmap)
|
putSprite(@currentmap)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ module Compiler
|
|||||||
def write_connections
|
def write_connections
|
||||||
conndata = load_data("Data/map_connections.dat") rescue nil
|
conndata = load_data("Data/map_connections.dat") rescue nil
|
||||||
return if !conndata
|
return if !conndata
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
File.open("PBS/connections.txt","wb") { |f|
|
File.open("PBS/connections.txt","wb") { |f|
|
||||||
add_PBS_header_to_file(f)
|
add_PBS_header_to_file(f)
|
||||||
f.write("\#-------------------------------\r\n")
|
f.write("\#-------------------------------\r\n")
|
||||||
@@ -509,7 +509,7 @@ module Compiler
|
|||||||
def write_encounters
|
def write_encounters
|
||||||
encdata = pbLoadEncountersData
|
encdata = pbLoadEncountersData
|
||||||
return if !encdata
|
return if !encdata
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
File.open("PBS/encounters.txt","wb") { |f|
|
File.open("PBS/encounters.txt","wb") { |f|
|
||||||
add_PBS_header_to_file(f)
|
add_PBS_header_to_file(f)
|
||||||
sortedkeys = encdata.keys.sort
|
sortedkeys = encdata.keys.sort
|
||||||
@@ -729,7 +729,7 @@ module Compiler
|
|||||||
f.write("\r\n")
|
f.write("\r\n")
|
||||||
end
|
end
|
||||||
# Write map metadata
|
# Write map metadata
|
||||||
map_infos = pbLoadRxData("Data/MapInfos")
|
map_infos = load_data("Data/MapInfos.rxdata")
|
||||||
schema = GameData::MapMetadata::SCHEMA
|
schema = GameData::MapMetadata::SCHEMA
|
||||||
keys = schema.keys.sort {|a, b| schema[a][0] <=> schema[b][0] }
|
keys = schema.keys.sort {|a, b| schema[a][0] <=> schema[b][0] }
|
||||||
GameData::MapMetadata.each do |map_data|
|
GameData::MapMetadata.each do |map_data|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module Compiler
|
|||||||
mapfiles[$1.to_i(10)] = true if map[/map(\d+)\.rxdata/i]
|
mapfiles[$1.to_i(10)] = true if map[/map(\d+)\.rxdata/i]
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
mapinfos = pbLoadRxData("Data/MapInfos")
|
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
maxOrder = 0
|
maxOrder = 0
|
||||||
# Exclude maps found in mapinfos
|
# Exclude maps found in mapinfos
|
||||||
for id in mapinfos.keys
|
for id in mapinfos.keys
|
||||||
@@ -239,9 +239,9 @@ module Compiler
|
|||||||
attr_reader :mapinfos
|
attr_reader :mapinfos
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@mapinfos = pbLoadRxData("Data/MapInfos")
|
@mapinfos = load_data("Data/MapInfos.rxdata")
|
||||||
@system = pbLoadRxData("Data/System")
|
@system = load_data("Data/System.rxdata")
|
||||||
@tilesets = pbLoadRxData("Data/Tilesets")
|
@tilesets = load_data("Data/Tilesets.rxdata")
|
||||||
@mapxy = []
|
@mapxy = []
|
||||||
@mapWidths = []
|
@mapWidths = []
|
||||||
@mapHeights = []
|
@mapHeights = []
|
||||||
@@ -1400,7 +1400,7 @@ module Compiler
|
|||||||
end
|
end
|
||||||
changed = false
|
changed = false
|
||||||
Graphics.update
|
Graphics.update
|
||||||
commonEvents = pbLoadRxData("Data/CommonEvents")
|
commonEvents = load_data("Data/CommonEvents.rxdata")
|
||||||
pbSetWindowText(_INTL("Processing common events"))
|
pbSetWindowText(_INTL("Processing common events"))
|
||||||
for key in 0...commonEvents.length
|
for key in 0...commonEvents.length
|
||||||
newevent = fix_event_use(commonEvents[key],0,mapData)
|
newevent = fix_event_use(commonEvents[key],0,mapData)
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ def mainFunctionDebug
|
|||||||
begin
|
begin
|
||||||
Compiler.main
|
Compiler.main
|
||||||
pbSetUpSystem
|
pbSetUpSystem
|
||||||
$data_animations = pbLoadRxData("Data/Animations")
|
$data_animations = load_data("Data/Animations.rxdata")
|
||||||
$data_tilesets = pbLoadRxData("Data/Tilesets")
|
$data_tilesets = load_data("Data/Tilesets.rxdata")
|
||||||
$data_common_events = pbLoadRxData("Data/CommonEvents")
|
$data_common_events = load_data("Data/CommonEvents.rxdata")
|
||||||
$data_system = pbLoadRxData("Data/System")
|
$data_system = load_data("Data/System.rxdata")
|
||||||
$game_system = Game_System.new
|
$game_system = Game_System.new
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Graphics.freeze
|
Graphics.freeze
|
||||||
|
|||||||
Reference in New Issue
Block a user