@zhongguo168a/yxeditor-common 0.0.75 → 0.0.76

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;
@@ -770,7 +770,7 @@ declare class Dictionary<K = string, V = any> {
770
770
  [key: string]: any;
771
771
  };
772
772
  protected size: number;
773
- private _data;
773
+ protected _data: any;
774
774
  private _onSet;
775
775
  private _onDelete;
776
776
  private _onSetCaller;
@@ -1532,7 +1532,25 @@ declare class AssetLoader extends Dispatcher {
1532
1532
  protected _failList: List<LoaderItem>;
1533
1533
  }
1534
1534
 
1535
- declare function parseAtlas(name: any, plist: any, texture: any): SpriteAtlas;
1535
+ /**
1536
+ * 自动生成等距图集的frame描述表。
1537
+ * 用于减少创建atlas文件的过程。
1538
+ *
1539
+ * @param atlasSize 图集的像素尺寸
1540
+ * @param gridSize 每格的像素尺寸
1541
+ * @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
1542
+ * @param maxCount 可选,限制生成数量
1543
+ * @returns atlas数据对象
1544
+ */
1545
+ declare function create等距图集(atlasSize: Vec2, gridSize: Vec2, keyFormat?: string, maxCount?: number): Record<string, any>;
1546
+ /**
1547
+ *
1548
+ * @param name 图集的名称
1549
+ * @param plist plist格式的json文件内容
1550
+ * @param texture
1551
+ * @returns
1552
+ */
1553
+ declare function parseAtlas(plist: any, texture: Texture2D): SpriteAtlas;
1536
1554
 
1537
1555
  declare enum LogLevel {
1538
1556
  DEBUG = 0,
@@ -2072,5 +2090,5 @@ declare class WidgetUtil {
2072
2090
  }
2073
2091
  declare var widgetutil: WidgetUtil;
2074
2092
 
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 };
2093
+ 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
2094
  export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
package/dist/index.esm.js CHANGED
@@ -4472,11 +4472,57 @@ class SampleCallbackList {
4472
4472
  }
4473
4473
  }
4474
4474
 
4475
- function parseAtlas(name, plist, texture) {
4475
+ /**
4476
+ * 自动生成等距图集的frame描述表。
4477
+ * 用于减少创建atlas文件的过程。
4478
+ *
4479
+ * @param atlasSize 图集的像素尺寸
4480
+ * @param gridSize 每格的像素尺寸
4481
+ * @param keyFormat 名称格式化字符串,例如 "%d.png" 或 "tile_%d.png"
4482
+ * @param maxCount 可选,限制生成数量
4483
+ * @returns atlas数据对象
4484
+ */
4485
+ function create等距图集(atlasSize, gridSize, keyFormat = "%d.png", maxCount) {
4486
+ const cols = Math.floor(atlasSize.x / gridSize.x);
4487
+ const rows = Math.floor(atlasSize.y / gridSize.y);
4488
+ const total = maxCount !== null && maxCount !== void 0 ? maxCount : cols * rows;
4489
+ const frames = {};
4490
+ let index = 0;
4491
+ for (let y = 0; y < rows; y++) {
4492
+ for (let x = 0; x < cols; x++) {
4493
+ if (index >= total)
4494
+ break;
4495
+ const key = keyFormat.replace("%d", (index + 1).toString());
4496
+ const frame = {
4497
+ frame: {
4498
+ x: x * gridSize.x,
4499
+ y: y * gridSize.y,
4500
+ w: gridSize.x,
4501
+ h: gridSize.y
4502
+ },
4503
+ rotated: false,
4504
+ trimmed: false,
4505
+ sourceSize: { w: gridSize.x, h: gridSize.y },
4506
+ spriteSourceSize: { x: 0, y: 0, w: gridSize.x, h: gridSize.y }
4507
+ };
4508
+ frames[key] = frame;
4509
+ index++;
4510
+ }
4511
+ }
4512
+ return frames;
4513
+ }
4514
+ /**
4515
+ *
4516
+ * @param name 图集的名称
4517
+ * @param plist plist格式的json文件内容
4518
+ * @param texture
4519
+ * @returns
4520
+ */
4521
+ function parseAtlas(plist, texture) {
4476
4522
  plist.meta;
4477
4523
  let frames = plist.frames;
4478
4524
  let atlas = new SpriteAtlas();
4479
- atlas.name = name;
4525
+ atlas.name = texture.name;
4480
4526
  atlas._nativeAsset = plist;
4481
4527
  let spriteFrames = atlas.spriteFrames;
4482
4528
  // 1/1_1_0.png:{
@@ -4887,7 +4933,8 @@ class AssetLoader extends Dispatcher {
4887
4933
  let tex = new Texture2D();
4888
4934
  tex.image = asset;
4889
4935
  tex.setFilters(1, 1);
4890
- let atlasSprite = parseAtlas(item.uri, content, tex);
4936
+ let atlasSprite = parseAtlas(content, tex);
4937
+ atlasSprite.name = item.uri.name;
4891
4938
  let uuid = atlasAsset.uuid;
4892
4939
  assetManager.assets.remove(uuid);
4893
4940
  assetManager.assets.add(uuid, atlasSprite);
@@ -6453,5 +6500,5 @@ class WidgetUtil {
6453
6500
  }
6454
6501
  var widgetutil = new WidgetUtil();
6455
6502
 
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 };
6503
+ 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
6504
  //# sourceMappingURL=index.esm.js.map