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

@ -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;