[add] Lobby 按鈕功能

This commit is contained in:
2022-05-08 20:36:56 +08:00
parent b644e0e0ab
commit d302a52d8d
105 changed files with 52578 additions and 3849 deletions

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "bb9ff296-9ba2-4946-8d9f-423fdeb6ef39",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@@ -0,0 +1,29 @@
import CSMessage from "../Message/CSMessage";
const { ccclass, property } = cc._decorator;
@ccclass
export class MainControl extends cc.Component {
//#region property
@property({ displayName: "訊息窗位置", type: cc.Node })
public MessageContent: cc.Node = null;
@property({ displayName: "MessageNormal", type: cc.Prefab })
public SourceMessage: cc.Prefab = null;
//#endregion
//#region 初始化
onLoad(): void {
// MainControl._instance = this;
this._initialEngine();
}
private _initialEngine(): void {
CSMessage.Initialize(this.SourceMessage, this.MessageContent);
}
//#endregion
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "ec0e4b2c-5018-4f84-9062-70403d8383e1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "a77a0b3c-4746-4581-aa25-10cd2a95ce30",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@@ -0,0 +1,51 @@
// import CSSettingsV3 from "../../FormTable/CSSettingsV3";
import { MessageNormal, MessageNormalData } from "./MessageNormal";
/** 訊息框相關 */
export default class CSMessage {
private static _sourceUI: cc.Prefab;
private static _parent: cc.Node;
public static Initialize(sourceUI: cc.Prefab, parent: cc.Node): void {
this._sourceUI = sourceUI;
this._parent = parent;
}
/** 一個按鈕的訊息框 */
public static CreateYesMsg(content: string, yesCallback: () => void = null, enterStr: string = null): void {
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
enterStr = enterStr ? enterStr : "確定";
let data: MessageNormalData = {
content: content,
isShowCancel: false,
yesCallback: yesCallback,
noCallback: null,
enterName: enterStr,
cancelName: null
};
MessageNormal.Create(this._sourceUI, this._parent, data);
}
/** 兩個按鈕的訊息框 */
public static CreateYesNoMsg(content: string, yesCallback: () => void = null, noCallback: () => void = null, enterStr: string = null, cancelStr: string = null): void {
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
// cancelStr = cancelStr ? cancelStr : CSSettingsV3.prototype.CommonString(4);
enterStr = enterStr ? enterStr : "確定";
cancelStr = cancelStr ? cancelStr : "取消";
let data: MessageNormalData = {
content: content,
isShowCancel: true,
yesCallback: yesCallback,
noCallback: noCallback,
enterName: enterStr,
cancelName: cancelStr
};
MessageNormal.Create(this._sourceUI, this._parent, data);
}
/** 網路錯誤訊息 */
public static NetError(method: string, state: number, str: string = ""): void {
let error: string = String.Format("[{0}] state:{1} {2}", method, state, str);
cc.warn("網路錯誤訊息: ", error);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "3f92822f-2324-4f9f-9480-0c1a5b16815f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,71 @@
import { CoroutineV2 } from "../../Engine/CatanEngine/CoroutineV2/CoroutineV2";
import UIPanel from "../../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
export interface MessageNormalData {
content: string;
// title: string;
isShowCancel: boolean;
yesCallback: () => void;
noCallback: () => void;
enterName: string;
cancelName: string;
}
@ccclass
export class MessageNormal extends UIPanel {
@property({ displayName: "訊息內容", type: cc.Label })
public Content: cc.Label = null;
// @property({ displayName: "標題", type: cc.Label })
// public Title: cc.Label = null;
@property({ displayName: "確定鈕", type: cc.Button })
public EnterBtn: cc.Button = null;
@property({ displayName: "取消鈕", type: cc.Button })
public CancalBtn: cc.Button = null;
@property({ displayName: "確定鈕文字", type: cc.Label })
public EnterText: cc.Label = null;
@property({ displayName: "取消鈕文字", type: cc.Label })
public CancalText: cc.Label = null;
private _data: MessageNormalData;
protected ImplementInitial(...initData: any[]): void {
this._data = initData[0];
this.Content.string = this._data.content;
// this.Title.string = this._data.title;
if (this._data.enterName) {
this.EnterText.string = this._data.enterName;
} else {
this._data.enterName = "";
}
this.EnterText.string = this._data.enterName;
if (this._data.cancelName) {
this.CancalText.string = this._data.cancelName;
} else {
this.CancalText.string = "";
}
this.CancalBtn.node.active = this._data.isShowCancel;
}
public OnEnter(): void {
if (this._data.yesCallback) {
this._data.yesCallback();
}
this.node.destroy();
}
public OnCancel(): void {
if (this._data.noCallback) {
this._data.noCallback();
}
this.node.destroy();
}
public static Create(sourceUI: cc.Prefab, parent: cc.Node, data: MessageNormalData): void {
let node: cc.Node = parent.ExAddChild(sourceUI);
let script: MessageNormal = node.getComponent(MessageNormal);
script.Initial(data);
CoroutineV2.Single(script.Show()).Start();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "539c898e-ee41-414a-a279-7ec1a8a9f5be",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}