|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:40:20
|
|
* @Date: 2025-03-20 15:40:20
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-03 15:38:50
|
|
|
|
|
|
|
+ * @LastEditTime: 2025-04-03 16:31:43
|
|
|
* @Description:设置界面
|
|
* @Description:设置界面
|
|
|
*/
|
|
*/
|
|
|
import { _decorator } from "cc";
|
|
import { _decorator } from "cc";
|
|
@@ -16,20 +16,20 @@ import { Account } from "../../account/Account";
|
|
|
import { ImageAsset, Texture2D, SpriteFrame, Sprite } from "cc";
|
|
import { ImageAsset, Texture2D, SpriteFrame, Sprite } from "cc";
|
|
|
import { IRemoteOptions, resLoader } from "db://oops-framework/core/common/loader/ResLoader";
|
|
import { IRemoteOptions, resLoader } from "db://oops-framework/core/common/loader/ResLoader";
|
|
|
import { Button } from "cc";
|
|
import { Button } from "cc";
|
|
|
-
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
/** 视图层对象 */
|
|
/** 视图层对象 */
|
|
|
@ccclass('SettingViewComp')
|
|
@ccclass('SettingViewComp')
|
|
|
@ecs.register('SettingView', false)
|
|
@ecs.register('SettingView', false)
|
|
|
export class SettingViewComp extends CCVMParentComp {
|
|
export class SettingViewComp extends CCVMParentComp {
|
|
|
|
|
+
|
|
|
data: any = {
|
|
data: any = {
|
|
|
- nickName: "金砖大王",
|
|
|
|
|
- uid: "1234567890",
|
|
|
|
|
- music_state: true,
|
|
|
|
|
- effect_state: true
|
|
|
|
|
|
|
+ head_url: "",
|
|
|
|
|
+ uid: 100000,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@property(Button)
|
|
@property(Button)
|
|
|
private musicBtn: Button = null!;
|
|
private musicBtn: Button = null!;
|
|
|
|
|
|
|
@@ -45,8 +45,9 @@ export class SettingViewComp extends CCVMParentComp {
|
|
|
start() {
|
|
start() {
|
|
|
// const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
|
// const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
|
|
this.setButton();
|
|
this.setButton();
|
|
|
- this.updateHead();
|
|
|
|
|
this.updateBtnState();
|
|
this.updateBtnState();
|
|
|
|
|
+ this.updateHead();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(SettingViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
/** 视图对象通过 ecs.Entity.remove(SettingViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
@@ -67,22 +68,27 @@ export class SettingViewComp extends CCVMParentComp {
|
|
|
|
|
|
|
|
//更新按钮状态
|
|
//更新按钮状态
|
|
|
private updateBtnState() {
|
|
private updateBtnState() {
|
|
|
- const music_state = oops.storage.get("music_state");
|
|
|
|
|
- const effect_state = oops.storage.get("effect_state");
|
|
|
|
|
- if (music_state == "" || music_state == null) {
|
|
|
|
|
|
|
+ console.log("updateBtnState");
|
|
|
|
|
+
|
|
|
|
|
+ const music_state = oops.storage.getBoolean("music_state");
|
|
|
|
|
+ const effect_state = oops.storage.getBoolean("effect_state");
|
|
|
|
|
+ oops.log.logView(music_state, "music_state");
|
|
|
|
|
+ console.log("effect_state", effect_state);
|
|
|
|
|
+
|
|
|
|
|
+ if (music_state == null) {
|
|
|
oops.storage.set("music_state", true);
|
|
oops.storage.set("music_state", true);
|
|
|
this._musicState = true;
|
|
this._musicState = true;
|
|
|
} else {
|
|
} else {
|
|
|
// 将字符串转换为布尔值
|
|
// 将字符串转换为布尔值
|
|
|
- let music_state_bool = music_state == "true" ? true : false;
|
|
|
|
|
|
|
+ let music_state_bool = music_state == true ? true : false;
|
|
|
this._musicState = music_state_bool;
|
|
this._musicState = music_state_bool;
|
|
|
}
|
|
}
|
|
|
- if (effect_state == "" || effect_state == null) {
|
|
|
|
|
|
|
+ if (effect_state == null) {
|
|
|
oops.storage.set("effect_state", true);
|
|
oops.storage.set("effect_state", true);
|
|
|
this._effectState = true;
|
|
this._effectState = true;
|
|
|
} else {
|
|
} else {
|
|
|
// 将字符串转换为布尔值
|
|
// 将字符串转换为布尔值
|
|
|
- let effect_state_bool = effect_state == "true" ? true : false;
|
|
|
|
|
|
|
+ let effect_state_bool = effect_state == true ? true : false;
|
|
|
this._effectState = effect_state_bool;
|
|
this._effectState = effect_state_bool;
|
|
|
}
|
|
}
|
|
|
oops.audio.switchMusic = this._musicState;
|
|
oops.audio.switchMusic = this._musicState;
|
|
@@ -104,20 +110,20 @@ export class SettingViewComp extends CCVMParentComp {
|
|
|
//更新头像
|
|
//更新头像
|
|
|
private updateHead() {
|
|
private updateHead() {
|
|
|
let account = ecs.getEntity<Account>(Account);
|
|
let account = ecs.getEntity<Account>(Account);
|
|
|
- let sprite = this.node.getChildByPath("Bg/btn_head/sp_head")!.uiSprite;
|
|
|
|
|
- // let url = account.AccountModel.head;
|
|
|
|
|
- let url = "http://www.kuaipng.com/Uploads/pic/w/2020/07-16/89010/water_89010_698_698_.png"
|
|
|
|
|
this.data.uid = account.AccountModel.Uid;
|
|
this.data.uid = account.AccountModel.Uid;
|
|
|
- var opt: IRemoteOptions = { ext: ".png" };
|
|
|
|
|
- var onComplete = (err: Error | null, data: ImageAsset) => {
|
|
|
|
|
- const texture = new Texture2D();
|
|
|
|
|
- texture.image = data;
|
|
|
|
|
-
|
|
|
|
|
- const spriteFrame = new SpriteFrame();
|
|
|
|
|
- spriteFrame.texture = texture;
|
|
|
|
|
- sprite.spriteFrame = spriteFrame;
|
|
|
|
|
- }
|
|
|
|
|
- resLoader.loadRemote<ImageAsset>(url, opt, onComplete);
|
|
|
|
|
|
|
+ let url = account.AccountModel.HeadUrl;
|
|
|
|
|
+ // let sprite = this.node.getChildByPath("Bg/btn_head/sp_head")!.uiSprite;
|
|
|
|
|
+ // let url = "http://www.kuaipng.com/Uploads/pic/w/2020/07-16/89010/water_89010_698_698_.png"
|
|
|
|
|
+ // var opt: IRemoteOptions = { ext: ".png" };
|
|
|
|
|
+ // var onComplete = (err: Error | null, data: ImageAsset) => {
|
|
|
|
|
+ // const texture = new Texture2D();
|
|
|
|
|
+ // texture.image = data;
|
|
|
|
|
+
|
|
|
|
|
+ // const spriteFrame = new SpriteFrame();
|
|
|
|
|
+ // spriteFrame.texture = texture;
|
|
|
|
|
+ // sprite.spriteFrame = spriteFrame;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // resLoader.loadRemote<ImageAsset>(url, opt, onComplete);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -157,8 +163,6 @@ export class SettingViewComp extends CCVMParentComp {
|
|
|
//用户协议
|
|
//用户协议
|
|
|
private btn_protocol() {
|
|
private btn_protocol() {
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|