| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  | 文件名:6_PlayerChat.nut | 
					
						
							|  |  |  | 路径:User/UI/Window/6_PlayerChat.nut | 
					
						
							|  |  |  | 创建日期:2025-01-20	18:03 | 
					
						
							|  |  |  | 文件用途: | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //主类 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  | class _PlayerChat extends Yosin_Window { | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:13:02 +08:00
										 |  |  |     //是否为顶层窗口 | 
					
						
							|  |  |  |     IsTop = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { | 
					
						
							|  |  |  |         base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local background = PlayerChat_Backgournd(); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         Addchild(background); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         RegisterWidget(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function RegisterWidget() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 普通 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local ordinary = PlayerChat_SplicingButton(6, 206, 53, 20, 8, "普通", sq_RGBA(255, 255, 255, 255)); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         AddUIChild(ordinary); | 
					
						
							|  |  |  |         ordinary.LBDownOnClick = function(btn) { | 
					
						
							|  |  |  |             print(111); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         ordinary.OnTriangleClick = function(btn) { | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |             print(222); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 公会 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local notice = PlayerChat_SplicingButton(60, 206, 53, 20, 47, "公会", sq_RGBA(254, 77, 245, 255)); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         AddUIChild(notice); | 
					
						
							|  |  |  |         notice.LBDownOnClick = function(btn) { | 
					
						
							|  |  |  |             print(111); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         notice.OnTriangleClick = function(btn) { | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |             print(222); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 频道 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local channel = PlayerChat_SplicingButton(114, 206, 53, 20, 48, "频道", sq_RGBA(221, 153, 197, 255)); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         AddUIChild(channel); | 
					
						
							|  |  |  |         channel.LBDownOnClick = function(btn) { | 
					
						
							|  |  |  |             print(111); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         channel.OnTriangleClick = function(btn) { | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |             print(222); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 募集 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local raise = PlayerChat_SplicingButton(168, 206, 53, 20, 49, "募集", sq_RGBA(105, 212, 238, 255)); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         AddUIChild(raise); | 
					
						
							|  |  |  |         raise.LBDownOnClick = function(btn) { | 
					
						
							|  |  |  |             print(111); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         raise.OnTriangleClick = function(btn) { | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |             print(222); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //逻辑入口 | 
					
						
							|  |  |  |     function Proc(Dt) { | 
					
						
							|  |  |  |         SyncPos(X, Y); | 
					
						
							|  |  |  |         base.Proc(Dt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 背景 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  | class PlayerChat_Backgournd extends CL_CanvasObject { | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     constructor() { | 
					
						
							|  |  |  |         base.constructor(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         DrawBackground(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // 绘制背景 | 
					
						
							|  |  |  |     function DrawBackground() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 创建画布 | 
					
						
							|  |  |  |         CL_CanvasObject(); | 
					
						
							|  |  |  |         // 重设大小并清空 | 
					
						
							|  |  |  |         ResizeAndClear(332, 600); | 
					
						
							|  |  |  |         // 开始绘制 | 
					
						
							|  |  |  |         BeginDraw(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local topLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 159); | 
					
						
							|  |  |  |         DrawSpriteFrame(topLine, 0, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local topBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 160); | 
					
						
							|  |  |  |         topBg.SetPosition(0, 2); | 
					
						
							|  |  |  |         topBg.SetScale(1, 28); | 
					
						
							|  |  |  |         DrawSprite(topBg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local bimg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 161); | 
					
						
							|  |  |  |         DrawSpriteFrame(bimg, 0, 30); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local bottomBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 162); | 
					
						
							|  |  |  |         bottomBg.SetPosition(0, 561); | 
					
						
							|  |  |  |         bottomBg.SetScale(1, 38); | 
					
						
							|  |  |  |         DrawSprite(bottomBg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local bottomLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 163); | 
					
						
							|  |  |  |         DrawSpriteFrame(bottomLine, 0, 598); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 系统按钮 | 
					
						
							|  |  |  |         local systemBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); | 
					
						
							|  |  |  |         DrawSprite(systemBtnBackground, 6, 15); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         local systemText = FontAssetManager.GenerateNormal("系统", true, { | 
					
						
							|  |  |  |             color = sq_RGBA(200, 173, 134, 255) | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         DrawActor(systemText, 18, 18); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // 系统 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local SystemBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); | 
					
						
							|  |  |  |         DrawSprite(SystemBround, 6, 35); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // 喇叭按钮 | 
					
						
							|  |  |  |         local megaphoneBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); | 
					
						
							|  |  |  |         DrawSprite(megaphoneBtnBackground, 6, 109); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 喇叭 | 
					
						
							|  |  |  |         local megaphoneext = FontAssetManager.GenerateNormal("喇叭", true, { | 
					
						
							|  |  |  |             color = sq_RGBA(255, 239, 1, 255) | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         DrawActor(megaphoneext, 18, 112); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // 喇叭 | 
					
						
							|  |  |  |         local megaphoneBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         DrawSprite(megaphoneBround, 6, 130); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // 消息 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |         local PlayerChatBround = Yosin_NineBoxStretch(321, 345, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); | 
					
						
							|  |  |  |         DrawSprite(PlayerChatBround, 6, 225); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 结束绘制 | 
					
						
							|  |  |  |         EndDraw(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 消息分类按钮 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  | class PlayerChat_SplicingButton extends Yosin_CommonUi { | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //按钮状态 | 
					
						
							|  |  |  |     State = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Sprite = null; | 
					
						
							|  |  |  |     SpriteState = -1; | 
					
						
							|  |  |  |     FrameList = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     select = false; | 
					
						
							|  |  |  |     cacheY = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LBDownOnClick = null; | 
					
						
							|  |  |  |     OnTriangleClick = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(X, Y, W, H, Idx, title, titleColor) { | 
					
						
							|  |  |  |         base.constructor(X, Y, W, H); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         cacheY = Y; | 
					
						
							|  |  |  |         FrameList = []; | 
					
						
							|  |  |  |         Sprite = CL_SpriteObject(); | 
					
						
							|  |  |  |         Addchild(Sprite); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (local i = 0; i< 3; i++) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-20 18:04:32 +08:00
										 |  |  |             local canvas = Yosin_EmeStretch(W, H, "sprite/interface/lenheartwindowcommon.img", 160 + i * 3); | 
					
						
							|  |  |  |             local Sf = canvas.ExportSpriteFrame(); | 
					
						
							| 
									
										
										
										
											2025-01-19 17:44:38 +08:00
										 |  |  |             FrameList.push(Sf); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 文字 | 
					
						
							|  |  |  |         local Text = FontAssetManager.GenerateNormal(title, true, { | 
					
						
							|  |  |  |             color = titleColor | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         Text.SetPosition(12, 1); | 
					
						
							|  |  |  |         Addchild(Text); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 三角 | 
					
						
							|  |  |  |         local triangle = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_new.img", Idx); | 
					
						
							|  |  |  |         triangle.SetPosition(W - 15, 8); | 
					
						
							|  |  |  |         Addchild(triangle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 按钮 | 
					
						
							|  |  |  |         local bigButton = Yosin_BaseButton(0, 0, W - 15, H, "sprite/interface/lenheartwindowcommon.img", 70); | 
					
						
							|  |  |  |         AddUIChild(bigButton); | 
					
						
							|  |  |  |         bigButton.OnClick = function(btn) { | 
					
						
							|  |  |  |             if (LBDownOnClick) { | 
					
						
							|  |  |  |                 LBDownOnClick(this); | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |         }.bindenv(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 三角按钮 | 
					
						
							|  |  |  |         local triangleButton = Yosin_BaseButton(W - 15, 0, 15, H, "sprite/interface/lenheartwindowcommon.img", 70); | 
					
						
							|  |  |  |         AddUIChild(triangleButton); | 
					
						
							|  |  |  |         triangleButton.OnClick = function(btn) { | 
					
						
							|  |  |  |             if (OnTriangleClick) { | 
					
						
							|  |  |  |                 OnTriangleClick(this); | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |         }.bindenv(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function ChangeFrame() { | 
					
						
							|  |  |  |         //状态更改 刷新精灵帧 | 
					
						
							|  |  |  |         if (State != SpriteState) { | 
					
						
							|  |  |  |             if (State == 2) { | 
					
						
							|  |  |  |                 Y = cacheY - 1; | 
					
						
							|  |  |  |                 SyncPos(X, Y); | 
					
						
							|  |  |  |             } else if (SpriteState == 2) { | 
					
						
							|  |  |  |                 Y = cacheY; | 
					
						
							|  |  |  |                 SyncPos(X, Y); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             SpriteState = State; | 
					
						
							|  |  |  |             Sprite.SetFrame(FrameList[SpriteState]); | 
					
						
							|  |  |  |             Sprite.SetPosition(0, 0); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function Proc(Dt) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (select) return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //不可用 | 
					
						
							|  |  |  |         if (State == 3) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             //按下 | 
					
						
							|  |  |  |             if (isLBDown) { | 
					
						
							|  |  |  |                 State = 2; | 
					
						
							|  |  |  |                 select = true; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             //悬停 | 
					
						
							|  |  |  |             else if (isInRect) { | 
					
						
							|  |  |  |                 State = 1; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             //普通 | 
					
						
							|  |  |  |             else { | 
					
						
							|  |  |  |                 State = 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         ChangeFrame(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |