Merge remote-tracking branch 'origin/dong' into yi

# Conflicts:
#	sqr/User/UI/Window/5_Inventory/5_Inventory.nut
This commit is contained in:
WONIU 2025-01-12 16:41:55 +08:00
commit 334fce6c86
10 changed files with 195 additions and 47 deletions

View File

@ -29,5 +29,8 @@ function _Yosin_Game_Logic_(Dt, GameListener) {
} }
} }
} }
try {
remove("Yosin_Game_Reloading.Sign");
} catch (exception) {
remove("Yosin_Game_Reloading.Sign"); }

View File

@ -255,6 +255,7 @@ class Yosin_Window extends Yosin_BaseWindow {
//切换到最上层窗口 即得到焦点时 全局窗口才调用 子窗口请不要调用此函数 //切换到最上层窗口 即得到焦点时 全局窗口才调用 子窗口请不要调用此函数
function ResetFocus() { function ResetFocus() {
this.Visible = true; this.Visible = true;
SetVisible(true);
//遍历全局窗口数组将自己移除重新添加在末尾 //遍历全局窗口数组将自己移除重新添加在末尾
foreach(Index, WindowObj in _SYS_WINDOW_LIST_) { foreach(Index, WindowObj in _SYS_WINDOW_LIST_) {
WindowObj.SetZOrder(10000000 + Index + (WindowObj.IsTop ? 10000000 : 0)); WindowObj.SetZOrder(10000000 + Index + (WindowObj.IsTop ? 10000000 : 0));
@ -402,7 +403,7 @@ function Sq_CreateWindow(ClassName, gObjectId, gX, gY, gWidth, gHeight, gTitleH)
//窗口逻辑入口 C回调 //窗口逻辑入口 C回调
function _Yosin_Windows_Logic_(Dt, Ui_Layer) { function _Yosin_Windows_Logic_(Dt, Ui_Layer) {
_UiObject_ = Actor(Ui_Layer); if (!_UiObject_) _UiObject_ = Actor(Ui_Layer);
//遍历窗口队列 如果可见则调用Show //遍历窗口队列 如果可见则调用Show
for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) { for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
local Window = _SYS_WINDOW_LIST_[i]; local Window = _SYS_WINDOW_LIST_[i];

View File

@ -39,12 +39,9 @@ class _GameController_ extends _Input_ {
this.KeyCode[Code] = Status; this.KeyCode[Code] = Status;
//只遍历有回调的键码 //只遍历有回调的键码
foreach(Code, Callback in GameKeyCodeCallback) { foreach(RCode, Callback in GameKeyCodeCallback) {
//是否按下传递不同指令 if (RCode == Code) {
if (GetGameKeyCode(Code)) { Callback(Status);
Callback(true);
} else {
Callback(false);
} }
} }
} }

View File

@ -15,16 +15,123 @@ function RegisterFunctionalPack() {
Charc.Cid = Info.cid; Charc.Cid = Info.cid;
TownObj.AddObject(Charc, true); TownObj.AddObject(Charc, true);
ClientCharacter = Charc; ClientCharacter = Charc;
//以下是角色应当初始化的各项东西
{
//初始化背包
if (ClientCharacterInventory) {
ClientCharacterInventory.DestroyWindow();
}
ClientCharacterInventory = _Inventory("背包窗口", 150, 12, 262, 548, 20);
}
}); });
/*
InventorySize : int //背包大小
InventoryType : byte //背包类型
InventoryItemCount : short //背包道具数量
ItemInfo : Struct //道具信息 结构体
{
Type : byte //类型
// Type 为 1 装备类型
{
Pos : short //装备位置
EquipId : int //装备ID
EquipEnchant : int //装备附魔编号
EquipUpgrade : byte //装备强化等级或增幅等级
EquipSeparate : byte //装备锻造
EquipIncrease : byte //装备增幅属性 0 无 1 力量 2 智力 3 体力 4 精神
EquipPowerPercentage : byte //装备力量百分比
EquipIntellectPercentage : byte //装备智力百分比
EquipStaminaPercentage : byte //装备体力百分比
EquipSpiritPercentage : byte //装备精神百分比
EquipPhysicalAttackPercentage : byte //装备物理攻击百分比
EquipMagicAttackPercentage : byte //装备魔法攻击百分比
EquipIndependentAttackPercentage : byte //装备独立攻击百分比
EquipPhysicalDefensePercentage : byte //装备物理防御百分比
EquipMagicDefensePercentage : byte //装备魔法防御百分比
EquipWrapCount : byte //装备再封装次数
}
// Type 为 2 消耗品类型
{
Pos : short //道具位置
ItemId : int //道具ID
ItemCount : int //道具数量
}
}
*/
//刷新客户端角色背包数据 //刷新客户端角色背包数据
MySocket.RegisterBinaryHandler(PACKET_ID.REFRESH_CLIENT_CHARACTER_INVENTORY_DATA_CALLBACK, function(Binary) { MySocket.RegisterBinaryHandler(PACKET_ID.REFRESH_CLIENT_CHARACTER_INVENTORY_DATA_CALLBACK, function(Binary) {
local Pack = Packet(Binary); local Pack = Packet(Binary);
local op = Pack.Get_Int(); local op = Pack.Get_Int();
//背包大小 //背包大小
local size = Pack.Get_Int(); local InventorySize = Pack.Get_Int();
//背包类型 //背包类型
local type = Pack.Get_Int(); local InventoryType = Pack.Get_Byte();
//背包道具数量
local InventoryItemCount = Pack.Get_Int();
//项目List
local ItemList = [];
//道具数据
for (local i = 0; i< InventoryItemCount; i++) {
local Type = Pack.Get_Byte();
//装备类型
if (Type == 1) {
local EquInfo = {
//装备位置
Pos = Pack.Get_Short(),
//装备ID
EquipId = Pack.Get_Int(),
//装备附魔编号
EquipEnchant = Pack.Get_Int(),
//装备强化等级或增幅等级
EquipUpgrade = Pack.Get_Byte(),
//装备锻造
EquipSeparate = Pack.Get_Byte(),
//装备增幅属性 0 无 1 力量 2 智力 3 体力 4 精神
EquipIncrease = Pack.Get_Byte(),
//装备力量百分比
EquipPowerPercentage = Pack.Get_Byte(),
//装备智力百分比
EquipIntellectPercentage = Pack.Get_Byte(),
//装备体力百分比
EquipStaminaPercentage = Pack.Get_Byte(),
//装备精神百分比
EquipSpiritPercentage = Pack.Get_Byte(),
//装备物理攻击百分比
EquipPhysicalAttackPercentage = Pack.Get_Byte(),
//装备魔法攻击百分比
EquipMagicAttackPercentage = Pack.Get_Byte(),
//装备独立攻击百分比
EquipIndependentAttackPercentage = Pack.Get_Byte(),
//装备物理防御百分比
EquipPhysicalDefensePercentage = Pack.Get_Byte(),
//装备魔法防御百分比
EquipMagicDefensePercentage = Pack.Get_Byte(),
//装备再封装次数
EquipWrapCount = Pack.Get_Byte(),
}
ItemList.push(EquInfo);
print("构造装备");
}
//消耗品类型
if (Type == 2) {
local ItemInfo = {
//道具位置
Pos = Pack.Get_Short(),
//道具ID
ItemId = Pack.Get_Int(),
//道具数量
ItemCount = Pack.Get_Int(),
}
ItemList.push(ItemInfo);
}
}
}); });
//城镇中添加角色的回包 //城镇中添加角色的回包

View File

@ -31,15 +31,15 @@ function TestStage() {
// Window.SetPosition(580, 80); // Window.SetPosition(580, 80);
// Window.ResetFocus(); // Window.ResetFocus();
// local TownObj = Town(1); // local TownObj = Town(2);
// local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]); // local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
// TownObj.AddObject(Charc, true); // TownObj.AddObject(Charc, true);
// ClientCharacter = Charc; // ClientCharacter = Charc;
local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 548, 20); // local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
// Window.equipmentPage.Item.ItemCollection.SetItemList([{ // Window.equipmentPage.ItemCollection.SetItemList([{
// ItemId = 27675 // ItemId = 27675
// }, { // }, {
// ItemId = 101020048 // ItemId = 101020048

View File

@ -86,10 +86,12 @@ class _Login_Window extends Yosin_Window {
function RegisterWidget() { function RegisterWidget() {
//账号输入框 //账号输入框
AccountInputBox = Yosin_InputBox(752, 240, 200); AccountInputBox = Yosin_InputBox(752, 240, 200);
AccountInputBox.str = "1"; //TODO 临时账户
AddUIChild(AccountInputBox); AddUIChild(AccountInputBox);
//密码输入框 //密码输入框
PasswordInputBox = Yosin_InputBox(752, 280, 200); PasswordInputBox = Yosin_InputBox(752, 280, 200);
PasswordInputBox.str = "1"; //TODO 临时账户
AddUIChild(PasswordInputBox); AddUIChild(PasswordInputBox);
//登录按钮 //登录按钮

View File

@ -4,13 +4,12 @@
创建日期:2025-01-06 14:06 创建日期:2025-01-06 14:06
文件用途: 背包窗口 文件用途: 背包窗口
*/ */
//主类
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
class _Inventory extends Yosin_Window { class _Inventory extends Yosin_Window {
// 装备页 // 装备页 /物品栏
equipmentPage = null; EquipmentPage = null;
// 装扮页 // 装扮页E
DressUpPage = null; DressUpPage = null;
// 物品栏排列按钮 // 物品栏排列按钮
@ -25,6 +24,8 @@ class _Inventory extends Yosin_Window {
// 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标 // 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标
itemSetBtnY = 467; itemSetBtnY = 467;
//是否可见
Visible = false;
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);
@ -34,6 +35,21 @@ class _Inventory extends Yosin_Window {
//注册控件 //注册控件
RegisterWidget(); RegisterWidget();
//注册按键回调事件
Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_ITEM_INVENTORY, function(Flag) {
//抬起的时候
if (Flag == 0) {
//如果窗口已经打开
if (this.Visible) {
//关闭窗口
CloseWindow();
} else {
//打开窗口
ResetFocus();
}
}
}.bindenv(this));
} }
function RegisterWidget() { function RegisterWidget() {
@ -46,7 +62,7 @@ class _Inventory extends Yosin_Window {
closeBtn.DownSimulateOffset = false; closeBtn.DownSimulateOffset = false;
closeBtn.SetZOrder(1); closeBtn.SetZOrder(1);
closeBtn.OnClick = function(btn) { closeBtn.OnClick = function(btn) {
print(13123123); CloseWindow();
} }
AddUIChild(closeBtn); AddUIChild(closeBtn);
//置顶按钮 //置顶按钮
@ -67,9 +83,9 @@ class _Inventory extends Yosin_Window {
}; };
//物品栏 装备页 //物品栏 装备页
equipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441); EquipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441);
AddUIChild(equipmentPage); AddUIChild(EquipmentPage);
equipmentPage.SetVisible(false); EquipmentPage.SetVisible(false);
// 装扮页 // 装扮页
DressUpPage = Inventory_DressUpPage(4, titlesBtn.bottom(), 300, 441); DressUpPage = Inventory_DressUpPage(4, titlesBtn.bottom(), 300, 441);
@ -110,7 +126,7 @@ class _Inventory extends Yosin_Window {
local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, { local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, {
color = txtColor color = txtColor
}); });
ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X , bg.Y + 2); ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X, bg.Y + 2);
Addchild(ReviveNum); Addchild(ReviveNum);
@ -135,7 +151,7 @@ class _Inventory extends Yosin_Window {
local storeNum = FontAssetManager.GenerateNormal("23434点券", true, { local storeNum = FontAssetManager.GenerateNormal("23434点券", true, {
color = txtColor color = txtColor
}); });
storeNum.SetPosition( bg.X + 120 - storeNum.GetSize().w , bg.Y + 27); storeNum.SetPosition(bg.X + 120 - storeNum.GetSize().w, bg.Y + 27);
Addchild(storeNum); Addchild(storeNum);
// 金币按钮 // 金币按钮
@ -149,7 +165,7 @@ class _Inventory extends Yosin_Window {
local storeNum = FontAssetManager.GenerateNormal("23434金币", true, { local storeNum = FontAssetManager.GenerateNormal("23434金币", true, {
color = txtColor color = txtColor
}); });
storeNum.SetPosition( bg.X + 245 - storeNum.GetSize().w, bg.Y + 27); storeNum.SetPosition(bg.X + 245 - storeNum.GetSize().w, bg.Y + 27);
Addchild(storeNum); Addchild(storeNum);
} }

View File

@ -2,31 +2,37 @@
文件名:Inventory_EquipmentPage.nut 文件名:Inventory_EquipmentPage.nut
路径:User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut 路径:User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut
创建日期:2025-01-06 13:50 创建日期:2025-01-06 13:50
文件用途: 背包装备页面 文件用途: 背包物品栏页面
*/ */
// 背包装备页面 // 背包物品栏页面
class Inventory_EquipmentPage extends Yosin_CommonUi { class Inventory_EquipmentPage extends Yosin_CommonUi {
// Item = null; //人物装备
CharactersEquipment = null;
//物品栏
ItemCollection = null; ItemCollection = null;
//重量进度条
WeightSchedule = null;
//总可承载重量
TotalLoadCapacity = 1.0;
//当前承载重量
CurrentLoadCapacity = 0.0;
constructor(x, y, w, h) { constructor(x, y, w, h) {
base.constructor(x, y, w, h); base.constructor(x, y, w, h);
// 人物装备 // 人物装备
local charactersEquipment = Inventory_CharactersEquipment(); CharactersEquipment = Inventory_CharactersEquipment();
charactersEquipment.SetPosition(5, 0); CharactersEquipment.SetPosition(5, 0);
Addchild(charactersEquipment); Addchild(CharactersEquipment);
// 添加书本按钮 // 添加书本按钮
AddBookButton(); AddBookButton();
// 物品栏 // 物品栏
AddItem(); AddItem();
} }
@ -34,9 +40,6 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
function AddBookButton() { function AddBookButton() {
// 称号 // 称号
local designation = Yosin_BaseButton(7, 145, 18, 20 "sprite/interface/newstyle/windows/inventory/inventory.img", 50); local designation = Yosin_BaseButton(7, 145, 18, 20 "sprite/interface/newstyle/windows/inventory/inventory.img", 50);
//点击事件回调
// permutationBtn.OnClick = function(Button) {
// }.bindenv(this);
AddUIChild(designation); AddUIChild(designation);
// 增益强化 // 增益强化
@ -73,8 +76,11 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
Addchild(itemBg); Addchild(itemBg);
// 物品栏 // 物品栏
ItemCollection = _ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7); ItemCollection = [];
AddUIChild(ItemCollection); for (local i = 0; i< 5; i++) {
ItemCollection.push(_ItemCollection(itemBg.X + 7, itemBg.Y + 3, 7));
}
AddUIChild(ItemCollection[0]);
local itemBgBottom = itemBg.bottom(); local itemBgBottom = itemBg.bottom();
@ -82,14 +88,28 @@ class Inventory_EquipmentPage extends Yosin_CommonUi {
local weight = FontAssetManager.GenerateNormal("重量", true, { local weight = FontAssetManager.GenerateNormal("重量", true, {
color = sq_RGBA(160, 132, 75, 255) color = sq_RGBA(160, 132, 75, 255)
}); });
weight.SetPosition(ItemCollection.X + 5, itemBgBottom - weight.GetSize().h - 5); weight.SetPosition(12, itemBgBottom - weight.GetSize().h - 5);
Addchild(weight); Addchild(weight);
// 重量进度条 // 重量进度条
local weightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4, 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1); WeightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4, 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1);
weightSchedule.SetPercentage(0.6); WeightSchedule.SetPercentage(0.0);
Addchild(weightSchedule); Addchild(WeightSchedule);
}
//刷新重量进度
function RefreshWeightProgress() {
WeightSchedule.SetPercentage(CurrentLoadCapacity / TotalLoadCapacity);
}
//设定总可承载重量
function SetTotalLoadCapacity(capacity) {
TotalLoadCapacity = capacity;
}
//设定物品栏列表
function SetItemCollectionList(Type, List) {
ItemCollection[Type].SetItemList(List);
} }
} }

View File

@ -55,7 +55,7 @@ enum CONTROLLER {
OPTION_HOTKEY_CREATURE_SKILL = 8 // 宠物技能键 OPTION_HOTKEY_CREATURE_SKILL = 8 // 宠物技能键
OPTION_HOTKEY_STATUS_WINDOW = 9 // (M) OPTION_HOTKEY_STATUS_WINDOW = 9 // (M)
OPTION_HOTKEY_SKILL_WINDOW = 10 // (K) OPTION_HOTKEY_SKILL_WINDOW = 10 // (K)
OPTION_HOTKEY_ITEM_INVENTORY = 11 // (I) OPTION_HOTKEY_ITEM_INVENTORY = 23 // (I)
OPTION_HOTKEY_OPTION_WINDOW = 12 // (O) OPTION_HOTKEY_OPTION_WINDOW = 12 // (O)
OPTION_HOTKEY_NORMAL_QUEST_WINDOW = 13 // (Q) OPTION_HOTKEY_NORMAL_QUEST_WINDOW = 13 // (Q)
OPTION_HOTKEY_AVATAR_INVENTORY = 14 // (U) OPTION_HOTKEY_AVATAR_INVENTORY = 14 // (U)

View File

@ -7,3 +7,5 @@
//客户端角色对象 //客户端角色对象
ClientCharacter <- null; ClientCharacter <- null;
//客户端角色的背包
ClientCharacterInventory <- null;