背包 装备和装扮页切换

This commit is contained in:
WONIU 2025-01-12 16:35:50 +08:00
parent b12d4ed3a0
commit c7dabbe069
2 changed files with 60 additions and 11 deletions

View File

@ -692,7 +692,7 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi {
titleBtn.index = i; titleBtn.index = i;
titleBtn.LBDownOnClick = function(btn) { titleBtn.LBDownOnClick = function(btn) {
btn.Parent.LBDownOnClick(this, btn.index); btn.Parent.LBDownOnClick(btn.Parent, btn.index);
for (local i = 0; i< btn.Parent.btns.len(); i++) { for (local i = 0; i< btn.Parent.btns.len(); i++) {
btn.Parent.btns[i].SetSelect(false); btn.Parent.btns[i].SetSelect(false);

View File

@ -8,12 +8,29 @@
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20); // local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
class _Inventory extends Yosin_Window { class _Inventory extends Yosin_Window {
// 装备页
equipmentPage = null; equipmentPage = null;
// 装扮页
DressUpPage = null;
// 物品栏排列按钮
permutationBtn = null;
// 物品栏设置按钮
setBtn = null;
// 物品栏搜索按钮
saerchBtn = null;
PageIndex = null;
uiPageIndex = null;
// 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标
itemSetBtnY = 467;
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);
PageIndex = 1;
uiPageIndex = 1;
//注册控件 //注册控件
RegisterWidget(); RegisterWidget();
@ -36,7 +53,8 @@ class _Inventory extends Yosin_Window {
local topBtn = Yosin_BaseButton(Width - 35, 2, 13, 13, "sprite/interface/lenheartwindowcommon.img", 455); local topBtn = Yosin_BaseButton(Width - 35, 2, 13, 13, "sprite/interface/lenheartwindowcommon.img", 455);
topBtn.DownSimulateOffset = false; topBtn.DownSimulateOffset = false;
topBtn.OnClick = function(btn) { topBtn.OnClick = function(btn) {
// btn.Parent.PageIndex += 1;
print(btn.Parent.PageIndex);
} }
AddUIChild(topBtn); AddUIChild(topBtn);
@ -45,34 +63,37 @@ class _Inventory extends Yosin_Window {
AddUIChild(titlesBtn); AddUIChild(titlesBtn);
titlesBtn.LBDownOnClick = function(btns, index) { titlesBtn.LBDownOnClick = function(btns, index) {
print(index); btns.Parent.PageIndex = index;
}; };
//物品栏 装备页 //物品栏 装备页
equipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441); equipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441);
AddUIChild(equipmentPage); AddUIChild(equipmentPage);
equipmentPage.SetVisible(false);
// 添加设置物品栏的按钮 // 装扮页
AddItemCollectSetBtn(); DressUpPage = Inventory_DressUpPage(4, titlesBtn.bottom(), 300, 441);
AddUIChild(DressUpPage);
// 钱包 // 钱包
AddMoneyItem(); AddMoneyItem();
// 添加设置物品栏的按钮
AddItemCollectSetBtn();
} }
// 添加设置物品栏的按钮 // 添加设置物品栏的按钮
function AddItemCollectSetBtn() { function AddItemCollectSetBtn() {
// 排列按钮 // 排列按钮
local permutationBtn = Yosin_BaseButton(226, 467, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73); permutationBtn = Yosin_BaseButton(226, itemSetBtnY, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73);
AddUIChild(permutationBtn); AddUIChild(permutationBtn);
// 设置 // 设置
local setBtn = Yosin_BaseButton(permutationBtn.X - 20, permutationBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77); setBtn = Yosin_BaseButton(permutationBtn.X - 20, permutationBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77);
AddUIChild(setBtn); AddUIChild(setBtn);
// 搜索 // 搜索
local saerchBtn = Yosin_BaseButton(setBtn.X - 24, permutationBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94); saerchBtn = Yosin_BaseButton(setBtn.X - 24, permutationBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94);
AddUIChild(saerchBtn); AddUIChild(saerchBtn);
} }
@ -140,8 +161,36 @@ class _Inventory extends Yosin_Window {
function Proc(Dt) { function Proc(Dt) {
SyncPos(X, Y); SyncPos(X, Y);
base.Proc(Dt); base.Proc(Dt);
if (PageIndex != uiPageIndex) {
uiPageIndex = PageIndex;
ChangPage();
}
} }
// 切换页面
function ChangPage() {
equipmentPage.SetVisible(false);
DressUpPage.SetVisible(false);
if (PageIndex == 0) {
equipmentPage.SetVisible(true);
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY);
setBtn.SetPosition(setBtn.X, itemSetBtnY);
saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY);
} else if (PageIndex == 1) {
DressUpPage.SetVisible(true);
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY + 28);
setBtn.SetPosition(setBtn.X, permutationBtn.Y);
saerchBtn.SetPosition(saerchBtn.X, permutationBtn.Y);
}
}
} }
// if (!getroottable().rawin("chongzaiflag")) { // if (!getroottable().rawin("chongzaiflag")) {