Advertisement
Archeia

ArcheiaSnippets

Sep 26th, 2018
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Archeia RPG Core Patch
  3. // Version: 1.0
  4. //=============================================================================
  5.  
  6. //-----------------------------------------------------------------------------
  7. // * Make sure that the game always scale properly.
  8. //-----------------------------------------------------------------------------
  9. Graphics._updateRealScale = function() {
  10.     if (this._stretchEnabled) {
  11.         var h = window.innerWidth / this._width;
  12.         var v = window.innerHeight / this._height;
  13.         this._realScale = Math.min(h,v);
  14.         if (this._realScale>=3) this._realScale = 3;
  15.         else if (this._realScale>=2) this._realScale = 2;
  16.         else if (this._realScale>=1.5) this._realScale = 1.5;
  17.         else if (this._realScale>=1) this._realScale = 1;
  18.         else this._realScale = 0.5;
  19.     } else {
  20.         this._realScale = this._scale;
  21.        
  22.     }
  23. };
  24.  
  25. //-----------------------------------------------------------------------------
  26. // * Remove smoothing from graphics
  27. //-----------------------------------------------------------------------------
  28. Graphics._centerElement = function(element) {
  29.     var width = element.width * this._realScale;
  30.     var height = element.height * this._realScale;
  31.     element.style.position = 'absolute';
  32.     element.style.margin = 'auto';
  33.     element.style.top = 0;
  34.     element.style.left = 0;
  35.     element.style.right = 0;
  36.     element.style.bottom = 0;
  37.     element.style.width = width + 'px';
  38.     element.style.height = height + 'px';
  39.     element.style["image-rendering"] = "pixelated";
  40.     element.style["font-smooth"] = "none";
  41. };
  42.  
  43. //-----------------------------------------------------------------------------
  44. // * Make Cursor Tile instead of stretching
  45. // Use it with this plugin for maximum effect: http://sumrndm.site/window-frame-anti-stretch/
  46. //-----------------------------------------------------------------------------
  47. Window.prototype._refreshCursor = function() {
  48.     var pad = this._padding;
  49.     var x = this._cursorRect.x + pad - this.origin.x;
  50.     var y = this._cursorRect.y + pad - this.origin.y;
  51.     var w = this._cursorRect.width;
  52.     var h = this._cursorRect.height;
  53.     var m = 4;
  54.     var x2 = Math.max(x, pad);
  55.     var y2 = Math.max(y, pad);
  56.     var ox = x - x2;
  57.     var oy = y - y2;
  58.     var w2 = Math.min(w, this._width - pad - x2);
  59.     var h2 = Math.min(h, this._height - pad - y2);
  60.     var bitmap = new Bitmap(w2, h2);
  61.  
  62.     this._windowCursorSprite.bitmap = bitmap;
  63.     this._windowCursorSprite.setFrame(0, 0, w2, h2);
  64.     this._windowCursorSprite.move(x2, y2);
  65.     // Spacing 1
  66.     var sp1 = 10;
  67.  
  68.     if (w > 0 && h > 0 && this._windowskin) {
  69.       var skin = this._windowskin;
  70.       var p = 96;
  71.       var q = 48;
  72.  
  73.       bitmap.blt(skin, p, p, sp1, sp1, ox, oy);
  74.       bitmap.blt(skin, p + q - sp1, p, sp1, sp1, ox + w2 - sp1, oy);
  75.       bitmap.blt(skin, p, p + q - sp1, sp1, sp1, ox, oy + h2 - sp1);
  76.       bitmap.blt(skin, p + q - sp1, p + q - sp1, sp1, sp1, ox + w2 - sp1, oy + h2 - sp1);
  77.  
  78.       bitmap.blt(skin, p + sp1, p, q - (sp1 * 2), sp1, ox + sp1, oy, w2 - (sp1 * 2))
  79.       bitmap.blt(skin, p + sp1, p + q - sp1, q - (sp1 * 2), sp1, ox + sp1, oy + h2 - sp1, w2 - (sp1 * 2))
  80.  
  81.       bitmap.blt(skin, p, p + sp1, sp1, q - (sp1 * 2), ox, oy + sp1, sp1, h2 - (sp1 * 2))
  82.       bitmap.blt(skin, p + q - sp1, p + sp1, sp1, q - (sp1 * 2), ox + w2 - sp1, oy + sp1, sp1, h2 - (sp1 * 2))
  83.  
  84.       bitmap.blt(skin, p + sp1, p + sp1, q - (sp1 * 2), q - (sp1 * 2), ox + sp1, oy + sp1, w2 - (sp1 * 2), h2 - (sp1 * 2))
  85.     }
  86. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement