Removed RGSS2 compatibility, condensed BitmapCache into RPG::Cache and made it work

This commit is contained in:
Maruno17
2021-03-10 21:32:00 +00:00
parent 117396f8e2
commit ba1d225b83
13 changed files with 163 additions and 870 deletions

View File

@@ -1,4 +1,6 @@
$VERBOSE = nil
Font.default_shadow = false if Font.respond_to?(:default_shadow)
Graphics.frame_rate = 40
def pbSetWindowText(string)
System.set_window_title(string || System.game_title)
@@ -25,4 +27,4 @@ def pbSetResizeFactor(factor)
Graphics.scale = (factor + 1) * 0.5
Graphics.center
end
end
end

View File

@@ -1,572 +0,0 @@
$TEST = true if $DEBUG
$DEBUG = true if $TEST
$scene = nil
Font.default_shadow = false if Font.respond_to?(:default_shadow)
Graphics.frame_rate = 40
#===============================================================================
#
#===============================================================================
=begin
class Win32API
class << self
unless defined?(debug_new)
alias debug_new new
end
def new(*args)
File.open("winapi.txt", "ab") { |f| f.write("new(#{args[0]},#{args[1]})\r\n") }
b = debug_new(*args)
b.setDllName(args[0], args[1])
return b
end
end
unless defined?(debug_call)
alias debug_call call
end
def setDllName(a,b)
@w32dll = a
@w32name = b
end
def call(*args)
if @w32name != "GetAsyncKeyState"
File.open("winapi.txt", "ab") { |f|
f.write("call(#{@w32dll},#{@w32name},#{args.inspect})\r\n")
}
end
debug_call(*args)
end
end
class Bitmap
class << self
unless defined?(debug_new)
alias debug_new new
end
def new(*args)
if args.length == 1
File.open("winapib.txt", "ab") { |f| f.write("new(#{args[0]})\r\n") }
end
debug_new(*args)
end
end
end
alias debug_load_data load_data
def load_data(*args)
File.open("winapif.txt", "ab") { |f| f.write("load(#{args[0]})\r\n") }
debug_load_data(*args)
end
=end
class Hangup < Exception; end
if false
p (Tilemap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# no changes
p (Plane.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# no changes
p (Viewport.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
p (Bitmap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# openness(=)
p (Window.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
p (Sprite.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
end
#===============================================================================
#
#===============================================================================
module RPG
class Animation
attr_accessor :id
attr_accessor :name
attr_accessor :animation_name
attr_accessor :animation_hue
attr_accessor :position
attr_accessor :frame_max
attr_accessor :frames
attr_accessor :timings
def initialize
@id = 0
@name = ""
@animation_name = ""
@animation_hue = 0
@position = 1
@frame_max = 1
@frames = [RPG::Animation::Frame.new]
@timings = []
end
end
end
module RPG
class Animation
class Frame
attr_accessor :cell_max
attr_accessor :cell_data
def initialize
@cell_max = 0
@cell_data = Table.new(0, 0)
end
end
end
end
module RPG
class Animation
class Timing
attr_accessor :frame
attr_accessor :se
attr_accessor :flash_scope
attr_accessor :flash_color
attr_accessor :flash_duration
attr_accessor :condition
def initialize
@frame = 0
@se = RPG::AudioFile.new("", 80)
@flash_scope = 0
@flash_color = Color.new(255, 255, 255, 255)
@flash_duration = 5
@condition = 0
end
end
end
end
module RPG
class System
attr_accessor :magic_number
attr_accessor :party_members
attr_accessor :elements
attr_accessor :switches
attr_accessor :variables
attr_accessor :windowskin_name
attr_accessor :title_name
attr_accessor :gameover_name
attr_accessor :battle_transition
attr_accessor :title_bgm
attr_accessor :battle_bgm
attr_accessor :battle_end_me
attr_accessor :gameover_me
attr_accessor :cursor_se
attr_accessor :decision_se
attr_accessor :cancel_se
attr_accessor :buzzer_se
attr_accessor :equip_se
attr_accessor :shop_se
attr_accessor :save_se
attr_accessor :load_se
attr_accessor :battle_start_se
attr_accessor :escape_se
attr_accessor :actor_collapse_se
attr_accessor :enemy_collapse_se
attr_accessor :words
attr_accessor :test_battlers
attr_accessor :test_troop_id
attr_accessor :start_map_id
attr_accessor :start_x
attr_accessor :start_y
attr_accessor :battleback_name
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :edit_map_id
def initialize
@magic_number = 0
@party_members = [1]
@elements = [nil, ""]
@switches = [nil, ""]
@variables = [nil, ""]
@windowskin_name = ""
@title_name = ""
@gameover_name = ""
@battle_transition = ""
@title_bgm = RPG::AudioFile.new
@battle_bgm = RPG::AudioFile.new
@battle_end_me = RPG::AudioFile.new
@gameover_me = RPG::AudioFile.new
@cursor_se = RPG::AudioFile.new("", 80)
@decision_se = RPG::AudioFile.new("", 80)
@cancel_se = RPG::AudioFile.new("", 80)
@buzzer_se = RPG::AudioFile.new("", 80)
@equip_se = RPG::AudioFile.new("", 80)
@shop_se = RPG::AudioFile.new("", 80)
@save_se = RPG::AudioFile.new("", 80)
@load_se = RPG::AudioFile.new("", 80)
@battle_start_se = RPG::AudioFile.new("", 80)
@escape_se = RPG::AudioFile.new("", 80)
@actor_collapse_se = RPG::AudioFile.new("", 80)
@enemy_collapse_se = RPG::AudioFile.new("", 80)
@words = RPG::System::Words.new
@test_battlers = []
@test_troop_id = 1
@start_map_id = 1
@start_x = 0
@start_y = 0
@battleback_name = ""
@battler_name = ""
@battler_hue = 0
@edit_map_id = 1
end
end
end
module RPG
class Tileset
attr_accessor :id
attr_accessor :name
attr_accessor :tileset_name
attr_accessor :autotile_names
attr_accessor :panorama_name
attr_accessor :panorama_hue
attr_accessor :fog_name
attr_accessor :fog_hue
attr_accessor :fog_opacity
attr_accessor :fog_blend_type
attr_accessor :fog_zoom
attr_accessor :fog_sx
attr_accessor :fog_sy
attr_accessor :battleback_name
attr_accessor :passages
attr_accessor :priorities
attr_accessor :terrain_tags
def initialize
@id = 0
@name = ""
@tileset_name = ""
@autotile_names = [""] * 7
@panorama_name = ""
@panorama_hue = 0
@fog_name = ""
@fog_hue = 0
@fog_opacity = 64
@fog_blend_type = 0
@fog_zoom = 200
@fog_sx = 0
@fog_sy = 0
@battleback_name = ""
@passages = Table.new(384)
@priorities = Table.new(384)
@priorities[0] = 5
@terrain_tags = Table.new(384)
end
end
end
module RPG
class CommonEvent
attr_accessor :id
attr_accessor :name
attr_accessor :trigger
attr_accessor :switch_id
attr_accessor :list
def initialize
@id = 0
@name = ""
@trigger = 0
@switch_id = 1
@list = [RPG::EventCommand.new]
end
end
end
module RPG
class Map
attr_accessor :tileset_id
attr_accessor :width
attr_accessor :height
attr_accessor :autoplay_bgm
attr_accessor :bgm
attr_accessor :autoplay_bgs
attr_accessor :bgs
attr_accessor :encounter_list
attr_accessor :encounter_step
attr_accessor :data
attr_accessor :events
def initialize(width, height)
@tileset_id = 1
@width = width
@height = height
@autoplay_bgm = false
@bgm = RPG::AudioFile.new
@autoplay_bgs = false
@bgs = RPG::AudioFile.new("", 80)
@encounter_list = []
@encounter_step = 30
@data = Table.new(width, height, 3)
@events = {}
end
end
end
module RPG
class MapInfo
attr_accessor :name
attr_accessor :parent_id
attr_accessor :order
attr_accessor :expanded
attr_accessor :scroll_x
attr_accessor :scroll_y
def initialize
@name = ""
@parent_id = 0
@order = 0
@expanded = false
@scroll_x = 0
@scroll_y = 0
end
end
end
module RPG
class Event
attr_accessor :id
attr_accessor :name
attr_accessor :x
attr_accessor :y
attr_accessor :pages
def initialize(x, y)
@id = 0
@name = ""
@x = x
@y = y
@pages = [RPG::Event::Page.new]
end
end
end
module RPG
class Event
class Page
attr_accessor :condition
attr_accessor :graphic
attr_accessor :move_type
attr_accessor :move_speed
attr_accessor :move_frequency
attr_accessor :move_route
attr_accessor :walk_anime
attr_accessor :step_anime
attr_accessor :direction_fix
attr_accessor :through
attr_accessor :always_on_top
attr_accessor :trigger
attr_accessor :list
def initialize
@condition = RPG::Event::Page::Condition.new
@graphic = RPG::Event::Page::Graphic.new
@move_type = 0
@move_speed = 3
@move_frequency = 3
@move_route = RPG::MoveRoute.new
@walk_anime = true
@step_anime = false
@direction_fix = false
@through = false
@always_on_top = false
@trigger = 0
@list = [RPG::EventCommand.new]
end
end
end
end
module RPG
class Event
class Page
class Condition
attr_accessor :switch1_valid
attr_accessor :switch2_valid
attr_accessor :variable_valid
attr_accessor :self_switch_valid
attr_accessor :switch1_id
attr_accessor :switch2_id
attr_accessor :variable_id
attr_accessor :variable_value
attr_accessor :self_switch_ch
def initialize
@switch1_valid = false
@switch2_valid = false
@variable_valid = false
@self_switch_valid = false
@switch1_id = 1
@switch2_id = 1
@variable_id = 1
@variable_value = 0
@self_switch_ch = "A"
end
end
end
end
end
module RPG
class Event
class Page
class Graphic
attr_accessor :tile_id
attr_accessor :character_name
attr_accessor :character_hue
attr_accessor :direction
attr_accessor :pattern
attr_accessor :opacity
attr_accessor :blend_type
def initialize
@tile_id = 0
@character_name = ""
@character_hue = 0
@direction = 2
@pattern = 0
@opacity = 255
@blend_type = 0
end
end
end
end
end
module RPG
class EventCommand
attr_accessor :code
attr_accessor :indent
attr_accessor :parameters
def initialize(code = 0, indent = 0, parameters = [])
@code = code
@indent = indent
@parameters = parameters
end
end
end
module RPG
class MoveRoute
attr_accessor :repeat
attr_accessor :skippable
attr_accessor :list
def initialize
@repeat = true
@skippable = false
@list = [RPG::MoveCommand.new]
end
end
end
module RPG
class MoveCommand
attr_accessor :code
attr_accessor :parameters
def initialize(code = 0, parameters = [])
@code = code
@parameters = parameters
end
end
end
module RPG
class System
class Words
attr_accessor :gold
attr_accessor :hp
attr_accessor :sp
attr_accessor :str
attr_accessor :dex
attr_accessor :agi
attr_accessor :int
attr_accessor :atk
attr_accessor :pdef
attr_accessor :mdef
attr_accessor :weapon
attr_accessor :armor1
attr_accessor :armor2
attr_accessor :armor3
attr_accessor :armor4
attr_accessor :attack
attr_accessor :skill
attr_accessor :guard
attr_accessor :item
attr_accessor :equip
def initialize
@gold = ""
@hp = ""
@sp = ""
@str = ""
@dex = ""
@agi = ""
@int = ""
@atk = ""
@pdef = ""
@mdef = ""
@weapon = ""
@armor1 = ""
@armor2 = ""
@armor3 = ""
@armor4 = ""
@attack = ""
@skill = ""
@guard = ""
@item = ""
@equip = ""
end
end
end
end
module RPG
class System
class TestBattler
attr_accessor :actor_id
attr_accessor :level
attr_accessor :weapon_id
attr_accessor :armor1_id
attr_accessor :armor2_id
attr_accessor :armor3_id
attr_accessor :armor4_id
def initialize
@actor_id = 1
@level = 1
@weapon_id = 0
@armor1_id = 0
@armor2_id = 0
@armor3_id = 0
@armor4_id = 0
end
end
end
end
module RPG
class AudioFile
attr_accessor :name
attr_accessor :volume
attr_accessor :pitch
def initialize(name = "", volume = 100, pitch = 100)
@name = name
@volume = volume
@pitch = pitch
end
# def play
# end
end
end

View File

@@ -80,7 +80,7 @@ class Scene_Map
$game_player.straighten
$game_map.update
disposeSpritesets
GC.start
RPG::Cache.clear
createSpritesets
if $game_temp.transition_processing
$game_temp.transition_processing = false

View File

@@ -75,6 +75,42 @@ def pbBitmapName(x)
return (ret) ? ret : x
end
def strsplit(str, re)
ret = []
tstr = str
while re =~ tstr
ret[ret.length] = $~.pre_match
tstr = $~.post_match
end
ret[ret.length] = tstr if ret.length
return ret
end
def canonicalize(c)
csplit = strsplit(c, /[\/\\]/)
pos = -1
ret = []
retstr = ""
for x in csplit
if x == ".."
if pos >= 0
ret.delete_at(pos)
pos -= 1
end
elsif x != "."
ret.push(x)
pos += 1
end
end
for i in 0...ret.length
retstr += "/" if i > 0
retstr += ret[i]
end
return retstr
end
module RTP
@rtpPaths = nil

View File

@@ -2,112 +2,93 @@ class Hangup < Exception; end
def strsplit(str, re)
ret = []
tstr = str
while re =~ tstr
ret[ret.length] = $~.pre_match
tstr = $~.post_match
end
ret[ret.length] = tstr if ret.length
return ret
end
def canonicalize(c)
csplit = strsplit(c, /[\/\\]/)
pos = -1
ret = []
retstr = ""
for x in csplit
if x == ".."
if pos >= 0
ret.delete_at(pos)
pos -= 1
end
elsif x != "."
ret.push(x)
pos += 1
end
end
for i in 0...ret.length
retstr += "/" if i > 0
retstr += ret[i]
end
return retstr
end
module RPG
module Cache
def self.debug
t = Time.now
filename = t.strftime("%H %M %S.%L.txt")
File.open("cache_" + filename, "wb") { |f|
@cache.each do |key, value|
if !value
f.write("#{key} (nil)\r\n")
elsif value.disposed?
f.write("#{key} (disposed)\r\n")
else
f.write("#{key} (#{value.refcount}, #{value.width}x#{value.height})\r\n")
end
end
}
end
def self.setKey(key, obj)
@cache[key] = obj
end
def self.fromCache(i)
return nil if !@cache.include?(i)
obj = @cache[i]
return nil if obj && obj.disposed?
return obj
end
def self.load_bitmap(folder_name, filename, hue = 0)
BitmapCache.load_bitmap(folder_name + filename.to_s, hue, true)
path = folder_name + filename
cached = true
ret = fromCache(path)
if !ret
if filename != ""
ret = BitmapWrapper.new(path)
else
ret = BitmapWrapper.new(32, 32)
end
@cache[path] = ret
cached = false
end
if hue == 0
ret.addRef if cached
return ret
end
key = [path, hue]
ret2 = fromCache(key)
if ret2
ret2.addRef
else
ret2 = ret.copy
ret2.hue_change(hue)
@cache[key] = ret2
end
return ret2
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.autotile(filename)
self.load_bitmap("Graphics/Autotiles/", filename)
end
def self.battleback(filename)
self.load_bitmap("Graphics/Battlebacks/", filename)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/", filename, hue)
end
def self.character(filename, hue)
self.load_bitmap("Graphics/Characters/", filename, hue)
end
def self.fog(filename, hue)
self.load_bitmap("Graphics/Fogs/", filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/", filename)
end
def self.icon(filename)
self.load_bitmap("Graphics/Icons/", filename)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.picture(filename)
self.load_bitmap("Graphics/Pictures/", filename)
end
def self.tileset(filename)
self.load_bitmap("Graphics/Tilesets/", filename)
end
def self.title(filename)
self.load_bitmap("Graphics/Titles/", filename)
end
def self.windowskin(filename)
self.load_bitmap("Graphics/Windowskins/", filename)
def self.tileEx(filename, tile_id, hue)
key = [filename, tile_id, hue]
ret = fromCache(key)
if ret
ret.addRef
else
ret = BitmapWrapper.new(32, 32)
x = (tile_id - 384) % 8 * 32
y = (tile_id - 384) / 8 * 32
tileset = yield(filename)
ret.blt(0, 0, tileset, Rect.new(x, y, 32, 32))
tileset.dispose
ret.hue_change(hue) if hue != 0
@cache[key] = ret
end
return ret
end
def self.tile(filename, tile_id, hue)
BitmapCache.tile(filename, tile_id, hue)
return self.tileEx(filename, tile_id, hue) { |f| self.tileset(f) }
end
def self.clear
BitmapCache.clear()
def self.transition(filename)
self.load_bitmap("Graphics/Transitions/", filename)
end
end
end
class BitmapWrapper < Bitmap
attr_reader :refcount
@@ -136,157 +117,3 @@ class BitmapWrapper < Bitmap
@refcount += 1
end
end
module BitmapCache
@cache = ObjectSpace::WeakMap.new
def self.fromCache(i)
return nil if !@cache.include?(i)
obj = @cache[i]
return nil if obj && obj.disposed?
return obj
end
def self.setKey(key, obj)
@cache[key] = obj
end
def self.debug
t = Time.now
filename = t.strftime("%H %M %S.%L.txt")
File.open("bitmapcache_" + filename, "wb") { |f|
for i in @cache.keys
k = fromCache(i)
if !k
f.write("#{i} (nil)\r\n")
elsif k.disposed?
f.write("#{i} (disposed)\r\n")
else
f.write("#{i} (#{k.refcount}, #{k.width}x#{k.height})\r\n")
end
end
}
end
def self.load_bitmap(path, hue = 0, failsafe = false)
cached = true
path = -canonicalize(path) # Creates a frozen string from the path, to ensure identical paths are treated as identical
objPath = fromCache(path)
if !objPath
begin
bm = BitmapWrapper.new(path)
rescue Hangup
begin
bm = BitmapWrapper.new(path)
rescue
raise _INTL("Failed to load the bitmap located at: {1}", path) if !failsafe
bm = BitmapWrapper.new(32, 32)
end
rescue
raise _INTL("Failed to load the bitmap located at: {1}", path) if !failsafe
bm = BitmapWrapper.new(32, 32)
end
objPath = bm
@cache[path] = objPath
cached = false
end
if hue == 0
objPath.addRef if cached
return objPath
else
key = [path, hue]
objKey = fromCache(key)
if !objKey
bitmap = objPath.copy
bitmap.hue_change(hue) if hue != 0
objKey = bitmap
@cache[key] = objKey
else
objKey.addRef
end
return objKey
end
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/" + filename, hue)
end
def self.autotile(filename)
self.load_bitmap("Graphics/Autotiles/" + filename)
end
def self.battleback(filename)
self.load_bitmap("Graphics/Battlebacks/" + filename)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/" + filename, hue)
end
def self.character(filename, hue)
self.load_bitmap("Graphics/Characters/" + filename, hue)
end
def self.fog(filename, hue)
self.load_bitmap("Graphics/Fogs/" + filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/" + filename)
end
def self.icon(filename)
self.load_bitmap("Graphics/Icons/" + filename)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/" + filename, hue)
end
def self.picture(filename)
self.load_bitmap("Graphics/Pictures/" + filename)
end
def self.tileset(filename)
self.load_bitmap("Graphics/Tilesets/" + filename)
end
def self.title(filename)
self.load_bitmap("Graphics/Titles/" + filename)
end
def self.windowskin(filename)
self.load_bitmap("Graphics/Windowskins/" + filename)
end
def self.tileEx(filename, tile_id, hue)
key = [filename, tile_id, hue]
objKey = fromCache(key)
if !objKey
bitmap = BitmapWrapper.new(Game_Map::TILE_WIDTH, Game_Map::TILE_HEIGHT)
x = (tile_id - 384) % 8 * Game_Map::TILE_WIDTH
y = (tile_id - 384) / 8 * Game_Map::TILE_HEIGHT
rect = Rect.new(x, y, Game_Map::TILE_WIDTH, Game_Map::TILE_HEIGHT)
tileset = yield(filename)
bitmap.blt(0, 0, tileset, rect)
tileset.dispose
bitmap.hue_change(hue) if hue != 0
objKey = bitmap
@cache[key] = objKey
else
objKey.addRef
end
objKey
end
def self.tile(filename, tile_id, hue)
return self.tileEx(filename, tile_id, hue) { |f| self.tileset(f) }
end
def self.clear
@cache = ObjectSpace::WeakMap.new
GC.start
end
end

View File

@@ -1,7 +1,7 @@
#===============================================================================
# SpriteWrapper is a class based on Sprite which wraps Sprite's properties.
# SpriteWrapper is a class which wraps (most of) Sprite's properties.
#===============================================================================
class SpriteWrapper < Sprite
class SpriteWrapper
def initialize(viewport=nil)
@sprite = Sprite.new(viewport)
end

View File

@@ -66,7 +66,7 @@ class PngAnimatedBitmap
@frames=[]
@currentFrame=0
@framecount=0
panorama=BitmapCache.load_bitmap(file,hue)
panorama=RPG::Cache.load_bitmap("",file,hue)
if file.split(/[\\\/]/)[-1][/^\[(\d+)(?:,(\d+))?\]/] # Starts with 1 or 2 numbers in brackets
# File has a frame count
numFrames = $1.to_i
@@ -187,7 +187,7 @@ class GifBitmap
file="" if !file
file=canonicalize(file)
begin
bitmap=BitmapCache.load_bitmap(file,hue)
bitmap=RPG::Cache.load_bitmap("",file,hue)
rescue
bitmap=nil
end
@@ -242,7 +242,7 @@ class GifBitmap
@gifbitmaps.push(gifbitmap)
bmfile.hue_change(hue) if hue!=0
if hue==0 && @gifdelays.length==1
BitmapCache.setKey(file,gifbitmap)
RPG::Cache.setKey(file,gifbitmap)
end
File.delete(bmfile)
else
@@ -257,7 +257,7 @@ class GifBitmap
@gifdelays=[1]
end
if @gifbitmaps.length==1
BitmapCache.setKey(file,@gifbitmaps[0])
RPG::Cache.setKey(file,@gifbitmaps[0])
end
end
end
@@ -351,7 +351,7 @@ end
def pbGetTileBitmap(filename, tile_id, hue)
return BitmapCache.tileEx(filename, tile_id, hue) { |f|
return RPG::Cache.tileEx(filename, tile_id, hue) { |f|
AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate
}
end

View File

@@ -629,7 +629,7 @@ module Transitions
@numframes = numframes
@duration = numframes
@disposed = false
@bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_square")
@bitmap = RPG::Cache.transition("black_square")
if !@bitmap
@disposed = true
return
@@ -709,7 +709,7 @@ module Transitions
@numframes = numframes
@duration = numframes
@disposed = false
@bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_square")
@bitmap = RPG::Cache.transition("black_square")
if !@bitmap
@disposed = true
return
@@ -794,9 +794,9 @@ module Transitions
@disposed = true
return
end
@bubblebitmap = BitmapCache.load_bitmap("Graphics/Transitions/water_1")
@splashbitmap = BitmapCache.load_bitmap("Graphics/Transitions/water_2")
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@bubblebitmap = RPG::Cache.transition("water_1")
@splashbitmap = RPG::Cache.transition("water_2")
@blackbitmap = RPG::Cache.transition("black_half")
@buffer = Graphics.snap_to_bitmap
if !@bubblebitmap || !@splashbitmap || !@blackbitmap || !@buffer
@disposed = true
@@ -898,8 +898,8 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_small")
@blackbitmap = RPG::Cache.transition("black_half")
@ballbitmap = RPG::Cache.transition("ball_small")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -996,8 +996,8 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_large")
@blackbitmap = RPG::Cache.transition("black_half")
@ballbitmap = RPG::Cache.transition("ball_large")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -1104,8 +1104,8 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_square")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_small")
@blackbitmap = RPG::Cache.transition("black_square")
@ballbitmap = RPG::Cache.transition("ball_small")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -1205,9 +1205,9 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@curvebitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_curve")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_small")
@blackbitmap = RPG::Cache.transition("black_half")
@curvebitmap = RPG::Cache.transition("black_curve")
@ballbitmap = RPG::Cache.transition("ball_small")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@curvebitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -1301,8 +1301,8 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_small")
@blackbitmap = RPG::Cache.transition("black_half")
@ballbitmap = RPG::Cache.transition("ball_small")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -1403,8 +1403,8 @@ module Transitions
@disposed = true
return
end
@blackbitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_half")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_large")
@blackbitmap = RPG::Cache.transition("black_half")
@ballbitmap = RPG::Cache.transition("ball_large")
@buffer = Graphics.snap_to_bitmap
if !@blackbitmap || !@ballbitmap || !@buffer
@disposed = true
@@ -1502,11 +1502,11 @@ module Transitions
@disposed = true
return
end
@black1bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_wedge_1")
@black2bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_wedge_2")
@black3bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_wedge_3")
@black4bitmap = BitmapCache.load_bitmap("Graphics/Transitions/black_wedge_4")
@ballbitmap = BitmapCache.load_bitmap("Graphics/Transitions/ball_small")
@black1bitmap = RPG::Cache.transition("black_wedge_1")
@black2bitmap = RPG::Cache.transition("black_wedge_2")
@black3bitmap = RPG::Cache.transition("black_wedge_3")
@black4bitmap = RPG::Cache.transition("black_wedge_4")
@ballbitmap = RPG::Cache.transition("ball_small")
if !@black1bitmap || !@black2bitmap || !@black3bitmap || !@black4bitmap || !@ballbitmap
@disposed = true
return

View File

@@ -3,7 +3,7 @@
#===============================================================================
def pbSceneStandby
$scene.disposeSpritesets if $scene && $scene.is_a?(Scene_Map)
GC.start
RPG::Cache.clear
Graphics.frame_reset
yield
$scene.createSpritesets if $scene && $scene.is_a?(Scene_Map)
@@ -131,8 +131,8 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
if (battletype==1 || battletype==3) && foe.length==1 # Against single trainer
tr_type = foe[0].trainer_type
if tr_type
tbargraphic = sprintf("Graphics/Transitions/vsBar_%s", tr_type.to_s) rescue nil
tgraphic = sprintf("Graphics/Transitions/vsTrainer_%s", tr_type.to_s) rescue nil
tbargraphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil
tgraphic = sprintf("vsTrainer_%s", tr_type.to_s) rescue nil
if pbResolveBitmap(tbargraphic) && pbResolveBitmap(tgraphic)
player_tr_type = $Trainer.trainer_type
outfit = $Trainer.outfit
@@ -144,32 +144,32 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
viewvs = Viewport.new(0,0,Graphics.width,Graphics.height)
viewvs.z = viewport.z
fade = Sprite.new(viewport)
fade.bitmap = BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
fade.bitmap = RPG::Cache.transition("vsFlash")
fade.tone = Tone.new(-255,-255,-255)
fade.opacity = 100
overlay = Sprite.new(viewport)
overlay.bitmap = Bitmap.new(Graphics.width,Graphics.height)
pbSetSystemFont(overlay.bitmap)
pbargraphic = sprintf("Graphics/Transitions/vsBar_%s_%d", player_tr_type.to_s, outfit) rescue nil
pbargraphic = sprintf("vsBar_%s_%d", player_tr_type.to_s, outfit) rescue nil
if !pbResolveBitmap(pbargraphic)
pbargraphic = sprintf("Graphics/Transitions/vsBar_%s", player_tr_type.to_s) rescue nil
pbargraphic = sprintf("vsBar_%s", player_tr_type.to_s) rescue nil
end
xoffset = ((Graphics.width/2)/10)*10
bar1 = Sprite.new(viewplayer)
bar1.bitmap = BitmapCache.load_bitmap(pbargraphic)
bar1.bitmap = RPG::Cache.transition(pbargraphic)
bar1.x = -xoffset
bar2 = Sprite.new(viewopp)
bar2.bitmap = BitmapCache.load_bitmap(tbargraphic)
bar2.bitmap = RPG::Cache.transition(tbargraphic)
bar2.x = xoffset
vs = Sprite.new(viewvs)
vs.bitmap = BitmapCache.load_bitmap("Graphics/Transitions/vs")
vs.bitmap = RPG::Cache.transition("vs")
vs.ox = vs.bitmap.width/2
vs.oy = vs.bitmap.height/2
vs.x = Graphics.width/2
vs.y = Graphics.height/1.5
vs.visible = false
flash = Sprite.new(viewvs)
flash.bitmap = BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
flash.bitmap = RPG::Cache.transition("vsFlash")
flash.opacity = 0
# Animate bars sliding in from either side
slideInTime = (Graphics.frame_rate*0.25).floor
@@ -186,18 +186,18 @@ def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
flash.opacity = 255
# Replace bar sprites with AnimatedPlanes, set up trainer sprites
bar1 = AnimatedPlane.new(viewplayer)
bar1.bitmap = BitmapCache.load_bitmap(pbargraphic)
bar1.bitmap = RPG::Cache.transition(pbargraphic)
bar2 = AnimatedPlane.new(viewopp)
bar2.bitmap = BitmapCache.load_bitmap(tbargraphic)
pgraphic = sprintf("Graphics/Transitions/vsTrainer_%s_%d", player_tr_type.to_s, outfit) rescue nil
bar2.bitmap = RPG::Cache.transition(tbargraphic)
pgraphic = sprintf("vsTrainer_%s_%d", player_tr_type.to_s, outfit) rescue nil
if !pbResolveBitmap(pgraphic)
pgraphic = sprintf("Graphics/Transitions/vsTrainer_%s", player_tr_type.to_s) rescue nil
pgraphic = sprintf("vsTrainer_%s", player_tr_type.to_s) rescue nil
end
player = Sprite.new(viewplayer)
player.bitmap = BitmapCache.load_bitmap(pgraphic)
player.bitmap = RPG::Cache.transition(pgraphic)
player.x = -xoffset
trainer = Sprite.new(viewopp)
trainer.bitmap = BitmapCache.load_bitmap(tgraphic)
trainer.bitmap = RPG::Cache.transition(tgraphic)
trainer.x = xoffset
trainer.tone = Tone.new(-255,-255,-255)
# Dim the flash and make the trainer sprites appear, while animating bars

View File

@@ -72,7 +72,7 @@ def pbHiddenMoveAnimation(pokemon)
viewport=Viewport.new(0,0,0,0)
viewport.z=99999
bg=Sprite.new(viewport)
bg.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/hiddenMovebg")
bg.bitmap=RPG::Cache.picture("hiddenMovebg")
sprite=PokemonSprite.new(viewport)
sprite.setOffset(PictureOrigin::Center)
sprite.setPokemonBitmap(pokemon)

View File

@@ -244,7 +244,7 @@ class PokemonPokedexInfo_Scene
# Draw the footprint
footprintfile = GameData::Species.footprint_filename(@species, @form)
if footprintfile
footprint = BitmapCache.load_bitmap(footprintfile)
footprint = RPG::Cache.load_bitmap("",footprintfile)
overlay.blt(226, 138, footprint, footprint.rect)
footprint.dispose
end

View File

@@ -158,7 +158,7 @@ class VoltorbFlip
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["bg"]=Sprite.new(@viewport)
@sprites["bg"].bitmap=BitmapCache.load_bitmap(@directory+"boardbg")
@sprites["bg"].bitmap=RPG::Cache.load_bitmap(@directory,"boardbg")
@sprites["text"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["text"].bitmap)
@sprites["text"].bitmap.font.size=26
@@ -184,7 +184,7 @@ class VoltorbFlip
@sprites["icon"].z=99997
@sprites["mark"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
@sprites["memo"]=Sprite.new(@viewport)
@sprites["memo"].bitmap=BitmapCache.load_bitmap(@directory+"memo")
@sprites["memo"].bitmap=RPG::Cache.load_bitmap(@directory,"memo")
@sprites["memo"].x=10
@sprites["memo"].y=244
@sprites["memo"].visible=false

View File

@@ -1173,7 +1173,7 @@ def animationEditorMain(animation)
sidewin.dispose
bottomwindow.dispose
viewport.dispose
GC.start
RPG::Cache.clear
end
################################################################################