diff --git a/sqr/Core/BaseClass/BaseObject.nut b/sqr/Core/BaseClass/BaseObject.nut index f894b91..25e4e0e 100644 --- a/sqr/Core/BaseClass/BaseObject.nut +++ b/sqr/Core/BaseClass/BaseObject.nut @@ -142,6 +142,15 @@ class CL_BaseObject { function GetSize() { return BaseObject_GetSize(this.C_Object); } + //获取右侧的坐标 + function right() { + return X + GetSize().w; + } + + //获取底部的坐标 + function bottom() { + return Y + GetSize().h; + } //获取缩放后的大小 function GetScaledSize() { return BaseObject_GetScaledSize(this.C_Object); diff --git a/sqr/Core/UI_Class/UI_Core.nut b/sqr/Core/UI_Class/UI_Core.nut index 70c66d4..978cc13 100644 --- a/sqr/Core/UI_Class/UI_Core.nut +++ b/sqr/Core/UI_Class/UI_Core.nut @@ -144,6 +144,22 @@ class Yosin_BaseWindow extends Layer { base.SetVisible(Flag); } + /* + * @函数作用: 获取窗口右侧的坐标 + */ + function right() { + return X + Width; + } + + /* + * @函数作用: 获取窗口底部的坐标 + */ + function bottom() { + return Y + Height; + } + + + /* * @函数作用: 添加子对象 * @参数 name diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index 1cf9d9f..6a60869 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -209,71 +209,79 @@ class Yosin_NineBoxStretch extends Yosin_CommonUi { // 绘制 function DrawBackground(width, height, path, imgId) { - local x = 0; - local y = 0; // 左上角 local backgroundTopLeft = CL_SpriteObject(path, imgId); - backgroundTopLeft.SetPosition(x, y); - Addchild(backgroundTopLeft); - // 左上角图片大小 - local cornerImgSize = backgroundTopLeft.GetSize(); - local cornerWidth = cornerImgSize.w; - local cornerHeight = cornerImgSize.h; - - // 中间 - local backgroundCenter = CL_SpriteObject(path, imgId + 4); - backgroundCenter.SetPosition(cornerWidth, y + cornerHeight); - Addchild(backgroundCenter); - // 中间图片大小 - local centerImgSize = backgroundCenter.GetSize(); - local centerWidth = centerImgSize.w; - local centerHeight = centerImgSize.h; - - - local scaleW = (width.tofloat() - cornerWidth.tofloat() * 2.0) / centerWidth.tofloat(); - local scaleH = (height.tofloat() - y.tofloat() - cornerHeight.tofloat()) / centerHeight.tofloat(); - // 上边 local backgroundTop = CL_SpriteObject(path, imgId + 1); - backgroundTop.SetPosition(cornerWidth, y); + // 右上角 + 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); + + // 中间图片大小 + 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.SetPosition(backgroundTopLeft.right() + 1, 0); backgroundTop.SetScale(scaleW, 1); Addchild(backgroundTop); // 右上角 - local backgroundTopRight = CL_SpriteObject(path, imgId + 2); - backgroundTopRight.SetPosition(width - cornerWidth, y); + backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0); Addchild(backgroundTopRight); // 左边 local backgroundLeft = CL_SpriteObject(path, imgId + 3); - backgroundLeft.SetPosition(x, y + cornerHeight); + backgroundLeft.SetPosition(0, backgroundTopLeft.bottom() + 1); backgroundLeft.SetScale(1, scaleH); Addchild(backgroundLeft); // 中间 + backgroundCenter.SetPosition(backgroundLeft.right() + 1, backgroundLeft.Y); backgroundCenter.SetScale(scaleW, scaleH); + Addchild(backgroundCenter); // 右边 - local backgroundRight = CL_SpriteObject(path, imgId + 5); - backgroundRight.SetPosition(width - cornerWidth, y + cornerHeight); + backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y); backgroundRight.SetScale(1, scaleH); Addchild(backgroundRight); // 左下角 - local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); - backgroundBottomLeft.SetPosition(x, height - cornerHeight); + backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h); Addchild(backgroundBottomLeft); // 下边 - local backgroundBottom = CL_SpriteObject(path, imgId + 7); - backgroundBottom.SetPosition(cornerWidth, height - cornerHeight); + backgroundBottom.SetPosition(backgroundBottomLeft.right() + 1, backgroundBottomLeft.Y); backgroundBottom.SetScale(scaleW, 1); Addchild(backgroundBottom); // 右下角 - local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); - backgroundBottomRight.SetPosition(width - cornerWidth, height - cornerHeight); + backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y); Addchild(backgroundBottomRight); } @@ -357,4 +365,47 @@ class Yosin_SplicingButton extends Yosin_CommonUi { } ChangeFrame(); } +} + + + + +// 窗口顶部标题 +class Yosin_TopTitle extends Yosin_CommonUi { + + constructor(W, H, title, drawBackground = true) { + base.constructor(0, 0, W, H); + + //内容背景 + if (drawBackground){ + local background = Yosin_NineBoxStretch(-1, 15, W + 1, H - 15, "sprite/interface/lenheartwindowcommon.img", 97); + AddUIChild(background); + } + + // 标题背景 + local Background = Yosin_EmeStretch(0, 0, W, 22, "sprite/interface/lenheartwindowcommon.img", 609); + Addchild(Background); + + // 标题亮色背景 + local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483); + local scaleW = (W / BackgroundBright.GetSize().w).tofloat(); + BackgroundBright.SetScale( scaleW , 1); + Addchild(BackgroundBright); + + + // 标题 + local titleTextActor = FontAssetManager.GenerateNormal(title, true, { + color = sq_RGBA(206, 189, 140, 255), + alignment = TextAlign.Center, + }); + local titleX = W / 2 - titleTextActor.GetSize().w / 2; + // 绘制标题 + titleTextActor.SetPosition(titleX, 2); + Addchild(titleTextActor); + + + } + + + } \ No newline at end of file diff --git a/sqr/User/UI/Window/233_HUD_Message.nut b/sqr/User/UI/Window/233_HUD_Message.nut index f134929..f9e7bd0 100644 --- a/sqr/User/UI/Window/233_HUD_Message.nut +++ b/sqr/User/UI/Window/233_HUD_Message.nut @@ -73,7 +73,7 @@ class _Yosin_MessageBox extends Yosin_Window { function RegisterWidget() { //背景 - local background = Yosin_NineBoxStretch(-1, 15, cacheW + 2, cacheH, "sprite/interface/lenheartwindowcommon.img", 97); + local background = Yosin_NineBoxStretch(-1, 15, cacheW + 1, cacheH, "sprite/interface/lenheartwindowcommon.img", 97); AddUIChild(background); local twoBackground = Yosin_NineBoxStretch(4, 20, cacheW - 8, cacheH - 36, "sprite/interface/lenheartwindowcommon.img", 97); AddUIChild(twoBackground); @@ -82,6 +82,11 @@ class _Yosin_MessageBox extends Yosin_Window { local titleBackground = Yosin_EmeStretch(0, 0, cacheW, 20, "sprite/interface/lenheartwindowcommon.img", 609); AddUIChild(titleBackground); + local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483); + local scaleW = (cacheW / BackgroundBright.GetSize().w).tofloat(); + BackgroundBright.SetScale( scaleW , 1); + Addchild(BackgroundBright); + //确认按钮 local confirmButton = Yosin_BaseButton(cacheW / 2 - 28, cacheH - 15, 56, 24 "sprite/interface/lenheartwindowcommon.img", 12); confirmButton.OnClick = function(Button) {