Module: RPG::Cache
- Defined in:
- scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb
Overview
Script that cache bitmaps when they are reusable.
Constant Summary collapse
- LOADS =
Array of load methods to call when the game starts
%i[load_animation load_autotile load_ball load_battleback load_battler load_character load_fog load_icon load_panorama load_particle load_pc load_picture load_pokedex load_title load_tileset load_transition load_interface load_foot_print load_b_icon load_poke_front load_poke_back]
- GIF_EXTENSION =
Extension of gif files
'.gif'
- Common_filename =
Common filename of the image to load
'Graphics/%s/%s'
- Common_filename_format =
Common filename with .png
format('%s.png', Common_filename)
- Notification_title =
Notification message when an image couldn't be loaded properly
'Failed to load graphic'
- Autotiles_Path =
Path where autotiles are stored from Graphics
'autotiles'
- Animations_Path =
Path where animations are stored from Graphics
'animations'
- Ball_Path =
Path where ball are stored from Graphics
'ball'
- BattleBacks_Path =
Path where battlebacks are stored from Graphics
'battlebacks'
- Battlers_Path =
Path where battlers are stored from Graphics
'battlers'
- Characters_Path =
Path where characters are stored from Graphics
'characters'
- Fogs_Path =
Path where fogs are stored from Graphics
'fogs'
- Icons_Path =
Path where icons are stored from Graphics
'icons'
- Interface_Path =
Path where interface are stored from Graphics
'interface'
- Panoramas_Path =
Path where panoramas are stored from Graphics
'panoramas'
- Particles_Path =
Path where particles are stored from Graphics
'particles'
- PC_Path =
Path where pc are stored from Graphics
'pc'
- Pictures_Path =
Path where pictures are stored from Graphics
'pictures'
- Pokedex_Path =
Path where pokedex images are stored from Graphics
'pokedex'
- Titles_Path =
Path where titles are stored from Graphics
'titles'
- Tilesets_Path =
Path where tilesets are stored from Graphics
'tilesets'
- Transitions_Path =
Path where transitions are stored from Graphics
'transitions'
- Windowskins_Path =
Path where windowskins are stored from Graphics
'windowskins'
- Pokedex_FootPrints_Path =
Path where footprints are stored from Graphics
'pokedex/footprints'
- Pokedex_PokeIcon_Path =
Path where pokeicon are stored from Graphics
'pokedex/pokeicon'
- Pokedex_PokeFront_Path =
Path where pokefront are stored from Graphics
['pokedex/pokefront', 'pokedex/pokefrontshiny']
- Pokedex_PokeBack_Path =
Path where pokeback are stored from Graphics
['pokedex/pokeback', 'pokedex/pokebackshiny']
- Cache_meta_without_hue =
Meta defintion of the cache loading without hue (shiny processing)
<<-CACHE_META_PROGRAMMATION LOADS << :load_%<cache_name>s %<cache_constant>s_Path = '%<cache_path>s' module_function def load_%<cache_name>s(flush_it = false) unless flush_it @%<cache_name>s_cache = {} @%<cache_name>s_data = Yuki::VD.new(PSDK_PATH + '/master/%<cache_name>s', :read) else dispose_bitmaps_from_cache_tab(@%<cache_name>s_cache) end end def %<cache_name>s_exist?(filename) test_file_existence(filename, %<cache_constant>s_Path, @%<cache_name>s_data) end def %<cache_name>s(filename, _hue = 0) load_image(@%<cache_name>s_cache, filename, %<cache_constant>s_Path, @%<cache_name>s_data) end def extract_%<cache_name>s(path = '') path += %<cache_constant>s_Path ori = Dir.pwd Dir.mkdir!(path.downcase) Dir.chdir(path.downcase) @%<cache_name>s_data.get_filenames.each do |filename| if filename.include?('/') dirname = File.dirname(filename) Dir.mkdir!(dirname) unless Dir.exist?(dirname) end was_cached = @%<cache_name>s_cache[filename] != nil bmp = %<cache_name>s(filename) bmp.to_png_file(filename + '.png') bmp.dispose unless was_cached end ensure Dir.chdir(ori) end CACHE_META_PROGRAMMATION
- Cache_meta_with_hue =
Meta definition of the cache loading with hue (shiny processing)
<<-CACHE_META_PROGRAMMATION LOADS << :load_%<cache_name>s %<cache_constant>s_Path = [%<cache_path>s] module_function def load_%<cache_name>s(flush_it = false) unless flush_it @%<cache_name>s_cache = Array.new(%<cache_constant>s_Path.size) { {} } @%<cache_name>s_data = [ Yuki::VD.new(PSDK_PATH + '/master/%<cache_name>s', :read), Yuki::VD.new(PSDK_PATH + '/master/%<cache_name>s_s', :read)] else @%<cache_name>s_cache.each { |cache_tab| dispose_bitmaps_from_cache_tab(cache_tab) } end end def %<cache_name>s_exist?(filename, hue = 0) test_file_existence(filename, %<cache_constant>s_Path.fetch(hue), @%<cache_name>s_data[hue]) end def %<cache_name>s(filename, hue = 0) load_image(@%<cache_name>s_cache.fetch(hue), filename, %<cache_constant>s_Path.fetch(hue), @%<cache_name>s_data[hue]) end def extract_%<cache_name>s(path = '', hue = 0) path += %<cache_constant>s_Path[hue] ori = Dir.pwd Dir.mkdir!(path.downcase) Dir.chdir(path.downcase) @%<cache_name>s_data[hue].get_filenames.each do |filename| if filename.include?('/') dirname = File.dirname(filename) Dir.mkdir!(dirname) unless Dir.exist?(dirname) end was_cached = @%<cache_name>s_cache[hue][filename] != nil bmp = %<cache_name>s(filename, hue) bmp.to_png_file(filename + '.png') bmp.dispose unless was_cached end ensure Dir.chdir(ori) end CACHE_META_PROGRAMMATION
Class Method Summary collapse
-
.animation(filename, _hue = 0) ⇒ Texture
Load an animation image.
-
.animation_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.autotile(filename, _hue = 0) ⇒ Texture
Load an autotile image.
-
.autotile_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.b_icon(filename, _hue = 0) ⇒ Texture
Load a Pokemon icon image.
-
.b_icon_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.ball(filename, _hue = 0) ⇒ Texture
Load ball animation image.
-
.ball_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.battleback(filename, _hue = 0) ⇒ Texture
Load a battle back image.
-
.battleback_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.battler(filename, _hue = 0) ⇒ Texture
Load a battler image.
-
.battler_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.character(filename, _hue = 0) ⇒ Texture
Load a character image.
-
.character_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.default_bitmap
Gets the default bitmap.
-
.dispose_bitmaps_from_cache_tab(cache_tab)
Dispose every bitmap of a cache table.
-
.fog(filename, _hue = 0) ⇒ Texture
Load a fog image.
-
.fog_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.foot_print(filename, _hue = 0) ⇒ Texture
Load a foot print image.
-
.foot_print_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.icon(filename, _hue = 0) ⇒ Texture
Load an icon.
-
.icon_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.interface(filename, _hue = 0) ⇒ Texture
Load an interface image.
-
.interface_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.interface_image(filename) ⇒ Image
Load an interface “Image” (to perform some background process).
-
.load_animation(flush_it = false)
Load/unload the animation cache.
-
.load_autotile(flush_it = false)
Load/unload the autotile cache.
-
.load_b_icon(flush_it = false)
Load/unload the pokemon icon cache.
-
.load_ball(flush_it = false)
Load/unload the ball cache.
-
.load_battleback(flush_it = false)
Load/unload the battleback cache.
-
.load_battler(flush_it = false)
Load/unload the battler cache.
-
.load_character(flush_it = false)
Load/unload the character cache.
-
.load_fog(flush_it = false)
Load/unload the fog cache.
-
.load_foot_print(flush_it = false)
Load/unload the foot print cache.
-
.load_icon(flush_it = false)
Load/unload the icon cache.
-
.load_image(cache_tab, filename, path, file_data = nil, image_class = Texture) ⇒ Texture
Loads an image (from cache, disk or virtual directory).
-
.load_image_from_file_data(filename, file_data, image_class) ⇒ Texture
Loads an image from virtual directory with the right encoding.
-
.load_interface(flush_it = false)
Load/unload the interface cache.
-
.load_panorama(flush_it = false)
Load/unload the panorama cache.
-
.load_particle(flush_it = false)
Load/unload the particle cache.
-
.load_pc(flush_it = false)
Load/unload the pc cache.
-
.load_picture(flush_it = false)
Load/unload the picture cache.
-
.load_poke_back(flush_it = false)
Load/unload the pokemon back cache.
-
.load_poke_front(flush_it = false)
Load/unload the pokemon front cache.
-
.load_pokedex(flush_it = false)
Load/unload the pokedex cache.
-
.load_tileset(flush_it = false)
Load/unload the tileset cache.
-
.load_title(flush_it = false)
Load/unload the title cache.
-
.load_transition(flush_it = false)
Load/unload the transition cache.
-
.load_windowskin(flush_it = false)
Load/unload the windoskin cache.
-
.meta_exec(line, name, constant, path, meta_code = Cache_meta_without_hue)
Execute a meta code generation (undef when done).
-
.panorama(filename, _hue = 0) ⇒ Texture
Load a panorama image.
-
.panorama_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.particle(filename, _hue = 0) ⇒ Texture
Load a particle image.
-
.particle_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.pc(filename, _hue = 0) ⇒ Texture
Load a pc image.
-
.pc_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.picture(filename, _hue = 0) ⇒ Texture
Load a picture image.
-
.picture_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.poke_back(filename, hue = 0) ⇒ Texture
Load a pokemon back image.
-
.poke_back_exist?(filename, hue = 0) ⇒ Boolean
Test if the image exist in the folder.
-
.poke_front(filename, hue = 0) ⇒ Texture
Load a pokemon face image.
-
.poke_front_exist?(filename, hue = 0) ⇒ Boolean
Test if the image exist in the folder.
-
.pokedex(filename, _hue = 0) ⇒ Texture
Load a pokedex image.
-
.pokedex_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.test_file_existence(filename, path, file_data = nil) ⇒ Boolean
Test if a file exist.
-
.tileset(filename, _hue = 0) ⇒ Texture
Load a tileset image.
-
.tileset_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.tileset_image(filename) ⇒ Image
Load a tileset “Image” (to perform some background process).
-
.title(filename, _hue = 0) ⇒ Texture
Load a title image.
-
.title_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.transition(filename, _hue = 0) ⇒ Texture
Load a transition image.
-
.transition_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
-
.windowskin(filename, _hue = 0) ⇒ Texture
Load a windowskin image.
-
.windowskin_exist?(filename) ⇒ Boolean
Test if the image exist in the folder.
Class Method Details
.animation(filename, _hue = 0) ⇒ Texture
Load an animation image
155 156 157 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 155 def animation(filename, _hue = 0) load_image(@animation_cache, filename, Animations_Path, @animation_data) end |
.animation_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
147 148 149 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 147 def animation_exist?(filename) test_file_existence(filename, Animations_Path, @animation_data) end |
.autotile(filename, _hue = 0) ⇒ Texture
Load an autotile image
181 182 183 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 181 def autotile(filename, _hue = 0) load_image(@autotile_cache, filename, Autotiles_Path, @autotile_data) end |
.autotile_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
173 174 175 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 173 def autotile_exist?(filename) test_file_existence(filename, Autotiles_Path, @autotile_data) end |
.b_icon(filename, _hue = 0) ⇒ Texture
Load a Pokemon icon image
671 672 673 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 671 def b_icon(filename, _hue = 0) load_image(@b_icon_cache, filename, Pokedex_PokeIcon_Path, @b_icon_data) end |
.b_icon_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
663 664 665 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 663 def b_icon_exist?(filename) test_file_existence(filename, Pokedex_PokeIcon_Path, @b_icon_data) end |
.ball(filename, _hue = 0) ⇒ Texture
Load ball animation image
207 208 209 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 207 def ball(filename, _hue = 0) load_image(@ball_cache, filename, Ball_Path, @ball_data) end |
.ball_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
199 200 201 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 199 def ball_exist?(filename) test_file_existence(filename, Ball_Path, @ball_data) end |
.battleback(filename, _hue = 0) ⇒ Texture
Load a battle back image
233 234 235 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 233 def battleback(filename, _hue = 0) load_image(@battleback_cache, filename, BattleBacks_Path, @battleback_data) end |
.battleback_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
225 226 227 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 225 def battleback_exist?(filename) test_file_existence(filename, BattleBacks_Path, @battleback_data) end |
.battler(filename, _hue = 0) ⇒ Texture
Load a battler image
259 260 261 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 259 def battler(filename, _hue = 0) load_image(@battler_cache, filename, Battlers_Path, @battler_data) end |
.battler_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
251 252 253 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 251 def battler_exist?(filename) test_file_existence(filename, Battlers_Path, @battler_data) end |
.character(filename, _hue = 0) ⇒ Texture
Load a character image
285 286 287 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 285 def character(filename, _hue = 0) load_image(@character_cache, filename, Characters_Path, @character_data) end |
.character_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
277 278 279 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 277 def character_exist?(filename) test_file_existence(filename, Characters_Path, @character_data) end |
.default_bitmap
Should be used in scripts that require a bitmap be doesn't perform anything on the bitmap
Gets the default bitmap
66 67 68 69 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 66 def default_bitmap @default_bitmap = Texture.new(16, 16) if @default_bitmap&.disposed? @default_bitmap end |
.dispose_bitmaps_from_cache_tab(cache_tab)
Dispose every bitmap of a cache table
73 74 75 76 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 73 def dispose_bitmaps_from_cache_tab(cache_tab) cache_tab.each_value { |bitmap| bitmap.dispose if bitmap && !bitmap.disposed? } cache_tab.clear end |
.fog(filename, _hue = 0) ⇒ Texture
Load a fog image
311 312 313 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 311 def fog(filename, _hue = 0) load_image(@fog_cache, filename, Fogs_Path, @fog_data) end |
.fog_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
303 304 305 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 303 def fog_exist?(filename) test_file_existence(filename, Fogs_Path, @fog_data) end |
.foot_print(filename, _hue = 0) ⇒ Texture
Load a foot print image
645 646 647 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 645 def foot_print(filename, _hue = 0) load_image(@foot_print_cache, filename, Pokedex_FootPrints_Path, @foot_print_data) end |
.foot_print_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
637 638 639 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 637 def foot_print_exist?(filename) test_file_existence(filename, Pokedex_FootPrints_Path, @foot_print_data) end |
.icon(filename, _hue = 0) ⇒ Texture
Load an icon
337 338 339 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 337 def icon(filename, _hue = 0) load_image(@icon_cache, filename, Icons_Path, @icon_data) end |
.icon_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
329 330 331 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 329 def icon_exist?(filename) test_file_existence(filename, Icons_Path, @icon_data) end |
.interface(filename, _hue = 0) ⇒ Texture
Load an interface image
363 364 365 366 367 368 369 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 363 def interface(filename, _hue = 0) if interface_exist?(filename_with_language = filename + ($options&.language || 'en')) || interface_exist?(filename_with_language = filename + 'en') filename = filename_with_language end load_image(@interface_cache, filename, Interface_Path, @interface_data) end |
.interface_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
355 356 357 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 355 def interface_exist?(filename) test_file_existence(filename, Interface_Path, @interface_data) end |
.interface_image(filename) ⇒ Image
Load an interface “Image” (to perform some background process)
374 375 376 377 378 379 380 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 374 def interface_image(filename) if interface_exist?(filename_with_language = filename + ($options&.language || 'en')) || interface_exist?(filename_with_language = filename + 'en') filename = filename_with_language end load_image(@interface_cache, filename, Interface_Path, @interface_data, Image) end |
.load_animation(flush_it = false)
Load/unload the animation cache
135 136 137 138 139 140 141 142 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 135 def load_animation(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@animation_cache) else @animation_cache = {} @animation_data = Yuki::VD.new(PSDK_PATH + '/master/animation', :read) end end |
.load_autotile(flush_it = false)
Load/unload the autotile cache
161 162 163 164 165 166 167 168 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 161 def load_autotile(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@autotile_cache) else @autotile_cache = {} @autotile_data = Yuki::VD.new(PSDK_PATH + '/master/autotile', :read) end end |
.load_b_icon(flush_it = false)
Load/unload the pokemon icon cache
651 652 653 654 655 656 657 658 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 651 def load_b_icon(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@b_icon_cache) else @b_icon_cache = {} @b_icon_data = Yuki::VD.new(PSDK_PATH + '/master/b_icon', :read) end end |
.load_ball(flush_it = false)
Load/unload the ball cache
187 188 189 190 191 192 193 194 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 187 def load_ball(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@ball_cache) else @ball_cache = {} @ball_data = Yuki::VD.new(PSDK_PATH + '/master/ball', :read) end end |
.load_battleback(flush_it = false)
Load/unload the battleback cache
213 214 215 216 217 218 219 220 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 213 def load_battleback(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@battleback_cache) else @battleback_cache = {} @battleback_data = Yuki::VD.new(PSDK_PATH + '/master/battleback', :read) end end |
.load_battler(flush_it = false)
Load/unload the battler cache
239 240 241 242 243 244 245 246 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 239 def load_battler(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@battler_cache) else @battler_cache = {} @battler_data = Yuki::VD.new(PSDK_PATH + '/master/battler', :read) end end |
.load_character(flush_it = false)
Load/unload the character cache
265 266 267 268 269 270 271 272 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 265 def load_character(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@character_cache) else @character_cache = {} @character_data = Yuki::VD.new(PSDK_PATH + '/master/character', :read) end end |
.load_fog(flush_it = false)
Load/unload the fog cache
291 292 293 294 295 296 297 298 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 291 def load_fog(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@fog_cache) else @fog_cache = {} @fog_data = Yuki::VD.new(PSDK_PATH + '/master/fog', :read) end end |
.load_foot_print(flush_it = false)
Load/unload the foot print cache
625 626 627 628 629 630 631 632 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 625 def load_foot_print(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@foot_print_cache) else @foot_print_cache = {} @foot_print_data = Yuki::VD.new(PSDK_PATH + '/master/foot_print', :read) end end |
.load_icon(flush_it = false)
Load/unload the icon cache
317 318 319 320 321 322 323 324 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 317 def load_icon(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@icon_cache) else @icon_cache = {} @icon_data = Yuki::VD.new(PSDK_PATH + '/master/icon', :read) end end |
.load_image(cache_tab, filename, path, file_data = nil, image_class = Texture) ⇒ Texture
This function displays a desktop notification if the image is not found. The resultat bitmap is an empty 16x16 bitmap in this case.
Loads an image (from cache, disk or virtual directory)
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 100 def load_image(cache_tab, filename, path, file_data = nil, image_class = Texture) complete_filename = format(Common_filename, path, filename).downcase return bitmap = image_class.new(16, 16) if File.directory?(complete_filename) || filename.empty? return File.binread(complete_filename) if File.exist?(complete_filename) bitmap = cache_tab.fetch(filename, nil) if !bitmap || bitmap.disposed? filename_ext = "#{complete_filename}.png" bitmap = image_class.new(filename_ext) if File.exist?(filename_ext) || !file_data.exists?(filename.downcase) bitmap = load_image_from_file_data(filename, file_data, image_class) if (!bitmap || bitmap.disposed?) && file_data bitmap ||= image_class.new(16, 16) end return bitmap rescue StandardError log_error "#{Notification_title} #{complete_filename}" return bitmap = image_class.new("\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x02\x03\x00\x00\x00\x0E\x14\x92g\x00\x00\x00\tPLTE\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\xCD^\xB7\x9C\x00\x00\x00>IDATx\x01\x85\xCF1\x0E\x00 \bCQ\x17\xEF\xE7\xD2\x85\xFB\xB1\xF4\x94&$Fm\a\xFE\xF4\x06B`x\x13\xD5z\xC0\xEA\a H \x04\x91\x02\xD2\x01E\x9E\xCD\x17\xD1\xC3/\xECg\xECSk\x03[\xAFg\x99\xE2\xED\xCFV\x00\x00\x00\x00IEND\xAEB`\x82", true) ensure cache_tab[filename] = bitmap if bitmap.is_a?(Texture) end |
.load_image_from_file_data(filename, file_data, image_class) ⇒ Texture
Loads an image from virtual directory with the right encoding
125 126 127 128 129 130 131 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 125 def load_image_from_file_data(filename, file_data, image_class) bitmap_data = file_data.read_data(filename.downcase) return bitmap_data if filename.end_with?(GIF_EXTENSION) bitmap = image_class.new(bitmap_data, true) if bitmap_data bitmap end |
.load_interface(flush_it = false)
Load/unload the interface cache
343 344 345 346 347 348 349 350 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 343 def load_interface(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@interface_cache) else @interface_cache = {} @interface_data = Yuki::VD.new(PSDK_PATH + '/master/interface', :read) end end |
.load_panorama(flush_it = false)
Load/unload the panorama cache
384 385 386 387 388 389 390 391 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 384 def load_panorama(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@panorama_cache) else @panorama_cache = {} @panorama_data = Yuki::VD.new(PSDK_PATH + '/master/panorama', :read) end end |
.load_particle(flush_it = false)
Load/unload the particle cache
410 411 412 413 414 415 416 417 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 410 def load_particle(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@particle_cache) else @particle_cache = {} @particle_data = Yuki::VD.new(PSDK_PATH + '/master/particle', :read) end end |
.load_pc(flush_it = false)
Load/unload the pc cache
436 437 438 439 440 441 442 443 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 436 def load_pc(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@pc_cache) else @pc_cache = {} @pc_data = Yuki::VD.new(PSDK_PATH + '/master/pc', :read) end end |
.load_picture(flush_it = false)
Load/unload the picture cache
462 463 464 465 466 467 468 469 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 462 def load_picture(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@picture_cache) else @picture_cache = {} @picture_data = Yuki::VD.new(PSDK_PATH + '/master/picture', :read) end end |
.load_poke_back(flush_it = false)
Load/unload the pokemon back cache
707 708 709 710 711 712 713 714 715 716 717 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 707 def load_poke_back(flush_it = false) if flush_it @poke_back_cache.each { |cache_tab| dispose_bitmaps_from_cache_tab(cache_tab) } else @poke_back_cache = Array.new(Pokedex_PokeBack_Path.size) { {} } @poke_back_data = [ Yuki::VD.new(PSDK_PATH + '/master/poke_back', :read), Yuki::VD.new(PSDK_PATH + '/master/poke_back_s', :read) ] end end |
.load_poke_front(flush_it = false)
Load/unload the pokemon front cache
677 678 679 680 681 682 683 684 685 686 687 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 677 def load_poke_front(flush_it = false) if flush_it @poke_front_cache.each { |cache_tab| dispose_bitmaps_from_cache_tab(cache_tab) } else @poke_front_cache = Array.new(Pokedex_PokeFront_Path.size) { {} } @poke_front_data = [ Yuki::VD.new(PSDK_PATH + '/master/poke_front', :read), Yuki::VD.new(PSDK_PATH + '/master/poke_front_s', :read) ] end end |
.load_pokedex(flush_it = false)
Load/unload the pokedex cache
488 489 490 491 492 493 494 495 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 488 def load_pokedex(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@pokedex_cache) else @pokedex_cache = {} @pokedex_data = Yuki::VD.new(PSDK_PATH + '/master/pokedex', :read) end end |
.load_tileset(flush_it = false)
Load/unload the tileset cache
540 541 542 543 544 545 546 547 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 540 def load_tileset(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@tileset_cache) else @tileset_cache = {} @tileset_data = Yuki::VD.new(PSDK_PATH + '/master/tileset', :read) end end |
.load_title(flush_it = false)
Load/unload the title cache
514 515 516 517 518 519 520 521 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 514 def load_title(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@title_cache) else @title_cache = {} @title_data = Yuki::VD.new(PSDK_PATH + '/master/title', :read) end end |
.load_transition(flush_it = false)
Load/unload the transition cache
573 574 575 576 577 578 579 580 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 573 def load_transition(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@transition_cache) else @transition_cache = {} @transition_data = Yuki::VD.new(PSDK_PATH + '/master/transition', :read) end end |
.load_windowskin(flush_it = false)
Load/unload the windoskin cache
599 600 601 602 603 604 605 606 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 599 def load_windowskin(flush_it = false) if flush_it dispose_bitmaps_from_cache_tab(@windowskin_cache) else @windowskin_cache = {} @windowskin_data = Yuki::VD.new(PSDK_PATH + '/master/windowskin', :read) end end |
.meta_exec(line, name, constant, path, meta_code = Cache_meta_without_hue)
Execute a meta code generation (undef when done)
822 823 824 825 826 827 828 829 830 831 832 833 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 822 def (line, name, constant, path, = Cache_meta_without_hue) module_eval( format( , cache_name: name, cache_constant: constant, cache_path: path ), __FILE__, line ) end |
.panorama(filename, _hue = 0) ⇒ Texture
Load a panorama image
404 405 406 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 404 def panorama(filename, _hue = 0) load_image(@panorama_cache, filename, Panoramas_Path, @panorama_data) end |
.panorama_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
396 397 398 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 396 def panorama_exist?(filename) test_file_existence(filename, Panoramas_Path, @panorama_data) end |
.particle(filename, _hue = 0) ⇒ Texture
Load a particle image
430 431 432 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 430 def particle(filename, _hue = 0) load_image(@particle_cache, filename, Particles_Path, @particle_data) end |
.particle_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
422 423 424 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 422 def particle_exist?(filename) test_file_existence(filename, Particles_Path, @particle_data) end |
.pc(filename, _hue = 0) ⇒ Texture
Load a pc image
456 457 458 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 456 def pc(filename, _hue = 0) load_image(@pc_cache, filename, PC_Path, @pc_data) end |
.pc_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
448 449 450 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 448 def pc_exist?(filename) test_file_existence(filename, PC_Path, @pc_data) end |
.picture(filename, _hue = 0) ⇒ Texture
Load a picture image
482 483 484 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 482 def picture(filename, _hue = 0) load_image(@picture_cache, filename, Pictures_Path, @picture_data) end |
.picture_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
474 475 476 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 474 def picture_exist?(filename) test_file_existence(filename, Pictures_Path, @picture_data) end |
.poke_back(filename, hue = 0) ⇒ Texture
Load a pokemon back image
731 732 733 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 731 def poke_back(filename, hue = 0) load_image(@poke_back_cache.fetch(hue), filename, Pokedex_PokeBack_Path.fetch(hue), @poke_back_data[hue]) end |
.poke_back_exist?(filename, hue = 0) ⇒ Boolean
Test if the image exist in the folder
723 724 725 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 723 def poke_back_exist?(filename, hue = 0) test_file_existence(filename, Pokedex_PokeBack_Path.fetch(hue), @poke_back_data[hue]) end |
.poke_front(filename, hue = 0) ⇒ Texture
Load a pokemon face image
701 702 703 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 701 def poke_front(filename, hue = 0) load_image(@poke_front_cache.fetch(hue), filename, Pokedex_PokeFront_Path.fetch(hue), @poke_front_data[hue]) end |
.poke_front_exist?(filename, hue = 0) ⇒ Boolean
Test if the image exist in the folder
693 694 695 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 693 def poke_front_exist?(filename, hue = 0) test_file_existence(filename, Pokedex_PokeFront_Path.fetch(hue), @poke_front_data[hue]) end |
.pokedex(filename, _hue = 0) ⇒ Texture
Load a pokedex image
508 509 510 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 508 def pokedex(filename, _hue = 0) load_image(@pokedex_cache, filename, Pokedex_Path, @pokedex_data) end |
.pokedex_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
500 501 502 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 500 def pokedex_exist?(filename) test_file_existence(filename, Pokedex_Path, @pokedex_data) end |
.test_file_existence(filename, path, file_data = nil) ⇒ Boolean
Test if a file exist
83 84 85 86 87 88 89 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 83 def test_file_existence(filename, path, file_data = nil) return true if file_data&.exists?(filename.downcase) return true if File.exist?(format(Common_filename_format, path, filename).downcase) return true if File.exist?(format(Common_filename, path, filename).downcase) false end |
.tileset(filename, _hue = 0) ⇒ Texture
Load a tileset image
560 561 562 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 560 def tileset(filename, _hue = 0) load_image(@tileset_cache, filename, Tilesets_Path, @tileset_data) end |
.tileset_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
552 553 554 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 552 def tileset_exist?(filename) test_file_existence(filename, Tilesets_Path, @tileset_data) end |
.tileset_image(filename) ⇒ Image
Load a tileset “Image” (to perform some background process)
567 568 569 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 567 def tileset_image(filename) load_image(@tileset_cache, filename, Tilesets_Path, @tileset_data, Image) end |
.title(filename, _hue = 0) ⇒ Texture
Load a title image
534 535 536 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 534 def title(filename, _hue = 0) load_image(@title_cache, filename, Titles_Path, @title_data) end |
.title_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
526 527 528 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 526 def title_exist?(filename) test_file_existence(filename, Titles_Path, @title_data) end |
.transition(filename, _hue = 0) ⇒ Texture
Load a transition image
593 594 595 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 593 def transition(filename, _hue = 0) load_image(@transition_cache, filename, Transitions_Path, @transition_data) end |
.transition_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
585 586 587 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 585 def transition_exist?(filename) test_file_existence(filename, Transitions_Path, @transition_data) end |
.windowskin(filename, _hue = 0) ⇒ Texture
Load a windowskin image
619 620 621 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 619 def windowskin(filename, _hue = 0) load_image(@windowskin_cache, filename, Windowskins_Path, @windowskin_data) end |
.windowskin_exist?(filename) ⇒ Boolean
Test if the image exist in the folder
611 612 613 |
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00100 RPG__Cache.rb', line 611 def windowskin_exist?(filename) test_file_existence(filename, Windowskins_Path, @windowskin_data) end |