def GetLearnableDomainSpells (pc, Level, baseClassName = -1): import GUICommon import GUICommonWindows Learnable =[] # only clerics have domains due to listdom.2da restrictions # no need to double check, as we only call this for IE_IWD2_SPELL_CLERIC if baseClassName == -1: baseClassName = GUICommon.GetClassRowName (pc) BaseClassIndex = CommonTables.Classes.GetRowIndex (baseClassName) # columns correspond to kits in the same order KitIndex = GUICommonWindows.GetKitIndex (pc, BaseClassIndex) if KitIndex == -1: print "GetLearnableDomainSpells: couldn't determine the kit, bailing out!" return Learnable # calculate the offset from the first cleric kit KitIndex -= CommonTables.Classes.FindValue ("CLASS", BaseClassIndex+1) DomainSpellTable = GemRB.LoadTable ("listdomn") # check everything in case someone wants to mod the spell amount for i in range(DomainSpellTable.GetRowCount ()): if DomainSpellTable.GetValue (i, KitIndex) == Level: SpellName = DomainSpellTable.GetRowName (i) SpellName = DomainSpellTable.GetValue (SpellName, "DOMAIN_RESREF") Learnable.append (SpellName) return Learnable
def OpenLUKitWindow (): global LUKitWindow # check if kit selection is needed at all # does the class have any kits at all? # if we're levelling up, we must also check we dont't already # have a kit with this class pc = GemRB.GameGetSelectedPCSingle () LUClass = GemRB.GetVar ("LUClass") # index, not ID LUClassName = CommonTables.Classes.GetRowName (LUClass) LUClassID = CommonTables.Classes.GetValue (LUClassName, "ID") hasKits = CommonTables.Classes.FindValue ("CLASS", LUClassID) kitIndex = GUICommonWindows.GetKitIndex (pc, LUClass) if hasKits == -1 or kitIndex > 0: LUNextPress () return LUKitWindow = Window = GemRB.LoadWindow (6) # title Label = Window.GetControl (0x10000000) Label.SetText (9894) # next Button = Window.GetControl (0) Button.SetText (36789) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, LUNextPress) Button.SetState (IE_GUI_BUTTON_DISABLED) Button.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR) # 1 does not exist, 2-10 are kit buttons # 11 scrollbar, 12 back Window.DeleteControl (12) # description TextArea = Window.GetControl (13) TextArea.SetText ("") # skip to the first kit of this class kitOffset = hasKits GemRB.SetVar ("LUKit", -1) for i in range(9): Button = Window.GetControl (i+2) kitClassName = CommonTables.Classes.GetRowName (kitOffset+i) kitClass = CommonTables.Classes.GetValue (kitClassName, "CLASS", GTV_INT) if kitClass != LUClassID: Button.SetState (IE_GUI_BUTTON_DISABLED) continue kitTitle = CommonTables.Classes.GetRowName (kitOffset+i) kitTitle = CommonTables.Classes.GetValue (kitTitle, "NAME_REF", GTV_REF) Button.SetText (kitTitle) Button.SetState (IE_GUI_BUTTON_ENABLED) Button.SetVarAssoc ("LUKit", i) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, LUKitPress) Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR) Window.ShowModal (MODAL_SHADOW_NONE)