130 lines
5.2 KiB
JavaScript
130 lines
5.2 KiB
JavaScript
System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
|
|
"use strict";
|
|
|
|
var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Button, Component, Sprite, SpriteFrame, AudioMgr, AssetController, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, UISwitcher;
|
|
|
|
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
|
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
|
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
|
|
function _reportPossibleCrUseOfAudioMgr(extras) {
|
|
_reporterNs.report("AudioMgr", "../audio/AudioMgr", _context.meta, extras);
|
|
}
|
|
|
|
function _reportPossibleCrUseOfAssetController(extras) {
|
|
_reporterNs.report("AssetController", "../../AssetController", _context.meta, extras);
|
|
}
|
|
|
|
return {
|
|
setters: [function (_unresolved_) {
|
|
_reporterNs = _unresolved_;
|
|
}, function (_cc) {
|
|
_cclegacy = _cc.cclegacy;
|
|
__checkObsolete__ = _cc.__checkObsolete__;
|
|
__checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
|
|
_decorator = _cc._decorator;
|
|
Button = _cc.Button;
|
|
Component = _cc.Component;
|
|
Sprite = _cc.Sprite;
|
|
SpriteFrame = _cc.SpriteFrame;
|
|
}, function (_unresolved_2) {
|
|
AudioMgr = _unresolved_2.AudioMgr;
|
|
}, function (_unresolved_3) {
|
|
AssetController = _unresolved_3.AssetController;
|
|
}],
|
|
execute: function () {
|
|
_crd = true;
|
|
|
|
_cclegacy._RF.push({}, "0167br+LjpPJInDK327SP0k", "UISwitcher", undefined);
|
|
|
|
__checkObsolete__(['_decorator', 'Button', 'Component', 'Node', 'Sprite', 'SpriteFrame', 'Toggle']);
|
|
|
|
({
|
|
ccclass,
|
|
property
|
|
} = _decorator);
|
|
|
|
_export("UISwitcher", UISwitcher = (_dec = ccclass('UISwitcher'), _dec2 = property({
|
|
type: SpriteFrame
|
|
}), _dec3 = property({
|
|
type: SpriteFrame
|
|
}), _dec(_class = (_class2 = class UISwitcher extends Component {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.toggle = void 0;
|
|
this.value = void 0;
|
|
this.sprite = void 0;
|
|
|
|
_initializerDefineProperty(this, "onSelect", _descriptor, this);
|
|
|
|
_initializerDefineProperty(this, "onNoSelect", _descriptor2, this);
|
|
|
|
this.onSwitchCallBack = void 0;
|
|
}
|
|
|
|
onLoad() {
|
|
this.toggle = this.getComponent(Button);
|
|
this.sprite = this.getComponent(Sprite);
|
|
}
|
|
|
|
start() {
|
|
this.toggle.node.on(Button.EventType.CLICK, this.onClickToggleBtn, this);
|
|
}
|
|
|
|
addCallBack(callBack) {
|
|
this.onSwitchCallBack = callBack;
|
|
}
|
|
|
|
SetValue(v) {
|
|
this.value = v;
|
|
this.switchSprite(this.value);
|
|
}
|
|
|
|
switchSprite(v) {
|
|
if (v) {
|
|
this.sprite.spriteFrame = this.onSelect;
|
|
} else {
|
|
this.sprite.spriteFrame = this.onNoSelect;
|
|
}
|
|
}
|
|
|
|
onClickToggleBtn() {
|
|
(_crd && AudioMgr === void 0 ? (_reportPossibleCrUseOfAudioMgr({
|
|
error: Error()
|
|
}), AudioMgr) : AudioMgr).inst.playOneShot((_crd && AssetController === void 0 ? (_reportPossibleCrUseOfAssetController({
|
|
error: Error()
|
|
}), AssetController) : AssetController).instance.click); // AudioMgr.inst.playOneShot(AssetController.instance.buttonClip)
|
|
|
|
this.value = !this.value;
|
|
this.switchSprite(this.value);
|
|
|
|
if (this.onSwitchCallBack != null) {
|
|
this.onSwitchCallBack(this.value);
|
|
}
|
|
}
|
|
|
|
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "onSelect", [_dec2], {
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true,
|
|
initializer: function initializer() {
|
|
return null;
|
|
}
|
|
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "onNoSelect", [_dec3], {
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true,
|
|
initializer: function initializer() {
|
|
return null;
|
|
}
|
|
})), _class2)) || _class));
|
|
|
|
_cclegacy._RF.pop();
|
|
|
|
_crd = false;
|
|
}
|
|
};
|
|
});
|
|
//# sourceMappingURL=60cdac507d8d69ba60d1a17b9010a0a8c3c7a055.js.map
|