优化背包界面 更改几个UI基类
This commit is contained in:
parent
ea2d779fcb
commit
5d38428f30
|
|
@ -57,66 +57,77 @@ class Yosin_BaseWindow extends Layer {
|
||||||
|
|
||||||
//鼠标事件回调
|
//鼠标事件回调
|
||||||
function OnMouseProc(MousePos_X, MousePos_Y) {
|
function OnMouseProc(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseProc(MousePos_X, MousePos_Y);
|
Window.OnMouseProc(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标左键按下回调
|
//鼠标左键按下回调
|
||||||
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseLbDown(MousePos_X, MousePos_Y);
|
Window.OnMouseLbDown(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标左键单击回调
|
//鼠标左键单击回调
|
||||||
function OnMouseLbClick(MousePos_X, MousePos_Y) {
|
function OnMouseLbClick(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseLbClick(MousePos_X, MousePos_Y);
|
Window.OnMouseLbClick(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标左键弹起回调
|
//鼠标左键弹起回调
|
||||||
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseLbUp(MousePos_X, MousePos_Y);
|
Window.OnMouseLbUp(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标右键按下回调
|
//鼠标右键按下回调
|
||||||
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseRbDown(MousePos_X, MousePos_Y);
|
Window.OnMouseRbDown(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标右键单击回调
|
//鼠标右键单击回调
|
||||||
function OnMouseRbClick(MousePos_X, MousePos_Y) {
|
function OnMouseRbClick(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseRbClick(MousePos_X, MousePos_Y);
|
Window.OnMouseRbClick(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标右键弹起回调
|
//鼠标右键弹起回调
|
||||||
function OnMouseRbUp(MousePos_X, MousePos_Y) {
|
function OnMouseRbUp(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseRbUp(MousePos_X, MousePos_Y);
|
Window.OnMouseRbUp(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标中键按下回调
|
//鼠标中键按下回调
|
||||||
function OnMouseMbDown(MousePos_X, MousePos_Y) {
|
function OnMouseMbDown(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseMbDown(MousePos_X, MousePos_Y);
|
Window.OnMouseMbDown(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标中键单击回调
|
//鼠标中键单击回调
|
||||||
function OnMouseMbClick(MousePos_X, MousePos_Y) {
|
function OnMouseMbClick(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseMbClick(MousePos_X, MousePos_Y);
|
Window.OnMouseMbClick(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标中键弹起回调
|
//鼠标中键弹起回调
|
||||||
function OnMouseMbUp(MousePos_X, MousePos_Y) {
|
function OnMouseMbUp(MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseMbUp(MousePos_X, MousePos_Y);
|
Window.OnMouseMbUp(MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//鼠标滚轮事件回调
|
//鼠标滚轮事件回调
|
||||||
function OnMouseWheel(Wheel, MousePos_X, MousePos_Y) {
|
function OnMouseWheel(Wheel, MousePos_X, MousePos_Y) {
|
||||||
|
if (!Visible) return;
|
||||||
foreach(Window in UI_Childrens) {
|
foreach(Window in UI_Childrens) {
|
||||||
Window.OnMouseWheel(Wheel, MousePos_X, MousePos_Y);
|
Window.OnMouseWheel(Wheel, MousePos_X, MousePos_Y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ class Yosin_EmeStretch extends CL_CanvasObject {
|
||||||
//按钮状态
|
//按钮状态
|
||||||
SpriteList = null;
|
SpriteList = null;
|
||||||
|
|
||||||
constructor( W, H, Path, Idx, Direction = true) {
|
constructor(W, H, Path, Idx, Direction = true) {
|
||||||
this.Path = Path;
|
this.Path = Path;
|
||||||
this.Idx = Idx;
|
this.Idx = Idx;
|
||||||
base.constructor();
|
base.constructor();
|
||||||
|
|
@ -256,105 +256,105 @@ class Yosin_EmeStretch extends CL_CanvasObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 九宫格拉伸
|
//九宫格拉伸
|
||||||
// function Yosin_NineBoxStretch(width, height, path, imgId) {
|
function Yosin_NineBoxStretch(width, height, path, imgId) {
|
||||||
|
|
||||||
// // 创建画布
|
// 创建画布
|
||||||
// local Canvas = CL_CanvasObject();
|
local Canvas = CL_CanvasObject();
|
||||||
// // 重设大小并清空
|
// 重设大小并清空
|
||||||
// Canvas.ResizeAndClear(width, height);
|
Canvas.ResizeAndClear(width, height);
|
||||||
// // 开始绘制
|
// 开始绘制
|
||||||
// Canvas.BeginDraw();
|
Canvas.BeginDraw();
|
||||||
|
|
||||||
// // 左上角
|
// 左上角
|
||||||
// // local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
||||||
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
||||||
// // 上边
|
// 上边
|
||||||
// local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
||||||
// // 右上角
|
// 右上角
|
||||||
// local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
||||||
// // 左边
|
// 左边
|
||||||
// local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
||||||
// // 中间
|
// 中间
|
||||||
// local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
||||||
// // 右边
|
// 右边
|
||||||
// local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
||||||
// // 左下角
|
// 左下角
|
||||||
// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
||||||
// // 下边
|
// 下边
|
||||||
// local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
||||||
// // 右下角
|
// 右下角
|
||||||
// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
||||||
|
|
||||||
|
|
||||||
// // 左上角
|
// 左上角
|
||||||
// Canvas.DrawSprite(backgroundTopLeft);
|
Canvas.DrawSprite(backgroundTopLeft);
|
||||||
|
|
||||||
// local TopLeftSize = backgroundTopLeft.GetSize();
|
local TopLeftSize = backgroundTopLeft.GetSize();
|
||||||
// local TopLeftBottom = TopLeftSize.h;
|
local TopLeftBottom = TopLeftSize.h;
|
||||||
// local TopLeftRight = TopLeftSize.w;
|
local TopLeftRight = TopLeftSize.w;
|
||||||
|
|
||||||
// // 中间图片大小
|
// 中间图片大小
|
||||||
// local centerImgSize = backgroundCenter.GetSize();
|
local centerImgSize = backgroundCenter.GetSize();
|
||||||
// local centerImgWidth = centerImgSize.w;
|
local centerImgWidth = centerImgSize.w;
|
||||||
// local centerImgHeight = centerImgSize.h;
|
local centerImgHeight = centerImgSize.h;
|
||||||
|
|
||||||
// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
||||||
// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
||||||
|
|
||||||
|
|
||||||
// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
||||||
// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
||||||
|
|
||||||
// // 上边
|
// 上边
|
||||||
// backgroundTop.SetScale(scaleW, 1);
|
backgroundTop.SetScale(scaleW, 1);
|
||||||
// backgroundTop.SetPosition(TopLeftRight, 0);
|
backgroundTop.SetPosition(TopLeftRight, 0);
|
||||||
// Canvas.DrawSprite(backgroundTop);
|
Canvas.DrawSprite(backgroundTop);
|
||||||
|
|
||||||
// // 右上角
|
// 右上角
|
||||||
// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
||||||
// Canvas.DrawSprite(backgroundTopRight);
|
Canvas.DrawSprite(backgroundTopRight);
|
||||||
|
|
||||||
// // 左边
|
// 左边
|
||||||
// backgroundLeft.SetScale(1, scaleH);
|
backgroundLeft.SetScale(1, scaleH);
|
||||||
// backgroundLeft.SetPosition(0, TopLeftBottom);
|
backgroundLeft.SetPosition(0, TopLeftBottom);
|
||||||
// Canvas.DrawSprite(backgroundLeft);
|
Canvas.DrawSprite(backgroundLeft);
|
||||||
|
|
||||||
// // 中间
|
// 中间
|
||||||
// backgroundCenter.SetScale(scaleW, scaleH);
|
backgroundCenter.SetScale(scaleW, scaleH);
|
||||||
// // Addchild(backgroundCenter);
|
// Addchild(backgroundCenter);
|
||||||
// backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
||||||
// Canvas.DrawSprite(backgroundCenter);
|
Canvas.DrawSprite(backgroundCenter);
|
||||||
|
|
||||||
// // 右边
|
// 右边
|
||||||
// backgroundRight.SetScale(1, scaleH);
|
backgroundRight.SetScale(1, scaleH);
|
||||||
// backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
||||||
// Canvas.DrawSprite(backgroundRight);
|
Canvas.DrawSprite(backgroundRight);
|
||||||
|
|
||||||
// // 左下角
|
// 左下角
|
||||||
// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
||||||
// Canvas.DrawSprite(backgroundBottomLeft);
|
Canvas.DrawSprite(backgroundBottomLeft);
|
||||||
|
|
||||||
// // 下边
|
// 下边
|
||||||
// backgroundBottom.SetScale(scaleW, 1);
|
backgroundBottom.SetScale(scaleW, 1);
|
||||||
// backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
||||||
// Canvas.DrawSprite(backgroundBottom);
|
Canvas.DrawSprite(backgroundBottom);
|
||||||
|
|
||||||
// // 右下角
|
// 右下角
|
||||||
// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
||||||
// Canvas.DrawSprite(backgroundBottomRight);
|
Canvas.DrawSprite(backgroundBottomRight);
|
||||||
|
|
||||||
// // 结束绘制
|
|
||||||
// Canvas.EndDraw();
|
|
||||||
// // 添加画布
|
|
||||||
// // Addchild(Canvas);
|
|
||||||
// local Sp = CL_SpriteObject();
|
|
||||||
// Sp.SetFrame(Canvas.ExportSpriteFrame());
|
|
||||||
// return Sp;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
// 结束绘制
|
||||||
|
Canvas.EndDraw();
|
||||||
|
// 添加画布
|
||||||
|
// Addchild(Canvas);
|
||||||
|
local Sp = CL_SpriteObject();
|
||||||
|
Sp.SetFrame(Canvas.ExportSpriteFrame());
|
||||||
|
return Sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
//九宫格拉伸
|
//九宫格拉伸
|
||||||
class Yosin_NineBoxStretch extends CL_CanvasObject {
|
class Yosin_NineBoxStretch extends CL_CanvasObject {
|
||||||
|
|
||||||
|
|
@ -451,6 +451,7 @@ class Yosin_NineBoxStretch extends CL_CanvasObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//拼接按钮
|
//拼接按钮
|
||||||
class Yosin_SplicingButton extends Yosin_CommonUi {
|
class Yosin_SplicingButton extends Yosin_CommonUi {
|
||||||
|
|
@ -474,14 +475,14 @@ class Yosin_SplicingButton extends Yosin_CommonUi {
|
||||||
SpriteList = array(4);
|
SpriteList = array(4);
|
||||||
|
|
||||||
//普通态
|
//普通态
|
||||||
SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx, Direction);
|
SpriteList[0] = Yosin_EmeStretch(W, H, Path, Idx, Direction);
|
||||||
//悬停态
|
//悬停态
|
||||||
SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction);
|
SpriteList[1] = Yosin_EmeStretch(W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction);
|
||||||
//按下态
|
//按下态
|
||||||
SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction);
|
SpriteList[2] = Yosin_EmeStretch(W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction);
|
||||||
if (UnavailableFlag) {
|
if (UnavailableFlag) {
|
||||||
//不可用态
|
//不可用态
|
||||||
SpriteList[3] = Yosin_EmeStretch( W, H, Path, Idx + 12, Direction);
|
SpriteList[3] = Yosin_EmeStretch(W, H, Path, Idx + 12, Direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,15 +636,15 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi {
|
||||||
SpriteList = array(3);
|
SpriteList = array(3);
|
||||||
|
|
||||||
//普通态
|
//普通态
|
||||||
SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx);
|
SpriteList[0] = Yosin_EmeStretch(W, H, Path, Idx);
|
||||||
Addchild(SpriteList[0]);
|
Addchild(SpriteList[0]);
|
||||||
|
|
||||||
//悬停态
|
//悬停态
|
||||||
SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + 3);
|
SpriteList[1] = Yosin_EmeStretch(W, H, Path, Idx + 3);
|
||||||
SpriteList[1].SetVisible(false)
|
SpriteList[1].SetVisible(false)
|
||||||
Addchild(SpriteList[1]);
|
Addchild(SpriteList[1]);
|
||||||
//按下态
|
//按下态
|
||||||
SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + 6);
|
SpriteList[2] = Yosin_EmeStretch(W, H, Path, Idx + 6);
|
||||||
SpriteList[2].SetVisible(false)
|
SpriteList[2].SetVisible(false)
|
||||||
Addchild(SpriteList[2]);
|
Addchild(SpriteList[2]);
|
||||||
|
|
||||||
|
|
@ -739,17 +740,17 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi {
|
||||||
titleBtn.index = i;
|
titleBtn.index = i;
|
||||||
|
|
||||||
titleBtn.LBDownOnClick = function(btn) {
|
titleBtn.LBDownOnClick = function(btn) {
|
||||||
btn.Parent.LBDownOnClick(btn.Parent, btn.index);
|
LBDownOnClick(btn.Parent, btn.index);
|
||||||
|
|
||||||
for (local i = 0; i< btn.Parent.btns.len(); i++) {
|
for (local i = 0; i< btns.len(); i++) {
|
||||||
btn.Parent.btns[i].SetSelect(false);
|
btns[i].SetSelect(false);
|
||||||
btn.Parent.btns[i].titleText.SetFillColor(sq_RGBA(130, 114, 84, 255));
|
btns[i].titleText.SetFillColor(sq_RGBA(130, 114, 84, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.SetSelect(true);
|
btn.SetSelect(true);
|
||||||
btn.Parent.btns[btn.index].titleText.SetFillColor(sq_RGBA(187, 176, 149, 255));
|
btns[btn.index].titleText.SetFillColor(sq_RGBA(187, 176, 149, 255));
|
||||||
|
|
||||||
};
|
}.bindenv(this);
|
||||||
|
|
||||||
btns.push(titleBtn);
|
btns.push(titleBtn);
|
||||||
btnX += btnW;
|
btnX += btnW;
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ function RegisterFunctionalPack() {
|
||||||
ItemList[EquInfo.Pos] <- GameItem.Equipment(EquInfo);
|
ItemList[EquInfo.Pos] <- GameItem.Equipment(EquInfo);
|
||||||
//装备栏
|
//装备栏
|
||||||
if (InventoryType == 2) {
|
if (InventoryType == 2) {
|
||||||
ClientCharacterInventory.EquipmentPage.SetItemCollectionList(0, ItemList);
|
ClientCharacterInventory.PageList[0].SetItemCollectionList(0, ItemList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//消耗品类型
|
//消耗品类型
|
||||||
|
|
@ -155,7 +155,7 @@ function RegisterFunctionalPack() {
|
||||||
ItemList[ItemInfo.Pos] <- GameItem.Stackable(ItemInfo.ItemId);
|
ItemList[ItemInfo.Pos] <- GameItem.Stackable(ItemInfo.ItemId);
|
||||||
|
|
||||||
|
|
||||||
ClientCharacterInventory.EquipmentPage.SetItemCollectionList(InventoryType - 2, ItemList);
|
ClientCharacterInventory.PageList[0].SetItemCollectionList(InventoryType - 2, ItemList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ function InitGame() {
|
||||||
// MySocket("127.0.0.1", 19666);
|
// MySocket("127.0.0.1", 19666);
|
||||||
|
|
||||||
//设定全局默认音量
|
//设定全局默认音量
|
||||||
_Globa_Audio_Volume_ = 0.03;
|
_Globa_Audio_Volume_ = 0.001;
|
||||||
_Globa_Sound_Volume_ = 0.03;
|
_Globa_Sound_Volume_ = 0.001;
|
||||||
|
|
||||||
Script();
|
Script();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ function TestStage() {
|
||||||
|
|
||||||
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
|
// local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20);
|
||||||
|
|
||||||
|
|
||||||
// Window.EquipmentPage.ItemCollection.SetItemList([{
|
// Window.EquipmentPage.ItemCollection.SetItemList([{
|
||||||
// ItemId = 27675
|
// ItemId = 27675
|
||||||
// }, {
|
// }, {
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,125 @@
|
||||||
创建日期:2025-01-06 14:06
|
创建日期:2025-01-06 14:06
|
||||||
文件用途: 背包窗口
|
文件用途: 背包窗口
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//钱包类
|
||||||
|
class Inventory_Wallet extends Yosin_CommonUi {
|
||||||
|
|
||||||
|
//复活币数量
|
||||||
|
ReviveCoinCount = 0;
|
||||||
|
ReviveCoinText = null;
|
||||||
|
//胜利的证明数量
|
||||||
|
WinCoinCount = 0;
|
||||||
|
WinCoinText = null;
|
||||||
|
//点卷数量
|
||||||
|
CeraCount = 0;
|
||||||
|
CeraText = null;
|
||||||
|
//金币数量
|
||||||
|
GoldCount = 0;
|
||||||
|
GoldText = null;
|
||||||
|
|
||||||
|
//override
|
||||||
|
function _set(idx, val) {
|
||||||
|
switch (idx) {
|
||||||
|
case "ReviveCoin": {
|
||||||
|
ReviveCoinCount = val;
|
||||||
|
ReviveCoinText.SetText(ReviveCoinCount + "个");
|
||||||
|
ReviveCoinText.SetPosition(120 - ReviveCoinText.GetSize().w, 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "WinCoin": {
|
||||||
|
WinCoinCount = val;
|
||||||
|
WinCoinText.SetText(WinCoinCount + "个");
|
||||||
|
WinCoinText.SetPosition(245 - WinCoinText.GetSize().w, 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Cera": {
|
||||||
|
CeraCount = val;
|
||||||
|
CeraText.SetText(CeraCount + "点券");
|
||||||
|
CeraText.SetPosition(120 - CeraText.GetSize().w, 27);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Gold": {
|
||||||
|
GoldCount = val;
|
||||||
|
GoldText.SetText(GoldCount + "金币");
|
||||||
|
GoldText.SetPosition(245 - GoldText.GetSize().w, 27);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(x, y, w, h) {
|
||||||
|
base.constructor(x, y, w, h);
|
||||||
|
|
||||||
|
RegisterWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 钱包
|
||||||
|
function RegisterWidget() {
|
||||||
|
|
||||||
|
local txtColor = sq_RGBA(130, 105, 61, 255);
|
||||||
|
local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 27);
|
||||||
|
Addchild(bg);
|
||||||
|
|
||||||
|
// 复活币个数
|
||||||
|
ReviveCoinText = FontAssetManager.GenerateNormal(ReviveCoinCount + "个", true, {
|
||||||
|
color = txtColor
|
||||||
|
});
|
||||||
|
ReviveCoinText.SetPosition(120 - ReviveCoinText.GetSize().w + bg.X, 2);
|
||||||
|
Addchild(ReviveCoinText);
|
||||||
|
|
||||||
|
|
||||||
|
// 胜利的证明
|
||||||
|
WinCoinText = FontAssetManager.GenerateNormal(WinCoinCount + "个", true, {
|
||||||
|
color = txtColor
|
||||||
|
});
|
||||||
|
WinCoinText.SetPosition(245 - WinCoinText.GetSize().w + bg.X, 2);
|
||||||
|
Addchild(WinCoinText);
|
||||||
|
|
||||||
|
|
||||||
|
// 商城
|
||||||
|
local storeBtn = Yosin_BaseButton(1 + bg.X, 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3);
|
||||||
|
//点击事件回调
|
||||||
|
// storeBtn.OnClick = function(Button) {
|
||||||
|
// }.bindenv(this);
|
||||||
|
AddUIChild(storeBtn);
|
||||||
|
|
||||||
|
|
||||||
|
// 点券
|
||||||
|
CeraText = FontAssetManager.GenerateNormal(CeraCount + "点券", true, {
|
||||||
|
color = txtColor
|
||||||
|
});
|
||||||
|
CeraText.SetPosition(120 - CeraText.GetSize().w, 27);
|
||||||
|
Addchild(CeraText);
|
||||||
|
|
||||||
|
// 金币按钮
|
||||||
|
local moneyBtn = Yosin_BaseButton(126 + bg.X, storeBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 7);
|
||||||
|
//点击事件回调
|
||||||
|
// moneyBtn.OnClick = function(Button) {
|
||||||
|
// }.bindenv(this);
|
||||||
|
AddUIChild(moneyBtn);
|
||||||
|
|
||||||
|
// 金币数量
|
||||||
|
GoldText = FontAssetManager.GenerateNormal(GoldCount + "金币", true, {
|
||||||
|
color = txtColor
|
||||||
|
});
|
||||||
|
GoldText.SetPosition(245 - GoldText.GetSize().w, 27);
|
||||||
|
Addchild(GoldText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//主类
|
//主类
|
||||||
class _Inventory extends Yosin_Window {
|
class _Inventory extends Yosin_Window {
|
||||||
|
|
||||||
// 装备页 /物品栏
|
//分页集合 0装备 1装扮 2宠物
|
||||||
EquipmentPage = null;
|
PageList = null;
|
||||||
// 装扮页E
|
//钱包
|
||||||
DressUpPage = null;
|
Wallet = null;
|
||||||
|
|
||||||
// 物品栏排列按钮
|
// 物品栏排列按钮
|
||||||
permutationBtn = null;
|
permutationBtn = null;
|
||||||
|
|
@ -19,23 +131,22 @@ class _Inventory extends Yosin_Window {
|
||||||
// 物品栏搜索按钮
|
// 物品栏搜索按钮
|
||||||
saerchBtn = null;
|
saerchBtn = null;
|
||||||
|
|
||||||
PageIndex = null;
|
|
||||||
uiPageIndex = null;
|
|
||||||
|
|
||||||
// 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标
|
// 物品栏排列搜索按钮 在显示物品栏页 时的Y坐标
|
||||||
itemSetBtnY = 467;
|
itemSetBtnY = 467;
|
||||||
//是否可见
|
//是否可见
|
||||||
Visible = false;
|
Visible = false;
|
||||||
|
|
||||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||||
|
PageList = [];
|
||||||
|
//调用父类构造函数
|
||||||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||||
|
|
||||||
PageIndex = 0;
|
|
||||||
uiPageIndex = 0;
|
|
||||||
|
|
||||||
//注册控件
|
//注册控件
|
||||||
RegisterWidget();
|
RegisterWidget();
|
||||||
|
|
||||||
|
//注册背包页面
|
||||||
|
RegisterPage();
|
||||||
|
|
||||||
//注册按键回调事件
|
//注册按键回调事件
|
||||||
Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_ITEM_INVENTORY, function(Flag) {
|
Input.RegisterGameKeyCode(CONTROLLER.OPTION_HOTKEY_ITEM_INVENTORY, function(Flag) {
|
||||||
//抬起的时候
|
//抬起的时候
|
||||||
|
|
@ -63,160 +174,80 @@ class _Inventory extends Yosin_Window {
|
||||||
closeBtn.SetZOrder(1);
|
closeBtn.SetZOrder(1);
|
||||||
closeBtn.OnClick = function(btn) {
|
closeBtn.OnClick = function(btn) {
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
}
|
}.bindenv(this);
|
||||||
AddUIChild(closeBtn);
|
AddUIChild(closeBtn);
|
||||||
//置顶按钮
|
//置顶按钮
|
||||||
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);
|
||||||
|
|
||||||
//分页按钮
|
//分页按钮
|
||||||
local titlesBtn = Yosin_RowMoreTitleBtn(5, 25, 250, ["物品栏", "装扮", "宠物", "护石"], "sprite/interface/lenheartwindowcommon.img", 160);
|
local titlesBtn = Yosin_RowMoreTitleBtn(5, 25, 250, ["物品栏", "装扮", "宠物", "护石"], "sprite/interface/lenheartwindowcommon.img", 160);
|
||||||
AddUIChild(titlesBtn);
|
AddUIChild(titlesBtn);
|
||||||
|
|
||||||
titlesBtn.LBDownOnClick = function(btns, index) {
|
titlesBtn.LBDownOnClick = function(btns, index) {
|
||||||
btns.Parent.PageIndex = index;
|
ChangPage(index);
|
||||||
};
|
}.bindenv(this);
|
||||||
|
|
||||||
//物品栏 装备页
|
|
||||||
EquipmentPage = Inventory_EquipmentPage(2, titlesBtn.bottom(), 300, 441);
|
|
||||||
AddUIChild(EquipmentPage);
|
|
||||||
EquipmentPage.SetVisible(false);
|
|
||||||
|
|
||||||
// 装扮页
|
|
||||||
DressUpPage = Inventory_DressUpPage(4, titlesBtn.bottom(), 300, 441);
|
|
||||||
AddUIChild(DressUpPage);
|
|
||||||
|
|
||||||
// 钱包
|
|
||||||
AddMoneyItem();
|
|
||||||
|
|
||||||
// 添加设置物品栏的按钮
|
|
||||||
AddItemCollectSetBtn();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加设置物品栏的按钮
|
|
||||||
function AddItemCollectSetBtn() {
|
|
||||||
// 排列按钮
|
// 排列按钮
|
||||||
permutationBtn = Yosin_BaseButton(226, itemSetBtnY, 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);
|
||||||
|
permutationBtn.SetZOrder(1);
|
||||||
AddUIChild(permutationBtn);
|
AddUIChild(permutationBtn);
|
||||||
|
|
||||||
// 设置
|
// 设置
|
||||||
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);
|
||||||
|
setBtn.SetZOrder(1);
|
||||||
AddUIChild(setBtn);
|
AddUIChild(setBtn);
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
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);
|
||||||
|
saerchBtn.SetZOrder(1);
|
||||||
AddUIChild(saerchBtn);
|
AddUIChild(saerchBtn);
|
||||||
|
|
||||||
|
//钱包类
|
||||||
|
Wallet = Inventory_Wallet(7, Height - 55, 248, 49);
|
||||||
|
AddUIChild(Wallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 钱包
|
function RegisterPage() {
|
||||||
function AddMoneyItem() {
|
//物品栏 装备页
|
||||||
|
local EquipmentPage = Inventory_EquipmentPage(2, 46, 300, 441);
|
||||||
local txtColor = sq_RGBA(130, 105, 61, 255);
|
PageList.push(EquipmentPage);
|
||||||
|
AddUIChild(EquipmentPage);
|
||||||
local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 27);
|
|
||||||
bg.SetPosition(7, Height - 55);
|
|
||||||
Addchild(bg);
|
|
||||||
|
|
||||||
// 复活币个数
|
|
||||||
local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, {
|
|
||||||
color = txtColor
|
|
||||||
});
|
|
||||||
ReviveNum.SetPosition(120 - ReviveNum.GetSize().w + bg.X, bg.Y + 2);
|
|
||||||
Addchild(ReviveNum);
|
|
||||||
|
|
||||||
|
|
||||||
// 胜利的证明
|
|
||||||
local winNum = FontAssetManager.GenerateNormal("23434个", true, {
|
|
||||||
color = txtColor
|
|
||||||
});
|
|
||||||
winNum.SetPosition(245 - winNum.GetSize().w + bg.X, bg.Y + 2);
|
|
||||||
Addchild(winNum);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 商城
|
|
||||||
local storeBtn = Yosin_BaseButton(1 + bg.X, bg.Y + 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3);
|
|
||||||
//点击事件回调
|
|
||||||
// storeBtn.OnClick = function(Button) {
|
|
||||||
// }.bindenv(this);
|
|
||||||
AddUIChild(storeBtn);
|
|
||||||
|
|
||||||
|
|
||||||
// 点券
|
|
||||||
local storeNum = FontAssetManager.GenerateNormal("23434点券", true, {
|
|
||||||
color = txtColor
|
|
||||||
});
|
|
||||||
storeNum.SetPosition(bg.X + 120 - storeNum.GetSize().w, bg.Y + 27);
|
|
||||||
Addchild(storeNum);
|
|
||||||
|
|
||||||
// 金币按钮
|
|
||||||
local moneyBtn = Yosin_BaseButton(126 + bg.X, storeBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 7);
|
|
||||||
//点击事件回调
|
|
||||||
// moneyBtn.OnClick = function(Button) {
|
|
||||||
// }.bindenv(this);
|
|
||||||
AddUIChild(moneyBtn);
|
|
||||||
|
|
||||||
// 金币数量
|
|
||||||
local storeNum = FontAssetManager.GenerateNormal("23434金币", true, {
|
|
||||||
color = txtColor
|
|
||||||
});
|
|
||||||
storeNum.SetPosition(bg.X + 245 - storeNum.GetSize().w, bg.Y + 27);
|
|
||||||
Addchild(storeNum);
|
|
||||||
|
|
||||||
|
// 装扮页
|
||||||
|
local DressUpPage = Inventory_DressUpPage(4, 46, 300, 441);
|
||||||
|
PageList.push(DressUpPage);
|
||||||
|
AddUIChild(DressUpPage);
|
||||||
|
DressUpPage.SetVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//override
|
||||||
|
|
||||||
//逻辑入口
|
//逻辑入口
|
||||||
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() {
|
function ChangPage(gIndex) {
|
||||||
|
foreach(Index, Page in PageList) {
|
||||||
EquipmentPage.SetVisible(false);
|
Page.SetVisible(false);
|
||||||
DressUpPage.SetVisible(false);
|
if (gIndex == Index) {
|
||||||
|
Page.SetVisible(true);
|
||||||
|
if (gIndex == 0) {
|
||||||
if (PageIndex == 0) {
|
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY);
|
||||||
EquipmentPage.SetVisible(true);
|
setBtn.SetPosition(setBtn.X, itemSetBtnY);
|
||||||
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY);
|
saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY);
|
||||||
setBtn.SetPosition(setBtn.X, itemSetBtnY);
|
} else if (gIndex == 1) {
|
||||||
saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY);
|
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY + 28);
|
||||||
} else if (PageIndex == 1) {
|
setBtn.SetPosition(setBtn.X, permutationBtn.Y);
|
||||||
DressUpPage.SetVisible(true);
|
saerchBtn.SetPosition(saerchBtn.X, permutationBtn.Y);
|
||||||
permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY + 28);
|
}
|
||||||
setBtn.SetPosition(setBtn.X, permutationBtn.Y);
|
}
|
||||||
saerchBtn.SetPosition(saerchBtn.X, permutationBtn.Y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!getroottable().rawin("chongzaiflag")) {
|
|
||||||
// getroottable()["chongzaiflag"] <- true;
|
|
||||||
// } else {
|
|
||||||
// //遍历窗口队列 如果可见则调用Show
|
|
||||||
// for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
|
|
||||||
// local Window = _SYS_WINDOW_LIST_[i];
|
|
||||||
// Window.Visible = false;
|
|
||||||
// Window.RemoveSelf();
|
|
||||||
// }
|
|
||||||
// TestStage();
|
|
||||||
// }
|
|
||||||
|
|
@ -30,7 +30,9 @@ class Inventory_DressUpPage extends Yosin_CommonUi {
|
||||||
local titlesBtn = Yosin_RowMoreTitleBtn(2, 180, 250, ["装扮", "徽章"], "sprite/interface/lenheartwindowcommon.img", 160);
|
local titlesBtn = Yosin_RowMoreTitleBtn(2, 180, 250, ["装扮", "徽章"], "sprite/interface/lenheartwindowcommon.img", 160);
|
||||||
AddUIChild(titlesBtn);
|
AddUIChild(titlesBtn);
|
||||||
|
|
||||||
|
// titlesBtn.LBDownOnClick = function(btns, index) {
|
||||||
|
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加按钮
|
// 添加按钮
|
||||||
|
|
@ -78,7 +80,7 @@ class Inventory_CharactersDressUp extends CL_CanvasObject {
|
||||||
|
|
||||||
// 魔法阵
|
// 魔法阵
|
||||||
local MagicLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 179);
|
local MagicLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 179);
|
||||||
DrawSpriteFrame(MagicLight, 5,55);
|
DrawSpriteFrame(MagicLight, 5, 55);
|
||||||
|
|
||||||
// 人物打光
|
// 人物打光
|
||||||
local CharacterLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178);
|
local CharacterLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178);
|
||||||
|
|
@ -88,17 +90,3 @@ class Inventory_CharactersDressUp extends CL_CanvasObject {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (!getroottable().rawin("chongzaiflag")) {
|
|
||||||
// getroottable()["chongzaiflag"] <- true;
|
|
||||||
// } else {
|
|
||||||
// //遍历窗口队列 如果可见则调用Show
|
|
||||||
// for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
|
|
||||||
// local Window = _SYS_WINDOW_LIST_[i];
|
|
||||||
// Window.Visible = false;
|
|
||||||
// Window.RemoveSelf();
|
|
||||||
// }
|
|
||||||
// TestStage();
|
|
||||||
// }
|
|
||||||
Loading…
Reference in New Issue