Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

DoubleX RMMV Preloaded Resources

DoubleX

Member
Joined
Nov 25, 2015
Messages
244
Points
18
Purpose
Lets you sets some audios/images to be loaded upon game start
This should boost the FPS on phones noticeably if there's enough memory

Parameters
Code:
<div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="" class="li1"> * @param IsPreloadAudio</li><li style="" class="li2"> * @type boolean</li><li style="" class="li1"> * @desc Sets whether the specified audios will be preloaded</li><li style="" class="li2"> * @default true</li><li style="" class="li1"> *</li><li style="" class="li2"> * @param preloadAudioMSInterval</li><li style="" class="li1"> * @parent IsPreloadAudio</li><li style="" class="li2"> * @type number</li><li style="" class="li1"> * @desc Sets the number of milliseconds to wait before loading the</li><li style="" class="li2"> * next audio included by the same parameter(0 means no wait)</li><li style="" class="li1"> * @default 0</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedBGMs</li><li style="" class="li2"> * @parent IsPreloadAudio</li><li style="" class="li1"> * @type file[]</li><li style="" class="li2"> * @dir audio/bgm/</li><li style="" class="li1"> * @desc Sets the list of BGMs to be preloaded</li><li style="" class="li2"> * @default []</li><li style="" class="li1"> *</li><li style="" class="li2"> * @param preloadedBGSs</li><li style="" class="li1"> * @parent IsPreloadAudio</li><li style="" class="li2"> * @type file[]</li><li style="" class="li1"> * @dir audio/bgs/</li><li style="" class="li2"> * @desc Sets the list of BGSs to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedMEs</li><li style="" class="li2"> * @parent IsPreloadAudio</li><li style="" class="li1"> * @type file[]</li><li style="" class="li2"> * @dir audio/me/</li><li style="" class="li1"> * @desc Sets the list of MEs to be preloaded</li><li style="" class="li2"> * @default []</li><li style="" class="li1"> *</li><li style="" class="li2"> * @param preloadedSEs</li><li style="" class="li1"> * @parent IsPreloadAudio</li><li style="" class="li2"> * @type file[]</li><li style="" class="li1"> * @dir audio/se/</li><li style="" class="li2"> * @desc Sets the list of SEs to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedStaticSEs</li><li style="" class="li2"> * @parent IsPreloadAudio</li><li style="" class="li1"> * @type file[]</li><li style="" class="li2"> * @dir audio/se/</li><li style="" class="li1"> * @desc Sets the list of static SEs to be preloaded</li><li style="" class="li2"> * @default []</li><li style="" class="li1"> *</li><li style="" class="li2"> * @param preloadedMiscAudios</li><li style="" class="li1"> * @parent IsPreloadAudio</li><li style="" class="li2"> * @type file[]</li><li style="" class="li1"> * @dir audio/</li><li style="" class="li2"> * @desc Sets the list of other audio files to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param IsPreloadImage</li><li style="" class="li2"> * @type boolean</li><li style="" class="li1"> * @desc Sets whether the specified images will be preloaded</li><li style="" class="li2"> * @default true</li><li style="" class="li1"> *</li><li style="" class="li2"> * @param preloadImageMSInterval</li><li style="" class="li1"> * @parent IsPreloadImage</li><li style="" class="li2"> * @type number</li><li style="" class="li1"> * @desc Sets the number of milliseconds to wait before loading the</li><li style="" class="li2"> * next hue and image under the same parameter(0 means no wait)</li><li style="" class="li1"> * @default 0</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedAnimations</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedAnimation>[]</li><li style="" class="li2"> * @desc Sets the list of animations to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedBattleBack1s</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedBattleBack1>[]</li><li style="" class="li2"> * @desc Sets the list of 1st battle backs to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedBattleBack2s</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedBattleBack2>[]</li><li style="" class="li2"> * @desc Sets the list of 2nd battle backs to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedCharacters</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedCharacter>[]</li><li style="" class="li2"> * @desc Sets the list of characters to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedEnemies</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedEnemy>[]</li><li style="" class="li2"> * @desc Sets the list of enemies to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedFaces</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedFace>[]</li><li style="" class="li2"> * @desc Sets the list of faces to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedParallaxes</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedParallax>[]</li><li style="" class="li2"> * @desc Sets the list of parallaxes to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedPictures</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedPicture>[]</li><li style="" class="li2"> * @desc Sets the list of pictures to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedSVActors</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedSVActor>[]</li><li style="" class="li2"> * @desc Sets the list of sideview actors to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedSVEnemies</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedSVEnemy>[]</li><li style="" class="li2"> * @desc Sets the list of sideview enemies to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedSystem</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedSystem>[]</li><li style="" class="li2"> * @desc Sets the list of system images to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedTilesets</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedTileset>[]</li><li style="" class="li2"> * @desc Sets the list of tilesets to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedTitles1</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedTitle1>[]</li><li style="" class="li2"> * @desc Sets the list of 1st titles to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedTitles2</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedTitle2>[]</li><li style="" class="li2"> * @desc Sets the list of 2nd titles to be preloaded</li><li style="" class="li1"> * @default []</li><li style="" class="li2"> *</li><li style="" class="li1"> * @param preloadedMiscImages</li><li style="" class="li2"> * @parent IsPreloadImage</li><li style="" class="li1"> * @type struct<PreloadedMiscImage>[]</li><li style="" class="li2"> * @desc Sets the list of other image files to be preloaded</li><li style="" class="li1"> * @default []</li></ol></div>

Help
Code:
<div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="" class="li1"> * 1. You should only preload resources that are actually used or the game can</li><li style="" class="li2"> *    take an excessively and unnecessarily long time to start</li><li style="" class="li1"> * 2. You might have to test the values of preloadAudioMSInterval and</li><li style="" class="li2"> *    preloadImageMSInterval to have the optimal preload time for your project</li><li style="" class="li1"> * 3. Setting preloadAudioMSInterval/preloadImageMSInterval as 0 might block</li><li style="" class="li2"> *    the UI thread for too long and thus crashing/freezing the game in phones</li><li style="" class="li1"> * 4. You should consider not preloading resources that are only rarely used</li><li style="" class="li2"> *    in case the preloading times are still too long</li><li style="" class="li1"> * 5. Some plugins might use HTML5Audio instead of WebAudio, and preloading</li><li style="" class="li2"> *    audios using HTML5Audio is meaningless HTML5Audio is a static class</li><li style="" class="li1"> *    having nothing to preload</li><li style="" class="li2"> * 6. You should compress the resources to be preoloaded for phones or the</li><li style="" class="li1"> *    extra memory consumption from preloading them can quickly crash/free the</li><li style="" class="li2"> *    game there</li><li style="" class="li1"> * 7. No identical resource should be duplicated in the same parameter or</li><li style="" class="li2"> *    across parameters(this plugin won't explicitly skip those duplicates as</li><li style="" class="li1"> *    simplifying the codes this way can actually reduce preload time)</li><li style="" class="li2"> * 8. If you want to keep the current parameter values in the plugin manager</li><li style="" class="li1"> *    upon using a newer version, you can do the following:</li><li style="" class="li2"> *    - Renames the newer version to be that of the older version</li><li style="" class="li1"> *    - Edits the value of DoubleX_RMMV.Preloaded_Resources_File to be the</li><li style="" class="li2"> *      filename of the older version, which must be done via opening this</li><li style="" class="li1"> *      plugin js file directly</li><li style="" class="li2"> * 9. (Advanced)By default, the images are cached upon first used, and the</li><li style="" class="li1"> *    cache is a Least Recently Used(LRU) cache. This plugin reserves all</li><li style="" class="li2"> *    preloaded images so the LRU will never release them unless they're</li><li style="" class="li1"> *    explicitly told to be released via a script call</li></ol></div>

Script Call Info
Code:
<div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="" class="li1"> *    # Image manipulations</li><li style="" class="li2"> *      1. ImageManager.releasePreloadedFolderImg(param, filename, hue)</li><li style="" class="li1"> *         - Releases the image with the filename filename and hue hue</li><li style="" class="li2"> *           specified in parameter param</li><li style="" class="li1"> *         - This can be useful when an image becomes rarely used and/or the</li><li style="" class="li2"> *           preloaded images are consuming too much memory</li><li style="" class="li1"> *         - Please note that using this script call doesn't always remove the</li><li style="" class="li2"> *           image from the LRU cache instantly as it's still up to the LRU</li><li style="" class="li1"> *           cache to determine when to remove that image now that it can be</li><li style="" class="li2"> *           removed due to no longer being reserved</li><li style="" class="li1"> *         - param and filename are supposed to be String</li><li style="" class="li2"> *         - hue is supposed to be an integer from 0 to 360 inclusive</li><li style="" class="li1"> *         - The script call's supposed to be Idempotent</li><li style="" class="li2"> *      2. ImageManager.releasePreloadedMiscImg(path, hue, smooth)</li><li style="" class="li1"> *         - Releases the image with the path path, hue hue and smooth smooth</li><li style="" class="li2"> *         - This can be useful when an image becomes rarely used and/or the</li><li style="" class="li1"> *           preloaded images are consuming too much memory</li><li style="" class="li2"> *         - Please note that using this script call doesn't always remove the</li><li style="" class="li1"> *           image from the LRU cache instantly as it's still up to the LRU</li><li style="" class="li2"> *           cache to determine when to remove that image now that it can be</li><li style="" class="li1"> *           removed due to no longer being reserved</li><li style="" class="li2"> *         - path is supposed to be a String</li><li style="" class="li1"> *         - hue is supposed to be an integer from 0 to 360 inclusive</li><li style="" class="li2"> *         - smooth is supposed to be a Boolean</li><li style="" class="li1"> *         - The script call's supposed to be Idempotent</li><li style="" class="li2"> *    # Audio manipulations</li><li style="" class="li1"> *      1. AudioManager.invalidateCachedWebAudio(folder, name)</li><li style="" class="li2"> *         - Releases the audio with folder folder and filename name from the</li><li style="" class="li1"> *           audio cache</li><li style="" class="li2"> *         - This only works for non static SE audio loaded as WebAudio</li><li style="" class="li1"> *         - folder is supposed to be a String</li><li style="" class="li2"> *         - name is supposed to be a String</li><li style="" class="li1"> *         - The script call's supposed to be Idempotent</li></ol></div>

Prerequisites
Code:
<div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="" class="li1">Abilities:</li><li style="" class="li2">1. Nothing special for most ordinary cases</li><li style="" class="li1">(No capability on Javascript ES5 experience but can still make reasonable guesses on readable novice codes up to 100 LoC scale)</li><li style="" class="li2">2. Little RMMV plugin development proficiency to fully utilize this plugin in intended ways</li><li style="" class="li1">(Elementary Javascript ES5 exposures being able to write beginner codes up to 300LoC scale )[/SPOILER]</li><li style="" class="li2"> </li><li style="" class="li1">[b]Terms Of Use[/b]</li><li style="" class="li2">[code=text]1. Commercial use's always allowed and crediting me's always optional.</li><li style="" class="li1">2. You shall keep this plugin's Plugin Info part's contents intact.</li><li style="" class="li2">3. You shalln't claim that this plugin's written by anyone other than DoubleX or my aliases. I always reserve the right to deny you from using any of my plugins anymore if you've violated this.</li><li style="" class="li1">4. If you repost this plugin directly(rather than just linking back), you shall inform me of these direct repostings. I always reserve the right to request you to edit those direct repostings.</li><li style="" class="li2">5. CC BY 4.0, except those conflicting with any of the above, applies to this plugin, unless you've my permissions not needing follow so.</li><li style="" class="li1">6. I always reserve the right to deny you from using this plugin anymore if you've violated any of the above.
</li><li style="" class="li2"> </li><li style="" class="li1">Contributors</li><li style="" class="li2">
Code:
Authors:</li><li style="" class="li1">1. DoubleX</li><li style="" class="li2">Plugin Development Collaborators:</li><li style="" class="li1">- None So Far</li><li style="" class="li2">Bug Reporters:</li><li style="" class="li1">- None So Far</li><li style="" class="li2">Compatibility Issue Raisers:</li><li style="" class="li1">- None So Far</li><li style="" class="li2">Feature Requesters:</li><li style="" class="li1">- None So Far
</li><li style="" class="li2"> </li><li style="" class="li1">Changelog</li><li style="" class="li2">
Code:
</li><li style="" class="li1">v1.00b(GMT 0300 27-Mar-2020):</li><li style="" class="li2">1. You no longer have to edit the value of DoubleX_RMMZ.Preloaded_Resources_File when changing the plugin file name</li><li style="" class="li1">2. Fixed the crashes when preloading animations, images, etc, wthout hues(such cases will be understood as having the default hue 0 only)</li><li style="" class="li2">v1.00a(GMT 1500 7-Jul-2020):</li><li style="" class="li1">1. 1st version of this plugin finished[/SPOILER]</li></ol></div>

Download Link
Pastebin
 

DoubleX

Member
Joined
Nov 25, 2015
Messages
244
Points
18
Updates
v1.00b(GMT 0300 27-Mar-2020):
1. You no longer have to edit the value of DoubleX_RMMZ.Preloaded_Resources_File when changing the plugin file name
2. Fixed the crashes when preloading animations, images, etc, wthout ues(such cases will be understood as having the default hue 0 only)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top