@zhongguo168a/yxeditor-common 0.0.74 → 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;
@@ -1134,23 +1134,6 @@ declare class MapUtil {
1134
1134
  }
1135
1135
  declare const maputil: MapUtil;
1136
1136
 
1137
- interface CommandInfo {
1138
- /**
1139
- * 默认的
1140
- */
1141
- caller?: any;
1142
- name: string;
1143
- handler: Function;
1144
- group?: string;
1145
- global: boolean;
1146
- }
1147
- declare class CommandManager extends EventDispatcher {
1148
- protected _infos: any[];
1149
- register(info: CommandInfo): void;
1150
- execute(name: string, ...args: any): any;
1151
- removeGroup(group: string): void;
1152
- }
1153
-
1154
1137
  declare enum ViewState {
1155
1138
  /**
1156
1139
  * 关闭
@@ -1216,7 +1199,6 @@ declare class RouteView extends EventDispatcher {
1216
1199
  */
1217
1200
  onStop(value: (ctx: this) => void): this;
1218
1201
  get reason(): LinkError;
1219
- get cmdmgr(): CommandManager;
1220
1202
  node: Node;
1221
1203
  datas: MapObject;
1222
1204
  tags: MapObject;
@@ -1226,7 +1208,6 @@ declare class RouteView extends EventDispatcher {
1226
1208
  protected _controller: RouteController;
1227
1209
  protected _route: Route;
1228
1210
  protected _reason: LinkError;
1229
- protected _cmdmgr: CommandManager;
1230
1211
  private _onOpen;
1231
1212
  private _onOpened;
1232
1213
  private _onClose;
@@ -1551,7 +1532,25 @@ declare class AssetLoader extends Dispatcher {
1551
1532
  protected _failList: List<LoaderItem>;
1552
1533
  }
1553
1534
 
1554
- 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;
1555
1554
 
1556
1555
  declare enum LogLevel {
1557
1556
  DEBUG = 0,
@@ -2091,5 +2090,5 @@ declare class WidgetUtil {
2091
2090
  }
2092
2091
  declare var widgetutil: WidgetUtil;
2093
2092
 
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, 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 };
2095
2094
  export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
package/dist/index.esm.js CHANGED
@@ -3892,39 +3892,6 @@ class ViewRepo extends ViewDict {
3892
3892
  }
3893
3893
  const viewrepo = new ViewRepo();
3894
3894
 
3895
- class CommandManager extends EventDispatcher {
3896
- constructor() {
3897
- super(...arguments);
3898
- this._infos = [];
3899
- }
3900
- register(info) {
3901
- this._infos[info.name] = info;
3902
- if (info.global) {
3903
- window[info.name] = info.handler;
3904
- }
3905
- }
3906
- execute(name, ...args) {
3907
- let info = this._infos[name];
3908
- if (!info) {
3909
- return;
3910
- }
3911
- let caller;
3912
- if (!caller) {
3913
- caller = info.caller;
3914
- }
3915
- return info.handler.call(caller, ...args);
3916
- }
3917
- removeGroup(group) {
3918
- for (let key in this._infos) {
3919
- let info = this._infos[key];
3920
- if (info.group == group) {
3921
- delete this._infos[key];
3922
- }
3923
- }
3924
- }
3925
- }
3926
- new CommandManager();
3927
-
3928
3895
  var ViewState;
3929
3896
  (function (ViewState) {
3930
3897
  /**
@@ -3966,7 +3933,6 @@ class RouteView extends EventDispatcher {
3966
3933
  this.tags = new MapObject({});
3967
3934
  this.enableHistory = false;
3968
3935
  this.state = 0;
3969
- this._cmdmgr = new CommandManager();
3970
3936
  this._onStop = (ctx) => {
3971
3937
  ctx.close();
3972
3938
  };
@@ -4173,9 +4139,6 @@ class RouteView extends EventDispatcher {
4173
4139
  get reason() {
4174
4140
  return this._reason;
4175
4141
  }
4176
- get cmdmgr() {
4177
- return this._cmdmgr;
4178
- }
4179
4142
  }
4180
4143
 
4181
4144
  class ViewHistory extends RouteList {
@@ -4509,11 +4472,57 @@ class SampleCallbackList {
4509
4472
  }
4510
4473
  }
4511
4474
 
4512
- 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) {
4513
4522
  plist.meta;
4514
4523
  let frames = plist.frames;
4515
4524
  let atlas = new SpriteAtlas();
4516
- atlas.name = name;
4525
+ atlas.name = texture.name;
4517
4526
  atlas._nativeAsset = plist;
4518
4527
  let spriteFrames = atlas.spriteFrames;
4519
4528
  // 1/1_1_0.png:{
@@ -4924,7 +4933,8 @@ class AssetLoader extends Dispatcher {
4924
4933
  let tex = new Texture2D();
4925
4934
  tex.image = asset;
4926
4935
  tex.setFilters(1, 1);
4927
- let atlasSprite = parseAtlas(item.uri, content, tex);
4936
+ let atlasSprite = parseAtlas(content, tex);
4937
+ atlasSprite.name = item.uri.name;
4928
4938
  let uuid = atlasAsset.uuid;
4929
4939
  assetManager.assets.remove(uuid);
4930
4940
  assetManager.assets.add(uuid, atlasSprite);
@@ -6490,5 +6500,5 @@ class WidgetUtil {
6490
6500
  }
6491
6501
  var widgetutil = new WidgetUtil();
6492
6502
 
6493
- 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 };
6494
6504
  //# sourceMappingURL=index.esm.js.map