创建角色增加 输入名称 弹窗

(cherry picked from commit e9a8a6ad17)
This commit is contained in:
WONIU 2024-12-19 17:32:03 +08:00 committed by Lenheart
parent 0183ede4f3
commit 570532aa99
1 changed files with 203 additions and 55 deletions

View File

@ -228,10 +228,12 @@ class _CreateCharacter extends Yosin_Window {
firedustAni = null; firedustAni = null;
auraAni = null; auraAni = null;
enter = null;
changJobAniClock = null; changJobAniClock = null;
changNextJobAniClock = null; changNextJobAniClock = null;
nextJobIndex = null; jobIndex = null;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
@ -247,6 +249,52 @@ class _CreateCharacter extends Yosin_Window {
} }
function RegisterDraw() {
//大背景
BackGround = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbackground.img", 0);
Addchild(BackGround);
// 人物图片
jobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 0);
jobImg.SetPosition(0, 0);
Addchild(jobImg);
// 下一个人物图片
nextJobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 11);
nextJobImg.SetPosition(500, 0);
nextJobImg.SetOpacity(0);
Addchild(nextJobImg);
// 光动画 ui/charactercreate/topdodge.ani
topLightObj = Animation("ui/charactercreate/topdodge.ani");
topLightObj.SetPosition(0, 0);
Addchild(topLightObj);
// 底部光动画
lightAni = Animation("ui/charactercreate/dust.ani");
lightAni.SetPosition(0, 0);
// lightAni.SetVisible(false);
Addchild(lightAni);
firedustAni = Animation("ui/charactercreate/firedust.ani");
firedustAni.SetPosition(0, 0);
firedustAni.SetVisible(false);
Addchild(firedustAni);
dustAni = Animation("ui/charactercreate/dust.ani");
dustAni.SetPosition(0, 0);
dustAni.SetVisible(false);
Addchild(dustAni);
auraAni = Animation("ui/charactercreate/aura.ani");
auraAni.SetPosition(0, 0);
auraAni.SetVisible(false);
Addchild(auraAni);
}
function RegisterWidget() { function RegisterWidget() {
//头像 //头像
headList = _CreateCharacter_SelectBaseHeadList(135, 40); headList = _CreateCharacter_SelectBaseHeadList(135, 40);
@ -260,7 +308,46 @@ class _CreateCharacter extends Yosin_Window {
// 创建职业 // 创建职业
infoWidget.OnClick = function () { infoWidget.OnClick = function () {
enter.SetVisible(true);
}.bindenv(this);
// 返回按钮
local backButton = Yosin_BaseButton(986, 30, 45, 12 "sprite/interface2/charactercreatever2/common_add.img", 0);
//点击事件回调
backButton.OnClick = function(Button) {
CloseWindow();
}.bindenv(this);
local backText = FontAssetManager.GenerateNormal("返回", true, {
color = sq_RGBA(159, 137, 80, 255)
});
backText.SetUpdateFunc(function(Text, Dt) {
if (Text.Parent.State == 1 || Text.Parent.State == 2) {
Text.SetFillColor(sq_RGBA(225, 218, 126, 255));
} else if (Text.Parent.State == 0) {
Text.SetFillColor(sq_RGBA(159, 137, 80, 255));
}
})
backText.SetPosition(16, -2.5);
backButton.Addchild(backText);
AddUIChild(backButton);
// 输入名字
enter = _create_Character_enterName();
enter.SetVisible(false);
AddUIChild(enter);
// 确定
enter.OnClick = function (enterName) {
local jobEnum = getJobEnum(jobIndex);
MySocket.Send(9, {
name = enterName,
gkb = jobEnum,
})
}.bindenv(this); }.bindenv(this);
} }
@ -268,11 +355,11 @@ class _CreateCharacter extends Yosin_Window {
// 切换职业 // 切换职业
function changJob(index) { function changJob(index) {
if (index == nextJobIndex) return; if (index == jobIndex) return;
local jobEnum = getJobEnum(index); local jobEnum = getJobEnum(index);
nextJobIndex = index; jobIndex = index;
// 切换背景 // 切换背景
BackGround.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/characterbackground.img", jobEnum)); BackGround.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/characterbackground.img", jobEnum));
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum)); nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum));
@ -370,13 +457,13 @@ class _CreateCharacter extends Yosin_Window {
}.bindenv(this), function () { }.bindenv(this), function () {
changNextJobAniClock = null; changNextJobAniClock = null;
local jobEnum = getJobEnum(nextJobIndex); local jobEnum = getJobEnum(jobIndex);
jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum )); jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum ));
jobImg.SetOpacity(1); jobImg.SetOpacity(1);
jobImg.SetPosition(0, 0); jobImg.SetPosition(0, 0);
if (nextJobIndex < 16) { if (jobIndex < 16) {
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(nextJobIndex + 1))); nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(jobIndex + 1)));
nextJobImg.SetOpacity(0); nextJobImg.SetOpacity(0);
nextJobImg.SetPosition(500, 0); nextJobImg.SetPosition(500, 0);
} }
@ -385,53 +472,8 @@ class _CreateCharacter extends Yosin_Window {
} }
function RegisterDraw() {
//大背景
BackGround = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbackground.img", 0);
Addchild(BackGround);
// 人物图片
jobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 0);
jobImg.SetPosition(0, 0);
Addchild(jobImg);
// 下一个人物图片
nextJobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 11);
nextJobImg.SetPosition(500, 0);
nextJobImg.SetOpacity(0);
Addchild(nextJobImg);
// 光动画 ui/charactercreate/topdodge.ani
topLightObj = Animation("ui/charactercreate/topdodge.ani");
topLightObj.SetPosition(0, 0);
Addchild(topLightObj);
// 底部光动画
lightAni = Animation("ui/charactercreate/dust.ani");
lightAni.SetPosition(0, 0);
// lightAni.SetVisible(false);
Addchild(lightAni);
firedustAni = Animation("ui/charactercreate/firedust.ani");
firedustAni.SetPosition(0, 0);
firedustAni.SetVisible(false);
Addchild(firedustAni);
dustAni = Animation("ui/charactercreate/dust.ani");
dustAni.SetPosition(0, 0);
dustAni.SetVisible(false);
Addchild(dustAni);
auraAni = Animation("ui/charactercreate/aura.ani");
auraAni.SetPosition(0, 0);
auraAni.SetVisible(false);
Addchild(auraAni);
}
//逻辑入口 //逻辑入口
function Proc(Dt) { function Proc(Dt) {
@ -701,10 +743,116 @@ class HeadButton extends Yosin_CommonUi {
} }
} }
// 输入角色名称
class _create_Character_enterName extends Yosin_Window {
nameInputBox = null;
//是否为独立窗口
IsIndependent = false;
OnClick = null;
constructor() {
base.constructor("输入角色名称", 0, 0, 1066, 600, 0);
//背景
local background = Yosin_NineBoxStretch(-2, 0, 1070, 604, "sprite/interface/lenheartwindowcommon.img", 97);
AddUIChild(background);
//背景
local background = Yosin_NineBoxStretch(413, 228, 240, 140, "sprite/interface/lenheartwindowcommon.img", 97);
AddUIChild(background);
// 标题文字
local title = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 13);
title.SetPosition(477.5, 240);
Addchild(title);
// 输入框
nameInputBox = Yosin_InputBox(433, 270, 150);
AddUIChild(nameInputBox);
// 重复检查按钮
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) {
button.State = 0;
}else{
button.State = 3;
}
})
//点击事件回调
checkButton.OnClick = function(Button) {
if (OnClick != null) OnClick(Button.Parent.nameInputBox.str);
}.bindenv(this);
//按钮文本
local checkTextActor = FontAssetManager.GenerateNormal("重复", true, {
color = sq_RGBA(200, 195, 169, 255)
});
checkTextActor.SetPosition(11, 4);
checkButton.Addchild(checkTextActor);
AddUIChild(checkButton);
//提示文本
local tipTextActor = FontAssetManager.GenerateNormal("最多可以输入2~6个汉字、12个英文字符。", true, {
color = sq_RGBA(200, 195, 169, 255)
wrap_width = 150,
});
tipTextActor.SetPosition(458, 300);
Addchild(tipTextActor);
// 确认检查按钮
local 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{
button.State = 3;
}
})
//点击事件回调
affirmButton.OnClick = function(Button) {
}.bindenv(this);
//按钮文本
local affirmTextActor = FontAssetManager.GenerateNormal("确认", true, {
color = sq_RGBA(153,128,71, 255)
});
affirmTextActor.SetPosition(11, 4);
affirmButton.Addchild(affirmTextActor);
AddUIChild(affirmButton);
// 取消检查按钮
local cancelButton = Yosin_BaseButton(533, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
//点击事件回调
cancelButton.OnClick = function(button) {
nameInputBox.str = "";
button.Parent.SetVisible(false);
}.bindenv(this);
//按钮文本
local cancelTextActor = FontAssetManager.GenerateNormal("取消", true, {
color = sq_RGBA(153,128,71, 255)
});
cancelTextActor.SetPosition(11, 4);
cancelButton.Addchild(cancelTextActor);
AddUIChild(cancelButton);
}
//逻辑入口
function Proc(Dt) {
SyncPos(X, Y);
base.Proc(Dt);
}
}