lyb-pixi-js 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/Base/LibPixiText.d.ts +2 -0
- package/Components/Base/LibPixiText.js +5 -2
- package/Components/Custom/LibPixiInput.d.ts +71 -0
- package/Components/Custom/LibPixiInput.js +180 -0
- package/README.md +4 -0
- package/libPixiJs.d.ts +3 -0
- package/libPixiJs.js +3 -0
- package/lyb-pixi.js +276 -112
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Text, TextStyle, } from "pixi.js";
|
|
1
|
+
import { Text, TEXT_GRADIENT, TextStyle, } from "pixi.js";
|
|
2
2
|
/** @description 自定义文本类
|
|
3
3
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiText-文本
|
|
4
4
|
*/
|
|
5
5
|
export class LibPixiText extends Text {
|
|
6
6
|
constructor(options) {
|
|
7
|
-
const { text, fontSize = 36, fontColor = 0xffffff, stroke, strokeThickness, fontFamily = "Arial", fontWeight = "normal", wordWrapWidth, lineHeight = 1, align = "left", indent = 0, shadow, } = options;
|
|
7
|
+
const { text, fontSize = 36, fontColor = 0xffffff, stroke, strokeThickness, fontFamily = "Arial", fontWeight = "normal", wordWrapWidth, lineHeight = 1, align = "left", indent = 0, shadow, gradientDirection, } = options;
|
|
8
8
|
const style = new TextStyle({
|
|
9
9
|
fontSize,
|
|
10
10
|
wordWrap: !!wordWrapWidth,
|
|
@@ -18,6 +18,9 @@ export class LibPixiText extends Text {
|
|
|
18
18
|
stroke: stroke ? stroke : "transparent",
|
|
19
19
|
strokeThickness: strokeThickness ? strokeThickness : 0,
|
|
20
20
|
lineJoin: "round",
|
|
21
|
+
fillGradientType: gradientDirection === "h"
|
|
22
|
+
? TEXT_GRADIENT.LINEAR_HORIZONTAL
|
|
23
|
+
: TEXT_GRADIENT.LINEAR_VERTICAL,
|
|
21
24
|
});
|
|
22
25
|
if (shadow) {
|
|
23
26
|
style.dropShadow = true;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Container } from "pixi.js";
|
|
2
|
+
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
3
|
+
interface Params {
|
|
4
|
+
/** 舞台 */
|
|
5
|
+
stage: Container;
|
|
6
|
+
/** 宽度 */
|
|
7
|
+
width: number;
|
|
8
|
+
/** 高度 */
|
|
9
|
+
height: number;
|
|
10
|
+
/** 字体与高度比 */
|
|
11
|
+
fontSizeRatio: number;
|
|
12
|
+
/** 是否需要placeholder */
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** placeholder颜色 */
|
|
15
|
+
placeholderColor?: string;
|
|
16
|
+
/** 背景色,用于调试输入框的位置 */
|
|
17
|
+
bgColor?: string;
|
|
18
|
+
/** 输入类型 */
|
|
19
|
+
type?: "number" | "text";
|
|
20
|
+
/** 字体颜色 */
|
|
21
|
+
color?: string;
|
|
22
|
+
/** 初始值 */
|
|
23
|
+
value?: string;
|
|
24
|
+
/** 是否整数 */
|
|
25
|
+
integer?: boolean;
|
|
26
|
+
/** 是否允许输入负数 */
|
|
27
|
+
isNegative?: boolean;
|
|
28
|
+
/** 最小值 */
|
|
29
|
+
min?: number;
|
|
30
|
+
/** 最大值 */
|
|
31
|
+
max?: number;
|
|
32
|
+
/** 最大长度 */
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
/** 对齐方式 */
|
|
35
|
+
align?: "left" | "center";
|
|
36
|
+
/** 输入回调 */
|
|
37
|
+
onInput?: (text: number | string) => void;
|
|
38
|
+
/** 失去焦点回调 */
|
|
39
|
+
onValue?: (text: number | string) => void;
|
|
40
|
+
/** 格式化显示值 */
|
|
41
|
+
onFormatValue?: (text: number | string) => string;
|
|
42
|
+
}
|
|
43
|
+
/** @description 动态缩放移动输入框 */
|
|
44
|
+
export declare class LibPixiInput extends LibPixiContainer {
|
|
45
|
+
/** 参数 */
|
|
46
|
+
private _params;
|
|
47
|
+
/** 只读输入框 */
|
|
48
|
+
private _readonlyInput;
|
|
49
|
+
/** placeholder */
|
|
50
|
+
private _placeholder;
|
|
51
|
+
/** 输入框dom */
|
|
52
|
+
private _input;
|
|
53
|
+
/** 当前输入的值 */
|
|
54
|
+
private _value;
|
|
55
|
+
constructor(params: Params);
|
|
56
|
+
/** @description 设置值 */
|
|
57
|
+
setValue(v: string): void;
|
|
58
|
+
/** @description 创建输入框 */
|
|
59
|
+
private _createInput;
|
|
60
|
+
/** @description 创建只读输入框 */
|
|
61
|
+
private _createReadOnlyInput;
|
|
62
|
+
/** @description 聚焦 */
|
|
63
|
+
private _focus;
|
|
64
|
+
/** @description 失焦 */
|
|
65
|
+
private _blur;
|
|
66
|
+
/** @description 失去焦点处理 */
|
|
67
|
+
private _onBlurHandler;
|
|
68
|
+
/** @description 实时更新输入框位置 */
|
|
69
|
+
private _updateInputPosition;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Ticker } from "pixi.js";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
import { libPixiEvent } from "../../Utils/LibPixiEvent";
|
|
4
|
+
import { libPixiScaleContainer } from "../../Utils/LibPixiScaleContainer";
|
|
5
|
+
import { LibPixiContainer } from "../Base/LibPixiContainer";
|
|
6
|
+
import { LibPixiText } from "../Base/LibPixiText";
|
|
7
|
+
/** @description 动态缩放移动输入框 */
|
|
8
|
+
export class LibPixiInput extends LibPixiContainer {
|
|
9
|
+
constructor(params) {
|
|
10
|
+
const { width, height, bgColor, value = "" } = params;
|
|
11
|
+
super(width, height, bgColor);
|
|
12
|
+
/** 当前输入的值 */
|
|
13
|
+
this._value = "";
|
|
14
|
+
/** @description 失去焦点处理 */
|
|
15
|
+
this._onBlurHandler = () => {
|
|
16
|
+
const { type = "text", integer = false, min = 1, max = Infinity, } = this._params;
|
|
17
|
+
let text = this._input.value.trim();
|
|
18
|
+
//如果类型为字符串,则不参与校验
|
|
19
|
+
if (type === "text")
|
|
20
|
+
return text;
|
|
21
|
+
//如果为空,则使用最小值
|
|
22
|
+
if (this._input.value === "")
|
|
23
|
+
text = min.toString();
|
|
24
|
+
//如果不能为负数,输入值小于最小值,则使用最小值
|
|
25
|
+
if (Number(text) < min)
|
|
26
|
+
text = min.toString();
|
|
27
|
+
//如果存在最大值,且输入值大于最大值,则使用最大值
|
|
28
|
+
if (max && Number(text) > max)
|
|
29
|
+
text = max.toString();
|
|
30
|
+
//如果要求整数,则取整
|
|
31
|
+
if (integer)
|
|
32
|
+
text = parseInt(text).toString();
|
|
33
|
+
//保留两位小数且不四舍五入
|
|
34
|
+
const value = new Decimal(Number(text));
|
|
35
|
+
text = value.toFixed(2, Decimal.ROUND_DOWN);
|
|
36
|
+
return text;
|
|
37
|
+
};
|
|
38
|
+
this.cursor = "text";
|
|
39
|
+
this._params = params;
|
|
40
|
+
this._value = value;
|
|
41
|
+
this._createInput();
|
|
42
|
+
this._createReadOnlyInput();
|
|
43
|
+
//聚焦
|
|
44
|
+
libPixiEvent(this, "pointertap", this._focus.bind(this));
|
|
45
|
+
const ticker = new Ticker();
|
|
46
|
+
ticker.add(() => {
|
|
47
|
+
if (this.destroyed) {
|
|
48
|
+
ticker.stop();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this._updateInputPosition();
|
|
52
|
+
});
|
|
53
|
+
ticker.start();
|
|
54
|
+
}
|
|
55
|
+
/** @description 设置值 */
|
|
56
|
+
setValue(v) {
|
|
57
|
+
const { onFormatValue } = this._params;
|
|
58
|
+
const value = v;
|
|
59
|
+
this._value = value;
|
|
60
|
+
this._readonlyInput.text = (onFormatValue === null || onFormatValue === void 0 ? void 0 : onFormatValue(value)) || value;
|
|
61
|
+
}
|
|
62
|
+
/** @description 创建输入框 */
|
|
63
|
+
_createInput() {
|
|
64
|
+
const { color = "#fff", maxLength = 999999, align = "left", type = "text", onInput = () => { }, } = this._params;
|
|
65
|
+
this._input = document.createElement("input");
|
|
66
|
+
this._input.type = type;
|
|
67
|
+
this._input.maxLength = maxLength;
|
|
68
|
+
this._input.style.cssText = `
|
|
69
|
+
position: absolute;
|
|
70
|
+
border: none;
|
|
71
|
+
outline: none;
|
|
72
|
+
display: none;
|
|
73
|
+
background-color: transparent;
|
|
74
|
+
color: ${color};
|
|
75
|
+
text-align: ${align};
|
|
76
|
+
`;
|
|
77
|
+
document.querySelector("#game").appendChild(this._input);
|
|
78
|
+
this._input.addEventListener("input", function () {
|
|
79
|
+
if (this.value.length > maxLength && type === "number") {
|
|
80
|
+
this.value = this.value.slice(0, maxLength);
|
|
81
|
+
}
|
|
82
|
+
onInput(this.value.trim());
|
|
83
|
+
});
|
|
84
|
+
this._input.addEventListener("paste", function (e) {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
const paste = (_b = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text")) !== null && _b !== void 0 ? _b : "";
|
|
87
|
+
if (paste.length > maxLength) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
this.value = paste.slice(0, maxLength);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this._input.addEventListener("blur", this._blur.bind(this));
|
|
93
|
+
}
|
|
94
|
+
/** @description 创建只读输入框 */
|
|
95
|
+
_createReadOnlyInput() {
|
|
96
|
+
const { color = "#fff", value = "", width, height, fontSizeRatio = 0.5, align = "left", placeholder = "", placeholderColor, } = this._params;
|
|
97
|
+
//创建描述
|
|
98
|
+
this._placeholder = new LibPixiText({
|
|
99
|
+
text: placeholder,
|
|
100
|
+
fontColor: placeholderColor,
|
|
101
|
+
fontSize: height * fontSizeRatio,
|
|
102
|
+
});
|
|
103
|
+
this.addChild(this._placeholder);
|
|
104
|
+
this._placeholder.visible = !value;
|
|
105
|
+
this._placeholder.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
106
|
+
this._placeholder.position.set(align === "left" ? 0 : width / 2, height / 2);
|
|
107
|
+
//创建实际显示的文本
|
|
108
|
+
this._readonlyInput = new LibPixiText({
|
|
109
|
+
text: value,
|
|
110
|
+
fontColor: color,
|
|
111
|
+
fontSize: height * fontSizeRatio,
|
|
112
|
+
});
|
|
113
|
+
this.addChild(this._readonlyInput);
|
|
114
|
+
this._readonlyInput.visible = !!value;
|
|
115
|
+
this._readonlyInput.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
116
|
+
this._readonlyInput.position.set(align === "left" ? 0 : width / 2, height / 2);
|
|
117
|
+
}
|
|
118
|
+
/** @description 聚焦 */
|
|
119
|
+
_focus() {
|
|
120
|
+
const { type } = this._params;
|
|
121
|
+
this._input.style.display = "block";
|
|
122
|
+
this._input.focus();
|
|
123
|
+
this._readonlyInput.visible = false;
|
|
124
|
+
this._placeholder.visible = false;
|
|
125
|
+
if (type === "number") {
|
|
126
|
+
this._input.value = this._value && Number(this._value).toString();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this._input.value = this._value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** @description 失焦 */
|
|
133
|
+
_blur() {
|
|
134
|
+
const { onValue, width } = this._params;
|
|
135
|
+
const value = this._onBlurHandler();
|
|
136
|
+
this.setValue(value);
|
|
137
|
+
this._input.style.display = "none";
|
|
138
|
+
libPixiScaleContainer(this._readonlyInput, width);
|
|
139
|
+
if (this._params.type === "number") {
|
|
140
|
+
this._readonlyInput.visible = true;
|
|
141
|
+
onValue === null || onValue === void 0 ? void 0 : onValue(Number(value));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
onValue === null || onValue === void 0 ? void 0 : onValue(value);
|
|
145
|
+
//如果输入的值为空,并且启用了描述,并且没有默认值,则显示描述
|
|
146
|
+
if (value === "" && this._placeholder) {
|
|
147
|
+
this._placeholder.visible = true;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this._readonlyInput.visible = true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** @description 实时更新输入框位置 */
|
|
155
|
+
_updateInputPosition() {
|
|
156
|
+
const { width, height, x, y } = this.getBounds();
|
|
157
|
+
const { fontSizeRatio = 0.5 } = this._params;
|
|
158
|
+
this._input.style.width = `${width}px`;
|
|
159
|
+
this._input.style.height = `${height}px`;
|
|
160
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
161
|
+
if (this._params.stage.rotation === 0) {
|
|
162
|
+
this._input.style.left = `${x}px`;
|
|
163
|
+
this._input.style.top = `${y}px`;
|
|
164
|
+
this._input.style.width = `${width}px`;
|
|
165
|
+
this._input.style.height = `${height}px`;
|
|
166
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
167
|
+
this._input.style.transform = `rotate(0deg)`;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const centerX = x + width / 2;
|
|
171
|
+
const centerY = y + height / 2;
|
|
172
|
+
this._input.style.left = `${centerX - height / 2}px`;
|
|
173
|
+
this._input.style.top = `${centerY - width / 2}px`;
|
|
174
|
+
this._input.style.width = `${height}px`;
|
|
175
|
+
this._input.style.height = `${width}px`;
|
|
176
|
+
this._input.style.fontSize = `${width * fontSizeRatio}px`;
|
|
177
|
+
this._input.style.transform = `rotate(90deg)`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
package/README.md
CHANGED
package/libPixiJs.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { LibPixiArc } from "./Components/Base/LibPixiArc";
|
|
|
32
32
|
import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
33
33
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
34
34
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
35
|
+
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
35
36
|
/** @description 组件 */
|
|
36
37
|
export declare const Components: {
|
|
37
38
|
Base: {
|
|
@@ -145,6 +146,8 @@ export declare const Components: {
|
|
|
145
146
|
LibPixiDragLocate: typeof LibPixiDragLocate;
|
|
146
147
|
/** @description 转盘布局 */
|
|
147
148
|
LibPixiTurntable: (num: number, distance: number, layoutCallback: (x: number, y: number, rotation: number, index: number) => void) => void;
|
|
149
|
+
/** @description 输入框 */
|
|
150
|
+
LibPixiInput: typeof LibPixiInput;
|
|
148
151
|
};
|
|
149
152
|
};
|
|
150
153
|
/** @description 方法 */
|
package/libPixiJs.js
CHANGED
|
@@ -51,6 +51,7 @@ import { LibPixiArc } from "./Components/Base/LibPixiArc";
|
|
|
51
51
|
import { LibPixiOval } from "./Components/Base/LibPixiOval";
|
|
52
52
|
import { LibPixiRound } from "./Components/Base/LibPixiRound";
|
|
53
53
|
import { LibPixiRoundedRect } from "./Components/Base/LibPixiRoundedRect";
|
|
54
|
+
import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
54
55
|
/** @description 组件 */
|
|
55
56
|
export const Components = {
|
|
56
57
|
Base: {
|
|
@@ -164,6 +165,8 @@ export const Components = {
|
|
|
164
165
|
LibPixiDragLocate,
|
|
165
166
|
/** @description 转盘布局 */
|
|
166
167
|
LibPixiTurntable,
|
|
168
|
+
/** @description 输入框 */
|
|
169
|
+
LibPixiInput,
|
|
167
170
|
},
|
|
168
171
|
};
|
|
169
172
|
/** @description 方法 */
|
package/lyb-pixi.js
CHANGED
|
@@ -1315,7 +1315,7 @@
|
|
|
1315
1315
|
var ys = arrObjKeys(obj, inspect2);
|
|
1316
1316
|
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
1317
1317
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
1318
|
-
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
|
|
1318
|
+
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
|
|
1319
1319
|
var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
|
|
1320
1320
|
var tag2 = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
|
|
1321
1321
|
if (ys.length === 0) {
|
|
@@ -1337,25 +1337,25 @@
|
|
|
1337
1337
|
return $replace$1.call(String(s2), /"/g, """);
|
|
1338
1338
|
}
|
|
1339
1339
|
function isArray$3(obj) {
|
|
1340
|
-
return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1340
|
+
return toStr$1(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1341
1341
|
}
|
|
1342
1342
|
function isDate(obj) {
|
|
1343
|
-
return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1343
|
+
return toStr$1(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1344
1344
|
}
|
|
1345
1345
|
function isRegExp$1(obj) {
|
|
1346
|
-
return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1346
|
+
return toStr$1(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1347
1347
|
}
|
|
1348
1348
|
function isError(obj) {
|
|
1349
|
-
return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1349
|
+
return toStr$1(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1350
1350
|
}
|
|
1351
1351
|
function isString(obj) {
|
|
1352
|
-
return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1352
|
+
return toStr$1(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1353
1353
|
}
|
|
1354
1354
|
function isNumber(obj) {
|
|
1355
|
-
return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1355
|
+
return toStr$1(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1356
1356
|
}
|
|
1357
1357
|
function isBoolean(obj) {
|
|
1358
|
-
return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1358
|
+
return toStr$1(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
1359
1359
|
}
|
|
1360
1360
|
function isSymbol(obj) {
|
|
1361
1361
|
if (hasShammedSymbols) {
|
|
@@ -1391,7 +1391,7 @@
|
|
|
1391
1391
|
function has$3(obj, key) {
|
|
1392
1392
|
return hasOwn$1.call(obj, key);
|
|
1393
1393
|
}
|
|
1394
|
-
function toStr(obj) {
|
|
1394
|
+
function toStr$1(obj) {
|
|
1395
1395
|
return objectToString.call(obj);
|
|
1396
1396
|
}
|
|
1397
1397
|
function nameOf(f2) {
|
|
@@ -1700,7 +1700,7 @@
|
|
|
1700
1700
|
var uri = URIError;
|
|
1701
1701
|
var abs$2 = Math.abs;
|
|
1702
1702
|
var floor$2 = Math.floor;
|
|
1703
|
-
var max$
|
|
1703
|
+
var max$3 = Math.max;
|
|
1704
1704
|
var min$2 = Math.min;
|
|
1705
1705
|
var pow$2 = Math.pow;
|
|
1706
1706
|
var round$3 = Math.round;
|
|
@@ -1833,102 +1833,78 @@
|
|
|
1833
1833
|
Object_getPrototypeOf = $Object2.getPrototypeOf || null;
|
|
1834
1834
|
return Object_getPrototypeOf;
|
|
1835
1835
|
}
|
|
1836
|
-
var
|
|
1837
|
-
var
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
var
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
var
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
var joiny = function(arr, joiner) {
|
|
1864
|
-
var str = "";
|
|
1865
|
-
for (var i2 = 0; i2 < arr.length; i2 += 1) {
|
|
1866
|
-
str += arr[i2];
|
|
1867
|
-
if (i2 + 1 < arr.length) {
|
|
1868
|
-
str += joiner;
|
|
1869
|
-
}
|
|
1836
|
+
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
|
|
1837
|
+
var toStr = Object.prototype.toString;
|
|
1838
|
+
var max$2 = Math.max;
|
|
1839
|
+
var funcType = "[object Function]";
|
|
1840
|
+
var concatty = function concatty2(a2, b2) {
|
|
1841
|
+
var arr = [];
|
|
1842
|
+
for (var i2 = 0; i2 < a2.length; i2 += 1) {
|
|
1843
|
+
arr[i2] = a2[i2];
|
|
1844
|
+
}
|
|
1845
|
+
for (var j2 = 0; j2 < b2.length; j2 += 1) {
|
|
1846
|
+
arr[j2 + a2.length] = b2[j2];
|
|
1847
|
+
}
|
|
1848
|
+
return arr;
|
|
1849
|
+
};
|
|
1850
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
1851
|
+
var arr = [];
|
|
1852
|
+
for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
|
|
1853
|
+
arr[j2] = arrLike[i2];
|
|
1854
|
+
}
|
|
1855
|
+
return arr;
|
|
1856
|
+
};
|
|
1857
|
+
var joiny = function(arr, joiner) {
|
|
1858
|
+
var str = "";
|
|
1859
|
+
for (var i2 = 0; i2 < arr.length; i2 += 1) {
|
|
1860
|
+
str += arr[i2];
|
|
1861
|
+
if (i2 + 1 < arr.length) {
|
|
1862
|
+
str += joiner;
|
|
1870
1863
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
);
|
|
1886
|
-
if (Object(result) === result) {
|
|
1887
|
-
return result;
|
|
1888
|
-
}
|
|
1889
|
-
return this;
|
|
1890
|
-
}
|
|
1891
|
-
return target.apply(
|
|
1892
|
-
that,
|
|
1864
|
+
}
|
|
1865
|
+
return str;
|
|
1866
|
+
};
|
|
1867
|
+
var implementation$1 = function bind2(that) {
|
|
1868
|
+
var target = this;
|
|
1869
|
+
if (typeof target !== "function" || toStr.apply(target) !== funcType) {
|
|
1870
|
+
throw new TypeError(ERROR_MESSAGE + target);
|
|
1871
|
+
}
|
|
1872
|
+
var args = slicy(arguments, 1);
|
|
1873
|
+
var bound;
|
|
1874
|
+
var binder = function() {
|
|
1875
|
+
if (this instanceof bound) {
|
|
1876
|
+
var result = target.apply(
|
|
1877
|
+
this,
|
|
1893
1878
|
concatty(args, arguments)
|
|
1894
1879
|
);
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
boundArgs[i2] = "$" + i2;
|
|
1900
|
-
}
|
|
1901
|
-
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
1902
|
-
if (target.prototype) {
|
|
1903
|
-
var Empty = function Empty2() {
|
|
1904
|
-
};
|
|
1905
|
-
Empty.prototype = target.prototype;
|
|
1906
|
-
bound.prototype = new Empty();
|
|
1907
|
-
Empty.prototype = null;
|
|
1880
|
+
if (Object(result) === result) {
|
|
1881
|
+
return result;
|
|
1882
|
+
}
|
|
1883
|
+
return this;
|
|
1908
1884
|
}
|
|
1909
|
-
return
|
|
1885
|
+
return target.apply(
|
|
1886
|
+
that,
|
|
1887
|
+
concatty(args, arguments)
|
|
1888
|
+
);
|
|
1910
1889
|
};
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
functionCall = Function.prototype.call;
|
|
1930
|
-
return functionCall;
|
|
1931
|
-
}
|
|
1890
|
+
var boundLength = max$2(0, target.length - args.length);
|
|
1891
|
+
var boundArgs = [];
|
|
1892
|
+
for (var i2 = 0; i2 < boundLength; i2++) {
|
|
1893
|
+
boundArgs[i2] = "$" + i2;
|
|
1894
|
+
}
|
|
1895
|
+
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
1896
|
+
if (target.prototype) {
|
|
1897
|
+
var Empty = function Empty2() {
|
|
1898
|
+
};
|
|
1899
|
+
Empty.prototype = target.prototype;
|
|
1900
|
+
bound.prototype = new Empty();
|
|
1901
|
+
Empty.prototype = null;
|
|
1902
|
+
}
|
|
1903
|
+
return bound;
|
|
1904
|
+
};
|
|
1905
|
+
var implementation = implementation$1;
|
|
1906
|
+
var functionBind = Function.prototype.bind || implementation;
|
|
1907
|
+
var functionCall = Function.prototype.call;
|
|
1932
1908
|
var functionApply;
|
|
1933
1909
|
var hasRequiredFunctionApply;
|
|
1934
1910
|
function requireFunctionApply() {
|
|
@@ -1939,14 +1915,14 @@
|
|
|
1939
1915
|
return functionApply;
|
|
1940
1916
|
}
|
|
1941
1917
|
var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
|
|
1942
|
-
var bind$2 =
|
|
1918
|
+
var bind$2 = functionBind;
|
|
1943
1919
|
var $apply$1 = requireFunctionApply();
|
|
1944
|
-
var $call$2 =
|
|
1920
|
+
var $call$2 = functionCall;
|
|
1945
1921
|
var $reflectApply = reflectApply;
|
|
1946
1922
|
var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
|
|
1947
|
-
var bind$1 =
|
|
1923
|
+
var bind$1 = functionBind;
|
|
1948
1924
|
var $TypeError$4 = type;
|
|
1949
|
-
var $call$1 =
|
|
1925
|
+
var $call$1 = functionCall;
|
|
1950
1926
|
var $actualApply = actualApply;
|
|
1951
1927
|
var callBindApplyHelpers = function callBindBasic2(args) {
|
|
1952
1928
|
if (args.length < 1 || typeof args[0] !== "function") {
|
|
@@ -2015,7 +1991,7 @@
|
|
|
2015
1991
|
hasRequiredHasown = 1;
|
|
2016
1992
|
var call = Function.prototype.call;
|
|
2017
1993
|
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
2018
|
-
var bind2 =
|
|
1994
|
+
var bind2 = functionBind;
|
|
2019
1995
|
hasown = bind2.call(call, $hasOwn);
|
|
2020
1996
|
return hasown;
|
|
2021
1997
|
}
|
|
@@ -2030,7 +2006,7 @@
|
|
|
2030
2006
|
var $URIError = uri;
|
|
2031
2007
|
var abs$1 = abs$2;
|
|
2032
2008
|
var floor$1 = floor$2;
|
|
2033
|
-
var max$1 = max$
|
|
2009
|
+
var max$1 = max$3;
|
|
2034
2010
|
var min$1 = min$2;
|
|
2035
2011
|
var pow$1 = pow$2;
|
|
2036
2012
|
var round$2 = round$3;
|
|
@@ -2064,7 +2040,7 @@
|
|
|
2064
2040
|
var $ObjectGPO = requireObject_getPrototypeOf();
|
|
2065
2041
|
var $ReflectGPO = requireReflect_getPrototypeOf();
|
|
2066
2042
|
var $apply = requireFunctionApply();
|
|
2067
|
-
var $call =
|
|
2043
|
+
var $call = functionCall;
|
|
2068
2044
|
var needsEval = {};
|
|
2069
2045
|
var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
2070
2046
|
var INTRINSICS = {
|
|
@@ -2234,7 +2210,7 @@
|
|
|
2234
2210
|
"%WeakMapPrototype%": ["WeakMap", "prototype"],
|
|
2235
2211
|
"%WeakSetPrototype%": ["WeakSet", "prototype"]
|
|
2236
2212
|
};
|
|
2237
|
-
var bind =
|
|
2213
|
+
var bind = functionBind;
|
|
2238
2214
|
var hasOwn = requireHasown();
|
|
2239
2215
|
var $concat = bind.call($call, Array.prototype.concat);
|
|
2240
2216
|
var $spliceApply = bind.call($apply, Array.prototype.splice);
|
|
@@ -31865,7 +31841,8 @@ void main(void)\r
|
|
|
31865
31841
|
lineHeight = 1,
|
|
31866
31842
|
align = "left",
|
|
31867
31843
|
indent = 0,
|
|
31868
|
-
shadow
|
|
31844
|
+
shadow,
|
|
31845
|
+
gradientDirection
|
|
31869
31846
|
} = options;
|
|
31870
31847
|
const style = new TextStyle({
|
|
31871
31848
|
fontSize,
|
|
@@ -31879,7 +31856,8 @@ void main(void)\r
|
|
|
31879
31856
|
fontFamily: LibPixiText.fontFamily || fontFamily,
|
|
31880
31857
|
stroke: stroke ? stroke : "transparent",
|
|
31881
31858
|
strokeThickness: strokeThickness ? strokeThickness : 0,
|
|
31882
|
-
lineJoin: "round"
|
|
31859
|
+
lineJoin: "round",
|
|
31860
|
+
fillGradientType: gradientDirection === "h" ? TEXT_GRADIENT.LINEAR_HORIZONTAL : TEXT_GRADIENT.LINEAR_VERTICAL
|
|
31883
31861
|
});
|
|
31884
31862
|
if (shadow) {
|
|
31885
31863
|
style.dropShadow = true;
|
|
@@ -58046,6 +58024,190 @@ void main(void){
|
|
|
58046
58024
|
this.endFill();
|
|
58047
58025
|
}
|
|
58048
58026
|
}
|
|
58027
|
+
class LibPixiInput extends LibPixiContainer {
|
|
58028
|
+
constructor(params) {
|
|
58029
|
+
const { width, height, bgColor, value = "" } = params;
|
|
58030
|
+
super(width, height, bgColor);
|
|
58031
|
+
this._value = "";
|
|
58032
|
+
this._onBlurHandler = () => {
|
|
58033
|
+
const {
|
|
58034
|
+
type: type2 = "text",
|
|
58035
|
+
integer = false,
|
|
58036
|
+
min: min2 = 1,
|
|
58037
|
+
max: max2 = Infinity
|
|
58038
|
+
} = this._params;
|
|
58039
|
+
let text = this._input.value.trim();
|
|
58040
|
+
if (type2 === "text")
|
|
58041
|
+
return text;
|
|
58042
|
+
if (this._input.value === "")
|
|
58043
|
+
text = min2.toString();
|
|
58044
|
+
if (Number(text) < min2)
|
|
58045
|
+
text = min2.toString();
|
|
58046
|
+
if (max2 && Number(text) > max2)
|
|
58047
|
+
text = max2.toString();
|
|
58048
|
+
if (integer)
|
|
58049
|
+
text = parseInt(text).toString();
|
|
58050
|
+
const value2 = new Decimal(Number(text));
|
|
58051
|
+
text = value2.toFixed(2, Decimal.ROUND_DOWN);
|
|
58052
|
+
return text;
|
|
58053
|
+
};
|
|
58054
|
+
this.cursor = "text";
|
|
58055
|
+
this._params = params;
|
|
58056
|
+
this._value = value;
|
|
58057
|
+
this._createInput();
|
|
58058
|
+
this._createReadOnlyInput();
|
|
58059
|
+
libPixiEvent(this, "pointertap", this._focus.bind(this));
|
|
58060
|
+
const ticker2 = new Ticker();
|
|
58061
|
+
ticker2.add(() => {
|
|
58062
|
+
if (this.destroyed) {
|
|
58063
|
+
ticker2.stop();
|
|
58064
|
+
return;
|
|
58065
|
+
}
|
|
58066
|
+
this._updateInputPosition();
|
|
58067
|
+
});
|
|
58068
|
+
ticker2.start();
|
|
58069
|
+
}
|
|
58070
|
+
/** @description 设置值 */
|
|
58071
|
+
setValue(v2) {
|
|
58072
|
+
const { onFormatValue } = this._params;
|
|
58073
|
+
const value = v2;
|
|
58074
|
+
this._value = value;
|
|
58075
|
+
this._readonlyInput.text = (onFormatValue == null ? void 0 : onFormatValue(value)) || value;
|
|
58076
|
+
}
|
|
58077
|
+
/** @description 创建输入框 */
|
|
58078
|
+
_createInput() {
|
|
58079
|
+
const {
|
|
58080
|
+
color = "#fff",
|
|
58081
|
+
maxLength = 999999,
|
|
58082
|
+
align = "left",
|
|
58083
|
+
type: type2 = "text",
|
|
58084
|
+
onInput = () => {
|
|
58085
|
+
}
|
|
58086
|
+
} = this._params;
|
|
58087
|
+
this._input = document.createElement("input");
|
|
58088
|
+
this._input.type = type2;
|
|
58089
|
+
this._input.maxLength = maxLength;
|
|
58090
|
+
this._input.style.cssText = `
|
|
58091
|
+
position: absolute;
|
|
58092
|
+
border: none;
|
|
58093
|
+
outline: none;
|
|
58094
|
+
display: none;
|
|
58095
|
+
background-color: transparent;
|
|
58096
|
+
color: ${color};
|
|
58097
|
+
text-align: ${align};
|
|
58098
|
+
`;
|
|
58099
|
+
document.querySelector("#game").appendChild(this._input);
|
|
58100
|
+
this._input.addEventListener("input", function() {
|
|
58101
|
+
if (this.value.length > maxLength && type2 === "number") {
|
|
58102
|
+
this.value = this.value.slice(0, maxLength);
|
|
58103
|
+
}
|
|
58104
|
+
onInput(this.value.trim());
|
|
58105
|
+
});
|
|
58106
|
+
this._input.addEventListener("paste", function(e2) {
|
|
58107
|
+
var _a;
|
|
58108
|
+
const paste = ((_a = e2.clipboardData) == null ? void 0 : _a.getData("text")) ?? "";
|
|
58109
|
+
if (paste.length > maxLength) {
|
|
58110
|
+
e2.preventDefault();
|
|
58111
|
+
this.value = paste.slice(0, maxLength);
|
|
58112
|
+
}
|
|
58113
|
+
});
|
|
58114
|
+
this._input.addEventListener("blur", this._blur.bind(this));
|
|
58115
|
+
}
|
|
58116
|
+
/** @description 创建只读输入框 */
|
|
58117
|
+
_createReadOnlyInput() {
|
|
58118
|
+
const {
|
|
58119
|
+
color = "#fff",
|
|
58120
|
+
value = "",
|
|
58121
|
+
width,
|
|
58122
|
+
height,
|
|
58123
|
+
fontSizeRatio = 0.5,
|
|
58124
|
+
align = "left",
|
|
58125
|
+
placeholder = "",
|
|
58126
|
+
placeholderColor
|
|
58127
|
+
} = this._params;
|
|
58128
|
+
this._placeholder = new LibPixiText({
|
|
58129
|
+
text: placeholder,
|
|
58130
|
+
fontColor: placeholderColor,
|
|
58131
|
+
fontSize: height * fontSizeRatio
|
|
58132
|
+
});
|
|
58133
|
+
this.addChild(this._placeholder);
|
|
58134
|
+
this._placeholder.visible = !value;
|
|
58135
|
+
this._placeholder.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
58136
|
+
this._placeholder.position.set(
|
|
58137
|
+
align === "left" ? 0 : width / 2,
|
|
58138
|
+
height / 2
|
|
58139
|
+
);
|
|
58140
|
+
this._readonlyInput = new LibPixiText({
|
|
58141
|
+
text: value,
|
|
58142
|
+
fontColor: color,
|
|
58143
|
+
fontSize: height * fontSizeRatio
|
|
58144
|
+
});
|
|
58145
|
+
this.addChild(this._readonlyInput);
|
|
58146
|
+
this._readonlyInput.visible = !!value;
|
|
58147
|
+
this._readonlyInput.anchor.set(align === "left" ? 0 : 0.5, 0.5);
|
|
58148
|
+
this._readonlyInput.position.set(
|
|
58149
|
+
align === "left" ? 0 : width / 2,
|
|
58150
|
+
height / 2
|
|
58151
|
+
);
|
|
58152
|
+
}
|
|
58153
|
+
/** @description 聚焦 */
|
|
58154
|
+
_focus() {
|
|
58155
|
+
const { type: type2 } = this._params;
|
|
58156
|
+
this._input.style.display = "block";
|
|
58157
|
+
this._input.focus();
|
|
58158
|
+
this._readonlyInput.visible = false;
|
|
58159
|
+
this._placeholder.visible = false;
|
|
58160
|
+
if (type2 === "number") {
|
|
58161
|
+
this._input.value = this._value && Number(this._value).toString();
|
|
58162
|
+
} else {
|
|
58163
|
+
this._input.value = this._value;
|
|
58164
|
+
}
|
|
58165
|
+
}
|
|
58166
|
+
/** @description 失焦 */
|
|
58167
|
+
_blur() {
|
|
58168
|
+
const { onValue, width } = this._params;
|
|
58169
|
+
const value = this._onBlurHandler();
|
|
58170
|
+
this.setValue(value);
|
|
58171
|
+
this._input.style.display = "none";
|
|
58172
|
+
libPixiScaleContainer(this._readonlyInput, width);
|
|
58173
|
+
if (this._params.type === "number") {
|
|
58174
|
+
this._readonlyInput.visible = true;
|
|
58175
|
+
onValue == null ? void 0 : onValue(Number(value));
|
|
58176
|
+
} else {
|
|
58177
|
+
onValue == null ? void 0 : onValue(value);
|
|
58178
|
+
if (value === "" && this._placeholder) {
|
|
58179
|
+
this._placeholder.visible = true;
|
|
58180
|
+
} else {
|
|
58181
|
+
this._readonlyInput.visible = true;
|
|
58182
|
+
}
|
|
58183
|
+
}
|
|
58184
|
+
}
|
|
58185
|
+
/** @description 实时更新输入框位置 */
|
|
58186
|
+
_updateInputPosition() {
|
|
58187
|
+
const { width, height, x: x2, y: y2 } = this.getBounds();
|
|
58188
|
+
const { fontSizeRatio = 0.5 } = this._params;
|
|
58189
|
+
this._input.style.width = `${width}px`;
|
|
58190
|
+
this._input.style.height = `${height}px`;
|
|
58191
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
58192
|
+
if (this._params.stage.rotation === 0) {
|
|
58193
|
+
this._input.style.left = `${x2}px`;
|
|
58194
|
+
this._input.style.top = `${y2}px`;
|
|
58195
|
+
this._input.style.width = `${width}px`;
|
|
58196
|
+
this._input.style.height = `${height}px`;
|
|
58197
|
+
this._input.style.fontSize = `${height * fontSizeRatio}px`;
|
|
58198
|
+
this._input.style.transform = `rotate(0deg)`;
|
|
58199
|
+
} else {
|
|
58200
|
+
const centerX = x2 + width / 2;
|
|
58201
|
+
const centerY = y2 + height / 2;
|
|
58202
|
+
this._input.style.left = `${centerX - height / 2}px`;
|
|
58203
|
+
this._input.style.top = `${centerY - width / 2}px`;
|
|
58204
|
+
this._input.style.width = `${height}px`;
|
|
58205
|
+
this._input.style.height = `${width}px`;
|
|
58206
|
+
this._input.style.fontSize = `${width * fontSizeRatio}px`;
|
|
58207
|
+
this._input.style.transform = `rotate(90deg)`;
|
|
58208
|
+
}
|
|
58209
|
+
}
|
|
58210
|
+
}
|
|
58049
58211
|
const Components = {
|
|
58050
58212
|
Base: {
|
|
58051
58213
|
/** (已废弃)
|
|
@@ -58157,7 +58319,9 @@ void main(void){
|
|
|
58157
58319
|
/** @description 元素拖拽定位 */
|
|
58158
58320
|
LibPixiDragLocate,
|
|
58159
58321
|
/** @description 转盘布局 */
|
|
58160
|
-
LibPixiTurntable
|
|
58322
|
+
LibPixiTurntable,
|
|
58323
|
+
/** @description 输入框 */
|
|
58324
|
+
LibPixiInput
|
|
58161
58325
|
}
|
|
58162
58326
|
};
|
|
58163
58327
|
const Utils = {
|