@zhongguo168a/yxeditor-common 0.0.132 → 0.0.139
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/dist/index.d.ts +5 -23
- package/dist/index.esm.js +68 -103
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as cc from 'cc';
|
|
2
|
-
import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, AssetManager, Asset,
|
|
2
|
+
import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, AssetManager, Asset, Camera, Canvas, Vec2, Vec3, Vec4, SpriteAtlas, Widget, UITransform, math } from 'cc';
|
|
3
3
|
|
|
4
4
|
interface IError {
|
|
5
5
|
isCancel(): boolean;
|
|
@@ -707,8 +707,10 @@ declare class ListSource extends EventDispatcher {
|
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
declare class DictIterator {
|
|
710
|
-
break(): void;
|
|
710
|
+
break(reason?: any): void;
|
|
711
711
|
isBreak(): boolean;
|
|
712
|
+
getReason(): any;
|
|
713
|
+
protected _reason: any;
|
|
712
714
|
protected _isBreak: any;
|
|
713
715
|
}
|
|
714
716
|
declare class Dictionary<K = string, V = any> {
|
|
@@ -1645,26 +1647,6 @@ declare class AssetLoader extends Dispatcher {
|
|
|
1645
1647
|
protected _failList: List<LoaderItem>;
|
|
1646
1648
|
}
|
|
1647
1649
|
|
|
1648
|
-
/**
|
|
1649
|
-
* 自动生成等距图集的frame描述表。
|
|
1650
|
-
* 用于减少创建atlas文件的过程。
|
|
1651
|
-
*
|
|
1652
|
-
* @param atlasSize 图集的像素尺寸
|
|
1653
|
-
* @param gridSize 每格的像素尺寸
|
|
1654
|
-
* @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
|
|
1655
|
-
* @param maxCount 可选,限制生成数量
|
|
1656
|
-
* @returns atlas数据对象
|
|
1657
|
-
*/
|
|
1658
|
-
declare function create等距图集(atlasSize: Vec2, gridSize: Vec2, keyFormat?: string, maxCount?: number): Record<string, any>;
|
|
1659
|
-
/**
|
|
1660
|
-
*
|
|
1661
|
-
* @param name 图集的名称
|
|
1662
|
-
* @param plist plist格式的json文件内容
|
|
1663
|
-
* @param texture
|
|
1664
|
-
* @returns
|
|
1665
|
-
*/
|
|
1666
|
-
declare function parseAtlas(plist: any, texture: Texture2D): SpriteAtlas;
|
|
1667
|
-
|
|
1668
1650
|
declare enum LogLevel {
|
|
1669
1651
|
DEBUG = 0,
|
|
1670
1652
|
INFO = 1,
|
|
@@ -2213,5 +2195,5 @@ declare class WidgetUtil {
|
|
|
2213
2195
|
}
|
|
2214
2196
|
declare var widgetutil: WidgetUtil;
|
|
2215
2197
|
|
|
2216
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewModel, ViewModelComponent, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil,
|
|
2198
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewModel, ViewModelComponent, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parsePlist, pathutil, randutil, resutil, routeViews, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, widgetutil };
|
|
2217
2199
|
export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HorizontalTextAlignment, VerticalTextAlignment, director, macro, Scheduler, math, instantiate, _decorator, Component, SpriteAtlas, Size, Vec2, Rect, SpriteFrame, path,
|
|
1
|
+
import { HorizontalTextAlignment, VerticalTextAlignment, director, macro, Scheduler, math, instantiate, _decorator, Component, assetManager, SpriteAtlas, Size, Vec2, Rect, SpriteFrame, path, Texture2D, ImageAsset, JsonAsset, TextAsset, Asset, find, Canvas, Node, Vec3, Vec4, resources, UITransform, Widget } from 'cc';
|
|
2
2
|
|
|
3
3
|
class NetUtil {
|
|
4
4
|
// 获取URL的参数对象
|
|
@@ -2825,12 +2825,16 @@ ListSource.EVENT_DATA_SET = "data_set";
|
|
|
2825
2825
|
ListSource.EVENT_TAGS_SET = "tags_set";
|
|
2826
2826
|
|
|
2827
2827
|
class DictIterator {
|
|
2828
|
-
break() {
|
|
2828
|
+
break(reason) {
|
|
2829
2829
|
this._isBreak = true;
|
|
2830
|
+
this._reason = reason;
|
|
2830
2831
|
}
|
|
2831
2832
|
isBreak() {
|
|
2832
2833
|
return this._isBreak;
|
|
2833
2834
|
}
|
|
2835
|
+
getReason() {
|
|
2836
|
+
return this._reason;
|
|
2837
|
+
}
|
|
2834
2838
|
}
|
|
2835
2839
|
class Dictionary {
|
|
2836
2840
|
constructor(data) {
|
|
@@ -4864,106 +4868,6 @@ class SampleCallbackList {
|
|
|
4864
4868
|
}
|
|
4865
4869
|
}
|
|
4866
4870
|
|
|
4867
|
-
/**
|
|
4868
|
-
* 自动生成等距图集的frame描述表。
|
|
4869
|
-
* 用于减少创建atlas文件的过程。
|
|
4870
|
-
*
|
|
4871
|
-
* @param atlasSize 图集的像素尺寸
|
|
4872
|
-
* @param gridSize 每格的像素尺寸
|
|
4873
|
-
* @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
|
|
4874
|
-
* @param maxCount 可选,限制生成数量
|
|
4875
|
-
* @returns atlas数据对象
|
|
4876
|
-
*/
|
|
4877
|
-
function create等距图集(atlasSize, gridSize, keyFormat = "%d.png", maxCount) {
|
|
4878
|
-
const cols = Math.floor(atlasSize.x / gridSize.x);
|
|
4879
|
-
const rows = Math.floor(atlasSize.y / gridSize.y);
|
|
4880
|
-
const total = maxCount !== null && maxCount !== void 0 ? maxCount : cols * rows;
|
|
4881
|
-
const frames = {};
|
|
4882
|
-
let index = 0;
|
|
4883
|
-
for (let y = 0; y < rows; y++) {
|
|
4884
|
-
for (let x = 0; x < cols; x++) {
|
|
4885
|
-
if (index >= total)
|
|
4886
|
-
break;
|
|
4887
|
-
const key = keyFormat.replace("%d", (index + 1).toString());
|
|
4888
|
-
const frame = {
|
|
4889
|
-
frame: {
|
|
4890
|
-
x: x * gridSize.x,
|
|
4891
|
-
y: y * gridSize.y,
|
|
4892
|
-
w: gridSize.x,
|
|
4893
|
-
h: gridSize.y
|
|
4894
|
-
},
|
|
4895
|
-
rotated: false,
|
|
4896
|
-
trimmed: false,
|
|
4897
|
-
sourceSize: { w: gridSize.x, h: gridSize.y },
|
|
4898
|
-
spriteSourceSize: { x: 0, y: 0, w: gridSize.x, h: gridSize.y }
|
|
4899
|
-
};
|
|
4900
|
-
frames[key] = frame;
|
|
4901
|
-
index++;
|
|
4902
|
-
}
|
|
4903
|
-
}
|
|
4904
|
-
return frames;
|
|
4905
|
-
}
|
|
4906
|
-
/**
|
|
4907
|
-
*
|
|
4908
|
-
* @param name 图集的名称
|
|
4909
|
-
* @param plist plist格式的json文件内容
|
|
4910
|
-
* @param texture
|
|
4911
|
-
* @returns
|
|
4912
|
-
*/
|
|
4913
|
-
function parseAtlas(plist, texture) {
|
|
4914
|
-
plist.meta;
|
|
4915
|
-
let frames = plist.frames;
|
|
4916
|
-
let atlas = new SpriteAtlas();
|
|
4917
|
-
atlas.name = texture.name;
|
|
4918
|
-
atlas._nativeAsset = plist;
|
|
4919
|
-
let spriteFrames = atlas.spriteFrames;
|
|
4920
|
-
// 1/1_1_0.png:{
|
|
4921
|
-
// frame: {x: 137, y: 302, w: 18, h: 24}
|
|
4922
|
-
// rotated: false
|
|
4923
|
-
// sourceSize: {w: 32, h: 32}
|
|
4924
|
-
// spriteSourceSize: {x: 7, y: 0, w: 18, h: 24}
|
|
4925
|
-
// trimmed: true
|
|
4926
|
-
// }
|
|
4927
|
-
let maxWidth = 0;
|
|
4928
|
-
let maxHeight = 0;
|
|
4929
|
-
for (let key in frames) {
|
|
4930
|
-
let frame = frames[key];
|
|
4931
|
-
let rotated = false, sourceSize, offset, textureRect;
|
|
4932
|
-
rotated = frame.rotated;
|
|
4933
|
-
{
|
|
4934
|
-
let size = frame.sourceSize;
|
|
4935
|
-
sourceSize = new Size(size.w, size.h);
|
|
4936
|
-
maxWidth = Math.max(maxWidth, size.w);
|
|
4937
|
-
maxHeight = Math.max(maxHeight, size.h);
|
|
4938
|
-
}
|
|
4939
|
-
{ // 需要转化成以sourceSize的中心点为原点,cocos坐标系的偏移量
|
|
4940
|
-
let pos = frame.spriteSourceSize;
|
|
4941
|
-
offset = new Vec2(pos.x + pos.w * 0.5, pos.y + pos.h * 0.5);
|
|
4942
|
-
offset.x -= sourceSize.width * 0.5;
|
|
4943
|
-
offset.y -= sourceSize.height * 0.5;
|
|
4944
|
-
offset.y = -offset.y; // y轴相反
|
|
4945
|
-
}
|
|
4946
|
-
{
|
|
4947
|
-
let rect = frame.frame;
|
|
4948
|
-
textureRect = new Rect(rect.x, rect.y, rect.w, rect.h);
|
|
4949
|
-
}
|
|
4950
|
-
var sprite = new SpriteFrame();
|
|
4951
|
-
sprite.name = key;
|
|
4952
|
-
sprite.reset({
|
|
4953
|
-
originalSize: sourceSize,
|
|
4954
|
-
rect: textureRect,
|
|
4955
|
-
offset: offset,
|
|
4956
|
-
isRotate: !!rotated,
|
|
4957
|
-
texture: texture
|
|
4958
|
-
});
|
|
4959
|
-
let name = path.mainFileName(key);
|
|
4960
|
-
spriteFrames[name] = sprite;
|
|
4961
|
-
}
|
|
4962
|
-
//
|
|
4963
|
-
plist.meta.maxSize = { w: maxWidth, h: maxHeight };
|
|
4964
|
-
return atlas;
|
|
4965
|
-
}
|
|
4966
|
-
|
|
4967
4871
|
class AssetURI {
|
|
4968
4872
|
/**
|
|
4969
4873
|
*
|
|
@@ -5033,6 +4937,67 @@ class XAssetManager {
|
|
|
5033
4937
|
}
|
|
5034
4938
|
let assetx = new XAssetManager();
|
|
5035
4939
|
|
|
4940
|
+
/**
|
|
4941
|
+
*
|
|
4942
|
+
* @param name 图集的名称
|
|
4943
|
+
* @param plist plist格式的json文件内容
|
|
4944
|
+
* @param texture
|
|
4945
|
+
* @returns
|
|
4946
|
+
*/
|
|
4947
|
+
function parseAtlas(plist, texture) {
|
|
4948
|
+
plist.meta;
|
|
4949
|
+
let frames = plist.frames;
|
|
4950
|
+
let atlas = new SpriteAtlas();
|
|
4951
|
+
atlas.name = texture.name;
|
|
4952
|
+
atlas._nativeAsset = plist;
|
|
4953
|
+
let spriteFrames = atlas.spriteFrames;
|
|
4954
|
+
// 1/1_1_0.png:{
|
|
4955
|
+
// frame: {x: 137, y: 302, w: 18, h: 24}
|
|
4956
|
+
// rotated: false
|
|
4957
|
+
// sourceSize: {w: 32, h: 32}
|
|
4958
|
+
// spriteSourceSize: {x: 7, y: 0, w: 18, h: 24}
|
|
4959
|
+
// trimmed: true
|
|
4960
|
+
// }
|
|
4961
|
+
let maxWidth = 0;
|
|
4962
|
+
let maxHeight = 0;
|
|
4963
|
+
for (let key in frames) {
|
|
4964
|
+
let frame = frames[key];
|
|
4965
|
+
let rotated = false, sourceSize, offset, textureRect;
|
|
4966
|
+
rotated = frame.rotated;
|
|
4967
|
+
{
|
|
4968
|
+
let size = frame.sourceSize;
|
|
4969
|
+
sourceSize = new Size(size.w, size.h);
|
|
4970
|
+
maxWidth = Math.max(maxWidth, size.w);
|
|
4971
|
+
maxHeight = Math.max(maxHeight, size.h);
|
|
4972
|
+
}
|
|
4973
|
+
{ // 需要转化成以sourceSize的中心点为原点,cocos坐标系的偏移量
|
|
4974
|
+
let pos = frame.spriteSourceSize;
|
|
4975
|
+
offset = new Vec2(pos.x + pos.w * 0.5, pos.y + pos.h * 0.5);
|
|
4976
|
+
offset.x -= sourceSize.width * 0.5;
|
|
4977
|
+
offset.y -= sourceSize.height * 0.5;
|
|
4978
|
+
offset.y = -offset.y; // y轴相反
|
|
4979
|
+
}
|
|
4980
|
+
{
|
|
4981
|
+
let rect = frame.frame;
|
|
4982
|
+
textureRect = new Rect(rect.x, rect.y, rect.w, rect.h);
|
|
4983
|
+
}
|
|
4984
|
+
var sprite = new SpriteFrame();
|
|
4985
|
+
sprite.name = key;
|
|
4986
|
+
sprite.reset({
|
|
4987
|
+
originalSize: sourceSize,
|
|
4988
|
+
rect: textureRect,
|
|
4989
|
+
offset: offset,
|
|
4990
|
+
isRotate: !!rotated,
|
|
4991
|
+
texture: texture
|
|
4992
|
+
});
|
|
4993
|
+
let name = path.mainFileName(key);
|
|
4994
|
+
spriteFrames[name] = sprite;
|
|
4995
|
+
}
|
|
4996
|
+
//
|
|
4997
|
+
plist.meta.maxSize = { w: maxWidth, h: maxHeight };
|
|
4998
|
+
return atlas;
|
|
4999
|
+
}
|
|
5000
|
+
|
|
5036
5001
|
class LoaderItem {
|
|
5037
5002
|
constructor() {
|
|
5038
5003
|
this.preload = false;
|
|
@@ -7005,5 +6970,5 @@ class WidgetUtil {
|
|
|
7005
6970
|
}
|
|
7006
6971
|
var widgetutil = new WidgetUtil();
|
|
7007
6972
|
|
|
7008
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewModel, ViewModelComponent, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil,
|
|
6973
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewModel, ViewModelComponent, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parsePlist, pathutil, randutil, resutil, routeViews, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, widgetutil };
|
|
7009
6974
|
//# sourceMappingURL=index.esm.js.map
|