Code:
#==================================================
# This set of Cache Modules allows scripters to call bitmap functions quicker
# By: azrith001
# Date Modified: 9/1/08 (m/d/y)
# -----Description----------------------------------------------
=begin
Ok for those scripters out there who just hate not being able
to call cache functions through RPG::Cache faster this is for you!
This set of cache modules will allow you to call all the needed folders in half the
original time(based on your typing speed)
-----------------------------------------------------------------
How to use:
Ok the modules are as followed
*Get
*Grab
*Open
*C
All modules consist of the same call functions. So if you were to call a title like
Get.title the same would work for another like Grab.title, I have also added a few
new functions when calling like a hue set for all graphics, and a file.exist? function
those of you who hate the Popup window.
-----------------------------------------------------------------
Call function:
* Loads bitmap from a folder
.load_bitmap(folder_name, filename, hue = 0)
* Loads Animation Bitmaps
.animation(filename, hue)
.ani(filename, hue)
* Loads AutoTile Bitmaps
.autotile(filename, hue = 0)
.atile(filename, hue = 0)
* Loads Battleback Bitmaps
.battleback(filename, hue = 0)
.batbck(filename, hue = 0)
* Loads Battler Bitmaps
.battler(filename, hue)
.bat(filename, hue)
* Loads Character Bitmaps
.character(filename, hue)
.ch(filename, hue)
.char(filename, hue)
* Loads Fog Bitmaps
.fog(filename, hue)
.fg(filename, hue)
* Loads Gameover Bitmaps
.gameover(filename)
.go(filename, hue = 0)
* Loads Icon Bitmaps
.icon(filename, hue = 0)
.ico(filename, hue = 0)
.i(filename, hue = 0)
* Loads Panorama Bitmaps
.panorama(filename, hue)
.pan(filename, hue)
* Loads Picture Bitmaps
.picture(filename, hue = 0)
.pic(filename, hue = 0)
.pics(filename, hue = 0)
.pix(filename, hue = 0)
* Loads Tileset Bitmaps
.tileset(filename, hue = 0)
.tset(filename, hue = 0)
* Loads Title Bitmaps
.title(filename, hue = 0)
.ti(filename, hue = 0)
* Loads Windowskin Bitmaps
.windowskin(filename, hue = 0)
.wskin(filename, hue = 0)
* Loads Tileset-Tile Bitmap
.tile(filename, tile_id, hue)
----------------------------------------------------------------
Adding your own:
To add your own Cache call function to these just type the following.
# replace x with Get or Grab or Open or C
# replace call with a call function like hud, menu, anything you want
# as long as it does not mach any others
-
#replace Folder/Name with the directory to your bitmaps like
# Graphics/Hud/ - Note: the ending / must be there!
module x
def self.call(filename, hue = 0)
self.load_bitmap("Folder/Name/", filename, hue)
end
end
Thanks for reading--- If you got this far XD
azrith001
=end
#==================================================
# IF YOU DONT KNOW RGSS DONT TOUCH BELOW!!
# Make Get Call Function
module Get
@cache = {}
def self.load_bitmap(folder_name, filename, hue = 0)
path = folder_name + filename
if not @cache.include?(path) or @cache[path].disposed?
if filename != ""
@cache[path] = Bitmap.new(path)
else
@cache[path] = Bitmap.new(32, 32)
end
end
if hue == 0
@cache[path]
else
key = [path, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = @cache[path].clone
@cache[key].hue_change(hue)
end
@cache[key]
end
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.ani(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.autotile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.atile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.battleback(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.batbck(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/", filename, hue)
end
def self.bat(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.ch(filename, hue)
self.load_bitmap("Graphics/Characters/", filename, hue)
end
def self.char(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.fg(filename, hue)
self.load_bitmap("Graphics/Fogs/", filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/", filename)
end
def self.go(filename, hue = 0)
self.load_bitmap("Graphics/Gameovers/", filename, hue)
end
def self.icon(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.ico(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.i(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.pan(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.picture(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pic(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pics(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pix(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.tileset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.tset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.title(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.ti(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.windowskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.wskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.tile(filename, tile_id, hue)
key = [filename, tile_id, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = Bitmap.new(32, 32)
x = (tile_id - 384) % 8 * 32
y = (tile_id - 384) / 8 * 32
rect = Rect.new(x, y, 32, 32)
@cache[key].blt(0, 0, self.tileset(filename), rect)
@cache[key].hue_change(hue)
end
@cache[key]
end
def self.clear
@cache = {}
GC.start
end
end
# Make Grab Module
module Grab
@cache = {}
def self.load_bitmap(folder_name, filename, hue = 0)
path = folder_name + filename
if not @cache.include?(path) or @cache[path].disposed?
if filename != ""
@cache[path] = Bitmap.new(path)
else
@cache[path] = Bitmap.new(32, 32)
end
end
if hue == 0
@cache[path]
else
key = [path, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = @cache[path].clone
@cache[key].hue_change(hue)
end
@cache[key]
end
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.ani(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.autotile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.atile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.battleback(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.batbck(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/", filename, hue)
end
def self.bat(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.ch(filename, hue)
self.load_bitmap("Graphics/Characters/", filename, hue)
end
def self.char(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.fg(filename, hue)
self.load_bitmap("Graphics/Fogs/", filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/", filename)
end
def self.go(filename, hue = 0)
self.load_bitmap("Graphics/Gameovers/", filename, hue)
end
def self.icon(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.ico(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.i(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.pan(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.picture(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pic(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pics(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pix(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.tileset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.tset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.title(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.ti(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.windowskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.wskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.tile(filename, tile_id, hue)
key = [filename, tile_id, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = Bitmap.new(32, 32)
x = (tile_id - 384) % 8 * 32
y = (tile_id - 384) / 8 * 32
rect = Rect.new(x, y, 32, 32)
@cache[key].blt(0, 0, self.tileset(filename), rect)
@cache[key].hue_change(hue)
end
@cache[key]
end
def self.clear
@cache = {}
GC.start
end
end
# Make Open Module
module Open
@cache = {}
def self.load_bitmap(folder_name, filename, hue = 0)
path = folder_name + filename
if not @cache.include?(path) or @cache[path].disposed?
if filename != ""
@cache[path] = Bitmap.new(path)
else
@cache[path] = Bitmap.new(32, 32)
end
end
if hue == 0
@cache[path]
else
key = [path, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = @cache[path].clone
@cache[key].hue_change(hue)
end
@cache[key]
end
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.ani(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.autotile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.atile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.battleback(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.batbck(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/", filename, hue)
end
def self.bat(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.ch(filename, hue)
self.load_bitmap("Graphics/Characters/", filename, hue)
end
def self.char(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.fg(filename, hue)
self.load_bitmap("Graphics/Fogs/", filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/", filename)
end
def self.go(filename, hue = 0)
self.load_bitmap("Graphics/Gameovers/", filename, hue)
end
def self.icon(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.ico(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.i(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.pan(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.picture(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pic(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pics(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pix(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.tileset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.tset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.title(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.ti(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.windowskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.wskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.tile(filename, tile_id, hue)
key = [filename, tile_id, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = Bitmap.new(32, 32)
x = (tile_id - 384) % 8 * 32
y = (tile_id - 384) / 8 * 32
rect = Rect.new(x, y, 32, 32)
@cache[key].blt(0, 0, self.tileset(filename), rect)
@cache[key].hue_change(hue)
end
@cache[key]
end
def self.clear
@cache = {}
GC.start
end
end
# Make Easy Cache Extensions
module C
@cache = {}
def self.load_bitmap(folder_name, filename, hue = 0)
path = folder_name + filename
if not @cache.include?(path) or @cache[path].disposed?
if filename != ""
@cache[path] = Bitmap.new(path)
else
@cache[path] = Bitmap.new(32, 32)
end
end
if hue == 0
@cache[path]
else
key = [path, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = @cache[path].clone
@cache[key].hue_change(hue)
end
@cache[key]
end
end
def self.animation(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.ani(filename, hue)
self.load_bitmap("Graphics/Animations/", filename, hue)
end
def self.autotile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.atile(filename, hue = 0)
self.load_bitmap("Graphics/Autotiles/", filename, hue)
end
def self.battleback(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.batbck(filename, hue = 0)
self.load_bitmap("Graphics/Battlebacks/", filename, hue)
end
def self.battler(filename, hue)
self.load_bitmap("Graphics/Battlers/", filename, hue)
end
def self.bat(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.ch(filename, hue)
self.load_bitmap("Graphics/Characters/", filename, hue)
end
def self.char(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.fg(filename, hue)
self.load_bitmap("Graphics/Fogs/", filename, hue)
end
def self.gameover(filename)
self.load_bitmap("Graphics/Gameovers/", filename)
end
def self.go(filename, hue = 0)
self.load_bitmap("Graphics/Gameovers/", filename, hue)
end
def self.icon(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.ico(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.i(filename, hue = 0)
self.load_bitmap("Graphics/Icons/", filename, hue)
end
def self.panorama(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.pan(filename, hue)
self.load_bitmap("Graphics/Panoramas/", filename, hue)
end
def self.picture(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pic(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pics(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.pix(filename, hue = 0)
self.load_bitmap("Graphics/Pictures/", filename, hue)
end
def self.tileset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.tset(filename, hue = 0)
self.load_bitmap("Graphics/Tilesets/", filename, hue)
end
def self.title(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.ti(filename, hue = 0)
self.load_bitmap("Graphics/Titles/", filename, hue)
end
def self.windowskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.wskin(filename, hue = 0)
self.load_bitmap("Graphics/Windowskins/", filename, hue)
end
def self.tile(filename, tile_id, hue)
key = [filename, tile_id, hue]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = Bitmap.new(32, 32)
x = (tile_id - 384) % 8 * 32
y = (tile_id - 384) / 8 * 32
rect = Rect.new(x, y, 32, 32)
@cache[key].blt(0, 0, self.tileset(filename), rect)
@cache[key].hue_change(hue)
end
@cache[key]
end
def self.clear
@cache = {}
GC.start
end
end