2024-12-11 15:08:57 +08:00
|
|
|
/*
|
|
|
|
|
文件名:0_Login.nut
|
|
|
|
|
路径:User/UI/0_Login.nut
|
|
|
|
|
创建日期:2024-12-01 15:13
|
|
|
|
|
文件用途:登录界面窗口
|
|
|
|
|
*/
|
|
|
|
|
class _Login_Window extends Yosin_Window {
|
|
|
|
|
//调试模式
|
|
|
|
|
// DeBugMode = true;
|
|
|
|
|
|
|
|
|
|
//不是窗口
|
|
|
|
|
// NoWindow = true;
|
|
|
|
|
|
|
|
|
|
//是否可见
|
|
|
|
|
// Visible = false;
|
|
|
|
|
|
|
|
|
|
AccountInputBox = null;
|
|
|
|
|
PasswordInputBox = null;
|
|
|
|
|
|
|
|
|
|
BackGroundMusic = null;
|
|
|
|
|
|
2024-12-15 20:15:29 +08:00
|
|
|
//信息
|
|
|
|
|
PackInfo = null;
|
|
|
|
|
|
2024-12-16 20:33:05 +08:00
|
|
|
//公告框
|
|
|
|
|
NoticeBox = null;
|
|
|
|
|
|
2024-12-11 15:08:57 +08:00
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
|
|
|
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
|
|
|
|
|
|
|
|
//注册绘制
|
|
|
|
|
RegisterDraw();
|
|
|
|
|
//注册控件
|
|
|
|
|
RegisterWidget();
|
|
|
|
|
// OpenDeBug();
|
|
|
|
|
|
|
|
|
|
//播放音乐
|
|
|
|
|
PlayBackgroundMusic();
|
2024-12-15 20:15:29 +08:00
|
|
|
|
|
|
|
|
//注册登录回调包
|
|
|
|
|
MySocket.RegisterHandler(2, function(Jso) {
|
2024-12-16 20:33:05 +08:00
|
|
|
if (NoticeBox) NoticeBox.CloseWindow();
|
2024-12-15 20:15:29 +08:00
|
|
|
//登录成功
|
|
|
|
|
if (Jso.state) {
|
2024-12-16 20:33:05 +08:00
|
|
|
NoticeBox = _Yosin_MessageBox("登录成功,正在进入游戏...");
|
2024-12-18 18:51:30 +08:00
|
|
|
MySocket.Send(PACKET_ID.QUERY_CHARACTER_LIST, null);
|
2024-12-15 20:15:29 +08:00
|
|
|
} else {
|
2024-12-16 20:33:05 +08:00
|
|
|
NoticeBox = _Yosin_MessageBox("登录失败");
|
2024-12-15 20:15:29 +08:00
|
|
|
}
|
|
|
|
|
}.bindenv(this));
|
|
|
|
|
|
|
|
|
|
//注册获取角色列表回包
|
|
|
|
|
MySocket.RegisterHandler(10, function(Jso) {
|
|
|
|
|
PackInfo = Jso;
|
|
|
|
|
}.bindenv(this));
|
|
|
|
|
//注册获取角色列表的装备回包
|
|
|
|
|
MySocket.RegisterBinaryHandler(10, function(Blob) {
|
|
|
|
|
Blob.readn('i');
|
|
|
|
|
foreach(info in PackInfo.charac) {
|
|
|
|
|
info.equip <- [];
|
|
|
|
|
for (local i = 0; i< 15; i++) {
|
|
|
|
|
local value = Blob.readn('i');
|
|
|
|
|
info.equip.append(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-16 20:33:05 +08:00
|
|
|
//关闭登录界面
|
2024-12-19 23:55:34 +08:00
|
|
|
NoticeBox.DestroyWindow();
|
|
|
|
|
DestroyWindow();
|
2024-12-15 20:15:29 +08:00
|
|
|
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
|
|
|
|
|
Window.Init(PackInfo);
|
2024-12-19 23:55:34 +08:00
|
|
|
Window.BackGroundMusic = this.BackGroundMusic;
|
2024-12-15 20:15:29 +08:00
|
|
|
}.bindenv(this));
|
2024-12-19 23:55:34 +08:00
|
|
|
|
2024-12-11 15:08:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function PlayBackgroundMusic() {
|
2024-12-19 23:55:34 +08:00
|
|
|
BackGroundMusic = Audio(MUSIC.M_CHARACTER_SELECT);
|
|
|
|
|
BackGroundMusic.Play();
|
2024-12-11 15:08:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MusicLogic() {
|
|
|
|
|
if (BackGroundMusic == null) return;
|
|
|
|
|
if (!BackGroundMusic.IsPlaying()) BackGroundMusic.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function RegisterWidget() {
|
|
|
|
|
//账号输入框
|
2024-12-20 21:52:49 +08:00
|
|
|
AccountInputBox = Yosin_InputBox(752, 240, 200);
|
2025-01-11 23:58:10 +08:00
|
|
|
AccountInputBox.str = "1"; //TODO 临时账户
|
2024-12-11 15:08:57 +08:00
|
|
|
AddUIChild(AccountInputBox);
|
|
|
|
|
|
|
|
|
|
//密码输入框
|
2024-12-20 21:52:49 +08:00
|
|
|
PasswordInputBox = Yosin_InputBox(752, 280, 200);
|
2025-01-11 23:58:10 +08:00
|
|
|
PasswordInputBox.str = "1"; //TODO 临时账户
|
2024-12-11 15:08:57 +08:00
|
|
|
AddUIChild(PasswordInputBox);
|
|
|
|
|
|
|
|
|
|
//登录按钮
|
|
|
|
|
local LoginButton = Yosin_BaseButton(770, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
|
2024-12-19 23:55:34 +08:00
|
|
|
LoginButton.OnClickSound = SOUND.CLICK_BUTTON4;
|
2024-12-11 15:08:57 +08:00
|
|
|
//点击事件回调
|
|
|
|
|
LoginButton.OnClick = function(Button) {
|
2024-12-19 23:55:34 +08:00
|
|
|
// sqdbg_break();
|
2024-12-18 18:51:30 +08:00
|
|
|
MySocket.Send(PACKET_ID.LOGIN, {
|
2024-12-11 15:08:57 +08:00
|
|
|
account = AccountInputBox.str,
|
|
|
|
|
password = PasswordInputBox.str
|
|
|
|
|
})
|
|
|
|
|
}.bindenv(this);
|
|
|
|
|
|
|
|
|
|
//登录按钮文本
|
2024-12-14 23:15:53 +08:00
|
|
|
local LoginTextActor = FontAssetManager.GenerateNormal("登录", true, {
|
|
|
|
|
color = sq_RGBA(200, 195, 169, 255)
|
|
|
|
|
});
|
2024-12-11 15:08:57 +08:00
|
|
|
LoginTextActor.SetPosition(26, 4);
|
|
|
|
|
LoginButton.Addchild(LoginTextActor);
|
|
|
|
|
AddUIChild(LoginButton);
|
|
|
|
|
|
|
|
|
|
//注册按钮
|
|
|
|
|
local RegisterButton = Yosin_BaseButton(865, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
|
2024-12-19 23:55:34 +08:00
|
|
|
RegisterButton.OnClickSound = SOUND.CLICK_BUTTON1;
|
2024-12-11 15:08:57 +08:00
|
|
|
//点击事件回调
|
|
|
|
|
RegisterButton.OnClick = function(Button) {
|
2024-12-18 18:51:30 +08:00
|
|
|
MySocket.Send(PACKET_ID.REGISTER, {
|
2024-12-11 15:08:57 +08:00
|
|
|
account = AccountInputBox.str,
|
|
|
|
|
password = PasswordInputBox.str
|
|
|
|
|
})
|
|
|
|
|
}.bindenv(this);
|
|
|
|
|
//注册按钮文本
|
2024-12-14 23:15:53 +08:00
|
|
|
local RegisterTextActor = FontAssetManager.GenerateNormal("注册", true, {
|
|
|
|
|
color = sq_RGBA(200, 195, 169, 255)
|
|
|
|
|
});
|
2024-12-11 15:08:57 +08:00
|
|
|
RegisterTextActor.SetPosition(26, 4);
|
|
|
|
|
RegisterButton.Addchild(RegisterTextActor);
|
|
|
|
|
AddUIChild(RegisterButton);
|
2025-01-04 20:03:17 +08:00
|
|
|
|
2024-12-11 15:08:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function RegisterDraw() {
|
|
|
|
|
//大背景
|
|
|
|
|
local BackGround = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbackground.img", 14);
|
|
|
|
|
Addchild(BackGround);
|
|
|
|
|
//左上角的背景
|
|
|
|
|
local Cover = CL_SpriteObject("sprite/interface2/channel/channelselect/channelbackground/channelbackground.img", 20);
|
|
|
|
|
Addchild(Cover);
|
|
|
|
|
//登录框的背景
|
|
|
|
|
local LoginBoxBg = CL_SpriteObject("sprite/login_ui.img", 3);
|
|
|
|
|
LoginBoxBg.SetPosition(634, 0);
|
|
|
|
|
Addchild(LoginBoxBg);
|
|
|
|
|
local AniObj = Animation("ui/selectcharacter/animation/selectcharactereffect.ani");
|
|
|
|
|
AniObj.SetPosition(770, 0);
|
|
|
|
|
Addchild(AniObj);
|
|
|
|
|
//登录游戏字体
|
|
|
|
|
local LoginText = CL_SpriteObject("sprite/login_ui.img", 0);
|
|
|
|
|
LoginText.SetPosition(796, 65);
|
|
|
|
|
Addchild(LoginText);
|
|
|
|
|
//登录游戏说明
|
|
|
|
|
local LoginTexttip = CL_SpriteObject("sprite/login_ui.img", 1);
|
|
|
|
|
LoginTexttip.SetPosition(-33, 40);
|
|
|
|
|
LoginText.Addchild(LoginTexttip);
|
|
|
|
|
|
|
|
|
|
//账号
|
2024-12-14 23:15:53 +08:00
|
|
|
local AccountTextActor = FontAssetManager.GenerateNormal("账号:", false, {
|
|
|
|
|
color = sq_RGBA(200, 195, 169, 255)
|
|
|
|
|
});
|
2024-12-11 15:08:57 +08:00
|
|
|
AccountTextActor.SetPosition(720, 241);
|
|
|
|
|
Addchild(AccountTextActor);
|
|
|
|
|
//密码
|
2024-12-14 23:15:53 +08:00
|
|
|
local PasswordTextActor = FontAssetManager.GenerateNormal("密码:", false, {
|
|
|
|
|
color = sq_RGBA(200, 195, 169, 255)
|
|
|
|
|
});
|
2024-12-11 15:08:57 +08:00
|
|
|
PasswordTextActor.SetPosition(720, 281);
|
|
|
|
|
Addchild(PasswordTextActor);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 20:51:26 +08:00
|
|
|
|
2024-12-11 15:08:57 +08:00
|
|
|
//逻辑入口
|
|
|
|
|
function Proc(Dt) {
|
2024-12-19 23:55:34 +08:00
|
|
|
if (Visible) MusicLogic();
|
2024-12-11 15:08:57 +08:00
|
|
|
SyncPos(X, Y);
|
|
|
|
|
base.Proc(Dt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|