Ticket #1802: hero_button.4.patch
File hero_button.4.patch, 6.7 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/gui/common/global.xml
26 26 sprite="colour: 0 0 0 200" 27 27 font="mono-stroke-10" 28 28 textcolor="white" 29 size=" 5 35 80 55"29 size="100%-80 70 100%-10 90" 30 30 z="199" 31 31 > 32 32 <action on="Tick"><![CDATA[ -
binaries/data/mods/public/gui/session/session.js
369 369 if (g_ShowAllStatusBars) 370 370 recalculateStatusBarDisplay(); 371 371 372 updateHero(simState); 372 373 updateGroups(); 373 374 updateDebug(simState); 374 375 updatePlayerDisplay(simState); … … 383 384 global.music.setState(global.music.states[battleState]); 384 385 } 385 386 387 function updateHero(simState) 388 { 389 var playerState = simState.players[Engine.GetPlayerID()]; 390 391 if (playerState.heroes.length > 0) 392 { 393 var heroImage = getGUIObjectByName("unitHeroImage"); 394 var heroState = Engine.GuiInterfaceCall("GetEntityState", playerState.heroes[0]); 395 var template = GetTemplateData(heroState.template); 396 heroImage.sprite = "stretched:session/portraits/" + template.icon; 397 398 var heroButton = getGUIObjectByName("unitHeroButton"); 399 heroButton.onpress = (function(e) { return function() { g_Selection.reset(); g_Selection.addList([e]); } })(playerState.heroes[0]); 400 heroButton.ondoublepress = (function(e) { return function() { selectAndMoveTo(e) }; })(playerState.heroes[0]); 401 heroButton.hidden = false; 402 403 // Setup tooltip 404 405 var name = "[font=\"serif-bold-16\"]" + template.name.specific + "[/font] "; 406 var health = "[font=\"serif-bold-13\"]Health:[/font] " + heroState.hitpoints + "/" + heroState.maxHitpoints; 407 408 var type = ""; 409 if (heroState.attack) 410 type = heroState.attack.type + " "; 411 var attack = "[font=\"serif-bold-13\"]" + type + "Attack:[/font] " + damageTypeDetails(heroState.attack); 412 // Show max attack range if ranged attack, also convert to tiles (4m per tile) 413 if (heroState.attack && heroState.attack.type == "Ranged") 414 attack += ", [font=\"serif-bold-13\"]Range:[/font] " + Math.round(heroState.attack.maxRange/4); 415 416 var armor = "[font=\"serif-bold-13\"]Armor:[/font] " + damageTypeDetails(heroState.armour); 417 var extra = template.tooltip; 418 419 heroButton.tooltip = name + "\n" + health + "\n" + attack + "\n" + armor + "\n" + extra; 420 } 421 else 422 { 423 var heroButton = getGUIObjectByName("unitHeroButton"); 424 heroButton.hidden = true; 425 } 426 427 }; 428 386 429 function updateGroups() 387 430 { 388 431 var guiName = "Group"; -
binaries/data/mods/public/gui/session/session.xml
666 757 </object> 667 758 668 759 <!-- ================================ ================================ --> 760 <!-- Hero Selection --> 761 <!-- ================================ ================================ --> 762 <object 763 name="unitHeroPanel" 764 size="0% 5% 0%+50 5%+50" 765 > 766 <object name="unitHeroButton" size="0 0 50 50" type="button" hidden="false" style="iconButton" 767 tooltip_style="sessionToolTip" tooltip="Attack and Armor"> 768 <object name="unitHeroImage" size="5 5 100%-5 100%-5" type="image" ghost="true"/> 769 </object> 770 771 </object> 772 773 <!-- ================================ ================================ --> 669 774 <!-- Unit Selection Groups --> 670 775 <!-- ================================ ================================ --> 671 776 <objectIndex: binaries/data/mods/public/simulation/components/GuiInterface.js -
binaries/data/mods/public/simulation/components/GuiInterface.js
79 79 "popCount": cmpPlayer.GetPopulationCount(), 80 80 "popLimit": cmpPlayer.GetPopulationLimit(), 81 81 "popMax": cmpPlayer.GetMaxPopulation(), 82 "heroes": cmpPlayer.GetHeroes(), 82 83 "resourceCounts": cmpPlayer.GetResourceCounts(), 83 84 "trainingBlocked": cmpPlayer.IsTrainingBlocked(), 84 85 "state": cmpPlayer.GetState(), -
binaries/data/mods/public/simulation/components/Player.js
19 19 "metal": 300, 20 20 "stone": 300 21 21 }; 22 22 23 23 this.team = -1; // team number of the player, players on the same team will always have ally diplomatic status - also this is useful for team emblems, scoring, etc. 24 24 this.teamsLocked = false; 25 25 this.state = "active"; // game state - one of "active", "defeated", "won" … … 32 32 this.isAI = false; 33 33 this.cheatsEnabled = true; 34 34 this.cheatTimeMultiplier = 1; 35 this.heroes = []; 35 36 }; 36 37 37 38 Player.prototype.SetPlayerID = function(id) … … 109 110 return Math.round(ApplyTechModificationsToPlayer("Player/MaxPopulation", this.maxPop, this.entity)); 110 111 }; 111 112 113 Player.prototype.GetHeroes = function() 114 { 115 return this.heroes; 116 }; 117 112 118 Player.prototype.IsTrainingBlocked = function() 113 119 { 114 120 return this.trainingBlocked; … … 446 452 Player.prototype.OnGlobalOwnershipChanged = function(msg) 447 453 { 448 454 var isConquestCritical = false; 455 var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity); 456 449 457 // Load class list only if we're going to need it 450 458 if (msg.from == this.playerID || msg.to == this.playerID) 451 459 { 452 var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity);453 460 if (cmpIdentity) 454 461 { 455 462 isConquestCritical = cmpIdentity.HasClass("ConquestCritical"); … … 465 472 this.popUsed -= cost.GetPopCost(); 466 473 this.popBonuses -= cost.GetPopBonus(); 467 474 } 475 476 if (cmpIdentity && cmpIdentity.HasClass("Hero")) 477 { 478 //Remove from Heroes list 479 var index = this.heroes.indexOf(msg.entity); 480 if (index >= 0) 481 { 482 this.heroes.splice(index, 1); 483 } 484 else 485 { 486 // Why is not the Hero in the list? 487 } 488 } 489 468 490 } 469 491 if (msg.to == this.playerID) 470 492 { … … 476 498 this.popUsed += cost.GetPopCost(); 477 499 this.popBonuses += cost.GetPopBonus(); 478 500 } 501 502 if (cmpIdentity && cmpIdentity.HasClass("Hero")) 503 { 504 this.heroes.push(msg.entity); 505 } 479 506 } 480 507 }; 481 508