Esempio n. 1
0
def ProfsSave (pc, type=LUPROFS_TYPE_LEVELUP):
	"""Updates the actor with the new proficiencies."""

	ProfCount = ProfsTable.GetRowCount () - ProfsTableOffset
	for i in range(ProfCount): # skip bg1 weapprof.2da proficiencies
		ProfID = ProfsTable.GetValue (i+ProfsTableOffset, 0)
		if GUICommon.GameIsBG1():
			ProfID = ProfID + IE_PROFICIENCYBASTARDSWORD
		SaveProf = GemRB.GetVar ("Prof "+str(i))

		if type == LUPROFS_TYPE_CHARGEN and GUICommon.GameIsBG2():
			GemRB.DispelEffect (pc, "Proficiency", ProfID)
		else:
			if type != LUPROFS_TYPE_DUALCLASS:
				OldProf = GemRB.GetPlayerStat (pc, ProfID) & 0x38
				SaveProf = OldProf | SaveProf
			else: # gotta move the old prof to the back for dual class
				OldProf = GemRB.GetPlayerStat (pc, ProfID) & 0x07
				SaveProf = (OldProf << 3) | SaveProf

		GemRB.SetPlayerStat (pc, ProfID, SaveProf)
		if GUICommon.GameIsBG2() and (type == LUPROFS_TYPE_LEVELUP or type == LUPROFS_TYPE_CHARGEN):
			if SaveProf:
				GemRB.ApplyEffect (pc, "Proficiency", SaveProf, ProfID)
	return
Esempio n. 2
0
def OpenGameplayOptionsWindow ():
	"""Open gameplay options window"""
	global SubOptionsWindow, HelpTextArea

	if SubOptionsWindow:
		if SubOptionsWindow:
			SubOptionsWindow.Unload ()
		SubOptionsWindow = None 

	SubOptionsWindow = Window = GemRB.LoadWindow (8)

	HelpTextArea = OptHelpText ('GameplayOptions', Window, 40, 18042)

	OptDone ('GameplayOptions', Window, 7)
	OptCancel ('GameplayOptions', Window, 20)

	OptSlider ('TooltipDelay', Window, 1, 'Tooltips', TOOLTIP_DELAY_FACTOR)
	OptSlider ('MouseScrollingSpeed', Window, 2, 'Mouse Scroll Speed', 5)
	OptSlider ('KeyboardScrollingSpeed', Window, 3, 'Keyboard Scroll Speed', 5)
	OptSlider ('Difficulty', Window, 12, 'Difficulty Level', 0)

	OptCheckbox ('DitherAlways', Window, 14, 25, 'Always Dither', 1)
	OptCheckbox ('Gore', Window, 19, 27, 'Gore', 1)
	OptCheckbox ('Infravision', Window, 42, 44, 'Infravision', 1)
	OptCheckbox ('Weather', Window, 47, 46, 'Weather', 1)
	if GUICommon.GameIsBG2():
		OptCheckbox ('RestUntilHealed', Window, 50, 48, 'Heal Party on Rest', 1)

	OptButton ('FeedbackOptions', Window, 5, 17163)
	OptButton ('AutopauseOptions', Window, 6, 17166)
	if GUICommon.GameIsBG2():
		OptButton ('HotkeyOptions', Window, 51, 816)

	Window.ShowModal (MODAL_SHADOW_GRAY)
	return
Esempio n. 3
0
def SpellsDonePress():
    """Move to the next assignable level.

	If there is not another assignable level, then save all the new spells and
	close the window."""

    global SpellBook, SpellLevel, SpellsWindow

    # save all the spells
    for i in range(len(Spells[SpellLevel])):
        if SpellBook[i]:  # we need to learn this spell
            GemRB.LearnSpell(pc, Spells[SpellLevel][i][0])

    # check to see if we need to update again
    for i in range(SpellLevel + 1, 9):
        if SpellsSelectPointsLeft[i] > 0:
            # reset the variables
            GemRB.SetVar("SpellTopIndex", 0)
            SpellLevel = i
            SpellBook = [0] * len(Spells[i])

            if (EnhanceGUI):
                # setup the scrollbar
                ScrollBar = SpellsWindow.GetControl(1000)
                if len(Spells[i]) > (24 + ExtraSpellButtons()):
                    HideUnhideScrollBar(0)
                    if chargen:
                        ScrollBar.SetVarAssoc(
                            "SpellTopIndex",
                            GUICommon.ceildiv((len(Spells[i]) - 24), 6) + 1)
                    else:
                        ScrollBar.SetVarAssoc(
                            "SpellTopIndex",
                            GUICommon.ceildiv((len(Spells[i]) - 25), 5) + 1)
                else:
                    ScrollBar.SetVarAssoc("SpellTopIndex", 0)
                    HideUnhideScrollBar(1)

            # show the spells and set the done button to off
            ShowSpells()
            DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
            return

    # close our window and update our records
    if SpellsWindow and (not chargen or GUICommon.GameIsBG2()):
        SpellsWindow.Unload()
        SpellsWindow = None

    # move to the next script if this is chargen
    if chargen:
        if GUICommon.GameIsBG2():
            # HACK
            GemRB.SetNextScript("GUICG6")
        elif GUICommon.GameIsBG1():
            # HACK
            from CharGenCommon import next
            next()

    return
Esempio n. 4
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
Esempio n. 5
0
def OpenGameplayOptionsWindow():
    """Open gameplay options window"""
    global SubOptionsWindow, HelpTextArea

    Window = SubOptionsWindow
    CloseSubOptionsWindow()

    #gameplayoptions
    Window = GemRB.LoadWindow(8)

    HelpTextArea = GUIOPTControls.OptHelpText('GameplayOptions', Window, 40,
                                              18042)

    GUIOPTControls.OptDone(CloseGameplayOptionsWindow, Window, 7)
    GUIOPTControls.OptCancel(CloseGameplayOptionsWindow, Window, 20)

    GUIOPTControls.OptSlider(18042, 18017, HelpTextArea, Window, 1, 21, 17143,
                             'Tooltips', DisplayHelpTooltipDelay,
                             TOOLTIP_DELAY_FACTOR)
    GUIOPTControls.OptSlider(18042, 18018, HelpTextArea, Window, 2, 22, 17144,
                             'Mouse Scroll Speed',
                             DisplayHelpMouseScrollingSpeed, 5)
    GUIOPTControls.OptSlider(18042, 18019, HelpTextArea, Window, 3, 23, 17145,
                             'Keyboard Scroll Speed', None, 5)
    GUIOPTControls.OptSlider(18042, 18020, HelpTextArea, Window, 12, 24, 13911,
                             'Difficulty Level', None, 0)

    GUIOPTControls.OptCheckbox(18042, 18021, HelpTextArea, Window, 14, 25,
                               13697, 'Always Dither')
    GUIOPTControls.OptCheckbox(18042, 18023, HelpTextArea, Window, 19, 27,
                               17182, 'Gore')
    GUIOPTControls.OptCheckbox(18042, 11797, HelpTextArea, Window, 42, 44,
                               11795, 'Infravision')
    GUIOPTControls.OptCheckbox(18042, 20619, HelpTextArea, Window, 47, 46,
                               20618, 'Weather')
    if GUICommon.GameIsBG2():
        GUIOPTControls.OptCheckbox(18042, 2242, HelpTextArea, Window, 50, 48,
                                   2241, 'Heal Party on Rest')
    elif GUICommon.GameIsIWD2():
        GUIOPTControls.OptCheckbox(18042, 15136, HelpTextArea, Window, 50, 49,
                                   17378, 'Maximum HP')

    GUIOPTControls.OptButton(OpenFeedbackOptionsWindow, Window, 5, 17163)
    GUIOPTControls.OptButton(OpenAutopauseOptionsWindow, Window, 6, 17166)
    if GUICommon.GameIsBG2():
        GUIOPTControls.OptButton(OpenHotkeyOptionsWindow, Window, 51, 816)

    SubOptionsWindow = Window
    Window.ShowModal(MODAL_SHADOW_GRAY)
    return
Esempio n. 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
Esempio n. 7
0
def DCOpenProfsWindow():
    """Opens the proficiency selection window."""

    global DCProfsWindow, DCProfsDoneButton

    # load up our window and set some basic variables
    DCProfsWindow = GemRB.LoadWindow(15)
    NewClassId = CommonTables.Classes.GetValue(ClassName, "ID", 1)
    if GUICommon.GameIsBG2():
        LUProfsSelection.SetupProfsWindow (pc, \
         LUProfsSelection.LUPROFS_TYPE_DUALCLASS, DCProfsWindow, DCProfsRedraw, classid=NewClassId)
    else:
        LUProfsSelection.SetupProfsWindow (pc, \
         LUProfsSelection.LUPROFS_TYPE_DUALCLASS, DCProfsWindow, \
         DCProfsRedraw, [0,0,0], [1,1,1], NewClassId, False, 0)

    # setup the done and cancel
    DCProfsDoneButton = DCProfsWindow.GetControl(76)
    DCProfsDoneButton.SetText(11973)
    DCProfsDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCProfsDonePress)
    DCProfsDoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    DCProfsDoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    DCProfsCancelButton = DCProfsWindow.GetControl(77)
    DCProfsCancelButton.SetText(13727)
    DCProfsCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCProfsCancelPress)
    DCProfsCancelButton.SetState(IE_GUI_BUTTON_ENABLED)
    DCProfsCancelButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # show the window and draw away
    DCProfsWindow.ShowModal(MODAL_SHADOW_GRAY)
    DCProfsRedraw()
    return
Esempio n. 8
0
def OpenAutopauseOptionsWindow():
    """Open autopause options window"""
    global GameOptionsWindow, HelpTextArea

    if GameOptionsWindow:
        if GameOptionsWindow:
            GameOptionsWindow.Unload()
        GameOptionsWindow = None

    GameOptionsWindow = Window = GemRB.LoadWindow(10)

    HelpTextArea = OptHelpText('AutopauseOptions', Window, 15, 18044)

    OptDone('AutopauseOptions', Window, 11)
    OptCancel('AutopauseOptions', Window, 14)

    OptCheckbox('CharacterHit', Window, 1, 17, 'Auto Pause State', 1)
    OptCheckbox('CharacterInjured', Window, 2, 18, 'Auto Pause State', 2)
    OptCheckbox('CharacterDead', Window, 3, 19, 'Auto Pause State', 4)
    OptCheckbox('CharacterAttacked', Window, 4, 20, 'Auto Pause State', 8)
    OptCheckbox('WeaponUnusable', Window, 5, 21, 'Auto Pause State', 16)
    OptCheckbox('TargetGone', Window, 13, 22, 'Auto Pause State', 32)
    OptCheckbox('EndOfRound', Window, 25, 24, 'Auto Pause State', 64)
    if Window.HasControl(26, IE_GUI_BUTTON):
        OptCheckbox('EnemySighted', Window, 26, 27, 'Auto Pause State', 128)
    if GUICommon.GameIsBG2():
        OptCheckbox('SpellCast', Window, 34, 30, 'Auto Pause State', 256)
        OptCheckbox('TrapFound', Window, 31, 33, 'Auto Pause State', 512)
        OptCheckbox('CenterOnActor', Window, 31, 33, 'Auto Pause Center', 1)

    Window.ShowModal(MODAL_SHADOW_GRAY)
    return
Esempio n. 9
0
def InfoWindow (Slot, Item):
	global MessageWindow

	Identify = Slot['Flags'] & IE_INV_ITEM_IDENTIFIED

	MessageWindow = Window = GemRB.LoadWindow (12)

	# TODO: check non-bg2 games to see which label is which
	if GUICommon.GameIsBG2():
		NameLabel = Window.GetControl (0x10000000)
		FakeLabel = Window.GetControl (0x10000007)
	else:
		NameLabel = Window.GetControl (0x10000007)
		FakeLabel = Window.GetControl (0x10000000)

	#fake label
	FakeLabel.SetText ("")

	#description bam
	if GUICommon.GameIsBG1() or GUICommon.GameIsBG2():
		Button = Window.GetControl (7)
		Button.SetFlags (IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_CENTER_PICTURES | IE_GUI_BUTTON_NO_IMAGE, OP_OR)
		Button.SetItemIcon (Slot['ItemResRef'], 2)

	#slot bam
	Button = Window.GetControl (2)
	Button.SetItemIcon (Slot['ItemResRef'], 0)

	TextArea = Window.GetControl (5)
	if Identify:
		NameLabel.SetText (Item['ItemNameIdentified'])
		TextArea.SetText (Item['ItemDescIdentified'])
	else:
		NameLabel.SetText (Item['ItemName'])
		TextArea.SetText (Item['ItemDesc'])

	#Done
	Button = Window.GetControl (4)
	Button.SetText (11973)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, ErrorDone)

	# hide the empty button
	if GUICommon.GameIsBG2() or GUICommon.GameIsIWD2():
		Window.DeleteControl (9)

	Window.ShowModal (MODAL_SHADOW_GRAY)
	return
Esempio n. 10
0
def PortraitDonePress():
    pc = GemRB.GameGetSelectedPCSingle()
    # eh, different sizes
    if GUICommon.GameIsBG2():
        GemRB.FillPlayerInfo(pc, Portrait.Name() + "M", Portrait.Name() + "S")
    else:
        GemRB.FillPlayerInfo(pc, Portrait.Name() + "L", Portrait.Name() + "S")
    CloseSubCustomizeWindow()
    return
Esempio n. 11
0
def RemovePlayerConfirm():
    slot = GemRB.GetVar("Selected")
    if GUICommon.GameIsBG2():
        GemRB.LeaveParty(slot, 2)
    elif GUICommon.GameIsBG1():
        GemRB.LeaveParty(slot, 1)
    else:
        GemRB.LeaveParty(slot)
    OpenReformPartyWindow()
    return
Esempio n. 12
0
def ShowSpells():
    """Shows the viewable 24 spells."""

    j = RowIndex()

    # we have a grid of 24 spells
    for i in range(24 + ExtraSpellButtons()):
        # ensure we can learn this many spells
        SpellButton = SpellsWindow.GetControl(i + SpellStart)
        if i + j >= len(Spells[SpellLevel]):
            SpellButton.SetState(IE_GUI_BUTTON_DISABLED)
            SpellButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            continue
        else:
            SpellButton.SetState(IE_GUI_BUTTON_ENABLED)
            SpellButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)

        # fill in the button with the spell data
        Spell = GemRB.GetSpell(Spells[SpellLevel][i + j][0], 1)
        SpellButton.SetTooltip(Spell['SpellName'])
        SpellButton.SetVarAssoc("ButtonPressed", i)
        SpellButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SpellsSelectPress)
        if GUICommon.GameIsBG2():
            SpellButton.SetSprites("GUIBTBUT", 0, 0, 1, 2, 3)
        else:
            SpellButton.SetSprites("GUIBTBUT", 0, 0, 1, 24, 25)

        SpellButton.SetSpellIcon(Spells[SpellLevel][i + j][0], 1)
        SpellButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)

        # don't allow the selection of an un-learnable spell
        if Spells[SpellLevel][i + j][1] == 0:
            SpellButton.SetState(IE_GUI_BUTTON_LOCKED)
            # shade red
            SpellButton.SetBorder(0, 0, 0, 0, 0, 200, 0, 0, 100, 1, 1)
        elif Spells[SpellLevel][i + j][1] == 1:  # learnable
            SpellButton.SetState(IE_GUI_BUTTON_ENABLED)
            # unset any borders on this button or an un-learnable from last level
            # will still shade red even though it is clickable
            SpellButton.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        else:  # specialist (shouldn't get here)
            # use the green border state for matching specialist spells
            SpellButton.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
            SpellButton.SetState(IE_GUI_BUTTON_THIRD)

    # show which spells are selected
    ShowSelectedSpells()

    GemRB.SetToken("number", str(SpellsSelectPointsLeft[SpellLevel]))
    SpellsTextArea.SetText(17250)

    return
Esempio n. 13
0
def CloseBiographyWindow():
    import GUIREC
    global BiographyWindow

    if BiographyWindow:
        BiographyWindow.Unload()
        BiographyWindow = None
    # TODO: check if bg1 wouldn't benefit from modality too
    if GUIREC.InformationWindow:
        if GUICommon.GameIsBG2() or GUICommon.GameIsIWD1():
            GUIREC.InformationWindow.ShowModal(MODAL_SHADOW_GRAY)
        else:
            GUIREC.InformationWindow.SetVisible(WINDOW_VISIBLE)
    return
Esempio n. 14
0
def OpenBiographyEditWindow():
    global SubCustomizeWindow
    global BioStrRef
    global TextArea

    Changed = 0
    pc = GemRB.GameGetSelectedPCSingle()
    BioStrRef = GemRB.GetPlayerString(pc, 74)
    if BioStrRef != 33347:
        Changed = 1

    # TODO: check if this is really needed
    if GUICommon.GameIsIWD1() or GUICommon.GameIsIWD2():
        SubCustomizeWindow = GemRB.LoadWindow(51)
    else:
        SubCustomizeWindow = GemRB.LoadWindow(23)

    ClearButton = SubCustomizeWindow.GetControl(5)
    if GUICommon.GameIsBG2():
        ClearButton.SetText(34881)
    else:
        ClearButton.SetText(18622)

    DoneButton = SubCustomizeWindow.GetControl(1)
    DoneButton.SetText(11973)
    DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    if GUICommon.GameIsIWD2():
        RevertButton = SubCustomizeWindow.GetControl(6)
    else:
        RevertButton = SubCustomizeWindow.GetControl(3)
    RevertButton.SetText(2240)
    if not Changed:
        RevertButton.SetState(IE_GUI_BUTTON_DISABLED)

    CancelButton = SubCustomizeWindow.GetControl(2)
    CancelButton.SetText(13727)
    CancelButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)

    TextArea = SubCustomizeWindow.GetControl(4)
    TextArea.SetBufferLength(65535)
    TextArea.SetText(BioStrRef)

    ClearButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClearBiography)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DoneBiographyWindow)
    RevertButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, RevertBiography)
    CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CloseSubCustomizeWindow)

    SubCustomizeWindow.ShowModal(MODAL_SHADOW_GRAY)
    return
Esempio n. 15
0
def OnPriestUnmemorizeSpell ():
	if PriestSpellUnmemorizeWindow:
		ClosePriestSpellUnmemorizeWindow ()

	pc = GemRB.GameGetSelectedPCSingle ()
	level = PriestSpellLevel
	type = IE_SPELL_TYPE_PRIEST

	index = GemRB.GetVar ("SpellButton")

	if GemRB.UnmemorizeSpell (pc, type, level, index):
		UpdatePriestWindow ()
		GemRB.PlaySound ("GAM_44")
		Button = PriestWindow.GetControl(index + 3)
		Button.SetAnimation ("FLASH", 0, GUICommon.GameIsBG2() is False) # no blending for bg2
	return
Esempio n. 16
0
def ShowKnownSpells():
    """Shows the viewable 24 spells."""

    j = RowIndex()
    Spells[SpellLevel] = Spellbook.GetMageSpells(
        KitMask, GemRB.GetPlayerStat(pc, IE_ALIGNMENT), SpellLevel + 1)

    # reset the title
    #17224 for priest spells
    Title = SpellsWindow.GetControl(0x10000000)
    Title.SetText(17189)

    # we have a grid of 24 spells
    for i in range(24):
        # ensure we can learn this many spells
        SpellButton = SpellsWindow.GetControl(i + SpellStart)
        if i + j >= len(SpellBook) or not SpellBook[i + j]:
            SpellButton.SetState(IE_GUI_BUTTON_DISABLED)
            SpellButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            continue
        else:
            SpellButton.SetState(IE_GUI_BUTTON_ENABLED)
            SpellButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)

        # fill in the button with the spell data
        Spell = GemRB.GetSpell(Spells[SpellLevel][i + j][0], 1)
        SpellButton.SetTooltip(Spell['SpellName'])
        SpellButton.SetVarAssoc("MemorizePressed", i)
        SpellButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MemorizePress)
        if GUICommon.GameIsBG2():
            SpellButton.SetSprites("GUIBTBUT", 0, 0, 1, 2, 3)
        else:
            SpellButton.SetSprites("GUIBTBUT", 0, 0, 1, 24, 25)
        SpellButton.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

        SpellButton.SetSpellIcon(Spells[SpellLevel][i + j][0], 1)
        SpellButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)

    # show which spells are selected
    ShowSelectedSpells()

    GemRB.SetToken("number", str(SpellsSelectPointsLeft[SpellLevel]))
    SpellsTextArea.SetText(17253)

    return
Esempio n. 17
0
def ReadItemWindow ():
	global level, spell_ref
	"""Tries to learn the mage scroll."""

	pc = GemRB.GameGetSelectedPCSingle ()
	slot = GemRB.GetVar ("ItemButton")
	ret = Spellbook.CannotLearnSlotSpell()

	if ret:
		# couldn't find any strrefs for the other undhandled values (stat, level)
		strref = 72873
		CloseItemInfoWindow ()
		if GUICommon.HasTOB() and ret == LSR_KNOWN:
			OpenErrorWindow (strref)
		return

	if GUICommon.GameIsPST():
		slot, slot_item = GUIINV.ItemHash[GemRB.GetVar ('ItemButton')]
	else:
		slot_item = GemRB.GetSlotItem (pc, slot)
	spell_ref = GemRB.GetItem (slot_item['ItemResRef'], pc)['Spell']
	spell = GemRB.GetSpell (spell_ref)
	if spell:
		# can we learn more spells of this level?
		level = spell['SpellLevel']-1
		spell_count = GemRB.GetKnownSpellsCount (pc, IE_SPELL_TYPE_WIZARD, level)
		if spell_count > GemRB.GetAbilityBonus (IE_INT, 2, GemRB.GetPlayerStat (pc, IE_INT)):
			ret = LSR_FULL
			if GUICommon.GameIsBG2():
				strref = 32097
			else:
				strref = -1
		else:
			GemRB.UseItem (pc, slot, 1, 5)
			GemRB.SetTimedEvent(DelayedReadItemWindow, 1)
			return
	else:
		print "WARNING: invalid spell header in item", slot_item['ItemResRef']
		CloseItemInfoWindow ()
		return -1

	CloseItemInfoWindow ()
	OpenErrorWindow (strref)

	return ret
Esempio n. 18
0
def SpellsCancelPress():
    """Removes all known spells and close the window.

	This is only callable within character generation."""

    # remove all learned spells
    GUICommon.RemoveKnownSpells(pc, IE_SPELL_TYPE_WIZARD, 1, 9, 1)

    if GUICommon.GameIsBG2():
        # unload teh window and go back
        if SpellsWindow:
            SpellsWindow.Unload()
        GemRB.SetNextScript("CharGen6")  #haterace
    elif GUICommon.GameIsBG1():
        import CharGenCommon
        CharGenCommon.BackPress()
    else:
        print "Uh-oh in SpellsCancelPress in", GemRB.GameType
    return
Esempio n. 19
0
def Set (PortraitName):
	global PortraitCount

	# removes the size marking character at the end
	if GUICommon.GameIsBG2():
		PortraitName = PortraitName.rstrip ("[ms]")
	else:
		PortraitName = PortraitName.rstrip ("[ls]")
	
	# capitalize PortraitName
	PortraitName = PortraitName.upper ()

	# search table
	for i in range(0, PortraitsTable.GetRowCount ()):
		if PortraitName == PortraitsTable.GetRowName (i).upper ():
			PortraitCount = i
			break

	return
Esempio n. 20
0
def GroupControls():
    """Sections that control group actions."""

    if GUICommon.GameIsIWD2():
        global PortraitWindow
        Window = PortraitWindow
    else:
        global ActionsWindow
        Window = ActionsWindow

    GemRB.SetVar("ActionLevel", 0)
    Button = Window.GetControl(ActionBarControlOffset)
    if GUICommon.GameIsBG2():  # no guard icon
        Button.SetActionIcon(globals(), -1)
    else:
        Button.SetActionIcon(globals(), 14)
    Button = Window.GetControl(1 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), 7)
    Button = Window.GetControl(2 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), 15)
    Button = Window.GetControl(3 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), 21)
    Button = Window.GetControl(4 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), -1)
    Button = Window.GetControl(5 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), -1)
    Button = Window.GetControl(6 + ActionBarControlOffset)
    Button.SetActionIcon(globals(), -1)
    GemRB.SetVar("Formation", GemRB.GameGetFormation())
    for i in range(5):
        Button = Window.GetControl(7 + ActionBarControlOffset + i)
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        idx = GemRB.GameGetFormation(i)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON | IE_GUI_BUTTON_NORMAL,
                        OP_SET)
        # kill the previous sprites or they show through
        Button.SetSprites("GUIBTBUT", 0, 0, 1, 2, 3)
        Button.SetBAM("FORM%x" % idx, 0, 0, -1)
        Button.SetVarAssoc("Formation", i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUICommon.SelectFormation)
        Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, SetupFormation)
        Button.SetTooltip(4935, 8 + i)
    return
Esempio n. 21
0
def OnPriestMemorizeSpell ():
	pc = GemRB.GameGetSelectedPCSingle ()
	level = PriestSpellLevel
	type = IE_SPELL_TYPE_PRIEST

	index = GemRB.GetVar ("SpellButton") - 100

	if GemRB.MemorizeSpell (pc, type, level, index):
		UpdatePriestWindow ()
		GemRB.PlaySound ("GAM_24")
		Button = PriestWindow.GetControl(index + 27)
		mem_cnt = GemRB.GetMemorizedSpellsCount (pc, type, level, False)
		Button2 = PriestWindow.GetControl(mem_cnt + 2)
		if GUICommon.GameIsBG2(): # no blending
			Button.SetAnimation ("FLASH")
			Button2.SetAnimation ("FLASH")
		else:
			Button.SetAnimation ("FLASH", 0, 1)
			Button2.SetAnimation ("FLASH", 0, 1)
	return
Esempio n. 22
0
def OpenSkillsWindow():
    """Opens the skills selection window.

	This will allow the selection of thief skills for appropriate classes, or
	auto-assign them for classes that recieve skills based on level."""

    global DCSkillsWindow, DCSkillsDoneButton

    DCSkillsWindow = GemRB.LoadWindow(7)
    if GUICommon.GameIsBG2():
        LUSkillsSelection.SetupSkillsWindow (pc, \
         LUSkillsSelection.LUSKILLS_TYPE_DUALCLASS, DCSkillsWindow, DCSkillsRedraw, classid=NewClassId)
    else:
        LUSkillsSelection.SetupSkillsWindow (pc, \
         LUSkillsSelection.LUSKILLS_TYPE_DUALCLASS, DCSkillsWindow, \
         DCSkillsRedraw, [0,0,0], [1,1,1], NewClassId, False)

    #just go back if we can't assign skills
    if GemRB.GetVar("SkillPointsLeft") <= 0:
        return

    # setup the back and done buttons
    BackButton = DCSkillsWindow.GetControl(24)
    BackButton.SetText(15416)
    BackButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCSkillsBackPress)

    DCSkillsDoneButton = DCSkillsWindow.GetControl(25)
    DCSkillsDoneButton.SetText(11973)
    DCSkillsDoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)
    DCSkillsDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCSkillsDonePress)
    DCSkillsDoneButton.SetState(IE_GUI_BUTTON_DISABLED)

    # setup the default text area
    TextArea = DCSkillsWindow.GetControl(22)
    TextArea.SetText(17248)

    DCSkillsWindow.ShowModal(MODAL_SHADOW_GRAY)
    DCSkillsRedraw()
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_NAND)
    return
Esempio n. 23
0
def OpenPriestSpellInfoWindow ():
	global PriestSpellInfoWindow

	if PriestSpellInfoWindow != None:
		if PriestSpellInfoWindow:
			PriestSpellInfoWindow.Unload ()
		PriestSpellInfoWindow = None
		return

	PriestSpellInfoWindow = Window = GemRB.LoadWindow (3)

	#back
	Button = Window.GetControl (5)
	Button.SetText (15416)
	Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenPriestSpellInfoWindow)

	index = GemRB.GetVar ("SpellButton")
	if index < 100:
		ResRef = PriestMemorizedSpellList[index]
	else:
		ResRef = PriestKnownSpellList[index - 100]

	spell = GemRB.GetSpell (ResRef)

	if GUICommon.GameIsBG2():
		Label = Window.GetControl (0x0fffffff)
	else:
		Label = Window.GetControl (0x10000000)
	Label.SetText (spell['SpellName'])

	Button = Window.GetControl (2)
	Button.SetSpellIcon (ResRef, 1)

	Text = Window.GetControl (3)
	Text.SetText (spell['SpellDesc'])

	Window.ShowModal (MODAL_SHADOW_GRAY)
	return
Esempio n. 24
0
def FeedScroll ():
	global TextArea, Position

	Table = GemRB.LoadTable (TableName)
	if GUICommon.GameIsBG2():
		#this is a rather primitive selection but works for the games
		Value = Table.GetValue (0, 1)
		if Value == "REPUTATION":
			line = 2
		else:
			line = 1
		Value = Table.GetValue (line, 1)
	elif GUICommon.GameIsBG1():
		Value = Table.GetValue (Row, Position)
		if Value == 'NONE':
			Position = 1
		else:
			Position = Position + 1
	else:
		Value = Table.GetValue (Chapter, 1)

	TextArea.Append (Value, -1, 6)
	return
Esempio n. 25
0
def ReadItemWindow():
    global pause
    """Tries to learn the mage scroll."""

    pc = GemRB.GameGetSelectedPCSingle()
    slot = GemRB.GetVar("ItemButton")
    ret = Spellbook.CannotLearnSlotSpell()

    if ret:
        # couldn't find any strrefs for the other undhandled values (stat, level)
        if ret == LSR_KNOWN and GUICommon.HasTOB():
            strref = 72873
        elif ret == LSR_KNOWN and GUICommon.GameIsPST():
            strref = 50394
        elif ret == LSR_FULL and GUICommon.GameIsBG2():
            strref = 32097
        elif ret == LSR_FULL and GUICommon.GameIsPST():
            strref = 50395
        elif GUICommon.GameIsPST():
            strref = 4250
        else:
            strref = 10831

        CloseItemInfoWindow()
        OpenErrorWindow(strref)

    else:
        if GUICommon.GameIsPST():
            slot, slot_item = GUIINV.ItemHash[GemRB.GetVar('ItemButton')]

        pause = GemRB.GamePause(3, 1)  #query the pause state
        GemRB.GamePause(0, 1)
        GemRB.UseItem(pc, slot, 1, 5)
        GemRB.SetTimedEvent(DelayedReadItemWindow, 1)

    return ret
Esempio n. 26
0
def RedrawSkills():
    """Redraws the entire window.

	Called whenever a state changes, such as a proficiency or skill being
	added or taken away."""

    global DoneButton, LevelUpWindow, HLACount

    # we need to disable the HLA button if we don't have any HLAs left
    HLACount = GemRB.GetVar("HLACount")
    if GUICommon.GameIsBG2() and HLACount == 0:
        # turn the HLA button off
        HLAButton = LevelUpWindow.GetControl(126)
        HLAButton.SetState(IE_GUI_BUTTON_DISABLED)

    # enable the done button if they've allocated all points
    # sorcerer spell selection (if applicable) comes after hitting the done button
    ProfPointsLeft = GemRB.GetVar("ProfsPointsLeft")
    SkillPointsLeft = GemRB.GetVar("SkillPointsLeft")
    if ProfPointsLeft == 0 and SkillPointsLeft == 0 and HLACount == 0:
        DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
    else:
        DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    return
Esempio n. 27
0
def StartTextScreen():
    global TextScreen, TextArea, TableName, Row

    GemRB.GamePause(1, 3)

    ID = -1
    MusicName = "*"
    Message = 17556  # default: Paused for chapter text
    TableName = GemRB.GetGameString(STR_TEXTSCREEN)

    #iwd2/bg2 has no separate music
    if GUICommon.GameIsIWD1():
        if TableName == "":
            MusicName = "chap0"
        else:
            MusicName = "chap1"
        TableName = "chapters"
    elif GUICommon.GameIsIWD2():
        TableName = "chapters"

    if TableName == "":
        EndTextScreen()
        return
    else:
        TextTable = GemRB.LoadTable("textscrn", 1)
        if TextTable != None:
            TxtRow = TextTable.GetRowIndex(TableName)
            if TxtRow >= 0:
                ID = TextTable.GetValue(TxtRow, 0)
                MusicName = TextTable.GetValue(TxtRow, 1)
                Message = TextTable.GetValue(TxtRow, 2)

    if Message != "*":
        GemRB.DisplayString(Message, 0xff0000)

    if GUICommon.GameIsIWD2():
        GemRB.LoadWindowPack("GUICHAP", 800, 600)
    else:
        GemRB.LoadWindowPack("GUICHAP", 640, 480)

    if GUICommon.GameIsBG2():
        ID = 62
    elif ID == -1:
        #default: try to determine ID from current chapter
        ID = GemRB.GetGameVar("CHAPTER") & 0x7fffffff
        Chapter = ID + 1

    if MusicName != "*":
        GemRB.LoadMusicPL(MusicName + ".mus")
    else:
        GemRB.HardEndPL()

    TextScreen = GemRB.LoadWindow(ID)
    TextScreen.SetFrame()

    TextArea = TextScreen.GetControl(2)
    TextArea.SetFlags(IE_GUI_TEXTAREA_SMOOTHSCROLL)

    Table = GemRB.LoadTable(TableName)
    if GUICommon.GameIsBG1():
        #these suckers couldn't use a fix row
        FindTextRow(Table)
    elif GUICommon.GameIsBG2():
        LoadPic = Table.GetValue(-1, -1)
        if LoadPic != "":
            TextScreen.SetPicture(LoadPic)
        FindTextRow(Table)
    else:
        Row = Chapter

    #caption
    Value = Table.GetValue(Row, 0)
    #don't display the fake -1 string (No caption in toscst.2da)
    if Value != "NONE" and Value > 0 and TextScreen.HasControl(0x10000000):
        Label = TextScreen.GetControl(0x10000000)
        Label.SetText(Value)

    #done
    Button = TextScreen.GetControl(0)
    Button.SetText(11973)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, EndTextScreen)
    Button.SetFlags(IE_GUI_BUTTON_DEFAULT | IE_GUI_BUTTON_CANCEL, OP_OR)

    #replay
    Button = TextScreen.GetControl(3)
    Button.SetText(16510)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ReplayTextScreen)

    #if this was opened from somewhere other than game control close that window
    GUICommon.CloseOtherWindow(None)
    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(
        WINDOW_INVISIBLE)  #removing the gamecontrol screen
    TextScreen.SetVisible(WINDOW_VISIBLE)

    ReplayTextScreen()
    return
Esempio n. 28
0
def SetupSkillsWindow(pc,
                      type,
                      window,
                      callback,
                      level1=[0, 0, 0],
                      level2=[1, 1, 1],
                      classid=0,
                      scroll=True):
    global SkillsWindow, SkillsCallback, SkillsOffsetPress, SkillsOffsetButton1, SkillsOffsetName
    global SkillsOffsetPoints, SkillsOffsetSum, SkillsIndices, SkillPointsLeft, SkillsTopIndex
    global SkillsTable, SkillsOldPos, SkillsClickCount, SkillsOldDirection, SkillsNumButtons
    global SkillsTextArea, SkillsKitName, SkillsAssignable

    #reset some basic values
    SkillsWindow = window
    SkillsCallback = callback
    SkillsOldPos = 0
    SkillsClickCount = 0
    SkillsOldDirection = 0
    SkillsAssignable = 0
    SkillsTable = GemRB.LoadTable("skills")
    SkillPointsLeft = 0
    GemRB.SetVar("SkillPointsLeft", 0)
    SkillsNullify()

    #make sure we're within ranges
    if not window or not callback or len(level1) != len(level2):
        return

    #setup the offsets
    if type == LUSKILLS_TYPE_LEVELUP and GUICommon.GameIsBG2():
        SkillsOffsetPress = 120
        SkillsOffsetButton1 = 17
        SkillsOffsetSum = 37
        SkillsOffsetName = 32
        SkillsOffsetPoints = 43
        SkillsNumButtons = 4
        SkillsTextArea = SkillsWindow.GetControl(110)
        ScrollBar = SkillsWindow.GetControl(109)
    elif type == LUSKILLS_TYPE_LEVELUP:
        SkillsOffsetPress = -1
        SkillsOffsetButton1 = 17
        SkillsOffsetSum = 37
        SkillsOffsetName = 32
        SkillsOffsetPoints = 43
        SkillsNumButtons = 4
        SkillsTextArea = SkillsWindow.GetControl(42)
        if (scroll):
            ScrollBar = SkillsWindow.GetControl(109)
    elif type == LUSKILLS_TYPE_DUALCLASS:
        SkillsOffsetPress = 5
        SkillsOffsetButton1 = 14
        SkillsOffsetSum = 8
        SkillsOffsetName = 0
        SkillsOffsetPoints = 9
        SkillsNumButtons = 4
        SkillsTextArea = SkillsWindow.GetControl(22)
        SkillsTextArea.SetText(17248)
        if (scroll):
            ScrollBar = SkillsWindow.GetControl(26)
            ScrollBar.SetDefaultScrollBar()
    elif type == LUSKILLS_TYPE_CHARGEN:
        SkillsOffsetPress = 21
        SkillsOffsetButton1 = 11
        SkillsOffsetSum = 5
        SkillsOffsetName = 6
        SkillsOffsetPoints = 1
        SkillsNumButtons = 4
        SkillsTextArea = SkillsWindow.GetControl(19)
        SkillsTextArea.SetText(17248)
        if (scroll):
            ScrollBar = SkillsWindow.GetControl(26)
            ScrollBar.SetDefaultScrollBar()
    else:
        return

    #get our class id and name
    IsDual = GUICommon.IsDualClassed(pc, 1)
    IsMulti = GUICommon.IsMultiClassed(pc, 1)
    if classid:  #used when dual-classing
        Class = classid
    elif IsDual[0]:  #only care about the current class
        Class = CommonTables.Classes.GetValue(IsDual[2], 5)
    else:
        Class = GemRB.GetPlayerStat(pc, IE_CLASS)
    ClassName = CommonTables.Classes.GetRowName(
        CommonTables.Classes.FindValue(5, Class))

    #get the number of classes
    if IsMulti[0] > 1:
        NumClasses = IsMulti[0]
    else:
        NumClasses = 1
    if NumClasses > len(level2):
        return

    #figure out the kitname if we need it
    #protect against kitted multiclasses
    Kit = GUICommon.GetKitIndex(pc)
    if not Kit or type == LUSKILLS_TYPE_DUALCLASS or IsDual[
            0] or IsMulti[0] > 1:
        SkillsKitName = ClassName
    else:
        SkillsKitName = CommonTables.KitList.GetValue(Kit, 0, 0)

    #figure out the correct skills table
    SkillIndex = -1
    for i in range(NumClasses):
        TmpClass = Class
        if NumClasses > 1:
            TmpClass = IsMulti[i + 1]
        if (CommonTables.ClassSkills.GetValue(TmpClass, 5, 0) != "*"):
            SkillIndex = i
            break

    #see if we got a thief (or monk)
    SkillsIndices = []
    if SkillIndex >= 0:
        #SkillsKitName should be fine as all multis are in classes.2da
        #also allows for thief kits
        SkillsAssignable = 1
        for i in range(SkillsTable.GetRowCount() - 2):
            SkillName = SkillsTable.GetRowName(i + 2)
            if SkillsTable.GetValue(SkillName, SkillsKitName) != -1:
                SkillsIndices.append(i)

        LevelDiff = []
        for i in range(NumClasses):
            LevelDiff.append(level2[i] - level1[i])
        if level1[SkillIndex] == 0:
            SkillPointsLeft = SkillsTable.GetValue("FIRST_LEVEL",
                                                   SkillsKitName, 1)
            LevelDiff[SkillIndex] -= 1
        SkillPointsLeft += LevelDiff[SkillIndex] * SkillsTable.GetValue(
            "RATE", SkillsKitName, 1)
        TotalSkillsAssignable = 0

        if SkillPointsLeft < 0:
            #really don't have an entry
            SkillPointsLeft = 0
        else:
            #get racial values for dual-classing
            SkillRacTable = GemRB.LoadTable("SKILLRAC")
            Race = CommonTables.Races.FindValue(
                3, GemRB.GetPlayerStat(pc, IE_RACE))
            Race = CommonTables.Races.GetRowName(Race)

            #get the skill values
            for i in range(SkillsTable.GetRowCount() - 2):
                SkillName = SkillsTable.GetRowName(i + 2)
                SkillID = SkillsTable.GetValue(SkillName, "ID")
                if type != LUSKILLS_TYPE_LEVELUP:  #give racial bonuses to starting classes
                    SkillValue = SkillRacTable.GetValue(Race, SkillName)
                else:
                    SkillValue = GemRB.GetPlayerStat(pc, SkillID, 1)
                GemRB.SetVar("Skill " + str(i), SkillValue)
                GemRB.SetVar("SkillBase " + str(i), SkillValue)
                TotalSkillsAssignable += LUSKILLS_MAX - SkillValue

        #protect against having more skills than we can assign
        if SkillPointsLeft > TotalSkillsAssignable:
            SkillPointsLeft = TotalSkillsAssignable
        GemRB.SetVar("SkillPointsLeft", SkillPointsLeft)
    else:
        #get ranger and bard skills
        SpecialSkillsMap = []
        for i in range(NumClasses):
            if IsMulti[0] > 1:
                classname = IsMulti[i + 1]
            else:
                classname = Class
            classname = CommonTables.Classes.GetRowName(
                CommonTables.Classes.FindValue(5, classname))
            for table in "RANGERSKILL", "BARDSKILL":
                SpecialSkillsTable = CommonTables.ClassSkills.GetValue(
                    classname, table)
                if SpecialSkillsTable != "*":
                    SpecialSkillsMap.append((SpecialSkillsTable, i))
                    break
        for skills in SpecialSkillsMap:
            SpecialSkillsTable = GemRB.LoadTable(skills[0])
            for skill in range(SpecialSkillsTable.GetColumnCount()):
                skillname = SpecialSkillsTable.GetColumnName(skill)
                value = SpecialSkillsTable.GetValue(str(level2[skills[1]]),
                                                    skillname)
                skillindex = SkillsTable.GetRowIndex(skillname) - 2
                GemRB.SetVar("Skill " + str(skillindex), value)
                SkillsIndices.append(skillindex)

    #we didn't find anything, so don't continue (will show as a return of 0)
    #or don't display if we aren't leveling and have a bard/ranger
    if not len(SkillsIndices) or (not SkillPointsLeft
                                  and type != LUSKILLS_TYPE_LEVELUP):
        SkillSumLabel = SkillsWindow.GetControl(0x10000000 + SkillsOffsetSum)
        SkillSumLabel.SetText("")
        return

    #skills scrollbar
    GemRB.SetVar("SkillsTopIndex", 0)
    if len(SkillsIndices) > SkillsNumButtons:
        ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, SkillScrollBarPress)
        #decrease it with the number of controls on screen (list size) and two unrelated rows
        ScrollBar.SetVarAssoc("SkillsTopIndex",
                              SkillsTable.GetRowCount() - SkillsNumButtons - 1)
    else:
        if len(SkillsIndices) and SkillsAssignable:
            #autoscroll to the first valid skill; luckily all three monk ones are adjacent
            GemRB.SetVar("SkillsTopIndex", SkillsIndices[0])

    #setup all the visible buttons
    for i in range(len(SkillsIndices)):
        if i == SkillsNumButtons:
            break
        if SkillsOffsetPress != -1:
            Button = SkillsWindow.GetControl(i + SkillsOffsetPress)
            Button.SetVarAssoc("Skill", SkillsIndices[i])
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SkillJustPress)

        Button = SkillsWindow.GetControl(i * 2 + SkillsOffsetButton1)
        Button.SetVarAssoc("Skill", SkillsIndices[i])
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SkillLeftPress)

        Button = SkillsWindow.GetControl(i * 2 + SkillsOffsetButton1 + 1)
        Button.SetVarAssoc("Skill", SkillsIndices[i])
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, SkillRightPress)

    SkillsRedraw()
    return
Esempio n. 29
0
def StartTextScreen():
    global TextScreen, TextArea, Chapter, TableName, Row, Ticks

    if GUICommon.GameIsIWD2():
        GemRB.LoadWindowPack("GUICHAP", 800, 600)
    else:
        GemRB.LoadWindowPack("GUICHAP", 640, 480)
        if GUICommon.GameIsBG1() or GUICommon.GameIsBG2():
            Ticks = BGTICKS

    LoadPic = TableName = GemRB.GetGameString(STR_LOADMOS)
    #if there is no preset loadpic, try to determine it from the chapter
    #fixme: we always assume there isn't for non-bg2
    if GUICommon.GameIsBG2():
        if TableName == "":
            Chapter = GemRB.GetGameVar("CHAPTER") & 0x7fffffff
            TableName = "CHPTXT" + str(Chapter)
        ID = 62
    else:
        ID = GemRB.GetGameVar("CHAPTER") & 0x7fffffff
        Chapter = ID + 1

    #iwd2/bg2 has no separate music
    if GUICommon.GameIsIWD1():
        if LoadPic == "":
            GemRB.LoadMusicPL("chap0.mus")
        else:
            GemRB.LoadMusicPL("chap1.mus")
        TableName = "chapters"
    elif GUICommon.GameIsIWD2():
        GemRB.HardEndPL()
        TableName = "chapters"
    elif GUICommon.GameIsBG1() and TableName[:6] == "chptxt":
        GemRB.LoadMusicPL("chapter.mus")
    else:
        GemRB.HardEndPL()

    TextScreen = GemRB.LoadWindow(ID)
    TextScreen.SetFrame()

    TextArea = TextScreen.GetControl(2)
    TextArea.SetFlags(IE_GUI_TEXTAREA_SMOOTHSCROLL)
    TextArea.SetEvent(IE_GUI_TEXTAREA_OUT_OF_TEXT, FeedScroll)

    #caption
    Table = GemRB.LoadTable(TableName)
    if GUICommon.GameIsBG1():
        #these suckers couldn't use a fix row
        FindTextRow(Table)
    elif GUICommon.GameIsBG2():
        LoadPic = Table.GetValue(-1, -1)
        if LoadPic != "":
            TextScreen.SetPicture(LoadPic)
        FindTextRow(Table)
    else:
        Row = Chapter

    Value = Table.GetValue(Row, 0)
    #don't display the fake -1 string (No caption in toscst.2da)
    if Value != "NONE" and Value > 0 and TextScreen.HasControl(0x10000000):
        Label = TextScreen.GetControl(0x10000000)
        Label.SetText(Value)

    #done
    Button = TextScreen.GetControl(0)
    Button.SetText(11973)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, EndTextScreen)
    Button.SetFlags(IE_GUI_BUTTON_DEFAULT | IE_GUI_BUTTON_CANCEL, OP_OR)

    #replay
    Button = TextScreen.GetControl(3)
    Button.SetText(16510)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ReplayTextScreen)

    GemRB.HideGUI()
    GUICommon.GameWindow.SetVisible(
        WINDOW_INVISIBLE)  #removing the gamecontrol screen
    TextScreen.SetVisible(WINDOW_VISIBLE)

    TextArea.Rewind(Ticks)
    GemRB.DisplayString(17556, 0xff0000)  #Paused for chapter text
    GemRB.GamePause(1, 1)
    return
Esempio n. 30
0
def DualClassWindow():
    """Opens the dual class selection window."""

    global pc, OldClassName, NewMageSpells, NewPriestMask, NewClassId, OldKitName, DualClassTable
    global DCMainWindow, DCMainClassButton, DCMainDoneButton, DCMainSkillsButton, DCMainStep

    # get our basic globals
    pc = GemRB.GameGetSelectedPCSingle()
    DCMainStep = 1

    # make sure to nullify old values
    NewPriestMask = 0
    NewMageSpells = 0
    NewClassId = 0

    # set up our main window
    DCMainWindow = GemRB.LoadWindow(5)

    # done button (off)
    DCMainDoneButton = DCMainWindow.GetControl(2)
    DCMainDoneButton.SetText(11973)
    DCMainDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCMainDonePress)
    DCMainDoneButton.SetState(IE_GUI_BUTTON_DISABLED)
    DCMainDoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # cancel button (on)
    DCMainCancelButton = DCMainWindow.GetControl(1)
    DCMainCancelButton.SetText(13727)
    DCMainCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCMainCancelPress)
    DCMainCancelButton.SetState(IE_GUI_BUTTON_ENABLED)
    DCMainCancelButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # class button (on)
    DCMainClassButton = DCMainWindow.GetControl(3)
    DCMainClassButton.SetText(11959)
    DCMainClassButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCMainClassPress)
    DCMainClassButton.SetState(IE_GUI_BUTTON_ENABLED)
    DCMainClassButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # skills button (off)
    DCMainSkillsButton = DCMainWindow.GetControl(4)
    DCMainSkillsButton.SetText(17372)
    DCMainSkillsButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCMainSkillsPress)
    DCMainSkillsButton.SetState(IE_GUI_BUTTON_DISABLED)
    DCMainSkillsButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # back button (on)
    DCMainBackButton = DCMainWindow.GetControl(5)
    if GUICommon.GameIsBG2():
        DCMainBackButton.SetText(15416)
    DCMainBackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DCMainBackPress)
    DCMainBackButton.SetState(IE_GUI_BUTTON_ENABLED)
    DCMainBackButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    # picture of character
    DCMainPictureButton = DCMainWindow.GetControl(6)
    DCMainPictureButton.SetState(IE_GUI_BUTTON_LOCKED)
    DCMainPictureButton.SetFlags(
        IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET)
    DCMainPictureButton.SetPicture(GemRB.GetPlayerPortrait(pc, 0), "NOPORTMD")

    # text area warning
    DCTextArea = DCMainWindow.GetControl(7)
    DCTextArea.SetText(10811)

    # character name
    DCLabel = DCMainWindow.GetControl(0x10000008)
    DCLabel.SetText(GemRB.GetPlayerName(pc, 0))

    # class name
    Kit = GUICommon.GetKitIndex(pc)
    OldClassName = CommonTables.Classes.GetRowName(
        CommonTables.Classes.FindValue(5, GemRB.GetPlayerStat(pc, IE_CLASS)))
    if Kit:
        OldKitName = CommonTables.KitList.GetValue(Kit, 0, 0)
    else:
        OldKitName = OldClassName
    DCLabel = DCMainWindow.GetControl(0x10000009)
    DCLabel.SetText(GUICommon.GetActorClassTitle(pc))

    # get the names of the classes we can dual to
    DualClassTable = GemRB.LoadTable("dualclas")
    for i in range(DualClassTable.GetColumnCount()):
        DCClasses.append(DualClassTable.GetColumnName(i))

    # show our window
    DCMainWindow.ShowModal(MODAL_SHADOW_GRAY)
    return