Ejemplo n.º 1
0
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)

    if GUICommonWindows.PortraitWindow:
        GUICommonWindows.UpdatePortraitWindow()

    # we want this to happen before we start fiddling with the GUI
    MessageWindow.UpdateControlStatus()

    GemRB.LoadWindowPack(GUICommon.GetWindowPack())
    ContinueWindow = Window = GemRB.LoadWindow(9)

    GUICommonWindows.EmptyControls()
    OldActionsWindow = GUICommonWindows.ActionsWindow
    #GUICommonWindows.ActionsWindow = None
    OldActionsWindow.SetVisible(WINDOW_INVISIBLE)
    GemRB.SetVar("ActionsWindow", -1)
Ejemplo n.º 2
0
def OpenReformPartyWindow ():
	global ReformPartyWindow
	global removable_pcs

	GemRB.SetVar ("Selected", 0)
	hideflag = CommonWindow.IsGameGUIHidden()

	if ReformPartyWindow:
		ReformPartyWindow.Unload ()
		ReformPartyWindow = None

		CommonWindow.SetGameGUIHidden(hideflag)
		#re-enabling party size control
		GemRB.GameSetPartySize (MAX_PARTY_SIZE)
		GUICommonWindows.UpdatePortraitWindow()
		return

	ReformPartyWindow = Window = GemRB.LoadWindow (24, GUICommon.GetWindowPack(), WINDOW_HCENTER|WINDOW_BOTTOM)

	# skip exportable party members (usually only the protagonist)
	removable_pcs = []
	for i in range (1, GemRB.GetPartySize()+1):
		if not GemRB.GetPlayerStat (i, IE_MC_FLAGS)&MC_EXPORTABLE:
			removable_pcs.append(i)

	#PC portraits
	PortraitButtons = GUICommonWindows.GetPortraitButtonPairs (Window, 1, "horizontal")
	for j in PortraitButtons:
		Button = PortraitButtons[j]
		Button.SetState (IE_GUI_BUTTON_LOCKED)
		Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE,OP_SET)
		color = {'r' : 0, 'g' : 255, 'b' : 0, 'a' : 255}
		Button.SetBorder (FRAME_PC_SELECTED, color, 0, 0, Button.GetInsetFrame(1,1,2,2))
		if j < len(removable_pcs):
			Button.SetVarAssoc ("Selected", removable_pcs[j])
		Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, UpdateReformWindow)

	# Remove
	Button = Window.GetControl (15)
	Button.SetText (17507)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RemovePlayer)

	# Done
	Button = Window.GetControl (8)
	Button.SetText (11973)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenReformPartyWindow)

	# if nobody can be removed, just close the window
	if not removable_pcs:
		OpenReformPartyWindow ()
		CommonWindow.SetGameGUIHidden(hideflag)
		return

	UpdateReformWindow ()
	CommonWindow.SetGameGUIHidden(hideflag)

	Window.ShowModal (MODAL_SHADOW_GRAY)
	return
Ejemplo n.º 3
0
def UpdateReformWindow():
    Window = ReformPartyWindow

    select = GemRB.GetVar("Selected")

    need_to_drop = GemRB.GetPartySize() - MAX_PARTY_SIZE
    if need_to_drop < 0:
        need_to_drop = 0

    #excess player number
    Label = Window.GetControl(0x1000000f)
    Label.SetText(str(need_to_drop))

    #done
    Button = Window.GetControl(8)
    if need_to_drop:
        Button.SetState(IE_GUI_BUTTON_DISABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_ENABLED)

    #remove
    Button = Window.GetControl(15)
    if select:
        Button.SetState(IE_GUI_BUTTON_ENABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_DISABLED)

    PortraitButtons = GUICommonWindows.GetPortraitButtonPairs(
        Window, 1, "horizontal")
    for i in PortraitButtons:
        Button = PortraitButtons[i]
        if i + 1 not in removable_pcs:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)

    for i in removable_pcs:
        index = removable_pcs.index(i)
        if index not in PortraitButtons:
            continue  # for saved games with higher party count than the current setup supports
        Button = PortraitButtons[index]
        Button.EnableBorder(FRAME_PC_SELECTED, select == i)
        pic = GemRB.GetPlayerPortrait(i, 1)
        if not pic:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)
            continue
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetFlags(
            IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_ALIGN_BOTTOM
            | IE_GUI_BUTTON_ALIGN_LEFT, OP_SET)
        Button.SetPicture(pic, "NOPORTSM")
    GUICommonWindows.UpdatePortraitWindow()
    return
Ejemplo n.º 4
0
def UpdateReformWindow():
    Window = ReformPartyWindow

    select = GemRB.GetVar("Selected")

    need_to_drop = GemRB.GetPartySize() - PARTY_SIZE
    if need_to_drop < 0:
        need_to_drop = 0

    #excess player number
    Label = Window.GetControl(0x1000000f)
    Label.SetText(str(need_to_drop))

    #done
    Button = Window.GetControl(8)
    if need_to_drop:
        Button.SetState(IE_GUI_BUTTON_DISABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_ENABLED)

    #remove
    Button = Window.GetControl(15)
    if select:
        Button.SetState(IE_GUI_BUTTON_ENABLED)
    else:
        Button.SetState(IE_GUI_BUTTON_DISABLED)

    for i in range(PARTY_SIZE + 1):
        Button = Window.GetControl(i)
        if i + 1 not in removable_pcs:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)
            continue

    for i in removable_pcs:
        Button = Window.GetControl(removable_pcs.index(i))
        Button.EnableBorder(FRAME_PC_SELECTED, select == i)
        pic = GemRB.GetPlayerPortrait(i, 1)
        if not pic:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetState(IE_GUI_BUTTON_LOCKED)
            continue
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetFlags(
            IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_ALIGN_BOTTOM
            | IE_GUI_BUTTON_ALIGN_LEFT, OP_SET)
        Button.SetPicture(pic, "NOPORTSM")
    GUICommonWindows.UpdatePortraitWindow()
    return
Ejemplo n.º 5
0
def DialogStarted():
    global ContinueWindow

    Container.CloseContainerWindow()

    # opening control size to maximum, enabling dialog window
    CommonWindow.SetGameGUIHidden(False)
    GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR)

    # disable the 1-6 hotkeys, so they'll work for choosing answers
    GUICommonWindows.UpdatePortraitWindow()

    MessageWindow.UpdateControlStatus()

    ContinueWindow = OpenDialogButton(9)
Ejemplo n.º 6
0
def DialogStarted ():
	global ContinueWindow

	# try to force-close anything which is open
	GUICommonWindows.CloseTopWindow()
	Container.CloseContainerWindow()

	# opening control size to maximum, enabling dialog window
	CommonWindow.SetGameGUIHidden(False)
	GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR)

	# disable the 1-6 hotkeys, so they'll work for choosing answers
	if GemRB.GetView ("PORTWIN"):
		GUICommonWindows.UpdatePortraitWindow ()

	ContinueWindow = OpenDialogButton(9)
Ejemplo n.º 7
0
def DialogStarted ():
	global ContinueWindow

	GUICommonWindows.CloseTopWindow()
	Container.CloseContainerWindow()

	# opening control size to maximum, enabling dialog window
	CommonWindow.SetGameGUIHidden(False)
	GemRB.GameSetScreenFlags(GS_DIALOG, OP_OR)
	
	# disable the 1-6 hotkeys, so they'll work for choosing answers
	GUICommonWindows.UpdatePortraitWindow ()

	MWin = GemRB.GetView("MSGWIN")
	CloseButton= MWin.GetControl (0)
	CloseButton.SetText ("")
	CloseButton.SetDisabled(True)
	CloseButton.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR)
Ejemplo n.º 8
0
def DialogEnded():
    global ContinueWindow, OldActionsWindow

    # TODO: why is this being called at game start?!
    if not ContinueWindow:
        return

    #GUICommonWindows.ActionsWindow = OldActionsWindow
    OldActionsWindow.SetVisible(WINDOW_VISIBLE)
    GemRB.SetVar("ActionsWindow", OldActionsWindow.ID)
    GUICommonWindows.UpdateActionsWindow()

    ContinueWindow.Unload()
    ContinueWindow = None
    OldActionsWindow = None

    if GUICommonWindows.PortraitWindow:
        GUICommonWindows.UpdatePortraitWindow()
Ejemplo n.º 9
0
def LevelUpDonePress():
    """Updates the PC with the new choices.

	Closes the window when finished."""
    import GUICommonWindows
    import GUIREC

    # proficiencies
    LUProfsSelection.ProfsSave(pc)

    # skills
    LUSkillsSelection.SkillsSave(pc)

    # level
    if DualSwap:  # swap the IE_LEVELs around if a backward dual
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[1])
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[1])
    GemRB.SetPlayerStat(pc, IE_LEVEL3, Level[2])

    print("Levels:", Level[0], "/", Level[1], "/", Level[2])

    # spells
    SaveNewSpells()

    # hlas
    # level, xp and other stuff by the core?

    # 5261 - Regained abilities from inactive class
    if IsDual:  # we're dual classed
        print("activation?")
        if (Level[0] - LevelDiff[0]) <= Level[1] and Level[0] > Level[
                1]:  # our new classes now surpasses our old class
            print("reactivating base class")
            ReactivateBaseClass()

    if LevelUpWindow:
        LevelUpWindow.Close()
    GUICommonWindows.UpdatePortraitWindow()
    return
Ejemplo n.º 10
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
Ejemplo n.º 11
0
def LevelUpDonePress():
    """Updates the PC with the new choices.

	Closes the window when finished."""
    import GUICommonWindows
    import GUIREC
    global SkillTable

    # proficiencies
    LUProfsSelection.ProfsSave(pc)

    # skills
    LUSkillsSelection.SkillsSave(pc)

    # level
    if DualSwap:  # swap the IE_LEVELs around if a backward dual
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[1])
    else:
        GemRB.SetPlayerStat(pc, IE_LEVEL, Level[0])
        GemRB.SetPlayerStat(pc, IE_LEVEL2, Level[1])
    GemRB.SetPlayerStat(pc, IE_LEVEL3, Level[2])

    print "Levels:", Level[0], "/", Level[1], "/", Level[2]

    # save our number of memorizable spells per level
    if DeltaWSpells > 0:
        # loop through each wizard spell level
        for i in range(len(NewWSpells)):
            if NewWSpells[i] > 0:  # we have new spells, so update
                GemRB.SetMemorizableSpellsCount(pc, NewWSpells[i],
                                                IE_SPELL_TYPE_WIZARD, i)

    # save our number of memorizable priest spells
    if DeltaDSpells > 0:  # druids and clerics count
        for i in range(len(NewDSpells)):
            # get each update
            if NewDSpells[i] > 0:
                GemRB.SetMemorizableSpellsCount(pc, NewDSpells[i],
                                                IE_SPELL_TYPE_PRIEST, i)

            # learn all the spells we're given, but don't have, up to our given casting level
            # bonus spells don't count in determining if we can use this level
            if GemRB.GetMemorizableSpellsCount(
                    pc, IE_SPELL_TYPE_PRIEST, i,
                    0) > 0:  # we can memorize spells of this level
                for j in range(NumClasses):  # loop through each class
                    TmpClassName = GUICommon.GetClassRowName(
                        Classes[j], "class")
                    IsDruid = CommonTables.ClassSkills.GetValue(
                        TmpClassName, "DRUIDSPELL", GTV_STR)
                    IsCleric = CommonTables.ClassSkills.GetValue(
                        TmpClassName, "CLERICSPELL", GTV_STR)
                    if IsCleric == "*" and IsDruid == "*":  # no divine spells (so mage/cleric multis don't screw up)
                        continue
                    elif IsCleric == "*":  # druid spells
                        ClassFlag = 0x8000
                    else:  # cleric spells
                        ClassFlag = 0x4000

                    Learnable = Spellbook.GetLearnablePriestSpells(
                        ClassFlag, GemRB.GetPlayerStat(pc, IE_ALIGNMENT),
                        i + 1)
                    for k in range(len(Learnable)
                                   ):  # loop through all the learnable spells
                        if Spellbook.HasSpell(
                                pc, IE_SPELL_TYPE_PRIEST, i, Learnable[k]
                        ) < 0:  # only write it if we don't yet know it
                            GemRB.LearnSpell(pc, Learnable[k])

    # hlas
    # level, xp and other stuff by the core?

    # 5261 - Regained abilities from inactive class
    if IsDual:  # we're dual classed
        print "activation?"
        if (Level[0] - LevelDiff[0]) <= Level[1] and Level[0] > Level[
                1]:  # our new classes now surpasses our old class
            print "reactivating base class"
            ReactivateBaseClass()

    if LevelUpWindow:
        LevelUpWindow.Unload()
    GUICommonWindows.UpdatePortraitWindow()
    GUIREC.UpdateRecordsWindow()

    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_OR)
    return
Ejemplo n.º 12
0
def OpenReformPartyWindow():
    global ReformPartyWindow, OldActionsWindow, OldMessageWindow
    global removable_pcs

    GemRB.SetVar("Selected", 0)
    hideflag = GemRB.HideGUI()

    if ReformPartyWindow:
        ReformPartyWindow.Unload()
        GemRB.SetVar("ActionsWindow", OldActionsWindow.ID)
        GemRB.SetVar("MessageWindow", OldMessageWindow.ID)
        GemRB.SetVar("OtherWindow", -1)

        OldActionsWindow = None
        OldMessageWindow = None
        ReformPartyWindow = None

        #GemRB.LoadWindowPack (GUICommon.GetWindowPack())
        if hideflag:
            GemRB.UnhideGUI()
        #re-enabling party size control
        GemRB.GameSetPartySize(PARTY_SIZE)
        GUICommonWindows.UpdatePortraitWindow()
        return

    GemRB.LoadWindowPack(GUICommon.GetWindowPack())
    ReformPartyWindow = Window = GemRB.LoadWindow(24)
    GemRB.SetVar("OtherWindow", Window.ID)

    # skip exportable party members (usually only the protagonist)
    removable_pcs = []
    for i in range(1, GemRB.GetPartySize() + 1):
        if not GemRB.GetPlayerStat(i, IE_MC_FLAGS) & MC_EXPORTABLE:
            removable_pcs.append(i)

    #PC portraits
    for j in range(PARTY_SIZE + 1):
        Button = Window.GetControl(j)
        Button.SetState(IE_GUI_BUTTON_LOCKED)
        Button.SetFlags(
            IE_GUI_BUTTON_RADIOBUTTON | IE_GUI_BUTTON_NO_IMAGE
            | IE_GUI_BUTTON_PICTURE, OP_SET)
        Button.SetBorder(FRAME_PC_SELECTED, 1, 1, 2, 2, 0, 255, 0, 255)
        if j < len(removable_pcs):
            Button.SetVarAssoc("Selected", removable_pcs[j])
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, UpdateReformWindow)

    # Remove
    Button = Window.GetControl(15)
    Button.SetText(17507)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RemovePlayer)

    # Done
    Button = Window.GetControl(8)
    Button.SetText(11973)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenReformPartyWindow)

    OldActionsWindow = GUIClasses.GWindow(GemRB.GetVar("ActionsWindow"))
    OldMessageWindow = GUIClasses.GWindow(GemRB.GetVar("MessageWindow"))
    GemRB.SetVar("ActionsWindow", -1)
    GemRB.SetVar("MessageWindow", -1)

    # if nobody can be removed, just close the window
    if not removable_pcs:
        OpenReformPartyWindow()
        if hideflag:
            GemRB.UnhideGUI()
        return

    UpdateReformWindow()
    if hideflag:
        GemRB.UnhideGUI()
    Window.ShowModal(MODAL_SHADOW_GRAY)
    return
Ejemplo n.º 13
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
Ejemplo n.º 14
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
Ejemplo n.º 15
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
Ejemplo n.º 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