mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-08 03:16:49 +08:00
Merge branch 'master' of https://gitee.com/dgflash/oops-plugin-framework
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2022-02-11 09:32:47
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-09-02 15:29:45
|
||||
* @LastEditTime: 2022-11-01 15:47:42
|
||||
*/
|
||||
import { ecs } from "../libs/ecs/ECS";
|
||||
import { ECSRootSystem } from "../libs/ecs/ECSSystem";
|
||||
import { LanguageManager } from "../libs/gui/language/Language";
|
||||
import { HttpRequest } from "../libs/network/HttpRequest";
|
||||
import { Config } from "../module/config/Config";
|
||||
import { AudioManager } from "./common/audio/AudioManager";
|
||||
import { MessageManager } from "./common/event/MessageManager";
|
||||
import { ResLoader } from "./common/loader/ResLoader";
|
||||
@@ -18,12 +19,13 @@ import { GameManager } from "./game/GameManager";
|
||||
import { LayerManager } from "./gui/layer/LayerManager";
|
||||
|
||||
/** 框架版本号 */
|
||||
export var version: string = "1.1.2";
|
||||
export var version: string = "1.1.3";
|
||||
|
||||
/** 框架核心模块访问入口 */
|
||||
export class oops {
|
||||
/** ----------核心模块---------- */
|
||||
|
||||
/** 游戏配置 */
|
||||
static config = new Config();
|
||||
/** 日志管理 */
|
||||
static log = Logger;
|
||||
/** 全局消息 */
|
||||
|
||||
@@ -2,18 +2,16 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-09-23 15:20:46
|
||||
* @LastEditTime: 2022-11-01 15:44:57
|
||||
*/
|
||||
import { Component, director, game, Game, log, Node, sys, view, _decorator } from "cc";
|
||||
import { ecs } from "../libs/ecs/ECS";
|
||||
import { Component, director, game, Game, JsonAsset, log, Node, sys, view, _decorator } from "cc";
|
||||
import { LanguageManager } from "../libs/gui/language/Language";
|
||||
import { HttpRequest } from "../libs/network/HttpRequest";
|
||||
import { config } from "../module/config/Config";
|
||||
import { BuildTimeConstants } from "../module/config/BuildTimeConstants";
|
||||
import { GameConfig } from "../module/config/GameConfig";
|
||||
import { GameQueryConfig } from "../module/config/GameQueryConfig";
|
||||
import { AudioManager } from "./common/audio/AudioManager";
|
||||
import { EventMessage } from "./common/event/EventMessage";
|
||||
import { MessageManager } from "./common/event/MessageManager";
|
||||
import { TimerManager } from "./common/manager/TimerManager";
|
||||
import { StorageManager } from "./common/storage/StorageManager";
|
||||
import { GameManager } from "./game/GameManager";
|
||||
import { GUI } from "./gui/GUI";
|
||||
import { LayerManager } from "./gui/layer/LayerManager";
|
||||
@@ -40,7 +38,18 @@ export class Root extends Component {
|
||||
onLoad() {
|
||||
console.log(`Oops Framework v${version}`);
|
||||
this.enabled = false;
|
||||
config.init(() => {
|
||||
|
||||
let config_name = "config/config";
|
||||
oops.res.load(config_name, JsonAsset, () => {
|
||||
var config = oops.res.get(config_name);
|
||||
oops.config.btc = new BuildTimeConstants();
|
||||
oops.config.query = new GameQueryConfig();
|
||||
oops.config.game = new GameConfig(config);
|
||||
oops.http.server = oops.config.game.httpServer; // Http 服务器地址
|
||||
oops.http.timeout = oops.config.game.httpTimeout; // Http 请求超时时间
|
||||
oops.storage.init(oops.config.game.localDataKey, oops.config.game.localDataIv); // 初始化本地存储加密
|
||||
game.frameRate = oops.config.game.frameRate; // 初始化每秒传输帧数
|
||||
|
||||
this.enabled = true;
|
||||
this.init();
|
||||
this.run();
|
||||
|
||||
@@ -284,10 +284,4 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源管理模块
|
||||
* @deprecated 下个版本废弃,请使用 oops.res
|
||||
*/
|
||||
export var resLoader = new ResLoader();
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { Component, sp, _decorator } from 'cc';
|
||||
import { resLoader } from '../../../core/common/loader/ResLoader';
|
||||
import { oops } from '../../../core/Oops';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 动画播放完隐藏特效 */
|
||||
@@ -28,7 +28,7 @@ export class SpineFinishedRelease extends Component {
|
||||
this.spine.setCompleteListener(this.onSpineComplete.bind(this));
|
||||
|
||||
if (this.resPath) {
|
||||
resLoader.load(this.resPath, sp.SkeletonData, (err: Error | null, sd: sp.SkeletonData) => {
|
||||
oops.res.load(this.resPath, sp.SkeletonData, (err: Error | null, sd: sp.SkeletonData) => {
|
||||
if (err) {
|
||||
console.error(`加载【${this.resPath}】的 SPINE 资源不存在`);
|
||||
return;
|
||||
|
||||
@@ -144,7 +144,7 @@ export class OrbitCamera extends Component {
|
||||
input.on(Input.EventType.MOUSE_WHEEL, this.onMouseWheel, this);
|
||||
}
|
||||
|
||||
this.resetTargetRotation();
|
||||
if (this.target) this.resetTargetRotation();
|
||||
|
||||
// 根据欧拉角信息计算摄像机四元数,旋转顺序为 YZX
|
||||
Quat.fromEuler(this._rotation, this._targetRotation.x, this._targetRotation.y, this._targetRotation.z);
|
||||
@@ -164,7 +164,7 @@ export class OrbitCamera extends Component {
|
||||
let targetRotation: Vec3 = this._targetRotation.set(this._startRotation);
|
||||
if (this.followTargetRotationY) {
|
||||
targetRotation = tempVec3_2.set(targetRotation);
|
||||
Quat.toEuler(tempVec3, this.target!.worldRotation);
|
||||
Quat.toEuler(tempVec3, this.target.worldRotation);
|
||||
targetRotation.add(tempVec3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Animation, AnimationClip, EventTouch, _decorator } from "cc";
|
||||
import { resLoader } from "../../../core/common/loader/ResLoader";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import ButtonSimple from "./ButtonSimple";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
@@ -17,8 +17,8 @@ export default class ButtonEffect extends ButtonSimple {
|
||||
onLoad() {
|
||||
this.anim = this.node.addComponent(Animation);
|
||||
|
||||
var ac_start = resLoader.get("common/anim/button_scale_start", AnimationClip)!;
|
||||
var ac_end = resLoader.get("common/anim/button_scale_end", AnimationClip)!;
|
||||
var ac_start = oops.res.get("common/anim/button_scale_start", AnimationClip)!;
|
||||
var ac_end = oops.res.get("common/anim/button_scale_end", AnimationClip)!;
|
||||
this.anim.defaultClip = ac_start;
|
||||
this.anim.createState(ac_start, ac_start?.name);
|
||||
this.anim.createState(ac_end, ac_end?.name);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-09-06 17:18:05
|
||||
*/
|
||||
|
||||
/**
|
||||
* 实现动态绑定的核心部分,
|
||||
* 每次修改属性值,都会调用对应函数,并且获取值的路径
|
||||
*/
|
||||
|
||||
const OP = Object.prototype;
|
||||
const types = {
|
||||
obj: '[object Object]',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, log, _decorator } from 'cc';
|
||||
import { DEBUG, EDITOR } from 'cc/env';
|
||||
import { DEBUG } from 'cc/env';
|
||||
import { VM } from './ViewModel';
|
||||
import { VMEnv } from './VMEnv';
|
||||
|
||||
// 用来处理通知数据的层级
|
||||
// 控制旗下子节点的数据
|
||||
@@ -9,13 +10,14 @@ import { VM } from './ViewModel';
|
||||
|
||||
const DEBUG_WATCH_PATH: boolean = false;
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
const { ccclass, help } = _decorator;
|
||||
|
||||
/**
|
||||
* watchPath 的基础,只提供绑定功能 和 对应的数据更新函数
|
||||
*/
|
||||
@ccclass
|
||||
export default class VMBase extends Component {
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMBase.md')
|
||||
export class VMBase extends Component {
|
||||
/**VM管理 */
|
||||
VM = VM;
|
||||
|
||||
@@ -35,7 +37,7 @@ export default class VMBase extends Component {
|
||||
* 如果需要重写onLoad 方法,请根据顺序调用 super.onLoad(),执行默认方法
|
||||
*/
|
||||
onLoad() {
|
||||
if (EDITOR) return;
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
// 提前拆分、并且解析路径
|
||||
let paths = this.watchPath.split('.');
|
||||
@@ -86,7 +88,8 @@ export default class VMBase extends Component {
|
||||
}
|
||||
|
||||
onEnable() {
|
||||
if (EDITOR) return; // 编辑器模式不能判断
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
if (this.templateMode) {
|
||||
this.setMultPathEvent(true);
|
||||
}
|
||||
@@ -98,7 +101,8 @@ export default class VMBase extends Component {
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
if (EDITOR) return;//编辑器模式不能判断
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
if (this.templateMode) {
|
||||
this.setMultPathEvent(false);
|
||||
}
|
||||
@@ -109,7 +113,8 @@ export default class VMBase extends Component {
|
||||
|
||||
// 多路径监听方式
|
||||
private setMultPathEvent(enabled: boolean = true) {
|
||||
if (EDITOR) return;
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
let arr = this.watchPathArr;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const path = arr[i];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CCString, Component, Enum, log, Node, _decorator } from "cc";
|
||||
import { EDITOR } from "cc/env";
|
||||
import { VMEnv } from "./VMEnv";
|
||||
|
||||
const { ccclass, property, executeInEditMode, menu, help } = _decorator;
|
||||
|
||||
@@ -17,7 +17,7 @@ enum ACTION_MODE {
|
||||
@ccclass
|
||||
@executeInEditMode
|
||||
@menu('ModelViewer/Edit-Comps (快速组件操作)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMCompsEdit.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMCompsEdit.md')
|
||||
export default class MVCompsEdit extends Component {
|
||||
@property({
|
||||
type: [CCString]
|
||||
@@ -149,11 +149,10 @@ export default class MVCompsEdit extends Component {
|
||||
collectNodes: Node[] = [];
|
||||
|
||||
onLoad() {
|
||||
//不要把脚本挂载运行时的提示
|
||||
if (!EDITOR) {
|
||||
let path = this.getNodePath(this.node);
|
||||
console.error('you forget delete MVEditFinder,[path]', path);
|
||||
}
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
let path = this.getNodePath(this.node);
|
||||
console.error('you forget delete MVEditFinder,[path]', path);
|
||||
}
|
||||
|
||||
setComponents(state: number) {
|
||||
@@ -213,17 +212,16 @@ export default class MVCompsEdit extends Component {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1://激活组件
|
||||
case 1: // 激活组件
|
||||
v.enabled = true;
|
||||
break;
|
||||
case 2://关闭组件
|
||||
case 2: // 关闭组件
|
||||
v.enabled = false;
|
||||
break;
|
||||
case 3://删除组件
|
||||
case 3: // 删除组件
|
||||
v.node.removeComponent(v);
|
||||
break;
|
||||
case 4://替换指定路径
|
||||
|
||||
case 4: // 替换指定路径
|
||||
let targetPath = this.targetPath;
|
||||
let replacePath = this.replacePath;
|
||||
if (v.templateMode === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Toggle, _decorator } from 'cc';
|
||||
import { EDITOR } from 'cc/env';
|
||||
import VMBase from './VMBase';
|
||||
import { VMBase } from './VMBase';
|
||||
import { VMEnv } from './VMEnv';
|
||||
|
||||
const { ccclass, property, executeInEditMode, menu, help } = _decorator;
|
||||
|
||||
@@ -26,8 +26,8 @@ const COMP_ARRAY_CHECK = [
|
||||
@ccclass
|
||||
@executeInEditMode
|
||||
@menu('ModelViewer/VM-Custom (自定义VM)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMCustom.md')
|
||||
export default class VMCustom extends VMBase {
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMCustom.md')
|
||||
export class VMCustom extends VMBase {
|
||||
@property({
|
||||
tooltip: '激活controller,以开启双向绑定,否则只能接收消息',
|
||||
})
|
||||
@@ -76,10 +76,11 @@ export default class VMCustom extends VMBase {
|
||||
|
||||
// 只在运行时检查组件是否缺失可用
|
||||
this.checkEditorComponent();//编辑器检查
|
||||
if (!EDITOR) {
|
||||
this._watchComponent = this.node.getComponent(this.componentName);
|
||||
this.checkComponentState();
|
||||
}
|
||||
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
this._watchComponent = this.node.getComponent(this.componentName);
|
||||
this.checkComponentState();
|
||||
}
|
||||
|
||||
onRestore() {
|
||||
@@ -93,18 +94,18 @@ export default class VMCustom extends VMBase {
|
||||
|
||||
// 挂在对应节点后,自动获取组件属性和名字
|
||||
checkEditorComponent() {
|
||||
if (EDITOR) {
|
||||
let checkArray = COMP_ARRAY_CHECK;
|
||||
for (let i = 0; i < checkArray.length; i++) {
|
||||
const params = checkArray[i];
|
||||
let comp = this.node.getComponent(params[0] as string);
|
||||
if (comp) {
|
||||
if (this.componentName == '') this.componentName = params[0] as string;
|
||||
if (this.componentProperty == '') this.componentProperty = params[1] as string;
|
||||
if (params[2] !== null) this.controller = params[2] as boolean;
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
break;
|
||||
}
|
||||
let checkArray = COMP_ARRAY_CHECK;
|
||||
for (let i = 0; i < checkArray.length; i++) {
|
||||
const params = checkArray[i];
|
||||
let comp = this.node.getComponent(params[0] as string);
|
||||
if (comp) {
|
||||
if (this.componentName == '') this.componentName = params[0] as string;
|
||||
if (this.componentProperty == '') this.componentProperty = params[1] as string;
|
||||
if (params[2] !== null) this.controller = params[2] as boolean;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +134,8 @@ export default class VMCustom extends VMBase {
|
||||
|
||||
/** 初始化获取数据 */
|
||||
onValueInit() {
|
||||
if (EDITOR) return; //编辑器模式不初始化
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
//更新信息
|
||||
this.setComponentValue(this.VM.getValue(this.watchPath));
|
||||
}
|
||||
@@ -150,7 +152,8 @@ export default class VMCustom extends VMBase {
|
||||
|
||||
update(dt: number) {
|
||||
// 脏检查(组件是否存在,是否被激活)
|
||||
if (EDITOR == true) return;
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
//if (this.templateMode == true) return; //todo 模板模式下不能计算
|
||||
if (!this.controller) return;
|
||||
if (!this._canWatchComponent || this._watchComponent['enabled'] === false) return;
|
||||
|
||||
10
assets/libs/model-view/VMEnv.ts
Normal file
10
assets/libs/model-view/VMEnv.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { EDITOR } from "cc/env";
|
||||
|
||||
/** VM组件环境验证 */
|
||||
export class VMEnv {
|
||||
/** 编辑状态 */
|
||||
static get editor() {
|
||||
// @ts-ignore
|
||||
return EDITOR && !cc.GAME_VIEW;
|
||||
}
|
||||
}
|
||||
9
assets/libs/model-view/VMEnv.ts.meta
Normal file
9
assets/libs/model-view/VMEnv.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fdf7243d-d4f7-425e-93d0-fbadacd6e7e2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CCString, Enum, EventHandler, _decorator } from 'cc';
|
||||
import VMBase from './VMBase';
|
||||
import { VMBase } from './VMBase';
|
||||
|
||||
// +普通 label 更新数据的情况,label.string = xxx;
|
||||
// +frameIndex 插件,通过number 数值设置 BhvFrameIndex 来切换当前贴图
|
||||
@@ -30,7 +30,7 @@ enum FILTER_MODE {
|
||||
@ccclass
|
||||
@executeInEditMode
|
||||
@menu('ModelViewer/VM-EventCall(调用函数)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMEvent.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMEvent.md')
|
||||
export default class VMEvent extends VMBase {
|
||||
@property({
|
||||
tooltip: '使用模板模式,可以使用多路径监听'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CCString, error, _decorator } from 'cc';
|
||||
import { EDITOR } from 'cc/env';
|
||||
import { StringFormatFunction } from './StringFormat';
|
||||
import VMBase from './VMBase';
|
||||
import { VMBase } from './VMBase';
|
||||
import { VMEnv } from './VMEnv';
|
||||
|
||||
const { ccclass, property, menu, executeInEditMode, help } = _decorator;
|
||||
|
||||
@@ -20,7 +20,7 @@ const LABEL_TYPE = {
|
||||
@ccclass
|
||||
@executeInEditMode
|
||||
@menu('ModelViewer/VM-Label(文本VM)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMLabel.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMLabel.md')
|
||||
export default class VMLabel extends VMBase {
|
||||
@property({
|
||||
tooltip: '是否启用模板代码,只能在运行时之前设置,\n将会动态解析模板语法 {{0}},并且自动设置监听的路径'
|
||||
@@ -29,6 +29,7 @@ export default class VMLabel extends VMBase {
|
||||
|
||||
@property({
|
||||
visible() {
|
||||
// @ts-ignore
|
||||
return this.templateMode === false;
|
||||
}
|
||||
})
|
||||
@@ -42,6 +43,7 @@ export default class VMLabel extends VMBase {
|
||||
@property({
|
||||
type: [CCString],
|
||||
visible() {
|
||||
// @ts-ignore
|
||||
return this.templateMode === true;
|
||||
}
|
||||
})
|
||||
@@ -64,16 +66,18 @@ export default class VMLabel extends VMBase {
|
||||
onLoad() {
|
||||
super.onLoad();
|
||||
this.checkLabel();
|
||||
if (!EDITOR) {
|
||||
if (this.templateMode) {
|
||||
this.originText = this.getLabelValue();
|
||||
this.parseTemplate();
|
||||
}
|
||||
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
if (this.templateMode) {
|
||||
this.originText = this.getLabelValue();
|
||||
this.parseTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
if (EDITOR) return;
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
this.onValueInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Enum, _decorator } from 'cc';
|
||||
import VMBase from './VMBase';
|
||||
import { VMBase } from './VMBase';
|
||||
|
||||
const { ccclass, property, menu, help } = _decorator;
|
||||
|
||||
@@ -17,7 +17,7 @@ enum CLAMP_MODE {
|
||||
*/
|
||||
@ccclass
|
||||
@menu('ModelViewer/VM-Modify(修改Model)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMModify.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMModify.md')
|
||||
export default class VMModify extends VMBase {
|
||||
@property({
|
||||
tooltip: "监视对象路径"
|
||||
|
||||
@@ -13,7 +13,7 @@ const { ccclass, help, executionOrder } = _decorator;
|
||||
*/
|
||||
@ccclass
|
||||
@executionOrder(-1)
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMParent.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMParent.md')
|
||||
export default class VMParent extends GameComponent {
|
||||
/** 绑定的标签,可以通过这个tag 获取 当前的 vm 实例 */
|
||||
protected tag: string = '_temp';
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
* @LastEditTime: 2022-08-11 15:43:34
|
||||
*/
|
||||
import { CCString, _decorator } from "cc";
|
||||
import { EDITOR } from "cc/env";
|
||||
import { StringFormatFunction } from "./StringFormat";
|
||||
import VMCustom from "./VMCustom";
|
||||
import { VMCustom } from "./VMCustom";
|
||||
import { VMEnv } from "./VMEnv";
|
||||
|
||||
const { ccclass, property, menu, help } = _decorator;
|
||||
|
||||
@ccclass
|
||||
@menu('ModelViewer/VM-Progress (VM-进度条)')
|
||||
@help('https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/VMProgress.md')
|
||||
@help('https://gitee.com/dgflash/oops-framework/blob/master/doc/mvvm/VMProgress.md')
|
||||
export default class VMProgress extends VMCustom {
|
||||
@property({
|
||||
visible: false,
|
||||
@@ -46,9 +46,9 @@ export default class VMProgress extends VMCustom {
|
||||
}
|
||||
|
||||
start() {
|
||||
if (!EDITOR) {
|
||||
this.onValueInit();
|
||||
}
|
||||
if (VMEnv.editor) return;
|
||||
|
||||
this.onValueInit();
|
||||
}
|
||||
|
||||
onValueInit() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Button, CCInteger, color, Color, Enum, Node, UIRenderer, Sprite, UIOpacity, _decorator } from 'cc';
|
||||
import { VM } from './ViewModel';
|
||||
import VMBase from './VMBase';
|
||||
import { VMBase } from './VMBase';
|
||||
|
||||
const { ccclass, property, menu, help } = _decorator;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ enum PARAM_TYPE {
|
||||
*/
|
||||
@ccclass
|
||||
@menu("添加特殊行为/UI/Button Group(一组按钮控制)")
|
||||
export default class BhvButtonGroup extends Component {
|
||||
export class BhvButtonGroup extends Component {
|
||||
@property({
|
||||
type: Enum(Button.Transition)
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ const { ccclass, property, executeInEditMode, requireComponent, menu } = _decora
|
||||
@executeInEditMode
|
||||
@requireComponent(Sprite)
|
||||
@menu("添加特殊行为/UI/Frame Index(帧图改变)")
|
||||
export default class BhvFrameIndex extends Component {
|
||||
export class BhvFrameIndex extends Component {
|
||||
@property({
|
||||
type: [SpriteFrame],
|
||||
tooltip: 'sprite将会用到帧图片'
|
||||
|
||||
@@ -25,7 +25,7 @@ type CustomCallback = (curValue: number, targetValue: number) => string;
|
||||
*/
|
||||
@ccclass
|
||||
@menu("添加特殊行为/UI/Roll Number (滚动数字)")
|
||||
export default class BhvRollNumber extends Component {
|
||||
export class BhvRollNumber extends Component {
|
||||
@property({
|
||||
type: Label,
|
||||
tooltip: '需要滚动的 Label 组件,如果不进行设置,就会从自己的节点自动查找'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { CCInteger, Component, Node, _decorator } from "cc";
|
||||
import { EDITOR } from "cc/env";
|
||||
import { VMEnv } from "../VMEnv";
|
||||
|
||||
const { ccclass, property, executeInEditMode, menu } = _decorator;
|
||||
|
||||
@ccclass
|
||||
@executeInEditMode
|
||||
@menu("添加特殊行为/UI/Switch Page (切换页面)")
|
||||
export default class BhvSwitchPage extends Component {
|
||||
export class BhvSwitchPage extends Component {
|
||||
@property
|
||||
isLoopPage: boolean = false;
|
||||
|
||||
@@ -34,7 +34,7 @@ export default class BhvSwitchPage extends Component {
|
||||
this.preIndex = this._index;//标记之前的页面
|
||||
this._index = v;
|
||||
|
||||
if (EDITOR) {
|
||||
if (VMEnv.editor) {
|
||||
this._updateEditorPage(v);
|
||||
}
|
||||
else {
|
||||
@@ -57,7 +57,8 @@ export default class BhvSwitchPage extends Component {
|
||||
}
|
||||
|
||||
private _updateEditorPage(page: number) {
|
||||
if (!EDITOR) return;
|
||||
if (!VMEnv.editor) return;
|
||||
|
||||
let children = this.node.children;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const node = children[i];
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-09-06 17:28:01
|
||||
* @LastEditTime: 2022-11-01 15:47:16
|
||||
*/
|
||||
|
||||
import { game, JsonAsset } from "cc";
|
||||
import { oops } from "../../core/Oops";
|
||||
import { BuildTimeConstants } from "./BuildTimeConstants";
|
||||
import { GameConfig } from "./GameConfig";
|
||||
import { GameQueryConfig } from "./GameQueryConfig";
|
||||
@@ -21,28 +19,4 @@ export class Config {
|
||||
|
||||
/** 浏览器查询参数 */
|
||||
public query!: GameQueryConfig;
|
||||
|
||||
/** 初始化游戏配置 */
|
||||
public init(callback: Function) {
|
||||
let config_name = "config/config";
|
||||
oops.res.load(config_name, JsonAsset, () => {
|
||||
var config = oops.res.get(config_name);
|
||||
this.btc = new BuildTimeConstants();
|
||||
this.query = new GameQueryConfig();
|
||||
this.game = new GameConfig(config);
|
||||
|
||||
// 初始化每秒传输帧数
|
||||
game.frameRate = this.game.frameRate;
|
||||
// Http 服务器地址
|
||||
oops.http.server = this.game.httpServer;
|
||||
// Http 请求超时时间
|
||||
oops.http.timeout = this.game.httpTimeout;
|
||||
// 初始化本地存储加密
|
||||
oops.storage.init(this.game.localDataKey, this.game.localDataIv);
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const config = new Config()
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-09-06 17:29:04
|
||||
* @LastEditTime: 2022-11-01 15:26:26
|
||||
*/
|
||||
|
||||
import { oops } from "../../core/Oops";
|
||||
@@ -52,6 +52,11 @@ export class GameConfig {
|
||||
}
|
||||
|
||||
private _data: any = null;
|
||||
/** 游戏配置数据 */
|
||||
public get data(): any {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
constructor(config: any) {
|
||||
let data = config.json;
|
||||
this._data = Object.freeze(data);
|
||||
|
||||
Reference in New Issue
Block a user