背包界面完成
This commit is contained in:
parent
a61d91db67
commit
72d2e37fb0
|
|
@ -154,6 +154,13 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
this.Idx = Idx;
|
this.Idx = Idx;
|
||||||
base.constructor(X, Y, W, H);
|
base.constructor(X, Y, W, H);
|
||||||
|
|
||||||
|
// 创建画布
|
||||||
|
local Canvas = CL_CanvasObject();
|
||||||
|
// 重设大小并清空
|
||||||
|
Canvas.ResizeAndClear( W, H);
|
||||||
|
// 开始绘制
|
||||||
|
Canvas.BeginDraw();
|
||||||
|
|
||||||
SpriteList = [];
|
SpriteList = [];
|
||||||
SpriteList.push(CL_SpriteObject(Path, Idx));
|
SpriteList.push(CL_SpriteObject(Path, Idx));
|
||||||
SpriteList.push(CL_SpriteObject(Path, Idx + 1));
|
SpriteList.push(CL_SpriteObject(Path, Idx + 1));
|
||||||
|
|
@ -179,12 +186,118 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Child in SpriteList) {
|
foreach(Child in SpriteList) {
|
||||||
Addchild(Child);
|
// Addchild(Child);
|
||||||
|
Canvas.DrawSprite(Child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 结束绘制
|
||||||
|
Canvas.EndDraw();
|
||||||
|
// 添加画布
|
||||||
|
Addchild(Canvas);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 九宫格拉伸
|
||||||
|
function Yosin_NineBoxStretch(X, Y, width, height, path, imgId) {
|
||||||
|
|
||||||
|
|
||||||
|
// 创建画布
|
||||||
|
local Canvas = CL_CanvasObject();
|
||||||
|
Canvas.SetPosition(X, Y);
|
||||||
|
// 重设大小并清空
|
||||||
|
Canvas.ResizeAndClear(width, height);
|
||||||
|
// 开始绘制
|
||||||
|
Canvas.BeginDraw();
|
||||||
|
|
||||||
|
// 左上角
|
||||||
|
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
||||||
|
local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
||||||
|
// 上边
|
||||||
|
local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
||||||
|
// 右上角
|
||||||
|
local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
||||||
|
// 左边
|
||||||
|
local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
||||||
|
// 中间
|
||||||
|
local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
||||||
|
// 右边
|
||||||
|
local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
||||||
|
// 左下角
|
||||||
|
local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
||||||
|
// 下边
|
||||||
|
local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
||||||
|
// 右下角
|
||||||
|
local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
||||||
|
|
||||||
|
|
||||||
|
// 左上角
|
||||||
|
Canvas.DrawSprite(backgroundTopLeft);
|
||||||
|
|
||||||
|
local TopLeftSize = backgroundTopLeft.GetSize();
|
||||||
|
local TopLeftBottom = TopLeftSize.h;
|
||||||
|
local TopLeftRight = TopLeftSize.w;
|
||||||
|
|
||||||
|
// 中间图片大小
|
||||||
|
local centerImgSize = backgroundCenter.GetSize();
|
||||||
|
local centerImgWidth = centerImgSize.w;
|
||||||
|
local centerImgHeight = centerImgSize.h;
|
||||||
|
|
||||||
|
local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
||||||
|
local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
||||||
|
|
||||||
|
|
||||||
|
local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
||||||
|
local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
||||||
|
|
||||||
|
// 上边
|
||||||
|
backgroundTop.SetScale(scaleW, 1);
|
||||||
|
backgroundTop.SetPosition(TopLeftRight + 1, 0);
|
||||||
|
Canvas.DrawSprite(backgroundTop);
|
||||||
|
|
||||||
|
// 右上角
|
||||||
|
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0);
|
||||||
|
Canvas.DrawSprite(backgroundTopRight);
|
||||||
|
|
||||||
|
// 左边
|
||||||
|
backgroundLeft.SetScale(1, scaleH);
|
||||||
|
backgroundLeft.SetPosition(0, TopLeftBottom + 1);
|
||||||
|
Canvas.DrawSprite(backgroundLeft);
|
||||||
|
|
||||||
|
// 中间
|
||||||
|
backgroundCenter.SetScale(scaleW, scaleH);
|
||||||
|
// Addchild(backgroundCenter);
|
||||||
|
backgroundCenter.SetPosition(TopLeftRight + 1, backgroundLeft.Y);
|
||||||
|
Canvas.DrawSprite(backgroundCenter);
|
||||||
|
|
||||||
|
// 右边
|
||||||
|
backgroundRight.SetScale(1, scaleH);
|
||||||
|
backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
||||||
|
Canvas.DrawSprite(backgroundRight);
|
||||||
|
|
||||||
|
// 左下角
|
||||||
|
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h);
|
||||||
|
Canvas.DrawSprite(backgroundBottomLeft);
|
||||||
|
|
||||||
|
// 下边
|
||||||
|
backgroundBottom.SetScale(scaleW, 1);
|
||||||
|
backgroundBottom.SetPosition(TopLeftRight + 1, backgroundBottomLeft.Y);
|
||||||
|
Canvas.DrawSprite(backgroundBottom);
|
||||||
|
|
||||||
|
// 右下角
|
||||||
|
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y);
|
||||||
|
Canvas.DrawSprite(backgroundBottomRight );
|
||||||
|
|
||||||
|
// 结束绘制
|
||||||
|
Canvas.EndDraw();
|
||||||
|
// 添加画布
|
||||||
|
// Addchild(Canvas);
|
||||||
|
|
||||||
|
return Canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// //九宫格拉伸
|
// //九宫格拉伸
|
||||||
// class Yosin_NineBoxStretch extends Yosin_CommonUi {
|
// class Yosin_NineBoxStretch extends Yosin_CommonUi {
|
||||||
|
|
||||||
|
|
@ -206,6 +319,7 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
// Canvas.BeginDraw();
|
// Canvas.BeginDraw();
|
||||||
|
|
||||||
// // 左上角
|
// // 左上角
|
||||||
|
// // 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);
|
||||||
|
|
@ -226,9 +340,7 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
|
|
||||||
|
|
||||||
// // 左上角
|
// // 左上角
|
||||||
// // backgroundTopLeft.SetPosition(0, 0);
|
// Canvas.DrawSprite(backgroundTopLeft);
|
||||||
// // Addchild(backgroundTopLeft);
|
|
||||||
// Canvas.DrawActor(backgroundTopLeft, 0, 0);
|
|
||||||
|
|
||||||
// local TopLeftSize = backgroundTopLeft.GetSize();
|
// local TopLeftSize = backgroundTopLeft.GetSize();
|
||||||
// local TopLeftBottom = TopLeftSize.h;
|
// local TopLeftBottom = TopLeftSize.h;
|
||||||
|
|
@ -247,49 +359,42 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
||||||
|
|
||||||
// // 上边
|
// // 上边
|
||||||
// // backgroundTop.SetPosition(backgroundTopLeft.right() + 1, 0);
|
|
||||||
// backgroundTop.SetScale(scaleW, 1);
|
// backgroundTop.SetScale(scaleW, 1);
|
||||||
// // Addchild(backgroundTop);
|
// backgroundTop.SetPosition(TopLeftRight + 1, 0);
|
||||||
// Canvas.DrawActor(backgroundTop, TopLeftRight + 1, 0);
|
// Canvas.DrawSprite(backgroundTop);
|
||||||
|
|
||||||
// // 右上角
|
// // 右上角
|
||||||
// // backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0);
|
// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0);
|
||||||
// // Addchild(backgroundTopRight);
|
// Canvas.DrawSprite(backgroundTopRight);
|
||||||
// Canvas.DrawActor(backgroundTopRight, width - backgroundTopRight.GetSize().w, 0);
|
|
||||||
|
|
||||||
// // 左边
|
// // 左边
|
||||||
// // backgroundLeft.SetPosition(0, backgroundTopLeft.bottom() + 1);
|
|
||||||
// backgroundLeft.SetScale(1, scaleH);
|
// backgroundLeft.SetScale(1, scaleH);
|
||||||
// // Addchild(backgroundLeft);
|
// backgroundLeft.SetPosition(0, TopLeftBottom + 1);
|
||||||
// Canvas.DrawActor(backgroundLeft, 0, TopLeftBottom + 1);
|
// Canvas.DrawSprite(backgroundLeft);
|
||||||
|
|
||||||
// // 中间
|
// // 中间
|
||||||
// // backgroundCenter.SetPosition(backgroundLeft.right() + 1, backgroundLeft.Y);
|
|
||||||
// backgroundCenter.SetScale(scaleW, scaleH);
|
// backgroundCenter.SetScale(scaleW, scaleH);
|
||||||
// // Addchild(backgroundCenter);
|
// // Addchild(backgroundCenter);
|
||||||
// Canvas.DrawActor(backgroundCenter, TopLeftRight + 1, backgroundLeft.Y);
|
// backgroundCenter.SetPosition(TopLeftRight + 1, backgroundLeft.Y);
|
||||||
|
// Canvas.DrawSprite(backgroundCenter);
|
||||||
|
|
||||||
// // 右边
|
// // 右边
|
||||||
// // backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
|
||||||
// backgroundRight.SetScale(1, scaleH);
|
// backgroundRight.SetScale(1, scaleH);
|
||||||
// // Addchild(backgroundRight);
|
// backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
||||||
// Canvas.DrawActor(backgroundRight, width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
// Canvas.DrawSprite(backgroundRight);
|
||||||
|
|
||||||
// // 左下角
|
// // 左下角
|
||||||
// // backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h);
|
// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h);
|
||||||
// // Addchild(backgroundBottomLeft);
|
// Canvas.DrawSprite(backgroundBottomLeft);
|
||||||
// Canvas.DrawActor(backgroundBottomLeft, 0, height - backgroundBottomLeft.GetSize().h);
|
|
||||||
|
|
||||||
// // 下边
|
// // 下边
|
||||||
// // backgroundBottom.SetPosition(backgroundBottomLeft.right() + 1, backgroundBottomLeft.Y);
|
|
||||||
// backgroundBottom.SetScale(scaleW, 1);
|
// backgroundBottom.SetScale(scaleW, 1);
|
||||||
// // Addchild(backgroundBottom);
|
// backgroundBottom.SetPosition(TopLeftRight + 1, backgroundBottomLeft.Y);
|
||||||
// Canvas.DrawActor(backgroundBottom, TopLeftRight + 1, backgroundBottomLeft.Y);
|
// Canvas.DrawSprite(backgroundBottom);
|
||||||
|
|
||||||
// // 右下角
|
// // 右下角
|
||||||
// // backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y);
|
// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y);
|
||||||
// // Addchild(backgroundBottomRight);
|
// Canvas.DrawSprite(backgroundBottomRight );
|
||||||
// Canvas.DrawActor(backgroundBottomRight,width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y );
|
|
||||||
|
|
||||||
// // 结束绘制
|
// // 结束绘制
|
||||||
// Canvas.EndDraw();
|
// Canvas.EndDraw();
|
||||||
|
|
@ -300,108 +405,6 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//九宫格拉伸
|
|
||||||
class Yosin_NineBoxStretch extends Yosin_CommonUi {
|
|
||||||
|
|
||||||
constructor(X, Y, W, H, Path, Idx) {
|
|
||||||
base.constructor(X, Y, W, H);
|
|
||||||
DrawBackground(W, H, Path, Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 绘制
|
|
||||||
function DrawBackground(width, height, path, imgId) {
|
|
||||||
|
|
||||||
|
|
||||||
// 创建画布
|
|
||||||
local Canvas = CL_CanvasObject();
|
|
||||||
// 重设大小并清空
|
|
||||||
Canvas.ResizeAndClear(width, height);
|
|
||||||
// 开始绘制
|
|
||||||
Canvas.BeginDraw();
|
|
||||||
|
|
||||||
// 左上角
|
|
||||||
// local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
||||||
local backgroundTopLeft = CL_SpriteObject(path, imgId);
|
|
||||||
// 上边
|
|
||||||
local backgroundTop = CL_SpriteObject(path, imgId + 1);
|
|
||||||
// 右上角
|
|
||||||
local backgroundTopRight = CL_SpriteObject(path, imgId + 2);
|
|
||||||
// 左边
|
|
||||||
local backgroundLeft = CL_SpriteObject(path, imgId + 3);
|
|
||||||
// 中间
|
|
||||||
local backgroundCenter = CL_SpriteObject(path, imgId + 4);
|
|
||||||
// 右边
|
|
||||||
local backgroundRight = CL_SpriteObject(path, imgId + 5);
|
|
||||||
// 左下角
|
|
||||||
local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6);
|
|
||||||
// 下边
|
|
||||||
local backgroundBottom = CL_SpriteObject(path, imgId + 7);
|
|
||||||
// 右下角
|
|
||||||
local backgroundBottomRight = CL_SpriteObject(path, imgId + 8);
|
|
||||||
|
|
||||||
|
|
||||||
// 左上角
|
|
||||||
// backgroundTopLeft.SetPosition(0, 0);
|
|
||||||
// Addchild(backgroundTopLeft);
|
|
||||||
Canvas.DrawActor(backgroundTopLeft, 0, 0);
|
|
||||||
|
|
||||||
local TopLeftSize = backgroundTopLeft.GetSize();
|
|
||||||
local TopLeftBottom = TopLeftSize.h;
|
|
||||||
local TopLeftRight = TopLeftSize.w;
|
|
||||||
|
|
||||||
// 中间图片大小
|
|
||||||
local centerImgSize = backgroundCenter.GetSize();
|
|
||||||
local centerImgWidth = centerImgSize.w;
|
|
||||||
local centerImgHeight = centerImgSize.h;
|
|
||||||
|
|
||||||
local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w;
|
|
||||||
local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h;
|
|
||||||
|
|
||||||
|
|
||||||
local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat();
|
|
||||||
local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat();
|
|
||||||
|
|
||||||
// 上边
|
|
||||||
// backgroundTop.SetScale(scaleW, 1);
|
|
||||||
// Canvas.DrawActor(backgroundTop, TopLeftRight + 1, 0);
|
|
||||||
// Canvas.DrawActor(backgroundTop, 20, 30);
|
|
||||||
|
|
||||||
// // 右上角
|
|
||||||
// Canvas.DrawActor(backgroundTopRight, width - backgroundTopRight.GetSize().w, 0);
|
|
||||||
|
|
||||||
// // 左边
|
|
||||||
// backgroundLeft.SetScale(1, scaleH);
|
|
||||||
// Canvas.DrawActor(backgroundLeft, 0, TopLeftBottom + 1);
|
|
||||||
|
|
||||||
// // 中间
|
|
||||||
// backgroundCenter.SetScale(scaleW, scaleH);
|
|
||||||
// // Addchild(backgroundCenter);
|
|
||||||
// Canvas.DrawActor(backgroundCenter, TopLeftRight + 1, backgroundLeft.Y);
|
|
||||||
|
|
||||||
// // 右边
|
|
||||||
// backgroundRight.SetScale(1, scaleH);
|
|
||||||
// Canvas.DrawActor(backgroundRight, width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
|
||||||
|
|
||||||
// // 左下角
|
|
||||||
// Canvas.DrawActor(backgroundBottomLeft, 0, height - backgroundBottomLeft.GetSize().h);
|
|
||||||
|
|
||||||
// // 下边
|
|
||||||
// backgroundBottom.SetScale(scaleW, 1);
|
|
||||||
// Canvas.DrawActor(backgroundBottom, TopLeftRight + 1, backgroundBottomLeft.Y);
|
|
||||||
|
|
||||||
// // 右下角
|
|
||||||
// Canvas.DrawActor(backgroundBottomRight,width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y );
|
|
||||||
|
|
||||||
// 结束绘制
|
|
||||||
Canvas.EndDraw();
|
|
||||||
// 添加画布
|
|
||||||
Addchild(Canvas);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//拼接按钮
|
//拼接按钮
|
||||||
class Yosin_SplicingButton extends Yosin_CommonUi {
|
class Yosin_SplicingButton extends Yosin_CommonUi {
|
||||||
//按钮状态
|
//按钮状态
|
||||||
|
|
@ -675,14 +678,14 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi {
|
||||||
btns = null;
|
btns = null;
|
||||||
tests = null;
|
tests = null;
|
||||||
|
|
||||||
constructor(X, Y, titles, path, idx, selectIndex = 0, baseWidth = 34) {
|
constructor(X, Y, W, titles, path, idx, baseWidth = 48) {
|
||||||
this.tests = titles;
|
this.tests = titles;
|
||||||
btns = [];
|
btns = [];
|
||||||
local btnX = 0;
|
local btnX = 5;
|
||||||
for (local i = 0; i< titles.len(); i++) {
|
for (local i = 0; i< titles.len(); i++) {
|
||||||
|
|
||||||
local textW = FontAssetManager.GenerateNormal(titles[i], true).GetSize().w + 10;
|
local textW = FontAssetManager.GenerateNormal(titles[i], true).GetSize().w + 10;
|
||||||
local btnW = baseWidth + 10;
|
local btnW = baseWidth;
|
||||||
btnW = textW > btnW ? textW : btnW;
|
btnW = textW > btnW ? textW : btnW;
|
||||||
|
|
||||||
local titleBtn = Yosin_StretchTitleButton(btnX, 1, btnW, 19, path, idx, titles[i]);
|
local titleBtn = Yosin_StretchTitleButton(btnX, 1, btnW, 19, path, idx, titles[i]);
|
||||||
|
|
@ -702,7 +705,7 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi {
|
||||||
};
|
};
|
||||||
|
|
||||||
btns.push(titleBtn);
|
btns.push(titleBtn);
|
||||||
btnX += btnW + 1;
|
btnX += btnW;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.constructor(X, Y, btnX, 21);
|
base.constructor(X, Y, btnX, 21);
|
||||||
|
|
@ -713,6 +716,27 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi {
|
||||||
|
|
||||||
btns[0].SetSelect(true);
|
btns[0].SetSelect(true);
|
||||||
|
|
||||||
|
// 创建画布
|
||||||
|
local Canvas = CL_CanvasObject();
|
||||||
|
Canvas.SetPosition(0, 19);
|
||||||
|
// 重设大小并清空
|
||||||
|
Canvas.ResizeAndClear(W, 1);
|
||||||
|
// 设置填充画刷 用于绘制边框和线条
|
||||||
|
Canvas.SetFillBrush(sq_RGBA(66, 61, 59, 250));
|
||||||
|
// 设置轮廓画刷 用于绘制边框和线条
|
||||||
|
Canvas.SetStrokeBrush(sq_RGBA(66, 61, 59, 250));
|
||||||
|
// 开始绘制
|
||||||
|
Canvas.BeginDraw();
|
||||||
|
|
||||||
|
// 画线段
|
||||||
|
Canvas.DrawLine(0, 1, W, 1);
|
||||||
|
|
||||||
|
// 结束绘制
|
||||||
|
Canvas.EndDraw();
|
||||||
|
// 添加画布
|
||||||
|
Addchild(Canvas);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Yosin_TopTitle extends Yosin_CommonUi {
|
||||||
//内容背景
|
//内容背景
|
||||||
if (drawBackground) {
|
if (drawBackground) {
|
||||||
local background = Yosin_NineBoxStretch(-1, 15, W + 1, H - 15, "sprite/interface/lenheartwindowcommon.img", 97);
|
local background = Yosin_NineBoxStretch(-1, 15, W + 1, H - 15, "sprite/interface/lenheartwindowcommon.img", 97);
|
||||||
AddUIChild(background);
|
Addchild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 标题背景
|
// 标题背景
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
文件用途: 背包窗口
|
文件用途: 背包窗口
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 258, 555, 20);
|
//local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 555, 20);
|
||||||
class _Inventory extends Yosin_Window {
|
class _Inventory extends Yosin_Window {
|
||||||
|
|
||||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||||
|
|
@ -14,18 +14,14 @@ class _Inventory extends Yosin_Window {
|
||||||
local title = Yosin_TopTitle(gWidth, gHeight, "装备栏(I)");
|
local title = Yosin_TopTitle(gWidth, gHeight, "装备栏(I)");
|
||||||
Addchild(title);
|
Addchild(title);
|
||||||
|
|
||||||
local dd = Yosin_NineBoxStretch(100, 200, 100,100 "sprite/interface/lenheartwindowcommon.img", 97);
|
|
||||||
dd.SetPosition(100, 50);
|
|
||||||
Addchild(dd);
|
|
||||||
|
|
||||||
//注册控件
|
//注册控件
|
||||||
// RegisterWidget();
|
RegisterWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
function RegisterWidget() {
|
function RegisterWidget() {
|
||||||
|
|
||||||
//标题按钮
|
//标题按钮
|
||||||
local titlesBtn = Yosin_RowMoreTitleBtn(10, 25, ["物品栏", "装扮", "宠物", "护石"],"sprite/interface/lenheartwindowcommon.img", 160);
|
local titlesBtn = Yosin_RowMoreTitleBtn(5, 22, 252, ["物品栏", "装扮", "宠物", "护石"], "sprite/interface/lenheartwindowcommon.img", 160);
|
||||||
AddUIChild(titlesBtn);
|
AddUIChild(titlesBtn);
|
||||||
|
|
||||||
titlesBtn.LBDownOnClick = function(btns, index) {
|
titlesBtn.LBDownOnClick = function(btns, index) {
|
||||||
|
|
@ -33,7 +29,7 @@ class _Inventory extends Yosin_Window {
|
||||||
};
|
};
|
||||||
|
|
||||||
//物品栏 装备页
|
//物品栏 装备页
|
||||||
local equipmentPage = Inventory_EquipmentPage( 0, titlesBtn.bottom() + 4, 300, Height - titlesBtn.bottom() - 4);
|
local equipmentPage = Inventory_EquipmentPage( 2, titlesBtn.bottom() + 4, 300, Height - titlesBtn.bottom() - 4);
|
||||||
AddUIChild(equipmentPage);
|
AddUIChild(equipmentPage);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,24 +153,28 @@ class InventoryItem extends Yosin_CommonUi {
|
||||||
base.constructor(gX, gY, gWidth, gHeight);
|
base.constructor(gX, gY, gWidth, gHeight);
|
||||||
|
|
||||||
//物品分类按钮
|
//物品分类按钮
|
||||||
local itemBtns = Yosin_RowMoreTitleBtn(10, 4, ["装备", "消耗品", "材料", "任务"], "sprite/interface/lenheartwindowcommon.img", 160);
|
local itemBtns = Yosin_RowMoreTitleBtn(3, 4, 252, ["装备", "消耗品", "材料", "副职业", "任务"], "sprite/interface/lenheartwindowcommon.img", 160);
|
||||||
AddUIChild(itemBtns);
|
AddUIChild(itemBtns);
|
||||||
|
|
||||||
itemBtns.LBDownOnClick = function(btns, index) {
|
itemBtns.LBDownOnClick = function(btns, index) {
|
||||||
print(index);
|
print(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 物品栏边框
|
||||||
|
local itemBg = Yosin_NineBoxStretch(2, itemBtns.bottom(), 253, 245, "sprite/interface/lenheartwindowcommon.img", 97);
|
||||||
|
Addchild(itemBg);
|
||||||
|
|
||||||
// 物品栏
|
// 物品栏
|
||||||
local itemCollection = itemCollection(5, itemBtns.bottom(), 247, 244, 7, 8);
|
local itemCollection = itemCollection(itemBg.X + 7, itemBg.Y + 7, 239, 209, 7, 8);
|
||||||
AddUIChild(itemCollection);
|
AddUIChild(itemCollection);
|
||||||
|
|
||||||
|
|
||||||
local itemBottom = itemCollection.bottom();
|
local itemBgBottom = itemBg.bottom();
|
||||||
// 重量
|
// 重量
|
||||||
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, itemBottom - weight.GetSize().h - 2);
|
weight.SetPosition(itemCollection.X + 5, itemBgBottom - weight.GetSize().h - 5);
|
||||||
Addchild(weight);
|
Addchild(weight);
|
||||||
|
|
||||||
// 重量进度条
|
// 重量进度条
|
||||||
|
|
@ -178,31 +182,25 @@ class InventoryItem extends Yosin_CommonUi {
|
||||||
weightSchedule.SetPercentage(0.6);
|
weightSchedule.SetPercentage(0.6);
|
||||||
Addchild(weightSchedule);
|
Addchild(weightSchedule);
|
||||||
|
|
||||||
// 搜索
|
// 排列按钮
|
||||||
//登录按钮
|
local permutationBtn = Yosin_BaseButton(itemBg.right() - 30, itemBgBottom - 26, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73);
|
||||||
local saerchBtn = Yosin_BaseButton(weightSchedule.right() + 12, itemBottom - 23, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94);
|
AddUIChild(permutationBtn);
|
||||||
//点击事件回调
|
|
||||||
// saerchBtn.OnClick = function(Button) {
|
|
||||||
// }.bindenv(this);
|
|
||||||
AddUIChild(saerchBtn);
|
|
||||||
|
|
||||||
// 设置
|
// 设置
|
||||||
local setBtn = Yosin_BaseButton(saerchBtn.right() + 2, saerchBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77);
|
local setBtn = Yosin_BaseButton(permutationBtn.X - 20, permutationBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77);
|
||||||
//点击事件回调
|
|
||||||
// setBtn.OnClick = function(Button) {
|
|
||||||
// }.bindenv(this);
|
|
||||||
AddUIChild(setBtn);
|
AddUIChild(setBtn);
|
||||||
|
|
||||||
// 排列按钮
|
// 搜索
|
||||||
local permutationBtn = Yosin_BaseButton(setBtn.right(), saerchBtn.Y, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73);
|
local saerchBtn = Yosin_BaseButton(setBtn.X - 24, permutationBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94);
|
||||||
//点击事件回调
|
AddUIChild(saerchBtn);
|
||||||
// permutationBtn.OnClick = function(Button) {
|
|
||||||
// }.bindenv(this);
|
|
||||||
AddUIChild(permutationBtn);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 复活币
|
// 复活币
|
||||||
local moneyItem = MoneyItem(5, itemBottom + 3, 3);
|
local moneyItem = MoneyItem(5, itemBgBottom + 3, 3);
|
||||||
AddUIChild(moneyItem);
|
AddUIChild(moneyItem);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ class itemCollection extends Yosin_CommonUi {
|
||||||
this.columnNum = columnNum;
|
this.columnNum = columnNum;
|
||||||
this.rowNum = rowNum;
|
this.rowNum = rowNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 创建画布
|
// 创建画布
|
||||||
Canvas = CL_CanvasObject();
|
Canvas = CL_CanvasObject();
|
||||||
// 重设大小并清空
|
// 重设大小并清空
|
||||||
|
|
@ -37,11 +35,8 @@ class itemCollection extends Yosin_CommonUi {
|
||||||
// 开始绘制
|
// 开始绘制
|
||||||
Canvas.BeginDraw();
|
Canvas.BeginDraw();
|
||||||
|
|
||||||
local background = Yosin_NineBoxStretch(0, 0, w + 6, h + 6, "sprite/interface/lenheartwindowcommon.img", 97);
|
local itemX = 0;
|
||||||
Canvas.DrawActor(background, 0, 0);
|
local itemY = 0;
|
||||||
|
|
||||||
local itemX = 4;
|
|
||||||
local itemY = 3;
|
|
||||||
for (local i = 0; i< columnNum; i++) {
|
for (local i = 0; i< columnNum; i++) {
|
||||||
local cells = [];
|
local cells = [];
|
||||||
for (local i = 0; i< rowNum; i++) {
|
for (local i = 0; i< rowNum; i++) {
|
||||||
|
|
@ -51,7 +46,7 @@ class itemCollection extends Yosin_CommonUi {
|
||||||
itemX += 30;
|
itemX += 30;
|
||||||
|
|
||||||
}
|
}
|
||||||
itemX = 3;
|
itemX = 0;
|
||||||
itemY += 30;
|
itemY += 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,8 +70,8 @@ class itemCollection extends Yosin_CommonUi {
|
||||||
|
|
||||||
if (isInRect) {
|
if (isInRect) {
|
||||||
local WorldPosition = this.GetWorldPosition();
|
local WorldPosition = this.GetWorldPosition();
|
||||||
local xx = MousePos_X - WorldPosition.x;
|
local xx = MousePos_X - WorldPosition.x -5;
|
||||||
local yy = MousePos_Y - WorldPosition.y;
|
local yy = MousePos_Y - WorldPosition.y -5;
|
||||||
local column = (yy / 30).tointeger();
|
local column = (yy / 30).tointeger();
|
||||||
local row = (xx / 30).tointeger();
|
local row = (xx / 30).tointeger();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue