Guest User

main_ui.js

a guest
Aug 14th, 2015
198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var PlayerInfoItems = $("#PlayerInfoItems")
  2.  
  3. var exp_table = [200, 350] //Build the exp table.
  4. var increase = 330
  5. for(var i = 2; i < 40; i++) {
  6. exp_table[i] = exp_table[i - 1] + increase
  7. increase += 90
  8. }
  9.  
  10. for(var i = 0; i < 6; i++) { //6 item placeholders
  11. var PlayerInfoItem = $.CreatePanel("Panel", PlayerInfoItems, "PlayerInfoItem" + i)
  12. PlayerInfoItem.AddClass("even-space-vertical")
  13. PlayerInfoItem.AddClass("fill")
  14. PlayerInfoItem.AddClass("square")
  15. PlayerInfoItem.style.backgroundColor = "red"
  16. if(i != 0) {
  17. PlayerInfoItem.style.marginTop = "4px"
  18. }
  19. }
  20.  
  21. function OnSpiritgateTickStats(event) { //Update stats from a custom event.
  22. $("#PlayerInfoStatsPowerLabel").text = event.power
  23. $("#PlayerInfoStatsHasteLabel").text = event.haste
  24. $("#PlayerInfoStatsArmourLabel").text = event.armour
  25. $("#PlayerInfoStatsMagicResistanceLabel").text = event.magic_resistance
  26.  
  27. var local_pid = Players.GetLocalPlayer()
  28. var local_pid_hero = Players.GetPlayerHeroEntityIndex(local_pid)
  29. $("#PlayerInfoStatsAttackDamageLabel").text = Entities.GetDamageMax(local_pid_hero)
  30. $("#PlayerInfoStatsMovespeedLabel").text = Math.round(Entities.GetIdealSpeed(local_pid_hero))
  31.  
  32. $("#PlayerInfoExtendedVis").text = "Vis: " + Players.GetGold(local_pid)
  33.  
  34. var target_exp = exp_table[Entities.GetLevel(local_pid_hero)] - Entities.GetCurrentXP(local_pid_hero) + Entities.GetCurrentXP(local_pid_hero) - exp_table[Entities.GetLevel(local_pid_hero) - 1]
  35. $("#PlayerInfoExpBar").style.width = (Entities.GetCurrentXP(local_pid_hero) - exp_table[Entities.GetLevel(local_pid_hero) - 1]) / target_exp * 100 + "%"
  36. $("#PlayerInfoExpLabel").text = "Exp: " + (Entities.GetCurrentXP(local_pid_hero) - exp_table[Entities.GetLevel(local_pid_hero) - 1]) + "/" + target_exp
  37. }
  38.  
  39. function OnSpiritgateSelectRole(event) { //From the hero select, one of 4 roles
  40. $("#PlayerInfoRolePassive").SetImage("file://{images}/custom_game/roles/role_" + event.role + ".png")
  41. }
  42.  
  43. function OnSpiritgateSelectShaper(event) { //From the hero select, update hero
  44. var local_pid = Players.GetLocalPlayer()
  45. var local_pid_hero = Players.GetPlayerHeroEntityIndex(local_pid)
  46.  
  47. var passive_ability_id = Entities.GetAbility(local_pid_hero, 4)
  48. $.Msg(Abilities.GetAbilityTextureName(passive_ability_id))
  49. $("#PlayerInfoShaperPassive").SetImage("file://{images}/custom_game/spellicons/" + Abilities.GetAbilityTextureName(passive_ability_id) + ".png")
  50. $("#PlayerInfoAvatarImage").heroname = Entities.GetUnitName(local_pid_hero)
  51. }
  52.  
  53. function OnSpiritgateGameStart(event) { //Only show the main UI once the game has started.
  54. $.GetContextPanel().AddClass("is-visible")
  55. $.GetContextPanel().RemoveClass("is-not-visible")
  56. }
  57.  
  58. GameEvents.Subscribe("SpiritgateSelectRole", OnSpiritgateSelectRole)
  59. GameEvents.Subscribe("SpiritgateSelectShaper", OnSpiritgateSelectShaper)
  60. GameEvents.Subscribe("SpiritgateTickStats", OnSpiritgateTickStats)
  61. GameEvents.Subscribe("SpiritgateGameStart", OnSpiritgateGameStart)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×