| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 文件名: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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //内容背景 | 
					
						
							| 
									
										
										
										
											2025-01-07 20:52:28 +08:00
										 |  |  |         if (drawBackground) { | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  |             local background = Yosin_NineBoxStretch( W, H, "sprite/interface/lenheartwindowcommon.img", 97); | 
					
						
							|  |  |  |             background.SetPosition(0, 0); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:39:29 +08:00
										 |  |  |             Addchild(background); | 
					
						
							| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  |         // 绘制标题背景 | 
					
						
							|  |  |  |         local titleX = drawBackground ? 2 : 0; | 
					
						
							|  |  |  |         local titleW = drawBackground ? W - 4 : W; | 
					
						
							| 
									
										
										
										
											2025-01-19 14:09:38 +08:00
										 |  |  |         local titleBackground = Yosin_EmeStretch( titleW, 20, "sprite/interface/lenheartwindowcommon.img", 609); | 
					
						
							|  |  |  |         titleBackground.SetPosition(titleX, 0); | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  |         titleBackground.SetScale(1, 1.3); | 
					
						
							|  |  |  |         Addchild(titleBackground); | 
					
						
							| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  |         // 标题背景光 | 
					
						
							| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  |         local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483); | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  |         local BackgroundBrightSize = BackgroundBright.GetSize(); | 
					
						
							|  |  |  |         // 计算光的缩放比例 | 
					
						
							|  |  |  |         local scaleW = (W / BackgroundBrightSize.w).tofloat(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-07 20:52:28 +08:00
										 |  |  |         BackgroundBright.SetScale(scaleW, 1); | 
					
						
							| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  |         BackgroundBright.SetPosition(0, 1); | 
					
						
							| 
									
										
										
										
											2025-01-11 01:27:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-06 21:00:13 +08:00
										 |  |  |         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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |