Пример #1
0
 def _slotInfoUpdated(self):
     self.availableGrenades = []
     if (self.pipInventoryInfo):
         def _filterFunc(item):
             return inventoryutils.itemHasAnyFilterCategory(item, inventoryutils.eItemFilterCategory.Weapon)
         weapons = inventoryutils.inventoryGetItems(self.pipInventoryInfo, _filterFunc)
         if(not weapons):
             return
         for weapon in weapons:        
             equipped = False
             if inventoryutils.itemIsWeaponThrowable(weapon):        
                 count = str(weapon.child('count').value())
                 name = str(weapon.child('text').value())
                 if (weapon.child('equipState').value() == 3):
                     equipped = True
                     self.lastEquippedGrenade = name.lower()
                 
                 self.availableGrenades.append([name.lower(), equipped])
                 
     self.availableRadioStations = []
     if(self.pipRadioInfo):
         for i in range(0, self.pipRadioInfo.childCount()):
             station = self.pipRadioInfo.child(i)
             if station.child('inRange').value():
                 self.availableRadioStations.append(station)
             if station.child('active').value():
                 self.currentRadioStation = station
    def updateWeaponViews(self):
        self.grenademodel.clear()
        selectedgrenade = -1
        grenadecounter = 0

        self.widget.label_EquipedWeapon.setText('')
        self.widget.lblRofAccRng.setText('')
        self.widget.lblPdmgIcon.setVisible(False)
        self.widget.lblPdmg.setVisible(False)
        self.widget.lblEdmgIcon.setVisible(False)
        self.widget.lblEdmg.setVisible(False)
        self.widget.lblRdmgIcon.setVisible(False)
        self.widget.lblRdmg.setVisible(False)
        self.widget.lblPodmgIcon.setVisible(False)
        self.widget.lblPodmg.setVisible(False)

        def _filterFunc(item):
            return inventoryutils.itemHasAnyFilterCategory(
                item, inventoryutils.eItemFilterCategory.Weapon)

        weapons = inventoryutils.inventoryGetItems(self.pipInventoryInfo,
                                                   _filterFunc)
        if (not weapons):
            return
        for weapon in weapons:
            name = weapon.child('text').value()
            if inventoryutils.itemIsWeaponThrowable(weapon):
                grenadecounter += 1

                count = str(weapon.child('count').value())
                if (weapon.child('equipState').value() == 3):
                    equipState = "+"
                else:
                    equipState = ""

                if (equipState == "+"):
                    selectedgrenade = grenadecounter

                item = [
                    QStandardItem(equipState),
                    QStandardItem(name),
                    QStandardItem(count)
                ]

                item[2].setData(QtCore.Qt.AlignCenter,
                                QtCore.Qt.TextAlignmentRole)

                self.grenademodel.appendRow(item)

            else:
                if (weapon.child('equipState').value() > 0):
                    strEquipedWeapon = weapon.child('text').value()
                    strAmmo = ''
                    valueAmmo = inventoryutils.itemFindItemCardInfoValue(
                        weapon, 10, 'damageType')
                    if valueAmmo != None:
                        strAmmo += ' (' + str(valueAmmo) + ')'

                    self.widget.label_EquipedWeapon.setText(strEquipedWeapon +
                                                            strAmmo)

                    damageInfos = inventoryutils.itemFindItemCardInfos(
                        weapon, inventoryutils.eItemCardInfoValueText.Damage)
                    for info in damageInfos:
                        damageType = info.child('damageType').value()
                        value = info.child('Value').value()
                        if itemCardInfoDamageTypes[
                                damageType] == 'Phy' and value != 0.0:
                            self.widget.lblPdmg.setText(str(int(value)))
                            self.widget.lblPdmg.setVisible(True)
                            self.widget.lblPdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[
                                damageType] == 'En' and value != 0.0:
                            self.widget.lblEdmg.setText(str(int(value)))
                            self.widget.lblEdmg.setVisible(True)
                            self.widget.lblEdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[
                                damageType] == 'Rad' and value != 0.0:
                            self.widget.lblRdmg.setText(str(int(value)))
                            self.widget.lblRdmg.setVisible(True)
                            self.widget.lblRdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[
                                damageType] == 'Po' and value != 0.0:
                            self.widget.lblPodmg.setText(str(int(value)))
                            self.widget.lblPodmg.setVisible(True)
                            self.widget.lblPodmgIcon.setVisible(True)
                            pass

                    RofAccRngStr = ''

                    rof = inventoryutils.itemFindItemCardInfoValue(
                        weapon,
                        inventoryutils.eItemCardInfoValueText.RateOfFire)
                    if rof == None:
                        speed = inventoryutils.itemFindItemCardInfoValue(
                            weapon,
                            inventoryutils.eItemCardInfoValueText.Speed)
                        if speed:
                            RofAccRngStr = 'Speed: ' + speed[1:].lower()
                    else:
                        RofAccRngStr = 'RoF: ' + str(round(rof, 2))

                    acc = inventoryutils.itemFindItemCardInfoValue(
                        weapon, inventoryutils.eItemCardInfoValueText.Accuracy)
                    if acc != None:
                        RofAccRngStr += '  Acc: ' + str(round(acc, 2))

                    rng = inventoryutils.itemFindItemCardInfoValue(
                        weapon, inventoryutils.eItemCardInfoValueText.Range)
                    if rng != None:
                        RofAccRngStr += '  Rng: ' + str(round(rng, 2))

                    self.widget.lblRofAccRng.setText(RofAccRngStr)

        self.widget.grenadeView.horizontalHeader().setSectionResizeMode(
            QHeaderView.ResizeToContents)
        self.widget.grenadeView.verticalHeader().setSectionResizeMode(
            QHeaderView.Fixed)
        self.widget.grenadeView.verticalHeader().setStretchLastSection(False)
        self.widget.grenadeView.horizontalHeader().setStretchLastSection(True)
        self.widget.grenadeView.setModel(self.grenademodel)

        if (selectedgrenade >= 1):
            self.widget.grenadeView.selectRow(selectedgrenade - 1)
        self.widget.grenadeView.hideColumn(0)
        self.widget.grenadeView.sortByColumn(1, QtCore.Qt.AscendingOrder)
    def updateWeaponViews(self):
        self.grenademodel.clear()
        selectedgrenade = -1
        grenadecounter = 0
        
        self.widget.label_EquipedWeapon.setText('')
        self.widget.lblRofAccRng.setText('')
        self.widget.lblPdmgIcon.setVisible(False)
        self.widget.lblPdmg.setVisible(False)
        self.widget.lblEdmgIcon.setVisible(False)
        self.widget.lblEdmg.setVisible(False)
        self.widget.lblRdmgIcon.setVisible(False)
        self.widget.lblRdmg.setVisible(False)
        self.widget.lblPodmgIcon.setVisible(False)
        self.widget.lblPodmg.setVisible(False)
        def _filterFunc(item):
            return inventoryutils.itemHasAnyFilterCategory(item, inventoryutils.eItemFilterCategory.Weapon)
        weapons = inventoryutils.inventoryGetItems(self.pipInventoryInfo, _filterFunc)
        if(not weapons):
            return
        for weapon in weapons:
            name = weapon.child('text').value()
            if inventoryutils.itemIsWeaponThrowable(weapon):
                grenadecounter += 1
                
                count = str(weapon.child('count').value())
                if (weapon.child('equipState').value() == 3):
                    equipState = "+"
                else:
                    equipState = ""

                if (equipState == "+"):
                    selectedgrenade = grenadecounter
                
                item = [
                    QStandardItem(equipState) , 
                    QStandardItem(name) , 
                    QStandardItem(count)
                ]
                
                item[2].setData(QtCore.Qt.AlignCenter, QtCore.Qt.TextAlignmentRole)
                
                self.grenademodel.appendRow(item)
     
            else:
                if ( weapon.child('equipState').value() > 0):
                    strEquipedWeapon = weapon.child('text').value()
                    strAmmo = ''
                    valueAmmo = inventoryutils.itemFindItemCardInfoValue(weapon, 10, 'damageType')
                    if valueAmmo != None:
                        strAmmo += ' (' + str(valueAmmo) + ')'

                    self.widget.label_EquipedWeapon.setText(strEquipedWeapon +  strAmmo)
                    
                    damageInfos = inventoryutils.itemFindItemCardInfos(weapon, inventoryutils.eItemCardInfoValueText.Damage)                 
                    for info in damageInfos:
                        damageType = info.child('damageType').value()
                        value = info.child('Value').value()
                        if itemCardInfoDamageTypes[damageType] == 'Phy' and value != 0.0:
                            self.widget.lblPdmg.setText( str(int(value)))
                            self.widget.lblPdmg.setVisible(True)
                            self.widget.lblPdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[damageType] == 'En' and value != 0.0:
                            self.widget.lblEdmg.setText (str(int(value)))
                            self.widget.lblEdmg.setVisible(True)
                            self.widget.lblEdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[damageType] == 'Rad' and value != 0.0:
                            self.widget.lblRdmg.setText (str(int(value)))
                            self.widget.lblRdmg.setVisible(True)
                            self.widget.lblRdmgIcon.setVisible(True)
                        elif itemCardInfoDamageTypes[damageType] == 'Po' and value != 0.0:
                            self.widget.lblPodmg.setText (str(int(value)))
                            self.widget.lblPodmg.setVisible(True)
                            self.widget.lblPodmgIcon.setVisible(True)
                            pass

                    RofAccRngStr = ''
                            
                    rof = inventoryutils.itemFindItemCardInfoValue(weapon, inventoryutils.eItemCardInfoValueText.RateOfFire)
                    if rof == None:
                        speed = inventoryutils.itemFindItemCardInfoValue(weapon, inventoryutils.eItemCardInfoValueText.Speed)
                        if speed:
                            RofAccRngStr = 'Speed: ' + speed[1:].lower()
                    else:
                        RofAccRngStr = 'RoF: ' + str(round(rof, 2))

                    acc = inventoryutils.itemFindItemCardInfoValue(weapon, inventoryutils.eItemCardInfoValueText.Accuracy)
                    if acc != None:
                        RofAccRngStr += '  Acc: ' + str(round(acc, 2))

                    rng = inventoryutils.itemFindItemCardInfoValue(weapon, inventoryutils.eItemCardInfoValueText.Range)
                    if rng != None:
                        RofAccRngStr += '  Rng: ' + str(round(rng, 2))
                        
                        
                    self.widget.lblRofAccRng.setText(RofAccRngStr)
                            
                
        self.widget.grenadeView.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.widget.grenadeView.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
        self.widget.grenadeView.verticalHeader().setStretchLastSection(False)
        self.widget.grenadeView.horizontalHeader().setStretchLastSection(True)
        self.widget.grenadeView.setModel(self.grenademodel)

        
        if (selectedgrenade >=1):
            self.widget.grenadeView.selectRow(selectedgrenade-1)
        self.widget.grenadeView.hideColumn(0)
        self.widget.grenadeView.sortByColumn(1, QtCore.Qt.AscendingOrder)
            
Пример #4
0
 def _data(self, item, column, role=QtCore.Qt.DisplayRole):
     pc = super().columnCount()
     if role == QtCore.Qt.DisplayRole:
         if column == pc:
             if item.child("equipState").value() > 0:
                 return "◼"
             else:
                 return ""
         elif column == pc + 1:
             if item.child("isLegendary").value() > 0:
                 return "◼"
             else:
                 return ""
         elif column == pc + 2:
             cached = item.getUserCache("damagetext")
             if not cached or cached.dirtyFlag:
                 text = ""
                 isFirst = True
                 damageInfos = inventoryutils.itemFindItemCardInfos(
                     item, inventoryutils.eItemCardInfoValueText.Damage
                 )
                 for info in damageInfos:
                     damageType = info.child("damageType").value()
                     value = info.child("Value").value()
                     if damageType < 10 and value != 0.0:
                         if isFirst:
                             isFirst = False
                         else:
                             text += " + "
                         text += str(int(value))
                         text += " " + itemCardInfoDamageTypes[damageType]
                 item.setUserCache("damagetext", text, 10)
             else:
                 text = cached.value
             return text
         elif column == pc + 3:
             rof = inventoryutils.itemFindItemCardInfoValue(item, inventoryutils.eItemCardInfoValueText.RateOfFire)
             if rof == None:
                 speed = inventoryutils.itemFindItemCardInfoValue(item, inventoryutils.eItemCardInfoValueText.Speed)
                 if speed:
                     return "Speed: " + speed[1:].lower()
                 else:
                     return None
             else:
                 return round(rof, 2)
         elif column == pc + 4:
             rng = inventoryutils.itemFindItemCardInfoValue(item, inventoryutils.eItemCardInfoValueText.Range)
             if rng == None:
                 return None
             else:
                 return round(rng, 2)
         elif column == pc + 5:
             val = inventoryutils.itemFindItemCardInfoValue(item, inventoryutils.eItemCardInfoValueText.Accuracy)
             if val == None:
                 return None
             else:
                 return round(val, 2)
         elif column == pc + 6:
             return inventoryutils.itemFindItemCardInfoValue(item, True, "showAsDescription", "text")
         elif column == pc + 7:
             if inventoryutils.itemIsWeaponGun(item):
                 return "Gun"
             elif inventoryutils.itemIsWeaponMelee(item):
                 return "Melee"
             elif inventoryutils.itemIsWeaponThrowable(item):
                 return "Grenade"
             else:
                 return "Unknown"
         elif column == pc + 8:
             value = inventoryutils.itemFindItemCardInfoValue(item, 10, "damageType")
             text = None
             if value != None:
                 text = inventoryutils.itemFindItemCardInfoValue(item, 10, "damageType", "text")
                 text += " (" + str(value) + ")"
             return text
     elif role == QtCore.Qt.TextAlignmentRole:
         if column == pc:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignCenter
         elif column == pc + 1:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignCenter
         elif column == pc + 2:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 3:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 4:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 5:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 6:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
         elif column == pc + 7:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
         elif column == pc + 8:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
     return super()._data(item, column, role)
Пример #5
0
 def _data(self, item, column, role=QtCore.Qt.DisplayRole):
     pc = super().columnCount()
     if role == QtCore.Qt.DisplayRole:
         if column == pc:
             if item.child('equipState').value() > 0:
                 return '◼'
             else:
                 return ''
         elif column == pc + 1:
             if item.child('isLegendary').value() > 0:
                 return '◼'
             else:
                 return ''
         elif column == pc + 2:
             cached = item.getUserCache('damagetext')
             if not cached or cached.dirtyFlag:
                 text = ''
                 isFirst = True
                 damageInfos = inventoryutils.itemFindItemCardInfos(
                     item, inventoryutils.eItemCardInfoValueText.Damage)
                 for info in damageInfos:
                     damageType = info.child('damageType').value()
                     value = info.child('Value').value()
                     if damageType < 10 and value != 0.0:
                         if isFirst:
                             isFirst = False
                         else:
                             text += ' + '
                         text += str(int(value))
                         text += ' ' + itemCardInfoDamageTypes[damageType]
                 item.setUserCache('damagetext', text, 10)
             else:
                 text = cached.value
             return text
         elif column == pc + 3:
             rof = inventoryutils.itemFindItemCardInfoValue(
                 item, inventoryutils.eItemCardInfoValueText.RateOfFire)
             if rof == None:
                 speed = inventoryutils.itemFindItemCardInfoValue(
                     item, inventoryutils.eItemCardInfoValueText.Speed)
                 if speed:
                     return 'Speed: ' + speed[1:].lower()
                 else:
                     return None
             else:
                 return round(rof, 2)
         elif column == pc + 4:
             rng = inventoryutils.itemFindItemCardInfoValue(
                 item, inventoryutils.eItemCardInfoValueText.Range)
             if rng == None:
                 return None
             else:
                 return round(rng, 2)
         elif column == pc + 5:
             val = inventoryutils.itemFindItemCardInfoValue(
                 item, inventoryutils.eItemCardInfoValueText.Accuracy)
             if val == None:
                 return None
             else:
                 return round(val, 2)
         elif column == pc + 6:
             return inventoryutils.itemFindItemCardInfoValue(
                 item, True, 'showAsDescription', 'text')
         elif column == pc + 7:
             if inventoryutils.itemIsWeaponGun(item):
                 return 'Gun'
             elif inventoryutils.itemIsWeaponMelee(item):
                 return 'Melee'
             elif inventoryutils.itemIsWeaponThrowable(item):
                 return 'Grenade'
             else:
                 return 'Unknown'
         elif column == pc + 8:
             value = inventoryutils.itemFindItemCardInfoValue(
                 item, 10, 'damageType')
             text = None
             if value != None:
                 text = inventoryutils.itemFindItemCardInfoValue(
                     item, 10, 'damageType', 'text')
                 text += ' (' + str(value) + ')'
             return text
     elif role == QtCore.Qt.TextAlignmentRole:
         if column == pc:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignCenter
         elif column == pc + 1:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignCenter
         elif column == pc + 2:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 3:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 4:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 5:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight
         elif column == pc + 6:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
         elif column == pc + 7:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
         elif column == pc + 8:
             return QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft
     return super()._data(item, column, role)