Advertisement
WCouillard

Coolie_ImageToggleSmoothing

Mar 11th, 2023
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 16.89 KB | Gaming | 0 0
  1. var Imported = Imported || {};
  2. Imported.Coolie_ImageToggleSmoothing = true;
  3.  
  4. var Coolie = Coolie || {};
  5. Coolie.ITS = Coolie.ITS || {};
  6. Coolie.ITS.version = 1.00;
  7.  
  8. /*:
  9.  * @plugindesc v1.00 Enables toggling of MV's default smoothing effect on images via a filename string
  10.  * @author Coolie (William Couillard)
  11.  *
  12.  * @param String Settings
  13.  * @param System Image Settings
  14.  *
  15.  * @param String
  16.  * @parent String Settings
  17.  * @desc Adding this string anywhere in an image's filename will enable smoothing. Any image except /img/system/ files.
  18.  * @default _!smooth
  19.  *
  20.  * @param System Image Smoothing?
  21.  * @parent System Image Settings
  22.  * @type boolean
  23.  * @yes true
  24.  * @no false
  25.  * @desc  ON: Smoothing applied to all /img/system/ files.
  26.  * OFF: Smoothing disabled to all /img/system/ files.
  27.  * @default true
  28.  *
  29.  * @help
  30.  * -----------------------------------------------------------------------------
  31.  * ABOUT THIS PLUGIN
  32.  * -----------------------------------------------------------------------------
  33.  * Images in RPG Maker MV have smoothing on by default. This means when the
  34.  * image is shown in-game, it will blur as the scale of the image changes. This
  35.  * helps to make images look better when they are scaled up or down in size on
  36.  * the screen, but it doesn't mean you ALWAYS want that effect on every image.
  37.  *
  38.  * If you are making a pixelated game, for example, you might want the smoothing
  39.  * turned off for certain images. This plugin lets you set a string for your
  40.  * image FILENAMES (NOT the "name" or "id" in the MV editor) to turn smoothing
  41.  * ON, and any FILENAMES without this string will not have smoothing!
  42.  *
  43.  * By default, this plugin disables the smoothing effect on all images in your
  44.  * game, but by adding a string to an image filename, we can restore the effect
  45.  * so you can choose which images have it, and which ones do not.
  46.  *
  47.  * The string you will have to add to your filenames is set in the parameters.
  48.  * Simply rename the files you with to keep smoothing for with your chosen
  49.  * string somewhere in the filename.
  50.  *
  51.  * Let's take the default MV animation file, Hit1, as an example.
  52.  *
  53.  * If we rename that file to "Hit1_!smooth" with this plugin's default setting,
  54.  * then that image will now have the default smoothing effect whenever it is
  55.  * used in your game.
  56.  *
  57.  * If we leave it as just "Hit1" with this plugin, it will no longer have the
  58.  * smoothing effect. Any occurence of the string will result in the image
  59.  * having the smoothing effect enabled.
  60.  *
  61.  * Just to be clear on the usage, you'll need to add the plugin, choose a
  62.  * string, then add that string to the filename of any image you wish to keep
  63.  * smoothing effects for. The string can be anywhere in the filename, like so:
  64.  *
  65.  * Filename: Hit1         : image will not have smoothing effect
  66.  * Filename: Hit1_!smooth : image will have smoothing effect
  67.  * Filename: _!smoothHit1 : image will have smoothing effect
  68.  * Filename: Hit_!smooth1 : image will have smoothing effect
  69.  *
  70.  * This can be done using one string on the filename of almost ANY image you
  71.  * have in your game! System images were intentionally left out, as they are
  72.  * very name-dependent files that would no longer work properly if you change
  73.  * their name(s). Due to this, I have added the option to either smooth or not
  74.  * smooth the entire img/system/ folder. It retains smoothing by default.
  75.  *
  76.  * The images contained in the following folders can have your string added
  77.  * to enable smoothing:
  78.  *
  79.  * img/animations/
  80.  * img/battlebacks1/
  81.  * img/battlebacks2/
  82.  * img/characters/
  83.  * img/enemies/
  84.  * img/faces/
  85.  * img/parallaxes/
  86.  * img/pictures/
  87.  * img/sv_actors/
  88.  * img/sv_enemies/
  89.  * img/tilesets/
  90.  * img/titles1/
  91.  * img/titles2/
  92.  *
  93.  * A lot of ImageManager default functions are replaced by this plugin, so there
  94.  * is still a chance that any other plugin that alters these functions will be
  95.  * incompatible. However, most plugins don't mess with these functions. Still,
  96.  * you should place it low on the list of plugins in your game.
  97.  *
  98.  * I will do my best to update this for compatibility.
  99.  *
  100.  * -----------------------------------------------------------------------------
  101.  * TIPS
  102.  * -----------------------------------------------------------------------------
  103.  * If you'd like to have an image that sometimes has the smoothing effect and
  104.  * sometimes does not, you can simply make a copy of the image in your folder
  105.  * and keep one with its original filename and one with the string added.
  106.  *
  107.  * Then you can simply call the appropriate image file when needed.
  108.  *
  109.  * -----------------------------------------------------------------------------
  110.  * TERMS OF USE
  111.  * -----------------------------------------------------------------------------
  112.  * It is OK to use this plugin in both commercial and non-commercial
  113.  * projects.
  114.  *
  115.  * Credit is appreciated, but not required.
  116.  *
  117.  * -----------------------------------------------------------------------------
  118.  * VERSION & UPDATE HISTORY
  119.  * -----------------------------------------------------------------------------
  120.  * > v1.00 : Initial Release
  121.  *            > March 11th, 2023
  122.  * -----------------------------------------------------------------------------
  123.  */
  124. Coolie.Parameters = PluginManager.parameters('Coolie_ImageToggleSmoothing');
  125. Coolie.Param = Coolie.Param || {};
  126.  
  127. Coolie.Param.SmoothingString = String(Coolie.Parameters['String']);
  128. Coolie.Param.SmoothingSystem = String(Coolie.Parameters['System Image Smoothing?']);
  129. var smoothingString = Coolie.Param.SmoothingString;
  130. var smoothingSystem = Coolie.Param.SmoothingSystem;
  131.  
  132. // Load
  133. ImageManager.loadAnimation = function(filename, hue) {
  134.     if (filename.contains(smoothingString)) {
  135.         return this.loadBitmap('img/animations/', filename, hue, true);
  136.     } else {
  137.         return this.loadBitmap('img/animations/', filename, hue, false);
  138.     }
  139. };
  140.  
  141. ImageManager.loadBattleback1 = function(filename, hue) {
  142.     if (filename.contains(smoothingString)) {
  143.         return this.loadBitmap('img/battlebacks1/', filename, hue, true);
  144.     } else {
  145.         return this.loadBitmap('img/battlebacks1/', filename, hue, false);
  146.     }
  147. };
  148.  
  149. ImageManager.loadBattleback2 = function(filename, hue) {
  150.     if (filename.contains(smoothingString)) {
  151.         return this.loadBitmap('img/battlebacks2/', filename, hue, true);
  152.     } else {
  153.         return this.loadBitmap('img/battlebacks2/', filename, hue, false);
  154.     }
  155. };
  156.  
  157. ImageManager.loadEnemy = function(filename, hue) {
  158.     if (filename.contains(smoothingString)) {
  159.         return this.loadBitmap('img/enemies/', filename, hue, true);
  160.     } else {
  161.         return this.loadBitmap('img/enemies/', filename, hue, false);
  162.     }
  163. };
  164.  
  165. ImageManager.loadCharacter = function(filename, hue) {
  166.     if (filename.contains(smoothingString)) {
  167.         return this.loadBitmap('img/characters/', filename, hue, true);
  168.     } else {
  169.         return this.loadBitmap('img/characters/', filename, hue, false);
  170.     }
  171. };
  172.  
  173. ImageManager.loadFace = function(filename, hue) {
  174.     if (filename.contains(smoothingString)) {
  175.         return this.loadBitmap('img/faces/', filename, hue, true);
  176.     } else {
  177.         return this.loadBitmap('img/faces/', filename, hue, false);
  178.     }
  179. };
  180.  
  181. ImageManager.loadParallax = function(filename, hue) {
  182.     if (filename.contains(smoothingString)) {
  183.         return this.loadBitmap('img/parallaxes/', filename, hue, true);
  184.     } else {
  185.         return this.loadBitmap('img/parallaxes/', filename, hue, false);
  186.     }
  187. };
  188.  
  189. ImageManager.loadPicture = function(filename, hue) {
  190.     if (filename.contains(smoothingString)) {
  191.         return this.loadBitmap('img/pictures/', filename, hue, true);
  192.     } else {
  193.         return this.loadBitmap('img/pictures/', filename, hue, false);
  194.     }
  195. };
  196.  
  197. ImageManager.loadSvActor = function(filename, hue) {
  198.     if (filename.contains(smoothingString)) {
  199.         return this.loadBitmap('img/sv_actors/', filename, hue, true);
  200.     } else {
  201.         return this.loadBitmap('img/sv_actors/', filename, hue, false);
  202.     }
  203. };
  204.  
  205. ImageManager.loadSvEnemy = function(filename, hue) {
  206.     if (filename.contains(smoothingString)) {
  207.         return this.loadBitmap('img/sv_enemies/', filename, hue, true);
  208.     } else {
  209.         return this.loadBitmap('img/sv_enemies/', filename, hue, false);
  210.     }
  211. };
  212.  
  213. ImageManager.loadTileset = function(filename, hue) {
  214.     if (filename.contains(smoothingString)) {
  215.         return this.loadBitmap('img/tilesets/', filename, hue, true);
  216.     } else {
  217.         return this.loadBitmap('img/tilesets/', filename, hue, false);
  218.     }
  219. };
  220.  
  221. ImageManager.loadTitle1 = function(filename, hue) {
  222.     if (filename.contains(smoothingString)) {
  223.         return this.loadBitmap('img/titles1/', filename, hue, true);
  224.     } else {
  225.         return this.loadBitmap('img/titles1/', filename, hue, false);
  226.     }
  227. };
  228.  
  229. ImageManager.loadTitle2 = function(filename, hue) {
  230.     if (filename.contains(smoothingString)) {
  231.         return this.loadBitmap('img/titles2/', filename, hue, true);
  232.     } else {
  233.         return this.loadBitmap('img/titles2/', filename, hue, false);
  234.     }
  235. };
  236.  
  237. // Reserve
  238. ImageManager.reserveAnimation = function(filename, hue, reservationId) {
  239.     if (filename.contains(smoothingString)) {
  240.         return this.reserveBitmap('img/animations/', filename, hue, true, reservationId);
  241.     } else {
  242.         return this.reserveBitmap('img/animations/', filename, hue, false, reservationId);
  243.     }      
  244. };
  245.  
  246. ImageManager.reserveBattleback1 = function(filename, hue, reservationId) {
  247.     if (filename.contains(smoothingString)) {
  248.         return this.reserveBitmap('img/battlebacks1/', filename, hue, true, reservationId);
  249.     } else {
  250.         return this.reserveBitmap('img/battlebacks1/', filename, hue, false, reservationId);
  251.     }
  252. };
  253.  
  254. ImageManager.reserveBattleback2 = function(filename, hue, reservationId) {
  255.     if (filename.contains(smoothingString)) {
  256.         return this.reserveBitmap('img/battlebacks2/', filename, hue, true, reservationId);
  257.     } else {
  258.         return this.reserveBitmap('img/battlebacks2/', filename, hue, false, reservationId);
  259.     }
  260. };
  261.  
  262. ImageManager.reserveEnemy = function(filename, hue, reservationId) {
  263.     if (filename.contains(smoothingString)) {
  264.         return this.reserveBitmap('img/enemies/', filename, hue, true, reservationId);
  265.     } else {
  266.         return this.reserveBitmap('img/enemies/', filename, hue, false, reservationId);
  267.     }
  268. };
  269.  
  270. ImageManager.reserveCharacter = function(filename, hue, reservationId) {
  271.     if (filename.contains(smoothingString)) {
  272.         return this.reserveBitmap('img/characters/', filename, hue, true, reservationId);
  273.     } else {
  274.         return this.reserveBitmap('img/characters/', filename, hue, false, reservationId);
  275.     }
  276. };
  277.  
  278. ImageManager.reserveFace = function(filename, hue, reservationId) {
  279.     if (filename.contains(smoothingString)) {
  280.         return this.reserveBitmap('img/faces/', filename, hue, true, reservationId);
  281.     } else {
  282.         return this.reserveBitmap('img/faces/', filename, hue, false, reservationId);
  283.     }
  284. };
  285.  
  286. ImageManager.reserveParallax = function(filename, hue, reservationId) {
  287.     if (filename.contains(smoothingString)) {
  288.         return this.reserveBitmap('img/parallaxes/', filename, hue, true, reservationId);
  289.     } else {
  290.         return this.reserveBitmap('img/parallaxes/', filename, hue, false, reservationId);
  291.     }
  292. };
  293.  
  294. ImageManager.reservePicture = function(filename, hue, reservationId) {
  295.     if (filename.contains(smoothingString)) {
  296.         return this.reserveBitmap('img/pictures/', filename, hue, true, reservationId);
  297.     } else {
  298.         return this.reserveBitmap('img/pictures/', filename, hue, false, reservationId);
  299.     }
  300. };
  301.  
  302. ImageManager.reserveSvActor = function(filename, hue, reservationId) {
  303.     if (filename.contains(smoothingString)) {
  304.         return this.reserveBitmap('img/sv_actors/', filename, hue, true, reservationId);
  305.     } else {
  306.         return this.reserveBitmap('img/sv_actors/', filename, hue, false, reservationId);
  307.     }
  308. };
  309.  
  310. ImageManager.reserveSvEnemy = function(filename, hue, reservationId) {
  311.     if (filename.contains(smoothingString)) {
  312.         return this.reserveBitmap('img/sv_enemies/', filename, hue, true, reservationId);
  313.     } else {
  314.         return this.reserveBitmap('img/sv_enemies/', filename, hue, false, reservationId);
  315.     }
  316. };
  317.  
  318. ImageManager.reserveTileset = function(filename, hue, reservationId) {
  319.     if (filename.contains(smoothingString)) {
  320.         return this.reserveBitmap('img/tilesets/', filename, hue, true, reservationId);
  321.     } else {
  322.         return this.reserveBitmap('img/tilesets/', filename, hue, false, reservationId);
  323.     }
  324. };
  325.  
  326. ImageManager.reserveTitle1 = function(filename, hue, reservationId) {
  327.     if (filename.contains(smoothingString)) {
  328.         return this.reserveBitmap('img/titles1/', filename, hue, true, reservationId);
  329.     } else {
  330.         return this.reserveBitmap('img/titles1/', filename, hue, false, reservationId);
  331.     }
  332. };
  333.  
  334. ImageManager.reserveTitle2 = function(filename, hue, reservationId) {
  335.     if (filename.contains(smoothingString)) {
  336.         return this.reserveBitmap('img/titles2/', filename, hue, true, reservationId);
  337.     } else {
  338.         return this.reserveBitmap('img/titles2/', filename, hue, false, reservationId);
  339.     }
  340. };
  341.  
  342. // Request
  343. ImageManager.requestAnimation = function(filename, hue) {
  344.     if (filename.contains(smoothingString)) {
  345.         return this.requestBitmap('img/animations/', filename, hue, true);
  346.     } else {
  347.         return this.requestBitmap('img/animations/', filename, hue, false);
  348.     }
  349. };
  350.  
  351. ImageManager.requestBattleback1 = function(filename, hue) {
  352.     if (filename.contains(smoothingString)) {
  353.         return this.requestBitmap('img/battlebacks1/', filename, hue, true);
  354.     } else {
  355.         return this.requestBitmap('img/battlebacks1/', filename, hue, false);
  356.     }
  357. };
  358.  
  359. ImageManager.requestBattleback2 = function(filename, hue) {
  360.     if (filename.contains(smoothingString)) {
  361.         return this.requestBitmap('img/battlebacks2/', filename, hue, true);
  362.     } else {
  363.         return this.requestBitmap('img/battlebacks2/', filename, hue, false);
  364.     }
  365. };
  366.  
  367. ImageManager.requestEnemy = function(filename, hue) {
  368.     if (filename.contains(smoothingString)) {
  369.         return this.requestBitmap('img/enemies/', filename, hue, true);
  370.     } else {
  371.         return this.requestBitmap('img/enemies/', filename, hue, false);
  372.     }
  373. };
  374.  
  375. ImageManager.requestCharacter = function(filename, hue) {
  376.     if (filename.contains(smoothingString)) {
  377.         return this.requestBitmap('img/characters/', filename, hue, true);
  378.     } else {
  379.         return this.requestBitmap('img/characters/', filename, hue, false);
  380.     }
  381. };
  382.  
  383. ImageManager.requestFace = function(filename, hue) {
  384.     if (filename.contains(smoothingString)) {
  385.         return this.requestBitmap('img/faces/', filename, hue, true);
  386.     } else {
  387.         return this.requestBitmap('img/faces/', filename, hue, false);
  388.     }
  389. };
  390.  
  391. ImageManager.requestParallax = function(filename, hue) {
  392.     if (filename.contains(smoothingString)) {
  393.         return this.requestBitmap('img/parallaxes/', filename, hue, true);
  394.     } else {
  395.         return this.requestBitmap('img/parallaxes/', filename, hue, false);
  396.     }
  397. };
  398.  
  399. ImageManager.requestPicture = function(filename, hue) {
  400.     if (filename.contains(smoothingString)) {
  401.         return this.requestBitmap('img/pictures/', filename, hue, true);
  402.     } else {
  403.         return this.requestBitmap('img/pictures/', filename, hue, false);
  404.     }
  405. };
  406.  
  407. ImageManager.requestSvActor = function(filename, hue) {
  408.     if (filename.contains(smoothingString)) {
  409.         return this.requestBitmap('img/sv_actors/', filename, hue, true);
  410.     } else {
  411.         return this.requestBitmap('img/sv_actors/', filename, hue, false);
  412.     }
  413. };
  414.  
  415. ImageManager.requestSvEnemy = function(filename, hue) {
  416.     if (filename.contains(smoothingString)) {
  417.         return this.requestBitmap('img/sv_enemies/', filename, hue, true);
  418.     } else {
  419.         return this.requestBitmap('img/sv_enemies/', filename, hue, false);
  420.     }
  421. };
  422.  
  423. ImageManager.requestTileset = function(filename, hue) {
  424.     if (filename.contains(smoothingString)) {
  425.         return this.requestBitmap('img/tilesets/', filename, hue, true);
  426.     } else {
  427.         return this.requestBitmap('img/tilesets/', filename, hue, false);
  428.     }
  429. };
  430.  
  431. ImageManager.requestTitle1 = function(filename, hue) {
  432.     if (filename.contains(smoothingString)) {
  433.         return this.requestBitmap('img/titles1/', filename, hue, true);
  434.     } else {
  435.         return this.requestBitmap('img/titles1/', filename, hue, false);
  436.     }
  437. };
  438.  
  439. ImageManager.requestTitle2 = function(filename, hue) {
  440.     if (filename.contains(smoothingString)) {
  441.         return this.requestBitmap('img/titles2/', filename, hue, true);
  442.     } else {
  443.         return this.requestBitmap('img/titles2/', filename, hue, false);
  444.     }
  445. };
  446.  
  447. // System
  448. ImageManager.loadSystem = function(filename, hue) {
  449.     if (smoothingSystem) {
  450.         return this.loadBitmap('img/system/', filename, hue, true);
  451.     } else {
  452.         return this.loadBitmap('img/system/', filename, hue, false);
  453.     }
  454. };
  455.  
  456. ImageManager.reserveSystem = function(filename, hue, reservationId) {
  457.     if (smoothingSystem) {
  458.         return this.reserveBitmap('img/system/', filename, hue, true, reservationId || this._systemReservationId);
  459.     } else {
  460.         return this.reserveBitmap('img/system/', filename, hue, false, reservationId || this._systemReservationId);
  461.     }
  462. };
  463.  
  464. ImageManager.requestSystem = function(filename, hue) {
  465.     if (smoothingSystem) {
  466.         return this.requestBitmap('img/system/', filename, hue, true);
  467.     } else {
  468.         return this.requestBitmap('img/system/', filename, hue, false);
  469.     }
  470. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement