/* 文件名: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(-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); BackgroundBright.SetPosition(0, 1); 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); local closeBtn = Yosin_BaseButton(W - 20, 4, 12, 12, "sprite/interface/lenheartwindowcommon.img", 544); closeBtn.DownSimulateOffset = false; closeBtn.OnClick = function(btn) { } AddUIChild(closeBtn); local topBtn = Yosin_BaseButton(W - 40, 2, 13, 13, "sprite/interface/lenheartwindowcommon.img", 455); topBtn.DownSimulateOffset = false; topBtn.OnClick = function(btn) { } AddUIChild(topBtn); } }