def RevealMap(): global MapWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow(ShowMap): if MapWindow: MapWindow.Unload() if OptionsWindow: OptionsWindow.Unload() if PortraitWindow: PortraitWindow.Unload() MapWindow = None #this window type should block the game GemRB.SetVar("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None PosX = GemRB.GetVar("MapControlX") PosY = GemRB.GetVar("MapControlY") GemRB.RevealArea(PosX, PosY, 30, 1) GemRB.GamePause(0, 0) return
def OnLoad(): global NameWindow, NameField, DoneButton if GUICommon.CloseOtherWindow(OnLoad): if (NameWindow): NameWindow.Unload() NameWindow = None return GemRB.LoadWindowPack("GUICG", 640, 480) NameWindow = GemRB.LoadWindow(5) BackButton = NameWindow.GetControl(3) BackButton.SetText(15416) DoneButton = NameWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) NameField = NameWindow.GetControl(2) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) NameField.SetEvent(IE_GUI_EDIT_ON_CHANGE, EditChange) NameWindow.ShowModal(MODAL_SHADOW_NONE) NameField.SetStatus(IE_GUI_CONTROL_FOCUSED) return
def OnLoad(): global SkillWindow, DoneButton GemRB.LoadWindowPack("GUICG", 640, 480) SkillWindow = GemRB.LoadWindow(9) GUICommon.CloseOtherWindow(SkillWindow.Unload) MyChar = GemRB.GetVar("Slot") Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \ GemRB.GetPlayerStat (MyChar, IE_LEVEL3)] LUProfsSelection.SetupProfsWindow(MyChar, LUProfsSelection.LUPROFS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0, 0, 0], Levels, scroll=False, profTableOffset=0) BackButton = SkillWindow.GetControl(77) BackButton.SetText(15416) BackButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) DoneButton = SkillWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) SkillWindow.ShowModal(MODAL_SHADOW_NONE) return
def OnLoad(): global ExportWindow, TextAreaControl GemRB.LoadWindowPack("GUICG", 640, 480) ExportWindow = GemRB.LoadWindow(21) if GameCheck.IsBG1(): GUICommon.CloseOtherWindow(ExportWindow.Unload) TextAreaControl = ExportWindow.GetControl(4) TextAreaControl.SetText(10962) TextAreaControl = ExportWindow.GetControl(2) TextAreaControl.ListResources(CHR_EXPORTS) FileNameEditBox = ExportWindow.GetControl(7) FileNameEditBox.SetEvent(IE_GUI_EDIT_ON_CHANGE, FileNameChange) DoneButton = ExportWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) CancelButton = ExportWindow.GetControl(1) CancelButton.SetText(13727) CancelButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress) CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress) TextAreaControl.SetEvent(IE_GUI_TEXTAREA_ON_SELECT, SelectPress) ExportWindow.ShowModal(MODAL_SHADOW_NONE) FileNameEditBox.SetStatus(IE_GUI_CONTROL_FOCUSED) return
def OnLoad(): global SkillWindow, DoneButton if GUICommon.CloseOtherWindow(OnLoad): if (SkillWindow): SkillWindow.Unload() SkillWindow = None return GemRB.LoadWindowPack("GUICG", 640, 480) SkillWindow = GemRB.LoadWindow(6) MyChar = GemRB.GetVar("Slot") Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \ GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \ GemRB.GetPlayerStat (MyChar, IE_LEVEL3)] LUSkillsSelection.SetupSkillsWindow( MyChar, LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0, 0, 0], Levels, 0, False) BackButton = SkillWindow.GetControl(25) BackButton.SetText(15416) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) DoneButton = SkillWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_NAND) RedrawSkills() SkillWindow.ShowModal(MODAL_SHADOW_NONE) return
def DonePress(): FileNameEditBox = ExportWindow.GetControl(7) FileName = FileNameEditBox.QueryText() Slot = GemRB.GetVar("Slot") GemRB.SaveCharacter(Slot, FileName) GUICommon.CloseOtherWindow(None) CharGenCommon.close() GemRB.SetNextScript("Start") return
def OnLoad(): global AlignmentWindow, TextAreaControl, DoneButton global AlignmentTable if GUICommon.CloseOtherWindow(OnLoad): if (AlignmentWindow): AlignmentWindow.Unload() AlignmentWindow = None return MyChar = GemRB.GetVar("Slot") GemRB.SetVar("Alignment", -1) Class = GemRB.GetPlayerStat(MyChar, IE_CLASS) ClassRow = CommonTables.Classes.FindValue(5, Class) KitName = CommonTables.Classes.GetRowName(ClassRow) AlignmentOk = GemRB.LoadTable("ALIGNMNT") GemRB.LoadWindowPack("GUICG", 640, 480) AlignmentTable = GemRB.LoadTable("aligns") AlignmentWindow = GemRB.LoadWindow(3) for i in range(9): Button = AlignmentWindow.GetControl(i + 2) Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) Button.SetState(IE_GUI_BUTTON_DISABLED) Button.SetText(AlignmentTable.GetValue(i, 0)) # This section enables or disables different alignment selections # based on Class, and depends on the ALIGNMNT.2DA table # # For now, we just enable all buttons for i in range(9): Button = AlignmentWindow.GetControl(i + 2) if AlignmentOk.GetValue(KitName, AlignmentTable.GetValue(i, 4)) != 0: Button.SetState(IE_GUI_BUTTON_ENABLED) else: Button.SetState(IE_GUI_BUTTON_DISABLED) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, AlignmentPress) Button.SetVarAssoc("Alignment", i) BackButton = AlignmentWindow.GetControl(13) BackButton.SetText(15416) DoneButton = AlignmentWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) TextAreaControl = AlignmentWindow.GetControl(11) TextAreaControl.SetText(9602) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) AlignmentWindow.ShowModal(MODAL_SHADOW_NONE) return
def OpenJournalWindow(): global JournalWindow, PortraitWindow, ActionsWindow global StartTime Table = GemRB.LoadTable("YEARS") StartTime = Table.GetValue("STARTTIME", "VALUE") if GUICommon.CloseOtherWindow(OpenJournalWindow): if LogWindow: OpenLogWindow() if BeastsWindow: OpenBeastsWindow() if QuestsWindow: OpenQuestsWindow() GemRB.HideGUI() if JournalWindow: JournalWindow.Unload() #making the portraitwindow visible again GUICommonWindows.EnableAnimatedWindows() GemRB.SetVar("OtherWindow", -1) PortraitWindow = None ActionsWindow = None JournalWindow = None GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() return GemRB.HideGUI() GemRB.LoadWindowPack("GUIJRNL") JournalWindow = GemRB.LoadWindow(0) GemRB.SetVar("OtherWindow", JournalWindow.ID) GUICommonWindows.DisableAnimatedWindows() # Quests Button = JournalWindow.GetControl(0) Button.SetText(20430) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenQuestsWindow) # Beasts Button = JournalWindow.GetControl(1) Button.SetText(20634) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenBeastsWindow) # Journal Button = JournalWindow.GetControl(2) Button.SetText(20635) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenLogWindow) # Done Button = JournalWindow.GetControl(3) Button.SetText(20636) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenJournalWindow) Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) Button.SetStatus(IE_GUI_CONTROL_FOCUSED) #JournalWindow.SetVisible (WINDOW_VISIBLE) GemRB.UnhideGUI()
def OnLoad(): global ClassWindow, TextAreaControl, DoneButton GemRB.LoadWindowPack("GUICG", 640, 480) ClassWindow = GemRB.LoadWindow(10) GUICommon.CloseOtherWindow (ClassWindow.Unload) ClassCount = CommonTables.Classes.GetRowCount()+1 RaceName = CommonTables.Races.GetRowName(GemRB.GetVar("Race")-1 ) j=0 for i in range(1,ClassCount): ClassName = CommonTables.Classes.GetRowName (i-1) if CommonTables.Classes.GetValue (ClassName, "MULTI") == 0: continue if j>11: Button = ClassWindow.GetControl(j+7) else: Button = ClassWindow.GetControl(j+2) Button.SetState(IE_GUI_BUTTON_DISABLED) Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR) j = j + 1 j=0 for i in range(1,ClassCount): ClassName = CommonTables.Classes.GetRowName (i-1) Allowed = CommonTables.Classes.GetValue(ClassName, RaceName) if CommonTables.Classes.GetValue (ClassName, "MULTI") == 0: continue if j>11: Button = ClassWindow.GetControl(j+7) else: Button = ClassWindow.GetControl(j+2) t = CommonTables.Classes.GetValue (ClassName, "NAME_REF") Button.SetText(t ) j=j+1 if Allowed ==0: continue Button.SetState(IE_GUI_BUTTON_ENABLED) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClassPress) Button.SetVarAssoc("Class", i) #multiclass, actually BackButton = ClassWindow.GetControl(14) BackButton.SetText(15416) DoneButton = ClassWindow.GetControl(0) DoneButton.SetText(11973) TextAreaControl = ClassWindow.GetControl(12) TextAreaControl.SetText(17244) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) ClassWindow.ShowModal(MODAL_SHADOW_NONE) return
def OpenJournalWindow(): global StartTime, StartYear global JournalWindow, PortraitWindow, OptionsWindow global OldPortraitWindow, OldOptionsWindow global Chapter if GUICommon.CloseOtherWindow(OpenJournalWindow): if JournalWindow: JournalWindow.Unload() if OptionsWindow: OptionsWindow.Unload() if PortraitWindow: PortraitWindow.Unload() JournalWindow = None GemRB.SetVar("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIJRNL", 640, 480) JournalWindow = Window = GemRB.LoadWindow(2) GemRB.SetVar("OtherWindow", JournalWindow.ID) #saving the original portrait window OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow(0) GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0, OpenJournalWindow) OptionsWindow.SetFrame() OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow(0) Table = GemRB.LoadTable("YEARS") #StartTime is the time offset for ingame time, beginning from the startyear StartTime = Table.GetValue("STARTTIME", "VALUE") / 4500 #StartYear is the year of the lowest ingame date to be printed StartYear = Table.GetValue("STARTYEAR", "VALUE") Button = Window.GetControl(3) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, JournalPrevSectionPress) Button = Window.GetControl(4) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, JournalNextSectionPress) Chapter = GemRB.GetGameVar("chapter") UpdateJournalWindow() OptionsWindow.SetVisible(WINDOW_VISIBLE) Window.SetVisible(WINDOW_VISIBLE) PortraitWindow.SetVisible(WINDOW_VISIBLE)
def ShowMap (): global MapWindow, OptionsWindow, PortraitWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow (ShowMap): if MapWindow: MapWindow.Unload () if OptionsWindow: OptionsWindow.Unload () if PortraitWindow: PortraitWindow.Unload () MapWindow = None #this window type should block the game GemRB.SetVar ("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI () GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None return GemRB.HideGUI () GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack ("GUIMAP", 640, 480) MapWindow = Window = GemRB.LoadWindow (2) #this window type blocks the game normally, but map window doesn't GemRB.SetVar ("OtherWindow", MapWindow.ID) #saving the original portrait window OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow (0) GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 0, ShowMap) OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow (0) OptionsWindow.SetFrame () # World Map Button = Window.GetControl (1) Button.SetState (IE_GUI_BUTTON_LOCKED) # Map Control Window.CreateMapControl (2, 0, 0, 0, 0) Map = Window.GetControl (2) Map.SetEvent (IE_GUI_MAP_ON_PRESS, RevealMap) Window.SetVisible (WINDOW_VISIBLE) OptionsWindow.SetVisible (WINDOW_GRAYED) PortraitWindow.SetVisible (WINDOW_GRAYED) OptionsWindow.SetVisible (WINDOW_FRONT) PortraitWindow.SetVisible (WINDOW_FRONT) Window.SetVisible (WINDOW_FRONT) Map.SetStatus (IE_GUI_CONTROL_FOCUSED) GemRB.GamePause (0,0) return
def OpenMapWindow (): global MapWindow, OptionsWindow, PortraitWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow (OpenMapWindow): if MapWindow: MapWindow.Unload () if OptionsWindow: OptionsWindow.Unload () if PortraitWindow: PortraitWindow.Unload () MapWindow = None #this window type should block the game GemRB.SetVar ("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) #OldOptionsWindow.SetVisible (WINDOW_VISIBLE) #OldPortraitWindow.SetVisible (WINDOW_VISIBLE) GemRB.UnhideGUI () GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None return GemRB.HideGUI () GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack ("GUIMAP", 640, 480) MapWindow = Window = GemRB.LoadWindow (2) #this window type blocks the game normally, but map window doesn't GemRB.SetVar ("OtherWindow", MapWindow.ID) #saving the original portrait window OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow (0) GUICommonWindows.MarkMenuButton (OptionsWindow) GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 0, OpenMapWindow) OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow (0) OptionsWindow.SetFrame () # World Map Button = Window.GetControl (1) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindowInside) # Map Control Window.CreateMapControl (2, 0, 0, 0, 0) Map = Window.GetControl (2) Map.SetEvent (IE_GUI_MAP_ON_DOUBLE_PRESS, LeftDoublePressMap) #OldOptionsWindow.SetVisible (WINDOW_INVISIBLE) #OldPortraitWindow.SetVisible (WINDOW_INVISIBLE) OptionsWindow.SetVisible (WINDOW_VISIBLE) Window.SetVisible (WINDOW_VISIBLE) PortraitWindow.SetVisible (WINDOW_VISIBLE) Map.SetStatus (IE_GUI_CONTROL_FOCUSED)
def OpenFormationWindow (): global FormationWindow if GUICommon.CloseOtherWindow(OpenFormationWindow): GemRB.HideGUI () if FormationWindow: FormationWindow.Unload () FormationWindow = None GemRB.GameSetFormation (last_formation, 0) GUICommonWindows.EnableAnimatedWindows () GemRB.SetVar ("OtherWindow", -1) GemRB.UnhideGUI () return GemRB.HideGUI () GemRB.LoadWindowPack (GUICommon.GetWindowPack()) FormationWindow = Window = GemRB.LoadWindow (27) GemRB.SetVar ("OtherWindow", Window.ID) GUICommonWindows.DisableAnimatedWindows () # Done Button = Window.GetControl (13) Button.SetText (1403) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenFormationWindow) tooltips = ( 44957, # Follow 44958, # T 44959, # Gather 44960, # 4 and 2 44961, # 3 by 2 44962, # Protect 48152, # 2 by 3 44964, # Rank 44965, # V 44966, # Wedge 44967, # S 44968, # Line 44969, # None ) for i in range (13): Button = Window.GetControl (i) Button.SetVarAssoc ("SelectedFormation", i) Button.SetTooltip (tooltips[i]) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, SelectFormation) GemRB.SetVar ("SelectedFormation", GemRB.GameGetFormation (0)) SelectFormation () GemRB.UnhideGUI ()
def DonePress(): FileNameEditBox = ExportWindow.GetControl(7) FileName = FileNameEditBox.QueryText() Slot = GemRB.GetVar("Slot") GemRB.SaveCharacter(Slot, FileName) if GameCheck.IsBG1(): GUICommon.CloseOtherWindow(None) CharGenCommon.close() GemRB.SetNextScript("Start") else: if ExportWindow: ExportWindow.Unload() GemRB.SetNextScript(GemRB.GetToken("NextScript")) return
def OnLoad(): global RaceWindow, TextAreaControl, DoneButton global RacialEnemyTable, RaceCount, TopIndex if GUICommon.CloseOtherWindow(OnLoad): if (RaceWindow): RaceWindow.Unload() RaceWindow = None return GemRB.SetVar("HatedRace", 0) ClassRow = GemRB.GetVar("Class") - 1 Class = CommonTables.Classes.GetValue(ClassRow, 5) ClassName = CommonTables.ClassSkills.GetRowName(Class) TableName = CommonTables.ClassSkills.GetValue(ClassName, "HATERACE") GemRB.LoadWindowPack("GUICG", 640, 480) RaceWindow = GemRB.LoadWindow(15) RacialEnemyTable = GemRB.LoadTable(TableName) RaceCount = RacialEnemyTable.GetRowCount() - LISTSIZE + 1 if RaceCount < 0: RaceCount = 0 for i in range(LISTSIZE): Button = RaceWindow.GetControl(i + 2) Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) Button.SetSprites("GUIHRC", i, 0, 1, 2, 3) BackButton = RaceWindow.GetControl(10) BackButton.SetText(15416) DoneButton = RaceWindow.GetControl(11) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) TextAreaControl = RaceWindow.GetControl(8) TextAreaControl.SetText(17256) TopIndex = 0 GemRB.SetVar("TopIndex", 0) ScrollBarControl = RaceWindow.GetControl(1) ScrollBarControl.SetVarAssoc("TopIndex", RaceCount) ScrollBarControl.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, DisplayRaces) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) RaceWindow.ShowModal(MODAL_SHADOW_NONE) DisplayRaces() return
def DialogStarted (): global ContinueWindow, OldActionsWindow # try to force-close anything which is open GUICommon.CloseOtherWindow(None) CommonWindow.CloseContainerWindow() # we need GUI for dialogs GemRB.UnhideGUI() # opening control size to maximum, enabling dialog window GemRB.GameSetScreenFlags(GS_HIDEGUI, OP_NAND) GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR) MessageWindow.UpdateControlStatus()
def OpenMapWindow(): global MapWindow if GUICommon.CloseOtherWindow(OpenMapWindow): if MapWindow: MapWindow.Unload() MapWindow = None GemRB.SetVar("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() GUICommonWindows.SetSelectionChangeHandler(None) return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIMAP", WIDTH, HEIGHT) MapWindow = Window = GemRB.LoadWindow(0) GemRB.SetVar("OtherWindow", MapWindow.ID) Label = Window.GetControl(0) Label.SetText("Area map") # World Map Button = Window.GetControl(1) Button.SetText("WMAP") Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindowInside) # Map Control Window.CreateMapControl(2, 0, 0, 0, 0) Map = Window.GetControl(2) Map.SetEvent(IE_GUI_MAP_ON_DOUBLE_PRESS, LeftDoublePressMap) Button = Window.GetControl(3) Button.SetText("Close") Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) Window.SetVisible(WINDOW_VISIBLE) Map.SetStatus(IE_GUI_CONTROL_FOCUSED) # create a button so we can map it do ESC for quit exiting Button = Window.CreateButton(99, 0, 0, 1, 1) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) GUICommonWindows.SetSelectionChangeHandler(None) return
def OpenMageWindow(): global MageWindow, OptionsWindow, PortraitWindow, OtherWindow, MageSpellInfoWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow(OpenMageWindow): CloseMageSpellUnmemorizeWindow() if MageSpellInfoWindow: MageSpellInfoWindow.Unload() MageSpellInfoWindow = None if OtherWindow: OtherWindow.Unload() OtherWindow = None if MageWindow: MageWindow.Unload() if OptionsWindow: OptionsWindow.Unload() if PortraitWindow: PortraitWindow.Unload() MageWindow = None GemRB.SetVar("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None GUICommonWindows.SetSelectionChangeHandler(None) return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIMG", 640, 480) #saving the original portrait window OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow(0) GUICommonWindows.MarkMenuButton(OptionsWindow) GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0, OpenMageWindow) OptionsWindow.SetFrame() OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow(0) GUICommonWindows.SetSelectionChangeHandler(SetupMageWindow) SetupMageWindow() return
def back(self): """Moves to the previous step. Unsets last""" GUICommon.CloseOtherWindow(None) self.unset(self.step) if len(self.stages[self.step]) == 3: #short, return to other short self.step = self.step - 1 self.unset(self.step) while len(self.stages[self.step]) != 3: self.step = self.step - 1 self.unset(self.step) else: self.step = self.step - 1 self.unset(self.step) while(not self.setScript()): self.step = self.step - 1 self.unset(self.step)
def WorldMapWindowCommon(Travel): global WorldMapWindow, WorldMapControl if GUICommon.CloseOtherWindow(CloseWorldMapWindow): CloseWorldMapWindow() return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIMAP", WIDTH, HEIGHT) WorldMapWindow = Window = GemRB.LoadWindow(0) Label = Window.GetControl(0) Label.SetText("World map") Button = Window.GetControl(1) Button.SetText("MAP") Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) GemRB.SetVar("OtherWindow", WorldMapWindow.ID) Window.SetFrame() Window.CreateWorldMapControl(2, 0, 0, 0, 0, Travel, "floattxt") WorldMapControl = Window.GetControl(2) WorldMapControl.SetAnimation("WMDAG") WorldMapControl.SetEvent(IE_GUI_WORLDMAP_ON_PRESS, GUIMACommon.MoveToNewArea) WorldMapControl.SetEvent(IE_GUI_MOUSE_ENTER_WORLDMAP, ChangeTooltip) # center on current area MapC() Button = Window.GetControl(3) Button.SetText("Close") if Travel >= 0: Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindow) else: Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) # TODO: change to CloseTopWindow Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) Window.SetVisible(WINDOW_VISIBLE) WorldMapControl.SetStatus(IE_GUI_CONTROL_FOCUSED) return
def OnLoad(): global CharSoundWindow, VoiceList if GUICommon.CloseOtherWindow(OnLoad): if (CharSoundWindow): CharSoundWindow.Unload() CharSoundWindow = None return GemRB.LoadWindowPack("GUICG", 640, 480) CharSoundWindow = GemRB.LoadWindow(19) VoiceList = CharSoundWindow.GetControl(45) VoiceList.SetFlags(IE_GUI_TEXTAREA_SELECTABLE) if GemRB.GetVar("Gender") == 1: GemRB.SetVar("Selected", 3) #first male sound else: GemRB.SetVar("Selected", 0) VoiceList.SetVarAssoc("Selected", 0) RowCount = VoiceList.GetCharSounds() PlayButton = CharSoundWindow.GetControl(47) PlayButton.SetState(IE_GUI_BUTTON_ENABLED) PlayButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PlayPress) PlayButton.SetText(17318) TextArea = CharSoundWindow.GetControl(50) TextArea.SetText(11315) BackButton = CharSoundWindow.GetControl(10) BackButton.SetText(15416) DoneButton = CharSoundWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) VoiceList.SetEvent(IE_GUI_TEXTAREA_ON_CHANGE, ChangeVoice) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) CharSoundWindow.ShowModal(MODAL_SHADOW_NONE) return
def OnLoad(): global RaceWindow, TextAreaControl, DoneButton global RaceTable if GUICommon.CloseOtherWindow(OnLoad): if (RaceWindow): RaceWindow.Unload() RaceWindow = None return GemRB.SetVar("Race", 0) GemRB.LoadWindowPack("GUICG", 640, 480) RaceWindow = GemRB.LoadWindow(8) RaceCount = CommonTables.Races.GetRowCount() for i in range(2, RaceCount + 2): Button = RaceWindow.GetControl(i) Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) for i in range(2, RaceCount + 2): Button = RaceWindow.GetControl(i) Button.SetText(CommonTables.Races.GetValue(i - 2, 0)) Button.SetState(IE_GUI_BUTTON_ENABLED) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RacePress) Button.SetVarAssoc("Race", i - 1) BackButton = RaceWindow.GetControl(10) BackButton.SetText(15416) DoneButton = RaceWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) TextAreaControl = RaceWindow.GetControl(8) TextAreaControl.SetText(17237) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) RaceWindow.ShowModal(MODAL_SHADOW_NONE) return
def jumpTo(self,to): if type(to) == str: done = False for i in range(len(self.stages)): if(to == self.stages[i][0]): self.step = i done = True if(not done): raise ValueError("stage name not found: "+str(to)) elif type(to) == int: if(to<0): to = len(self.stages)+to if(to<0 or to>=len(self.stages)): raise ValueError("stage index not found: "+str(to)) self.step = to return else: raise ValueError("bad arg type: "+str(type(to)) + " " + str(to)) GUICommon.CloseOtherWindow(None) while(not self.setScript()): self.step = self.step + 1
def CloseWorldMapWindow(): global WorldMapWindow, WorldMapControl global OldPortraitWindow, OldOptionsWindow assert GUICommon.CloseOtherWindow(CloseWorldMapWindow) if WorldMapWindow: WorldMapWindow.Unload() if PortraitWindow: PortraitWindow.Unload() if OptionsWindow: OptionsWindow.Unload() WorldMapWindow = None WorldMapControl = None GUICommonWindows.PortraitWindow = OldPortraitWindow OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None GemRB.SetVar("OtherWindow", -1) GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() return
def WorldMapWindowCommon(Travel): global WorldMapWindow, WorldMapControl global OptionsWindow, PortraitWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow(CloseWorldMapWindow): return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIWMAP", 800, 600) WorldMapWindow = Window = GemRB.LoadWindow(2) #(fuzzie just copied this from the map window code..) GemRB.SetVar("OtherWindow", WorldMapWindow.ID) #saving the original portrait window OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow() OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow(0) GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0, OpenMapWindow) OptionsWindow.SetFrame() Window.CreateWorldMapControl(4, 0, 62, 640, 418, Travel, "infofont") WorldMapControl = Window.GetControl(4) WorldMapControl.SetAnimation("WMDAG") WorldMapControl.SetEvent(IE_GUI_WORLDMAP_ON_PRESS, MoveToNewArea) WorldMapControl.SetEvent(IE_GUI_MOUSE_ENTER_WORLDMAP, ChangeTooltip) # Done Button = Window.GetControl(0) if Travel >= 0: Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindow) else: Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) Window.SetVisible(WINDOW_VISIBLE) WorldMapControl.SetStatus(IE_GUI_CONTROL_FOCUSED)
def OpenMageWindow (): global MageWindow, PauseState if GUICommon.CloseOtherWindow (OpenMageWindow): GemRB.HideGUI () if MageWindow: MageWindow.Unload () MageWindow = None GemRB.SetVar ("OtherWindow", -1) GUICommonWindows.SetSelectionChangeHandler (None) GUICommon.GameWindow.SetVisible (WINDOW_VISIBLE) GemRB.UnhideGUI () GemRB.GamePause (PauseState, 3) return PauseState = GemRB.GamePause (3, 1) GemRB.GamePause (1, 3) GemRB.HideGUI () GemRB.LoadWindowPack ("GUIMG") MageWindow = Window = GemRB.LoadWindow (3) GemRB.SetVar ("OtherWindow", MageWindow.ID) Button = Window.GetControl (0) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, MagePrevLevelPress) Button = Window.GetControl (1) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, MageNextLevelPress) # Setup memorized spells buttons for i in range (12): Icon = Window.GetControl (2 + i) Icon.SetBorder (0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 1) GUICommonWindows.SetSelectionChangeHandler (UpdateMageWindow) GemRB.UnhideGUI () UpdateMageWindow ()
def OnLoad(): global GenderWindow, TextAreaControl, DoneButton if GUICommon.CloseOtherWindow(OnLoad): if (GenderWindow): GenderWindow.Unload() GenderWindow = None return GemRB.LoadWindowPack("GUICG", 640, 480) GenderWindow = GemRB.LoadWindow(1) BackButton = GenderWindow.GetControl(6) BackButton.SetText(15416) DoneButton = GenderWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) TextAreaControl = GenderWindow.GetControl(5) TextAreaControl.SetText(17236) MaleButton = GenderWindow.GetControl(2) MaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) FemaleButton = GenderWindow.GetControl(3) FemaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) GemRB.SetVar("Gender", 0) MaleButton.SetVarAssoc("Gender", 1) FemaleButton.SetVarAssoc("Gender", 2) MaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedMale) FemaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedFemale) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress) DoneButton.SetState(IE_GUI_BUTTON_DISABLED) GenderWindow.ShowModal(MODAL_SHADOW_NONE) return
def OpenInventoryWindow(): """Opens the inventory window.""" import GUICommonWindows global InventoryWindow, OptionsWindow, PortraitWindow global OldPortraitWindow, OldOptionsWindow if GUICommon.CloseOtherWindow(OpenInventoryWindow): if GemRB.IsDraggingItem() == 1: pc = GemRB.GameGetSelectedPCSingle() #store the item in the inventory before window is closed GemRB.DropDraggedItem(pc, -3) #dropping on ground if cannot store in inventory if GemRB.IsDraggingItem() == 1: GemRB.DropDraggedItem(pc, -2) InventoryCommon.CloseIdentifyItemWindow() InventoryCommon.CloseAbilitiesItemWindow() InventoryCommon.CancelColor() if InventoryCommon.ItemInfoWindow: InventoryCommon.ItemInfoWindow.Unload() InventoryCommon.ItemInfoWindow = None if InventoryCommon.ItemAmountWindow: InventoryCommon.ItemAmountWindow.Unload() InventoryCommon.ItemAmountWindow = None if InventoryCommon.ErrorWindow: InventoryCommon.ErrortWindow.Unload() InventoryCommon.ErrortWindow = None if InventoryWindow: InventoryWindow.Unload() if OptionsWindow: OptionsWindow.Unload() if PortraitWindow: PortraitWindow.Unload() InventoryWindow = None GemRB.SetVar("OtherWindow", -1) GemRB.SetVar("MessageLabel", -1) GUICommonWindows.PortraitWindow = OldPortraitWindow GUICommonWindows.UpdatePortraitWindow() OldPortraitWindow = None GUICommonWindows.OptionsWindow = OldOptionsWindow OldOptionsWindow = None #don't go back to multi selection mode when going to the store screen if not GemRB.GetVar("Inventory"): GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE) GemRB.UnhideGUI() GUICommonWindows.SetSelectionChangeHandler(None) return GemRB.HideGUI() GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) GemRB.LoadWindowPack("GUIINV", 640, 480) InventoryWindow = Window = GemRB.LoadWindow(2) GemRB.SetVar("OtherWindow", InventoryWindow.ID) GemRB.SetVar("MessageLabel", Window.GetControl(0x1000003f).ID) OldOptionsWindow = GUICommonWindows.OptionsWindow OptionsWindow = GemRB.LoadWindow(0) GUICommonWindows.MarkMenuButton(OptionsWindow) GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0, OpenInventoryWindow) OptionsWindow.SetFrame() #saving the original portrait window OldPortraitWindow = GUICommonWindows.PortraitWindow PortraitWindow = GUICommonWindows.OpenPortraitWindow(0) #ground items scrollbar ScrollBar = Window.GetControl(66) ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RefreshInventoryWindow) #Ground Item for i in range(5): Button = Window.GetControl(i + 68) Button.SetEvent(IE_GUI_MOUSE_ENTER_BUTTON, InventoryCommon.MouseEnterGround) Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, InventoryCommon.MouseLeaveGround) Button.SetVarAssoc("GroundItemButton", i) Button.SetSprites("STONSLOT", 0, 0, 2, 4, 3) #major & minor clothing color Button = Window.GetControl(62) Button.SetSprites("INVBUT", 0, 0, 1, 0, 0) Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, InventoryCommon.MajorPress) Button.SetTooltip(12007) Button = Window.GetControl(63) Button.SetSprites("INVBUT", 0, 0, 1, 0, 0) Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, InventoryCommon.MinorPress) Button.SetTooltip(12008) #portrait Button = Window.GetControl(50) Button.SetState(IE_GUI_BUTTON_LOCKED) Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET) Button.SetEvent(IE_GUI_BUTTON_ON_DRAG_DROP, InventoryCommon.OnAutoEquip) #encumbrance Button = Window.GetControl(67) r = Button.GetRect() Label = Window.CreateLabel( 0x10000043, r["X"], r["Y"], r["Width"], 20, "NUMBER", "0:", IE_FONT_ALIGN_LEFT | IE_FONT_ALIGN_TOP | IE_FONT_SINGLE_LINE) Label = Window.CreateLabel( 0x10000044, r["X"], r["Y"] + r["Height"] - 20, r["Width"], 20, "NUMBER", "0:", IE_FONT_ALIGN_RIGHT | IE_FONT_ALIGN_BOTTOM | IE_FONT_SINGLE_LINE) # armor class Label = Window.GetControl(0x10000038) Label.SetTooltip(17183) # hp current Label = Window.GetControl(0x10000039) Label.SetTooltip(17184) # hp max Label = Window.GetControl(0x1000003a) Label.SetTooltip(17378) # info label, game paused, etc Label = Window.GetControl(0x1000003f) Label.SetText("") SlotCount = GemRB.GetSlotType(-1)["Count"] for slot in range(SlotCount): SlotType = GemRB.GetSlotType(slot + 1) if SlotType["ID"]: Button = Window.GetControl(SlotType["ID"]) Button.SetEvent(IE_GUI_MOUSE_ENTER_BUTTON, InventoryCommon.MouseEnterSlot) Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, InventoryCommon.MouseLeaveSlot) Button.SetVarAssoc("ItemButton", slot + 1) #keeping 2 in the original place, because it is how #the gui resource has it, but setting the other cycles Button.SetSprites("STONSLOT", 0, 0, 2, 4, 3) # create a button so we can map it do ESC for quit exiting Button = Window.CreateButton(999, 0, 0, 1, 1) Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenInventoryWindow) Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) GemRB.SetVar("TopIndex", 0) GUICommonWindows.SetSelectionChangeHandler(UpdateInventoryWindow) UpdateInventoryWindow() OptionsWindow.SetVisible(WINDOW_VISIBLE) Window.SetVisible(WINDOW_FRONT) PortraitWindow.SetVisible(WINDOW_VISIBLE) Window.SetKeyPressEvent(GUICommonWindows.SwitchPCByKey) return
def setAccept(): #set my character up MyChar = GemRB.GetVar("Slot") ClassName = GUICommon.GetClassRowName(MyChar) #reputation AllignID = GemRB.GetPlayerStat(MyChar, IE_ALIGNMENT) TmpTable = GemRB.LoadTable("repstart") t = TmpTable.GetValue(AllignID, 0) * 10 GemRB.SetPlayerStat(MyChar, IE_REPUTATION, t) #lore, thac0, hp, and saves if not GemRB.GetVar("ImportedChar"): GemRB.SetPlayerStat(MyChar, IE_MAXHITPOINTS, 0) GemRB.SetPlayerStat(MyChar, IE_HITPOINTS, 0) LUCommon.SetupSavingThrows(MyChar) LUCommon.SetupThaco(MyChar) LUCommon.SetupLore(MyChar) LUCommon.SetupHP(MyChar) #slot 1 is the protagonist if MyChar == 1: GemRB.GameSetReputation(t) #gold TmpTable = GemRB.LoadTable("strtgold") t = GemRB.Roll(TmpTable.GetValue(ClassName, "ROLLS"), TmpTable.GetValue(ClassName, "SIDES"), TmpTable.GetValue(ClassName, "MODIFIER")) GemRB.SetPlayerStat(MyChar, IE_GOLD, t * TmpTable.GetValue(ClassName, "MULTIPLIER")) #set the base number of attacks; effects will add the proficiency bonus GemRB.SetPlayerStat(MyChar, IE_NUMBEROFATTACKS, 2) #colors GUICommon.SetColorStat(MyChar, IE_METAL_COLOR, 0x1B) GUICommon.SetColorStat(MyChar, IE_LEATHER_COLOR, 0x16) GUICommon.SetColorStat(MyChar, IE_ARMOR_COLOR, 0x17) #does all the rest LargePortrait = GemRB.GetToken("LargePortrait") SmallPortrait = GemRB.GetToken("SmallPortrait") GemRB.FillPlayerInfo(MyChar, LargePortrait, SmallPortrait) GemRB.SetPlayerString(MyChar, 74, 11863) #10 is a weapon slot (see slottype.2da row 10) GemRB.CreateItem(MyChar, "staf01", 10, 1, 0, 0) GemRB.SetEquippedQuickSlot(MyChar, 0) # apply class/kit abilities GUICommon.ResolveClassAbilities(MyChar, ClassName) #LETS PLAY!! playmode = GemRB.GetVar("PlayMode") GemRB.SetVar("ImportedChar", 0) GUICommon.CloseOtherWindow(None) if playmode >= 0: CharGenCommon.close() if GemRB.GetVar("GUIEnhancements"): GemRB.SaveCharacter(GemRB.GetVar("Slot"), "gembak") GemRB.EnterGame() else: #show the export window GemRB.SetToken("NextScript", "CharGen") GemRB.SetNextScript("ExportFile")
def OpenSpellsWindow(actor, table, level, diff, kit=0, gen=0, recommend=True): """Opens the spells selection window. table should refer to the name of the classes MXSPLxxx.2da. level contains the current level of the actor. diff contains the difference from the old level. kit should always be GetKitIndex except when dualclassing. gen is true if this is for character generation. recommend is used in bg2 for spell recommendation / autopick.""" global SpellsWindow, DoneButton, SpellsSelectPointsLeft, Spells, chargen, SpellPointsLeftLabel global SpellsTextArea, SpellsKnownTable, SpellTopIndex, SpellBook, SpellLevel, pc, SpellStart global KitMask, EnhanceGUI, Memorization #enhance GUI? if (GemRB.GetVar("GUIEnhancements") & GE_SCROLLBARS): EnhanceGUI = 1 # save our pc pc = actor chargen = gen # this ensures compatibility with chargen, sorc, and dual-classing if kit == 0: KitMask = 0x4000 else: # need to implement this if converted to CharGen KitMask = kit # make sure there is an entry at the given level (bard) SpellsKnownTable = GemRB.LoadTable(table) if not SpellsKnownTable.GetValue(str(level), str(1), 1): if chargen: if GameCheck.IsBG2(): # HACK GemRB.SetNextScript("GUICG6") elif GameCheck.IsBG1(): # HACK from CharGenCommon import next next() return # load our window if chargen: GemRB.LoadWindowPack("GUICG", 640, 480) SpellsWindow = GemRB.LoadWindow(7) if not recommend: GUICommon.CloseOtherWindow(SpellsWindow.Unload) DoneButton = SpellsWindow.GetControl(0) SpellsTextArea = SpellsWindow.GetControl(27) SpellPointsLeftLabel = SpellsWindow.GetControl(0x1000001b) if (EnhanceGUI): SpellsWindow.CreateScrollBar(1000, 325, 42, 16, 252) HideUnhideScrollBar(1) SpellStart = 2 # cancel button only applicable for chargen SpellsCancelButton = SpellsWindow.GetControl(29) SpellsCancelButton.SetState(IE_GUI_BUTTON_ENABLED) SpellsCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellsCancelPress) SpellsCancelButton.SetText(13727) SpellsCancelButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) if (recommend): # recommended spell picks SpellsPickButton = SpellsWindow.GetControl(30) SpellsPickButton.SetState(IE_GUI_BUTTON_ENABLED) SpellsPickButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellsPickPress) SpellsPickButton.SetText(34210) else: SpellsWindow = GemRB.LoadWindow(8) DoneButton = SpellsWindow.GetControl(28) SpellsTextArea = SpellsWindow.GetControl(26) SpellPointsLeftLabel = SpellsWindow.GetControl(0x10000018) if (EnhanceGUI): SpellsWindow.CreateScrollBar(1000, 290, 142, 16, 252) HideUnhideScrollBar(1) #25th spell button for sorcerers SpellsWindow.CreateButton(24, 231, 345, 42, 42) SpellStart = 0 # setup our variables GemRB.SetVar("SpellTopIndex", 0) Memorization = 0 # the done button also doubles as a next button DoneButton.SetState(IE_GUI_BUTTON_DISABLED) DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellsDonePress) DoneButton.SetText(11973) DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) AlreadyShown = 0 for i in range(9): # make sure we always have a value to minus (bards) SecondPoints = SpellsKnownTable.GetValue(str(level - diff), str(i + 1), 1) if not SecondPoints: SecondPoints = 0 # make sure we get more spells of each class before continuing SpellsSelectPointsLeft[i] = SpellsKnownTable.GetValue( str(level), str(i + 1), 1) - SecondPoints if SpellsSelectPointsLeft[i] <= 0: continue elif chargen and KitMask != 0x4000: # specialists get an extra spell per level SpellsSelectPointsLeft[i] += 1 # chargen character seem to get more spells per level (this is kinda dirty hack) # except sorcerers if chargen and GemRB.GetPlayerStat(pc, IE_CLASS) != 19: SpellsSelectPointsLeft[i] += 1 # get all the spells of the given level Spells[i] = Spellbook.GetMageSpells( KitMask, GemRB.GetPlayerStat(pc, IE_ALIGNMENT), i + 1) # dump all the spells we already know NumDeleted = 0 for j in range(len(Spells[i])): CurrentIndex = j - NumDeleted # this ensure we don't go out of range if Spellbook.HasSpell(pc, IE_SPELL_TYPE_WIZARD, i, Spells[i][CurrentIndex][0]) >= 0: del Spells[i][CurrentIndex] NumDeleted += 1 # display these spells if it's the first non-zero level if AlreadyShown == 0: # save the level and spellbook data SpellLevel = i SpellBook = [0] * len(Spells[i]) if (EnhanceGUI): # setup the scrollbar ScrollBar = SpellsWindow.GetControl(1000) ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, ShowSpells) ScrollBar.SetDefaultScrollBar() # only scroll if we have more than 24 spells or 25 if extra 25th spell slot is available in sorcs LevelUp if len(Spells[i]) > (24 + ExtraSpellButtons()): HideUnhideScrollBar(0) if chargen: ScrollBar.SetVarAssoc( "SpellTopIndex", GUICommon.ceildiv((len(Spells[i]) - 24), 6) + 1) else: #there are five rows of 5 spells in level up of sorcs ScrollBar.SetVarAssoc( "SpellTopIndex", GUICommon.ceildiv((len(Spells[i]) - 25), 5) + 1) else: ScrollBar.SetVarAssoc("SpellTopIndex", 0) HideUnhideScrollBar(1) # show our spells ShowSpells() AlreadyShown = 1 # show the selection window if chargen: if recommend: SpellsWindow.SetVisible(WINDOW_VISIBLE) else: SpellsWindow.ShowModal(MODAL_SHADOW_NONE) else: SpellsWindow.ShowModal(MODAL_SHADOW_GRAY) return