1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- e =
- (this && this.__decorate) ||
- function(t, e, i, s) {
- var o,
- a = arguments.length,
- n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
- else
- for (var r = t.length - 1; 0 <= r; r--)
- (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
- return 3 < a && n && Object.defineProperty(e, i, n), n;
- };
- Object.defineProperty(i, "__esModule", { value: !0 }), (i.UIImage = void 0);
- const { ccclass: o, property: a, menu: n } = cc._decorator;
- let r = /(\.jpg)$/,
- l = (s = class extends cc.Sprite {
- constructor() {
- super(...arguments), (this._source = null), (this.sourceChanged = !1);
- }
- set source(t) {
- if ("" === t) return (this._source = t), void(this.spriteFrame = null);
- t != this._source &&
- ((this._source = t),
- this.node && this.node.activeInHierarchy ? this.parseSource() : (this.sourceChanged = !0));
- }
- onLoad() {
- this.sourceChanged && this.parseSource();
- }
- onEnable() {
- super.onEnable(), this.sourceChanged && this.parseSource();
- }
- get source() {
- return this._source;
- }
- $setTexture(t) {
- if (t == this.spriteFrame) return !1;
- (this.spriteFrame = t), (this.sourceChanged = !1);
- }
- parseSource() {
- this.sourceChanged = !1;
- let i = this._source;
- if (i && "string" == typeof i) {
- var t = s.cacheList[i] || cc.resources.get(i, cc.SpriteFrame);
- if (t) this.$setTexture(t);
- else if (-1 == i.indexOf("http"))
- cc.resources.load(i, cc.SpriteFrame, (t, e) => {
- i === this._source &&
- (t ? Log.error(`\u56fe\u7247\u4e0d\u5b58\u5728:${i}`, t) : this.$setTexture(e));
- });
- else {
- let t = ".png";
- r.test(i) && (t = ".jpg"),
- cc.assetManager.loadRemote(i, { ext: t }, (t, e) => {
- i === this._source &&
- (t ?
- Log.error(`\u56fe\u7247\u4e0d\u5b58\u5728:${i}`, t) :
- ((s.cacheList[i] = new cc.SpriteFrame(e)), this.$setTexture(s.cacheList[i])));
- });
- }
- } else this.$setTexture(i);
- }
- });
- (l.cacheList = {}),
- e([a({ type: cc.SpriteFrame })], l.prototype, "_source", void 0),
- e([a({ type: cc.SpriteFrame })], l.prototype, "source", null),
- (s = e([o], l)),
- (i.UIImage = s);
|