Skip to content

Instantly share code, notes, and snippets.

@pavelmaca
Last active August 29, 2015 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelmaca/efbc1a80b688480d53b6 to your computer and use it in GitHub Desktop.
Save pavelmaca/efbc1a80b688480d53b6 to your computer and use it in GitHub Desktop.
#Embedded file name: InfoPanel
"""
(c) Dellux 2013
Recompiled by Skino88
Fixed by: Assassik, webium
"""
import BigWorld, GUI, Keys
import weakref
import CommandMapping
import Vehicle
from Avatar import PlayerAvatar
from gui.Scaleform.Battle import Battle
from gui.Shared.Utils.Timeinterval import TimeInterval
from gui.Scaleform.Flash import Flash
from gui import DEPTH_OF_Aim
class InfoPanel(Flash):
UPDATE_INTERVAL = 0.03
def __init__(self, parentUI):
Flash.__init__(self, 'InfoPanel.swf')
self.__timeInterval = None
self.__isVisible = None
self.component.wg_inputKeyMode = 1
self.component.position.z = DEPTH_OF_Aim
self.movie.backgroundAlpha = 0.0
self.component.focus = False
self.component.moveFocus = False
self.component.heightMode = 'PIXEL'
self.component.widthMode = 'PIXEL'
self.flashSize = GUI.screenResolution()
self.addExternalCallback('InfoPanel.targetEnable', self.targetEnableCallBack)
def start(self):
global isIPVisible
self.active(True)
self.setup()
self.__timeInterval = TimeInterval(self.UPDATE_INTERVAL, self, 'update')
self.__timeInterval.start()
isIPVisible = True
self.update()
self.setVisible(True)
def destroy(self):
self.active(False)
self.setVisible(False)
self.__timeInterval.stop()
def setVisible(self, isVisible):
self.__isVisible = isVisible
self.component.visible = self.__isVisible
def setup(self):
pass
def update(self):
if self.__isVisible != isIPVisible:
self.setVisible(isIPVisible)
if BigWorld.target() or BigWorld.isKeyDown(Keys.KEY_LALT):
player = BigWorld.player()
target = BigWorld.target()
#target must be Vehicle, if not display info about own tank
if target is None or not isinstance(target, Vehicle.Vehicle):
target = player.getVehicleAttached()
showInfoPanel = self.showInfoPanel(player, target)
if showInfoPanel:
typeDescr = target.typeDescriptor
vTypeDescr = player.vehicleTypeDescriptor
vType = typeDescr.type.userString
hullArmor = [typeDescr.hull['primaryArmor'][0], typeDescr.hull['primaryArmor'][1], typeDescr.hull['primaryArmor'][2]]
turretArmor = [typeDescr.turret['primaryArmor'][0], typeDescr.turret['primaryArmor'][1], typeDescr.turret['primaryArmor'][2]]
gunName = typeDescr.gun['shortUserString']
gunReload = typeDescr.gun['reloadTime']
visionRadius = typeDescr.turret['circularVisionRadius']
iconName = typeDescr.name.replace(':', '-')
pWeight = round(vTypeDescr._VehicleDescr__computeWeight()[0] / 1000)
vWeight = round(typeDescr._VehicleDescr__computeWeight()[0] / 1000)
shellDamage = [0, 0, 0]
i = 0
for element in typeDescr.gun['shots']:
shellDamage[i] = element['shell']['damage'][0]
i = i + 1
shellPower = [0, 0, 0]
j = 0
for element in typeDescr.gun['shots']:
shellPower[j] = element['piercingPower'][0]
j = j + 1
shellType = ['', '', '']
k = 0
for element in typeDescr.gun['shots']:
if element['shell']['kind'] == 'ARMOR_PIERCING':
shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING', 'AP')
elif element['shell']['kind'] == 'HIGH_EXPLOSIVE':
shellType[k] = element['shell']['kind'].replace('HIGH_EXPLOSIVE', 'HE')
elif element['shell']['kind'] == 'ARMOR_PIERCING_CR':
shellType[k] = element['shell']['kind'].replace('ARMOR_PIERCING_CR', 'CR')
else:
shellType[k] = element['shell']['kind'].replace('HOLLOW_CHARGE', 'HC')
k = k + 1
self.flashCall('InfoPanelValue', [vType,
gunName,
gunReload,
visionRadius,
iconName,
hullArmor[0],
hullArmor[1],
hullArmor[2],
turretArmor[0],
turretArmor[1],
turretArmor[2],
shellDamage[0],
shellDamage[1],
shellDamage[2],
shellPower[0],
shellPower[1],
shellPower[2],
shellType[0],
shellType[1],
shellType[2],
pWeight,
vWeight])
if BigWorld.player() is not None:
if BigWorld.player().inputHandler.aim is not None:
aimMode = BigWorld.player().inputHandler.aim.mode
self.flashCall('AimMode', [aimMode])
else:
aimMode = None
def flashCall(self, funcName, args = None):
self.call('InfoPanel.' + funcName, args)
def targetEnableCallBack(self, cid, team, enemy, dead):
self.isTeam = team
self.isEnemy = enemy
self.isDead = dead
def showInfoPanel(self, player, target):
if target is None:
return False
elif player.team == target.publicInfo['team'] and self.isTeam == 'true' and target.health > 0:
return True
elif player.team is not target.publicInfo['team'] and self.isEnemy == 'true' and target.health > 0:
return True
elif target.health <= 0 and self.isDead == 'true':
return True
else:
return False
saved_afterCreate = Battle.afterCreate
def new_afterCreate(self):
saved_afterCreate(self)
self.__InfoPanel = InfoPanel(weakref.proxy(self))
self.__InfoPanel.start()
Battle.afterCreate = new_afterCreate
saved_beforeDelete = Battle.beforeDelete
def new_beforeDelete(self):
saved_beforeDelete(self)
self.__InfoPanel.destroy()
Battle.beforeDelete = new_beforeDelete
saved_handleKey = PlayerAvatar.handleKey
def new_handleKey(self, isDown, key, mods):
global isIPVisible
cmdMap = CommandMapping.g_instance
if cmdMap.isFired(CommandMapping.CMD_TOGGLE_GUI, key) and isDown:
isIPVisible = not isIPVisible
return saved_handleKey(self, isDown, key, mods)
PlayerAvatar.handleKey = new_handleKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment