Move all engine changes into plugin

This commit is contained in:
OleSTEEP 2024-02-06 23:56:10 +03:00
parent 040a56c09f
commit c39ec970f1
10 changed files with 452 additions and 74 deletions

View file

@ -73,6 +73,13 @@ var $plugins = [
"parameters":
{}
},
{
"name": "VND_OmoriFixes",
"status": true,
"description": "Some fixes for android platform",
"parameters":
{}
},
{
"name": "YEP_CoreEngine",
"status": true,

View file

@ -0,0 +1,189 @@
// by VienDesu! 2023
//=============================================================================
// * Patches for rpg_core
//=============================================================================
Bitmap.prototype._requestImage = function (url) {
if (Bitmap._reuseImages.length !== 0) {
this._image = Bitmap._reuseImages.pop();
} else {
this._image = new Image();
}
url = replaceSpecialSymbols(url);
url = require("fs").cachedAlternativeName(url);
if (this._decodeAfterRequest && !this._loader) {
this._loader = ResourceHandler.createLoader(url, this._requestImage.bind(this, url), this._onError.bind(this));
}
this._image = new Image();
this._url = url;
this._loadingState = 'requesting';
if (!Decrypter.checkImgIgnore(url) && Decrypter.hasEncryptedImages) {
this._loadingState = 'decrypting';
Decrypter.decryptImg(url, this);
} else {
this._image.src = encodeURI(url);
this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this));
this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this));
}
};
Graphics.printLoadingError = function (url) {
if (this._errorPrinter && !this._errorShowed) {
this._errorPrinter.innerHTML = this._makeErrorHtml('Loading Error', 'Failed to load: ' + url);
var button = document.createElement('button');
button.innerHTML = 'Retry';
button.style.fontSize = '24px';
button.style.color = '#000000';
button.style.backgroundColor = '#000000';
button.onmousedown = button.ontouchstart = function (event) {
ResourceHandler.retry();
event.stopPropagation();
};
this._errorPrinter.appendChild(button);
this._loadingCount = -Infinity;
}
};
Graphics._switchFPSMeter = function() {
};
Graphics._switchFullScreen = function () {
this._requestFullScreen();
};
Graphics._isFullScreen = function () {
return true;
};
Graphics._requestFullScreen = function () {
try {
var element = document.body;
if (element.requestFullScreen) {
element.requestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
} catch (e) {
console.log(`Fullscreen request denied! %s`, e)
}
};
Input._wrapNwjsAlert = function () {
if (Utils.isNwjs()) {
var _alert = window.alert;
window.alert = function () {
var gui = require('nw.gui');
var win = gui.window;
_alert.apply(this, arguments);
win.focus();
Input.clear();
};
}
};
Input._setupEventHandlers = function () {
document.addEventListener('keydown', this._onKeyDown.bind(this));
document.addEventListener('keyup', this._onKeyUp.bind(this));
};
TouchInput.update = function () {
return;
};
//=============================================================================
// * Patches for rpg_managers
//=============================================================================
DataManager.loadDataFile = function (name, src) {
var xhr = new XMLHttpRequest();
var url = _dfs.cachedAlternativeName('data/' + src);
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function () {
if (xhr.status < 400) {
window[name] = JSON.parse(xhr.responseText);
DataManager.onLoad(window[name]);
}
};
xhr.onerror = this._mapLoader || function () {
DataManager._errorUrl = DataManager._errorUrl || url;
};
window[name] = null;
xhr.send();
};
ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
if (filename) {
var path = folder + filename + '.png';
var bitmap = this.loadNormalBitmap(path, hue || 0);
bitmap.smooth = smooth;
return bitmap;
} else {
return this.loadEmptyBitmap();
}
};
ImageManager.loadNormalBitmap = function (path, hue) {
var key = this._generateCacheKey(path, hue);
var bitmap = this._imageCache.get(key);
if (!bitmap) {
bitmap = Bitmap.load(decodeURIComponent(replaceSpecialSymbols(path)));
bitmap.addLoadListener(function () {
bitmap.rotateHue(hue);
});
this._imageCache.add(key, bitmap);
} else if (!bitmap.isReady()) {
bitmap.decode();
}
return bitmap;
};
SceneManager.initNwjs = function () {
if (Utils.isNwjs()) {
var gui = require('nw.gui');
var win = gui.window;
if (process.platform === 'darwin' && !win.menu) {
var menubar = new gui.Menu({ type: 'menubar' });
var option = { hideEdit: true, hideWindow: true };
menubar.createMacBuiltin('Game', option);
win.menu = menubar;
}
}
};
SceneManager.onKeyDown = function (event) {
if (!event.ctrlKey && !event.altKey) {
switch (event.keyCode) {
case 116: // F5
if (Utils.isNwjs()) {
location.reload();
}
break;
case 119: // F8
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
require('nw.gui').window.showDevTools();
}
break;
}
}
};
//=============================================================================
// * Patches for rpg_objects
//=============================================================================
Game_Temp.prototype.setDestination = function (x, y) {
return;
};

View file

@ -1671,9 +1671,6 @@ Bitmap.prototype._requestImage = function (url) {
this._image = new Image();
}
url = replaceSpecialSymbols(url);
url = require("fs").cachedAlternativeName(url);
if (this._decodeAfterRequest && !this._loader) {
this._loader = ResourceHandler.createLoader(url, this._requestImage.bind(this, url), this._onError.bind(this));
}
@ -1686,7 +1683,7 @@ Bitmap.prototype._requestImage = function (url) {
this._loadingState = 'decrypting';
Decrypter.decryptImg(url, this);
} else {
this._image.src = encodeURI(url);
this._image.src = url;
this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this));
this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this));
@ -1997,7 +1994,7 @@ Graphics.printLoadingError = function (url) {
var button = document.createElement('button');
button.innerHTML = 'Retry';
button.style.fontSize = '24px';
button.style.color = '#000000';
button.style.color = '#ffffff';
button.style.backgroundColor = '#000000';
button.onmousedown = button.ontouchstart = function (event) {
ResourceHandler.retry();
@ -2866,23 +2863,23 @@ Graphics._onTouchEnd = function (event) {
}
};
///**
// * @static
// * @method _switchFPSMeter
// * @private
// */
//Graphics._switchFPSMeter = function() {
// if (this._fpsMeter.isPaused) {
// this.showFps();
// this._fpsMeter.showFps();
// this._fpsMeterToggled = false;
// } else if (!this._fpsMeterToggled) {
// this._fpsMeter.showDuration();
// this._fpsMeterToggled = true;
// } else {
// this.hideFps();
// }
//};
/**
* @static
* @method _switchFPSMeter
* @private
*/
Graphics._switchFPSMeter = function() {
if (this._fpsMeter.isPaused) {
this.showFps();
this._fpsMeter.showFps();
this._fpsMeterToggled = false;
} else if (!this._fpsMeterToggled) {
this._fpsMeter.showDuration();
this._fpsMeterToggled = true;
} else {
this.hideFps();
}
};
/**
* @static
@ -2901,7 +2898,11 @@ Graphics._switchStretchMode = function () {
* @private
*/
Graphics._switchFullScreen = function () {
if (this._isFullScreen()) {
this._requestFullScreen();
} else {
this._cancelFullScreen();
}
};
/**
@ -2911,7 +2912,6 @@ Graphics._switchFullScreen = function () {
* @private
*/
Graphics._isFullScreen = function () {
return true;
return ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitFullscreenElement &&
!document.msFullscreenElement));
@ -2923,7 +2923,6 @@ Graphics._isFullScreen = function () {
* @private
*/
Graphics._requestFullScreen = function () {
try {
var element = document.body;
if (element.requestFullScreen) {
element.requestFullScreen();
@ -2934,9 +2933,6 @@ Graphics._requestFullScreen = function () {
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
} catch (e) {
console.log(`Fullscreen request denied! %s`, e)
}
};
/**
@ -3212,7 +3208,7 @@ Input._wrapNwjsAlert = function () {
var _alert = window.alert;
window.alert = function () {
var gui = require('nw.gui');
var win = gui.window;
var win = gui.Window.get();
_alert.apply(this, arguments);
win.focus();
Input.clear();
@ -3228,7 +3224,7 @@ Input._wrapNwjsAlert = function () {
Input._setupEventHandlers = function () {
document.addEventListener('keydown', this._onKeyDown.bind(this));
document.addEventListener('keyup', this._onKeyUp.bind(this));
//window.addEventListener('blur', this._onLostFocus.bind(this));
window.addEventListener('blur', this._onLostFocus.bind(this));
};
/**
@ -3517,7 +3513,6 @@ TouchInput.clear = function () {
* @method update
*/
TouchInput.update = function () {
return;
this._triggered = this._events.triggered;
this._cancelled = this._events.cancelled;
this._moved = this._events.moved;

View file

@ -76,10 +76,9 @@ DataManager.loadDatabase = function () {
}
};
window._dfs = require("fs");
DataManager.loadDataFile = function (name, src) {
var xhr = new XMLHttpRequest();
var url = _dfs.cachedAlternativeName('data/' + src);
var url = 'data/' + src;
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function () {
@ -863,7 +862,7 @@ ImageManager.loadTitle2 = function (filename, hue) {
ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
if (filename) {
var path = folder + filename + '.png';
var path = folder + encodeURIComponent(filename) + '.png';
var bitmap = this.loadNormalBitmap(path, hue || 0);
bitmap.smooth = smooth;
return bitmap;
@ -887,7 +886,7 @@ ImageManager.loadNormalBitmap = function (path, hue) {
var key = this._generateCacheKey(path, hue);
var bitmap = this._imageCache.get(key);
if (!bitmap) {
bitmap = Bitmap.load(decodeURIComponent(replaceSpecialSymbols(path)));
bitmap = Bitmap.load(decodeURIComponent(path));
bitmap.addLoadListener(function () {
bitmap.rotateHue(hue);
});
@ -1877,7 +1876,7 @@ SceneManager.initInput = function () {
SceneManager.initNwjs = function () {
if (Utils.isNwjs()) {
var gui = require('nw.gui');
var win = gui.window;
var win = gui.Window.get();
if (process.platform === 'darwin' && !win.menu) {
var menubar = new gui.Menu({ type: 'menubar' });
var option = { hideEdit: true, hideWindow: true };
@ -1941,7 +1940,7 @@ SceneManager.onKeyDown = function (event) {
break;
case 119: // F8
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
require('nw.gui').window.showDevTools();
require('nw.gui').Window.get().showDevTools();
}
break;
}

View file

@ -39,7 +39,6 @@ Game_Temp.prototype.reservedCommonEvent = function () {
};
Game_Temp.prototype.setDestination = function (x, y) {
return;
this._destinationX = x;
this._destinationY = y;
};

View file

@ -73,6 +73,13 @@ var $plugins = [
"parameters":
{}
},
{
"name": "VND_OmoriFixes",
"status": true,
"description": "Some fixes for android platform",
"parameters":
{}
},
{
"name": "YEP_CoreEngine",
"status": true,

View file

@ -0,0 +1,189 @@
// by VienDesu! 2023
//=============================================================================
// * Patches for rpg_core
//=============================================================================
Bitmap.prototype._requestImage = function (url) {
if (Bitmap._reuseImages.length !== 0) {
this._image = Bitmap._reuseImages.pop();
} else {
this._image = new Image();
}
url = replaceSpecialSymbols(url);
url = require("fs").cachedAlternativeName(url);
if (this._decodeAfterRequest && !this._loader) {
this._loader = ResourceHandler.createLoader(url, this._requestImage.bind(this, url), this._onError.bind(this));
}
this._image = new Image();
this._url = url;
this._loadingState = 'requesting';
if (!Decrypter.checkImgIgnore(url) && Decrypter.hasEncryptedImages) {
this._loadingState = 'decrypting';
Decrypter.decryptImg(url, this);
} else {
this._image.src = encodeURI(url);
this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this));
this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this));
}
};
Graphics.printLoadingError = function (url) {
if (this._errorPrinter && !this._errorShowed) {
this._errorPrinter.innerHTML = this._makeErrorHtml('Loading Error', 'Failed to load: ' + url);
var button = document.createElement('button');
button.innerHTML = 'Retry';
button.style.fontSize = '24px';
button.style.color = '#000000';
button.style.backgroundColor = '#000000';
button.onmousedown = button.ontouchstart = function (event) {
ResourceHandler.retry();
event.stopPropagation();
};
this._errorPrinter.appendChild(button);
this._loadingCount = -Infinity;
}
};
Graphics._switchFPSMeter = function() {
};
Graphics._switchFullScreen = function () {
this._requestFullScreen();
};
Graphics._isFullScreen = function () {
return true;
};
Graphics._requestFullScreen = function () {
try {
var element = document.body;
if (element.requestFullScreen) {
element.requestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
} catch (e) {
console.log(`Fullscreen request denied! %s`, e)
}
};
Input._wrapNwjsAlert = function () {
if (Utils.isNwjs()) {
var _alert = window.alert;
window.alert = function () {
var gui = require('nw.gui');
var win = gui.window;
_alert.apply(this, arguments);
win.focus();
Input.clear();
};
}
};
Input._setupEventHandlers = function () {
document.addEventListener('keydown', this._onKeyDown.bind(this));
document.addEventListener('keyup', this._onKeyUp.bind(this));
};
TouchInput.update = function () {
return;
};
//=============================================================================
// * Patches for rpg_managers
//=============================================================================
DataManager.loadDataFile = function (name, src) {
var xhr = new XMLHttpRequest();
var url = _dfs.cachedAlternativeName('data/' + src);
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function () {
if (xhr.status < 400) {
window[name] = JSON.parse(xhr.responseText);
DataManager.onLoad(window[name]);
}
};
xhr.onerror = this._mapLoader || function () {
DataManager._errorUrl = DataManager._errorUrl || url;
};
window[name] = null;
xhr.send();
};
ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
if (filename) {
var path = folder + filename + '.png';
var bitmap = this.loadNormalBitmap(path, hue || 0);
bitmap.smooth = smooth;
return bitmap;
} else {
return this.loadEmptyBitmap();
}
};
ImageManager.loadNormalBitmap = function (path, hue) {
var key = this._generateCacheKey(path, hue);
var bitmap = this._imageCache.get(key);
if (!bitmap) {
bitmap = Bitmap.load(decodeURIComponent(replaceSpecialSymbols(path)));
bitmap.addLoadListener(function () {
bitmap.rotateHue(hue);
});
this._imageCache.add(key, bitmap);
} else if (!bitmap.isReady()) {
bitmap.decode();
}
return bitmap;
};
SceneManager.initNwjs = function () {
if (Utils.isNwjs()) {
var gui = require('nw.gui');
var win = gui.window;
if (process.platform === 'darwin' && !win.menu) {
var menubar = new gui.Menu({ type: 'menubar' });
var option = { hideEdit: true, hideWindow: true };
menubar.createMacBuiltin('Game', option);
win.menu = menubar;
}
}
};
SceneManager.onKeyDown = function (event) {
if (!event.ctrlKey && !event.altKey) {
switch (event.keyCode) {
case 116: // F5
if (Utils.isNwjs()) {
location.reload();
}
break;
case 119: // F8
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
require('nw.gui').window.showDevTools();
}
break;
}
}
};
//=============================================================================
// * Patches for rpg_objects
//=============================================================================
Game_Temp.prototype.setDestination = function (x, y) {
return;
};

View file

@ -1671,9 +1671,6 @@ Bitmap.prototype._requestImage = function (url) {
this._image = new Image();
}
url = replaceSpecialSymbols(url);
url = require("fs").cachedAlternativeName(url);
if (this._decodeAfterRequest && !this._loader) {
this._loader = ResourceHandler.createLoader(url, this._requestImage.bind(this, url), this._onError.bind(this));
}
@ -1686,7 +1683,7 @@ Bitmap.prototype._requestImage = function (url) {
this._loadingState = 'decrypting';
Decrypter.decryptImg(url, this);
} else {
this._image.src = encodeURI(url);
this._image.src = url;
this._image.addEventListener('load', this._loadListener = Bitmap.prototype._onLoad.bind(this));
this._image.addEventListener('error', this._errorListener = this._loader || Bitmap.prototype._onError.bind(this));
@ -1997,7 +1994,7 @@ Graphics.printLoadingError = function (url) {
var button = document.createElement('button');
button.innerHTML = 'Retry';
button.style.fontSize = '24px';
button.style.color = '#000000';
button.style.color = '#ffffff';
button.style.backgroundColor = '#000000';
button.onmousedown = button.ontouchstart = function (event) {
ResourceHandler.retry();
@ -2866,23 +2863,23 @@ Graphics._onTouchEnd = function (event) {
}
};
///**
// * @static
// * @method _switchFPSMeter
// * @private
// */
//Graphics._switchFPSMeter = function() {
// if (this._fpsMeter.isPaused) {
// this.showFps();
// this._fpsMeter.showFps();
// this._fpsMeterToggled = false;
// } else if (!this._fpsMeterToggled) {
// this._fpsMeter.showDuration();
// this._fpsMeterToggled = true;
// } else {
// this.hideFps();
// }
//};
/**
* @static
* @method _switchFPSMeter
* @private
*/
Graphics._switchFPSMeter = function() {
if (this._fpsMeter.isPaused) {
this.showFps();
this._fpsMeter.showFps();
this._fpsMeterToggled = false;
} else if (!this._fpsMeterToggled) {
this._fpsMeter.showDuration();
this._fpsMeterToggled = true;
} else {
this.hideFps();
}
};
/**
* @static
@ -2901,7 +2898,11 @@ Graphics._switchStretchMode = function () {
* @private
*/
Graphics._switchFullScreen = function () {
if (this._isFullScreen()) {
this._requestFullScreen();
} else {
this._cancelFullScreen();
}
};
/**
@ -2911,7 +2912,6 @@ Graphics._switchFullScreen = function () {
* @private
*/
Graphics._isFullScreen = function () {
return true;
return ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitFullscreenElement &&
!document.msFullscreenElement));
@ -2923,7 +2923,6 @@ Graphics._isFullScreen = function () {
* @private
*/
Graphics._requestFullScreen = function () {
try {
var element = document.body;
if (element.requestFullScreen) {
element.requestFullScreen();
@ -2934,9 +2933,6 @@ Graphics._requestFullScreen = function () {
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
} catch (e) {
console.log(`Fullscreen request denied! %s`, e)
}
};
/**
@ -3212,7 +3208,7 @@ Input._wrapNwjsAlert = function () {
var _alert = window.alert;
window.alert = function () {
var gui = require('nw.gui');
var win = gui.window;
var win = gui.Window.get();
_alert.apply(this, arguments);
win.focus();
Input.clear();
@ -3228,7 +3224,7 @@ Input._wrapNwjsAlert = function () {
Input._setupEventHandlers = function () {
document.addEventListener('keydown', this._onKeyDown.bind(this));
document.addEventListener('keyup', this._onKeyUp.bind(this));
//window.addEventListener('blur', this._onLostFocus.bind(this));
window.addEventListener('blur', this._onLostFocus.bind(this));
};
/**
@ -3517,7 +3513,6 @@ TouchInput.clear = function () {
* @method update
*/
TouchInput.update = function () {
return;
this._triggered = this._events.triggered;
this._cancelled = this._events.cancelled;
this._moved = this._events.moved;

View file

@ -76,10 +76,9 @@ DataManager.loadDatabase = function () {
}
};
window._dfs = require("fs");
DataManager.loadDataFile = function (name, src) {
var xhr = new XMLHttpRequest();
var url = _dfs.cachedAlternativeName('data/' + src);
var url = 'data/' + src;
xhr.open('GET', url);
xhr.overrideMimeType('application/json');
xhr.onload = function () {
@ -863,7 +862,7 @@ ImageManager.loadTitle2 = function (filename, hue) {
ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
if (filename) {
var path = folder + filename + '.png';
var path = folder + encodeURIComponent(filename) + '.png';
var bitmap = this.loadNormalBitmap(path, hue || 0);
bitmap.smooth = smooth;
return bitmap;
@ -887,7 +886,7 @@ ImageManager.loadNormalBitmap = function (path, hue) {
var key = this._generateCacheKey(path, hue);
var bitmap = this._imageCache.get(key);
if (!bitmap) {
bitmap = Bitmap.load(decodeURIComponent(replaceSpecialSymbols(path)));
bitmap = Bitmap.load(decodeURIComponent(path));
bitmap.addLoadListener(function () {
bitmap.rotateHue(hue);
});
@ -1877,7 +1876,7 @@ SceneManager.initInput = function () {
SceneManager.initNwjs = function () {
if (Utils.isNwjs()) {
var gui = require('nw.gui');
var win = gui.window;
var win = gui.Window.get();
if (process.platform === 'darwin' && !win.menu) {
var menubar = new gui.Menu({ type: 'menubar' });
var option = { hideEdit: true, hideWindow: true };
@ -1941,7 +1940,7 @@ SceneManager.onKeyDown = function (event) {
break;
case 119: // F8
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
require('nw.gui').window.showDevTools();
require('nw.gui').Window.get().showDevTools();
}
break;
}

View file

@ -39,7 +39,6 @@ Game_Temp.prototype.reservedCommonEvent = function () {
};
Game_Temp.prototype.setDestination = function (x, y) {
return;
this._destinationX = x;
this._destinationY = y;
};