Exemplo n.º 1
0
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() or GameCheck.IsIWD1()) and not GameCheck.IsBG2Demo():
        Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0), "NOPORTMD")
    else:
        Button.SetPicture(GemRB.GetPlayerPortrait(pc, 0), "NOPORTLG")

    # armorclass
    Label = Window.GetControl(0x10000028)
    ac = GemRB.GetPlayerStat(pc, IE_ARMORCLASS)
    Label.SetText(str(ac))
    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)

    # 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
Exemplo n.º 2
0
def UpdateRecordsWindow(Window):
    global alignment_help

    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)
    pic = GemRB.GetPlayerPortrait(pc, 0)["Sprite"]
    if not pic:
        pic = ""
    if GameCheck.IsBG2() and not GameCheck.IsBG2Demo():
        Button.SetPicture(pic, "NOPORTMD")
    else:
        Button.SetPicture(pic, "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.SetColor(cstr)

    Label = Window.GetControl(0x10000009)
    Label.SetText(sdex)
    Label.SetColor(cdex)

    Label = Window.GetControl(0x1000000a)
    Label.SetText(scon)
    Label.SetColor(ccon)

    Label = Window.GetControl(0x1000000b)
    Label.SetText(sint)
    Label.SetColor(cint)

    Label = Window.GetControl(0x1000000c)
    Label.SetText(swis)
    Label.SetColor(cwis)

    Label = Window.GetControl(0x1000000d)
    Label.SetText(schr)
    Label.SetColor(cchr)

    # 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.SetColor(ColorWhitish, TA_COLOR_INITIALS)
    Text.SetText(GetStatOverview(pc))
    #TODO: making window visible/shaded depending on the pc's state

    return