DOF/sqr/User/UI/Widget/Top_Title.nut

53 lines
1.6 KiB
Plaintext

/*
文件名:Top_Title.nut
路径:User/UI/Widget/Top_Title.nut
创建日期:2025-01-06 14:00
文件用途: 窗口顶部标题
*/
// 窗口顶部标题
class Yosin_TopTitle extends Yosin_CommonUi {
constructor(W, H, title, drawBackground = true) {
base.constructor(0, 0, W, H);
//内容背景
if (drawBackground) {
local background = Yosin_NineBoxStretch( W, H, "sprite/interface/lenheartwindowcommon.img", 97);
background.SetPosition(0, 0);
Addchild(background);
}
// 绘制标题背景
local titleX = drawBackground ? 2 : 0;
local titleW = drawBackground ? W - 4 : W;
local titleBackground = Yosin_EmeStretch(titleX, 0, titleW, 20, "sprite/interface/lenheartwindowcommon.img", 609);
titleBackground.SetScale(1, 1.3);
Addchild(titleBackground);
// 标题背景光
local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483);
local BackgroundBrightSize = BackgroundBright.GetSize();
// 计算光的缩放比例
local scaleW = (W / BackgroundBrightSize.w).tofloat();
print(scaleW);
BackgroundBright.SetScale(scaleW, 1);
BackgroundBright.SetPosition(0, 1);
print(BackgroundBright.X );
Addchild(BackgroundBright);
// 标题
local titleTextActor = FontAssetManager.GenerateNormal(title, true, {
color = sq_RGBA(206, 189, 140, 255)
});
local titleX = W / 2 - titleTextActor.GetSize().w / 2;
// 绘制标题
titleTextActor.SetPosition(titleX, 2);
Addchild(titleTextActor);
}
}