Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Cachext
- #--------------------------------------------------------------------------
- # DKP Cachext
- # Do not edit unless you really know what your doing!
- # Platform: VX Ace
- # Author: Dark paladin
- # Description: Just an update to the Cache module for use with scripts
- # created by me.
- # -------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # *Graphics
- #--------------------------------------------------------------------------
- #You can edit the stuff in purple between the "" to change folder location.
- #--------------------------------------------------------------------------
- # *Logo Folder
- #--------------------------------------------------------------------------
- def self.logo(filename)
- load_bitmap("Graphics/Logo/", filename)
- end
- #--------------------------------------------------------------------------
- # *Menu Graphics Folder
- #--------------------------------------------------------------------------
- def self.dpmenu(filename)
- load_bitmap("Graphics/DPmenu/Main/", filename)
- end
- def self.dpjournal(filename)
- load_bitmap("Graphics/DPmenu/Journal/", filename)
- end
- def self.dphud(filename)
- load_bitmap("Graphics/DPmenu/Hud/", filename)
- end
- #--------------------------------------------------------------------------
- # * Load Bitmap
- #--------------------------------------------------------------------------
- def self.load_bitmap(folder_name, filename, hue = 0)
- @cachext ||= {}
- if filename.empty?
- empty_bitmap
- elsif hue == 0
- normal_bitmap(folder_name + filename)
- else
- hue_changed_bitmap(folder_name + filename, hue)
- end
- end
- #--------------------------------------------------------------------------
- # * Create Empty Bitmap
- #--------------------------------------------------------------------------
- def self.empty_bitmap
- Bitmap.new(32, 32)
- end
- #--------------------------------------------------------------------------
- # * Create/Get Normal Bitmap
- #--------------------------------------------------------------------------
- def self.normal_bitmap(path)
- @cachext[path] = Bitmap.new(path) unless include?(path)
- @cachext[path]
- end
- #--------------------------------------------------------------------------
- # * Create/Get Hue-Changed Bitmap
- #--------------------------------------------------------------------------
- def self.hue_changed_bitmap(path, hue)
- key = [path, hue]
- unless include?(key)
- @cachext[key] = normal_bitmap(path).clone
- @cachext[key].hue_change(hue)
- end
- @cachext[key]
- end
- #--------------------------------------------------------------------------
- # * Check Cache Existence
- #--------------------------------------------------------------------------
- def self.include?(key)
- @cachext[key] && !@cachext[key].disposed?
- end
- #--------------------------------------------------------------------------
- # * Clear Cache
- #--------------------------------------------------------------------------
- def self.clear
- @cachext ||= {}
- @cachext.clear
- GC.start
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement