def UpdateFloatMenuWindow (): Window = FloatMenuWindow # this enables the use of hotkeys without the window being open if not FloatMenuWindow: return pc = GemRB.GameGetFirstSelectedPC () Button = Window.GetControl (CID_PORTRAIT) Button.SetSprites (GUICommonWindows.GetActorPortrait (pc, 'FMENU'), 0, 0, 1, 2, 3) Button = Window.GetControl (CID_PREV) Button.SetState (IE_GUI_BUTTON_DISABLED) Button = Window.GetControl (CID_NEXT) Button.SetState (IE_GUI_BUTTON_DISABLED) updaterFunc = None if float_menu_mode == MENU_MODE_SINGLE: updaterFunc = UpdateFloatMenuSingleAction elif float_menu_mode == MENU_MODE_GROUP: updaterFunc = UpdateFloatMenuGroupAction elif float_menu_mode == MENU_MODE_WEAPONS: # weapons updaterFunc = lambda i: UpdateFloatMenuItem (pc, i, 1) elif float_menu_mode == MENU_MODE_ITEMS: # items updaterFunc = lambda i: UpdateFloatMenuItem (pc, i, 0) elif float_menu_mode == MENU_MODE_SPELLS: # spells RefreshSpellList(pc, False) Button = Window.GetControl (CID_PREV) Button.SetState (IE_GUI_BUTTON_ENABLED) Button = Window.GetControl (CID_NEXT) Button.SetState (IE_GUI_BUTTON_ENABLED) updaterFunc = lambda i: UpdateFloatMenuSpell (pc, i) elif float_menu_mode == MENU_MODE_ABILITIES: # abilities RefreshSpellList(pc, True) if float_menu_index: Button = Window.GetControl (CID_PREV) Button.SetState (IE_GUI_BUTTON_ENABLED) if float_menu_index+3<len(spell_list): Button = Window.GetControl (CID_NEXT) Button.SetState (IE_GUI_BUTTON_ENABLED) updaterFunc = lambda i: UpdateFloatMenuSpell (pc, i) elif float_menu_mode == MENU_MODE_DIALOG: updaterFunc = ClearSlot if not updaterFunc: return for i in range (SLOT_COUNT): updaterFunc (i) return
def UpdateFloatMenuWindow (): Window = FloatMenuWindow # this enables the use of hotkeys without the window being open if not FloatMenuWindow: return pc = GemRB.GameGetFirstSelectedPC () Button = Window.GetControl (0) Button.SetSprites (GUICommonWindows.GetActorPortrait (pc, 'FMENU'), 0, 0, 1, 2, 3) Button = Window.GetControl (13) Button.SetState (IE_GUI_BUTTON_LOCKED) Button = Window.GetControl (14) Button.SetState (IE_GUI_BUTTON_LOCKED) if float_menu_mode == MENU_MODE_SINGLE: for i in range (5): UpdateFloatMenuSingleAction (i) elif float_menu_mode == MENU_MODE_GROUP: for i in range (5): UpdateFloatMenuGroupAction (i) elif float_menu_mode == MENU_MODE_WEAPONS: # weapons for i in range (5): UpdateFloatMenuItem (pc, i, 1) elif float_menu_mode == MENU_MODE_ITEMS: # items for i in range (5): UpdateFloatMenuItem (pc, i, 0) elif float_menu_mode == MENU_MODE_SPELLS: # spells RefreshSpellList(pc, False) if float_menu_index: Button = Window.GetControl (13) Button.SetState (IE_GUI_BUTTON_ENABLED) if float_menu_index+3<len(spell_list): Button = Window.GetControl (14) Button.SetState (IE_GUI_BUTTON_ENABLED) for i in range (5): UpdateFloatMenuSpell (pc, i) elif float_menu_mode == MENU_MODE_ABILITIES: # abilities RefreshSpellList(pc, True) if float_menu_index: Button = Window.GetControl (13) Button.SetState (IE_GUI_BUTTON_ENABLED) if float_menu_index+3<len(spell_list): Button = Window.GetControl (14) Button.SetState (IE_GUI_BUTTON_ENABLED) for i in range (5): UpdateFloatMenuSpell (pc, i) return
def UpdateRecordsWindow(): global stats_overview, faction_help, alignment_help Window = RecordsWindow if not RecordsWindow: print "SelectionChange handler points to non existing window\n" return pc = GemRB.GameGetSelectedPCSingle() # Setting up the character information GetCharacterHeader(pc) # Checking whether character has leveled up. Button = Window.GetControl(9) if avatar_header['SecoLevel'] == 0: if avatar_header['XP'] >= avatar_header['PrimNextLevXP']: Button.SetState(IE_GUI_BUTTON_ENABLED) else: Button.SetState(IE_GUI_BUTTON_DISABLED) else: # Character is Multi-Class if avatar_header['XP'] >= avatar_header[ 'PrimNextLevXP'] or avatar_header['XP'] >= avatar_header[ 'SecoNextLevXP']: Button.SetState(IE_GUI_BUTTON_ENABLED) else: Button.SetState(IE_GUI_BUTTON_DISABLED) # name Label = Window.GetControl(0x1000000a) Label.SetText(GemRB.GetPlayerName(pc, 1)) # portrait Image = Window.GetControl(2) Image.SetState(IE_GUI_BUTTON_LOCKED) Image.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET) Image.SetPicture(GUICommonWindows.GetActorPortrait(pc, 'STATS')) # armorclass Label = Window.GetControl(0x1000000b) Label.SetText(str(GemRB.GetPlayerStat(pc, IE_ARMORCLASS))) Label.SetTooltip(4197) # hp now Label = Window.GetControl(0x1000000c) Label.SetText(str(GemRB.GetPlayerStat(pc, IE_HITPOINTS))) Label.SetTooltip(4198) # hp max Label = Window.GetControl(0x1000000d) Label.SetText(str(GemRB.GetPlayerStat(pc, IE_MAXHITPOINTS))) Label.SetTooltip(4199) # stats sstr = GemRB.GetPlayerStat(pc, IE_STR) bstr = GemRB.GetPlayerStat(pc, IE_STR, 1) sstrx = GemRB.GetPlayerStat(pc, IE_STREXTRA) bstrx = GemRB.GetPlayerStat(pc, IE_STREXTRA, 1) if (sstrx > 0) and (sstr == 18): sstr = "%d/%02d" % (sstr, sstrx % 100) if (bstrx > 0) and (bstr == 18): bstr = "%d/%02d" % (bstr, bstrx % 100) sint = GemRB.GetPlayerStat(pc, IE_INT) bint = GemRB.GetPlayerStat(pc, IE_INT, 1) swis = GemRB.GetPlayerStat(pc, IE_WIS) bwis = GemRB.GetPlayerStat(pc, IE_WIS, 1) sdex = GemRB.GetPlayerStat(pc, IE_DEX) bdex = GemRB.GetPlayerStat(pc, IE_DEX, 1) scon = GemRB.GetPlayerStat(pc, IE_CON) bcon = GemRB.GetPlayerStat(pc, IE_CON, 1) schr = GemRB.GetPlayerStat(pc, IE_CHR) bchr = GemRB.GetPlayerStat(pc, IE_CHR, 1) stats = (sstr, sint, swis, sdex, scon, schr) basestats = (bstr, bint, bwis, bdex, bcon, bchr) for i in range(6): Label = Window.GetControl(0x1000000e + i) if stats[i] != basestats[i]: Label.SetTextColor(255, 0, 0) else: Label.SetTextColor(255, 255, 255) Label.SetText(str(stats[i])) # race # HACK: for some strange reason, Morte's race is 1 (Human), instead of 45 (Morte) print "species: %d race: %d" % (GemRB.GetPlayerStat( pc, IE_SPECIES), GemRB.GetPlayerStat(pc, IE_RACE)) #be careful, some saves got this field corrupted race = GemRB.GetPlayerStat(pc, IE_SPECIES) - 1 text = CommonTables.Races.GetValue(race, 0) Label = Window.GetControl(0x10000014) Label.SetText(text) # sex GenderTable = GemRB.LoadTable("GENDERS") text = GenderTable.GetValue(GemRB.GetPlayerStat(pc, IE_SEX) - 1, 0) Label = Window.GetControl(0x10000015) Label.SetText(text) # class text = CommonTables.Classes.GetValue( GemRB.GetPlayerStat(pc, IE_CLASS) - 1, 0) Label = Window.GetControl(0x10000016) Label.SetText(text) # alignment align = GemRB.GetPlayerStat(pc, IE_ALIGNMENT) ss = GemRB.LoadSymbol("ALIGN") sym = ss.GetValue(align) AlignmentTable = GemRB.LoadTable("ALIGNS") alignment_help = GemRB.GetString(AlignmentTable.GetValue(sym, 'DESC_REF')) frame = (3 * int(align / 16) + align % 16) - 4 Button = Window.GetControl(5) Button.SetState(IE_GUI_BUTTON_LOCKED) Button.SetSprites('STALIGN', 0, frame, 0, 0, 0) Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpAlignment) Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave) # faction faction = GemRB.GetPlayerStat(pc, IE_FACTION) FactionTable = GemRB.LoadTable("FACTIONS") faction_help = GemRB.GetString(FactionTable.GetValue(faction, 0)) frame = FactionTable.GetValue(faction, 1) Button = Window.GetControl(6) Button.SetState(IE_GUI_BUTTON_LOCKED) Button.SetSprites('STFCTION', 0, frame, 0, 0, 0) Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpFaction) Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave) # help, info textarea stats_overview = GetStatOverview(pc) Text = Window.GetControl(0) Text.SetText(stats_overview) return
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
def UpdateRecordsWindow (): global stats_overview, faction_help, alignment_help Window = RecordsWindow if not RecordsWindow: print "SelectionChange handler points to non existing window\n" return pc = GemRB.GameGetSelectedPCSingle () # Setting up the character information GetCharacterHeader (pc) # Checking whether character has leveled up. Button = Window.GetControl (9) if avatar_header['SecoLevel'] == 0: if avatar_header['XP'] >= avatar_header['PrimNextLevXP']: Button.SetState (IE_GUI_BUTTON_ENABLED) else: Button.SetState (IE_GUI_BUTTON_DISABLED) else: # Character is Multi-Class if avatar_header['XP'] >= avatar_header['PrimNextLevXP'] or avatar_header['XP'] >= avatar_header['SecoNextLevXP']: Button.SetState (IE_GUI_BUTTON_ENABLED) else: Button.SetState (IE_GUI_BUTTON_DISABLED) # name Label = Window.GetControl (0x1000000a) Label.SetText (GemRB.GetPlayerName (pc, 1)) # portrait Image = Window.GetControl (2) Image.SetState (IE_GUI_BUTTON_LOCKED) Image.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET) Image.SetPicture (GUICommonWindows.GetActorPortrait (pc, 'STATS')) # armorclass Label = Window.GetControl (0x1000000b) Label.SetText (str (GemRB.GetPlayerStat (pc, IE_ARMORCLASS))) Label.SetTooltip (4197) # hp now Label = Window.GetControl (0x1000000c) Label.SetText (str (GemRB.GetPlayerStat (pc, IE_HITPOINTS))) Label.SetTooltip (4198) # hp max Label = Window.GetControl (0x1000000d) Label.SetText (str (GemRB.GetPlayerStat (pc, IE_MAXHITPOINTS))) Label.SetTooltip (4199) # stats sstr = GemRB.GetPlayerStat (pc, IE_STR) bstr = GemRB.GetPlayerStat (pc, IE_STR,1) sstrx = GemRB.GetPlayerStat (pc, IE_STREXTRA) bstrx = GemRB.GetPlayerStat (pc, IE_STREXTRA,1) if (sstrx > 0) and (sstr==18): sstr = "%d/%02d" %(sstr, sstrx % 100) if (bstrx > 0) and (bstr==18): bstr = "%d/%02d" %(bstr, bstrx % 100) sint = GemRB.GetPlayerStat (pc, IE_INT) bint = GemRB.GetPlayerStat (pc, IE_INT,1) swis = GemRB.GetPlayerStat (pc, IE_WIS) bwis = GemRB.GetPlayerStat (pc, IE_WIS,1) sdex = GemRB.GetPlayerStat (pc, IE_DEX) bdex = GemRB.GetPlayerStat (pc, IE_DEX,1) scon = GemRB.GetPlayerStat (pc, IE_CON) bcon = GemRB.GetPlayerStat (pc, IE_CON,1) schr = GemRB.GetPlayerStat (pc, IE_CHR) bchr = GemRB.GetPlayerStat (pc, IE_CHR,1) stats = (sstr, sint, swis, sdex, scon, schr) basestats = (bstr, bint, bwis, bdex, bcon, bchr) for i in range (6): Label = Window.GetControl (0x1000000e + i) if stats[i]!=basestats[i]: Label.SetTextColor (255, 0, 0) else: Label.SetTextColor (255, 255, 255) Label.SetText (str (stats[i])) # race # this is -1 to lookup the value in the table race = GemRB.GetPlayerStat (pc, IE_SPECIES) - 1 # workaround for original saves that don't have the characters species stat set properly if race == -1: if GemRB.GetPlayerStat (pc, IE_SPECIFIC) == 3: # Vhailor race = 50 # Changes from GHOST to RESTLESS_SPIRIT elif GemRB.GetPlayerStat (pc, IE_SPECIFIC) == 9: # Morte race = 44 # Changes from HUMAN to MORTE. Morte is Morte :) else: race = GemRB.GetPlayerStat (pc, IE_RACE) - 1 text = CommonTables.Races.GetValue (race, 0) Label = Window.GetControl (0x10000014) Label.SetText (text) # sex GenderTable = GemRB.LoadTable ("GENDERS") text = GenderTable.GetValue (GemRB.GetPlayerStat (pc, IE_SEX) - 1, GTV_STR) Label = Window.GetControl (0x10000015) Label.SetText (text) # class text = CommonTables.Classes.GetValue (GUICommon.GetClassRowName (pc), "NAME_REF") Label = Window.GetControl (0x10000016) Label.SetText (text) # alignment align = GemRB.GetPlayerStat (pc, IE_ALIGNMENT) ss = GemRB.LoadSymbol ("ALIGN") sym = ss.GetValue (align) AlignmentTable = GemRB.LoadTable ("ALIGNS") alignment_help = AlignmentTable.GetValue (sym, 'DESC_REF', GTV_REF) frame = (3 * int (align / 16) + align % 16) - 4 Button = Window.GetControl (5) Button.SetState (IE_GUI_BUTTON_LOCKED) Button.SetSprites ('STALIGN', 0, frame, 0, 0, 0) Button.SetEvent (IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpAlignment) Button.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave) # faction faction = GemRB.GetPlayerStat (pc, IE_FACTION) FactionTable = GemRB.LoadTable ("FACTIONS") faction_help = FactionTable.GetValue (faction, 0, GTV_REF) frame = FactionTable.GetValue (faction, 1) Button = Window.GetControl (6) Button.SetState (IE_GUI_BUTTON_LOCKED) Button.SetSprites ('STFCTION', 0, frame, 0, 0, 0) Button.SetEvent (IE_GUI_MOUSE_OVER_BUTTON, OnRecordsHelpFaction) Button.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON, OnRecordsButtonLeave) # help, info textarea stats_overview = GetStatOverview (pc) Text = Window.GetControl (0) Text.SetText (stats_overview) return
def RefreshInventoryWindow(): Window = InventoryWindow 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')) GUICommon.SetEncumbranceLabels(Window, 46, None, pc, True) # armor class ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS) ac += GemRB.GetAbilityBonus(IE_DEX, 2, GemRB.GetPlayerStat(pc, IE_DEX)) 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( GemRB.GetPlayerStat(pc, IE_CLASS) - 1, 0) Label = Window.GetControl(0x1000003f) Label.SetText(text) held = GemRB.GetPlayerStat(pc, IE_HELD) + GemRB.GetPlayerStat( pc, IE_CASTERHOLD) if held == 0 and GemRB.GetPlayerStat(pc, IE_STATE_ID) & STATE_DEAD == 0: Window.SetVisible(WINDOW_VISIBLE) else: Window.SetVisible(WINDOW_GRAYED) # update ground inventory slots Container = GemRB.GetContainer(pc, 1) TopIndex = GemRB.GetVar("TopIndex") for i in range(10): Button = Window.GetControl(i + 47) if GemRB.IsDraggingItem(): Button.SetState(IE_GUI_BUTTON_SECOND) 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: 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 not identified or item["ItemNameIdentified"] == -1: Button.SetTooltip(item["ItemName"]) Button.EnableBorder(0, 1) else: Button.SetTooltip(item["ItemNameIdentified"]) Button.EnableBorder(0, 0) 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 else: Button.SetFlags(IE_GUI_BUTTON_PICTURE, OP_NAND) Button.SetTooltip(4273) 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