@zhongguo168a/yxeditor-common 0.0.75 → 0.0.77

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, ISchedulable, AssetManager, Asset, SpriteAtlas, Camera, Canvas, Vec2, Vec3, Vec4, Widget, UITransform, math } from 'cc';
1
+ import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, ISchedulable, AssetManager, Asset, Vec2, Texture2D, SpriteAtlas, Camera, Canvas, Vec3, Vec4, Widget, UITransform, math } from 'cc';
2
2
 
3
3
  interface IError {
4
4
  isCancel(): boolean;
@@ -692,6 +692,7 @@ declare class ListSource extends EventDispatcher {
692
692
  refresh(node: ListNode): void;
693
693
  walk(f: (node: ListNode) => boolean): boolean;
694
694
  walkPrev(node: ListNode, f: (node: ListNode) => boolean): boolean;
695
+ resetData(data: []): void;
695
696
  get data(): any[];
696
697
  private _data;
697
698
  }
@@ -770,7 +771,7 @@ declare class Dictionary<K = string, V = any> {
770
771
  [key: string]: any;
771
772
  };
772
773
  protected size: number;
773
- private _data;
774
+ protected _data: any;
774
775
  private _onSet;
775
776
  private _onDelete;
776
777
  private _onSetCaller;
@@ -1532,7 +1533,25 @@ declare class AssetLoader extends Dispatcher {
1532
1533
  protected _failList: List<LoaderItem>;
1533
1534
  }
1534
1535
 
1535
- declare function parseAtlas(name: any, plist: any, texture: any): SpriteAtlas;
1536
+ /**
1537
+ * 自动生成等距图集的frame描述表。
1538
+ * 用于减少创建atlas文件的过程。
1539
+ *
1540
+ * @param atlasSize 图集的像素尺寸
1541
+ * @param gridSize 每格的像素尺寸
1542
+ * @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
1543
+ * @param maxCount 可选,限制生成数量
1544
+ * @returns atlas数据对象
1545
+ */
1546
+ declare function create等距图集(atlasSize: Vec2, gridSize: Vec2, keyFormat?: string, maxCount?: number): Record<string, any>;
1547
+ /**
1548
+ *
1549
+ * @param name 图集的名称
1550
+ * @param plist plist格式的json文件内容
1551
+ * @param texture
1552
+ * @returns
1553
+ */
1554
+ declare function parseAtlas(plist: any, texture: Texture2D): SpriteAtlas;
1536
1555
 
1537
1556
  declare enum LogLevel {
1538
1557
  DEBUG = 0,
@@ -2072,5 +2091,5 @@ declare class WidgetUtil {
2072
2091
  }
2073
2092
  declare var widgetutil: WidgetUtil;
2074
2093
 
2075
- export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, 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, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, 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, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
2094
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, 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, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, create等距图集, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
2076
2095
  export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
package/dist/index.esm.js CHANGED
@@ -2736,6 +2736,9 @@ class ListSource extends EventDispatcher {
2736
2736
  }
2737
2737
  }
2738
2738
  }
2739
+ resetData(data) {
2740
+ this._data = [];
2741
+ }
2739
2742
  get data() {
2740
2743
  return this._data;
2741
2744
  }
@@ -4472,11 +4475,57 @@ class SampleCallbackList {
4472
4475
  }
4473
4476
  }
4474
4477
 
4475
- function parseAtlas(name, plist, texture) {
4478
+ /**
4479
+ * 自动生成等距图集的frame描述表。
4480
+ * 用于减少创建atlas文件的过程。
4481
+ *
4482
+ * @param atlasSize 图集的像素尺寸
4483
+ * @param gridSize 每格的像素尺寸
4484
+ * @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
4485
+ * @param maxCount 可选,限制生成数量
4486
+ * @returns atlas数据对象
4487
+ */
4488
+ function create等距图集(atlasSize, gridSize, keyFormat = "%d.png", maxCount) {
4489
+ const cols = Math.floor(atlasSize.x / gridSize.x);
4490
+ const rows = Math.floor(atlasSize.y / gridSize.y);
4491
+ const total = maxCount !== null && maxCount !== void 0 ? maxCount : cols * rows;
4492
+ const frames = {};
4493
+ let index = 0;
4494
+ for (let y = 0; y < rows; y++) {
4495
+ for (let x = 0; x < cols; x++) {
4496
+ if (index >= total)
4497
+ break;
4498
+ const key = keyFormat.replace("%d", (index + 1).toString());
4499
+ const frame = {
4500
+ frame: {
4501
+ x: x * gridSize.x,
4502
+ y: y * gridSize.y,
4503
+ w: gridSize.x,
4504
+ h: gridSize.y
4505
+ },
4506
+ rotated: false,
4507
+ trimmed: false,
4508
+ sourceSize: { w: gridSize.x, h: gridSize.y },
4509
+ spriteSourceSize: { x: 0, y: 0, w: gridSize.x, h: gridSize.y }
4510
+ };
4511
+ frames[key] = frame;
4512
+ index++;
4513
+ }
4514
+ }
4515
+ return frames;
4516
+ }
4517
+ /**
4518
+ *
4519
+ * @param name 图集的名称
4520
+ * @param plist plist格式的json文件内容
4521
+ * @param texture
4522
+ * @returns
4523
+ */
4524
+ function parseAtlas(plist, texture) {
4476
4525
  plist.meta;
4477
4526
  let frames = plist.frames;
4478
4527
  let atlas = new SpriteAtlas();
4479
- atlas.name = name;
4528
+ atlas.name = texture.name;
4480
4529
  atlas._nativeAsset = plist;
4481
4530
  let spriteFrames = atlas.spriteFrames;
4482
4531
  // 1/1_1_0.png:{
@@ -4887,7 +4936,8 @@ class AssetLoader extends Dispatcher {
4887
4936
  let tex = new Texture2D();
4888
4937
  tex.image = asset;
4889
4938
  tex.setFilters(1, 1);
4890
- let atlasSprite = parseAtlas(item.uri, content, tex);
4939
+ let atlasSprite = parseAtlas(content, tex);
4940
+ atlasSprite.name = item.uri.name;
4891
4941
  let uuid = atlasAsset.uuid;
4892
4942
  assetManager.assets.remove(uuid);
4893
4943
  assetManager.assets.add(uuid, atlasSprite);
@@ -6453,5 +6503,5 @@ class WidgetUtil {
6453
6503
  }
6454
6504
  var widgetutil = new WidgetUtil();
6455
6505
 
6456
- export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, 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, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, 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, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
6506
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, 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, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, create等距图集, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
6457
6507
  //# sourceMappingURL=index.esm.js.map