def OpenMageWindow():
    global MageWindow

    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()
        return

    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()
Exemple #2
0
def OpenJournalWindow():
    global StartTime, StartYear
    global JournalWindow, Chapter
    global PortraitWindow, OptionsWindow
    global OldPortraitWindow, OldOptionsWindow

    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")

    if GUICommon.CloseOtherWindow(OpenJournalWindow):
        GemRB.HideGUI()
        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
        GUICommonWindows.SetSelectionChangeHandler(None)
        return

    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)
    GemRB.LoadWindowPack("GUIJRNL", 800, 600)
    JournalWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", JournalWindow.ID)

    #saving the original portrait window
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow()
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                             OpenJournalWindow)
    Window.SetFrame()

    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")
    Window.SetVisible(WINDOW_VISIBLE)
    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    # this is here just so we redraw the portrait borders properly in case of reselection
    GUICommonWindows.SetSelectionChangeHandler(UpdateJournalWindow)
    UpdateJournalWindow()
Exemple #3
0
def OpenPriestWindow ():
	global PriestWindow

	if GUICommon.CloseOtherWindow (OpenPriestWindow):
		GemRB.HideGUI ()
		if PriestWindow:
			PriestWindow.Unload ()
		PriestWindow = None
		GemRB.SetVar ("OtherWindow", -1)
		
		GUICommonWindows.SetSelectionChangeHandler (None)
		GemRB.UnhideGUI ()
		return
		
	GemRB.HideGUI ()
	GemRB.LoadWindowPack ("GUIPR")
	PriestWindow = Window = GemRB.LoadWindow (3)
	GemRB.SetVar ("OtherWindow", PriestWindow.ID)

	Button = Window.GetControl (0)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PriestPrevLevelPress)

	Button = Window.GetControl (1)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PriestNextLevelPress)

	# 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 (UpdatePriestWindow)
	GemRB.UnhideGUI ()
	UpdatePriestWindow ()
Exemple #4
0
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
Exemple #5
0
def CloseStoreWindow():
    import GUIINV
    global StoreWindow, ActionWindow, PortraitWindow
    global OldPortraitWindow

    GemRB.SetVar("Inventory", 0)
    CloseWindows()
    if StoreWindow:
        StoreWindow.Unload()
    if ActionWindow:
        ActionWindow.Unload()
    if PortraitWindow:
        PortraitWindow.Unload()
    StoreWindow = None
    GemRB.LeaveStore()
    GUICommonWindows.PortraitWindow = OldPortraitWindow
    if Inventory:  # broken if available
        GUIINV.OpenInventoryWindow()
    else:
        GUICommon.GameWindow.SetVisible(
            WINDOW_VISIBLE)  #enabling the game control screen
        GemRB.UnhideGUI()  #enabling the other windows
        GUICommonWindows.SetSelectionChangeHandler(None)

    CureTable = None
    return
Exemple #6
0
def OpenStoreRumourWindow ():
	global StoreRumourWindow

	GemRB.SetVar ("TopIndex", 0)
	CloseWindows()

	StoreRumourWindow = Window = GemRB.LoadWindow (8)

	#removing those pesky labels
	for i in range (5):
		Window.DeleteControl (0x10000005+i)

	TextArea = Window.GetControl (11)
	TextArea.SetText (14144)

	#tavern quality image
	if GUICommon.GameIsBG1() or GUICommon.GameIsBG2():
		BAM = "TVRNQUL%d"% ((Store['StoreFlags']>>9)&3)
		Button = Window.GetControl (12)
		Button.SetSprites (BAM, 0, 0, 0, 0, 0)
		Button.SetState (IE_GUI_BUTTON_LOCKED)

	ScrollBar = Window.GetControl (5)
	ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, UpdateStoreRumourWindow)
	Count = Store['StoreDrinkCount']
	if Count>4:
		Count = Count-4
	else:
		Count = 0
	ScrollBar.SetVarAssoc ("TopIndex", Count+1)

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreRumourWindow )
	UpdateStoreRumourWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #7
0
def OpenStoreIdentifyWindow():
    global StoreIdentifyWindow

    GemRB.SetVar("Index", -1)
    GemRB.SetVar("TopIndex", 0)
    CloseWindows()

    StoreIdentifyWindow = Window = GemRB.LoadWindow(5)

    # Identify
    Button = Window.GetControl(4)
    Button.SetText(44971)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, IdentifyPressed)
    Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoIdentifyWindow)

    # price ...
    Label = Window.GetControl(0x10000001)
    Label.SetText("0")

    # 8-11 item slots, 0x1000000c-f labels
    for i in range(4):
        Button = Window.GetControl(i + 6)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 128, 160, 0, 1)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RedrawStoreIdentifyWindow)
        Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoIdentifyWindow)

    ScrollBar = Window.GetControl(5)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreIdentifyWindow)

    GUICommonWindows.SetSelectionChangeHandler(UpdateStoreIdentifyWindow)
    UpdateStoreIdentifyWindow()
    Window.SetVisible(WINDOW_VISIBLE)
    return
Exemple #8
0
def OpenStoreDonateWindow():
    global StoreDonateWindow

    CloseWindows()

    StoreDonateWindow = Window = GemRB.LoadWindow(10)

    ## graphics
    #Button = Window.GetControl (10)
    #Button.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_PLAYONCE, OP_OR)
    #Button.SetState (IE_GUI_BUTTON_LOCKED)

    # Donate
    Button = Window.GetControl(2)
    Button.SetText(45307)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonateGold)
    Button.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # Entry
    Field = Window.GetControl(3)
    Field.SetText("0")
    Field.SetEvent(IE_GUI_EDIT_ON_CHANGE, UpdateStoreDonateWindow)
    Field.SetStatus(IE_GUI_EDIT_NUMBER | IE_GUI_CONTROL_FOCUSED)

    # +
    Button = Window.GetControl(4)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, IncrementDonation)
    # -
    Button = Window.GetControl(5)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DecrementDonation)

    GUICommonWindows.SetSelectionChangeHandler(UpdateStoreDonateWindow)
    UpdateStoreDonateWindow()
    Window.SetVisible(WINDOW_VISIBLE)
    return
Exemple #9
0
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
Exemple #10
0
def OpenStoreStealWindow ():
	global StoreStealWindow
	global LeftButton

	GemRB.SetVar ("RightIndex", 0)
	GemRB.SetVar ("LeftIndex", 0)
	GemRB.SetVar ("RightTopIndex", 0)
	GemRB.SetVar ("LeftTopIndex", 0)
	CloseWindows()

	StoreStealWindow = Window = GemRB.LoadWindow (6)

	# left scrollbar
	ScrollBarLeft = Window.GetControl (9)
	ScrollBarLeft.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreStealWindow)

	# right scrollbar
	ScrollBarRight = Window.GetControl (10)
	ScrollBarRight.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreStealWindow)

	for i in range (ItemButtonCount):
		Button = Window.GetControl (i+4)
		if GUICommon.GameIsBG2():
			Button.SetBorder (0,0,0,0,0,0,0,128,160,0,1)
		else:
			Button.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RedrawStoreStealWindow)
		Button.AttachScrollBar (ScrollBarLeft)

		Button = Window.GetControl (i+11)
		if GUICommon.GameIsBG2():
			Button.SetBorder (0,0,0,0,0,0,0,128,160,0,1)
		else:
			Button.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
		Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoRightWindow)
		Button.SetFont ("NUMBER")
		Button.SetFlags (IE_GUI_BUTTON_ALIGN_RIGHT|IE_GUI_BUTTON_ALIGN_TOP, OP_OR)
		Button.AttachScrollBar (ScrollBarRight)

	# Steal
	LeftButton = Button = Window.GetControl (1)
	Button.SetText (14179)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, StealPressed)

	Button = Window.GetControl (37)
	Button.SetState (IE_GUI_BUTTON_LOCKED)

	# encumbrance
	Label = Window.CreateLabel (0x10000043, 15,325,60,15,"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP)
	Label = Window.CreateLabel (0x10000044, 15,365,80,15,"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_TOP)

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreStealWindow )
	UpdateStoreStealWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #11
0
def OpenStoreIdentifyWindow ():
	global StoreIdentifyWindow
	global LeftButton

	GemRB.SetVar ("Index", -1)
	GemRB.SetVar ("TopIndex", 0)
	CloseWindows()

	StoreIdentifyWindow = Window = GemRB.LoadWindow (4)

	ScrollBar = Window.GetControl (7)
	ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreIdentifyWindow)

	TextArea = Window.GetControl (23)
	TextArea.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL)

	# Identify
	LeftButton = Button = Window.GetControl (5)
	Button.SetText (14133)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, IdentifyPressed)
	Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoIdentifyWindow)

	# price ...
	Label = Window.GetControl (0x10000003)
	Label.SetText ("0")

	# 8-11 item slots, 0x1000000c-f labels
	for i in range (ItemButtonCount):
		Button = Window.GetControl (i+8)
		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
		if GameCheck.IsIWD1() or GameCheck.IsIWD2():
			Button.SetSprites ("GUISTMSC", 0, 1,2,0,3)
			Button.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
		elif GameCheck.IsBG1():
			Button.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
		else:
			Button.SetBorder (0,0,0,0,0,0,0,128,160,0,1)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, SelectID)
		Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoIdentifyWindow)
		Button.SetFont ("NUMBER")
		Button.SetFlags (IE_GUI_BUTTON_ALIGN_RIGHT|IE_GUI_BUTTON_ALIGN_BOTTOM, OP_OR)
		Button.AttachScrollBar (ScrollBar)

	UnselectNoRedraw ()

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreIdentifyWindow )
	UpdateStoreIdentifyWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #12
0
def OpenStoreRentWindow ():
	global StoreRentWindow

	CloseWindows()

	StoreRentWindow = Window = GemRB.LoadWindow (7)

	# room types
	RentIndex = -1
	for i in range (4):
		ok = Store['StoreRoomPrices'][i]
		if ok >= 0:
			RentIndex = i
			break

	# RentIndex needs to be set before SetVarAssoc
	GemRB.SetVar ("RentIndex", RentIndex)

	for i in range (4):
		ok = Store['StoreRoomPrices'][i]
		Button = Window.GetControl (i)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateStoreRentWindow)
		if ok<0:
			Button.SetState (IE_GUI_BUTTON_DISABLED) #disabled room icons are selected, not disabled
		else:
			Button.SetVarAssoc ("RentIndex", i)

		Button = Window.GetControl (i+4)
		Button.SetText (14294+i)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateStoreRentWindow)
		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
		Button.SetVarAssoc ("RentIndex", i)
		if GameCheck.IsBG1():
			#these bioware guys screw up everything possible
			#remove this line if you fixed guistore
			Button.SetSprites ("GUISTROC",0, 1,2,0,3)
		if ok<0:
			Button.SetState (IE_GUI_BUTTON_DISABLED)

	# Rent
	Button = Window.GetControl (11)
	Button.SetText (14293)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RentRoom)

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreRentWindow )
	UpdateStoreRentWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #13
0
def OpenStoreStealWindow ():
	global StoreStealWindow
	global LeftButton

	GemRB.SetVar ("RightIndex", 0)
	GemRB.SetVar ("LeftIndex", 0)
	CloseWindows()

	StoreStealWindow = Window = GemRB.LoadWindow (7)

	for i in range (4):
		Button = Window.GetControl (i+5)
		Button.SetBorder (0,0,0,0,0,128,0,0,100,0,1)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RedrawStoreStealWindow)

		Button = Window.GetControl (i+14)
		Button.SetBorder (0,0,0,0,0,128,0,0,100,0,1)
		Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoRightWindow)

	# Steal
	LeftButton = Button = Window.GetControl (0)
	Button.SetText (45305)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, StealPressed)

	# encumbrance
	Button = Window.GetControl (22)
	Button.SetState (IE_GUI_BUTTON_LOCKED)
	GUICommon.SetEncumbranceLabels (Window, 22, None, GemRB.GameGetSelectedPCSingle (), True)
	Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)
	Button.SetFont ('NUMBER')

	#Label = Window.CreateLabel (0x10000043, 15,325,60,15,"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP)
	#Label = Window.CreateLabel (0x10000044, 15,365,80,15,"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_TOP)

	# left scrollbar
	ScrollBar = Window.GetControl (4)
	ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreStealWindow)

	# right scrollbar
	ScrollBar = Window.GetControl (13)
	ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreStealWindow)

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreStealWindow )
	UpdateStoreStealWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #14
0
def OpenStoreHealWindow ():
	global StoreHealWindow

	GemRB.SetVar ("Index", -1)
	GemRB.SetVar ("TopIndex", 0)
	CloseWindows()

	StoreHealWindow = Window = GemRB.LoadWindow (5)

	ScrollBar = Window.GetControl (7)
	ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, UpdateStoreHealWindow)

	#spell buttons
	for i in range (ItemButtonCount):
		Button = Window.GetControl (i+8)
		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateStoreHealWindow)
		Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoHealWindow)
		#Button.AttachScrollBar (ScrollBar)

	UnselectNoRedraw ()

	# price tag
	Label = Window.GetControl (0x10000003)
	Label.SetText ("0")

	# Heal
	Button = Window.GetControl (5)
	Button.SetText (13703)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, BuyHeal)
	Button.SetState (IE_GUI_BUTTON_DISABLED)

	Count = Store['StoreCureCount']
	if Count>4:
		Count = Count-4
	else:
		Count = 0
	ScrollBar.SetVarAssoc ("TopIndex", Count)

	GUICommonWindows.SetSelectionChangeHandler( UpdateStoreHealWindow )
	UpdateStoreHealWindow ()
	Window.SetVisible (WINDOW_VISIBLE)
	return
Exemple #15
0
def CloseOptionsWindow ():
	global GameOptionsWindow, OptionsWindow
	global OldOptionsWindow

	if GameOptionsWindow == None:
		return

	if GameOptionsWindow:
		GameOptionsWindow.Unload ()
	if OptionsWindow:
		OptionsWindow.Unload ()

	GameOptionsWindow = None
	GUICommonWindows.SetSelectionChangeHandler (None)
	GemRB.SetVar ("OtherWindow", -1)
	GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
	GUICommonWindows.OptionsWindow = OldOptionsWindow
	OldOptionsWindow = None
	return
Exemple #16
0
def OpenRecordsWindow():
    import GUICommonWindows

    global RecordsWindow, OptionsWindow, PortraitWindow, PauseState
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenRecordsWindow):
        if InformationWindow: OpenInformationWindow()

        GUIRECCommon.CloseSubSubCustomizeWindow()
        GUIRECCommon.CloseSubCustomizeWindow()
        GUIRECCommon.CloseCustomizeWindow()
        GUIRECCommon.ExportCancelPress()
        GUIRECCommon.CloseBiographyWindow()
        KitDonePress()
        CloseInformationWindow()

        if RecordsWindow:
            RecordsWindow.Unload()
        if OptionsWindow:
            OptionsWindow.Unload()
        if PortraitWindow:
            PortraitWindow.Unload()

        RecordsWindow = None
        GemRB.SetVar("OtherWindow", -1)
        GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
        GemRB.UnhideGUI()
        GUICommonWindows.PortraitWindow = OldPortraitWindow
        OldPortraitWindow = None
        GUICommonWindows.UpdatePortraitWindow()
        GUICommonWindows.OptionsWindow = OldOptionsWindow
        OldOptionsWindow = None
        GUICommonWindows.SetSelectionChangeHandler(None)
        GemRB.GamePause(PauseState, 3)
        return

    PauseState = GemRB.GamePause(3, 1)
    GemRB.GamePause(1, 3)

    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)

    GemRB.LoadWindowPack("GUIREC", 640, 480)
    RecordsWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", RecordsWindow.ID)
    # saving the original portrait window
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                             OpenRecordsWindow)
    GUICommonWindows.MarkMenuButton(OptionsWindow)
    OptionsWindow.SetFrame()
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow(0)

    # dual class
    Button = Window.GetControl(0)
    Button.SetText(7174)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DualClass.DualClassWindow)

    # levelup
    Button = Window.GetControl(37)
    Button.SetText(7175)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, LevelUp.OpenLevelUpWindow)

    # information
    Button = Window.GetControl(1)
    Button.SetText(11946)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenInformationWindow)

    # reform party
    Button = Window.GetControl(51)
    Button.SetText(16559)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenRecReformPartyWindow)

    # customize
    Button = Window.GetControl(50)
    Button.SetText(10645)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenCustomizeWindow)

    # export
    Button = Window.GetControl(36)
    Button.SetText(13956)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenExportWindow)

    # kit info
    if GameCheck.IsBG2():
        Button = Window.GetControl(52)
        Button.SetText(61265)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenKitInfoWindow)

    # 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, OpenRecordsWindow)
    Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)

    GUICommonWindows.SetSelectionChangeHandler(UpdateRecordsWindow)
    UpdateRecordsWindow()

    Window.SetKeyPressEvent(GUICommonWindows.SwitchPCByKey)

    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    Window.SetVisible(WINDOW_VISIBLE)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    return
Exemple #17
0
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
Exemple #18
0
def InitInventoryWindow(Window):
    """Opens the inventory window."""

    Window.AddAlias("WIN_INV")
    Window.GetControl(0x1000003f).AddAlias("MsgSys", 1)

    #ground items scrollbar
    ScrollBar = Window.GetControl(66)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE,
                       lambda: RefreshInventoryWindow(Window))

    #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("ItemButton", i + 68)
        Button.SetSprites("STONSLOT", 0, 0, 1, 2, 3)

    #major & minor clothing color
    Button = Window.GetControl(62)
    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.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.SetAction(InventoryCommon.OnAutoEquip, IE_ACT_DRAG_DROP_DST)

    #encumbrance
    Button = Window.GetControl(67)
    Button.CreateLabel(
        0x10000043, "NUMBER", "0:",
        IE_FONT_ALIGN_LEFT | IE_FONT_ALIGN_TOP | IE_FONT_SINGLE_LINE)
    Button.CreateLabel(
        0x10000044, "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)
            Button.SetSprites("STONSLOT", 0, 0, 1, 2, 3)

    GemRB.SetVar("TopIndex", 0)
    GUICommonWindows.SetSelectionChangeHandler(UpdateInventoryWindow)

    return
Exemple #19
0
def OpenOptionsWindow():
    """Open main options window"""

    global GameOptionsWindow, OptionsWindow, PortraitWindow
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenOptionsWindow):
        CloseOptionsWindow()
        return

    GemRB.GamePause(1, 3)

    CommonWindow.CloseContainerWindow()
    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)
    if GameCheck.IsBG1():
        GUICommonWindows.SetSelectionChangeHandler(None)

    GemRB.LoadWindowPack("GUIOPT", WIDTH, HEIGHT)
    GameOptionsWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", GameOptionsWindow.ID)

    if OldOptionsWindow == None:
        # OptionsWindow is the leftmost menu bar window present in most of the games
        OldOptionsWindow = GUICommonWindows.OptionsWindow
        OptionsWindow = GemRB.LoadWindow(0)
        GUICommonWindows.MarkMenuButton(OptionsWindow)
        GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                                 OpenOptionsWindow)
        OptionsWindow.SetFrame()
        if not GameCheck.IsBG1(
        ):  #not in PST either, but it has its own OpenOptionsWindow()
            OptionsWindow.SetFrame()
            #saving the original portrait window
            OldPortraitWindow = GUICommonWindows.PortraitWindow
            PortraitWindow = GUICommonWindows.OpenPortraitWindow(0)

    # Return to Game
    Button = Window.GetControl(11)
    Button.SetText(10308)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenOptionsWindow)
    Button.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)

    # Quit Game
    Button = Window.GetControl(10)
    Button.SetText(13731)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenQuitMsgWindow)

    # Load Game
    Button = Window.GetControl(5)
    Button.SetText(13729)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenLoadMsgWindow)

    # Save Game
    Button = Window.GetControl(6)
    Button.SetText(13730)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenSaveMsgWindow)

    # Video Options
    Button = Window.GetControl(7)
    Button.SetText(17162)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenVideoOptionsWindow)

    # Audio Options
    Button = Window.GetControl(8)
    Button.SetText(17164)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenAudioOptionsWindow)

    # Gameplay Options
    Button = Window.GetControl(9)
    Button.SetText(17165)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenGameplayOptionsWindow)

    # game version, e.g. v1.1.0000
    VersionLabel = Window.GetControl(0x1000000b)
    VersionLabel.SetText(GEMRB_VERSION)

    if GameCheck.IsIWD2():
        # Keyboard shortcuts
        KeyboardButton = Window.GetControl(13)
        KeyboardButton.SetText(33468)
        KeyboardButton.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OpenHotkeyOptionsWindow)

        # Movies
        MoviesButton = Window.GetControl(14)
        MoviesButton.SetText(15415)
        MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenMovieWindow)

    RestoreWinVisibility()

    return
Exemple #20
0
def OpenPriestWindow():
    import GUICommonWindows
    global PriestWindow, OptionsWindow, PortraitWindow, PriestSpellInfoWindow
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenPriestWindow):
        ClosePriestSpellUnmemorizeWindow()
        if PriestSpellInfoWindow:
            PriestSpellInfoWindow.Unload()
            PriestSpellInfoWindow = None
        if PriestWindow:
            PriestWindow.Unload()
        if OptionsWindow:
            OptionsWindow.Unload()
        if PortraitWindow:
            PortraitWindow.Unload()

        PriestWindow = 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("GUIPR", 640, 480)
    PriestWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", PriestWindow.ID)
    #saving the original portrait window
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.MarkMenuButton(OptionsWindow)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                             OpenPriestWindow)
    OptionsWindow.SetFrame()
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow(0)

    Button = Window.GetControl(1)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, PriestPrevLevelPress)

    Button = Window.GetControl(2)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, PriestNextLevelPress)

    #setup level buttons
    if GameCheck.IsBG2():
        for i in range(7):
            Button = Window.GetControl(55 + i)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RefreshPriestLevel)
            Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

        for i in range(7):
            Button = Window.GetControl(55 + i)
            Button.SetVarAssoc("PriestSpellLevel", i)

    # Setup memorized spells buttons
    for i in range(12):
        Button = Window.GetControl(3 + i)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 1)
        Button.SetSprites("SPELFRAM", 0, 0, 0, 0, 0)
        Button.SetFlags(
            IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE
            | IE_GUI_BUTTON_PLAYALWAYS, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)

    # Setup book spells buttons
    for i in range(GUICommon.GetGUISpellButtonCount()):
        Button = Window.GetControl(27 + i)
        Button.SetFlags(
            IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PLAYONCE
            | IE_GUI_BUTTON_PLAYALWAYS, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)

    GUICommonWindows.SetSelectionChangeHandler(UpdatePriestWindow)
    UpdatePriestWindow()
    return
Exemple #21
0
def OpenRecordsWindow():
    global RecordsWindow
    global StatTable

    StatTable = GemRB.LoadTable("abcomm")

    if GUICommon.CloseOtherWindow(OpenRecordsWindow):
        GemRB.HideGUI()
        if InformationWindow: OpenInformationWindow()

        if RecordsWindow:
            RecordsWindow.Unload()
        RecordsWindow = None
        GemRB.SetVar("OtherWindow", -1)
        GUICommonWindows.SetSelectionChangeHandler(None)

        GemRB.UnhideGUI()
        return

    GemRB.HideGUI()
    GemRB.LoadWindowPack("GUIREC")
    RecordsWindow = Window = GemRB.LoadWindow(3)
    GemRB.SetVar("OtherWindow", RecordsWindow.ID)

    # Information
    Button = Window.GetControl(7)
    Button.SetText(4245)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenInformationWindow)

    # Reform Party
    Button = Window.GetControl(8)
    Button.SetText(4244)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIWORLD.OpenReformPartyWindow)

    # Level Up
    Button = Window.GetControl(9)
    Button.SetText(4246)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenLevelUpWindow)

    statevents = (OnRecordsHelpStrength, OnRecordsHelpIntelligence,
                  OnRecordsHelpWisdom, OnRecordsHelpDexterity,
                  OnRecordsHelpConstitution, OnRecordsHelpCharisma)
    # stat buttons
    for i in range(6):
        Button = Window.GetControl(31 + i)
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
        Button.SetSprites("", 0, 0, 0, 0, 0)
        Button.SetState(IE_GUI_BUTTON_LOCKED)
        Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, statevents[i])
        Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave)

    # AC button
    Button = Window.GetControl(37)
    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
    Button.SetSprites("", 0, 0, 0, 0, 0)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpArmorClass)
    Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave)

    # HP button
    Button = Window.GetControl(38)
    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
    Button.SetSprites("", 0, 0, 0, 0, 0)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpHitPoints)
    Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave)

    GUICommonWindows.SetSelectionChangeHandler(UpdateRecordsWindow)
    UpdateRecordsWindow()

    GemRB.UnhideGUI()
Exemple #22
0
def OpenSpellBookWindow():
    global SpellBookWindow, OptionsWindow, PortraitWindow
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenSpellBookWindow):
        if SpellBookWindow:
            SpellBookWindow.Unload()
        if OptionsWindow:
            OptionsWindow.Unload()
        if PortraitWindow:
            PortraitWindow.Unload()

        SpellBookWindow = 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("GUISPL", 800, 600)
    SpellBookWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", SpellBookWindow.ID)
    #saving the original portrait window
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow()
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                             OpenSpellBookWindow)
    Window.SetFrame()

    Button = Window.GetControl(92)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellBookPrevPress)

    Button = Window.GetControl(93)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellBookNextPress)

    #setup level buttons
    for i in range(9):
        Button = Window.GetControl(55 + i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RefreshSpellBookLevel)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        Button.SetVarAssoc("SpellBookSpellLevel", i)

    # Setup memorized spells buttons
    for i in range(24):
        Button = Window.GetControl(6 + i)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 1)
        #Button.SetBAM ("SPELFRAM",0,0,0)
        Button.SetFlags(
            IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE
            | IE_GUI_BUTTON_NO_IMAGE, OP_OR)

    # Setup book spells buttons
    for i in range(8):
        Button = Window.GetControl(30 + i)
        Button.SetFlags(IE_GUI_BUTTON_PLAYONCE, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)
        Button.SetVarAssoc("SpellIndex", i)

    GUICommonWindows.SetSelectionChangeHandler(SelectedNewPlayer)
    SelectedNewPlayer()
    return
Exemple #23
0
def OpenInventoryWindow ():
	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)

		if InventoryWindow:
			InventoryWindow.Unload ()
		if OptionsWindow:
			OptionsWindow.Unload ()
		if PortraitWindow:
			PortraitWindow.Unload ()

		InventoryWindow = None
		GemRB.SetVar ("OtherWindow", -1)
		GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
		GemRB.UnhideGUI ()
		GUICommonWindows.PortraitWindow = OldPortraitWindow
		GUICommonWindows.UpdatePortraitWindow ()
		OldPortraitWindow = None
		GUICommonWindows.OptionsWindow = OldOptionsWindow
		OldOptionsWindow = None
		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.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,1,2,3)

	#major & minor clothing color
	Button = Window.GetControl (62)
	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.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"],15,
		"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP)
	Label = Window.CreateLabel (0x10000044, r["X"],r["Y"]+r["Height"]-15,r["Width"],15,
		"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_BOTTOM)

	#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)
			Button.SetSprites ("STONSLOT",0,0,1,2,3)

	GemRB.SetVar ("TopIndex", 0)
	GUICommonWindows.SetSelectionChangeHandler (UpdateInventoryWindow)
	UpdateInventoryWindow ()
	OptionsWindow.SetVisible (WINDOW_VISIBLE)
	Window.SetVisible (WINDOW_FRONT)
	PortraitWindow.SetVisible (WINDOW_VISIBLE)
	return
Exemple #24
0
def OpenRecordsWindow():
    import GUICommonWindows

    global RecordsWindow, OptionsWindow, PortraitWindow
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenRecordsWindow):
        if InformationWindow: OpenInformationWindow()

        if RecordsWindow:
            RecordsWindow.Unload()
        if OptionsWindow:
            OptionsWindow.Unload()
        if PortraitWindow:
            PortraitWindow.Unload()

        RecordsWindow = None
        GemRB.SetVar("OtherWindow", -1)
        GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
        GemRB.UnhideGUI()
        GUICommonWindows.PortraitWindow = OldPortraitWindow
        OldPortraitWindow = None
        GUICommonWindows.UpdatePortraitWindow()
        GUICommonWindows.OptionsWindow = OldOptionsWindow
        OldOptionsWindow = None
        GUICommonWindows.SetSelectionChangeHandler(None)
        return

    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)

    GemRB.LoadWindowPack("GUIREC", 640, 480)
    RecordsWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", RecordsWindow.ID)
    # saving the original portrait window
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0,
                                             OpenRecordsWindow)
    GUICommonWindows.MarkMenuButton(OptionsWindow)
    OptionsWindow.SetFrame()
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow(0)

    # dual class
    Button = Window.GetControl(0)
    Button.SetText(7174)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DualClass.DualClassWindow)

    # levelup
    Button = Window.GetControl(37)
    Button.SetText(7175)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, LevelUp.OpenLevelUpWindow)

    # information
    Button = Window.GetControl(1)
    Button.SetText(11946)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenInformationWindow)

    # reform party
    Button = Window.GetControl(51)
    Button.SetText(16559)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenRecReformPartyWindow)

    # customize
    Button = Window.GetControl(50)
    Button.SetText(10645)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenCustomizeWindow)

    # export
    Button = Window.GetControl(36)
    Button.SetText(13956)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenExportWindow)

    # kit info
    if GameCheck.IsBG2():
        Button = Window.GetControl(52)
        Button.SetText(61265)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenKitInfoWindow)

    GUICommonWindows.SetSelectionChangeHandler(UpdateRecordsWindow)
    UpdateRecordsWindow()

    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    Window.SetVisible(WINDOW_VISIBLE)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    return
Exemple #25
0
def OpenInventoryWindow():
    """Opens the inventory window."""

    global AvSlotsTable
    global InventoryWindow, PauseState

    AvSlotsTable = GemRB.LoadTable('avslots')

    if GUICommon.CloseOtherWindow(OpenInventoryWindow):
        GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
        if InventoryWindow:
            InventoryWindow.Unload()
        InventoryWindow = None
        GemRB.SetVar("OtherWindow", -1)
        GemRB.SetVar("MessageLabel", -1)
        GUICommonWindows.SetSelectionChangeHandler(None)
        GemRB.UnhideGUI()
        GemRB.GamePause(PauseState, 3)
        return

    PauseState = GemRB.GamePause(3, 1)
    GemRB.GamePause(1, 3)

    GemRB.HideGUI()
    GemRB.LoadWindowPack("GUIINV")
    InventoryWindow = Window = GemRB.LoadWindow(3)
    GemRB.SetVar("OtherWindow", InventoryWindow.ID)
    GemRB.SetVar("MessageLabel", Window.GetControl(0x1000003d).ID)

    # inventory slots
    for i in range(44):
        Button = Window.GetControl(i)
        Button.SetFlags(IE_GUI_BUTTON_ALIGN_RIGHT | IE_GUI_BUTTON_ALIGN_BOTTOM,
                        OP_OR)
        Button.SetFont("NUMBER")
        Button.SetVarAssoc("ItemButton", i)
        Button.SetBorder(0, 0, 0, 0, 0, 128, 128, 255, 64, 0, 1)
        Button.SetBorder(1, 0, 0, 0, 0, 255, 128, 128, 64, 0, 1)
        Button.SetEvent(IE_GUI_MOUSE_ENTER_BUTTON, MouseEnterSlot)
        Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, MouseLeaveSlot)

    # Ground Item
    for i in range(10):
        Button = Window.GetControl(i + 47)
        Button.SetVarAssoc("GroundItemButton", i)
        Button.SetFlags(IE_GUI_BUTTON_ALIGN_RIGHT | IE_GUI_BUTTON_ALIGN_BOTTOM,
                        OP_OR)
        Button.SetFont("NUMBER")
        Button.SetBorder(0, 0, 0, 0, 0, 128, 128, 255, 64, 0, 1)
        Button.SetBorder(1, 0, 0, 0, 0, 255, 128, 128, 64, 0, 1)
        Button.SetEvent(IE_GUI_MOUSE_ENTER_BUTTON,
                        InventoryCommon.MouseEnterGround)
        Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON,
                        InventoryCommon.MouseLeaveGround)

    ScrollBar = Window.GetControl(45)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RefreshInventoryWindow)

    for i in range(57, 64):
        Label = Window.GetControl(0x10000000 + i)
        Label.SetText(str(i))

    # portrait
    Button = Window.GetControl(44)
    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, OnAutoEquip)

    # encumbrance
    Button = Window.GetControl(46)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
    Button.SetFont('NUMBER')

    # armor class
    Label = Window.GetControl(0x1000003a)
    Label.SetTooltip(4197)

    # hp current
    Label = Window.GetControl(0x1000003b)
    Label.SetTooltip(4198)

    # hp max
    Label = Window.GetControl(0x1000003c)
    Label.SetTooltip(4199)

    # 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)

    # info label, game paused, etc
    Label = Window.GetControl(0x1000003d)
    Label.SetTextColor(255, 255, 255)
    Label.SetText("")
    GemRB.SetVar("TopIndex", 0)
    GUICommonWindows.SetSelectionChangeHandler(UpdateInventoryWindow)
    UpdateInventoryWindow()

    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)
    GUICommonWindows.PortraitWindow.SetVisible(WINDOW_VISIBLE)
    GUICommonWindows.OptionsWindow.SetVisible(WINDOW_VISIBLE)
    return
Exemple #26
0
def OpenRecordsWindow ():
	global RecordsWindow, OptionsWindow, PortraitWindow
	global OldPortraitWindow, OldOptionsWindow, SelectWindow
	global BonusSpellTable, HateRaceTable

	if GUICommon.CloseOtherWindow (OpenRecordsWindow):
		if RecordsWindow:
			RecordsWindow.Unload ()
		if OptionsWindow:
			OptionsWindow.Unload ()
		if PortraitWindow:
			PortraitWindow.Unload ()

		RecordsWindow = 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 ("GUIREC", 800, 600)
	RecordsWindow = Window = GemRB.LoadWindow (2)
	GemRB.SetVar ("OtherWindow", RecordsWindow.ID)
	#saving the original portrait window
	OldPortraitWindow = GUICommonWindows.PortraitWindow
	PortraitWindow = GUICommonWindows.OpenPortraitWindow ()
	OldOptionsWindow = GUICommonWindows.OptionsWindow
	OptionsWindow = GemRB.LoadWindow (0)
	GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 0, OpenRecordsWindow)
	Window.SetFrame ()

	if not BonusSpellTable:
		BonusSpellTable = GemRB.LoadTable ("mxsplbon")
	if not HateRaceTable:
		HateRaceTable = GemRB.LoadTable ("haterace")

	#portrait icon
	Button = Window.GetControl (2)
	Button.SetState (IE_GUI_BUTTON_LOCKED)
	Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET)

	#information (help files)
	Button = Window.GetControl (1)
	Button.SetText (11946)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenHelpWindow)

	#biography
	Button = Window.GetControl (59)
	Button.SetText (18003)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenBiographyWindow)

	#export
	Button = Window.GetControl (36)
	Button.SetText (13956)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenExportWindow)

	#customize
	Button = Window.GetControl (50)
	Button.SetText (10645)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, GUIRECCommon.OpenCustomizeWindow)

	#general
	GemRB.SetVar ("SelectWindow", 1)

	Button = Window.GetControl (60)
	Button.SetTooltip (40316)
	Button.SetVarAssoc ("SelectWindow", 1)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateRecordsWindow)

	#weapons and armour
	Button = Window.GetControl (61)
	Button.SetTooltip (40317)
	Button.SetVarAssoc ("SelectWindow", 2)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateRecordsWindow)

	#skills and feats
	Button = Window.GetControl (62)
	Button.SetTooltip (40318)
	Button.SetVarAssoc ("SelectWindow", 3)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateRecordsWindow)

	#miscellaneous
	Button = Window.GetControl (63)
	Button.SetTooltip (33500)
	Button.SetVarAssoc ("SelectWindow", 4)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateRecordsWindow)

	#level up
	Button = Window.GetControl (37)
	Button.SetText (7175)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateRecordsWindow) #TODO: OpenLevelUpWindow

	GUICommonWindows.SetSelectionChangeHandler (UpdateRecordsWindow)

	UpdateRecordsWindow ()
	return
Exemple #27
0
def OpenJournalWindow ():
	import GUICommonWindows
	global JournalWindow, OptionsWindow, PortraitWindow
	global OldPortraitWindow, OldOptionsWindow
	global StartTime, StartYear
	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
		GUICommonWindows.SetSelectionChangeHandler (None)
		return
		
	Table = GemRB.LoadTable("YEARS")
	StartTime = Table.GetValue("STARTTIME", "VALUE") / 4500
	StartYear = Table.GetValue("STARTYEAR", "VALUE")

	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.MarkMenuButton (OptionsWindow)
	GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 0, OpenJournalWindow)
	OptionsWindow.SetFrame ()
	OldPortraitWindow = GUICommonWindows.PortraitWindow
	PortraitWindow = GUICommonWindows.OpenPortraitWindow (0)

	# prev. chapter
	Button = JournalWindow.GetControl (3)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PrevChapterPress)

	# next chapter
	Button = JournalWindow.GetControl (4)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, NextChapterPress)

	GemRB.SetVar ("Section", Section)
	# Quests
	Button = JournalWindow.GetControl (6)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetVarAssoc ("Section", 1)
	Button.SetText (45485)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateLogWindow)

	# Quests completed
	Button = JournalWindow.GetControl (7)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetVarAssoc ("Section", 2)
	Button.SetText (45486)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateLogWindow)

	# Journal
	Button = JournalWindow.GetControl (8)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetVarAssoc ("Section", 4)
	Button.SetText (15333)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateLogWindow)

	# User
	Button = JournalWindow.GetControl (9)
	Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
	Button.SetVarAssoc ("Section", 0)
	Button.SetText (45487)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateLogWindow)

	# Order
	Button = JournalWindow.GetControl (10)
	Button.SetText (4627)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, ToggleOrderWindow)

	# Done
	#Button = JournalWindow.GetControl (3)
	#Button.SetText (20636)
	#Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenJournalWindow)

	Chapter = GemRB.GetGameVar("chapter")
	if Chapter>65535:
		Chapter=0

	GUICommonWindows.SetSelectionChangeHandler (UpdateLogWindow)
	UpdateLogWindow ()
	OptionsWindow.SetVisible (WINDOW_VISIBLE)
	Window.SetVisible (WINDOW_FRONT)
	PortraitWindow.SetVisible (WINDOW_VISIBLE)
	return
Exemple #28
0
def OpenInventoryWindow():
    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)
        GUICommon.GameWindow.SetVisible(WINDOW_VISIBLE)
        GemRB.UnhideGUI()
        GUICommonWindows.PortraitWindow = OldPortraitWindow
        GUICommonWindows.UpdatePortraitWindow()
        OldPortraitWindow = None
        GUICommonWindows.OptionsWindow = OldOptionsWindow
        OldOptionsWindow = None
        GUICommonWindows.SetSelectionChangeHandler(None)
        return

    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE)

    GemRB.LoadWindowPack("GUIINV", 800, 600)
    InventoryWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", InventoryWindow.ID)
    #TODO: Setup the MessageLabel here if needed
    #saving the original portrait window
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow()
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 1,
                                             OpenInventoryWindow)
    Window.SetFrame()

    Window.SetKeyPressEvent(GUICommonWindows.SwitchPCByKey)

    #ground items scrollbar
    ScrollBar = Window.GetControl(66)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RefreshInventoryWindow)

    # Ground Items (6)
    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.SetFont("NUMFONT")

    Button = Window.GetControl(81)
    Button.SetTooltip(12011)
    Button.SetVarAssoc("GroundItemButton", 6)
    Button.SetFont("NUMFONT")
    Button.SetFlags(
        IE_GUI_BUTTON_ALIGN_RIGHT | IE_GUI_BUTTON_ALIGN_BOTTOM
        | IE_GUI_BUTTON_PICTURE, OP_OR)

    #major & minor clothing color
    Button = Window.GetControl(62)
    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.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, InventoryCommon.MinorPress)
    Button.SetTooltip(12008)

    #hair & skin color
    Button = Window.GetControl(82)
    Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, InventoryCommon.HairPress)
    Button.SetTooltip(37560)

    Button = Window.GetControl(83)
    Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, InventoryCommon.SkinPress)
    Button.SetTooltip(37559)

    # paperdoll
    Button = Window.GetControl(50)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetFlags(
        IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE
        | IE_GUI_BUTTON_ANIMATED, OP_SET)
    Button.SetEvent(IE_GUI_BUTTON_ON_DRAG_DROP, InventoryCommon.OnAutoEquip)

    # portrait
    Button = Window.GetControl(84)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET)

    # 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)
            Button.SetFont("NUMFONT")

    GemRB.SetVar("TopIndex", 0)

    for i in range(4):
        Button = Window.GetControl(109 + i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ChangeWeaponPressed)
        Button.SetVarAssoc("Equipped", i)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        #Why they mess up .chu's i don't know
        Button.SetSprites("INVBUT3", i, 0, 1, 2, 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)

    GUICommonWindows.SetSelectionChangeHandler(UpdateInventoryWindow)

    UpdateInventoryWindow()
    return
Exemple #29
0
def OpenMageWindow():
    global MageWindow, OptionsWindow, PortraitWindow
    global OldPortraitWindow, OldOptionsWindow

    if GUICommon.CloseOtherWindow(OpenMageWindow):
        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)
    MageWindow = Window = GemRB.LoadWindow(2)
    GemRB.SetVar("OtherWindow", MageWindow.ID)
    #saving the original portrait window
    OldOptionsWindow = GUICommonWindows.OptionsWindow
    OptionsWindow = GemRB.LoadWindow(0)
    GUICommonWindows.SetupMenuWindowControls(OptionsWindow, 0, OpenMageWindow)
    OptionsWindow.SetFrame()
    OldPortraitWindow = GUICommonWindows.PortraitWindow
    PortraitWindow = GUICommonWindows.OpenPortraitWindow(0)

    Button = Window.GetControl(1)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, MagePrevLevelPress)

    Button = Window.GetControl(2)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, MageNextLevelPress)

    ## 	#unknown usage
    ## 	Button = Window.GetControl (55)
    ## 	Button.SetState (IE_GUI_BUTTON_LOCKED)
    ## 	#Button.SetText (123)
    ## 	#Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, xxPress)

    ## 	#setup level buttons
    ## 	for i in range (9):
    ## 		Button = Window.GetControl (56 + i)
    ## 		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RefreshMageLevel)
    ## 		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    ## 	for i in range (9):
    ## 		Button = Window.GetControl (56 + i)
    ## 		Button.SetVarAssoc ("MageSpellLevel", i)

    # Setup memorized spells buttons
    for i in range(12):
        Button = Window.GetControl(3 + i)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 1)
        Button.SetSprites("SPELFRAM", 0, 0, 0, 0, 0)
        Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)

    # Setup book spells buttons
    for i in range(GUICommon.GetIWDSpellButtonCount()):
        Button = Window.GetControl(27 + i)
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)

    GUICommonWindows.SetSelectionChangeHandler(UpdateMageWindow)
    UpdateMageWindow()
    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    #bringing the window front
    Window.SetVisible(WINDOW_FRONT)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    return
Exemple #30
0
def OpenStoreShoppingWindow():
    global StoreShoppingWindow
    global LeftButton, RightButton

    CloseWindows()

    StoreShoppingWindow = Window = GemRB.LoadWindow(4)

    if Inventory:
        # Title
        Label = Window.GetControl(0xfffffff)
        Label.SetText(51881)
        # buy price ...
        Label = Window.GetControl(0x1000002b)
        Label.SetText("")
        # sell price ...
        Label = Window.GetControl(0x1000002c)
        Label.SetText("")
        # buy price ...
        Label = Window.GetControl(0x1000002f)
        Label.SetText("")
        # sell price ...
        Label = Window.GetControl(0x10000030)
        Label.SetText("")
    else:
        # buy price ...
        Label = Window.GetControl(0x10000003)
        Label.SetText("0")

        # sell price ...
        Label = Window.GetControl(0x10000004)
        Label.SetText("0")

    for i in range(4):
        Button = Window.GetControl(i + 8)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 128, 160, 0, 1)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SelectBuy)
        Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoLeftWindow)

        Button = Window.GetControl(i + 17)
        Button.SetBorder(0, 0, 0, 0, 0, 0, 0, 128, 160, 0, 1)
        if Store['StoreType'] != 3:  # can't sell to temples
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SelectSell)
        Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, InfoRightWindow)

    # Buy
    LeftButton = Button = Window.GetControl(0)
    if Inventory:
        Button.SetText(51882)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ToBackpackPressed)
    else:
        Button.SetText(45303)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, BuyPressed)

    # Sell
    RightButton = Button = Window.GetControl(1)
    if Inventory:
        Button.SetText(51883)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ToBagPressed)
    else:
        Button.SetText(45304)
        if Store['StoreType'] != 3:  # can't sell to temples
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SellPressed)

    ## inactive button
    #Button = Window.GetControl (50)
    #Button.SetState (IE_GUI_BUTTON_LOCKED)
    #Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)

    ##backpack
    #Button = Window.GetControl (44)
    #Button.SetState (IE_GUI_BUTTON_LOCKED)

    ## encumbrance
    Button = Window.GetControl(25)
    GUICommon.SetEncumbranceLabels(Window, 25, None,
                                   GemRB.GameGetSelectedPCSingle())
    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    ##Label = Window.CreateLabel (0x10000019, 15,325,60,15,"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP)
    ##Label = Window.CreateLabel (0x10000044, 15,365,80,15,"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_TOP)

    # left scrollbar
    ScrollBar = Window.GetControl(7)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreShoppingWindow)

    # right scrollbar
    ScrollBar = Window.GetControl(16)
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawStoreShoppingWindow)

    GUICommonWindows.SetSelectionChangeHandler(UpdateStoreShoppingWindow)
    UpdateStoreShoppingWindow()
    Window.SetVisible(WINDOW_VISIBLE)
    return