From 8434db70b9dcd3a896d43838828ae53f41cb4690 Mon Sep 17 00:00:00 2001 From: Brad Allred Date: Fri, 30 Mar 2018 23:16:00 -0600 Subject: [PATCH] PST: fixish window loading they open... thats about it --- gemrb/GUIScripts/pst/GUIINV.py | 45 ++++++++++++--------------------- gemrb/GUIScripts/pst/GUIJRNL.py | 28 ++++---------------- gemrb/GUIScripts/pst/GUIMA.py | 27 ++++++-------------- gemrb/GUIScripts/pst/GUIMG.py | 4 +-- gemrb/GUIScripts/pst/GUIOPT.py | 18 +++++-------- gemrb/GUIScripts/pst/GUIPR.py | 29 ++++++++------------- gemrb/GUIScripts/pst/GUIREC.py | 33 +++++------------------- 7 files changed, 54 insertions(+), 130 deletions(-) diff --git a/gemrb/GUIScripts/pst/GUIINV.py b/gemrb/GUIScripts/pst/GUIINV.py index cae4a6ff66..f3405306fc 100644 --- a/gemrb/GUIScripts/pst/GUIINV.py +++ b/gemrb/GUIScripts/pst/GUIINV.py @@ -31,8 +31,6 @@ from ie_stats import * from ie_slots import * - -InventoryWindow = None ItemAmountWindow = None OverSlot = None @@ -58,24 +56,14 @@ # 0x10000000 + 63 - class -def OpenInventoryWindow (): +def InitInventoryWindow (Window): """Opens the inventory window.""" global AvSlotsTable - global InventoryWindow - - AvSlotsTable = GemRB.LoadTable ('avslots') - if GUICommon.CloseOtherWindow (OpenInventoryWindow): - if InventoryWindow: - InventoryWindow.Unload () - InventoryWindow = None - GemRB.SetVar ("OtherWindow", -1) - GUICommonWindows.SetSelectionChangeHandler (None) - return + Window.AddAlias("WIN_INV") - InventoryWindow = Window = GemRB.LoadWindow (3, "GUIINV") - GemRB.SetVar ("OtherWindow", InventoryWindow.ID) + AvSlotsTable = GemRB.LoadTable ('avslots') Window.GetControl(0x1000003d).AddAlias("MsgSys", 1) # inventory slots @@ -88,7 +76,7 @@ def OpenInventoryWindow (): color = {'r' : 128, 'g' : 128, 'b' : 255, 'a' : 64} Button.SetBorder (0,color,0,1) color['r'], color['b'] = color['b'], color['r'] - Button.SetBorde (1,color,0,1) + Button.SetBorder (1,color,0,1) Button.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON, MouseEnterSlot) Button.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON, MouseLeaveSlot) @@ -109,7 +97,7 @@ def OpenInventoryWindow (): Button.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON, InventoryCommon.MouseLeaveGround) ScrollBar = Window.GetControl (45) - ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RefreshInventoryWindow) + ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, lambda: RefreshInventoryWindow(Window)) for i in range (57, 64): Label = Window.GetControl (0x10000000 + i) @@ -143,20 +131,16 @@ def OpenInventoryWindow (): Label = Window.GetControl (0x1000003d) Label.SetTextColor(255, 255, 255) Label.SetText ("") - GemRB.SetVar ("TopIndex", 0) - GUICommonWindows.SetSelectionChangeHandler (UpdateInventoryWindow) - UpdateInventoryWindow () - GUICommonWindows.PortraitWindow.Focus() - GUICommonWindows.OptionsWindow.Focus() return -def UpdateInventoryWindow (): +def UpdateInventoryWindow (Window = None): """Redraws the inventory window and resets TopIndex.""" global ItemHash global slot_list - Window = InventoryWindow + if Window == None: + Window = GemRB.GetView("WIN_INV") GUICommonWindows.UpdateAnimation () @@ -168,7 +152,7 @@ def UpdateInventoryWindow (): if Count<1: Count=1 ScrollBar.SetVarAssoc ("TopIndex", Count) - RefreshInventoryWindow () + RefreshInventoryWindow (Window) # And now for the items .... ItemHash = {} @@ -181,13 +165,14 @@ def UpdateInventoryWindow (): for i in range (46): UpdateSlot (pc, i) +ToggleInventoryWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIINV", GUICommonWindows.ToggleWindow, InitInventoryWindow, UpdateInventoryWindow, WINDOW_TOP) +OpenInventoryWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIINV", GUICommonWindows.OpenWindowOnce, InitInventoryWindow, UpdateInventoryWindow, WINDOW_TOP) + InventoryCommon.UpdateInventoryWindow = UpdateInventoryWindow -def RefreshInventoryWindow (): +def RefreshInventoryWindow (Window): """Partial redraw without resetting TopIndex.""" - Window = InventoryWindow - pc = GemRB.GameGetSelectedPCSingle () # name @@ -199,7 +184,9 @@ def RefreshInventoryWindow (): Button = Window.GetControl (44) Button.SetPicture (GUICommonWindows.GetActorPortrait (pc, 'INVENTORY')) + Label = Window.GetControl (0x1000003a) GUICommon.SetEncumbranceLabels (Window, 46, None, pc, True) + Label = Window.GetControl (0x1000003a) # armor class ac = GemRB.GetPlayerStat (pc, IE_ARMORCLASS) @@ -270,7 +257,7 @@ def RefreshInventoryWindow (): return def UpdateSlot (pc, i): - Window = InventoryWindow + Window = GemRB.GetView("WIN_INV") # NOTE: there are invisible items (e.g. MORTEP) in inaccessible slots # used to assign powers and protections diff --git a/gemrb/GUIScripts/pst/GUIJRNL.py b/gemrb/GUIScripts/pst/GUIJRNL.py index 5464c52ce7..a0f63d1022 100644 --- a/gemrb/GUIScripts/pst/GUIJRNL.py +++ b/gemrb/GUIScripts/pst/GUIJRNL.py @@ -59,31 +59,12 @@ StartTime = 0 ################################################### -def OpenJournalWindow (): - global JournalWindow, PortraitWindow, ActionsWindow +def InitJournalWindow (JournalWindow): global StartTime Table = GemRB.LoadTable("YEARS") StartTime = Table.GetValue("STARTTIME", "VALUE") - - if GUICommon.CloseOtherWindow (OpenJournalWindow): - if LogWindow: OpenLogWindow() - if BeastsWindow: OpenBeastsWindow() - if QuestsWindow: OpenQuestsWindow() - - if JournalWindow: - JournalWindow.Unload() - #making the portraitwindow visible again - GUICommonWindows.EnableAnimatedWindows () - GemRB.SetVar ("OtherWindow", -1) - PortraitWindow = None - ActionsWindow = None - JournalWindow = None - - return - JournalWindow = GemRB.LoadWindow (0, "GUIJRNL") - GemRB.SetVar ("OtherWindow", JournalWindow.ID) GUICommonWindows.DisableAnimatedWindows () # Quests @@ -104,12 +85,13 @@ def OpenJournalWindow (): # Done Button = JournalWindow.GetControl (3) Button.SetText (20636) - Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenJournalWindow) + Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, lambda: JournalWindow.Close()) Button.MakeEscape() - Button.Focus() - #JournalWindow.Focus() + return +ToggleJournalWindow = GUICommonWindows.CreateTopWinLoader(0, "GUIJRNL", GUICommonWindows.ToggleWindow, InitJournalWindow) +OpenJournalWindow = GUICommonWindows.CreateTopWinLoader(0, "GUIJRNL", GUICommonWindows.OpenWindowOnce, InitJournalWindow) ################################################### def OpenQuestsWindow (): diff --git a/gemrb/GUIScripts/pst/GUIMA.py b/gemrb/GUIScripts/pst/GUIMA.py index e8a947e1b1..a6281b85df 100644 --- a/gemrb/GUIScripts/pst/GUIMA.py +++ b/gemrb/GUIScripts/pst/GUIMA.py @@ -33,21 +33,7 @@ PosY = 0 ################################################### -def OpenMapWindow (): - global MapWindow - - if GUICommon.CloseOtherWindow (OpenMapWindow): - if WorldMapWindow: OpenWorldMapWindowInside () - - if MapWindow: - MapWindow.Unload () - MapWindow = None - GemRB.SetVar ("OtherWindow", -1) - - return - - MapWindow = Window = GemRB.LoadWindow (3, "GUIMA") - GemRB.SetVar ("OtherWindow", MapWindow.ID) +def InitMapWindow (Window): # World Map Button = Window.GetControl (0) @@ -67,8 +53,7 @@ def OpenMapWindow (): # Map Control # ronote and usernote are the pins for the notes - # 4 is the Label's control ID - Map = Window.CreateMapControl (3, 24, 23, 480, 360, 4, "USERNOTE", "RONOTE") + Map = Window.CreateMapControl (3, 24, 23, 480, 360, Text, "USERNOTE", "RONOTE") GemRB.SetVar ("ShowMapNotes", IE_GUI_MAP_VIEW_NOTES) Map.SetVarAssoc ("ShowMapNotes", IE_GUI_MAP_VIEW_NOTES) @@ -87,9 +72,13 @@ def OpenMapWindow (): # Done Button = Window.GetControl (5) Button.SetText (1403) - Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenMapWindow) + Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, lambda: Window.Close()) Button.MakeEscape() - Button.Focus() + + return + +ToggleMapWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMA", GUICommonWindows.ToggleWindow, InitMapWindow, None, WINDOW_TOP) +OpenMapWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMA", GUICommonWindows.OpenWindowOnce, InitMapWindow, None, WINDOW_TOP) def NoteChanged (): #shift focus to the static label diff --git a/gemrb/GUIScripts/pst/GUIMG.py b/gemrb/GUIScripts/pst/GUIMG.py index f01d538a6e..745508374c 100644 --- a/gemrb/GUIScripts/pst/GUIMG.py +++ b/gemrb/GUIScripts/pst/GUIMG.py @@ -128,8 +128,8 @@ def UpdateMageWindow (Window=None): CantCast = CommonTables.ClassSkills.GetValue (GUICommon.GetClassRowName (pc), "MAGESPELL") == "*" # GUICommon.AdjustWindowVisibility (Window, pc, CantCast) -ToggleSpellWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMG", GUICommonWindows.ToggleWindow, InitMageWindow, UpdateMageWindow) -OpenSpellWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMG", GUICommonWindows.OpenWindowOnce, InitMageWindow, UpdateMageWindow) +ToggleSpellWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMG", GUICommonWindows.ToggleWindow, InitMageWindow, UpdateMageWindow, WINDOW_TOP) +OpenSpellWindow = GUICommonWindows.CreateTopWinLoader(3, "GUIMG", GUICommonWindows.OpenWindowOnce, InitMageWindow, UpdateMageWindow, WINDOW_TOP) def MagePrevLevelPress (): global MageSpellLevel diff --git a/gemrb/GUIScripts/pst/GUIOPT.py b/gemrb/GUIScripts/pst/GUIOPT.py index f9a95a619f..b18ab3ad87 100644 --- a/gemrb/GUIScripts/pst/GUIOPT.py +++ b/gemrb/GUIScripts/pst/GUIOPT.py @@ -48,22 +48,13 @@ QuitMsgWindow = None ################################################### -def OpenOptionsWindow (): +def InitOptionsWindow (Window): """Open main options window (peacock tail)""" - global OptionsWindow - - if GUICommon.CloseOtherWindow (OpenOptionsWindow): - GemRB.SetVar ("OtherWindow", -1) - GUICommonWindows.EnableAnimatedWindows () - - return GemRB.GamePause (1, 1) TrySavingConfiguration () CommonWindow.CloseContainerWindow () - OptionsWindow = Window = GemRB.LoadWindow (0, "GUIOPT") - GemRB.SetVar ("OtherWindow", OptionsWindow.ID) GUICommonWindows.DisableAnimatedWindows () def ConfigOptButton(button, strref, action): @@ -72,7 +63,7 @@ def ConfigOptButton(button, strref, action): button.SetFlags (IE_GUI_BUTTON_MULTILINE, OP_OR) # Return to Game - ConfigOptButton(Window.GetControl (0), 28638, OpenOptionsWindow) + ConfigOptButton(Window.GetControl (0), 28638, lambda: Window.Close()) # Quit Game ConfigOptButton(Window.GetControl (1), 2595, OpenQuitMsgWindow) @@ -101,6 +92,11 @@ def ConfigOptButton(button, strref, action): # game version, e.g. v1.1.0000 Label = Window.GetControl (0x10000007) Label.SetText (GemRB.GEMRB_VERSION) + + return + +ToggleOptionsWindow = GUICommonWindows.CreateTopWinLoader(0, "GUIOPT", GUICommonWindows.ToggleWindow, InitOptionsWindow) +OpenOptionsWindow = GUICommonWindows.CreateTopWinLoader(0, "GUIOPT", GUICommonWindows.OpenWindowOnce, InitOptionsWindow) def TrySavingConfiguration(): if not GemRB.SaveConfig(): diff --git a/gemrb/GUIScripts/pst/GUIPR.py b/gemrb/GUIScripts/pst/GUIPR.py index e22e741c02..7eda189eda 100644 --- a/gemrb/GUIScripts/pst/GUIPR.py +++ b/gemrb/GUIScripts/pst/GUIPR.py @@ -36,21 +36,7 @@ PriestSpellUnmemorizeWindow = None -def OpenPriestWindow (): - global PriestWindow - - if GUICommon.CloseOtherWindow (OpenPriestWindow): - if PriestWindow: - PriestWindow.Unload () - PriestWindow = None - GemRB.SetVar ("OtherWindow", -1) - - GUICommonWindows.SetSelectionChangeHandler (None) - return - - PriestWindow = Window = GemRB.LoadWindow (3, "GUIPR") - GemRB.SetVar ("OtherWindow", PriestWindow.ID) - +def InitPriestWindow (Window): Button = Window.GetControl (0) Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PriestPrevLevelPress) @@ -63,16 +49,17 @@ def OpenPriestWindow (): color = {'r' : 0, 'g' : 0, 'b' :0, 'a' : 160} Icon.SetBorder (0, color, 0, 1) - GUICommonWindows.SetSelectionChangeHandler (UpdatePriestWindow) - UpdatePriestWindow () + return -def UpdatePriestWindow (): +def UpdatePriestWindow (Window=None): global PriestMemorizedSpellList, PriestKnownSpellList + if Window == None: + Window = PriestSpellWindow + PriestMemorizedSpellList = [] PriestKnownSpellList = [] - Window = PriestWindow pc = GemRB.GameGetSelectedPCSingle () type = IE_SPELL_TYPE_PRIEST level = PriestSpellLevel @@ -143,6 +130,10 @@ def UpdatePriestWindow (): CantCast += GemRB.GetPlayerStat(pc, IE_DISABLEDBUTTON)&(1<