386 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			386 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名:4_PersonalInfo.nut | ||
|  | 路径:User/UI/Window/4_PersonalInfo.nut | ||
|  | 创建日期:2024-12-26	00:32 | ||
|  | 文件用途: 个人信息 | ||
|  | */ | ||
|  | 
 | ||
|  | // 个人信息 286, 530 | ||
|  | class _PersonalInfo extends Yosin_Window { | ||
|  | 
 | ||
|  |     roleTitleBtn = null; | ||
|  |     dressUpTitleBtn = null; | ||
|  |     stoneTitleBtn = null; | ||
|  | 
 | ||
|  | 
 | ||
|  |     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { | ||
|  |         base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); | ||
|  | 
 | ||
|  |         local title = Yosin_TopTitle(gWidth, gHeight, "个人信息(M)"); | ||
|  |         AddUIChild(title); | ||
|  | 
 | ||
|  |         //注册控件 | ||
|  |         RegisterWidget(); | ||
|  |     } | ||
|  | 
 | ||
|  |     function RegisterWidget() { | ||
|  |         // 角色按钮 | ||
|  |         roleTitleBtn = titleButton(10, 25, 40, 19, "sprite/interface/lenheartwindowcommon.img", 82, "角色"); | ||
|  |         AddUIChild(roleTitleBtn); | ||
|  |         // 装扮/宠物按钮 | ||
|  |         dressUpTitleBtn = titleButton(roleTitleBtn.right() + 1, 25, 71, 19, "sprite/interface/lenheartwindowcommon.img", 86, "装扮/宠物"); | ||
|  |         AddUIChild(dressUpTitleBtn); | ||
|  |         // 护石按钮 | ||
|  |         stoneTitleBtn = titleButton(dressUpTitleBtn.right() + 1, 25, 40, 19, "sprite/interface/lenheartwindowcommon.img", 82, "护石"); | ||
|  |         AddUIChild(stoneTitleBtn); | ||
|  | 
 | ||
|  |         roleTitleBtn.LBDownOnClick = function (btn) { | ||
|  |             titleClick(btn); | ||
|  |         }.bindenv(this); | ||
|  |         dressUpTitleBtn.LBDownOnClick = function (btn) { | ||
|  |             titleClick(btn); | ||
|  |         }.bindenv(this); | ||
|  |         stoneTitleBtn.LBDownOnClick = function (btn) { | ||
|  |             titleClick(btn); | ||
|  |         }.bindenv(this); | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  |         // 角色信息 | ||
|  |         local roleInfo = roleInfo("个人角色信息", roleTitleBtn.X, roleTitleBtn.bottom() + 2 ); | ||
|  |         AddUIChild(roleInfo); | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function titleClick(btn) { | ||
|  |         btn.Parent.roleTitleBtn.select = false; | ||
|  |         btn.Parent.dressUpTitleBtn.select = false; | ||
|  |         btn.Parent.stoneTitleBtn.select = false; | ||
|  |         btn.select = true; | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     //逻辑入口 | ||
|  |     function Proc(Dt) { | ||
|  |         SyncPos(X, Y); | ||
|  |         base.Proc(Dt); | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | // 角色信息 | ||
|  | class roleInfo extends Yosin_Window { | ||
|  | 
 | ||
|  |     //是否为独立窗口 | ||
|  |     IsIndependent = false; | ||
|  | 
 | ||
|  |     brown = sq_RGBA(160, 132, 75, 255); | ||
|  |     green = sq_RGBA(74, 161, 87, 255); | ||
|  | 
 | ||
|  |     btn = null; | ||
|  | 
 | ||
|  |     constructor(gObjectId, gX, gY) { | ||
|  |         base.constructor(gObjectId, gX, gY, 266, 355, 0); | ||
|  | 
 | ||
|  |         //注册控件 | ||
|  |         RegisterWidget(); | ||
|  |     } | ||
|  | 
 | ||
|  |     function RegisterWidget() { | ||
|  |         // 背景 | ||
|  |         local backGround = CL_SpriteObject("sprite/interface2/profile/profile.img", 60); | ||
|  |         Addchild(backGround); | ||
|  |         // 装备背景 | ||
|  |         local equipmentBackground = CL_SpriteObject("sprite/interface2/profile/profile.img", 14); | ||
|  |         equipmentBackground.SetPosition(7.5, 8); | ||
|  |         Addchild(equipmentBackground); | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  |         // 冒险家名望 | ||
|  |         local adventurerFame = CL_SpriteObject("sprite/interface2/profile/profile_icon.img", 53); | ||
|  |         adventurerFame.SetPosition(70, 185); | ||
|  |         Addchild(adventurerFame); | ||
|  | 
 | ||
|  |         local adventurerFameText = FontAssetManager.GenerateNormal("冒险家名望", true, { | ||
|  |             color = brown | ||
|  |         }); | ||
|  |         adventurerFameText.SetPosition(adventurerFame.right() + 5, adventurerFame.Y); | ||
|  |         Addchild(adventurerFameText); | ||
|  | 
 | ||
|  |         // 冒险家名望数值 | ||
|  |         local adventurerFameNum = FontAssetManager.GenerateNormal("7", true, { | ||
|  |             color = green | ||
|  |         }); | ||
|  |         adventurerFameNum.SetPosition(adventurerFameText.right() + 5, adventurerFameText.Y); | ||
|  |         Addchild(adventurerFameNum); | ||
|  | 
 | ||
|  | 
 | ||
|  |         // 属性 | ||
|  | 
 | ||
|  |         // 生命 | ||
|  |         local life = roleInfoPropertyItem(0, 213, 0, "生命", "100"); | ||
|  |         Addchild(life); | ||
|  |         // 魔法 | ||
|  |         local magic = roleInfoPropertyItem(life.right() + 16, life.Y, 1, "魔法", "100"); | ||
|  |         Addchild(magic); | ||
|  |         // 物理防御力 | ||
|  |         local physicalDefense = roleInfoPropertyItem(life.X, life.bottom(), 8, "物理防御力", "100", false); | ||
|  |         Addchild(physicalDefense); | ||
|  |         // 魔法防御力 | ||
|  |         local magicDefense = roleInfoPropertyItem(physicalDefense.right() + 16, physicalDefense.Y, 9, "魔法防御力", "100"); | ||
|  |         Addchild(magicDefense); | ||
|  | 
 | ||
|  |         // 力量 | ||
|  |         local strength = roleInfoPropertyItem(life.X, physicalDefense.bottom(), 2, "力量", "100"); | ||
|  |         Addchild(strength); | ||
|  |         // 智力 | ||
|  |         local intelligence = roleInfoPropertyItem(strength.right() + 16, strength.Y, 3, "智力", "100"); | ||
|  |         Addchild(intelligence); | ||
|  |         // 体力 | ||
|  |         local vitality = roleInfoPropertyItem(strength.X, strength.bottom(), 4, "体力", "100"); | ||
|  |         Addchild(vitality); | ||
|  |         // 精神 | ||
|  |         local spirit = roleInfoPropertyItem(vitality.right() + 16, vitality.Y, 5, "精神", "100"); | ||
|  |         Addchild(spirit); | ||
|  |         // 物理攻击力 | ||
|  |         local physicalATK = roleInfoPropertyItem(life.X, spirit.bottom(), 6, "物理攻击力", "100"); | ||
|  |         Addchild(physicalATK); | ||
|  |         // 魔法攻击力 | ||
|  |         local magicATK = roleInfoPropertyItem(physicalATK.right() + 16, physicalATK.Y, 7, "魔法攻击力", "100"); | ||
|  |         Addchild(magicATK); | ||
|  |         // 物理暴击 | ||
|  |         local physicalCrit = roleInfoPropertyItem(life.X, magicATK.bottom(), 10, "物理暴击", "100"); | ||
|  |         Addchild(physicalCrit); | ||
|  |         // 魔法暴击 | ||
|  |         local magicCrit = roleInfoPropertyItem(physicalCrit.right() + 16, physicalCrit.Y, 11, "魔法暴击", "100"); | ||
|  |         Addchild(magicCrit); | ||
|  |         // 独立攻击 | ||
|  |         local independentAttack = roleInfoPropertyItem(life.X, magicCrit.bottom(), 12, "独立攻击", "100"); | ||
|  |         Addchild(independentAttack); | ||
|  | 
 | ||
|  |         // 攻击速度 | ||
|  |         local attackSpeed = roleInfoPropertyItem(life.X, independentAttack.bottom(), 13, "攻击速度", "100"); | ||
|  |         Addchild(attackSpeed); | ||
|  |         // 释放速度 | ||
|  |         local releaseSpeed = roleInfoPropertyItem(attackSpeed.right() + 16, attackSpeed.Y, 14, "释放速度", "100"); | ||
|  |         Addchild(releaseSpeed); | ||
|  |         // 移动速度 | ||
|  |         local moveSpeed = roleInfoPropertyItem(life.X, releaseSpeed.bottom(), 15, "移动速度", "100"); | ||
|  |         Addchild(moveSpeed); | ||
|  | 
 | ||
|  |         // 攻击属性 | ||
|  |         local attackProperty = roleInfoPropertyItem(life.X, moveSpeed.bottom(), 16, "攻击属性", "火(0)/冰(0)/光(0)/暗(0)", true, 260); | ||
|  |         Addchild(attackProperty); | ||
|  | 
 | ||
|  | 
 | ||
|  |         // 副职业 | ||
|  |         local subJob = otherButton(0, 401, 62, "副职业", false); | ||
|  |         AddUIChild(subJob); | ||
|  |         subJob.OnClick = function (btn) { | ||
|  |             //todo 打开副职业面板 | ||
|  |             print(11111); | ||
|  |         }.bindenv(this); | ||
|  | 
 | ||
|  |         local separation = CL_SpriteObject("sprite/interface2/profile/profile.img", 70 ); | ||
|  |         separation.SetPosition(subJob.right(), subJob.Y + 7.5); | ||
|  |         Addchild(separation); | ||
|  | 
 | ||
|  |         // 战斗分析 | ||
|  |         local battleAnalysis = otherButton(subJob.right() + 1, subJob.Y, 64, "战斗分析"); | ||
|  |         AddUIChild(battleAnalysis); | ||
|  |         battleAnalysis.OnClick = function (btn) { | ||
|  |             //todo 打开面板 | ||
|  |             print(11111); | ||
|  |         }.bindenv(this); | ||
|  | 
 | ||
|  |         local separationOne = CL_SpriteObject("sprite/interface2/profile/profile.img", 70 ); | ||
|  |         separationOne.SetPosition(battleAnalysis.right(), battleAnalysis.Y + 7.5); | ||
|  |         Addchild(separationOne); | ||
|  | 
 | ||
|  |         // 决斗信息 //todo 图不对 | ||
|  |         local duelInfo = otherButton(battleAnalysis.right() + 1, battleAnalysis.Y, 66, "决斗信息"); | ||
|  |         AddUIChild(duelInfo); | ||
|  |         duelInfo.OnClick = function (btn) { | ||
|  |             //todo 打开面板 | ||
|  |             print(11111); | ||
|  |         }.bindenv(this); | ||
|  | 
 | ||
|  |         local separationTwo = CL_SpriteObject("sprite/interface2/profile/profile.img", 70 ); | ||
|  |         separationTwo.SetPosition(duelInfo.right(), duelInfo.Y + 7.5); | ||
|  |         Addchild(separationTwo); | ||
|  | 
 | ||
|  |         // 详细信息 | ||
|  |         local detailedInformation = otherButton(duelInfo.right() + 1, duelInfo.Y, 66, "详细信息"); | ||
|  |         AddUIChild(detailedInformation); | ||
|  |         detailedInformation.OnClick = function (btn) { | ||
|  |             //todo 打开面板 | ||
|  |             print(11111); | ||
|  |         }.bindenv(this); | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function RegisterDraw() { | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     //逻辑入口 | ||
|  |     function Proc(Dt) { | ||
|  |         SyncPos(X, Y); | ||
|  |         base.Proc(Dt); | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | // 标题按钮 | ||
|  | class titleButton extends Yosin_BaseButton { | ||
|  | 
 | ||
|  |     select = false; | ||
|  |     cacheY = null; | ||
|  | 
 | ||
|  |     LBDownOnClick = null; | ||
|  | 
 | ||
|  |     constructor(X, Y, W, H, Path, Idx, title) { | ||
|  |         base.constructor(X, Y, W, H, Path, Idx); | ||
|  | 
 | ||
|  |         cacheY = Y; | ||
|  |         DownSimulateOffset = false; | ||
|  | 
 | ||
|  |         local backText = FontAssetManager.GenerateNormal( title , true, { | ||
|  |             color = sq_RGBA(130, 114, 84, 255) | ||
|  |         }); | ||
|  |         backText.SetUpdateFunc(function(Text, Dt) { | ||
|  |             if (select) { | ||
|  |                 Text.SetFillColor(sq_RGBA(187,176,149, 255)); | ||
|  |             } else { | ||
|  |                 Text.SetFillColor(sq_RGBA(130,114,84, 255)); | ||
|  |             } | ||
|  |         }) | ||
|  | 
 | ||
|  |         backText.SetPosition(9, 2); | ||
|  |         Addchild(backText); | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function ChangeFrame() { | ||
|  |         //状态更改 刷新精灵帧 | ||
|  |         if (State != SpriteState) { | ||
|  |             if (State == 2) { | ||
|  |                 Y -= 1; | ||
|  |                 SyncPos(X, Y); | ||
|  |             } else if (SpriteState == 2) { | ||
|  |                 Y += 1; | ||
|  |                 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; | ||
|  |                 if (LBDownOnClick != null) { | ||
|  |                     LBDownOnClick(this); | ||
|  |                 } | ||
|  |             } | ||
|  |             //悬停 | ||
|  |             else if (isInRect) { | ||
|  |                 State = 1; | ||
|  |             } | ||
|  |             //普通 | ||
|  |             else { | ||
|  |                 State = 0; | ||
|  |             } | ||
|  |         } | ||
|  |         ChangeFrame(); | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | // 属性项 | ||
|  | class roleInfoPropertyItem extends Yosin_CommonUi { | ||
|  | 
 | ||
|  |     // additionReaction 属性是否有加成 加成为绿色 不加成灰色 | ||
|  |     constructor(gX, gY, idx, title, numText, additionReaction = true,  width = 120) { | ||
|  |         base.constructor(gX, gY, width, 18); | ||
|  | 
 | ||
|  |         local titlecolor = additionReaction ? sq_RGBA(160, 132, 75, 255) : sq_RGBA(79, 79, 79, 255); | ||
|  |         local numColor = additionReaction ? sq_RGBA(75, 161, 85, 255) : sq_RGBA(79, 79, 79, 255); | ||
|  | 
 | ||
|  |         local icon = CL_SpriteObject("sprite/interface2/profile/profile_icon.img", idx); | ||
|  |         icon.SetPosition(5, 0); | ||
|  |         Addchild(icon); | ||
|  | 
 | ||
|  |         // 属性名称 | ||
|  |         local property = FontAssetManager.GenerateNormal(title, true, { | ||
|  |             color = titlecolor | ||
|  |         }); | ||
|  |         property.SetPosition(icon.right() + 5, icon.Y); | ||
|  |         Addchild(property); | ||
|  | 
 | ||
|  |         // 属性数值 | ||
|  |         local propertyNum = FontAssetManager.GenerateNormal(numText, true, { | ||
|  |             color = numColor | ||
|  |         }); | ||
|  |         local numX = width - propertyNum.GetSize().w; | ||
|  |         propertyNum.SetPosition( numX, icon.Y); | ||
|  |         Addchild(propertyNum); | ||
|  | 
 | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     //逻辑入口 | ||
|  |     function Proc(Dt) { | ||
|  |         SyncPos(X, Y); | ||
|  |         base.Proc(Dt); | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | // 其他面板按钮 | ||
|  | class otherButton extends Yosin_CommonUi { | ||
|  | 
 | ||
|  |     enabled = true; | ||
|  | 
 | ||
|  |     constructor(gX, gY, idx, title, enabled = true, ) { | ||
|  |         base.constructor(gX, gY, 65, 65); | ||
|  | 
 | ||
|  |         this.enabled = enabled; | ||
|  | 
 | ||
|  |         local icon = CL_SpriteObject("sprite/interface2/profile/profile.img", enabled ? idx : idx +1 ); | ||
|  |         icon.SetPosition( 0, 4); | ||
|  |         Addchild(icon); | ||
|  | 
 | ||
|  |         local titlecolor = enabled? sq_RGBA(160, 132, 75, 255) : sq_RGBA(79, 79, 79, 255); | ||
|  |         // 属性名称 | ||
|  |         local property = FontAssetManager.GenerateNormal(title, true, { | ||
|  |             color = titlecolor | ||
|  |         }); | ||
|  |         property.SetPosition( 65/ 2 - property.GetSize().w / 2 , icon.bottom() + 5); | ||
|  |         Addchild(property); | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | 
 |