[add] Lobby 按鈕功能
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
interface StringConstructor {
|
||||
interface StringConstructor {
|
||||
IsNullOrEmpty: (value: string) => boolean;
|
||||
Format: (format: string, ...args: any[]) => string;
|
||||
IsNullOrWhiteSpace: (input: string) => boolean;
|
||||
}
|
||||
|
||||
String.IsNullOrEmpty = function (value: string): boolean {
|
||||
return value === undefined || value === null || value.trim() === '';
|
||||
String.IsNullOrEmpty = function (value: string): boolean {
|
||||
return value === undefined || value === null || value.trim() === "";
|
||||
};
|
||||
|
||||
String.Format = function (format: string, ...args: any[]): string {
|
||||
return format.replace(/{(\d+)}/g, (match, index) => {
|
||||
let value = args[index];
|
||||
if (value === null || value === undefined) return '';
|
||||
return '' + value;
|
||||
if (value === null || value === undefined) { return ""; }
|
||||
return "" + value;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
String.IsNullOrWhiteSpace = function (input: string): boolean {
|
||||
if (typeof input === "undefined" || input == null) {
|
||||
return true;
|
||||
}
|
||||
return input.replace(/\s/g, "").length < 1;
|
||||
};
|
||||
@@ -10,9 +10,30 @@ export default class LocalStorageData {
|
||||
}
|
||||
|
||||
// =======================================================================================
|
||||
// public get GameConfig(): string { return cc.sys.localStorage.getItem("GameConfig"); }
|
||||
// public set GameConfig(value: string) { cc.sys.localStorage.setItem("GameConfig", value); }
|
||||
public get Date(): string { return cc.sys.localStorage.getItem("date"); }
|
||||
public set Date(value: string) { cc.sys.localStorage.setItem("date", value); }
|
||||
|
||||
public get AvatarSettings(): string { return cc.sys.localStorage.getItem("AvatarSettings"); }
|
||||
public set AvatarSettings(value: string) { cc.sys.localStorage.setItem("AvatarSettings", value); }
|
||||
public get Member(): string[] { return cc.sys.localStorage.getItem("member") ? JSON.parse(cc.sys.localStorage.getItem("member")) : []; }
|
||||
public set Member(value: string[]) { cc.sys.localStorage.setItem("member", JSON.stringify(value)); }
|
||||
|
||||
public get Avatar(): number[] { return cc.sys.localStorage.getItem("avatar") ? JSON.parse(cc.sys.localStorage.getItem("avatar")) : []; }
|
||||
public set Avatar(value: number[]) { cc.sys.localStorage.setItem("avatar", JSON.stringify(value)); }
|
||||
|
||||
public get IsSingleMode(): number { return cc.sys.localStorage.getItem("isSingleMode") ? +cc.sys.localStorage.getItem("isSingleMode") : 0; }
|
||||
public set IsSingleMode(value: number) { cc.sys.localStorage.setItem("isSingleMode", value.toString()); }
|
||||
|
||||
public get Selected(): string[] { return cc.sys.localStorage.getItem("selected") ? JSON.parse(cc.sys.localStorage.getItem("selected")) : []; }
|
||||
public set Selected(value: string[]) { cc.sys.localStorage.setItem("selected", JSON.stringify(value)); }
|
||||
|
||||
public get FirstTeam(): number { return cc.sys.localStorage.getItem("firstTeam") ? +cc.sys.localStorage.getItem("firstTeam") : -1; }
|
||||
public set FirstTeam(value: number) { cc.sys.localStorage.setItem("firstTeam", value.toString()); }
|
||||
|
||||
public get Score(): number[] { return cc.sys.localStorage.getItem("score") ? JSON.parse(cc.sys.localStorage.getItem("score")) : []; }
|
||||
public set Score(value: number[]) { cc.sys.localStorage.setItem("score", JSON.stringify(value)); }
|
||||
|
||||
public get Results(): Map<string, Object> { return cc.sys.localStorage.getItem("results") ? new Map(JSON.parse(cc.sys.localStorage.getItem("results"))) : new Map<string, Object>(); }
|
||||
public set Results(value: Map<string, Object>) { cc.sys.localStorage.setItem("results", JSON.stringify(Array.from(value.entries()))); }
|
||||
|
||||
public get HistoryTeam(): Map<string, string[]> { return cc.sys.localStorage.getItem("historyTeam") ? new Map(JSON.parse(cc.sys.localStorage.getItem("historyTeam"))) : new Map<string, string[]>(); }
|
||||
public set HistoryTeam(value: Map<string, string[]>) { cc.sys.localStorage.setItem("historyTeam", JSON.stringify(Array.from(value.entries()))); }
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ declare interface Array<T> {
|
||||
* @param call Callback function.
|
||||
*/
|
||||
AddListener(call: Function): void;
|
||||
/** 深拷貝 */
|
||||
Copy(): any[];
|
||||
}
|
||||
|
||||
Array.prototype.ExRemoveAt || Object.defineProperty(Array.prototype, "ExRemoveAt", {
|
||||
@@ -92,4 +94,11 @@ Array.prototype.AddListener || Object.defineProperty(Array.prototype, "AddListen
|
||||
EventHandler.handler = <any>call;
|
||||
this.push(EventHandler);
|
||||
}
|
||||
});
|
||||
|
||||
Array.prototype.Copy || Object.defineProperty(Array.prototype, "Copy", {
|
||||
enumerable: false,
|
||||
value: function (): any[] {
|
||||
return Array.from(this);
|
||||
}
|
||||
});
|
||||
12
assets/Script/Engine/Utils/Object.meta
Normal file
12
assets/Script/Engine/Utils/Object.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.2",
|
||||
"uuid": "a726d04f-4b2c-4e8f-9160-ef0fb6d11625",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
10
assets/Script/Engine/Utils/Object/ObjectEx.ts
Normal file
10
assets/Script/Engine/Utils/Object/ObjectEx.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
export module ObjectEx {
|
||||
|
||||
/**
|
||||
* 深拷貝
|
||||
*/
|
||||
export function Copy(any: any): any {
|
||||
return JSON.parse(JSON.stringify(any));
|
||||
}
|
||||
}
|
||||
9
assets/Script/Engine/Utils/Object/ObjectEx.ts.meta
Normal file
9
assets/Script/Engine/Utils/Object/ObjectEx.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "8d75fc79-4886-48fc-8350-e2f3ae19a079",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user