From: <ave...@pr...> - 2004-01-25 13:04:50
|
Update of /cvsroot/gemrb/gemrb/gemrb/GUIScripts/iwd2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21280/GUIScripts/iwd2 Added Files: Abilities.py CharGen6.py Log Message: Add: Abilities.py for iwd2 --- NEW FILE: Abilities.py --- #character generation, ability (GUICG4) import GemRB AbilityWindow = 0 TextAreaControl = 0 DoneButton = 0 AbilityTable = 0 PointsLeft = 16 Minimum = 0 Maximum = 0 Add = 0 KitIndex = 0 HasStrExtra = 0 def CalcLimits(Abidx): global Minimum, Maximum, Add RaceTable = GemRB.LoadTable("races") Abracead = GemRB.LoadTable("ABRACEAD") Abclsmod = GemRB.LoadTable("ABCLSMOD") Race = GemRB.GetVar("Race")-1 RaceName = GemRB.GetTableRowName(RaceTable, Race) Minimum = 3 Maximum = 18 Abclasrq = GemRB.LoadTable("ABCLASRQ") tmp = GemRB.GetTableValue(Abclasrq, KitIndex, Abidx) if tmp!=0 and tmp>Minimum: Minimum = tmp Abracerq = GemRB.LoadTable("ABRACERQ") Race = GemRB.GetTableRowIndex(Abracerq, RaceName) tmp = GemRB.GetTableValue(Abracerq, Race, Abidx*2) if tmp!=0 and tmp>Minimum: Minimum = tmp tmp = GemRB.GetTableValue(Abracerq, Race, Abidx*2+1) if tmp!=0 and tmp>Maximum: Maximum = tmp Race = GemRB.GetTableRowIndex(Abracead, RaceName) Add = GemRB.GetTableValue(Abracead, Race, Abidx) + GemRB.GetTableValue(Abclsmod, KitIndex, Abidx) Maximum = Maximum + Add Minimum = Minimum + Add if Minimum<1: Minimum=1 if Maximum>25: Maximum=25 return def RollPress(): global Minimum, Maximum, Add, HasStrExtra GemRB.InvalidateWindow(AbilityWindow) GemRB.SetVar("Ability",0) GemRB.SetVar("Ability -1",0) SumLabel = GemRB.GetControl(AbilityWindow, 0x10000002) PointsLeft=16 GemRB.SetText(AbilityWindow, SumLabel, str(PointsLeft)) GemRB.SetLabelUseRGB(AbilityWindow, SumLabel, 1) if HasStrExtra: e = GemRB.Roll(1,100,0) else: e = 0 GemRB.SetVar("StrExtra", e) for i in range(0,6): v = 10+Add GemRB.SetVar("Ability "+str(i), v ) Label = GemRB.GetControl(AbilityWindow, 0x10000003+i) if i==0 and v==18 and HasStrExtra: GemRB.SetText(AbilityWindow, Label, "18/"+str(e) ) else: GemRB.SetText(AbilityWindow, Label, str(v) ) GemRB.SetLabelUseRGB(AbilityWindow, Label, 1) return def OnLoad(): global AbilityWindow, TextAreaControl, DoneButton global PointsLeft, HasStrExtra global AbilityTable global KitIndex, Minimum, Maximum Kit = GemRB.GetVar("Class Kit") ClassTable = GemRB.LoadTable("classes") Class = GemRB.GetVar("Class")-1 if Kit == 0: KitName = GemRB.GetTableRowName(ClassTable, Class) else: KitList = GemRB.LoadTable("kitlist") #rowname is just a number, first value row what we need here KitName = GemRB.GetTableValue(KitList, Kit, 0) if GemRB.GetTableValue(ClassTable, Class, 3)=="SAVEWAR": HasStrExtra=1 else: HasStrExtra=0 Abclasrq = GemRB.LoadTable("ABCLASRQ") KitIndex = GemRB.GetTableRowIndex(Abclasrq, KitName) GemRB.LoadWindowPack("GUICG") AbilityTable = GemRB.LoadTable("ability") AbilityWindow = GemRB.LoadWindow(4) RollPress() for i in range(0,6): Button = GemRB.GetControl(AbilityWindow, i+30) GemRB.SetEvent(AbilityWindow, Button, IE_GUI_BUTTON_ON_PRESS, "JustPress") GemRB.SetVarAssoc(AbilityWindow, Button, "Ability", i) Button = GemRB.GetControl(AbilityWindow, i*2+16) GemRB.SetEvent(AbilityWindow, Button, IE_GUI_BUTTON_ON_PRESS, "LeftPress") GemRB.SetVarAssoc(AbilityWindow, Button, "Ability", i ) Button = GemRB.GetControl(AbilityWindow, i*2+17) GemRB.SetEvent(AbilityWindow, Button, IE_GUI_BUTTON_ON_PRESS, "RightPress") GemRB.SetVarAssoc(AbilityWindow, Button, "Ability", i ) BackButton = GemRB.GetControl(AbilityWindow,36) GemRB.SetText(AbilityWindow,BackButton,15416) DoneButton = GemRB.GetControl(AbilityWindow,0) GemRB.SetText(AbilityWindow,DoneButton,11973) GemRB.SetButtonFlags(AbilityWindow, DoneButton, IE_GUI_BUTTON_DEFAULT,OP_OR) TextAreaControl = GemRB.GetControl(AbilityWindow, 29) GemRB.SetText(AbilityWindow,TextAreaControl,17247) GemRB.SetEvent(AbilityWindow,DoneButton,IE_GUI_BUTTON_ON_PRESS,"NextPress") GemRB.SetEvent(AbilityWindow,BackButton,IE_GUI_BUTTON_ON_PRESS,"BackPress") GemRB.SetVisible(AbilityWindow,1) return def RightPress(): global PointsLeft GemRB.InvalidateWindow(AbilityWindow) Abidx = GemRB.GetVar("Ability") Ability = GemRB.GetVar("Ability "+str(Abidx) ) #should be more elaborate CalcLimits(Abidx) GemRB.SetToken("MINIMUM",str(Minimum) ) GemRB.SetToken("MAXIMUM",str(Maximum) ) GemRB.SetText(AbilityWindow, TextAreaControl, GemRB.GetTableValue(AbilityTable, Abidx, 1) ) if Ability<=Minimum: return GemRB.SetVar("Ability "+str(Abidx), Ability-1) PointsLeft = PointsLeft + 1 GemRB.SetVar("Ability -1",PointsLeft) SumLabel = GemRB.GetControl(AbilityWindow, 0x10000002) GemRB.SetText(AbilityWindow, SumLabel, str(PointsLeft) ) Label = GemRB.GetControl(AbilityWindow, 0x10000003+Abidx) StrExtra = GemRB.GetVar("StrExtra") if Abidx==0 and Ability==19 and StrExtra: GemRB.SetText(AbilityWindow, Label, "18/"+str(StrExtra) ) else: GemRB.SetText(AbilityWindow, Label, str(Ability-1) ) GemRB.SetButtonState(AbilityWindow, DoneButton,IE_GUI_BUTTON_DISABLED) return def JustPress(): Abidx = GemRB.GetVar("Ability") Ability = GemRB.GetVar("Ability "+str(Abidx) ) #should be more elaborate CalcLimits(Abidx) GemRB.SetToken("MINIMUM",str(Minimum) ) GemRB.SetToken("MAXIMUM",str(Maximum) ) GemRB.SetText(AbilityWindow, TextAreaControl, GemRB.GetTableValue(AbilityTable, Abidx, 1) ) return def LeftPress(): global PointsLeft, HasStrExtra GemRB.InvalidateWindow(AbilityWindow) PointsLeft=GemRB.GetVar("Ability -1") #should be more elaborate Minimum=3 Maximum=18 GemRB.SetToken("MINIMUM",str(Minimum) ) GemRB.SetToken("MAXIMUM",str(Maximum) ) Abidx = GemRB.GetVar("Ability") Ability = GemRB.GetVar("Ability "+str(Abidx) ) GemRB.SetText(AbilityWindow, TextAreaControl, GemRB.GetTableValue(AbilityTable, Abidx, 1) ) if PointsLeft == 0: return if Ability>=Maximum: #should be more elaborate return GemRB.SetVar("Ability "+str(Abidx), Ability+1) PointsLeft = PointsLeft - 1 GemRB.SetVar("Ability -1",PointsLeft) SumLabel = GemRB.GetControl(AbilityWindow, 0x10000002) GemRB.SetText(AbilityWindow, SumLabel, str(PointsLeft) ) Label = GemRB.GetControl(AbilityWindow, 0x10000003+Abidx) StrExtra = GemRB.GetVar("StrExtra") if Abidx==0 and Ability==17 and HasStrExtra==1: GemRB.SetText(AbilityWindow, Label, "18/"+str(StrExtra) ) else: GemRB.SetText(AbilityWindow, Label, str(Ability+1) ) if PointsLeft == 0: GemRB.SetButtonState(AbilityWindow, DoneButton,IE_GUI_BUTTON_ENABLED) return def BackPress(): GemRB.UnloadWindow(AbilityWindow) GemRB.SetNextScript("CharGen5") GemRB.SetVar("StrExtra",0) for i in range(-1,6): GemRB.SetVar("Ability "+str(i),0) #scrapping the abilities return def NextPress(): GemRB.UnloadWindow(AbilityWindow) GemRB.SetNextScript("CharGen6") # return --- NEW FILE: CharGen6.py --- #character generation (GUICG 0) import GemRB CharGenWindow = 0 StartOverWindow = 0 TextAreaControl = 0 def OnLoad(): global CharGenWindow, StartOverWindow, TextAreaControl GemRB.SetVar("Feats",0) #feats GemRB.LoadWindowPack("GUICG") StartOverWindow = GemRB.LoadWindow(53) YesButton = GemRB.GetControl(StartOverWindow,0) GemRB.SetText(StartOverWindow, YesButton, 13912) GemRB.SetEvent(StartOverWindow, YesButton, IE_GUI_BUTTON_ON_PRESS,"CancelPress") NoButton = GemRB.GetControl(StartOverWindow,1) GemRB.SetText(StartOverWindow, NoButton, 13913) GemRB.SetEvent(StartOverWindow, NoButton, IE_GUI_BUTTON_ON_PRESS,"NoExitPress") TextAreaControl = GemRB.GetControl(StartOverWindow, 2) GemRB.SetText(StartOverWindow, TextAreaControl, 40275) CharGenWindow = GemRB.LoadWindow(0) PortraitButton = GemRB.GetControl(CharGenWindow, 12) GemRB.SetButtonFlags(CharGenWindow, PortraitButton, IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE,OP_SET) PortraitTable = GemRB.LoadTable("pictures") PortraitName = GemRB.GetTableRowName(PortraitTable,GemRB.GetVar("PortraitIndex") ) GemRB.SetButtonPicture(CharGenWindow,PortraitButton, PortraitName+"L") RaceTable = GemRB.LoadTable("races") ClassTable = GemRB.LoadTable("classes") AlignmentTable = GemRB.LoadTable("aligns") GenderButton = GemRB.GetControl(CharGenWindow,0) GemRB.SetText(CharGenWindow,GenderButton,11956) GemRB.SetButtonState(CharGenWindow,GenderButton,IE_GUI_BUTTON_DISABLED) RaceButton = GemRB.GetControl(CharGenWindow,1) GemRB.SetText(CharGenWindow,RaceButton, 11957) GemRB.SetButtonState(CharGenWindow,RaceButton,IE_GUI_BUTTON_DISABLED) ClassButton = GemRB.GetControl(CharGenWindow,2) GemRB.SetText(CharGenWindow,ClassButton, 11959) GemRB.SetButtonState(CharGenWindow,ClassButton,IE_GUI_BUTTON_DISABLED) AlignmentButton = GemRB.GetControl(CharGenWindow,3) GemRB.SetText(CharGenWindow,AlignmentButton, 11958) GemRB.SetButtonState(CharGenWindow,AlignmentButton,IE_GUI_BUTTON_DISABLED) AbilitiesButton = GemRB.GetControl(CharGenWindow,4) GemRB.SetText(CharGenWindow,AbilitiesButton, 11960) GemRB.SetButtonState(CharGenWindow,AbilitiesButton,IE_GUI_BUTTON_DISABLED) SkillButton = GemRB.GetControl(CharGenWindow,5) GemRB.SetText(CharGenWindow,SkillButton, 17372) GemRB.SetButtonState(CharGenWindow,SkillButton,IE_GUI_BUTTON_ENABLED) AppearanceButton = GemRB.GetControl(CharGenWindow,6) GemRB.SetText(CharGenWindow,AppearanceButton, 11961) GemRB.SetButtonState(CharGenWindow,AppearanceButton,IE_GUI_BUTTON_DISABLED) NameButton = GemRB.GetControl(CharGenWindow,7) GemRB.SetText(CharGenWindow,NameButton, 11963) GemRB.SetButtonState(CharGenWindow,NameButton,IE_GUI_BUTTON_DISABLED) BackButton = GemRB.GetControl(CharGenWindow, 11) GemRB.SetText(CharGenWindow, BackButton, 15416) GemRB.SetButtonState(CharGenWindow,BackButton,IE_GUI_BUTTON_ENABLED) AcceptButton = GemRB.GetControl(CharGenWindow, 8) GemRB.SetText(CharGenWindow, AcceptButton, 28210) GemRB.SetButtonState(CharGenWindow,AcceptButton,IE_GUI_BUTTON_DISABLED) ImportButton = GemRB.GetControl(CharGenWindow, 13) GemRB.SetText(CharGenWindow, ImportButton, 13955) GemRB.SetButtonState(CharGenWindow,ImportButton,IE_GUI_BUTTON_DISABLED) CancelButton = GemRB.GetControl(CharGenWindow, 15) GemRB.SetText(CharGenWindow, CancelButton, 36788) GemRB.SetButtonState(CharGenWindow,CancelButton,IE_GUI_BUTTON_ENABLED) BiographyButton = GemRB.GetControl(CharGenWindow, 16) GemRB.SetText(CharGenWindow, BiographyButton, 18003) GemRB.SetButtonState(CharGenWindow,BiographyButton,IE_GUI_BUTTON_DISABLED) TextAreaControl= GemRB.GetControl(CharGenWindow,9) GemRB.SetText(CharGenWindow, TextAreaControl, 12135) GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,": ") if GemRB.GetVar("Gender") == 1: GemRB.TextAreaAppend(CharGenWindow, TextAreaControl, 1050) else: GemRB.TextAreaAppend(CharGenWindow, TextAreaControl, 1051) GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,1048,-1) # new line GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,": ") GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,GemRB.GetTableValue(RaceTable,GemRB.GetVar("Race")-1,2)) GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,11959,-1) # new line GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,": ") GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,GemRB.GetTableValue(ClassTable,GemRB.GetVar("Class")-1,0)) GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,11958,-1) # new line GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,": ") GemRB.TextAreaAppend(CharGenWindow, TextAreaControl,GemRB.GetTableValue(AlignmentTable,GemRB.GetVar("Alignment")-1,0)) GemRB.SetEvent(CharGenWindow, CancelButton, IE_GUI_BUTTON_ON_PRESS, "StartOverPress") GemRB.SetEvent(CharGenWindow, BackButton, IE_GUI_BUTTON_ON_PRESS, "BackPress") GemRB.SetEvent(CharGenWindow, AbilitiesButton, IE_GUI_BUTTON_ON_PRESS, "NextPress") GemRB.SetVisible(CharGenWindow,1) return def NextPress(): GemRB.UnloadWindow(CharGenWindow) GemRB.SetNextScript("Abilities") #abilities return def StartOverPress(): GemRB.SetVisible(StartOverWindow,1) return def NoExitPress(): GemRB.SetVisible(StartOverWindow,0) GemRB.SetVisible(CharGenWindow,1) return def CancelPress(): GemRB.UnloadWindow(CharGenWindow) GemRB.UnloadWindow(StartOverWindow) GemRB.SetNextScript("CharGen") return def BackPress(): GemRB.UnloadWindow(CharGenWindow) GemRB.SetNextScript("CharGen4") #alignment return |