39 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			39 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名: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(); | ||
|  |     } | ||
|  | } |