Example #1
0
def RefreshInventoryWindow ():
	"""Partial redraw without resetting TopIndex."""

	Window = InventoryWindow

	pc = GemRB.GameGetSelectedPCSingle ()

	# name
	Label = Window.GetControl (0x10000032)
	Label.SetText (GemRB.GetPlayerName (pc, 0))

	# portrait
	Button = Window.GetControl (50)
	Color1 = GemRB.GetPlayerStat (pc, IE_METAL_COLOR)
	Color2 = GemRB.GetPlayerStat (pc, IE_MINOR_COLOR)
	Color3 = GemRB.GetPlayerStat (pc, IE_MAJOR_COLOR)
	Color4 = GemRB.GetPlayerStat (pc, IE_SKIN_COLOR)
	Color5 = GemRB.GetPlayerStat (pc, IE_LEATHER_COLOR)
	Color6 = GemRB.GetPlayerStat (pc, IE_ARMOR_COLOR)
	Color7 = GemRB.GetPlayerStat (pc, IE_HAIR_COLOR)
	Button.SetPLT (GUICommon.GetActorPaperDoll (pc),
		Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0, 0)

	anim_id = GemRB.GetPlayerStat (pc, IE_ANIMATION_ID)
	row = "0x%04X" %anim_id
	size = CommonTables.Pdolls.GetValue (row, "SIZE")

	# Weapon
	slot_item = GemRB.GetSlotItem (pc, GemRB.GetEquippedQuickSlot (pc) )
	if slot_item:
		item = GemRB.GetItem (slot_item["ItemResRef"])
		if (item['AnimationType'] != ''):
			Button.SetPLT ("WP" + size + item['AnimationType'] + "INV", Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0, 1)

	# Shield
	slot_item = GemRB.GetSlotItem (pc, 3)
	if slot_item:
		itemname = slot_item["ItemResRef"]
		item = GemRB.GetItem (itemname)
		if (item['AnimationType'] != ''):
			if (GemRB.CanUseItemType (SLOT_WEAPON, itemname)):
				#off-hand weapon
				Button.SetPLT ("WP" + size + item['AnimationType'] + "OIN", Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0, 2)
			else:
				#shield
				Button.SetPLT ("WP" + size + item['AnimationType'] + "INV", Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0, 2)

	# Helmet
	slot_item = GemRB.GetSlotItem (pc, 1)
	if slot_item:
		item = GemRB.GetItem (slot_item["ItemResRef"])
		if (item['AnimationType'] != ''):
			Button.SetPLT ("WP" + size + item['AnimationType'] + "INV", Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0, 3)

	# encumbrance
	GUICommon.SetEncumbranceLabels ( Window, 0x10000043, 0x10000044, pc)

	# armor class
	ac = GemRB.GetPlayerStat (pc, IE_ARMORCLASS)
	Label = Window.GetControl (0x10000038)
	Label.SetText (str (ac))
	Label.SetTooltip (10339)

	# hp current
	hp = GemRB.GetPlayerStat (pc, IE_HITPOINTS)
	Label = Window.GetControl (0x10000039)
	Label.SetText (str (hp))
	Label.SetTooltip (17184)

	# hp max
	hpmax = GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS)
	Label = Window.GetControl (0x1000003a)
	Label.SetText (str (hpmax))
	Label.SetTooltip (17378)

	# party gold
	Label = Window.GetControl (0x10000040)
	Label.SetText (str (GemRB.GameGetPartyGold ()))

	# class
	ClassTitle = GUICommon.GetActorClassTitle (pc)
	Label = Window.GetControl (0x10000042)
	Label.SetText (ClassTitle)

	Button = Window.GetControl (62)
	Color = GemRB.GetPlayerStat (pc, IE_MAJOR_COLOR, 1) & 0xFF
	Button.SetBAM ("COLGRAD", 0, 0, Color)

	Button = Window.GetControl (63)
	Color = GemRB.GetPlayerStat (pc, IE_MINOR_COLOR, 1) & 0xFF
	Button.SetBAM ("COLGRAD", 0, 0, Color)

	# update ground inventory slots
	Container = GemRB.GetContainer (pc, 1)
	TopIndex = GemRB.GetVar ("TopIndex")
	for i in range (5):
		Button = Window.GetControl (i+68)
		if GemRB.IsDraggingItem ()==1:
			Button.SetState (IE_GUI_BUTTON_FAKEPRESSED)
		else:
			Button.SetState (IE_GUI_BUTTON_ENABLED)
		Button.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP, InventoryCommon.OnDragItemGround)
		Slot = GemRB.GetContainerItem (pc, i+TopIndex)

		if Slot == None:
			Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, None)
			Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
			Button.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
		else:
			Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, InventoryCommon.OnDragItemGround)
			Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, InventoryCommon.OpenGroundItemInfoWindow)
			Button.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS, None) #TODO: implement OpenGroundItemAmountWindow

		GUICommon.UpdateInventorySlot (pc, Button, Slot, "ground")

	# making window visible/shaded depending on the pc's state
	GUICommon.AdjustWindowVisibility (Window, pc, False)
	return
Example #2
0
def RefreshInventoryWindow():
    """Partial redraw without resetting TopIndex."""

    Window = InventoryWindow

    pc = GemRB.GameGetSelectedPCSingle()

    # name
    Label = Window.GetControl(0x10000032)
    Label.SetText(GemRB.GetPlayerName(pc, 0))

    # class
    Label = Window.GetControl(0x10000042)
    Label.SetText(GUICommon.GetActorClassTitle(pc))

    # portrait
    Button = Window.GetControl(50)
    Color1 = GemRB.GetPlayerStat(pc, IE_METAL_COLOR)
    Color2 = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR)
    Color3 = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR)
    Color4 = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR)
    Color5 = GemRB.GetPlayerStat(pc, IE_LEATHER_COLOR)
    Color6 = GemRB.GetPlayerStat(pc, IE_ARMOR_COLOR)
    Color7 = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR)
    # disable coloring and equipment for non-humanoid dolls (shapes/morphs, mod additions)
    # ... which doesn't include ogres and flinds, who are also clown-colored
    # if one more exception needs to be added, rather externalise this to a new pdolls.2da flags column
    anim_id = GemRB.GetPlayerStat(pc, IE_ANIMATION_ID)
    if (anim_id < 0x5000 or anim_id >= 0x7000 or anim_id
            == 0x6404) and (anim_id != 0x8000 and anim_id != 0x9000):
        Color1 = -1
    Button.SetPLT(GUICommon.GetActorPaperDoll(pc), Color1, Color2, Color3,
                  Color4, Color5, Color6, Color7, 0, 0)
    # disable equipment for flinds and ogres and Sarevok (Recovery Mod)
    if anim_id == 0x8000 or anim_id == 0x9000 or anim_id == 0x6404:
        Color1 = -1

    row = "0x%04X" % anim_id
    size = CommonTables.Pdolls.GetValue(row, "SIZE")

    # Weapon
    slot_item = GemRB.GetSlotItem(pc, GemRB.GetEquippedQuickSlot(pc))
    if slot_item and Color1 != -1:
        item = GemRB.GetItem(slot_item["ItemResRef"])
        if (item['AnimationType'] != ''):
            Button.SetPLT("WP" + size + item['AnimationType'] + "INV", Color1,
                          Color2, Color3, Color4, Color5, Color6, Color7, 0, 1)

    # Shield
    slot_item = GemRB.GetSlotItem(pc, 3)
    if slot_item and Color1 != -1:
        itemname = slot_item["ItemResRef"]
        item = GemRB.GetItem(itemname)
        if (item['AnimationType'] != ''):
            if (GemRB.CanUseItemType(SLOT_WEAPON, itemname)):
                #off-hand weapon
                Button.SetPLT("WP" + size + item['AnimationType'] + "OIN",
                              Color1, Color2, Color3, Color4, Color5, Color6,
                              Color7, 0, 2)
            else:
                #shield
                Button.SetPLT("WP" + size + item['AnimationType'] + "INV",
                              Color1, Color2, Color3, Color4, Color5, Color6,
                              Color7, 0, 2)

    # Helmet
    slot_item = GemRB.GetSlotItem(pc, 1)
    if slot_item and Color1 != -1:
        item = GemRB.GetItem(slot_item["ItemResRef"])
        if (item['AnimationType'] != ''):
            Button.SetPLT("WP" + size + item['AnimationType'] + "INV", Color1,
                          Color2, Color3, Color4, Color5, Color6, Color7, 0, 3)

    # encumbrance
    GUICommon.SetEncumbranceLabels(Window, 0x10000043, 0x10000044, pc)

    # armor class
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label = Window.GetControl(0x10000038)
    Label.SetText(str(ac))
    Label.SetTooltip(10339)

    # hp current
    hp = GemRB.GetPlayerStat(pc, IE_HITPOINTS)
    Label = Window.GetControl(0x10000039)
    Label.SetText(str(hp))
    Label.SetTooltip(17184)

    # hp max
    hpmax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)
    Label = Window.GetControl(0x1000003a)
    Label.SetText(str(hpmax))
    Label.SetTooltip(17378)

    # party gold
    Label = Window.GetControl(0x10000040)
    Label.SetText(str(GemRB.GameGetPartyGold()))

    Button = Window.GetControl(62)
    Color = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(63)
    Color = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    # update ground inventory slots
    Container = GemRB.GetContainer(pc, 1)
    TopIndex = GemRB.GetVar("TopIndex")
    for i in range(5):
        Button = Window.GetControl(i + 68)
        if GemRB.IsDraggingItem() == 1:
            Button.SetState(IE_GUI_BUTTON_FAKEPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetEvent(IE_GUI_BUTTON_ON_DRAG_DROP,
                        InventoryCommon.OnDragItemGround)
        Slot = GemRB.GetContainerItem(pc, i + TopIndex)

        if Slot == None:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
        else:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            InventoryCommon.OnDragItemGround)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            InventoryCommon.OpenGroundItemInfoWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            None)  #TODO: implement OpenGroundItemAmountWindow

        InventoryCommon.UpdateInventorySlot(pc, Button, Slot, "ground")

    # making window visible/shaded depending on the pc's state
    GUICommon.AdjustWindowVisibility(Window, pc, False)
    return
Example #3
0
def UpdatePriestWindow(Window):
    global PriestMemorizedSpellList, PriestKnownSpellList

    PriestMemorizedSpellList = []
    PriestKnownSpellList = []

    pc = GemRB.GameGetSelectedPCSingle()
    spelltype = IE_SPELL_TYPE_PRIEST
    level = PriestSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, spelltype, level)

    ClassName = GUICommon.GetClassRowName(pc)
    CantCast = CommonTables.ClassSkills.GetValue(ClassName,
                                                 "CLERICSPELL") == "*"
    CantCast += GemRB.GetPlayerStat(pc, IE_DISABLEDBUTTON) & (1 << ACT_CAST)
    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)

    Name = GemRB.GetPlayerName(pc, 1)
    Label = Window.GetControl(0x10000027)
    Label.SetText(Name)

    Label = Window.GetControl(0x10000026)
    GemRB.SetToken('LEVEL', str(level + 1))
    Label.SetText(19672)

    mem_cnt = GemRB.GetMemorizedSpellsCount(pc, spelltype, level, False)
    for i in range(12):
        Icon = Window.GetControl(2 + i)
        color = {'r': 0, 'g': 0, 'b': 0, 'a': 160}
        Icon.SetBorder(0, color, 0, 1)
        if i < mem_cnt:
            ms = GemRB.GetMemorizedSpell(pc, spelltype, level, i)
            Icon.SetSpellIcon(ms['SpellResRef'])
            Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            if ms['Flags']:
                Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                              OpenPriestSpellUnmemorizeWindow)
            else:
                Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnPriestUnmemorizeSpell)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                          OpenPriestSpellInfoWindow)
            spell = GemRB.GetSpell(ms['SpellResRef'])
            Icon.SetTooltip(spell['SpellName'])
            PriestMemorizedSpellList.append(ms['SpellResRef'])
            Icon.EnableBorder(0, ms['Flags'] == 0)
        else:
            if i < max_mem_cnt:
                Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
                Icon.SetSprites("IVSLOT", 0, 0, 0, 0, 0)
            else:
                Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
            Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Icon.SetTooltip('')
            Icon.EnableBorder(0, 0)

    known_cnt = GemRB.GetKnownSpellsCount(pc, spelltype, level)
    btncount = 20
    i = 0
    for i in range(known_cnt):
        Icon = Window.GetControl(14 + i)
        ks = GemRB.GetKnownSpell(pc, spelltype, level, i)
        Icon.SetSpellIcon(ks['SpellResRef'])
        Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
        Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnPriestMemorizeSpell)
        Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, OpenPriestSpellInfoWindow)
        spell = GemRB.GetSpell(ks['SpellResRef'])
        Icon.SetTooltip(spell['SpellName'])
        PriestKnownSpellList.append(ks['SpellResRef'])
        Icon.SetVarAssoc("SpellButton", 100 + i)

    if known_cnt == 0: i = -1
    for i in range(i + 1, btncount):
        Icon = Window.GetControl(14 + i)
        Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
        Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
        Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
        Icon.SetTooltip('')

    return
Example #4
0
def UpdateMageWindow():
    global MageMemorizedSpellList, MageKnownSpellList

    MageMemorizedSpellList = []
    MageKnownSpellList = []

    Window = MageWindow
    pc = GemRB.GameGetSelectedPCSingle()
    type = IE_SPELL_TYPE_WIZARD
    level = MageSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, type, level, 1)

    Label = Window.GetControl(0x10000032)
    if GameCheck.IsBG2():
        GemRB.SetToken("SPELLLEVEL", str(level + 1))
        Label.SetText(10345)
    else:
        GemRB.SetToken('LEVEL', str(level + 1))
        Label.SetText(12137)

    Name = GemRB.GetPlayerName(pc, 0)
    Label = Window.GetControl(0x10000035)
    Label.SetText(Name)

    known_cnt = GemRB.GetKnownSpellsCount(pc, type, level)
    mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, False)
    true_mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, True)
    if not BookType:
        for i in range(12):
            Button = Window.GetControl(3 + i)
            Button.SetAnimation("")
            if i < mem_cnt:
                ms = GemRB.GetMemorizedSpell(pc, type, level, i)
                Button.SetSpellIcon(ms['SpellResRef'], 0)
                Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
                Button.SetFlags(IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE,
                                OP_OR)
                if ms['Flags']:
                    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                    OpenMageSpellUnmemorizeWindow)
                else:
                    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                    OnMageUnmemorizeSpell)
                Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                                OpenMageSpellInfoWindow)
                MageMemorizedSpellList.append(ms['SpellResRef'])
                Button.SetVarAssoc("SpellButton", i)
                Button.EnableBorder(0, ms['Flags'] == 0)
                spell = GemRB.GetSpell(ms['SpellResRef'])
                if not spell:
                    print "Missing memorised spell!", ms['SpellResRef']
                    continue
                Button.SetTooltip(spell['SpellName'])
            else:
                if i < max_mem_cnt:
                    Button.SetFlags(
                        IE_GUI_BUTTON_NORMAL | IE_GUI_BUTTON_PLAYONCE, OP_SET)
                else:
                    Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
                Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
                Button.SetTooltip('')
                Button.EnableBorder(0, 0)
    else:
        label = Window.GetControl(0x10000040)
        if known_cnt:
            # we give sorcerers all charges for all the spells, so some extra math is needed
            label.SetText(
                GemRB.GetString(61256) + " " + str(true_mem_cnt / known_cnt) +
                "/" + str(max_mem_cnt))
        else:
            label.SetText("")

    for i in range(GUICommon.GetGUISpellButtonCount()):
        Button = Window.GetControl(27 + i)
        Button.SetAnimation("")
        if i < known_cnt:
            ks = GemRB.GetKnownSpell(pc, type, level, i)
            Button.SetSpellIcon(ks['SpellResRef'], 0)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnMageMemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenMageSpellInfoWindow)
            MageKnownSpellList.append(ks['SpellResRef'])
            Button.SetVarAssoc("SpellButton", 100 + i)
            spell = GemRB.GetSpell(ks['SpellResRef'])
            if not spell:
                print "Missing known spell!", ms['SpellResRef']
                continue
            Button.SetTooltip(spell['SpellName'])
        else:
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetTooltip('')
            Button.EnableBorder(0, 0)

    CantCast = CommonTables.ClassSkills.GetValue(GUICommon.GetClassRowName(pc),
                                                 "MAGESPELL") == "*"
    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)
    return
Example #5
0
def UpdatePriestWindow():
    global PriestMemorizedSpellList, PriestKnownSpellList

    PriestMemorizedSpellList = []
    PriestKnownSpellList = []

    Window = PriestWindow
    pc = GemRB.GameGetSelectedPCSingle()
    type = IE_SPELL_TYPE_PRIEST
    level = PriestSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, type, level)

    Label = Window.GetControl(0x10000032)
    # bg2 uses a shorthand form
    if GameCheck.IsBG2():
        GemRB.SetToken("SPELLLEVEL", str(level + 1))
        Label.SetText(10345)
    else:
        GemRB.SetToken('LEVEL', str(level + 1))
        Label.SetText(12137)

    Name = GemRB.GetPlayerName(pc, 0)
    Label = Window.GetControl(0x10000035)
    Label.SetText(Name)

    mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, False)
    for i in range(12):
        Button = Window.GetControl(3 + i)
        Button.SetAnimation("")
        if i < mem_cnt:
            ms = GemRB.GetMemorizedSpell(pc, type, level, i)
            Button.SetSpellIcon(ms['SpellResRef'], 0)
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            Button.SetFlags(
                IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE
                | IE_GUI_BUTTON_PLAYALWAYS, OP_OR)
            if ms['Flags']:
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OpenPriestSpellUnmemorizeWindow)
            else:
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OnPriestUnmemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenPriestSpellInfoWindow)
            spell = GemRB.GetSpell(ms['SpellResRef'])
            Button.SetTooltip(spell['SpellName'])
            PriestMemorizedSpellList.append(ms['SpellResRef'])
            Button.SetVarAssoc("SpellButton", i)
            Button.EnableBorder(0, ms['Flags'] == 0)
        else:
            if i < max_mem_cnt:
                Button.SetFlags(
                    IE_GUI_BUTTON_NORMAL | IE_GUI_BUTTON_PLAYONCE
                    | IE_GUI_BUTTON_PLAYALWAYS, OP_SET)
            else:
                Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetTooltip('')
            Button.EnableBorder(0, 0)

    known_cnt = GemRB.GetKnownSpellsCount(pc, type, level)
    for i in range(GUICommon.GetGUISpellButtonCount()):
        Button = Window.GetControl(27 + i)
        Button.SetAnimation("")
        if i < known_cnt:
            ks = GemRB.GetKnownSpell(pc, type, level, i)
            Button.SetSpellIcon(ks['SpellResRef'], 0)
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnPriestMemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenPriestSpellInfoWindow)
            spell = GemRB.GetSpell(ks['SpellResRef'])
            Button.SetTooltip(spell['SpellName'])
            PriestKnownSpellList.append(ks['SpellResRef'])
            Button.SetVarAssoc("SpellButton", 100 + i)
        else:
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetTooltip('')
            Button.EnableBorder(0, 0)

    ClassName = GUICommon.GetClassRowName(pc)
    DivineCaster = CommonTables.ClassSkills.GetValue(ClassName, "CLERICSPELL")
    if DivineCaster == "*":
        # also check the DRUIDSPELL column
        DivineCaster = CommonTables.ClassSkills.GetValue(
            ClassName, "DRUIDSPELL")
    CantCast = DivineCaster == "*"
    CantCast += GemRB.GetPlayerStat(pc, IE_DISABLEDBUTTON) & (1 << ACT_CAST)

    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)
    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    #bringing window front
    Window.SetVisible(WINDOW_FRONT)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    return
Example #6
0
def RefreshInventoryWindow(Window):
    """Partial redraw without resetting TopIndex."""

    pc = GemRB.GameGetSelectedPCSingle()

    # name
    Label = Window.GetControl(0x10000039)
    Label.SetText(GemRB.GetPlayerName(pc, 1))

    # portrait
    Button = Window.GetControl(44)
    Button.SetPicture(GUICommonWindows.GetActorPortrait(pc, 'INVENTORY'))

    # there's a label at 0x1000003a, but we don't need it
    GUICommon.SetEncumbranceLabels(Window, 46, None, pc)

    # armor class
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label = Window.GetControl(0x1000003a)
    Label.SetText(str(ac))

    # hp current
    hp = GemRB.GetPlayerStat(pc, IE_HITPOINTS)
    Label = Window.GetControl(0x1000003b)
    Label.SetText(str(hp))

    # hp max
    hpmax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)
    Label = Window.GetControl(0x1000003c)
    Label.SetText(str(hpmax))

    # party gold
    Label = Window.GetControl(0x1000003e)
    Label.SetText(str(GemRB.GameGetPartyGold()))

    # class
    text = CommonTables.Classes.GetValue(GUICommon.GetClassRowName(pc),
                                         "NAME_REF")

    Label = Window.GetControl(0x1000003f)
    Label.SetText(text)

    GUICommon.AdjustWindowVisibility(Window, pc, False)

    # update ground inventory slots
    TopIndex = GemRB.GetVar("TopIndex")
    for i in range(10):
        Button = Window.GetControl(i + 47)
        if GemRB.IsDraggingItem():
            Button.SetState(IE_GUI_BUTTON_FAKEPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetAction(InventoryCommon.OnDragItemGround,
                         IE_ACT_DRAG_DROP_DST)
        Slot = GemRB.GetContainerItem(pc, i + TopIndex)
        if Slot != None:
            item = GemRB.GetItem(Slot['ItemResRef'])
            identified = Slot["Flags"] & IE_INV_ITEM_IDENTIFIED

            Button.SetItemIcon(Slot['ItemResRef'])
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
            if item['MaxStackAmount'] > 1:
                Button.SetText(str(Slot['Usages0']))
            else:
                Button.SetText('')
            if not identified or item["ItemNameIdentified"] == -1:
                Button.SetTooltip(item["ItemName"])
                Button.EnableBorder(0, 1)
            else:
                Button.SetTooltip(item["ItemNameIdentified"])
                Button.EnableBorder(0, 0)

            Button.SetValue(i + TopIndex)
            Button.SetAction(InventoryCommon.OnDragItemGround,
                             IE_ACT_DRAG_DROP_CRT)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            InventoryCommon.OnDragItemGround)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            InventoryCommon.OpenGroundItemInfoWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            InventoryCommon.OpenGroundItemAmountWindow)

        else:
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetTooltip(4273)
            Button.SetText('')
            Button.EnableBorder(0, 0)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
    return
Example #7
0
def UpdateSpellBookWindow():
    global SpellBookSpellLevel

    Window = SpellBookWindow
    pc = GemRB.GameGetSelectedPCSingle()

    for i in range(4):
        Button = Window.GetControl(88 + i)

        if len(ActiveSpellBooks) > BookTopIndex + i:
            type = ActiveSpellBooks[BookTopIndex + i]
            Button.SetText(BookNames[type])
            Button.SetVarAssoc("SelectedBook", type)
            Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
            Button.SetState(IE_GUI_BUTTON_ENABLED)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, UpdateSpellBook)
        else:
            Button.SetState(IE_GUI_BUTTON_DISABLED)
            Button.SetText("")

    SelectedBook = GemRB.GetVar("SelectedBook")
    type = SelectedBook
    level = SpellBookSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, type, level)
    sorcerer_style = (type
                      == IE_IWD2_SPELL_BARD) or (type
                                                 == IE_IWD2_SPELL_SORCERER)

    Name = GemRB.GetPlayerName(pc, 0)
    Label = Window.GetControl(0xfffffff)
    Label.SetText(Name)

    Button = Window.GetControl(1)
    Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0))
    Button.SetState(IE_GUI_BUTTON_LOCKED)

    mem_cnt = GetMemorizedSpellsCount()  # count of unique memorized spells
    true_mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, True)
    for i in range(24):
        Button = Window.GetControl(6 + i)
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
        Label = Window.GetControl(0x1000003f + i)
        # actually, it doesn't display any memorized spells for sorcerer-style spellbooks
        if i < mem_cnt and not sorcerer_style:
            ms = MemorizedSpellList[i]
            spell = ms['SpellResRef']
            Button.SetSpellIcon(spell)
            Button.SetFlags(IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE,
                            OP_OR)
            Button.SetTooltip(ms['SpellName'])
            Button.SetVarAssoc("SpellButton", i)
            # since spells are stacked, we need to check first whether to unmemorize (deplete) or remove (already depeleted)
            if ms['MemoCount'] < ms['KnownCount']:
                # already depleted, just remove
                Button.SetEvent(
                    IE_GUI_BUTTON_ON_PRESS,
                    lambda: OnSpellBookUnmemorizeSpell(ms['MemoCount']))
            else:
                # deplete and remove
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OpenSpellBookSpellRemoveWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenSpellBookSpellInfoWindow)
            tmp = str(ms['MemoCount']) + "/" + str(ms['KnownCount'])
            Label.SetText(tmp)
        else:
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.EnableBorder(0, 0)
            Label.SetText('')

    known_cnt = len(KnownSpellList)
    SpellTopIndex = GemRB.GetVar("SpellTopIndex")
    for i in range(8):
        Button = Window.GetControl(30 + i)
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
        Label = Window.GetControl(0x10000025 + i)
        if i + SpellTopIndex < known_cnt:
            ks = KnownSpellList[i + SpellTopIndex]
            spell = ks['SpellResRef']
            Button.SetSpellIcon(spell)
            if not sorcerer_style:
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OnSpellBookMemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenSpellBookSpellInfoWindow)
            Label.SetText(ks['SpellName'])
            Button.SetVarAssoc("SpellButton", 100 + i + SpellTopIndex)
        else:
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.EnableBorder(0, 0)
            Label.SetText('')

    # number of available spell slots
    # sorcerer-style books are different, since max_mem_cnt holds the total level capacity, not the slot count
    # and they display just the current and total number of memorizations per level
    Label = Window.GetControl(0x10000004)
    if sorcerer_style:
        Label.SetText(str(true_mem_cnt) + "/" + str(max_mem_cnt))
    else:
        # reset mem_cnt to take into account stacks
        mem_cnt = GetMemorizedSpellsCount(True)
        Label.SetText(str(max_mem_cnt - mem_cnt))

    #if actor is uncontrollable, make this grayed
    CantCast = GemRB.GetPlayerStat(pc, IE_DISABLEDBUTTON) & (1 << ACT_CAST)
    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)

    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    return
Example #8
0
def RefreshInventoryWindow():
    Window = InventoryWindow

    pc = GemRB.GameGetSelectedPCSingle()

    # name
    Label = Window.GetControl(0x10000032)
    Label.SetText(GemRB.GetPlayerName(pc, 0))

    # paperdoll
    Button = Window.GetControl(50)
    Button.SetFlags(IE_GUI_BUTTON_CENTER_PICTURES, OP_OR)
    pdoll = GUICommonWindows.GetActorPaperDoll(pc) + "G11"
    if GemRB.HasResource(pdoll, RES_BAM):
        pal = [
            GemRB.GetPlayerStat(pc, c)
            for c in range(IE_METAL_COLOR, IE_HAIR_COLOR + 1)
        ]
        Button.SetAnimation(pdoll, 0, 0, pal)

    # portrait
    Button = Window.GetControl(84)
    Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0)["Sprite"])

    # encumbrance
    GUICommon.SetEncumbranceLabels(Window, 0x10000042, None, pc)

    # armor class
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label = Window.GetControl(0x10000038)
    Label.SetText(str(ac))

    # hp current
    hp = GemRB.GetPlayerStat(pc, IE_HITPOINTS)
    Label = Window.GetControl(0x10000039)
    Label.SetText(str(hp))

    # hp max
    hpmax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)
    Label = Window.GetControl(0x1000003a)
    Label.SetText(str(hpmax))

    # party gold
    Label = Window.GetControl(0x10000040)
    Label.SetText(str(GemRB.GameGetPartyGold()))

    Button = Window.GetControl(62)
    Color = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(63)
    Color = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(82)
    Color = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(83)
    Color = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    # update ground inventory slots
    TopIndex = GemRB.GetVar("TopIndex")
    for i in range(6):
        if i < 5:
            Button = Window.GetControl(i + 68)
        else:
            Button = Window.GetControl(i + 76)

        if GemRB.IsDraggingItem() == 1:
            Button.SetState(IE_GUI_BUTTON_FAKEPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetAction(InventoryCommon.OnDragItemGround,
                         IE_ACT_DRAG_DROP_DST)

        Slot = GemRB.GetContainerItem(pc, i + TopIndex)
        if Slot == None:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
        else:
            Button.SetAction(InventoryCommon.OnDragItemGround,
                             IE_ACT_DRAG_DROP_CRT)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            InventoryCommon.OnDragItemGround)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            InventoryCommon.OpenGroundItemInfoWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            InventoryCommon.OpenGroundItemAmountWindow)

        InventoryCommon.UpdateInventorySlot(pc, Button, Slot, "ground")

    #if actor is uncontrollable, make this grayed
    GUICommon.AdjustWindowVisibility(Window, pc, False)
    return
Example #9
0
def UpdateRecordsWindow ():
	global RecordsTextArea

	Window = RecordsWindow

	pc = GemRB.GameGetSelectedPCSingle ()

	#name
	Label = Window.GetControl (0x1000000e)
	Label.SetText (GemRB.GetPlayerName (pc, 0))

	#portrait
	Button = Window.GetControl (2)
	Button.SetPicture (GemRB.GetPlayerPortrait (pc,0))

	# armorclass
	Label = Window.GetControl (0x10000028)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_ARMORCLASS)))
	Label.SetTooltip (17183)

	# hp now
	Label = Window.GetControl (0x10000029)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_HITPOINTS)))
	Label.SetTooltip (17184)

	# hp max
	Label = Window.GetControl (0x1000002a)
	Label.SetText (str (GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS)))
	Label.SetTooltip (17378)

	#level up
	Button = Window.GetControl (37)
	levelsum = GemRB.GetPlayerStat (pc, IE_CLASSLEVELSUM)
	if GetNextLevelExp(levelsum, GetECL(pc)) <= GemRB.GetPlayerStat (pc, IE_XP):
		Button.SetState (IE_GUI_BUTTON_ENABLED)
	else:
		Button.SetState (IE_GUI_BUTTON_DISABLED)

	# stats

	sstr = GemRB.GetPlayerStat (pc, IE_STR)
	dstr = sstr-GemRB.GetPlayerStat (pc, IE_STR,1)
	bstr = GUICommon.GetAbilityBonus (pc, IE_STR)
	sint = GemRB.GetPlayerStat (pc, IE_INT)
	dint = sint-GemRB.GetPlayerStat (pc, IE_INT,1)
	bint = GUICommon.GetAbilityBonus (pc, IE_INT)
	swis = GemRB.GetPlayerStat (pc, IE_WIS)
	dwis = swis-GemRB.GetPlayerStat (pc, IE_WIS,1)
	bwis = GUICommon.GetAbilityBonus (pc, IE_WIS)
	sdex = GemRB.GetPlayerStat (pc, IE_DEX)
	ddex = sdex-GemRB.GetPlayerStat (pc, IE_DEX,1)
	bdex = GUICommon.GetAbilityBonus (pc, IE_DEX)
	scon = GemRB.GetPlayerStat (pc, IE_CON)
	dcon = scon-GemRB.GetPlayerStat (pc, IE_CON,1)
	bcon = GUICommon.GetAbilityBonus (pc, IE_CON)
	schr = GemRB.GetPlayerStat (pc, IE_CHR)
	dchr = schr-GemRB.GetPlayerStat (pc, IE_CHR,1)
	bchr = GUICommon.GetAbilityBonus (pc, IE_CHR)

	Label = Window.GetControl (0x1000002f)
	Label.SetText (str(sstr))
	ColorDiff2 (Window, Label, dstr)

	Label = Window.GetControl (0x10000009)
	Label.SetText (str(sdex))
	ColorDiff2 (Window, Label, ddex)

	Label = Window.GetControl (0x1000000a)
	Label.SetText (str(scon))
	ColorDiff2 (Window, Label, dcon)

	Label = Window.GetControl (0x1000000b)
	Label.SetText (str(sint))
	ColorDiff2 (Window, Label, dint)

	Label = Window.GetControl (0x1000000c)
	Label.SetText (str(swis))
	ColorDiff2 (Window, Label, dwis)

	Label = Window.GetControl (0x1000000d)
	Label.SetText (str(schr))
	ColorDiff2 (Window, Label, dchr)

	Label = Window.GetControl (0x10000035)
	Label.SetText (PlusMinusStat(bstr))
	ColorDiff (Window, Label, bstr)

	Label = Window.GetControl (0x10000036)
	Label.SetText (PlusMinusStat(bdex))
	ColorDiff (Window, Label, bdex)

	Label = Window.GetControl (0x10000037)
	Label.SetText (PlusMinusStat(bcon))
	ColorDiff (Window, Label, bcon)

	Label = Window.GetControl (0x10000038)
	Label.SetText (PlusMinusStat(bint))
	ColorDiff (Window, Label, bint)

	Label = Window.GetControl (0x10000039)
	Label.SetText (PlusMinusStat(bwis))
	ColorDiff (Window, Label, bwis)

	Label = Window.GetControl (0x1000003a)
	Label.SetText (PlusMinusStat(bchr))
	ColorDiff (Window, Label, bchr)

	RecordsTextArea = Window.GetControl (45)
	RecordsTextArea.SetText ("")
	RecordsTextArea.Append ("[capital=0]")

	DisplayCommon (pc)

	SelectWindow = GemRB.GetVar ("SelectWindow")
	if SelectWindow == 1:
		DisplayGeneral (pc)
	elif SelectWindow == 2:
		DisplayWeapons (pc)
	elif SelectWindow == 3:
		DisplaySkills (pc)
	elif SelectWindow == 4:
		DisplayMisc (pc)

	#if actor is uncontrollable, make this grayed
	GUICommon.AdjustWindowVisibility (Window, pc, 0)
	PortraitWindow.SetVisible (WINDOW_VISIBLE)
	OptionsWindow.SetVisible (WINDOW_VISIBLE)
	return
Example #10
0
def UpdateMageWindow():
    global MageMemorizedSpellList, MageKnownSpellList

    MageMemorizedSpellList = []
    MageKnownSpellList = []

    Window = MageWindow
    pc = GemRB.GameGetSelectedPCSingle()
    type = IE_SPELL_TYPE_WIZARD
    level = MageSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, type, level)

    Name = GemRB.GetPlayerName(pc, 1)
    Label = Window.GetControl(0x10000027)
    Label.SetText(Name)

    Label = Window.GetControl(0x10000026)
    GemRB.SetToken('LEVEL', str(level + 1))
    Label.SetText(19672)
    mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, False)
    for i in range(12):
        Icon = Window.GetControl(2 + i)
        Icon.SetBorder(0, 0, 0, 0, 0, 0, 0, 0, 160, 0, 1)
        if i < mem_cnt:
            ms = GemRB.GetMemorizedSpell(pc, type, level, i)
            Icon.SetSpellIcon(ms['SpellResRef'])
            Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            if ms['Flags']:
                Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                              OpenMageSpellUnmemorizeWindow)
            else:
                Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnMageUnmemorizeSpell)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                          OpenMageSpellInfoWindow)
            spell = GemRB.GetSpell(ms['SpellResRef'])
            Icon.SetTooltip(spell['SpellName'])
            MageMemorizedSpellList.append(ms['SpellResRef'])
            Icon.SetVarAssoc("SpellButton", i)
            Icon.EnableBorder(0, ms['Flags'] == 0)
        else:
            if i < max_mem_cnt:
                Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
                Icon.SetSprites("IVSLOT", 0, 0, 0, 0, 0)
            else:
                Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
            Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Icon.SetTooltip('')
            Icon.EnableBorder(0, 0)

    #--------------------------test-----------------------------#
    print "max_mem_cnt is: ", max_mem_cnt
    print "mem_cnt is:     ", mem_cnt
    known_cnt = GemRB.GetKnownSpellsCount(pc, type, level)
    for i in range(20):
        Icon = Window.GetControl(14 + i)
        if i < known_cnt:
            ks = GemRB.GetKnownSpell(pc, type, level, i)
            Icon.SetSpellIcon(ks['SpellResRef'])
            Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnMageMemorizeSpell)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                          OpenMageSpellInfoWindow)
            spell = GemRB.GetSpell(ks['SpellResRef'])
            Icon.SetTooltip(spell['SpellName'])
            MageKnownSpellList.append(ks['SpellResRef'])
            Icon.SetVarAssoc("SpellButton", 100 + i)
        else:
            Icon.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
            Icon.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Icon.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Icon.SetTooltip('')

    CantCast = CommonTables.ClassSkills.GetValue(GUICommon.GetClassRowName(pc),
                                                 "MAGESPELL") == "*"
    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)
Example #11
0
def RefreshInventoryWindow():
    Window = InventoryWindow

    pc = GemRB.GameGetSelectedPCSingle()

    # name
    Label = Window.GetControl(0x10000032)
    Label.SetText(GemRB.GetPlayerName(pc, 0))

    # paperdoll
    Button = Window.GetControl(50)
    Color1 = GemRB.GetPlayerStat(pc, IE_METAL_COLOR)
    Color2 = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR)
    Color3 = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR)
    Color4 = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR)
    Color5 = GemRB.GetPlayerStat(pc, IE_LEATHER_COLOR)
    Color6 = GemRB.GetPlayerStat(pc, IE_ARMOR_COLOR)
    Color7 = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR)

    Button.SetFlags(IE_GUI_BUTTON_CENTER_PICTURES, OP_OR)
    pdoll = GUICommonWindows.GetActorPaperDoll(pc) + "WK"
    # FIXME: animation bleeds through top window
    # NOTE: regenerate invenwin.png with a transparent hole if we
    # can ever keep drawing the gamecontrol underneath ...
    # and then remove this block
    if GemRB.HasResource(pdoll, RES_BAM):
        Button.SetAnimation(pdoll)
        Button.SetAnimationPalette(Color1, Color2, Color3, Color4, Color5,
                                   Color6, Color7, 0)

    # portrait
    Button = Window.GetControl(84)
    # NOTE: use FillPlayerInfo or code to switch pics iff the party will grow
    #Button.SetPicture (GemRB.GetPlayerPortrait (pc,0))
    Button.SetPicture("portr1L")

    # encumbrance
    GUICommon.SetEncumbranceLabels(Window, 0x10000042, None, pc)

    # armor class
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label = Window.GetControl(0x10000038)
    Label.SetText(str(ac))

    # hp current
    hp = GemRB.GetPlayerStat(pc, IE_HITPOINTS)
    Label = Window.GetControl(0x10000039)
    Label.SetText(str(hp))

    # hp max
    hpmax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)
    Label = Window.GetControl(0x1000003a)
    Label.SetText(str(hpmax))

    # party gold
    Label = Window.GetControl(0x10000040)
    Label.SetText(str(GemRB.GameGetPartyGold()))

    Button = Window.GetControl(62)
    Color = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(63)
    Color = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(82)
    Color = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(83)
    Color = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    # update ground inventory slots
    Container = GemRB.GetContainer(pc, 1)
    TopIndex = GemRB.GetVar("TopIndex")
    for i in range(6):
        if i < 5:
            Button = Window.GetControl(i + 68)
        else:
            Button = Window.GetControl(i + 76)

        if GemRB.IsDraggingItem() == 1:
            Button.SetState(IE_GUI_BUTTON_FAKEPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetEvent(IE_GUI_BUTTON_ON_DRAG_DROP,
                        InventoryCommon.OnDragItemGround)

        Slot = GemRB.GetContainerItem(pc, i + TopIndex)
        if Slot == None:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
        else:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            InventoryCommon.OnDragItemGround)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            InventoryCommon.OpenGroundItemInfoWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            InventoryCommon.OpenGroundItemAmountWindow)

        InventoryCommon.UpdateInventorySlot(pc, Button, Slot, "ground")

    #if actor is uncontrollable, make this grayed
    GUICommon.AdjustWindowVisibility(Window, pc, False)
    return
Example #12
0
def UpdateMageWindow():
    global MageMemorizedSpellList, MageKnownSpellList

    MageMemorizedSpellList = []
    MageKnownSpellList = []

    Window = MageWindow
    pc = GemRB.GameGetSelectedPCSingle()
    type = IE_SPELL_TYPE_WIZARD
    level = MageSpellLevel
    max_mem_cnt = GemRB.GetMemorizableSpellsCount(pc, type, level)

    Label = Window.GetControl(0x10000032)
    GemRB.SetToken('LEVEL', str(level + 1))
    Label.SetText(12137)

    Name = GemRB.GetPlayerName(pc, 0)
    Label = Window.GetControl(0x10000035)
    Label.SetText(Name)
    mem_cnt = GemRB.GetMemorizedSpellsCount(pc, type, level, False)
    for i in range(12):
        Button = Window.GetControl(3 + i)
        if i < mem_cnt:
            ms = GemRB.GetMemorizedSpell(pc, type, level, i)
            Button.SetSpellIcon(ms['SpellResRef'], 0)
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
            Button.SetFlags(IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_PLAYONCE,
                            OP_OR)
            if ms['Flags']:
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                OpenMageSpellUnmemorizeWindow)
            else:
                Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnMageUnmemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenMageSpellInfoWindow)
            spell = GemRB.GetSpell(ms['SpellResRef'])
            Button.SetTooltip(spell['SpellName'])
            MageMemorizedSpellList.append(ms['SpellResRef'])
            Button.SetVarAssoc("SpellButton", i)
            Button.EnableBorder(0, ms['Flags'] == 0)
        else:
            if i < max_mem_cnt:
                Button.SetFlags(IE_GUI_BUTTON_NORMAL | IE_GUI_BUTTON_PLAYONCE,
                                OP_SET)
            else:
                Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetTooltip('')
            Button.EnableBorder(0, 0)

    known_cnt = GemRB.GetKnownSpellsCount(pc, type, level)
    for i in range(GUICommon.GetGUISpellButtonCount()):
        Button = Window.GetControl(27 + i)
        if i < known_cnt:
            ks = GemRB.GetKnownSpell(pc, type, level, i)
            Button.SetSpellIcon(ks['SpellResRef'], 0)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OnMageMemorizeSpell)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            OpenMageSpellInfoWindow)
            spell = GemRB.GetSpell(ks['SpellResRef'])
            Button.SetTooltip(spell['SpellName'])
            MageKnownSpellList.append(ks['SpellResRef'])
            Button.SetVarAssoc("SpellButton", 100 + i)

        else:
            Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetTooltip('')
            Button.EnableBorder(0, 0)

    CantCast = CommonTables.ClassSkills.GetValue(GUICommon.GetClassRowName(pc),
                                                 "MAGESPELL") == "*"
    GUICommon.AdjustWindowVisibility(Window, pc, CantCast)
    return
Example #13
0
def RefreshInventoryWindow():
    Window = InventoryWindow

    pc = GemRB.GameGetSelectedPCSingle()

    # name
    Label = Window.GetControl(0x10000032)
    Label.SetText(GemRB.GetPlayerName(pc, 0))

    # paperdoll
    Button = Window.GetControl(50)
    Color1 = GemRB.GetPlayerStat(pc, IE_METAL_COLOR)
    Color2 = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR)
    Color3 = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR)
    Color4 = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR)
    Color5 = GemRB.GetPlayerStat(pc, IE_LEATHER_COLOR)
    Color6 = GemRB.GetPlayerStat(pc, IE_ARMOR_COLOR)
    Color7 = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR)

    Button.SetFlags(IE_GUI_BUTTON_CENTER_PICTURES, OP_OR)
    Button.SetAnimation(GUICommonWindows.GetActorPaperDoll(pc) + "G11")
    Button.SetAnimationPalette(Color1, Color2, Color3, Color4, Color5, Color6,
                               Color7, 0)

    # portrait
    Button = Window.GetControl(84)
    Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0))

    # encumbrance
    GUICommon.SetEncumbranceLabels(Window, 0x10000042, None, pc)

    # armor class
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label = Window.GetControl(0x10000038)
    Label.SetText(str(ac))

    # hp current
    hp = GemRB.GetPlayerStat(pc, IE_HITPOINTS)
    Label = Window.GetControl(0x10000039)
    Label.SetText(str(hp))

    # hp max
    hpmax = GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS)
    Label = Window.GetControl(0x1000003a)
    Label.SetText(str(hpmax))

    # party gold
    Label = Window.GetControl(0x10000040)
    Label.SetText(str(GemRB.GameGetPartyGold()))

    Button = Window.GetControl(62)
    Color = GemRB.GetPlayerStat(pc, IE_MAJOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(63)
    Color = GemRB.GetPlayerStat(pc, IE_MINOR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(82)
    Color = GemRB.GetPlayerStat(pc, IE_HAIR_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    Button = Window.GetControl(83)
    Color = GemRB.GetPlayerStat(pc, IE_SKIN_COLOR, 1) & 0xFF
    Button.SetBAM("COLGRAD", 0, 0, Color)

    # update ground inventory slots
    Container = GemRB.GetContainer(pc, 1)
    TopIndex = GemRB.GetVar("TopIndex")
    for i in range(6):
        if i < 5:
            Button = Window.GetControl(i + 68)
        else:
            Button = Window.GetControl(i + 76)

        if GemRB.IsDraggingItem() == 1:
            Button.SetState(IE_GUI_BUTTON_FAKEPRESSED)
        else:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetEvent(IE_GUI_BUTTON_ON_DRAG_DROP,
                        InventoryCommon.OnDragItemGround)

        Slot = GemRB.GetContainerItem(pc, i + TopIndex)
        if Slot == None:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS, None)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS, None)
        else:
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                            InventoryCommon.OnDragItemGround)
            Button.SetEvent(IE_GUI_BUTTON_ON_RIGHT_PRESS,
                            InventoryCommon.OpenGroundItemInfoWindow)
            Button.SetEvent(IE_GUI_BUTTON_ON_SHIFT_PRESS,
                            None)  #TODO: implement OpenGroundItemAmountWindow

        GUICommon.UpdateInventorySlot(pc, Button, Slot, "ground")

    #if actor is uncontrollable, make this grayed
    GUICommon.AdjustWindowVisibility(Window, pc, False)
    PortraitWindow.SetVisible(WINDOW_VISIBLE)
    OptionsWindow.SetVisible(WINDOW_VISIBLE)
    return