Пример #1
0
def AcceptPress():
    if TotPoints:
        # Setting up the error window
        TextArea = QuitWindow.GetControl(0)
        TextArea.SetText(46782)

        Button = QuitWindow.GetControl(1)
        Button.SetText("")
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
        Button.SetState(IE_GUI_BUTTON_DISABLED)
        Button = QuitWindow.GetControl(2)
        Button.SetText(46783)
        Button.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, OkButton)
        NewLifeWindow.SetVisible(WINDOW_GRAYED)  #go dark
        QuitWindow.SetVisible(WINDOW_VISIBLE)
        return

    if NewLifeWindow:
        NewLifeWindow.Unload()
    if QuitWindow:
        QuitWindow.Unload()
    #set my character up
    if not LevelUp:
        MyChar = GemRB.CreatePlayer("charbase", 1)

    Str = Stats[0]
    if Str <= 18:
        GemRB.SetPlayerStat(1, IE_STR, Str)
        GemRB.SetPlayerStat(1, IE_STREXTRA, 0)
    else:
        GemRB.SetPlayerStat(1, IE_STR, 18)
        GemRB.SetPlayerStat(1, IE_STREXTRA, extras[Str - 19])

    GemRB.SetPlayerStat(1, IE_INT, Stats[1])
    GemRB.SetPlayerStat(1, IE_WIS, Stats[2])
    GemRB.SetPlayerStat(1, IE_DEX, Stats[3])
    GemRB.SetPlayerStat(1, IE_CON, Stats[4])
    GemRB.SetPlayerStat(1, IE_CHR, Stats[5])

    if LevelUp:
        # hp is handled in GUIREC
        import GUIREC
        GUIREC.OpenLevelUpWindow()
        return

    #don't add con bonus, it will be calculated by the game
    #interestingly enough, the game adds only one level's con bonus
    Con = Stats[4]
    if Con > 14:
        x = 30
    else:
        x = 20 + (Con - 9) * 2

    print "Setting max hp to: ", x
    GemRB.SetPlayerStat(1, IE_MAXHITPOINTS, x)
    #adding the remaining constitution bonus to the current hp
    #if Con>14:
    #	x = x+(Con-14)*3
    print "Setting current hp to: ", x
    GemRB.SetPlayerStat(1, IE_HITPOINTS, x)

    GemRB.FillPlayerInfo(1)  #does all the rest
    #alter this if needed
    GemRB.SetRepeatClickFlags(GEM_RK_DISABLE, OP_SET)
    #LETS PLAY!!
    GemRB.EnterGame()
    return
Пример #2
0
def OpenLUStatsWindow(Type=1):
    global NewLifeWindow, QuitWindow, StatTable
    global TotPoints, AcPoints, HpPoints
    global TotLabel, AcLabel, HpLabel
    global TextArea, Stats, StatLabels, StatLowerLimit, StatLimit, LevelUp

    GemRB.SetRepeatClickFlags(GEM_RK_DOUBLESPEED, OP_SET)
    LevelUp = Type
    if LevelUp:
        import GUICommonWindows
        import GUIREC
        GUICommonWindows.OptionsWindow.SetVisible(WINDOW_INVISIBLE)
        GUICommonWindows.PortraitWindow.SetVisible(WINDOW_INVISIBLE)
        GUICommonWindows.ActionsWindow.SetVisible(WINDOW_INVISIBLE)
        GUIREC.RecordsWindow.SetVisible(WINDOW_INVISIBLE)
        # only TNO gets the main stat boosts
        pc = GemRB.GameGetFirstSelectedPC()
        if pc != 1:
            GUIREC.OpenLevelUpWindow()
            return
    else:
        GemRB.LoadGame(None)  #loading the base game
    StatTable = GemRB.LoadTable("abcomm")
    GemRB.LoadWindowPack("GUICG")
    #setting up confirmation window
    QuitWindow = GemRB.LoadWindow(1)
    QuitWindow.SetVisible(WINDOW_INVISIBLE)

    #setting up CG window
    NewLifeWindow = GemRB.LoadWindow(0)

    if LevelUp:
        Str = GemRB.GetPlayerStat(1, IE_STR, 1)
        Dex = GemRB.GetPlayerStat(1, IE_DEX, 1)
        Con = GemRB.GetPlayerStat(1, IE_CON, 1)
        Wis = GemRB.GetPlayerStat(1, IE_WIS, 1)
        Int = GemRB.GetPlayerStat(1, IE_INT, 1)
        Cha = GemRB.GetPlayerStat(1, IE_CHR, 1)
        TotPoints = 1  # FIXME: actually LevelDiff
        Stats = [Str, Int, Wis, Dex, Con, Cha]
        StatLowerLimit = list(
            Stats
        )  # so we copy the values or the lower limit would increase with them
        StatLimit = [25] * 6
    else:
        Str = Dex = Con = Wis = Int = Cha = 9
        TotPoints = 21
        Stats = [Str, Int, Wis, Dex, Con, Cha]

    # stat label controls
    for i in range(len(Stats)):
        StatLabels[i] = NewLifeWindow.GetControl(0x10000018 + i)

    # individual stat buttons
    for i in range(len(Stats)):
        Button = NewLifeWindow.GetControl(i + 2)
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
        Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, StatPress[i])

    Button = NewLifeWindow.GetControl(8)
    Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_SET)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetSprites("", 0, 0, 0, 0, 0)
    Button.SetText(5025)
    Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, AcPress)

    Button = NewLifeWindow.GetControl(9)
    Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_SET)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetSprites("", 0, 0, 0, 0, 0)
    Button.SetText(5026)
    Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, HpPress)

    Button = NewLifeWindow.GetControl(10)
    Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_SET)
    Button.SetState(IE_GUI_BUTTON_LOCKED)
    Button.SetSprites("", 0, 0, 0, 0, 0)
    Button.SetText(5027)
    Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, PointPress)

    # stat +/- buttons
    for i in range(len(StatPress)):
        Button = NewLifeWindow.GetControl(11 + 2 * i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, IncreasePress)
        Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, StatPress[i])
        Button.SetVarAssoc("Pressed", i)

        Button = NewLifeWindow.GetControl(12 + 2 * i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DecreasePress)
        Button.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, StatPress[i])
        Button.SetVarAssoc("Pressed", i)

    NewLifeLabel = NewLifeWindow.GetControl(0x10000023)
    NewLifeLabel.SetText(1899)

    TextArea = NewLifeWindow.GetControl(23)
    TextArea.SetText(18495)

    TotLabel = NewLifeWindow.GetControl(0x10000020)
    AcLabel = NewLifeWindow.GetControl(0x1000001E)
    HpLabel = NewLifeWindow.GetControl(0x1000001F)

    Label = NewLifeWindow.GetControl(0x10000021)
    Label.SetText(254)

    PhotoButton = NewLifeWindow.GetControl(35)
    PhotoButton.SetState(IE_GUI_BUTTON_LOCKED)
    PhotoButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE,
                         OP_SET)
    PhotoButton.SetEvent(IE_GUI_MOUSE_OVER_BUTTON, OverPhoto)
    PhotoButton.SetPicture("STPNOC")

    AcceptButton = NewLifeWindow.GetControl(0)
    AcceptButton.SetText(4192)
    AcceptButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, AcceptPress)
    AcceptButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR)

    CancelButton = NewLifeWindow.GetControl(1)
    CancelButton.SetText(4196)
    CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress)

    UpdateLabels()

    NewLifeWindow.SetVisible(WINDOW_VISIBLE)
    return