Go to the documentation of this file.00001 '''
00002 TargetHud()
00003
00004 implements the overhead hud display for player's current target
00005
00006 Anoria (c) Gsk 2010
00007 '''
00008
00009 import BigWorld
00010 import GUI
00011 from Helpers import TargetCaps
00012
00013 import AnGUI
00014 from Listener import Listener
00015 from config import request
00016 from config.consts import PROFICIENCY_CODES
00017
00018 class TargetHud():
00019
00020 def __init__(self):
00021 self.gui = GUI.load("gui/target.gui")
00022 self.focusEntity = None
00023
00024 def updateTargetHealth(self, entity, instantly=False):
00025 try:
00026 healthPercent = entity.healthPercent / 100.0
00027 except:
00028 healthPercent = 1.0
00029
00030
00031
00032 healthBar = self.gui.health
00033 healthBar.clipper.value = healthPercent
00034 healthBar.colourer.value = healthPercent
00035 if instantly:
00036 healthBar.colourer.reset()
00037 healthBar.clipper.reset()
00038
00039
00040 def targetFocus(self, entity):
00041 self.focusEntity = entity
00042 healthBarVisible = TargetCaps.CAP_CAN_HIT in entity.targetCaps
00043 try:
00044 overheadText = entity.name
00045 except:
00046 try:
00047 overheadText = entity.__class__.__name__
00048 except:
00049 overheadText = ""
00050
00051 self.gui.healthBk.visible = healthBarVisible
00052 self.gui.health.visible = healthBarVisible
00053
00054 nameComponent = self.gui.name
00055 nameComponent.text = overheadText
00056 self.gui.source = entity.model.bounds
00057
00058 if hasattr(entity, "targettingColour"):
00059 nameComponent.colour = entity.targettingColour
00060 else:
00061 nameComponent.colour = (255, 255, 255, 255)
00062
00063 self.updateTargetHealth(entity, instantly=True)
00064