def UpdateRecordsWindow(): global alignment_help Window = RecordsWindow if not RecordsWindow: print "SelectionChange handler points to non existing window\n" return pc = GemRB.GameGetSelectedPCSingle() #update mage school GemRB.SetVar("MAGESCHOOL", 0) Kit = GUICommon.GetKitIndex(pc) if Kit and CommonTables.KitList.GetValue(Kit, 7) == 1: MageTable = GemRB.LoadTable("magesch") GemRB.SetVar( "MAGESCHOOL", MageTable.FindValue(3, CommonTables.KitList.GetValue(Kit, 6))) # exportable Button = Window.GetControl(36) if Exportable(pc): Button.SetState(IE_GUI_BUTTON_ENABLED) else: Button.SetState(IE_GUI_BUTTON_DISABLED) # dual-classable Button = Window.GetControl(0) if GUICommon.CanDualClass(pc): Button.SetState(IE_GUI_BUTTON_DISABLED) else: Button.SetState(IE_GUI_BUTTON_ENABLED) # levelup Button = Window.GetControl(37) if LUCommon.CanLevelUp(pc): Button.SetState(IE_GUI_BUTTON_ENABLED) else: Button.SetState(IE_GUI_BUTTON_DISABLED) # name Label = Window.GetControl(0x1000000e) Label.SetText(GemRB.GetPlayerName(pc, 0)) # portrait Button = Window.GetControl(2) Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE, OP_SET) Button.SetState(IE_GUI_BUTTON_LOCKED) if GameCheck.IsBG2() and not GameCheck.IsBG2Demo(): Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0), "NOPORTMD") else: Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0), "NOPORTLG") # armorclass GUICommon.DisplayAC(pc, Window, 0x10000028) # 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) # stats sstr = GemRB.GetPlayerStat(pc, IE_STR) sstrx = GemRB.GetPlayerStat(pc, IE_STREXTRA) cstr = GetStatColor(pc, IE_STR) if sstrx > 0 and sstr == 18: sstr = "%d/%02d" % (sstr, sstrx % 100) else: sstr = str(sstr) sint = str(GemRB.GetPlayerStat(pc, IE_INT)) cint = GetStatColor(pc, IE_INT) swis = str(GemRB.GetPlayerStat(pc, IE_WIS)) cwis = GetStatColor(pc, IE_WIS) sdex = str(GemRB.GetPlayerStat(pc, IE_DEX)) cdex = GetStatColor(pc, IE_DEX) scon = str(GemRB.GetPlayerStat(pc, IE_CON)) ccon = GetStatColor(pc, IE_CON) schr = str(GemRB.GetPlayerStat(pc, IE_CHR)) cchr = GetStatColor(pc, IE_CHR) Label = Window.GetControl(0x1000002f) Label.SetText(sstr) Label.SetTextColor(cstr[0], cstr[1], cstr[2]) Label = Window.GetControl(0x10000009) Label.SetText(sdex) Label.SetTextColor(cdex[0], cdex[1], cdex[2]) Label = Window.GetControl(0x1000000a) Label.SetText(scon) Label.SetTextColor(ccon[0], ccon[1], ccon[2]) Label = Window.GetControl(0x1000000b) Label.SetText(sint) Label.SetTextColor(cint[0], cint[1], cint[2]) Label = Window.GetControl(0x1000000c) Label.SetText(swis) Label.SetTextColor(cwis[0], cwis[1], cwis[2]) Label = Window.GetControl(0x1000000d) Label.SetText(schr) Label.SetTextColor(cchr[0], cchr[1], cchr[2]) # class ClassTitle = GUICommon.GetActorClassTitle(pc) Label = Window.GetControl(0x10000030) Label.SetText(ClassTitle) # race text = CommonTables.Races.GetValue( CommonTables.Races.FindValue(3, GemRB.GetPlayerStat(pc, IE_RACE)), 0) Label = Window.GetControl(0x1000000f) Label.SetText(text) # alignment text = CommonTables.Aligns.FindValue(3, GemRB.GetPlayerStat(pc, IE_ALIGNMENT)) text = CommonTables.Aligns.GetValue(text, 0) Label = Window.GetControl(0x10000010) Label.SetText(text) # gender Label = Window.GetControl(0x10000011) if GemRB.GetPlayerStat(pc, IE_SEX) == 1: Label.SetText(7198) else: Label.SetText(7199) # help, info textarea Text = Window.GetControl(45) Text.SetText(GetStatOverview(pc)) #TODO: making window visible/shaded depending on the pc's state Window.SetVisible(WINDOW_VISIBLE) return
def RefreshInventoryWindow(Window): """Partial redraw without resetting TopIndex.""" 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 GUICommon.DisplayAC(pc, Window, 0x10000038) # 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 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.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.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) InventoryCommon.UpdateInventorySlot(pc, Button, Slot, "ground") # making window visible/shaded depending on the pc's state GUICommon.AdjustWindowVisibility(Window, pc, False) return