Beispiel #1
0
class GUI(object):
    def __init__(self):
        self.char = Character(self)
        self.main = MainWindow(control=self)
        self.initConnections()
        self.updateDisplayAll()
        
    def updateDisplayAll(self):
        self.updateCharAbilities()
        
    def updateCharAbilities(self):
        self.main.curStatsWidget.displayStrBonuses()
        self.main.curStatsWidget.displayIntBonuses()
        self.main.curStatsWidget.displayDexBonuses()
        self.main.curStatsWidget.displayConBonuses()
        self.main.curStatsWidget.displayWisBonuses()
        self.main.curStatsWidget.displayChaBonuses()
        self.main.curStatsWidget.displayHP()
                    
    def show(self):
        self.main.show()
    
    @property    
    def charName(self):
        return self.main.baseStatsWidget.name

    @charName.setter    
    def charName(self, val):
        self.main.baseStatsWidget.name = val

    @property    
    def race(self):
        return self.main.baseStatsWidget.race

    @race.setter
    def race(self, val):
        self.main.baseStatsWidget.race = val
        #self.main.curStatsWidget.updateDisplayAll()

    @property    
    def alignment(self):
        return self.main.baseStatsWidget.alignment

    @alignment.setter
    def alignment(self, val):
        self.main.baseStatsWidget.alignment = val

    @property    
    def cls(self):
        return self.main.baseStatsWidget.classVal
    
    @cls.setter
    def cls(self, val):
        self.main.baseStatsWidget.classVal = val
        #self.main.curStatsWidget.updateDisplayAll()
        
    @property
    def curLvl(self):
        return self.main.baseStatsWidget.curLvl
    
    @curLvl.setter
    def curLvl(self, val):
        self.main.baseStatsWidget.curLvl = val
        #self.main.curStatsWidget.updateDisplayAll()
        
    @property
    def lvlUpStats(self):
        return self.main.leveling.lvlUpStats()

    @lvlUpStats.setter
    def lvlUpStats(self, val):
        self.main.leveling.setLvlUpStats(val)
        #self.main.curStatsWidget.updateDisplayAll()
        
    def initConnections(self):
        # Base Vals
        self.main.baseStatsWidget.strBase.valueChanged.connect(self.baseStrUpdate)
        self.main.baseStatsWidget.intBase.valueChanged.connect(self.baseIntUpdate)
        self.main.baseStatsWidget.dexBase.valueChanged.connect(self.baseDexUpdate)
        self.main.baseStatsWidget.conBase.valueChanged.connect(self.baseConUpdate)
        self.main.baseStatsWidget.wisBase.valueChanged.connect(self.baseWisUpdate)
        self.main.baseStatsWidget.chaBase.valueChanged.connect(self.baseChaUpdate)
        self.main.baseStatsWidget.nameWidget.editingFinished.connect(self.nameUpdate)
        self.main.baseStatsWidget.raceWidget.currentIndexChanged.connect(self.raceUpdate)
        self.main.baseStatsWidget.classWidget.currentIndexChanged.connect(self.classUpdate)
        self.main.baseStatsWidget.alignWidget.currentIndexChanged.connect(self.alignUpdate)
        self.main.baseStatsWidget.levelWidget.currentIndexChanged.connect(self.levelUpdate)
        
        #Level stats
        self.main.leveling.signal.levelUpChange.connect(self.levelStatsUpdate)
        
        #CurStats
        self.main.curStatsWidget.hpInj.valueChanged.connect(self.injuryUpdate)
        
    def baseStrUpdate(self, val):
        self.char.updateBaseStr(val)
        self.main.curStatsWidget.updateDisplayAll()

    def baseIntUpdate(self, val):
        self.char.updateBaseInt(val)
        self.main.curStatsWidget.updateDisplayAll()

    def baseDexUpdate(self, val):
        self.char.updateBaseDex(val)
        self.main.curStatsWidget.updateDisplayAll()

    def baseConUpdate(self, val):
        self.char.updateBaseCon(val)
        self.main.curStatsWidget.updateDisplayAll()

    def baseWisUpdate(self, val):
        self.char.updateBaseWis(val)
        self.main.curStatsWidget.updateDisplayAll()

    def baseChaUpdate(self, val):
        self.char.updateBaseCha(val)
        self.main.curStatsWidget.updateDisplayAll()

    def nameUpdate(self, val):
        self.char.updateName(val)
        self.main.curStatsWidget.updateDisplayAll()

    def raceUpdate(self, val):
        self.char.updateRace(val)
        self.main.curStatsWidget.updateDisplayAll()

    def classUpdate(self, val):
        self.char.updateClass(val)
        self.main.curStatsWidget.updateDisplayAll()

    def alignUpdate(self, val):
        self.char.updateAlign(val)
        self.main.curStatsWidget.updateDisplayAll()

    def levelUpdate(self, val):
        self.char.updateLevel(val)
        self.main.curStatsWidget.updateDisplayAll()
        
    def levelStatsUpdate(self, val):
        self.char.updateLvlUpStats(val)
        self.main.curStatsWidget.updateDisplayAll()

    def injuryUpdate(self, val):
        self.char.updateInjury(val)
        self.main.curStatsWidget.displayHP()
    
    def setBaseStr(self, val):
        self.main.baseStatsWidget.strBase.setValue(val)

    def setBaseInt(self, val):
        self.main.baseStatsWidget.intBase.setValue(val)

    def setBaseDex(self, val):
        self.main.baseStatsWidget.dexBase.setValue(val)

    def setBaseCon(self, val):
        self.main.baseStatsWidget.conBase.setValue(val)

    def setBaseWis(self, val):
        self.main.baseStatsWidget.wisBase.setValue(val)

    def setBaseCha(self, val):
        self.main.baseStatsWidget.chaBase.setValue(val)
    
    def setInjury(self, val):
        self.main.curStatsWidget.hpInj.setValue(val)