Example #1
0
def OpenPortraitSelectWindow():
    global PortraitPictureButton

    SubCustomizeWindow = GemRB.LoadWindow(18)
    SubCustomizeWindow.AddAlias("SUB_WIN", 0)

    PortraitPictureButton = SubCustomizeWindow.GetControl(0)
    PortraitPictureButton.SetFlags(
        IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE, OP_SET)
    PortraitPictureButton.SetState(IE_GUI_BUTTON_LOCKED)

    PortraitLeftButton = SubCustomizeWindow.GetControl(1)
    PortraitLeftButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitLeftButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitLeftPress)

    PortraitRightButton = SubCustomizeWindow.GetControl(2)
    PortraitRightButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitRightButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitRightPress)

    PortraitDoneButton = SubCustomizeWindow.GetControl(3)
    PortraitDoneButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitDonePress)
    PortraitDoneButton.SetText(11973)
    PortraitDoneButton.MakeDefault()

    PortraitCancelButton = SubCustomizeWindow.GetControl(4)
    PortraitCancelButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                  lambda: SubCustomizeWindow.Close())
    PortraitCancelButton.SetText(13727)
    PortraitCancelButton.MakeEscape()

    PortraitCustomButton = SubCustomizeWindow.GetControl(5)
    PortraitCustomButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitCustomButton.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                  OpenCustomPortraitWindow)
    PortraitCustomButton.SetText(17545)

    # get players gender and portrait
    Pc = GemRB.GameGetSelectedPCSingle()
    PcPortrait = GemRB.GetPlayerPortrait(Pc, 0)["ResRef"]

    # initialize and set portrait
    Portrait.Init(Gender)
    Portrait.Set(PcPortrait)
    PortraitPictureButton.SetPicture(Portrait.Name() + PortraitNameSuffix,
                                     "NOPORTLG")

    SubCustomizeWindow.ShowModal(MODAL_SHADOW_GRAY)
    return
Example #2
0
def OpenPortraitSelectWindow():
    global CharGenWindow, PortraitWindow, PortraitPictureButton

    PortraitWindow = GemRB.LoadWindow(18)

    PortraitPictureButton = PortraitWindow.GetControl(0)
    PortraitPictureButton.SetFlags(
        IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE, OP_SET)

    PortraitLeftButton = PortraitWindow.GetControl(1)
    PortraitLeftButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitLeftButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitLeftPress)
    PortraitLeftButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    PortraitRightButton = PortraitWindow.GetControl(2)
    PortraitRightButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitRightButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitRightPress)
    PortraitRightButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    PortraitCustomButton = PortraitWindow.GetControl(5)
    PortraitCustomButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitCustomButton.SetEvent(IE_GUI_BUTTON_ON_PRESS,
                                  OpenCustomPortraitWindow)
    PortraitCustomButton.SetText(17545)

    PortraitDoneButton = PortraitWindow.GetControl(3)
    PortraitDoneButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitDonePress)
    PortraitDoneButton.SetText(11973)
    PortraitDoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    PortraitCancelButton = PortraitWindow.GetControl(4)
    PortraitCancelButton.SetState(IE_GUI_BUTTON_ENABLED)
    PortraitCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitCancelPress)
    PortraitCancelButton.SetText(13727)
    PortraitCancelButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)

    # get players gender and portrait
    Pc = GemRB.GameGetSelectedPCSingle()
    PcGender = GemRB.GetPlayerStat(Pc, IE_SEX)
    PcPortrait = GemRB.GetPlayerPortrait(Pc, 0)

    # initialize and set portrait
    Portrait.Init(PcGender)
    Portrait.Set(PcPortrait)
    PortraitPictureButton.SetPicture(Portrait.Name() + "G")

    PortraitWindow.ShowModal(MODAL_SHADOW_GRAY)
    return
Example #3
0
def OnLoad():
    global ColorWindow, DoneButton, PDollButton
    global HairTable, SkinTable, ColorTable
    global HairButton, SkinButton, MajorButton, MinorButton
    global Color1, Color2, Color3, Color4, PDollResRef

    ColorWindow = GemRB.LoadWindow(13, "GUICG")
    CharOverview.PositionCharGenWin(ColorWindow)

    pc = GemRB.GetVar("Slot")
    Race = IDLUCommon.GetRace(pc)
    RaceName = CommonTables.Races.GetRowName(Race)
    HairTable = GemRB.LoadTable(CommonTables.Races.GetValue(RaceName, "HAIR"))
    SkinTable = GemRB.LoadTable(CommonTables.Races.GetValue(RaceName, "SKIN"))
    ColorTable = GemRB.LoadTable("clowncol")

    #set these colors to some default
    Gender = GemRB.GetPlayerStat(pc, IE_SEX)
    Portrait.Init(Gender)
    Portrait.Set(GemRB.GetPlayerPortrait(pc)["ResRef"])
    PortraitName = Portrait.Name()  # strips the last char like the table needs

    PortraitTable = GemRB.LoadTable("pictures")
    Color1 = PortraitTable.GetValue(PortraitName, "HAIR", GTV_INT)
    Color2 = PortraitTable.GetValue(PortraitName, "SKIN", GTV_INT)
    Color3 = PortraitTable.GetValue(PortraitName, "MAJOR", GTV_INT)
    Color4 = PortraitTable.GetValue(PortraitName, "MINOR", GTV_INT)
    PDollButton = ColorWindow.GetControl(1)
    PDollButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    PDollButton.SetState(IE_GUI_BUTTON_LOCKED)

    HairButton = ColorWindow.GetControl(2)
    HairButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    HairButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, HairPress)
    HairButton.SetBAM("COLGRAD", 1, 0, Color1)

    SkinButton = ColorWindow.GetControl(3)
    SkinButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    SkinButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SkinPress)
    SkinButton.SetBAM("COLGRAD", 1, 0, Color2)

    MajorButton = ColorWindow.GetControl(5)
    MajorButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    MajorButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MajorPress)
    MajorButton.SetBAM("COLGRAD", 1, 0, Color3)

    MinorButton = ColorWindow.GetControl(4)
    MinorButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)
    MinorButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MinorPress)
    MinorButton.SetBAM("COLGRAD", 1, 0, Color4)

    BackButton = ColorWindow.GetControl(13)
    BackButton.SetText(15416)
    DoneButton = ColorWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)

    # calculate the paperdoll animation id from the race, class and gender
    PDollTable = GemRB.LoadTable("avatars")
    table = GemRB.LoadTable("avprefr")
    RaceID = CommonTables.Races.GetValue(RaceName, "ID", GTV_INT)
    # look up base race if needed
    if RaceID > 1000:
        RaceID = RaceID >> 16
        Race = CommonTables.Races.FindValue("ID", RaceID)
        RaceName = CommonTables.Races.GetRowName(Race)
    AnimID = 0x6000 + table.GetValue(RaceName, "RACE")

    table = GemRB.LoadTable("avprefc")
    Class = GemRB.GetPlayerStat(pc, IE_CLASS)
    ClassName = GUICommon.GetClassRowName(Class - 1, "index")
    AnimID = AnimID + table.GetValue(ClassName, "PREFIX")

    table = GemRB.LoadTable("avprefg")
    AnimID = AnimID + table.GetValue(Gender, 0)

    PDollResRef = PDollTable.GetValue(hex(AnimID), "AT_1") + "G11"
    if PDollResRef == "*G11":
        print("ERROR, couldn't find the paperdoll! AnimID is", hex(AnimID))
        print("Falling back to an elven paperdoll.")
        PDollResRef = "CEMB1G11"

    RefreshPDoll()
    ColorWindow.Focus()
    return