创建角色 接口调试

This commit is contained in:
WONIU 2024-12-20 21:47:10 +08:00
parent ba47018537
commit 04e956d413
1 changed files with 60 additions and 11 deletions

View File

@ -233,7 +233,7 @@ class _CreateCharacter extends Yosin_Window {
changJobAniClock = null;
changNextJobAniClock = null;
jobIndex = null;
jobIndex = 0;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
@ -243,6 +243,18 @@ class _CreateCharacter extends Yosin_Window {
//注册控件
RegisterWidget();
// 创建角色回包
MySocket.RegisterHandler(4, function(Jso) {
if (Jso.type == 0){
// 创建成功.
NoticeBox = _Yosin_MessageBox("创建成功.");
}else{
// 创建失败.
NoticeBox = _Yosin_MessageBox("创建失败.");
}
}.bindenv(this));
}
function PlayBackgroundMusic() {
@ -751,8 +763,18 @@ class _create_Character_enterName extends Yosin_Window {
//是否为独立窗口
IsIndependent = false;
affirmButton = null;
OnClick = null;
//公告框
NoticeBox = null;
// 检查过的名称
checkName = null;
// 当前名称
name = null;
constructor() {
base.constructor("输入角色名称", 0, 0, 1066, 600, 0);
@ -770,14 +792,17 @@ class _create_Character_enterName extends Yosin_Window {
Addchild(title);
// 输入框
nameInputBox = Yosin_InputBox(433, 270, 150);
local nameInputBox = Yosin_InputBox(433, 270, 150);
AddUIChild(nameInputBox);
nameInputBox.SetUpdateFunc(function(inputBox, Dt) {
inputBox.Parent.name = inputBox.str;
})
// 重复检查按钮
local checkButton = Yosin_BaseButton(593, 267, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
checkButton.State = 3;
checkButton.SetUpdateFunc(function(button, Dt) {
if (button.Parent.nameInputBox.str.len() > 0) {
if (button.Parent.name.len() > 0) {
button.State = 0;
}else{
button.State = 3;
@ -785,7 +810,11 @@ class _create_Character_enterName extends Yosin_Window {
})
//点击事件回调
checkButton.OnClick = function(Button) {
if (OnClick != null) OnClick(Button.Parent.nameInputBox.str);
MySocket.Send(6, {
name = nameInputBox.str,
})
}.bindenv(this);
//按钮文本
local checkTextActor = FontAssetManager.GenerateNormal("重复", true, {
@ -805,19 +834,17 @@ class _create_Character_enterName extends Yosin_Window {
Addchild(tipTextActor);
// 确认检查按钮
local affirmButton = Yosin_BaseButton(473, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
// 确认按钮
affirmButton = Yosin_BaseButton(473, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
affirmButton.State = 3;
affirmButton.SetUpdateFunc(function(button, Dt) {
if (button.Parent.nameInputBox.str.len() > 0) {
button.State = 0;
}else{
if (button.Parent.name != button.Parent.checkName && button.State != 3) {
button.State = 3;
}
})
//点击事件回调
affirmButton.OnClick = function(Button) {
if (OnClick != null) OnClick(Button.Parent.checkName);
}.bindenv(this);
//按钮文本
local affirmTextActor = FontAssetManager.GenerateNormal("确认", true, {
@ -828,7 +855,7 @@ class _create_Character_enterName extends Yosin_Window {
AddUIChild(affirmButton);
// 取消检查按钮
// 取消按钮
local cancelButton = Yosin_BaseButton(533, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
//点击事件回调
cancelButton.OnClick = function(button) {
@ -843,6 +870,23 @@ class _create_Character_enterName extends Yosin_Window {
cancelButton.Addchild(cancelTextActor);
AddUIChild(cancelButton);
// 昵称重复检查回包
MySocket.RegisterHandler(3, function(Jso) {
if (NoticeBox) NoticeBox.CloseWindow();
if (Jso.type == 0){
// 可以使用的ID 确认按钮可以使用.
NoticeBox = _Yosin_MessageBox("可以使用的ID.");
checkName = nameInputBox.str;
affirmButton.State = 0;
}else{
// 名称重复.
NoticeBox = _Yosin_MessageBox("名称重复.");
}
}.bindenv(this));
}
//逻辑入口
@ -850,6 +894,11 @@ class _create_Character_enterName extends Yosin_Window {
SyncPos(X, Y);
base.Proc(Dt);
// if (nameInputBox.str != checkName && affirmButton.State != 3) {
// affirmButton.State = 3;
// }
}
}