lyb-pixi-js 1.12.19 → 1.12.21
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/Custom/LibPixiArrangeLinearV2.d.ts +2 -0
- package/Components/Custom/LibPixiArrangeLinearV2.js +17 -5
- package/Components/Custom/LibPixiProgress.d.ts +4 -0
- package/Components/Custom/LibPixiProgress.js +14 -3
- package/Components/Custom/LibPixiPuzzleBg.d.ts +2 -2
- package/Components/Custom/LibPixiPuzzleBg.js +3 -3
- package/Components/Custom/LibPixiTextGroup.d.ts +20 -0
- package/Components/Custom/LibPixiTextGroup.js +50 -0
- package/Components/Custom/LibPixiTextGroupWrap.d.ts +20 -0
- package/Components/Custom/LibPixiTextGroupWrap.js +50 -0
- package/README.md +4 -0
- package/libPixiJs.d.ts +3 -0
- package/libPixiJs.js +3 -0
- package/lyb-pixi.js +95 -16
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export class LibPixiArrangeLinearV2 extends Container {
|
|
|
15
15
|
}
|
|
16
16
|
/** @description 布局 */
|
|
17
17
|
layout() {
|
|
18
|
-
const { colNum = this._elementList.length, gap = 10, direction = "x" } = this._params;
|
|
18
|
+
const { colNum = this._elementList.length, gap = 10, direction = "x", anchorX = 0, anchorY = 0, } = this._params;
|
|
19
19
|
let lastRowMax = 0; // 当前行(或列)的最大高度(或宽度),用于多行/多列换行时计算偏移
|
|
20
20
|
let rowOffset = 0; // 累计偏移量,控制换行后的整体偏移位置
|
|
21
21
|
this._elementList.forEach((item, index) => {
|
|
@@ -24,14 +24,19 @@ export class LibPixiArrangeLinearV2 extends Container {
|
|
|
24
24
|
const col = index % colNum; // 当前列号
|
|
25
25
|
if (direction === "x") {
|
|
26
26
|
//间隔
|
|
27
|
-
const gapValue = Array.isArray(gap) ? (
|
|
27
|
+
const gapValue = Array.isArray(gap) ? (_a = gap[index - 1]) !== null && _a !== void 0 ? _a : 0 : gap;
|
|
28
28
|
//在每行第一列重置列偏移量
|
|
29
29
|
if (col === 0 && row > 0) {
|
|
30
30
|
rowOffset += lastRowMax + gapValue;
|
|
31
31
|
lastRowMax = 0;
|
|
32
32
|
}
|
|
33
33
|
// 横向位置 = 前一个元素的右侧 + 间隔;首列则从 0 开始
|
|
34
|
-
item.x =
|
|
34
|
+
item.x =
|
|
35
|
+
col === 0
|
|
36
|
+
? 0
|
|
37
|
+
: this._elementList[index - 1].x +
|
|
38
|
+
this._elementList[index - 1].width +
|
|
39
|
+
gapValue;
|
|
35
40
|
// 纵向位置 = 当前累计的行偏移
|
|
36
41
|
rowOffset && (item.y = rowOffset);
|
|
37
42
|
// 更新当前行的最大高度
|
|
@@ -39,20 +44,27 @@ export class LibPixiArrangeLinearV2 extends Container {
|
|
|
39
44
|
}
|
|
40
45
|
else {
|
|
41
46
|
//间隔
|
|
42
|
-
const gapValue = Array.isArray(gap) ? (
|
|
47
|
+
const gapValue = Array.isArray(gap) ? (_b = gap[index - 1]) !== null && _b !== void 0 ? _b : 0 : gap;
|
|
43
48
|
//在每列第一行重置行偏移
|
|
44
49
|
if (col === 0 && row > 0) {
|
|
45
50
|
rowOffset += lastRowMax + gapValue;
|
|
46
51
|
lastRowMax = 0;
|
|
47
52
|
}
|
|
48
53
|
// 纵向位置 = 首列则从 0 开始,其余从前一个元素的y坐标 + 高度 + 间隔;
|
|
49
|
-
item.y =
|
|
54
|
+
item.y =
|
|
55
|
+
col === 0
|
|
56
|
+
? 0
|
|
57
|
+
: this._elementList[index - 1].y +
|
|
58
|
+
this._elementList[index - 1].height +
|
|
59
|
+
gapValue;
|
|
50
60
|
// 横向位置 = 当前累计的列偏移
|
|
51
61
|
rowOffset && (item.x = rowOffset);
|
|
52
62
|
// 更新当前列的最大宽度
|
|
53
63
|
lastRowMax = Math.max(lastRowMax, item.width);
|
|
54
64
|
}
|
|
55
65
|
});
|
|
66
|
+
const bounds = this.getLocalBounds();
|
|
67
|
+
this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
|
|
56
68
|
}
|
|
57
69
|
/** @description 获取列表元素 */
|
|
58
70
|
getList() {
|
|
@@ -12,6 +12,8 @@ export interface LibPixiProgressParams {
|
|
|
12
12
|
bgTexture: Texture;
|
|
13
13
|
/** 进度条纹理 */
|
|
14
14
|
barTexture: Texture;
|
|
15
|
+
/** 方向 */
|
|
16
|
+
direction?: "h" | "v";
|
|
15
17
|
}
|
|
16
18
|
/** @description 通过裁剪的方式显示进度条
|
|
17
19
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiProgress-进度条
|
|
@@ -21,6 +23,8 @@ export declare class LibPixiProgress extends Container {
|
|
|
21
23
|
private _progressBar;
|
|
22
24
|
/** 蒙版 */
|
|
23
25
|
private _maskGraphics;
|
|
26
|
+
/** 方向 */
|
|
27
|
+
private _direction;
|
|
24
28
|
constructor(params: LibPixiProgressParams);
|
|
25
29
|
/** @description 更新进度
|
|
26
30
|
* @param progress 进度值,范围从0到1
|
|
@@ -5,7 +5,8 @@ import { Container, Graphics, Sprite } from "pixi.js";
|
|
|
5
5
|
export class LibPixiProgress extends Container {
|
|
6
6
|
constructor(params) {
|
|
7
7
|
super();
|
|
8
|
-
const { bgWidth, bgHeight, barWidth, barHeight, bgTexture, barTexture } = params;
|
|
8
|
+
const { bgWidth, bgHeight, barWidth, barHeight, bgTexture, barTexture, direction } = params;
|
|
9
|
+
this._direction = direction || "h";
|
|
9
10
|
// 背景图
|
|
10
11
|
const background = new Sprite(bgTexture);
|
|
11
12
|
this.addChild(background);
|
|
@@ -17,7 +18,12 @@ export class LibPixiProgress extends Container {
|
|
|
17
18
|
// 创建蒙版
|
|
18
19
|
const mask = new Graphics();
|
|
19
20
|
mask.beginFill(0xffffff);
|
|
20
|
-
|
|
21
|
+
if (direction === "h") {
|
|
22
|
+
mask.drawRect(0, 0, 0, this._progressBar.height);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
mask.drawRect(0, 0, this._progressBar.width, 0);
|
|
26
|
+
}
|
|
21
27
|
mask.endFill();
|
|
22
28
|
this._progressBar.addChild(mask);
|
|
23
29
|
this._progressBar.mask = mask;
|
|
@@ -30,7 +36,12 @@ export class LibPixiProgress extends Container {
|
|
|
30
36
|
const clampedProgress = Math.max(0, Math.min(1, progress));
|
|
31
37
|
this._maskGraphics.clear();
|
|
32
38
|
this._maskGraphics.beginFill(0xffffff);
|
|
33
|
-
|
|
39
|
+
if (this._direction === "h") {
|
|
40
|
+
this._maskGraphics.drawRect(0, 0, this._progressBar.width * clampedProgress, this._progressBar.height);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this._maskGraphics.drawRect(0, this._progressBar.height * (1 - clampedProgress), this._progressBar.width, this._progressBar.height * clampedProgress);
|
|
44
|
+
}
|
|
34
45
|
this._maskGraphics.endFill();
|
|
35
46
|
}
|
|
36
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Container } from "pixi.js";
|
|
1
|
+
import { Container, Texture } from "pixi.js";
|
|
2
2
|
/** @description 设计图背景拼接
|
|
3
3
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
4
4
|
*/
|
|
5
5
|
export declare class LibPixiPuzzleBg extends Container {
|
|
6
|
-
constructor();
|
|
6
|
+
constructor(texture: Texture);
|
|
7
7
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { libJsDecimal } from "lyb-js/Math/LibJsDecimal.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Container, Sprite } from "pixi.js";
|
|
3
3
|
/** @description 设计图背景拼接
|
|
4
4
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPuzzleBg-设计图背景拼接
|
|
5
5
|
*/
|
|
6
6
|
export class LibPixiPuzzleBg extends Container {
|
|
7
|
-
constructor() {
|
|
7
|
+
constructor(texture) {
|
|
8
8
|
super();
|
|
9
9
|
this.eventMode = "none";
|
|
10
10
|
// 背景
|
|
11
|
-
const bg = new Sprite(
|
|
11
|
+
const bg = new Sprite(texture);
|
|
12
12
|
this.addChild(bg);
|
|
13
13
|
bg.visible = false;
|
|
14
14
|
//读取配置
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Container, type ITextStyle } from "pixi.js";
|
|
2
|
+
interface TextItem {
|
|
3
|
+
text: string;
|
|
4
|
+
style?: Partial<ITextStyle>;
|
|
5
|
+
}
|
|
6
|
+
interface TextGroupOptions {
|
|
7
|
+
items: TextItem[];
|
|
8
|
+
defaultStyle?: Partial<ITextStyle>;
|
|
9
|
+
wordWrapWidth?: number;
|
|
10
|
+
paddingX?: number;
|
|
11
|
+
paddingY?: number;
|
|
12
|
+
align?: "left" | "center" | "right";
|
|
13
|
+
anchorX?: number;
|
|
14
|
+
anchorY?: number;
|
|
15
|
+
}
|
|
16
|
+
/** @description 文本组换行 */
|
|
17
|
+
export declare class LibPixiTextGroupWrap extends Container {
|
|
18
|
+
constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, }: TextGroupOptions);
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Container, Text } from "pixi.js";
|
|
2
|
+
/** @description 文本组换行 */
|
|
3
|
+
export class LibPixiTextGroupWrap extends Container {
|
|
4
|
+
constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
|
|
5
|
+
super();
|
|
6
|
+
if (!items.length)
|
|
7
|
+
return;
|
|
8
|
+
const lineGroups = [];
|
|
9
|
+
let currentLine = [];
|
|
10
|
+
let x = 0;
|
|
11
|
+
// 分行
|
|
12
|
+
for (const { text, style = {} } of items) {
|
|
13
|
+
const instance = new Text(text, Object.assign(Object.assign({}, defaultStyle), style));
|
|
14
|
+
const w = instance.width;
|
|
15
|
+
if (wordWrapWidth && x + w > wordWrapWidth && x > 0) {
|
|
16
|
+
lineGroups.push(currentLine);
|
|
17
|
+
currentLine = [];
|
|
18
|
+
x = 0;
|
|
19
|
+
}
|
|
20
|
+
currentLine.push(instance);
|
|
21
|
+
x += w + paddingX;
|
|
22
|
+
}
|
|
23
|
+
if (currentLine.length)
|
|
24
|
+
lineGroups.push(currentLine);
|
|
25
|
+
// 布局每行
|
|
26
|
+
let y = 0;
|
|
27
|
+
for (const line of lineGroups) {
|
|
28
|
+
const totalWidth = line.reduce((sum, i) => sum + i.width + paddingX, -paddingX);
|
|
29
|
+
let offsetX = 0;
|
|
30
|
+
if (align === "center" && wordWrapWidth)
|
|
31
|
+
offsetX = (wordWrapWidth - totalWidth) / 2;
|
|
32
|
+
else if (align === "right" && wordWrapWidth)
|
|
33
|
+
offsetX = wordWrapWidth - totalWidth;
|
|
34
|
+
let currentX = offsetX;
|
|
35
|
+
let maxHeight = 0;
|
|
36
|
+
for (const item of line) {
|
|
37
|
+
item.x = currentX;
|
|
38
|
+
item.y = y;
|
|
39
|
+
this.addChild(item);
|
|
40
|
+
currentX += item.width + paddingX;
|
|
41
|
+
if (item.height > maxHeight)
|
|
42
|
+
maxHeight = item.height;
|
|
43
|
+
}
|
|
44
|
+
y += maxHeight + paddingY;
|
|
45
|
+
}
|
|
46
|
+
// 根据 anchor 调整整体偏移
|
|
47
|
+
const bounds = this.getLocalBounds();
|
|
48
|
+
this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Container, type ITextStyle } from "pixi.js";
|
|
2
|
+
interface TextItem {
|
|
3
|
+
text: string;
|
|
4
|
+
style?: Partial<ITextStyle>;
|
|
5
|
+
}
|
|
6
|
+
interface TextGroupOptions {
|
|
7
|
+
items: TextItem[];
|
|
8
|
+
defaultStyle?: Partial<ITextStyle>;
|
|
9
|
+
wordWrapWidth?: number;
|
|
10
|
+
paddingX?: number;
|
|
11
|
+
paddingY?: number;
|
|
12
|
+
align?: "left" | "center" | "right";
|
|
13
|
+
anchorX?: number;
|
|
14
|
+
anchorY?: number;
|
|
15
|
+
}
|
|
16
|
+
/** @description 文本组换行 */
|
|
17
|
+
export declare class LibPixiTextGroupWrap extends Container {
|
|
18
|
+
constructor({ items, defaultStyle, wordWrapWidth, paddingX, paddingY, align, anchorX, anchorY, }: TextGroupOptions);
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Container, Text } from "pixi.js";
|
|
2
|
+
/** @description 文本组换行 */
|
|
3
|
+
export class LibPixiTextGroupWrap extends Container {
|
|
4
|
+
constructor({ items, defaultStyle = {}, wordWrapWidth, paddingX = 0, paddingY = 0, align = "left", anchorX = 0, anchorY = 0, }) {
|
|
5
|
+
super();
|
|
6
|
+
if (!items.length)
|
|
7
|
+
return;
|
|
8
|
+
const lineGroups = [];
|
|
9
|
+
let currentLine = [];
|
|
10
|
+
let x = 0;
|
|
11
|
+
// 分行
|
|
12
|
+
for (const { text, style = {} } of items) {
|
|
13
|
+
const instance = new Text(text, Object.assign(Object.assign({}, defaultStyle), style));
|
|
14
|
+
const w = instance.width;
|
|
15
|
+
if (wordWrapWidth && x + w > wordWrapWidth && x > 0) {
|
|
16
|
+
lineGroups.push(currentLine);
|
|
17
|
+
currentLine = [];
|
|
18
|
+
x = 0;
|
|
19
|
+
}
|
|
20
|
+
currentLine.push(instance);
|
|
21
|
+
x += w + paddingX;
|
|
22
|
+
}
|
|
23
|
+
if (currentLine.length)
|
|
24
|
+
lineGroups.push(currentLine);
|
|
25
|
+
// 布局每行
|
|
26
|
+
let y = 0;
|
|
27
|
+
for (const line of lineGroups) {
|
|
28
|
+
const totalWidth = line.reduce((sum, i) => sum + i.width + paddingX, -paddingX);
|
|
29
|
+
let offsetX = 0;
|
|
30
|
+
if (align === "center" && wordWrapWidth)
|
|
31
|
+
offsetX = (wordWrapWidth - totalWidth) / 2;
|
|
32
|
+
else if (align === "right" && wordWrapWidth)
|
|
33
|
+
offsetX = wordWrapWidth - totalWidth;
|
|
34
|
+
let currentX = offsetX;
|
|
35
|
+
let maxHeight = 0;
|
|
36
|
+
for (const item of line) {
|
|
37
|
+
item.x = currentX;
|
|
38
|
+
item.y = y;
|
|
39
|
+
this.addChild(item);
|
|
40
|
+
currentX += item.width + paddingX;
|
|
41
|
+
if (item.height > maxHeight)
|
|
42
|
+
maxHeight = item.height;
|
|
43
|
+
}
|
|
44
|
+
y += maxHeight + paddingY;
|
|
45
|
+
}
|
|
46
|
+
// 根据 anchor 调整整体偏移
|
|
47
|
+
const bounds = this.getLocalBounds();
|
|
48
|
+
this.pivot.set(bounds.x + bounds.width * anchorX, bounds.y + bounds.height * anchorY);
|
|
49
|
+
}
|
|
50
|
+
}
|
package/README.md
CHANGED
package/libPixiJs.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
|
36
36
|
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
37
37
|
import { LibPixiTicker } from "./Utils/LibPixiTicker";
|
|
38
38
|
import { LibPixiArrangeLinearV2 } from "./Components/Custom/LibPixiArrangeLinearV2";
|
|
39
|
+
import { LibPixiTextGroupWrap } from "./Components/Custom/LibPixiTextGroupWrap";
|
|
39
40
|
/** @description 组件 */
|
|
40
41
|
export declare const Components: {
|
|
41
42
|
Base: {
|
|
@@ -153,6 +154,8 @@ export declare const Components: {
|
|
|
153
154
|
LibPixiInput: typeof LibPixiInput;
|
|
154
155
|
/** @description 线性排列 */
|
|
155
156
|
LibPixiArrangeLinearV2: typeof LibPixiArrangeLinearV2;
|
|
157
|
+
/** @description 文本组换行 */
|
|
158
|
+
LibPixiTextGroupWrap: typeof LibPixiTextGroupWrap;
|
|
156
159
|
};
|
|
157
160
|
};
|
|
158
161
|
/** @description 方法 */
|
package/libPixiJs.js
CHANGED
|
@@ -55,6 +55,7 @@ import { LibPixiInput } from "./Components/Custom/LibPixiInput";
|
|
|
55
55
|
import { LibPixiGridLayoutV2 } from "./Utils/LibPixiGridLayoutV2";
|
|
56
56
|
import { LibPixiTicker } from "./Utils/LibPixiTicker";
|
|
57
57
|
import { LibPixiArrangeLinearV2 } from "./Components/Custom/LibPixiArrangeLinearV2";
|
|
58
|
+
import { LibPixiTextGroupWrap } from "./Components/Custom/LibPixiTextGroupWrap";
|
|
58
59
|
/** @description 组件 */
|
|
59
60
|
export const Components = {
|
|
60
61
|
Base: {
|
|
@@ -172,6 +173,8 @@ export const Components = {
|
|
|
172
173
|
LibPixiInput,
|
|
173
174
|
/** @description 线性排列 */
|
|
174
175
|
LibPixiArrangeLinearV2,
|
|
176
|
+
/** @description 文本组换行 */
|
|
177
|
+
LibPixiTextGroupWrap,
|
|
175
178
|
},
|
|
176
179
|
};
|
|
177
180
|
/** @description 方法 */
|
package/lyb-pixi.js
CHANGED
|
@@ -49183,7 +49183,8 @@ void main(void)\r
|
|
|
49183
49183
|
class LibPixiProgress extends Container {
|
|
49184
49184
|
constructor(params) {
|
|
49185
49185
|
super();
|
|
49186
|
-
const { bgWidth, bgHeight, barWidth, barHeight, bgTexture, barTexture } = params;
|
|
49186
|
+
const { bgWidth, bgHeight, barWidth, barHeight, bgTexture, barTexture, direction } = params;
|
|
49187
|
+
this._direction = direction || "h";
|
|
49187
49188
|
const background = new Sprite(bgTexture);
|
|
49188
49189
|
this.addChild(background);
|
|
49189
49190
|
this._progressBar = new Sprite(barTexture);
|
|
@@ -49192,7 +49193,11 @@ void main(void)\r
|
|
|
49192
49193
|
this._progressBar.y = (bgHeight - barHeight) / 2;
|
|
49193
49194
|
const mask = new Graphics();
|
|
49194
49195
|
mask.beginFill(16777215);
|
|
49195
|
-
|
|
49196
|
+
if (direction === "h") {
|
|
49197
|
+
mask.drawRect(0, 0, 0, this._progressBar.height);
|
|
49198
|
+
} else {
|
|
49199
|
+
mask.drawRect(0, 0, this._progressBar.width, 0);
|
|
49200
|
+
}
|
|
49196
49201
|
mask.endFill();
|
|
49197
49202
|
this._progressBar.addChild(mask);
|
|
49198
49203
|
this._progressBar.mask = mask;
|
|
@@ -49205,12 +49210,16 @@ void main(void)\r
|
|
|
49205
49210
|
const clampedProgress = Math.max(0, Math.min(1, progress));
|
|
49206
49211
|
this._maskGraphics.clear();
|
|
49207
49212
|
this._maskGraphics.beginFill(16777215);
|
|
49208
|
-
this.
|
|
49209
|
-
0,
|
|
49210
|
-
|
|
49211
|
-
this.
|
|
49212
|
-
|
|
49213
|
-
|
|
49213
|
+
if (this._direction === "h") {
|
|
49214
|
+
this._maskGraphics.drawRect(0, 0, this._progressBar.width * clampedProgress, this._progressBar.height);
|
|
49215
|
+
} else {
|
|
49216
|
+
this._maskGraphics.drawRect(
|
|
49217
|
+
0,
|
|
49218
|
+
this._progressBar.height * (1 - clampedProgress),
|
|
49219
|
+
this._progressBar.width,
|
|
49220
|
+
this._progressBar.height * clampedProgress
|
|
49221
|
+
);
|
|
49222
|
+
}
|
|
49214
49223
|
this._maskGraphics.endFill();
|
|
49215
49224
|
}
|
|
49216
49225
|
}
|
|
@@ -57787,10 +57796,10 @@ void main(void){
|
|
|
57787
57796
|
return Number(result.toFixed(point, Decimal.ROUND_DOWN));
|
|
57788
57797
|
};
|
|
57789
57798
|
class LibPixiPuzzleBg extends Container {
|
|
57790
|
-
constructor() {
|
|
57799
|
+
constructor(texture) {
|
|
57791
57800
|
super();
|
|
57792
57801
|
this.eventMode = "none";
|
|
57793
|
-
const bg = new Sprite(
|
|
57802
|
+
const bg = new Sprite(texture);
|
|
57794
57803
|
this.addChild(bg);
|
|
57795
57804
|
bg.visible = false;
|
|
57796
57805
|
const config2 = JSON.parse(localStorage.getItem("puzzle_bg_config") || "{}");
|
|
@@ -57815,10 +57824,7 @@ void main(void){
|
|
|
57815
57824
|
} else if (e2.code === "NumpadSubtract" && bg.alpha > 0) {
|
|
57816
57825
|
bg.alpha = libJsDecimal(bg.alpha, 0.1, "-");
|
|
57817
57826
|
}
|
|
57818
|
-
localStorage.setItem(
|
|
57819
|
-
"puzzle_bg_config",
|
|
57820
|
-
JSON.stringify({ alpha: bg.alpha, x: bg.x, y: bg.y })
|
|
57821
|
-
);
|
|
57827
|
+
localStorage.setItem("puzzle_bg_config", JSON.stringify({ alpha: bg.alpha, x: bg.x, y: bg.y }));
|
|
57822
57828
|
});
|
|
57823
57829
|
}
|
|
57824
57830
|
}
|
|
@@ -58449,7 +58455,13 @@ void main(void){
|
|
|
58449
58455
|
}
|
|
58450
58456
|
/** @description 布局 */
|
|
58451
58457
|
layout() {
|
|
58452
|
-
const {
|
|
58458
|
+
const {
|
|
58459
|
+
colNum = this._elementList.length,
|
|
58460
|
+
gap = 10,
|
|
58461
|
+
direction = "x",
|
|
58462
|
+
anchorX = 0,
|
|
58463
|
+
anchorY = 0
|
|
58464
|
+
} = this._params;
|
|
58453
58465
|
let lastRowMax = 0;
|
|
58454
58466
|
let rowOffset = 0;
|
|
58455
58467
|
this._elementList.forEach((item, index) => {
|
|
@@ -58475,6 +58487,11 @@ void main(void){
|
|
|
58475
58487
|
lastRowMax = Math.max(lastRowMax, item.width);
|
|
58476
58488
|
}
|
|
58477
58489
|
});
|
|
58490
|
+
const bounds = this.getLocalBounds();
|
|
58491
|
+
this.pivot.set(
|
|
58492
|
+
bounds.x + bounds.width * anchorX,
|
|
58493
|
+
bounds.y + bounds.height * anchorY
|
|
58494
|
+
);
|
|
58478
58495
|
}
|
|
58479
58496
|
/** @description 获取列表元素 */
|
|
58480
58497
|
getList() {
|
|
@@ -58488,6 +58505,66 @@ void main(void){
|
|
|
58488
58505
|
this._elementList = [];
|
|
58489
58506
|
}
|
|
58490
58507
|
}
|
|
58508
|
+
class LibPixiTextGroupWrap extends Container {
|
|
58509
|
+
constructor({
|
|
58510
|
+
items,
|
|
58511
|
+
defaultStyle = {},
|
|
58512
|
+
wordWrapWidth,
|
|
58513
|
+
paddingX = 0,
|
|
58514
|
+
paddingY = 0,
|
|
58515
|
+
align = "left",
|
|
58516
|
+
anchorX = 0,
|
|
58517
|
+
anchorY = 0
|
|
58518
|
+
}) {
|
|
58519
|
+
super();
|
|
58520
|
+
if (!items.length)
|
|
58521
|
+
return;
|
|
58522
|
+
const lineGroups = [];
|
|
58523
|
+
let currentLine = [];
|
|
58524
|
+
let x2 = 0;
|
|
58525
|
+
for (const { text, style = {} } of items) {
|
|
58526
|
+
const instance2 = new Text(text, { ...defaultStyle, ...style });
|
|
58527
|
+
const w2 = instance2.width;
|
|
58528
|
+
if (wordWrapWidth && x2 + w2 > wordWrapWidth && x2 > 0) {
|
|
58529
|
+
lineGroups.push(currentLine);
|
|
58530
|
+
currentLine = [];
|
|
58531
|
+
x2 = 0;
|
|
58532
|
+
}
|
|
58533
|
+
currentLine.push(instance2);
|
|
58534
|
+
x2 += w2 + paddingX;
|
|
58535
|
+
}
|
|
58536
|
+
if (currentLine.length)
|
|
58537
|
+
lineGroups.push(currentLine);
|
|
58538
|
+
let y2 = 0;
|
|
58539
|
+
for (const line of lineGroups) {
|
|
58540
|
+
const totalWidth = line.reduce(
|
|
58541
|
+
(sum2, i2) => sum2 + i2.width + paddingX,
|
|
58542
|
+
-paddingX
|
|
58543
|
+
);
|
|
58544
|
+
let offsetX = 0;
|
|
58545
|
+
if (align === "center" && wordWrapWidth)
|
|
58546
|
+
offsetX = (wordWrapWidth - totalWidth) / 2;
|
|
58547
|
+
else if (align === "right" && wordWrapWidth)
|
|
58548
|
+
offsetX = wordWrapWidth - totalWidth;
|
|
58549
|
+
let currentX = offsetX;
|
|
58550
|
+
let maxHeight = 0;
|
|
58551
|
+
for (const item of line) {
|
|
58552
|
+
item.x = currentX;
|
|
58553
|
+
item.y = y2;
|
|
58554
|
+
this.addChild(item);
|
|
58555
|
+
currentX += item.width + paddingX;
|
|
58556
|
+
if (item.height > maxHeight)
|
|
58557
|
+
maxHeight = item.height;
|
|
58558
|
+
}
|
|
58559
|
+
y2 += maxHeight + paddingY;
|
|
58560
|
+
}
|
|
58561
|
+
const bounds = this.getLocalBounds();
|
|
58562
|
+
this.pivot.set(
|
|
58563
|
+
bounds.x + bounds.width * anchorX,
|
|
58564
|
+
bounds.y + bounds.height * anchorY
|
|
58565
|
+
);
|
|
58566
|
+
}
|
|
58567
|
+
}
|
|
58491
58568
|
const Components = {
|
|
58492
58569
|
Base: {
|
|
58493
58570
|
/** (已废弃)
|
|
@@ -58603,7 +58680,9 @@ void main(void){
|
|
|
58603
58680
|
/** @description 输入框 */
|
|
58604
58681
|
LibPixiInput,
|
|
58605
58682
|
/** @description 线性排列 */
|
|
58606
|
-
LibPixiArrangeLinearV2
|
|
58683
|
+
LibPixiArrangeLinearV2,
|
|
58684
|
+
/** @description 文本组换行 */
|
|
58685
|
+
LibPixiTextGroupWrap
|
|
58607
58686
|
}
|
|
58608
58687
|
};
|
|
58609
58688
|
const Utils = {
|