"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var setNullDefault = function (value, defaultValue) { return (value === null ? defaultValue : value); };
var extendsDraggableWindowClass = function (WindowClass) { var _a; return _a = (function (_super) {
__extends(Window_Draggable, _super);
function Window_Draggable() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_this._dragX = null;
_this._dragY = null;
_this._dragging = false;
return _this;
}
Object.defineProperty(Window_Draggable.prototype, "dragableRect", {
get: function () {
return new Rectangle(this.x, this.y, this.width, this.height);
},
enumerable: false,
configurable: true
});
Window_Draggable.prototype.update = function () {
_super.prototype.update.call(this);
this.updateDrag();
};
Window_Draggable.prototype.updateDrag = function () {
var _this = this;
var isInside = this.dragableRect.contains(TouchInput.x, TouchInput.y);
var isTriggered = TouchInput.isTriggered();
var isReleased = TouchInput.isReleased();
var isPressed = TouchInput.isPressed();
var draggingWin = Window_Draggable.draggingWin;
if (isTriggered && isInside) {
this._dragX = this.canvasToLocalX(TouchInput.x);
this._dragY = this.canvasToLocalY(TouchInput.y);
this._dragging = true;
var list = SceneManager._scene._windowLayer.children;
list.sort(function (a, b) { return Number(a === _this) - Number(b === _this); });
Window_Draggable.draggingWin = this;
}
else if (isPressed && this._dragging && draggingWin === this) {
this.x = TouchInput.x - setNullDefault(this._dragX, 0);
this.y = TouchInput.y - setNullDefault(this._dragY, 0);
}
else if (isReleased) {
this._dragging = false;
}
};
return Window_Draggable;
}(WindowClass)),
_a.draggingWin = null,
_a; };