Skip to content

Commit

Permalink
Export plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Aug 29, 2023
1 parent df92d72 commit ebbc2c8
Show file tree
Hide file tree
Showing 28 changed files with 654 additions and 418 deletions.
160 changes: 125 additions & 35 deletions dist/rexcanvasinputplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,36 +991,9 @@
return GetBobWorldPosition(this.parent, this, offsetX, offsetY, out);
};

var ScrollTo = function ScrollTo() {
var textObject = this.parent;
var dx, dy;
var childLeftX = this.drawX + this.drawTLX;
var childRightX = childLeftX + this.width;
if (childLeftX < 0) {
dx = 0 - childLeftX;
} else if (childRightX > textObject.width) {
dx = textObject.width - childRightX;
} else {
dx = 0;
}
var childTopY = this.drawY + this.drawTLY;
var childBottomY = childTopY + this.height;
if (childTopY < 0) {
dy = 0 - childTopY;
} else if (childBottomY > textObject.height) {
dy = textObject.height - childBottomY;
} else {
dy = 0;
}
textObject._textOX += dx;
textObject._textOY += dy;
return this;
};

var Methods$2 = {
contains: Contains,
getWorldPosition: GetWorldPosition,
scrollTo: ScrollTo
getWorldPosition: GetWorldPosition
};
Object.assign(Methods$2, RenderMethods);

Expand Down Expand Up @@ -4054,21 +4027,19 @@
}
};

var SetTextOXYMethods = {
var SetTextOXYMethods$1 = {
setTextOX: function setTextOX(ox) {
if (ox === this._textOX) {
return this;
}
this._textOX = ox;
this.updateTexture();
return this;
},
setTextOY: function setTextOY(oy) {
if (oy === this._textOY) {
return this;
}
this._textOY = oy;
this.updateTexture();
return this;
},
setTextOXY: function setTextOXY(ox, oy) {
Expand All @@ -4077,7 +4048,6 @@
}
this._textOX = ox;
this._textOY = oy;
this.updateTexture();
return this;
},
addTextOX: function addTextOX(incX) {
Expand Down Expand Up @@ -4538,7 +4508,7 @@
setChildrenInteractiveEnable: SetChildrenInteractiveEnable,
setInteractive: SetInteractive
};
Object.assign(Methods$1, MoveChildMethods, BackgroundMethods, InnerBoundsMethods, SetAlignMethods, SetTextOXYMethods);
Object.assign(Methods$1, MoveChildMethods, BackgroundMethods, InnerBoundsMethods, SetAlignMethods, SetTextOXYMethods$1);

var Stack = /*#__PURE__*/function () {
function Stack() {
Expand Down Expand Up @@ -5589,6 +5559,38 @@
hiddenTextEdit.prevSelectionEnd = selectionEnd;
};

var ScrollToBob = function ScrollToBob(bob) {
var textObject = bob.parent;
var textObjectLeftX = 0,
textObjectRightX = textObject.width,
textObjectTopY = 0,
textObjectBottomY = textObject.height;
var childX = bob.drawX,
childY = bob.drawY;
var childLeftX = childX + bob.drawTLX,
childRightX = childX + bob.drawTRX,
childTopY = childY + bob.drawTLY,
childBottomY = childY + bob.drawBLY;
var dx;
if (childLeftX < textObjectLeftX) {
dx = textObjectLeftX - childLeftX;
} else if (childRightX > textObjectRightX) {
dx = textObjectRightX - childRightX;
} else {
dx = 0;
}
var dy;
if (childTopY < textObjectTopY) {
dy = textObjectTopY - childTopY;
} else if (childBottomY > textObjectBottomY) {
dy = textObjectBottomY - childBottomY;
} else {
dy = 0;
}
textObject._textOX += dx;
textObject._textOY += dy;
};

var MoveCursor = function MoveCursor(hiddenTextEdit) {
var textObject = hiddenTextEdit.parent;
var text = textObject.text;
Expand Down Expand Up @@ -5618,7 +5620,7 @@
if (child.text === '\n') {
child.copyTextSize(textObject.lastInsertCursor);
}
child.scrollTo();
ScrollToBob(child);
textObject.emit('cursorin', child, cursorPosition, textObject);
}
}
Expand Down Expand Up @@ -6438,7 +6440,35 @@

// Push back lastInsertCursor directly
textObject.children.push(textObject.lastInsertCursor);
textObject.runWordWrap();
var result = textObject.runWordWrap();
textObject.contentWidth = result.maxLineWidth;
textObject.contentHeight = result.linesHeight;
textObject.linesCount = result.lines.length;
};

var SetTextOXYMethods = {
setTextOYByPercentage: function setTextOYByPercentage(percentage) {
this.setTextOY(-this.textVisibleHeight * percentage);
return this;
},
getTextOYPercentage: function getTextOYPercentage() {
var textVisibleHeight = this.textVisibleHeight;
if (textVisibleHeight === 0) {
return 0;
}
return this._textOY / -textVisibleHeight;
},
setTextOXByPercentage: function setTextOXByPercentage(percentage) {
this.setTextOX(-this.textVisibleWidth * percentage);
return this;
},
getTextOXPercentage: function getTextOXPercentage() {
var textVisibleWidth = this.textVisibleWidth;
if (textVisibleWidth === 0) {
return 0;
}
return this._textOX / -textVisibleWidth;
}
};

var IsPlainObject = Phaser.Utils.Objects.IsPlainObject;
Expand Down Expand Up @@ -6467,6 +6497,11 @@
var cursorStyle = ExtractByPrefix(config.style, 'cursor');
_this = _super.call(this, scene, x, y, fixedWidth, fixedHeight, config);
_this.type = 'rexCanvasInput';

// readonly
_this.contentWidth = undefined;
_this.contentHeight = undefined;
_this.linesCount = undefined;
_this._text;
_this.textEdit = CreateHiddenTextEdit(_assertThisInitialized(_this), config);
if (config.focusStyle) {
Expand Down Expand Up @@ -6698,12 +6733,67 @@
this.minLength = value;
return this;
}
}, {
key: "topTextOY",
get: function get() {
return 0;
}
}, {
key: "bottomTextOY",
get: function get() {
return -this.tableVisibleHeight;
}
}, {
key: "leftTextOX",
get: function get() {
return 0;
}
}, {
key: "rightTextOX",
get: function get() {
return -this.textVisibleWidth;
}
}, {
key: "textVisibleHeight",
get: function get() {
var h = this.contentHeight - this.height;
if (h < 0) {
h = 0;
}
return h;
}
}, {
key: "textVisibleWidth",
get: function get() {
var w = this.contentWidth - this.width;
if (w < 0) {
w = 0;
}
return w;
}
}, {
key: "t",
get: function get() {
return this.getTextOYPercentage();
},
set: function set(value) {
this.setTextOYByPercentage(value).updateTexture();
}
}, {
key: "s",
get: function get() {
return this.getTextOXPercentage();
},
set: function set(value) {
this.setTextOXByPercentage(value).updateTexture();
}
}]);
return CanvasInput;
}(DynamicText);
var DefaultParseTextCallback = function DefaultParseTextCallback(text) {
return text;
};
Object.assign(CanvasInput.prototype, SetTextOXYMethods);

function CanvasInputFactory (x, y, width, height, config) {
var gameObject = new CanvasInput(this.scene, x, y, width, height, config);
Expand Down
2 changes: 1 addition & 1 deletion dist/rexcanvasinputplugin.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit ebbc2c8

Please sign in to comment.