Compare commits

...

21 Commits

Author SHA1 Message Date
WONIU dd69f0a65b 同步合并
# Conflicts:
#	sqr/SquirrelFileConfig.cfg
#	sqr/User/UI/Window/233_HUD_Message.nut
#	sqr/folder-alias.json
2024-12-15 21:48:29 +08:00
Lenheart ebd130349a PVF资源管理读取Equ添加缓存 2024-12-15 20:23:11 +08:00
Lenheart 622fe5330d 角色动画类更新 2024-12-15 20:22:46 +08:00
Lenheart a397f5198b 添加角色类更换装备的保护检测 2024-12-15 20:21:17 +08:00
Lenheart 0577e6bb66 场景更新 2024-12-15 20:17:40 +08:00
Lenheart 46de44df96 Socket发包接口修复 2024-12-15 20:17:09 +08:00
Lenheart 1a862df685 为Item装备类添加构造保护 2024-12-15 20:16:48 +08:00
Lenheart eca5da2ff9 UI核心类的 Proc与Update冲突修复 2024-12-15 20:16:26 +08:00
Lenheart fc62731bcd 关闭debug 2024-12-15 20:16:01 +08:00
Lenheart d8faa49866 深拷贝函数重构优化性能 2024-12-15 20:15:48 +08:00
Lenheart 230ddba3f6 窗口UI更新 2024-12-15 20:15:29 +08:00
WONIU 3d8c996f6b 公告消息弹窗(动态大小)
(cherry picked from commit c7dfe7c994)
2024-12-14 23:46:53 +08:00
WONIU 7d5a49862c 九宫格拉伸
(cherry picked from commit 68068e79ff)
2024-12-14 23:46:41 +08:00
Lenheart eeaeff06ce no message 2024-12-14 23:18:06 +08:00
Lenheart cd4e30774c 完善滚动条控件 2024-12-14 23:16:14 +08:00
Lenheart 254d6856c2 因为GenerateNormal 文字类的修改 而修改的UI窗口例程 2024-12-14 23:15:53 +08:00
Lenheart 5cacad707e 修改UI类基类 根据窗口和控件类型选定不同基类 2024-12-14 23:15:06 +08:00
Lenheart f430d6af41 更新GenerateNormal 文字的 参数 2024-12-14 21:31:44 +08:00
Lenheart fc18097b7a 滚动栏封装 2024-12-14 16:14:16 +08:00
Lenheart 1e45bf6958 可拖动按钮封装 2024-12-14 16:13:56 +08:00
Lenheart 2dd1bb90b9 更新主程序 修复LayerActor BUG 2024-12-14 16:13:43 +08:00
17 changed files with 343 additions and 97 deletions

Binary file not shown.

View File

@ -6,16 +6,16 @@
*/
class Layer extends Actor {
constructor(...) {
local C_Object;
if (vargv.len() == 0) {
C_Object = LayerActor_Create();
base.constructor(C_Object);
} else {
C_Object = vargv[0];
base.constructor(C_Object, true);
}
}
// constructor(...) {
// local C_Object;
// if (vargv.len() == 0) {
// C_Object = LayerActor_Create();
// base.constructor(C_Object);
// } else {
// C_Object = vargv[0];
// base.constructor(C_Object, true);
// }
// }
//设置图层裁剪区域
function SetClipRect(x, y, w, h) {

View File

@ -24,10 +24,21 @@ function print(Object) {
/*
* @函数作用: 深拷贝Table
*/
// function sq_DeepCopy(original) {
// local Ret = Json.Encode(original);
// Ret = Json.Decode(Ret);
// return Ret;
// }
function sq_DeepCopy(original) {
local Ret = Json.Encode(original);
Ret = Json.Decode(Ret);
return Ret;
local RetTable = clone(original);
foreach(Key, Value in original) {
if (typeof Value == "table") {
RetTable[Key] = sq_DeepCopy(Value);
} else if (typeof Value == "array") {
RetTable[Key] = sq_DeepCopy(Value);
}
}
return RetTable;
}
/*

View File

@ -25,9 +25,20 @@ class Yosin_BaseWindow extends Layer {
Y = null;
B_Y = null;
constructor() {
//构造函数 创建一个空Actor
base.constructor();
function _typeof() {
return "Yosin_BaseWindow";
}
//构造函数
constructor(IsWindowFlag = false) {
local ObjectBuf;
//如果是游戏窗口类 则以Layer为基类 否则以Actor为基类
if (IsWindowFlag) {
ObjectBuf = LayerActor_Create();
base.constructor(ObjectBuf);
} else {
base.constructor();
}
//子控件list初始化
UI_Childrens = [];
@ -111,8 +122,6 @@ class Yosin_BaseWindow extends Layer {
if (Window.UpdateFunc) Window.UpdateFunc(Window, Dt);
Window.Proc(Dt);
}
//显示才调用Update
if (Visible) base.OnUpdate(Dt);
}
//同步坐标
function SyncPos(X, Y) {
@ -190,9 +199,10 @@ class Yosin_Window extends Yosin_BaseWindow {
Y = gY;
//调用原生方法
base.constructor();
base.constructor(true);
SetSize(Width, Height);
SyncPos(X, Y);
}
//切换到最上层窗口 即得到焦点时 全局窗口才调用 子窗口请不要调用此函数
@ -331,6 +341,8 @@ class Yosin_Window extends Yosin_BaseWindow {
//调用原生方法
base.OnMouseWheel(Flag, MousePos_X, MousePos_Y);
}
}
//创建窗口
@ -366,6 +378,8 @@ function _Yosin_Windows_Logic_(Dt, Ui_Layer) {
}
//无论窗口是否显示都需要调用Proc
Window.Proc(Dt);
//无论是否显示都调用Update
Window.OnUpdate(Dt);
}
}

View File

@ -51,6 +51,15 @@ class _AssetManager_ {
DataTable.growtype[i].name <- name;
}
}
//默认时装
else if (Key == "[default avatar]") {
DataTable.default_avatar <- [];
while (true) {
local Ret = Data.Get();
if (Ret == "[/default avatar]") break;
DataTable.default_avatar.append(Ret);
}
}
//基础属性
else if (Key == "[HP MAX]]" || Key == "[MP MAX]]" || Key == "[physical attack]]" || Key == "[physical defense]]" || Key == "[magical attack]]" || Key == "[magical defense]]" || Key == "[inventory limit]]" || Key == "[MP regen speed]]" || Key == "[move speed]]" || Key == "[attack speed]]" || Key == "[cast speed]]" || Key == "[hit recovery]]" || Key == "[jump power]]" || Key == "[weight]]" || Key == "[jump speed]]") {
local RealKey = Key.slice(1, Key.len() - 1);
@ -115,7 +124,11 @@ class _AssetManager_ {
EquipmentList = ScriptData.GetFileData("equipment/equipment.lst", function(DataTable, Data) {
while (!Data.Eof()) {
local Key = Data.Get();
DataTable.rawset(Key, Data.Get());
//注册装备列表 路径写入 数据未读取
DataTable.rawset(Key, {
Path = Data.Get(),
Data = null
});
}
if (_DEBUG_) print("加载装备List完成, 共" + DataTable.len() + "个");
});
@ -141,7 +154,9 @@ class _AssetManager_ {
function GetEquipment(Idx) {
//如果没有这件装备则返回
if (!(EquipmentList.rawin(Idx))) return;
local Path = EquipmentList[Idx];
//如果装备数据已经读取过存在了则直接返回
if (EquipmentList[Idx].Data) return EquipmentList[Idx].Data;
local Path = EquipmentList[Idx].Path;
local m_data = ScriptData.GetFileData("equipment/" + Path, function(DataTable, Data) {
DataTable.DirPath <- DataTable.filepath.slice(0, DataTable.filepath.lastfind("/") + 1);
while (!Data.Eof()) {
@ -203,6 +218,7 @@ class _AssetManager_ {
}
}
});
EquipmentList[Idx].Data = m_data;
return m_data;
}
}

View File

@ -232,9 +232,7 @@ class Character_Animation extends Actor {
}
//初始化
function Init(...) {
local SlotType = false;
if (vargv.len() > 0) SlotType = vargv[0];
function Init(SlotType = false) {
//读取并设置 等待Ani
ReadAndSetAni("WaitingAni", "waiting motion", SlotType);
//读取并设置 移动Ani

View File

@ -43,14 +43,14 @@ class GameItem.Equipment extends GameItem.Item {
local EquInfo = AssetManager.GetEquipment(vargv[0]);
if (EquInfo) {
Idx = vargv[0];
Name = EquInfo["name"];
GetRealEquipmentType(EquInfo["type"].path);
Minimum_level = EquInfo["minimum level"];
Grade = EquInfo["grade"];
Job = EquInfo["usable_job"];
Icon = EquInfo["icon"];
Animation_Job = EquInfo["Ani"];
DirPath = EquInfo["DirPath"];
if (EquInfo.rawin("name")) Name = EquInfo["name"];
if (EquInfo.rawin("type")) GetRealEquipmentType(EquInfo["type"].path);
if (EquInfo.rawin("minimum level")) Minimum_level = EquInfo["minimum level"];
if (EquInfo.rawin("grade")) Grade = EquInfo["grade"];
if (EquInfo.rawin("usable_job")) Job = EquInfo["usable_job"];
if (EquInfo.rawin("icon")) Icon = EquInfo["icon"];
if (EquInfo.rawin("Ani")) Animation_Job = EquInfo["Ani"];
if (EquInfo.rawin("DirPath")) DirPath = EquInfo["DirPath"];
}
}
}

View File

@ -36,6 +36,10 @@ class GameObject.Character extends GameObject.ActiveObject {
Addchild(AnimationManager);
AnimationManager.Init();
foreach(EquId in Info.default_avatar) {
local EquObj = GameItem.Equipment(EquId);
ChangeEquipment(EquObj);
}
//构造属性对象
// Attribute = AttributeClass();
}
@ -108,12 +112,15 @@ class GameObject.Character extends GameObject.ActiveObject {
//通过职业和装备列表来构造一个角色
GameObject.CreateCharacter <- function(Job = 0, EquIdList = []) {
//构造角色
local Character = GameObject.Character();
Character.Init(Job);
foreach(EquId in EquIdList) {
local EquObj = GameItem.Equipment(EquId);
Character.ChangeEquipment(EquObj);
if (EquId > 0) {
local EquObj = GameItem.Equipment(EquId);
Character.ChangeEquipment(EquObj);
}
}
return Character;
}

View File

@ -26,6 +26,7 @@ class MySocket extends Socket {
State = 1;
}.bindenv(this));
BindFunc(SOCKET_CALLBACK_TYPE.onReceive, function(PacketId, Str) {
// print("收到消息:" + PacketId + " " + Str);
//如果存在对应处理逻辑
if (PackHandler.rawin(PacketId)) {
//将字符画序列化json
@ -57,8 +58,10 @@ class MySocket extends Socket {
//发包
function Send(PacketId, Jso) {
//将json序列化字符串
local Str = Json.Encode(Jso);
Socket_SendPacket(getroottable()._MySocket_.Client, PacketId, Str);
local SendObject;
if (typeof Jso == "table") SendObject = Json.Encode(Jso); //table转json字符串 字符串包
else if (typeof Jso == "blob") SendObject = Jso; //字节流包
else SendObject = ""; //空包
Socket_SendPacket(getroottable()._MySocket_.Client, PacketId, SendObject);
}
}

View File

@ -6,8 +6,8 @@
*/
function InitGame() {
//初始化Socekt连接
// MySocket("192.168.200.24", 19666);
MySocket("127.0.0.1", 19666);
MySocket("192.168.200.15", 19003);
// MySocket("127.0.0.1", 19666);
//设定全局默认音量
_Globa_Audio_Volume_ = 0.1;

View File

@ -11,14 +11,9 @@ function TestStage() {
// local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
local T = {
Background = 0
}
Window.Init(T);
// local Fontobj = Font();
@ -54,4 +49,28 @@ function TestStage() {
// Charc.SetAnimation("RestAni");
// Charc.SetZOrder(99999999);
// MapObj.Addchild(Charc);
// local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
// local T = {
// Background = 1,
// Charc = [{
// Job = 0,
// Ava = [601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]
// }, {
// Job = 0,
// Ava = [601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]
// }, {
// Job = 0,
// Ava = [601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]
// }, {
// Job = 0,
// Ava = [601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]
// }, {
// Job = 0,
// Ava = [601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]
// }]
// };
// Window.Init(T);
}

View File

@ -9,19 +9,44 @@ class Yosin_DragButton extends Yosin_CommonUi {
Path = "";
//索引
Idx = 0;
//方向
Direction = true;
//按钮
Button = null;
//变动位置回调函数
OnChange = null;
//鼠标相对位置
M_Xpos = null;
M_Ypos = null;
//未移动时的初始坐标
BasePos = null;
//移动Flag
MoveFlag = false;
//最大移动值
Max_Move_Value = 0;
//移动值
Move_Value = 0;
//侦测值
Detect_Value = 0;
constructor(X, Y, W, H, Path, Idx, Direction = true, UnavailableFlag = true) {
this.Path = Path;
this.Idx = Idx;
this.Direction = Direction;
base.constructor(X, Y, W, H);
Button = Yosin_SplicingButton(0, 0, W, H, Path, Idx, Direction, UnavailableFlag);
Button.DownSimulateOffset = false;
AddUIChild(Button);
BasePos = {
x = X,
y = Y
}
}
//override
@ -29,5 +54,55 @@ class Yosin_DragButton extends Yosin_CommonUi {
function OnMouseLbDown(MousePos_X, MousePos_Y) {
base.OnMouseLbDown(MousePos_X, MousePos_Y);
if (isInRect) {
MoveFlag = true;
M_Xpos = MousePos_X; //原始鼠标位置数据
M_Ypos = MousePos_Y;
B_X = X; //原始窗口位置
B_Y = Y;
}
}
//override
function OnMouseProc(MousePos_X, MousePos_Y) {
//调用原生方法
base.OnMouseProc(MousePos_X, MousePos_Y);
//移动
if (MoveFlag) {
//左键拖动
if (Direction) {
Move_Value = B_X + (MousePos_X - M_Xpos);
if (!(Move_Value >= (0 + BasePos.x) && Move_Value <= (Max_Move_Value - Width + BasePos.x))) {
X = Move_Value;
DragLogic((Move_Value - Localtion_X).tofloat() / (Max_Move_Value - Width + BasePos.x - Localtion_X).tofloat());
}
} else {
Move_Value = B_Y + (MousePos_Y - M_Ypos);
if (Move_Value >= (0 + BasePos.y) && Move_Value <= (Max_Move_Value - Height + BasePos.y)) {
Y = (Move_Value);
DragLogic((Move_Value - Localtion_Y).tofloat() / (Max_Move_Value - Height + BasePos.y - Localtion_Y).tofloat());
}
}
SyncPos(X, Y);
}
}
//拖动逻辑
function DragLogic(Value) {
Detect_Value = Value;
if (OnChange) OnChange(Value);
}
//鼠标左键弹起回调
function OnMouseLbUp(MousePos_X, MousePos_Y) {
base.OnMouseLbUp(MousePos_X, MousePos_Y);
MoveFlag = false;
}
//设置最大移动值
function SetMaxMoveValue(Value) {
Max_Move_Value = Value;
}
}

View File

@ -4,7 +4,7 @@
创建日期:2024-12-13 23:17
文件用途:
*/
//基础按钮
//滚动条
class Yosin_ScrollBar extends Yosin_CommonUi {
//控制器
Controller = null;
@ -14,18 +14,22 @@ class Yosin_ScrollBar extends Yosin_CommonUi {
//上按钮
UpButton = null;
//滚动按钮
ScrollButton = null;
//下按钮
DownButton = null;
//回调函数
OnChange = null;
//Path
Path = "sprite/interface/lenheartwindowcommon.img";
constructor(X, Y, H, gSize) {
constructor(X, Y, H, S_H) {
base.constructor(X, Y, 9, H > 26 ? H : 26);
Controller = {
CurPos = 0,
Size = gSize
}
//上按钮
@ -37,6 +41,9 @@ class Yosin_ScrollBar extends Yosin_CommonUi {
AddUIChild(UpButton);
//滚动条
ScrollButton = Yosin_DragButton(0, 13, 9, S_H, Path, 184, false, false);
ScrollButton.SetMaxMoveValue(Height - 26);
AddUIChild(ScrollButton);
//下按钮
DownButton = Yosin_BaseButton(0, Height - 13, 9, 13, Path, 22);
@ -50,6 +57,11 @@ class Yosin_ScrollBar extends Yosin_CommonUi {
function Proc(Dt) {
base.Proc(Dt);
Controller.CurPos = ScrollButton.Detect_Value;
}
function SetChangeCallBack(Func) {
ScrollButton.OnChange = Func;
}
}

View File

@ -19,6 +19,9 @@ class _Login_Window extends Yosin_Window {
BackGroundMusic = null;
//信息
PackInfo = null;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
@ -30,6 +33,35 @@ class _Login_Window extends Yosin_Window {
//播放音乐
PlayBackgroundMusic();
//注册登录回调包
MySocket.RegisterHandler(2, function(Jso) {
//登录成功
if (Jso.state) {
HUD_Message(500, 200, "登录成功,正在进入游戏...");
MySocket.Send(9, null);
} else {
HUD_Message(500, 200, "登录失败");
}
}.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);
}
}
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
Window.Init(PackInfo);
}.bindenv(this));
}
function PlayBackgroundMusic() {
@ -62,7 +94,9 @@ class _Login_Window extends Yosin_Window {
}.bindenv(this);
//登录按钮文本
local LoginTextActor = FontAssetManager.GenerateNormal("登录", sq_RGBA(200, 195, 169, 255), true);
local LoginTextActor = FontAssetManager.GenerateNormal("登录", true, {
color = sq_RGBA(200, 195, 169, 255)
});
LoginTextActor.SetPosition(26, 4);
LoginButton.Addchild(LoginTextActor);
AddUIChild(LoginButton);
@ -77,7 +111,9 @@ class _Login_Window extends Yosin_Window {
})
}.bindenv(this);
//注册按钮文本
local RegisterTextActor = FontAssetManager.GenerateNormal("注册", sq_RGBA(200, 195, 169, 255), true);
local RegisterTextActor = FontAssetManager.GenerateNormal("注册", true, {
color = sq_RGBA(200, 195, 169, 255)
});
RegisterTextActor.SetPosition(26, 4);
RegisterButton.Addchild(RegisterTextActor);
AddUIChild(RegisterButton);
@ -107,11 +143,15 @@ class _Login_Window extends Yosin_Window {
LoginText.Addchild(LoginTexttip);
//账号
local AccountTextActor = FontAssetManager.GenerateNormal("账号:", sq_RGBA(200, 195, 169, 255), false);
local AccountTextActor = FontAssetManager.GenerateNormal("账号:", false, {
color = sq_RGBA(200, 195, 169, 255)
});
AccountTextActor.SetPosition(720, 241);
Addchild(AccountTextActor);
//密码
local PasswordTextActor = FontAssetManager.GenerateNormal("密码:", sq_RGBA(200, 195, 169, 255), false);
local PasswordTextActor = FontAssetManager.GenerateNormal("密码:", false, {
color = sq_RGBA(200, 195, 169, 255)
});
PasswordTextActor.SetPosition(720, 281);
Addchild(PasswordTextActor);
}

View File

@ -82,16 +82,16 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
//选择背景按钮集合
SettingBackgroundButtonList = null;
//背景对象
Background = null;
ScrollObject = null;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
SettingBackgroundButtonList = [];
// SetClipRect(-gWidth, 0, gWidth, gHeight + 20);
// SetClipRect(0, 0, 1066, 600);
// ShowBorder(true);
// SetLayerOpacity(1);
SetClipRect(5, 9, gWidth, gHeight - 9);
}
function Init() {
@ -102,25 +102,72 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
function RegisterDraw() {
//背景
Background = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/setup/setup.img", 17);
Addchild(Background);
Background.SetPosition(X, Y);
Background.SetZOrder(-10);
Background.SetVisible(false);
//因为裁切原因 所以要添加到父对象中
Parent.Addchild(Background);
for (local i = 0; i< 24; i++) {
local Buf = _Select_Character_SettingBackground_Object_Window(5 + (101 * (i % 2)), 9 + (61 * (i / 2)), 91, 51, i);
SettingBackgroundButtonList.push(Buf);
//如果是父对象默认构造的默认是勾选状态
if (i == Parent.Info.Background) {
if (i == Parent.Info.loginImg) {
Buf.SelectMask.SetVisible(true);
Buf.SelectFlag = true;
}
AddUIChild(Buf);
}
ScrollObject = Yosin_ScrollBar(Width - 13, 5, Height - 8, 20);
ScrollObject.SetChangeCallBack(function(Value) {
foreach(Pos, Button in SettingBackgroundButtonList) {
Button.SetPosition(5 + (101 * (Pos % 2)), 9 + (61 * (Pos / 2)) - Value * (61 * 12));
}
}.bindenv(this));
AddUIChild(ScrollObject);
}
//逻辑入口
function Proc(Dt) {
SyncPos(X, Y);
base.Proc(Dt);
//override
//设置是否可见 通过重载设置可见同步Background的可见性
function SetVisible(Flag) {
base.SetVisible(Flag);
if (Flag) {
if (Background) Background.SetVisible(true);
} else {
if (Background) Background.SetVisible(false);
}
}
}
//角色
class _Select_Character_Chr extends Yosin_Window {
//是否为独立窗口
IsIndependent = false;
Info = null;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
RegisterDraw();
}
function Init(Info) {
this.Info = Info;
RegisterCharac();
}
function RegisterDraw() {
local Magic = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/selectcharacter.img", 10);
Addchild(Magic);
}
function RegisterCharac() {
local Charc = GameObject.CreateCharacter(Info.job, Info.equip);
Charc.SetAnimation("RestAni");
Charc.SetPosition(48, 12, 0);
Addchild(Charc);
}
}
@ -141,6 +188,8 @@ class _Select_Character_Window extends Yosin_Window {
SettingBackgroundWindow = null;
//背景图片
BackGround = null;
//角色遮罩栏
CharacterMaskBox = null;
//信息
Info = null;
@ -157,6 +206,9 @@ class _Select_Character_Window extends Yosin_Window {
//注册绘制
RegisterDraw();
//注册控件
// for (local i = 0; i< 50; i++) {
// RegisterWidget();
// }
RegisterWidget();
//注册窗口
RegisterWindow();
@ -181,6 +233,13 @@ class _Select_Character_Window extends Yosin_Window {
AddUIChild(SettingBackgroundWindow);
//先添加为子对象 因为子对象需要用到父对象
SettingBackgroundWindow.Init();
//角色对象
for (local i = 0; i< 5; i++) {
local Buf = _Select_Character_Chr("选择角色角色对象" + i, 190 + (i * 144), ((i % 2) ? 15 : 0) + 225, 126, 208, 0);
if (i< Info.charac.len()) Buf.Init(Info.charac[i]);
AddUIChild(Buf);
}
}
function RegisterWidget() {
@ -192,7 +251,9 @@ class _Select_Character_Window extends Yosin_Window {
}.bindenv(this);
AddUIChild(SettingButton);
//登录按钮文本
local LoginTextActor = FontAssetManager.GenerateNormal("背景设置", sq_RGBA(221, 197, 147, 255), true);
local LoginTextActor = FontAssetManager.GenerateNormal("背景设置", true, {
color = sq_RGBA(221, 197, 147, 255)
});
LoginTextActor.SetPosition(23, 3);
LoginTextActor.SetUpdateFunc(function(Text, Dt) {
if (Text.Parent.State == 1 || Text.Parent.State == 2) {
@ -203,14 +264,6 @@ class _Select_Character_Window extends Yosin_Window {
})
SettingButton.Addchild(LoginTextActor);
// local TestButton = Yosin_ScrollBar(300, 200, 50, 100);
// AddUIChild(TestButton);
// local TestButton = Yosin_SplicingButton(200, 200, 77, 68, "sprite/interface/lenheartwindowcommon.img", 184, false, false);
// TestButton.DownSimulateOffset = false;
local TestButton = Yosin_DragButton(200, 200, 9, 120, "sprite/interface/lenheartwindowcommon.img", 184, false, false);
// TestButton.SetScale(5.0, 5.0);
AddUIChild(TestButton);
}
//切换背景
@ -220,23 +273,18 @@ class _Select_Character_Window extends Yosin_Window {
BackGround = null;
}
BackGround = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/background/large/background_large_event.img", Idx);
BackGround.SetZOrder(-10);
/*
BackGround = Layer();
BackGround.Addchild(CL_SpriteObject("sprite/interface2/selectcharacter_ver2/background/large/background_large_event.img", Idx));
BackGround.SetZOrder(-10);
BackGround.SetPosition(100, 100);
BackGround.SetClipRect(0, 0, 200, 200);
*/
BackGround.SetZOrder(-100);
Addchild(BackGround);
}
function RegisterDraw() {
//大背景 根据玩家的设定背景决定
ChangeBackground(Info.Background);
ChangeBackground(Info.loginImg);
//角色遮罩栏
CharacterMaskBox = Yosin_NineBoxStretch(-4, 330, 1074, 680, "sprite/interface/lenheartwindowcommon.img", 0);
AddUIChild(CharacterMaskBox);
}

View File

@ -30,10 +30,10 @@ class HUD_Message extends Yosin_Window {
horizontalMargin = 20,
// 垂直边距
verticalMargin = 20,
} ) {
}) {
local title = info.rawin("title") ? info.title : "公告";
local horizontalMargin = info.rawin("horizontalMargin") ? info.horizontalMargin : 20;
local title = info.rawin("title") ? info.title : "公告";
local horizontalMargin = info.rawin("horizontalMargin") ? info.horizontalMargin : 20;
local verticalMargin = info.rawin("verticalMargin") ? info.verticalMargin : 20;
// 标题
@ -59,17 +59,16 @@ class HUD_Message extends Yosin_Window {
local verticalMargin = 50 + verticalMargin * 2;
cacheH = messageTextActor.GetSize().h + verticalMargin;
print("cacheW:" + cacheW.tostring());
print("cacheH:" + cacheH.tostring());
// 默认构造数据
base.constructor("公告或信息弹窗" + clock().tostring() , gX, gY, cacheW, cacheH, 20);
base.constructor("公告或信息弹窗" + clock().tostring(), gX, gY, cacheW, cacheH, 20);
//注册控件
RegisterWidget();
//注册绘制
RegisterDraw();
ResetFocus();
}
function RegisterWidget() {
@ -84,9 +83,10 @@ class HUD_Message extends Yosin_Window {
AddUIChild(titleBackground);
//确认按钮
local confirmButton = Yosin_BaseButton( cacheW / 2 - 28, cacheH - 15, 56, 24 "sprite/interface/lenheartwindowcommon.img", 12);
local confirmButton = Yosin_BaseButton(cacheW / 2 - 28, cacheH - 15, 56, 24 "sprite/interface/lenheartwindowcommon.img", 12);
confirmButton.OnClick = function(Button) {
this.RemoveSelf();
//关闭本窗口
CloseWindow();
}.bindenv(this);
AddUIChild(confirmButton);
@ -96,9 +96,10 @@ class HUD_Message extends Yosin_Window {
confirmButton.Addchild(confirmTextActor);
//关闭按钮
local closeButton = Yosin_BaseButton( cacheW - 15, 5, 10, 9 "sprite/interface/lenheartwindowcommon.img", 42);
local closeButton = Yosin_BaseButton(cacheW - 15, 5, 10, 9 "sprite/interface/lenheartwindowcommon.img", 42);
closeButton.OnClick = function(Button) {
this.RemoveSelf();
//关闭本窗口
CloseWindow();
}.bindenv(this);
AddUIChild(closeButton);
@ -109,7 +110,7 @@ class HUD_Message extends Yosin_Window {
local titleX = cacheW / 2 - titleTextActor.GetSize().w / 2;
// 绘制标题
titleTextActor.SetPosition( titleX , 2);
titleTextActor.SetPosition(titleX, 2);
Addchild(titleTextActor);
@ -117,7 +118,7 @@ class HUD_Message extends Yosin_Window {
local messageY = cacheH / 2 - messageTextActor.GetSize().h / 2;
// 绘制内容
messageTextActor.SetPosition( messageX , messageY );
messageTextActor.SetPosition(messageX, messageY);
Addchild(messageTextActor);
}

View File

@ -9,12 +9,14 @@
function main(args) {
local Game = GameWindow();
Game.title = "Yosin & Kiwano";
Game.bg_color = [255.0, 255.0, 255.0, 255.0];
Game.size = [1066, 600];
Game.v_sync = false;
Game.frame_interval = 10000;
Game.debug_mode = true;
// Game.debug_mode = true;
Game.Run(LoginStage);
}