mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-10-30 19:05:44 +00:00
仓库中添加内置的demo
This commit is contained in:
9
demo/assets/script/Binary.ts.meta
Normal file
9
demo/assets/script/Binary.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "24de22b8-8818-44a6-be2a-6aaa539447b0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Data.meta
Normal file
9
demo/assets/script/Data.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "204786f0-6faa-434f-bb4a-365be227bf25",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
24
demo/assets/script/Data/DataHelper.ts
Normal file
24
demo/assets/script/Data/DataHelper.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-17
|
||||
* @Description: 准备一个数据类
|
||||
*/
|
||||
|
||||
import { GlobalEvent } from "kunpocc-event";
|
||||
|
||||
export class DataHelper {
|
||||
private static _data: Map<string, any> = new Map();
|
||||
|
||||
public static getValue<T>(key: string, defaultValue: T): T {
|
||||
if (this._data.has(key)) {
|
||||
return this._data.get(key) as T;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static setValue(key: string, value: any): void {
|
||||
this._data.set(key, value);
|
||||
/** 数据改变后发送事件 */
|
||||
GlobalEvent.send(key);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Data/DataHelper.ts.meta
Normal file
9
demo/assets/script/Data/DataHelper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7340bacc-d167-47e8-a83b-2224c46b7fd0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
65
demo/assets/script/Debug.ts
Normal file
65
demo/assets/script/Debug.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @Author: LQ
|
||||
* @Date: 2023-04-17
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { cc, kunpo } from "./header";
|
||||
|
||||
const tt = window['tt'];
|
||||
|
||||
export class Debug {
|
||||
public static Register(): void {
|
||||
this._registerSystemEvent();
|
||||
}
|
||||
|
||||
private static _registerSystemEvent(): void {
|
||||
cc.input.on(cc.Input.EventType.KEY_DOWN, (event: cc.EventKeyboard) => {
|
||||
if (event.keyCode == cc.KeyCode.KEY_Q) {
|
||||
kunpo.WindowManager.showWindow("HomeWindow")
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_W) {
|
||||
kunpo.WindowManager.showWindow("HideAllWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_E) {
|
||||
kunpo.WindowManager.showWindow("HideOneWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_R) {
|
||||
kunpo.WindowManager.showWindow("CloseAllWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_T) {
|
||||
kunpo.WindowManager.showWindow("CloseOneWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_Y) {
|
||||
kunpo.WindowManager.showWindow("GameWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_U) {
|
||||
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_A) {
|
||||
kunpo.WindowManager.showWindow("PopWindowHeader1");
|
||||
// new NetAuth().start();
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_S) {
|
||||
kunpo.WindowManager.showWindow("PopWindowHeader2");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_D) {
|
||||
kunpo.WindowManager.showWindow("PopWindow");
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_F) {
|
||||
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_G) {
|
||||
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_H) {
|
||||
|
||||
} else if (event.keyCode == cc.KeyCode.KEY_J) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 跳转侧边栏 */
|
||||
public navigateToScene(): void {
|
||||
if (tt['navigateToScene']) {
|
||||
tt['navigateToScene']({
|
||||
scene: "sidebar",
|
||||
success: (res: { errMsg: string }) => {
|
||||
console.log(`侧边栏跳转成功:${res.errMsg}`);
|
||||
},
|
||||
fail: (res: { errMsg: string, errNo: number }) => {
|
||||
console.log(`侧边栏跳转失败 code:${res.errNo}; msg:${res.errMsg}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Debug.ts.meta
Normal file
9
demo/assets/script/Debug.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cb6cfaf4-abaa-446a-bdba-a6b6f32cd810",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
87
demo/assets/script/GameEntry.ts
Normal file
87
demo/assets/script/GameEntry.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { Debug } from './Debug';
|
||||
import { cc, fgui, kunpo, KunpoAssets } from './header';
|
||||
import { SDKHelper } from './Helper/SDKHelper';
|
||||
import { UIPackageRegister } from './UIPackageRegister';
|
||||
const { ccclass, property, menu } = cc._decorator;
|
||||
@ccclass("GameEntry")
|
||||
@menu("kunpo/GameEntry")
|
||||
export class GameEntry extends kunpo.CocosEntry {
|
||||
@property(cc.Node)
|
||||
private root: cc.Node = null;
|
||||
@property(cc.Asset)
|
||||
private manifest: cc.Asset = null;
|
||||
|
||||
public getConfig(): kunpo.FrameConfig {
|
||||
return {
|
||||
debug: false
|
||||
};
|
||||
}
|
||||
|
||||
onInit(): void {
|
||||
let deviceId = cc.sys.localStorage.getItem('xBBres');
|
||||
if (!deviceId || deviceId === "") {
|
||||
deviceId = "browser@" + Date.now().toString();
|
||||
cc.sys.localStorage.setItem('xBBres', deviceId);
|
||||
}
|
||||
kunpo.Platform.deviceId = deviceId;
|
||||
|
||||
Debug.Register();
|
||||
UIPackageRegister.Register();
|
||||
SDKHelper.manifestUrl = this.manifest?.nativeUrl;
|
||||
this.loadBaseResources();
|
||||
}
|
||||
|
||||
/** 1. 加载基础资源 */
|
||||
private loadBaseResources(): void {
|
||||
let paths: KunpoAssets.IAssetConfig[] = [
|
||||
{ path: "ui/manual", type: cc.Asset }, // 手动加载UI基础资源
|
||||
];
|
||||
let loader = new KunpoAssets.AssetLoader("load");
|
||||
loader.start({
|
||||
configs: paths,
|
||||
complete: () => {
|
||||
fgui.UIPackage.addPackage("ui/manual/Basics");
|
||||
fgui.UIPackage.addPackage("ui/manual/Home");
|
||||
this.loadResources();
|
||||
},
|
||||
fail: (msg: string, err: Error) => {
|
||||
|
||||
},
|
||||
progress: (percent: number) => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 2. 加载剩余资源 */
|
||||
private loadResources(): void {
|
||||
let paths: KunpoAssets.IAssetConfig[] = [
|
||||
{ path: "prefab", type: cc.Prefab },
|
||||
{ path: "config/buffer", type: cc.BufferAsset },
|
||||
// { path: "icon", type: cc.SpriteFrame },
|
||||
// { path: "texture/6101/spriteFrame", type: cc.SpriteFrame, isFile: true },
|
||||
// { path: "pet", type: cc.SpriteFrame, bundle: "bundle_res" },
|
||||
];
|
||||
let loader = new KunpoAssets.AssetLoader("load");
|
||||
loader.start({
|
||||
configs: paths,
|
||||
complete: () => {
|
||||
this.loadComplete();
|
||||
},
|
||||
fail: (msg: string, err: Error) => {
|
||||
|
||||
},
|
||||
progress: (percent: number) => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private loadComplete(): void {
|
||||
kunpo.WindowManager.showWindow("HomeWindow", "这是一个测试窗口").then(() => {
|
||||
kunpo.log("窗口显示成功");
|
||||
this.root.active = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/GameEntry.ts.meta
Normal file
9
demo/assets/script/GameEntry.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e5804a9e-c17f-4df6-8a74-778687e2bec1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Helper.meta
Normal file
9
demo/assets/script/Helper.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "62ab5824-ce9f-4472-98ad-23bd415ec454",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
20
demo/assets/script/Helper/NativeCallJS.ts
Normal file
20
demo/assets/script/Helper/NativeCallJS.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-03-22
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
function KunpoNativeCallJsHandler(jsonString: string) {
|
||||
console.log("KunpoNativeCallJsHandler", jsonString);
|
||||
// let json = JSON.parse(jsonString);
|
||||
// let functionName = json.function;
|
||||
// let args = json.args;
|
||||
// let func = _global[functionName];
|
||||
// if (func) {
|
||||
// func(...args);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
let _global = globalThis || window || global;
|
||||
(_global as any)["KunpoNativeCallJsHandler"] = KunpoNativeCallJsHandler;
|
||||
9
demo/assets/script/Helper/NativeCallJS.ts.meta
Normal file
9
demo/assets/script/Helper/NativeCallJS.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "6dd5b452-10ce-4d6c-9013-c0c991560dd7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
27
demo/assets/script/Helper/SDKHelper.ts
Normal file
27
demo/assets/script/Helper/SDKHelper.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-03-22
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { GlobalEvent } from "kunpocc-event";
|
||||
|
||||
export class SDKHelper {
|
||||
private static _manifestUrl: string = "";
|
||||
public static getSystemInfo(): Promise<{ version: string, build: number }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
KunpoSDK.SDKHelper.getInstance().getSystemInfo();
|
||||
GlobalEvent.addOnce("calljs::getSystemInfo", (data: { version: string, build: number }) => {
|
||||
resolve(data);
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
|
||||
public static set manifestUrl(url: string) {
|
||||
this._manifestUrl = url;
|
||||
}
|
||||
|
||||
public static get manifestUrl(): string {
|
||||
return this._manifestUrl;
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Helper/SDKHelper.ts.meta
Normal file
9
demo/assets/script/Helper/SDKHelper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "76eb0078-54f0-400d-a151-68586eaa78f3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
73
demo/assets/script/Math.ts
Normal file
73
demo/assets/script/Math.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
interface Math {
|
||||
/**
|
||||
* 限制值
|
||||
* @param value 当前值
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
*/
|
||||
clampf(value: number, min: number, max: number): number;
|
||||
|
||||
/**
|
||||
* 随机从 min 到 max 的整数(包含min和max)
|
||||
* @param min
|
||||
* @param max
|
||||
*/
|
||||
rand(min: number, max: number): number;
|
||||
|
||||
/**
|
||||
* 随机从 min 到 max的数
|
||||
* @param min
|
||||
* @param max
|
||||
*/
|
||||
randRange(min: number, max: number): number;
|
||||
|
||||
/**
|
||||
* 角度转弧度
|
||||
* @param angle 角度
|
||||
*/
|
||||
rad(angle: number): number;
|
||||
|
||||
/**
|
||||
* 弧度转角度
|
||||
* @param radian 弧度
|
||||
*/
|
||||
deg(radian: number): number;
|
||||
|
||||
/**
|
||||
* 数值平滑渐变
|
||||
* @param num1
|
||||
* @param num2
|
||||
* @param elapsedTime
|
||||
* @param responseTime
|
||||
*/
|
||||
smooth(num1: number, num2: number, elapsedTime: number, responseTime: number): number;
|
||||
}
|
||||
|
||||
Math.clampf = function (value: number, min: number, max: number): number {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
};
|
||||
|
||||
Math.rand = function (min: number, max: number): number {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
};
|
||||
|
||||
Math.randRange = function (min: number, max: number): number {
|
||||
return Math.random() * (max - min) + min;
|
||||
};
|
||||
|
||||
Math.rad = function (angle: number): number {
|
||||
return (angle * Math.PI) / 180;
|
||||
};
|
||||
|
||||
Math.deg = function (radian: number): number {
|
||||
return (radian * 180) / Math.PI;
|
||||
};
|
||||
|
||||
Math.smooth = function (num1: number, num2: number, elapsedTime: number, responseTime: number): number {
|
||||
let out: number = num1;
|
||||
if (elapsedTime > 0) {
|
||||
out = out + (num2 - num1) * (elapsedTime / (elapsedTime + responseTime));
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
9
demo/assets/script/Math.ts.meta
Normal file
9
demo/assets/script/Math.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a336ce23-5d73-4280-b2e9-084389a3877e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Net.meta
Normal file
9
demo/assets/script/Net.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "fcf6e6db-b041-4ade-a17c-c2ac3d72aed0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
43
demo/assets/script/Net/NetHelper.ts
Normal file
43
demo/assets/script/Net/NetHelper.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-05-20
|
||||
* @Description:
|
||||
*/
|
||||
import { HttpManager, IHttpEvent } from "kunpocc-net";
|
||||
import { kunpo } from "../header";
|
||||
import { ServerConfig } from "./header";
|
||||
|
||||
|
||||
export class NetHelper {
|
||||
public static get url(): string { return ServerConfig.url };
|
||||
public static get appid(): string { return ServerConfig.appid };
|
||||
public static get secret(): string { return ServerConfig.secret };
|
||||
|
||||
public static send(url: string, data: any, netEvent: IHttpEvent) {
|
||||
netEvent.data = new Date().getTime();
|
||||
let sendData = JSON.stringify(data);
|
||||
console.log(`http request\n name:${netEvent.name}\n url=${this.url + url}\n data=${sendData}`);
|
||||
HttpManager.post(this.url + url, sendData, "json", netEvent, this.formatHeaders(netEvent.data, data), 5);
|
||||
}
|
||||
|
||||
private static formatHeaders(time: number, data: any): any[] {
|
||||
return ["content-type", "application/json", "sign", this.signCalculateJSON(time, data), "time", encodeURIComponent(String(time)), "authorization", ""];
|
||||
}
|
||||
|
||||
/** 计算签名 */
|
||||
public static signCalculateJSON(time: number, data: any): string {
|
||||
let signData = {
|
||||
appid: this.appid,
|
||||
signkey: this.secret,
|
||||
time: time,
|
||||
body: JSON.stringify(data)
|
||||
}
|
||||
let keys = Object.keys(signData);
|
||||
keys.sort();
|
||||
let signStr = [];
|
||||
for (let key of keys) {
|
||||
signStr.push(`${key}=${signData[key]}&`);
|
||||
}
|
||||
return encodeURIComponent(kunpo.md5(signStr.join("")));
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Net/NetHelper.ts.meta
Normal file
9
demo/assets/script/Net/NetHelper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e9a1a84a-bf3a-4b94-aeea-9160d84713f8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
65
demo/assets/script/Net/NetTaskBase.ts
Normal file
65
demo/assets/script/Net/NetTaskBase.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-05-20
|
||||
* @Description: 网络基类
|
||||
*/
|
||||
|
||||
import { HttpTask, IHttpResponse } from "kunpocc-net";
|
||||
import { INetResponse } from "./header";
|
||||
|
||||
export abstract class NetTaskBase extends HttpTask {
|
||||
protected url: string = '';
|
||||
private _succeed: (data: any) => void;
|
||||
private _httpError: (data: any) => void;
|
||||
private _taskError: (data: any) => void;
|
||||
|
||||
/**
|
||||
* 设置回调
|
||||
* @param {object} res 回调函数
|
||||
* @param {function} res.succeed 任务成功回调
|
||||
* @param {function} res.taskError 任务错误回调 (一般是服务端返回错误码)
|
||||
* @param {function} res.httpError http错误回调 (一般是网络错误)
|
||||
*/
|
||||
public setTaskCallback(res: { succeed: (response: any) => void, taskError?: (response: any) => void, httpError?: (response: any) => void }) {
|
||||
this._succeed = res?.succeed;
|
||||
this._httpError = res?.httpError;
|
||||
this._taskError = res?.taskError;
|
||||
}
|
||||
|
||||
public onComplete(response: IHttpResponse): void {
|
||||
try {
|
||||
let data = response.data as INetResponse;
|
||||
if (data.responseStatus == 0) {
|
||||
console.log(`http response\n name:${this.name}\n url=${this.url}\n data=${JSON.stringify(data)}`);
|
||||
this.onTaskComplete(data);
|
||||
this._succeed?.(data);
|
||||
} else {
|
||||
throw new Error("任务错误");
|
||||
}
|
||||
} catch (error) {
|
||||
let data = response.data as INetResponse;
|
||||
console.log(`http response task error\n name:${this.name}\n url:${this.url}\n responseStatus:${data.responseStatus}\n data:${JSON.stringify(data)}`);
|
||||
this.onTaskError(data.responseStatus, response.data);
|
||||
this._taskError?.(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
public onError(response: IHttpResponse): void {
|
||||
let message = response.message;
|
||||
let statusCode = response.statusCode;
|
||||
console.log(`http response error\n name:${this.name}\n url:${this.url}\n message:${message}\n statusCode:${statusCode}`);
|
||||
this.onHttpError(message);
|
||||
this._httpError?.(response.data);
|
||||
}
|
||||
|
||||
/** 任务完成 子类必须实现 */
|
||||
protected abstract onTaskComplete(data: any): void;
|
||||
/** 任务错误 子类实现 */
|
||||
protected onTaskError(errcode: number, data: any): void {
|
||||
|
||||
};
|
||||
/** http错误 子类实现 */
|
||||
protected onHttpError(message: string): void {
|
||||
|
||||
};
|
||||
}
|
||||
9
demo/assets/script/Net/NetTaskBase.ts.meta
Normal file
9
demo/assets/script/Net/NetTaskBase.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8c6e5935-bded-41fb-9df8-21dd76f82186",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
28
demo/assets/script/Net/header.ts
Normal file
28
demo/assets/script/Net/header.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-28
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
export interface INetResponse {
|
||||
responseStatus: number;
|
||||
packet: any;
|
||||
}
|
||||
|
||||
export interface IServerInfo {
|
||||
/** 名称 */
|
||||
name: string,
|
||||
/** http地址 */
|
||||
url: string,
|
||||
/** 应用id */
|
||||
appid: string,
|
||||
/** 密钥 */
|
||||
secret: string,
|
||||
}
|
||||
|
||||
export const ServerConfig: IServerInfo = {
|
||||
name: "dev-gblnn",
|
||||
url: "",
|
||||
appid: "",
|
||||
secret: "",
|
||||
}
|
||||
9
demo/assets/script/Net/header.ts.meta
Normal file
9
demo/assets/script/Net/header.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cad69694-c4c3-4d7d-b490-26e5ebd1141e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Net/task.meta
Normal file
9
demo/assets/script/Net/task.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "35d378d9-a2a5-407b-afec-9c7e55e408cf",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
44
demo/assets/script/Net/task/NetAuth.ts
Normal file
44
demo/assets/script/Net/task/NetAuth.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-05-20
|
||||
* @Description: 新版鉴权接口
|
||||
*/
|
||||
import { kunpo } from "../../header";
|
||||
import { INetResponse } from "../header";
|
||||
import { NetHelper } from "../NetHelper";
|
||||
import { NetTaskBase } from "../NetTaskBase";
|
||||
|
||||
interface IAuthResponse extends INetResponse {
|
||||
token: string;
|
||||
uid: number; // 用户id
|
||||
sdkId: string;
|
||||
channel: number;
|
||||
/** 注册渠道 */
|
||||
regChannel: number;
|
||||
}
|
||||
|
||||
/** 账户认证 */
|
||||
export class NetAuth extends NetTaskBase {
|
||||
name: string = "NetSocketAuth";
|
||||
url: string = '/api/game/auth';
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
let data = {
|
||||
channel: 25,
|
||||
token: kunpo.Platform.deviceId,
|
||||
openid: kunpo.Platform.deviceId,
|
||||
sdkChannel: 25,
|
||||
distinctId: ''
|
||||
}
|
||||
NetHelper.send(this.url, data, this);
|
||||
}
|
||||
|
||||
protected onTaskComplete(data: IAuthResponse): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
demo/assets/script/Net/task/NetAuth.ts.meta
Normal file
9
demo/assets/script/Net/task/NetAuth.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "10bbcb28-912a-4ba5-9bfd-a21668ee8763",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Socket.meta
Normal file
9
demo/assets/script/Socket.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "4d07e39e-8369-4331-890e-80d2472a6b52",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
26
demo/assets/script/Socket/ProtoInfos.ts
Normal file
26
demo/assets/script/Socket/ProtoInfos.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-08-06
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { protocol } from "../header";
|
||||
import { com } from "./proto/proto";
|
||||
|
||||
export interface ProtocolFormat {
|
||||
request: number;
|
||||
response: number;
|
||||
desc: string;
|
||||
}
|
||||
|
||||
export class ProtoInfos {
|
||||
public encodeData<T>(protoCode: number, data: string): ArrayBuffer {
|
||||
return protocol.CommonMessage.encode({ cmdCode: 0, protocolId: protoCode, responseStatus: 1, msgId: 1, msg: data }).finish();
|
||||
}
|
||||
|
||||
/** 前四个字节是长度信息 */
|
||||
public decodeData(buffer: Uint8Array | ArrayBufferLike): com.kunpo.proto.CommonMessage {
|
||||
let response_buffer = new Uint8Array(buffer);
|
||||
return protocol.CommonMessage.decode(response_buffer);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Socket/ProtoInfos.ts.meta
Normal file
9
demo/assets/script/Socket/ProtoInfos.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d686884b-fad9-4a58-8781-5bac09b47041",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/Socket/proto.meta
Normal file
9
demo/assets/script/Socket/proto.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "6961d096-69d0-4c14-9fd7-fa98afc5357e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
53
demo/assets/script/Socket/proto/proto.d.ts
vendored
Normal file
53
demo/assets/script/Socket/proto/proto.d.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import * as $protobuf from "protobufjs";
|
||||
import Long = require("long");
|
||||
export namespace com {
|
||||
|
||||
namespace kunpo {
|
||||
|
||||
namespace proto {
|
||||
|
||||
interface ICommonMessage {
|
||||
cmdCode?: (number|null);
|
||||
protocolId?: (number|null);
|
||||
data?: (Uint8Array|null);
|
||||
responseStatus?: (number|null);
|
||||
msg?: (string|null);
|
||||
msgId?: (number|null);
|
||||
}
|
||||
|
||||
class CommonMessage implements ICommonMessage {
|
||||
constructor(p?: com.kunpo.proto.ICommonMessage);
|
||||
public cmdCode: number;
|
||||
public protocolId: number;
|
||||
public data: Uint8Array;
|
||||
public responseStatus: number;
|
||||
public msg: string;
|
||||
public msgId: number;
|
||||
public static encode(m: com.kunpo.proto.ICommonMessage, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): com.kunpo.proto.CommonMessage;
|
||||
}
|
||||
|
||||
namespace test {
|
||||
|
||||
interface IUserInfo {
|
||||
userId?: (number|null);
|
||||
userName?: (string|null);
|
||||
nickName?: (string|null);
|
||||
level?: (number|null);
|
||||
createTime?: (number|null);
|
||||
}
|
||||
|
||||
class UserInfo implements IUserInfo {
|
||||
constructor(p?: com.kunpo.proto.test.IUserInfo);
|
||||
public userId: number;
|
||||
public userName: string;
|
||||
public nickName: string;
|
||||
public level: number;
|
||||
public createTime: number;
|
||||
public static encode(m: com.kunpo.proto.test.IUserInfo, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): com.kunpo.proto.test.UserInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/Socket/proto/proto.d.ts.meta
Normal file
9
demo/assets/script/Socket/proto/proto.d.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1508669b-41ae-40e9-b24e-c4af0f01120d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
1
demo/assets/script/Socket/proto/proto.js
Normal file
1
demo/assets/script/Socket/proto/proto.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var $protobuf=protobuf;var $Reader=$protobuf.Reader,$Writer=$protobuf.Writer,$util=$protobuf.util;var $root=$protobuf.roots["default"]||($protobuf.roots["default"]={});$root.com=function(){var com={};com.kunpo=function(){var kunpo={};kunpo.proto=function(){var proto={};proto.CommonMessage=function(){function CommonMessage(p){if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)this[ks[i]]=p[ks[i]]}CommonMessage.prototype.cmdCode=0;CommonMessage.prototype.protocolId=0;CommonMessage.prototype.data=$util.newBuffer([]);CommonMessage.prototype.responseStatus=0;CommonMessage.prototype.msg="";CommonMessage.prototype.msgId=0;CommonMessage.encode=function encode(m,w){if(!w)w=$Writer.create();if(m.cmdCode!=null&&Object.hasOwnProperty.call(m,"cmdCode"))w.uint32(8).int32(m.cmdCode);if(m.protocolId!=null&&Object.hasOwnProperty.call(m,"protocolId"))w.uint32(16).int32(m.protocolId);if(m.data!=null&&Object.hasOwnProperty.call(m,"data"))w.uint32(26).bytes(m.data);if(m.responseStatus!=null&&Object.hasOwnProperty.call(m,"responseStatus"))w.uint32(32).sint32(m.responseStatus);if(m.msg!=null&&Object.hasOwnProperty.call(m,"msg"))w.uint32(42).string(m.msg);if(m.msgId!=null&&Object.hasOwnProperty.call(m,"msgId"))w.uint32(48).int32(m.msgId);return w};CommonMessage.decode=function decode(r,l){if(!(r instanceof $Reader))r=$Reader.create(r);var c=l===undefined?r.len:r.pos+l,m=new $root.com.kunpo.proto.CommonMessage;while(r.pos<c){var t=r.uint32();switch(t>>>3){case 1:{m.cmdCode=r.int32();break}case 2:{m.protocolId=r.int32();break}case 3:{m.data=r.bytes();break}case 4:{m.responseStatus=r.sint32();break}case 5:{m.msg=r.string();break}case 6:{m.msgId=r.int32();break}default:r.skipType(t&7);break}}return m};return CommonMessage}();proto.test=function(){var test={};test.UserInfo=function(){function UserInfo(p){if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)this[ks[i]]=p[ks[i]]}UserInfo.prototype.userId=0;UserInfo.prototype.userName="";UserInfo.prototype.nickName="";UserInfo.prototype.level=0;UserInfo.prototype.createTime=$util.Long?$util.Long.fromBits(0,0,false):0;UserInfo.encode=function encode(m,w){if(!w)w=$Writer.create();if(m.userId!=null&&Object.hasOwnProperty.call(m,"userId"))w.uint32(8).int32(m.userId);if(m.userName!=null&&Object.hasOwnProperty.call(m,"userName"))w.uint32(18).string(m.userName);if(m.nickName!=null&&Object.hasOwnProperty.call(m,"nickName"))w.uint32(26).string(m.nickName);if(m.level!=null&&Object.hasOwnProperty.call(m,"level"))w.uint32(32).int32(m.level);if(m.createTime!=null&&Object.hasOwnProperty.call(m,"createTime"))w.uint32(40).int64(m.createTime);return w};UserInfo.decode=function decode(r,l){if(!(r instanceof $Reader))r=$Reader.create(r);var c=l===undefined?r.len:r.pos+l,m=new $root.com.kunpo.proto.test.UserInfo;while(r.pos<c){var t=r.uint32();switch(t>>>3){case 1:{m.userId=r.int32();break}case 2:{m.userName=r.string();break}case 3:{m.nickName=r.string();break}case 4:{m.level=r.int32();break}case 5:{m.createTime=r.int64();break}default:r.skipType(t&7);break}}return m};return UserInfo}();return test}();return proto}();return kunpo}();return com}();module.exports=$root;
|
||||
9
demo/assets/script/Socket/proto/proto.js.meta
Normal file
9
demo/assets/script/Socket/proto/proto.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "javascript",
|
||||
"imported": true,
|
||||
"uuid": "e777207e-c569-4375-838f-aeb51ff06a30",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI.meta
Normal file
9
demo/assets/script/UI.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "ce0bb648-7b41-4640-be24-62109ab2ad59",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics.meta
Normal file
9
demo/assets/script/UI/Basics.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "eae449a2-8b5c-42ff-8917-888937877f85",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Common.meta
Normal file
9
demo/assets/script/UI/Basics/Common.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e7f088c6-38b1-4278-8ba4-4f7de40afb3d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
126
demo/assets/script/UI/Basics/Common/AlertWindow.ts
Normal file
126
demo/assets/script/UI/Basics/Common/AlertWindow.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import { cc, fgui, kunpo } from '../../../header';
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
interface WindowData {
|
||||
content: string;
|
||||
title?: string;
|
||||
okTitle?: string;
|
||||
cancelTitle?: string;
|
||||
showClose?: boolean; // 显示关闭按钮
|
||||
emptyAreaClose?: boolean; // 点击空白区域关闭
|
||||
align?: cc.HorizontalTextAlignment; // 内容文本水平对齐方式 default:居中对齐
|
||||
leading?: number;//行距
|
||||
okNotClose?: boolean; // 点击OK按钮时不关闭本界面
|
||||
cancelNotClose?: boolean; // 点击取消按钮时不关闭本界面
|
||||
complete?: () => void; // 确定按钮的回调
|
||||
cancel?: () => void; // 取消按钮的回调
|
||||
close?: () => void; // 关闭界面的回调 (只有点击关闭按钮和空白位置关闭时才会触发)
|
||||
}
|
||||
|
||||
|
||||
@uiclass("Window", "Basics", "AlertWindow")
|
||||
export class AlertWindow extends kunpo.Window {
|
||||
@uiprop private bg: fgui.GLoader;
|
||||
@uiprop private lab_title: fgui.GTextField;
|
||||
@uiprop private lab_content: fgui.GTextField;
|
||||
@uiprop private btn_close: fgui.GButton;
|
||||
@uiprop private btn_ok: fgui.GButton;
|
||||
@uiprop private btn_cancel: fgui.GButton;
|
||||
|
||||
private _isEmptyAreaClose: boolean = false;
|
||||
private _window_data: WindowData = null;
|
||||
|
||||
private _complete: () => void;
|
||||
private _cancel: () => void;
|
||||
private _closeFunc: () => void;
|
||||
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Full;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
}
|
||||
|
||||
protected onAdapted() {
|
||||
}
|
||||
|
||||
protected onShow(data: WindowData): void {
|
||||
this._complete = data.complete;
|
||||
this._cancel = data.cancel;
|
||||
this._closeFunc = data.close;
|
||||
this._window_data = data;
|
||||
|
||||
// 标题
|
||||
if (data.title) {
|
||||
this.lab_title.text = data.title;
|
||||
} else {
|
||||
this.lab_title.visible = false;
|
||||
}
|
||||
|
||||
// 关闭按钮
|
||||
this.btn_close.visible = !!data.showClose;
|
||||
|
||||
// 空白位置关闭标记
|
||||
this._isEmptyAreaClose = !!data.emptyAreaClose;
|
||||
|
||||
// 确定按钮
|
||||
if (data.okTitle) {
|
||||
this.btn_ok.title = data.okTitle;
|
||||
} else {
|
||||
this.btn_ok.visible = false;
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
if (data.cancelTitle) {
|
||||
this.btn_cancel.text = data.cancelTitle;
|
||||
} else {
|
||||
this.btn_cancel.visible = false;
|
||||
}
|
||||
|
||||
this.lab_content.text = data.content;
|
||||
let align = typeof data.align == "number" ? data.align : cc.Label.HorizontalAlign.CENTER;
|
||||
let leading = typeof data.leading == "number" ? data.leading : this.lab_content.leading;
|
||||
this.lab_content.align = align;
|
||||
this.lab_content.leading = leading;
|
||||
this.lab_content.ensureSizeCorrect();
|
||||
|
||||
// 限制背景框高度
|
||||
if (this.bg.height < 500) {
|
||||
this.bg.height = 500;
|
||||
}
|
||||
|
||||
// 确定取消按钮位置调整
|
||||
if (this.btn_ok.visible && !this.btn_cancel.visible) {
|
||||
this.btn_ok.x = this.bg.x + (this.bg.width - this.btn_ok.width) * 0.5;
|
||||
} else if (this.btn_cancel.visible && !this.btn_ok.visible) {
|
||||
this.btn_cancel.x = this.bg.x + (this.bg.width - this.btn_cancel.width) * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
if (this._isEmptyAreaClose) {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
this._closeFunc && this._closeFunc();
|
||||
}
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
this._closeFunc && this._closeFunc();
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnOk(): void {
|
||||
!this._window_data.okNotClose && kunpo.WindowManager.closeWindow(this.name);
|
||||
this._complete && this._complete();
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCancel(): void {
|
||||
!this._window_data.cancelNotClose && kunpo.WindowManager.closeWindow(this.name);
|
||||
this._cancel && this._cancel();
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Common/AlertWindow.ts.meta
Normal file
9
demo/assets/script/UI/Basics/Common/AlertWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "434791ba-2680-4643-aea0-ecf8bebc2ff9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
13
demo/assets/script/UI/Basics/Common/LoadUIWindow.ts
Normal file
13
demo/assets/script/UI/Basics/Common/LoadUIWindow.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
import { kunpo } from '../../../header';
|
||||
const { uiclass, uiprop } = kunpo._uidecorator;
|
||||
|
||||
/** UI界面资源加载等待界面 */
|
||||
@uiclass("Wait", "Basics", "LoadUIWindow")
|
||||
export class LoadUIWindow extends kunpo.Window {
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Full;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Common/LoadUIWindow.ts.meta
Normal file
9
demo/assets/script/UI/Basics/Common/LoadUIWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0b7e1ba3-9877-45ea-9d1b-71115f04744b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
86
demo/assets/script/UI/Basics/Common/ToastWindow.ts
Normal file
86
demo/assets/script/UI/Basics/Common/ToastWindow.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* @Description: 通用Toast提示
|
||||
* @Author: Gongxh
|
||||
* @Date: 2021-04-27 09:20:14
|
||||
*/
|
||||
|
||||
import { cc, fgui, kunpo } from "../../../header";
|
||||
interface ToastData {
|
||||
text: string, // 文本
|
||||
duration?: number, // 持续时间
|
||||
swallowTouch?: boolean, // 吞噬touch事件
|
||||
showMask?: boolean, // 显示遮罩
|
||||
align?: cc.HorizontalTextAlignment // 对齐方式
|
||||
}
|
||||
|
||||
const { uiclass, uiprop } = kunpo._uidecorator;
|
||||
@uiclass("Toast", "Basics", "ToastWindow")
|
||||
export class ToastWindow extends kunpo.Window {
|
||||
@uiprop private toast: fgui.GComponent;
|
||||
@uiprop private labTips: fgui.GTextField;
|
||||
@uiprop private bgMask: fgui.GGraph;
|
||||
|
||||
private _showTransition: fgui.Transition;
|
||||
private _hideTransition: fgui.Transition;
|
||||
|
||||
private _swallowTouch: boolean = false; // 吞噬touch事件
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Full;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
this.bgAlpha = 0;
|
||||
|
||||
this._showTransition = this.toast.getTransition("show");
|
||||
this._hideTransition = this.toast.getTransition("hide");
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数说明
|
||||
* @param {string} data.text toast文本
|
||||
* @param {number} data.duration 存在时间( < 0)为常驻 default 2秒
|
||||
* @param {boolean} data.swallowTouch 吞噬touch事件 default 不吞噬
|
||||
* @param {boolean} data.showMask 是否显示半透明遮罩 (当显示遮罩时,必定吞噬touch事件) default 不显示
|
||||
* @param {cc.HorizontalTextAlignment} data.align 横向文本对齐方式 default 居中对齐
|
||||
*/
|
||||
protected onShow(data: ToastData): void {
|
||||
this.bgMask.visible = data.showMask;
|
||||
this._swallowTouch = data.showMask ? true : (data.swallowTouch || false);
|
||||
this.opaque = this._swallowTouch;
|
||||
// if (this._swallowTouch) {
|
||||
// this.node.on(cc.Node.EventType.TOUCH_END, () => { }, this.node);
|
||||
// } else {
|
||||
// this.node.targetOff(this.node);
|
||||
// }
|
||||
|
||||
this.labTips.text = data.text;
|
||||
|
||||
let align = data.align || cc.HorizontalTextAlignment.CENTER;
|
||||
this.labTips.align = align;
|
||||
this.labTips.autoSize = fgui.AutoSizeType.Both;
|
||||
this.labTips.ensureSizeCorrect();
|
||||
// 调整文本尺寸
|
||||
let maxWidht = 504;
|
||||
if (this.labTips.width > maxWidht) {
|
||||
this.labTips.autoSize = fgui.AutoSizeType.Height;
|
||||
this.labTips.width = maxWidht;
|
||||
this.labTips.ensureSizeCorrect();
|
||||
} else {
|
||||
this.labTips.autoSize = fgui.AutoSizeType.Both;
|
||||
}
|
||||
|
||||
|
||||
this._showTransition.stop(true);
|
||||
this._hideTransition.stop(true);
|
||||
this._showTransition.play(() => {
|
||||
let duration = data.duration || 2.0
|
||||
if (duration > 0) {
|
||||
this._hideTransition.play(() => {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}, 1, duration);
|
||||
}
|
||||
}, 1, 0);
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Common/ToastWindow.ts.meta
Normal file
9
demo/assets/script/UI/Basics/Common/ToastWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "993ce544-0214-4132-ba2c-2d464aa39257",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Header.meta
Normal file
9
demo/assets/script/UI/Basics/Header.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "d53b1983-3f1e-4e89-8114-88dfcc95075f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
31
demo/assets/script/UI/Basics/Header/WindowHeader.ts
Normal file
31
demo/assets/script/UI/Basics/Header/WindowHeader.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-01-12
|
||||
* @Description:
|
||||
*/
|
||||
import { fgui, kunpo } from '../../../header';
|
||||
const { uiheader, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiheader("Basics", "WindowHeader")
|
||||
export class WindowHeader extends kunpo.WindowHeader {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
|
||||
this.btn_close.onClick(() => {
|
||||
kunpo.log("WindowHeader btn_close");
|
||||
}, this);
|
||||
}
|
||||
|
||||
protected onShow(window: kunpo.Window, userdata?: any): void {
|
||||
kunpo.log("WindowHeader onShow:");
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("WindowHeader onHide");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("WindowHeader onClose");
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Basics/Header/WindowHeader.ts.meta
Normal file
9
demo/assets/script/UI/Basics/Header/WindowHeader.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bcb15a03-27d3-46b7-9f6b-53040cd6bbcb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
32
demo/assets/script/UI/Basics/Header/WindowHeader2.ts
Normal file
32
demo/assets/script/UI/Basics/Header/WindowHeader2.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-01-12
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from '../../../header';
|
||||
const { uiheader, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiheader("Basics", "WindowHeader2")
|
||||
export class WindowHeader2 extends kunpo.WindowHeader {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
|
||||
this.btn_close.onClick(() => {
|
||||
kunpo.log("WindowHeader btn_close");
|
||||
}, this);
|
||||
}
|
||||
|
||||
protected onShow(window: kunpo.Window, userdata?: any): void {
|
||||
kunpo.log("WindowHeader onShow:");
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("WindowHeader onHide");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("WindowHeader onClose");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2a956cae-8688-40b9-89d3-86407a1f3631",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/CloseAllWindow.ts.meta
Normal file
9
demo/assets/script/UI/CloseAllWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c59e1239-0afc-4df7-b1e9-b7b968b48709",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/CloseOneWindow.ts.meta
Normal file
9
demo/assets/script/UI/CloseOneWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ecbe9481-c878-4ffd-863c-d9db4641ef2a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Components.meta
Normal file
9
demo/assets/script/UI/Components.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "3896f27e-b6e5-4757-a872-8a1b925a24f3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Condition.meta
Normal file
9
demo/assets/script/UI/Condition.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "aa136c25-aeef-4b18-9051-246cf5cd1176",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
82
demo/assets/script/UI/Condition/ConditionWindow.ts
Normal file
82
demo/assets/script/UI/Condition/ConditionWindow.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-17
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { ConditionType } from "../../condition/ConditionType";
|
||||
import { DataHelper } from "../../Data/DataHelper";
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Condition", "ConditionWindow")
|
||||
export class ConditionWindow extends kunpo.Window {
|
||||
@uiprop reddot1: fgui.GComponent;
|
||||
@uiprop reddot2: fgui.GComponent;
|
||||
|
||||
@uiprop btn_condition1: fgui.GButton;
|
||||
@uiprop btn_condition2: fgui.GButton;
|
||||
@uiprop btn_condition3: fgui.GButton;
|
||||
@uiprop btn_condition4: fgui.GButton;
|
||||
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideOne;
|
||||
|
||||
/** 初始化注册的所有条件 (临时写到这里,应该放到项目数据初始化之后 调用这个方法) */
|
||||
kunpo.ConditionManager.initCondition();
|
||||
|
||||
this.btn_condition1.title = `条件1: ${DataHelper.getValue("condition1", true)}`;
|
||||
this.btn_condition2.title = `条件2: ${DataHelper.getValue("condition2", true)}`;
|
||||
this.btn_condition3.title = `条件3: ${DataHelper.getValue("condition3", true)}`;
|
||||
this.btn_condition4.title = `条件4: ${DataHelper.getValue("condition4", true)}`;
|
||||
|
||||
/** 任意一个满足 显示节点 */
|
||||
new kunpo.ConditionAnyNode(this.reddot1, ConditionType.Condition1, ConditionType.Condition2, ConditionType.Condition3, ConditionType.Condition4);
|
||||
|
||||
/** 所有条件都满足 显示节点 */
|
||||
new kunpo.ConditionAllNode(this.reddot2, ConditionType.Condition1, ConditionType.Condition2, ConditionType.Condition3, ConditionType.Condition4);
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCondition1(): void {
|
||||
const value = DataHelper.getValue("condition1", true);
|
||||
DataHelper.setValue("condition1", !value);
|
||||
|
||||
this.btn_condition1.title = `条件1: ${!value}`;
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCondition2(): void {
|
||||
const value = DataHelper.getValue("condition2", true);
|
||||
DataHelper.setValue("condition2", !value);
|
||||
this.btn_condition2.title = `条件2: ${!value}`;
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCondition3(): void {
|
||||
const value = DataHelper.getValue("condition3", true);
|
||||
DataHelper.setValue("condition3", !value);
|
||||
this.btn_condition3.title = `条件3: ${!value}`;
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCondition4(): void {
|
||||
const value = DataHelper.getValue("condition4", true);
|
||||
DataHelper.setValue("condition4", !value);
|
||||
this.btn_condition4.title = `条件4: ${!value}`;
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Condition/ConditionWindow.ts.meta
Normal file
9
demo/assets/script/UI/Condition/ConditionWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "addf31f0-70a4-4238-8b2f-c9971873eaa9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/ConditionWindow.ts.meta
Normal file
9
demo/assets/script/UI/ConditionWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d73deef4-cfcf-4381-8ff4-afee0930c850",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Game.meta
Normal file
9
demo/assets/script/UI/Game.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "d0871aff-1fb9-4f5b-96d6-dc008b804d82",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/HideAllWindow.ts.meta
Normal file
9
demo/assets/script/UI/HideAllWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1a445c8e-e43f-46b8-8483-c721a76d716e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/HideOneWindow.ts.meta
Normal file
9
demo/assets/script/UI/HideOneWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "34d16557-9a49-4995-8331-123fe8e47e79",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
103
demo/assets/script/UI/HomeWindow.ts
Normal file
103
demo/assets/script/UI/HomeWindow.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-11
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { AssetPool } from "kunpocc-assets";
|
||||
import { cc, fgui, kunpo, KunpoAssets } from "../header";
|
||||
const { uiclass, uiprop, uiclick, uicontrol, uitransition } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Home", "HomeWindow")
|
||||
export class HomeWindow extends kunpo.Window {
|
||||
@uicontrol private status: fgui.Controller;
|
||||
@uicontrol private sta2: fgui.Controller;
|
||||
|
||||
@uitransition private t0: fgui.Transition;
|
||||
@uitransition private t1: fgui.Transition;
|
||||
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.CloseAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("HomeWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickUI(): void {
|
||||
kunpo.WindowManager.showWindow("UIBaseWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onSocketWindow(): void {
|
||||
kunpo.WindowManager.showWindow("SocketTestWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCondition(): void {
|
||||
kunpo.WindowManager.showWindow("ConditionWindow");
|
||||
}
|
||||
|
||||
|
||||
@uiclick
|
||||
private onClickMiniGame(): void {
|
||||
if (kunpo.Platform.isWX || kunpo.Platform.isAlipay || kunpo.Platform.isBytedance) {
|
||||
kunpo.WindowManager.showWindow("MiniGameWindow");
|
||||
} else {
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "当前平台不是 微信/阿里/抖音小游戏" })
|
||||
}
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnHotUpdate(): void {
|
||||
if (kunpo.Platform.isNativeMobile) {
|
||||
kunpo.WindowManager.showWindow("HotUpdateWindow");
|
||||
} else {
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "只有原生平台才支持热更新" })
|
||||
}
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickLoadBuffer(): void {
|
||||
let paths: KunpoAssets.IAssetConfig[] = [
|
||||
{ path: "config/buffer", type: cc.BufferAsset },
|
||||
];
|
||||
let loader = new KunpoAssets.AssetLoader("load");
|
||||
loader.start({
|
||||
configs: paths,
|
||||
complete: () => {
|
||||
kunpo.log("加载成功");
|
||||
|
||||
let basic = AssetPool.get<cc.BufferAsset>("config/buffer/basic");
|
||||
kunpo.log("basic", JSON.stringify(kunpo.Binary.toJson(basic.buffer())));
|
||||
|
||||
let dict = AssetPool.get<cc.BufferAsset>("config/buffer/dict");
|
||||
kunpo.log("dict", JSON.stringify(kunpo.Binary.toJson(dict.buffer())));
|
||||
|
||||
let listDict = AssetPool.get<cc.BufferAsset>("config/buffer/list_dict");
|
||||
kunpo.log("list_dict", JSON.stringify(kunpo.Binary.toJson(listDict.buffer())));
|
||||
|
||||
let aaa = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: 4,
|
||||
e: 5,
|
||||
};
|
||||
kunpo.log("aaa", JSON.stringify(kunpo.Binary.toJson(aaa)));
|
||||
},
|
||||
fail: (msg: string, err: Error) => {
|
||||
kunpo.log("加载失败", msg, err);
|
||||
},
|
||||
progress: (percent: number) => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getHeaderInfo(): kunpo.WindowHeaderInfo {
|
||||
return kunpo.WindowHeaderInfo.create("WindowHeader", "aaa");
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/HomeWindow.ts.meta
Normal file
9
demo/assets/script/UI/HomeWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a82b56f3-6cfa-4fd1-a090-44137d7e62d4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/HotUpdate.meta
Normal file
9
demo/assets/script/UI/HotUpdate.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "d1a31574-d301-493b-9a96-b3bfcba60ba9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
139
demo/assets/script/UI/HotUpdate/HotUpdateWindow.ts
Normal file
139
demo/assets/script/UI/HotUpdate/HotUpdateWindow.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-04-18
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { HotUpdateCode, log } from "kunpocc";
|
||||
import { fgui, kunpo } from "../../header";
|
||||
import { SDKHelper } from "../../Helper/SDKHelper";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "HotUpdate", "HotUpdateWindow")
|
||||
export class HotUpdateWindow extends kunpo.Window {
|
||||
@uiprop lab_version: fgui.GTextField = null;
|
||||
@uiprop lab_desc: fgui.GTextField = null;
|
||||
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
let version = KunpoSDK.SDKHelper.getInstance().getVersionCode()
|
||||
kunpo.HotUpdateManager.getInstance().init(SDKHelper.manifestUrl, version);
|
||||
this.lab_version.text = `当前资源版本号:` + kunpo.HotUpdateManager.getInstance().resVersion;
|
||||
|
||||
this.lab_desc.text = "点击检查更新按钮,检查是否有新版本 或者 点击更新按钮,直接更新 hahaha";
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("CloseAllWindow onClose");
|
||||
}
|
||||
|
||||
private refreshTips(tips: string, touchable: boolean = false): void {
|
||||
this.lab_desc.text = tips;
|
||||
this.touchable = touchable;
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onCheckUpdate(): void {
|
||||
this.refreshTips("正在检查更新... 请稍后", false);
|
||||
|
||||
kunpo.HotUpdateManager.getInstance().checkUpdate().then((res: kunpo.ICheckUpdatePromiseResult) => {
|
||||
kunpo.log("发现热更新:", JSON.stringify(res));
|
||||
this.refreshTips(`发现热更新 需更新大小:${Math.floor(res.size / 1024 * 1000) * 0.001}MB`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `发现热更新 需更新大小:${Math.floor(res.size / 1024 * 1000) * 0.001}MB`,
|
||||
okTitle: "更新",
|
||||
cancelTitle: "取消",
|
||||
complete: () => {
|
||||
this.startUpdate(true);
|
||||
},
|
||||
cancel: () => {
|
||||
kunpo.log("取消");
|
||||
},
|
||||
});
|
||||
}).catch((res: any) => {
|
||||
log("检查热更新出错了", JSON.stringify(res));
|
||||
if (res.code == HotUpdateCode.LatestVersion) {
|
||||
this.refreshTips(`已经是最新版本了`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `已经是最新版本了`,
|
||||
okTitle: "知道了",
|
||||
});
|
||||
} else {
|
||||
this.refreshTips(`出错了 code:${res.code} message:${res.message}`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `出错了 code:${res.code} message:${res.message}`,
|
||||
okTitle: "知道了",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onStartUpdate(): void {
|
||||
this.startUpdate(false);
|
||||
}
|
||||
|
||||
private startUpdate(skipCheck: boolean = false): void {
|
||||
this.refreshTips(`正在更新... 请稍后`, false);
|
||||
|
||||
kunpo.HotUpdateManager.getInstance().startUpdate({
|
||||
skipCheck: skipCheck,
|
||||
progress: (kb: number, total: number) => {
|
||||
kunpo.log("热更新进度", kb, total);
|
||||
this.refreshTips(`正在更新... 请稍后 ${Math.floor(kb / total * 100)}% `, false);
|
||||
},
|
||||
complete: (code: HotUpdateCode, message: string) => {
|
||||
kunpo.log("热更新完成", code, message);
|
||||
if (code == HotUpdateCode.LatestVersion) {
|
||||
this.refreshTips(`已经是最新版了 不需要更新`, true);
|
||||
// 已经是最新版了
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `已经是最新版了 不需要更新`,
|
||||
okTitle: "知道了",
|
||||
});
|
||||
} else if (code == HotUpdateCode.UpdateFailed) {
|
||||
this.refreshTips(`更新失败了 code:${code} message:${message}`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `热更新失败了 是否重试失败的资源 message:${message}`,
|
||||
okTitle: "重试",
|
||||
cancelTitle: "取消",
|
||||
complete: () => {
|
||||
kunpo.HotUpdateManager.getInstance().retryUpdate();
|
||||
},
|
||||
cancel: () => {
|
||||
kunpo.log("取消");
|
||||
},
|
||||
});
|
||||
} else if (code == HotUpdateCode.LoadVersionFailed || code == HotUpdateCode.ParseVersionFailed) {
|
||||
this.refreshTips(`更新失败了 code:${code} message:${message}`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `更新失败了 code:${code} message:${message} 可以选择跳过热更新`,
|
||||
okTitle: "知道了",
|
||||
});
|
||||
} else {
|
||||
this.refreshTips(`更新失败了 code:${code} message:${message}`, true);
|
||||
kunpo.WindowManager.showWindowIm("AlertWindow", {
|
||||
title: "提示",
|
||||
content: `热更新失败了, 根据code的值,看是重启游戏,还是跳过更新 message:${message}`,
|
||||
okTitle: "知道了",
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/HotUpdate/HotUpdateWindow.ts.meta
Normal file
9
demo/assets/script/UI/HotUpdate/HotUpdateWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "25c11bf0-c7a2-4b27-8172-22a0fba89114",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/MiniGame.meta
Normal file
9
demo/assets/script/UI/MiniGame.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "fc664f7f-0b4b-406b-8240-8c6b974b3c38",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
122
demo/assets/script/UI/MiniGame/MiniGameWindow.ts
Normal file
122
demo/assets/script/UI/MiniGame/MiniGameWindow.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-04-12
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
let IsInitAds = false;
|
||||
let AdId = "";
|
||||
|
||||
let IsInitPay = false;
|
||||
|
||||
// private static readonly wechat_ads_id: string = "adunit-c9b71a32c0fb3d3d";
|
||||
// private static readonly byte_ads_id: string = "592b3kadh11b27p317";
|
||||
// private static readonly aliy_ads_id: string = "ad_tiny_2021004170666283_202410082200196957";
|
||||
|
||||
@uiclass("Window", "MiniGame", "MiniGameWindow")
|
||||
export class MiniGameWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
@uiprop lab_adid: fgui.GTextInput;
|
||||
@uiprop lab_payQuantity: fgui.GTextInput;
|
||||
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("MiniGameWindow onShow:", userdata);
|
||||
this.lab_adid.text = "592b3kadh11b27p317";
|
||||
|
||||
if (IsInitAds) {
|
||||
this.lab_adid.text = AdId;
|
||||
this.lab_adid.touchable = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("CloseAllWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnInitAds(): void {
|
||||
if (!IsInitAds) {
|
||||
if (this.lab_adid.text) {
|
||||
kunpo.MiniHelper.ad().init(this.lab_adid.text);
|
||||
IsInitAds = true;
|
||||
|
||||
kunpo.MiniHelper.ad().showAds({
|
||||
success: () => {
|
||||
kunpo.log("广告显示成功");
|
||||
},
|
||||
fail: (errCode, errMsg) => {
|
||||
kunpo.log("广告显示失败", errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
kunpo.MiniHelper.ad().showAds({
|
||||
success: () => {
|
||||
kunpo.log("广告显示成功");
|
||||
},
|
||||
fail: (errCode, errMsg) => {
|
||||
kunpo.log("广告显示失败", errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@uiclick
|
||||
private onClickBtnPay(): void {
|
||||
if (!IsInitPay) {
|
||||
let payQuantity = parseInt(this.lab_payQuantity.text);
|
||||
if (isNaN(payQuantity) || payQuantity <= 0) {
|
||||
kunpo.log("请输入正确的值");
|
||||
return;
|
||||
} else {
|
||||
console.log("初始化支付", payQuantity);
|
||||
kunpo.MiniHelper.pay().init("1450135093", payQuantity);
|
||||
IsInitPay = true;
|
||||
}
|
||||
kunpo.MiniHelper.pay().pay({
|
||||
rmb: 1,
|
||||
orderId: `order_${kunpo.Time.now()}`,
|
||||
shopId: "1234",
|
||||
shopName: "测试商品",
|
||||
extraInfo: {
|
||||
"test": "test"
|
||||
},
|
||||
success: () => {
|
||||
kunpo.log("支付调用成功");
|
||||
},
|
||||
fail: (res) => {
|
||||
kunpo.log("支付调用失败", res.errCode, res.errMsg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
kunpo.MiniHelper.pay().pay({
|
||||
rmb: 1,
|
||||
orderId: kunpo.Time.now() + "",
|
||||
shopId: "1234",
|
||||
shopName: "测试商品",
|
||||
extraInfo: {
|
||||
"test": "test"
|
||||
},
|
||||
success: () => {
|
||||
kunpo.log("支付调用成功");
|
||||
},
|
||||
fail: (res) => {
|
||||
kunpo.log("支付调用失败", res.errCode, res.errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/MiniGame/MiniGameWindow.ts.meta
Normal file
9
demo/assets/script/UI/MiniGame/MiniGameWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1b9f360b-3ad4-4eb1-9092-1fdab6270a16",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/PopWindow.ts.meta
Normal file
9
demo/assets/script/UI/PopWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5377ee34-e10a-4312-9e6e-d4c3e242a880",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/PopWindowHeader1.ts.meta
Normal file
9
demo/assets/script/UI/PopWindowHeader1.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a7ecfd55-c16b-4dbf-9451-e11dd2bbdb40",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/PopWindowHeader2.ts.meta
Normal file
9
demo/assets/script/UI/PopWindowHeader2.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d2f063c7-ff7e-44c7-85bb-9ca5f4f452e4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Socket.meta
Normal file
9
demo/assets/script/UI/Socket.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "dd0d6cdf-59a4-446e-840b-ddd9c17db824",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
83
demo/assets/script/UI/Socket/SocketTestWindow.ts
Normal file
83
demo/assets/script/UI/Socket/SocketTestWindow.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-03-29
|
||||
* @Description:
|
||||
*/
|
||||
import { Socket } from "kunpocc-net";
|
||||
import { fgui, kunpo } from "../../header";
|
||||
import { ProtoInfos } from "../../Socket/ProtoInfos";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Socket", "SocketTestWindow")
|
||||
export class SocketTestWindow extends kunpo.Window {
|
||||
@uiprop private text_input: fgui.GTextInput;
|
||||
@uiprop private text_input_message: fgui.GTextInput;
|
||||
|
||||
private _status: fgui.Controller;
|
||||
private socket: Socket;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
|
||||
this._status = this.getController("status");
|
||||
|
||||
this.text_input.text = "ws://10.8.36.142:8080";
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onCloseWindow(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onConnection(): void {
|
||||
if (this.socket) {
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "已经存在一个连接" });
|
||||
return;
|
||||
}
|
||||
this.socket = new Socket(this.text_input.text, { binaryType: "arraybuffer" });
|
||||
this.socket.onopen = () => {
|
||||
kunpo.log("连接成功");
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "连接成功" });
|
||||
this._status.setSelectedIndex(1);
|
||||
}
|
||||
this.socket.onmessage = (data: any) => {
|
||||
kunpo.log("收到消息", data);
|
||||
}
|
||||
|
||||
this.socket.onclose = (code: number, reason: string) => {
|
||||
kunpo.log("连接关闭", code, reason);
|
||||
this._status.setSelectedIndex(0);
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: `连接断开 code:${code} reason:${reason}` });
|
||||
this.socket = null;
|
||||
}
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onDisconnect(): void {
|
||||
this.socket?.close(3001, "主动断开");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onSendText(): void {
|
||||
if (!this.text_input_message.text) {
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "请输入要发送的消息" });
|
||||
return;
|
||||
}
|
||||
this.socket?.send(this.text_input_message.text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送二进制这里使用 protobuf
|
||||
*/
|
||||
@uiclick
|
||||
private onSendBinary(): void {
|
||||
if (!this.text_input_message.text) {
|
||||
kunpo.WindowManager.showWindowIm("ToastWindow", { text: "请输入要发送的消息" });
|
||||
return;
|
||||
}
|
||||
let protoInfos = new ProtoInfos();
|
||||
let buffer = protoInfos.encodeData(1, this.text_input_message.text);
|
||||
this.socket?.sendBuffer(buffer);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Socket/SocketTestWindow.ts.meta
Normal file
9
demo/assets/script/UI/Socket/SocketTestWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bf8b0dec-aa56-401f-bec1-f9200ac1042d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/SocketTestWindow.ts.meta
Normal file
9
demo/assets/script/UI/SocketTestWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f4e808a7-37da-486d-b371-35f2d4f4918b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Window.meta
Normal file
9
demo/assets/script/UI/Window.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "151a2b6f-f082-4e0f-bf54-718c31f777af",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
49
demo/assets/script/UI/Window/CloseAllWindow.ts
Normal file
49
demo/assets/script/UI/Window/CloseAllWindow.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-21
|
||||
* @Description:
|
||||
*/
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "CloseAllWindow")
|
||||
export class CloseAllWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.CloseAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("CloseAllWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("CloseAllWindow onHide");
|
||||
}
|
||||
|
||||
protected onCover(): void {
|
||||
kunpo.log("CloseAllWindow onCover");
|
||||
}
|
||||
|
||||
protected onRecover(): void {
|
||||
kunpo.log("CloseAllWindow onRecover");
|
||||
}
|
||||
|
||||
protected onShowFromHide(): void {
|
||||
kunpo.log("CloseAllWindow onShowFromHide");
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
kunpo.log("CloseAllWindow 点击空白区域");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("CloseAllWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/CloseAllWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/CloseAllWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "323b9ed8-0b74-4c65-99d4-a9e46e33cd6a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
50
demo/assets/script/UI/Window/CloseOneWindow.ts
Normal file
50
demo/assets/script/UI/Window/CloseOneWindow.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-21
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "CloseOneWindow")
|
||||
export class CloseOneWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.CloseOne;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("CloseOneWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("CloseOneWindow onHide");
|
||||
}
|
||||
|
||||
protected onCover(): void {
|
||||
kunpo.log("CloseOneWindow onCover");
|
||||
}
|
||||
|
||||
protected onRecover(): void {
|
||||
kunpo.log("CloseOneWindow onRecover");
|
||||
}
|
||||
|
||||
protected onShowFromHide(): void {
|
||||
kunpo.log("CloseOneWindow onShowFromHide");
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
kunpo.log("CloseOneWindow 点击空白区域");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("CloseOneWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/CloseOneWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/CloseOneWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f107c3dc-ff92-4b78-8384-b8908fa51bd8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/Components.meta
Normal file
9
demo/assets/script/UI/Window/Components.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "179bd030-c5da-4803-a8aa-999bc7106a35",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
17
demo/assets/script/UI/Window/Components/CustomComponents.ts
Normal file
17
demo/assets/script/UI/Window/Components/CustomComponents.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-26
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../../header";
|
||||
const { uiheader, uiprop, uicom, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uicom("Window", "CustomComponents")
|
||||
export class CustomComponents extends fgui.GComponent {
|
||||
@uiprop n1: fgui.GTextField;
|
||||
|
||||
public onInit(): void {
|
||||
kunpo.log("CustomComponents onInit");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a8d4cfe1-8b55-4d01-8a17-fddb82a3c035",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
49
demo/assets/script/UI/Window/HideAllWindow.ts
Normal file
49
demo/assets/script/UI/Window/HideAllWindow.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-21
|
||||
* @Description:
|
||||
*/
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "HideAllWindow")
|
||||
export class HideAllWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("HideAllWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("HideAllWindow onHide");
|
||||
}
|
||||
|
||||
protected onCover(): void {
|
||||
kunpo.log("HideAllWindow onCover");
|
||||
}
|
||||
|
||||
protected onRecover(): void {
|
||||
kunpo.log("HideAllWindow onRecover");
|
||||
}
|
||||
|
||||
protected onShowFromHide(): void {
|
||||
kunpo.log("HideAllWindow onShowFromHide");
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
kunpo.log("HideAllWindow 点击空白区域");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("HideAllWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/HideAllWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/HideAllWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c9f63827-cffb-45c8-9bde-6580385ef829",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
50
demo/assets/script/UI/Window/HideOneWindow.ts
Normal file
50
demo/assets/script/UI/Window/HideOneWindow.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-21
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "HideOneWindow")
|
||||
export class HideOneWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideOne;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("HideOneWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("HideOneWindow onHide");
|
||||
}
|
||||
|
||||
protected onCover(): void {
|
||||
kunpo.log("HideOneWindow onCover");
|
||||
}
|
||||
|
||||
protected onRecover(): void {
|
||||
kunpo.log("HideOneWindow onRecover");
|
||||
}
|
||||
|
||||
protected onShowFromHide(): void {
|
||||
kunpo.log("HideOneWindow onShowFromHide");
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
kunpo.log("HideOneWindow 点击空白区域");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("HideOneWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/HideOneWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/HideOneWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3735a1a5-aa89-42a5-b71d-07b405970080",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
22
demo/assets/script/UI/Window/PopWindow.ts
Normal file
22
demo/assets/script/UI/Window/PopWindow.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-01-12
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "PopWindow")
|
||||
export class PopWindow extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onCloseWindow(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/PopWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/PopWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3f040196-71f3-4af5-af01-ca1c2ed874b8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
26
demo/assets/script/UI/Window/PopWindowHeader1.ts
Normal file
26
demo/assets/script/UI/Window/PopWindowHeader1.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2024-12-14
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "PopWindowHeader1")
|
||||
export class PopWindowHeader1 extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
}
|
||||
|
||||
getHeaderInfo(): kunpo.WindowHeaderInfo {
|
||||
return kunpo.WindowHeaderInfo.create("WindowHeader", "aaa");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onCloseWindow(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/PopWindowHeader1.ts.meta
Normal file
9
demo/assets/script/UI/Window/PopWindowHeader1.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0760d294-bd0b-4749-b644-0cfe78c3e5d9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
26
demo/assets/script/UI/Window/PopWindowHeader2.ts
Normal file
26
demo/assets/script/UI/Window/PopWindowHeader2.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-01-12
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { fgui, kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "PopWindowHeader2")
|
||||
export class PopWindowHeader2 extends kunpo.Window {
|
||||
@uiprop btn_close: fgui.GButton;
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.Normal;
|
||||
}
|
||||
|
||||
getHeaderInfo(): kunpo.WindowHeaderInfo {
|
||||
return kunpo.WindowHeaderInfo.create("WindowHeader2", "aaa");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onCloseWindow(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/PopWindowHeader2.ts.meta
Normal file
9
demo/assets/script/UI/Window/PopWindowHeader2.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "28191db1-d974-4911-9fe5-2104cfc45050",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
88
demo/assets/script/UI/Window/UIBaseWindow.ts
Normal file
88
demo/assets/script/UI/Window/UIBaseWindow.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-04-19
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
import { kunpo } from "../../header";
|
||||
const { uiclass, uiprop, uiclick } = kunpo._uidecorator;
|
||||
|
||||
@uiclass("Window", "Window", "UIBaseWindow")
|
||||
export class UIBaseWindow extends kunpo.Window {
|
||||
protected onInit(): void {
|
||||
this.adapterType = kunpo.AdapterType.Bang;
|
||||
this.type = kunpo.WindowType.HideAll;
|
||||
}
|
||||
|
||||
protected onShow(userdata?: any): void {
|
||||
kunpo.log("UIBaseWindow onShow:", userdata);
|
||||
}
|
||||
|
||||
protected onHide(): void {
|
||||
kunpo.log("UIBaseWindow onHide");
|
||||
}
|
||||
|
||||
protected onCover(): void {
|
||||
kunpo.log("UIBaseWindow onCover");
|
||||
}
|
||||
|
||||
protected onRecover(): void {
|
||||
kunpo.log("UIBaseWindow onRecover");
|
||||
}
|
||||
|
||||
protected onShowFromHide(): void {
|
||||
kunpo.log("UIBaseWindow onShowFromHide");
|
||||
}
|
||||
|
||||
protected onEmptyAreaClick(): void {
|
||||
kunpo.log("UIBaseWindow 点击空白区域");
|
||||
}
|
||||
|
||||
protected onClose(): void {
|
||||
kunpo.log("UIBaseWindow onClose");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnClose(): void {
|
||||
kunpo.WindowManager.closeWindow(this.name);
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnHeader1(): void {
|
||||
kunpo.WindowManager.showWindow("PopWindowHeader1");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnHeader2(): void {
|
||||
kunpo.WindowManager.showWindow("PopWindowHeader2");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnEmpty(): void {
|
||||
kunpo.WindowManager.showWindow("PopWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCloseOne(): void {
|
||||
kunpo.WindowManager.showWindow("CloseOneWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnCloseAll(): void {
|
||||
kunpo.WindowManager.showWindow("CloseAllWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnHideOne(): void {
|
||||
kunpo.WindowManager.showWindow("HideOneWindow");
|
||||
}
|
||||
|
||||
@uiclick
|
||||
private onClickBtnHideAll(): void {
|
||||
kunpo.WindowManager.showWindow("HideAllWindow");
|
||||
}
|
||||
|
||||
public getHeaderInfo(): kunpo.WindowHeaderInfo {
|
||||
return kunpo.WindowHeaderInfo.create("WindowHeader", "aaa");
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UI/Window/UIBaseWindow.ts.meta
Normal file
9
demo/assets/script/UI/Window/UIBaseWindow.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "95f0b543-53f1-416e-a789-d1cc9de0e2a8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
51
demo/assets/script/UIPackageRegister.ts
Normal file
51
demo/assets/script/UIPackageRegister.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-26
|
||||
* @Description:
|
||||
*/
|
||||
import { kunpo } from './header';
|
||||
export class UIPackageRegister {
|
||||
public static Register(): void {
|
||||
kunpo.WindowManager.initPackageConfig({
|
||||
config: {
|
||||
/** UI所在resources中的路径 */
|
||||
uiPath: "ui",
|
||||
/**
|
||||
* 手动管理资源的包
|
||||
* 1. 用于基础UI包, 提供一些最基础的组件,所有其他包都可能引用其中的内容
|
||||
* 2. 资源header所在的包
|
||||
* 3. 用于一些特殊场景, 比如需要和其他资源一起加载, 并且显示进度条的包
|
||||
*/
|
||||
manualPackages: ["Basics", "Home"],
|
||||
/**
|
||||
* 不推荐配置 只是提供一种特殊需求的实现方式
|
||||
* 窗口引用到其他包中的资源 需要的配置信息
|
||||
*/
|
||||
linkPackages: {},
|
||||
/**
|
||||
* 关闭界面后,需要立即释放资源的包名(建议尽量少)
|
||||
* 一般不建议包进行频繁装载卸载,因为每次装载卸载必然是要消耗CPU时间(意味着耗电)和产生大量GC的。UI系统占用的内存是可以精确估算的,你可以按照包的使用频率设定哪些包是需要立即释放的。
|
||||
* 不包括手动管理的包
|
||||
*/
|
||||
imReleasePackages: [],
|
||||
},
|
||||
showWaitWindow: this._showWaitWindow,
|
||||
hideWaitWindow: this._hideWaitWindow,
|
||||
fail: this._fail,
|
||||
});
|
||||
}
|
||||
|
||||
private static _showWaitWindow(): void {
|
||||
console.log("显示资源加载等待窗");
|
||||
kunpo.WindowManager.showWindow("LoadUIWindow");
|
||||
}
|
||||
|
||||
private static _hideWaitWindow(): void {
|
||||
console.log("关闭资源加载等待窗");
|
||||
kunpo.WindowManager.closeWindow("LoadUIWindow");
|
||||
}
|
||||
|
||||
private static _fail(windowName: string, errmsg: string, pkgs: string[]): void {
|
||||
console.log("资源加载失败", windowName, errmsg, pkgs);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/UIPackageRegister.ts.meta
Normal file
9
demo/assets/script/UIPackageRegister.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f2a30cc8-4ea8-461f-86d0-d8d77d9076f4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
demo/assets/script/condition.meta
Normal file
9
demo/assets/script/condition.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "68249aa2-e13d-4d56-b368-3e66145a80c6",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
23
demo/assets/script/condition/Condition1.ts
Normal file
23
demo/assets/script/condition/Condition1.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-17
|
||||
* @Description: 条件1 关联数据conditon1
|
||||
*/
|
||||
import { GlobalEvent } from 'kunpocc-event';
|
||||
import { DataHelper } from '../Data/DataHelper';
|
||||
import { kunpo } from '../header';
|
||||
import { ConditionType } from './ConditionType';
|
||||
const { conditionClass } = kunpo._conditionDecorator;
|
||||
|
||||
@conditionClass(ConditionType.Condition1)
|
||||
export class Condition1 extends kunpo.ConditionBase {
|
||||
protected onInit(): void {
|
||||
GlobalEvent.add("condition1", () => {
|
||||
this.tryUpdate();
|
||||
}, this);
|
||||
}
|
||||
|
||||
protected evaluate(): boolean {
|
||||
return DataHelper.getValue("condition1", true);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/condition/Condition1.ts.meta
Normal file
9
demo/assets/script/condition/Condition1.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3be3041b-9739-434b-9394-4213b24b3b59",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
23
demo/assets/script/condition/Condition2.ts
Normal file
23
demo/assets/script/condition/Condition2.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-17
|
||||
* @Description: 条件2 关联数据condition2
|
||||
*/
|
||||
import { GlobalEvent } from 'kunpocc-event';
|
||||
import { DataHelper } from '../Data/DataHelper';
|
||||
import { kunpo } from '../header';
|
||||
import { ConditionType } from './ConditionType';
|
||||
const { conditionClass } = kunpo._conditionDecorator;
|
||||
|
||||
@conditionClass(ConditionType.Condition2)
|
||||
export class Condition2 extends kunpo.ConditionBase {
|
||||
protected onInit(): void {
|
||||
GlobalEvent.add("condition2", () => {
|
||||
this.tryUpdate();
|
||||
}, this);
|
||||
}
|
||||
|
||||
protected evaluate(): boolean {
|
||||
return DataHelper.getValue("condition2", true);
|
||||
}
|
||||
}
|
||||
9
demo/assets/script/condition/Condition2.ts.meta
Normal file
9
demo/assets/script/condition/Condition2.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "1b1192af-5665-46b9-baeb-d33adc76ac6b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
23
demo/assets/script/condition/Condition3.ts
Normal file
23
demo/assets/script/condition/Condition3.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-02-17
|
||||
* @Description: 条件3 关联数据condition3
|
||||
*/
|
||||
import { GlobalEvent } from 'kunpocc-event';
|
||||
import { DataHelper } from '../Data/DataHelper';
|
||||
import { kunpo } from '../header';
|
||||
import { ConditionType } from './ConditionType';
|
||||
const { conditionClass } = kunpo._conditionDecorator;
|
||||
|
||||
@conditionClass(ConditionType.Condition3)
|
||||
export class Condition3 extends kunpo.ConditionBase {
|
||||
protected onInit(): void {
|
||||
GlobalEvent.add("condition3", () => {
|
||||
this.tryUpdate();
|
||||
}, this);
|
||||
}
|
||||
|
||||
protected evaluate(): boolean {
|
||||
return DataHelper.getValue("condition3", true);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user