From da0e76a02c9cdaa6ca4e1bc6ff55a1b8cc259736 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Mon, 20 Jan 2025 18:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=BF=B7=E4=BD=A0?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E7=B1=BB=20=E8=BF=94=E5=9B=9E=E4=B8=BA?= =?UTF-8?q?=E7=94=BB=E5=B8=83=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/User/UI/Widget/Mininumber.nut | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sqr/User/UI/Widget/Mininumber.nut diff --git a/sqr/User/UI/Widget/Mininumber.nut b/sqr/User/UI/Widget/Mininumber.nut new file mode 100644 index 0000000..d6d6056 --- /dev/null +++ b/sqr/User/UI/Widget/Mininumber.nut @@ -0,0 +1,39 @@ +/* +文件名:Mininumber.nut +路径:User/UI/Widget/Mininumber.nut +创建日期:2025-01-20 17:49 +文件用途: +*/ +//迷你数字 +class Yosin_Mininumber extends CL_CanvasObject { + + //图片数字宽度 + Yosin_Mininumber_NumberWidth = [6, 4, 6, 6, 6, 6, 6, 6, 6, 6]; + + // 构造函数 + constructor(Number) { + + if (typeof Number != "integer") error("参数错误"); + local NumberString = Number.tostring(); + + base.constructor(); + + // 创建画布 + CL_CanvasObject(); + // 重设大小并清空 + ResizeAndClear(NumberString.len() * 6, 10); + // 开始绘制 + BeginDraw(); + + local DrawTextWidth = 0; + foreach(value in NumberString) { + local realnum = value - 48; + DrawSpriteFrame(CL_SpriteFrameObject("sprite/interface/mininumberset.img", realnum), DrawTextWidth, 0); + DrawTextWidth += Yosin_Mininumber_NumberWidth[realnum]; + } + + + // 结束绘制 + EndDraw(); + } +} \ No newline at end of file