Esempio n. 1
0
def OnLoad():
    global CharSoundWindow, VoiceList

    CharSoundWindow = GemRB.LoadWindow(19, "GUICG")
    CharGenCommon.PositionCharGenWin(CharSoundWindow)

    VoiceList = CharSoundWindow.GetControl(45)
    Voices = VoiceList.ListResources(CHR_SOUNDS)
    GUICommon.AddDefaultVoiceSet(VoiceList, Voices)
    # preselect the default entry to avoid an infinite loop if Play is pressed immediately
    VoiceList.SetVarAssoc("Selected", 0)

    PlayButton = CharSoundWindow.GetControl(47)
    PlayButton.SetState(IE_GUI_BUTTON_ENABLED)
    PlayButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PlayPress)
    PlayButton.SetText(17318)

    TextArea = CharSoundWindow.GetControl(50)
    TextArea.SetText(11315)

    BackButton = CharSoundWindow.GetControl(10)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = CharSoundWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    VoiceList.SetEvent(IE_GUI_TEXTAREA_ON_SELECT, ChangeVoice)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    CharSoundWindow.Focus()
    return
Esempio n. 2
0
def OnLoad():
    global SkillWindow, DoneButton, MyChar

    SkillWindow = GemRB.LoadWindow(6, "GUICG")
    CharGenCommon.PositionCharGenWin(SkillWindow)

    MyChar = GemRB.GetVar("Slot")

    Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
      GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
    LUSkillsSelection.SetupSkillsWindow (MyChar, \
     LUSkillsSelection.LUSKILLS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0,0,0], Levels)

    # can't be moved earlier as this var will be set in the setup call above
    if not GemRB.GetVar("SkillPointsLeft"):  #skipping
        if SkillWindow:
            SkillWindow.Unload()
        GemRB.SetNextScript("GUICG9")
        return

    BackButton = SkillWindow.GetControl(25)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)

    DoneButton = SkillWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    DoneButton.SetDisabled(True)

    RedrawSkills()
    SkillWindow.Focus()
    return
Esempio n. 3
0
def OnLoad():
    global ImportWindow

    ImportWindow = GemRB.LoadWindow(20, "GUICG")
    CharGenCommon.PositionCharGenWin(ImportWindow)

    TextAreaControl = ImportWindow.GetControl(4)
    TextAreaControl.SetText(53774)

    TextAreaControl = ImportWindow.GetControl(2)
    #Fill TextArea Control with character sheets, make textarea a listbox

    DoneButton = ImportWindow.GetControl(0)
    DoneButton.SetText(2610)
    DoneButton.SetDisabled(True)
    DoneButton.MakeDefault()

    CancelButton = ImportWindow.GetControl(1)
    CancelButton.SetText(15416)
    CancelButton.MakeEscape()

    DoneButton.OnPress(Done1Press)
    CancelButton.OnPress(CancelPress)
    ImportWindow.Focus()
    return
Esempio n. 4
0
def OnLoad():
    global BioWindow

    BioWindow = GemRB.LoadWindow(23, "GUICG")
    CharGenCommon.PositionCharGenWin(BioWindow)

    EditTextArea = BioWindow.ReplaceSubview(3, IE_GUI_TEXTAREA, "NORMAL")
    BIO = GemRB.GetToken("BIO")
    EditTextArea.AddAlias("BIO")
    EditTextArea.SetFlags(IE_GUI_TEXTAREA_EDITABLE, OP_OR)
    EditTextArea.SetColor(ColorWhitish, TA_COLOR_NORMAL)

    if BIO:
        EditTextArea.SetText(BIO)
    else:
        EditTextArea.SetText(15882)

    # done
    OkButton = BioWindow.GetControl(1)
    OkButton.SetText(11973)

    ClearButton = BioWindow.GetControl(4)
    ClearButton.SetText(34881)

    # back
    CancelButton = BioWindow.GetControl(2)
    CancelButton.SetText(12896)
    CancelButton.MakeEscape()

    OkButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, OkPress)
    ClearButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClearBiography)
    CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress)
    EditTextArea.Focus()
    return
Esempio n. 5
0
def OnLoad():
    global GenderWindow, TextAreaControl, DoneButton, MyChar

    MyChar = GemRB.GetVar("Slot")

    GenderWindow = GemRB.LoadWindow(1, "GUICG")
    GenderWindow.SetFlags(WF_ALPHA_CHANNEL, OP_OR)
    CharGenCommon.PositionCharGenWin(GenderWindow)

    BackButton = GenderWindow.GetControl(6)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = GenderWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    TextAreaControl = GenderWindow.GetControl(5)
    TextAreaControl.SetText(17236)

    MaleButton = GenderWindow.GetControl(2)
    MaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    FemaleButton = GenderWindow.GetControl(3)
    FemaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    MaleButton.SetVarAssoc("Gender", 1)
    FemaleButton.SetVarAssoc("Gender", 2)
    MaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedMale)
    FemaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedFemale)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    DoneButton.SetDisabled(True)
    GenderWindow.Focus()
    return
Esempio n. 6
0
def OnLoad():
	global ImportWindow, TextAreaControl

	ImportWindow = GemRB.LoadWindow(20, "GUICG")
	CharGenCommon.PositionCharGenWin(ImportWindow)

	TextAreaControl = ImportWindow.GetControl(4)
	TextAreaControl.SetText(10963)

	TextAreaControl = ImportWindow.GetControl(2)
	TextAreaControl.ListResources(CHR_EXPORTS)
 
	DoneButton = ImportWindow.GetControl(0)
	DoneButton.SetText(2610)
	DoneButton.SetDisabled(True)
	DoneButton.MakeDefault()

	CancelButton = ImportWindow.GetControl(1)
	CancelButton.SetText(15416)
	CancelButton.MakeEscape()

	DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress)
	CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress)
	TextAreaControl.SetEvent(IE_GUI_TEXTAREA_ON_SELECT, SelectPress)
	ImportWindow.Focus()
	return
Esempio n. 7
0
def OnLoad():
    global ClassWindow, TextAreaControl, DoneButton, MyChar, ButtonCount, MCRowIndices

    ClassWindow = GemRB.LoadWindow(10, "GUICG")
    CharGenCommon.PositionCharGenWin(ClassWindow)

    MyChar = GemRB.GetVar("Slot")
    ClassCount = CommonTables.Classes.GetRowCount() + 1
    Race = GemRB.GetPlayerStat(MyChar, IE_RACE)
    RaceName = CommonTables.Races.GetRowName(
        CommonTables.Races.FindValue(3, Race))

    MCRowIndices = []
    for i in range(1, ClassCount):
        ClassName = CommonTables.Classes.GetRowName(i - 1)
        Allowed = CommonTables.Classes.GetValue(ClassName, RaceName)
        if CommonTables.Classes.GetValue(ClassName, "MULTI") == 0:
            # not a multiclass
            continue
        MCRowIndices.append((i - 1, Allowed))

    ButtonCount = 10
    if len(MCRowIndices) > 10:
        # add another button, there's another slot left
        extramc = ClassWindow.CreateButton(15, 18, 250, 271, 20)
        extramc.SetState(IE_GUI_BUTTON_DISABLED)
        extramc.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        extramc.SetSprites("GUICGBC", 0, 0, 1, 2, 3)
        ButtonCount = 11
    if len(MCRowIndices) > 11:
        # bah, also add a scrollbar
        ScrollBar = ClassWindow.CreateScrollBar(1000, {
            'x': 290,
            'y': 50,
            'w': 16,
            'h': 220
        }, "GUISCRCW")
        ScrollBar.SetVarAssoc("TopIndex", 0, 0, len(MCRowIndices) - 11)
        ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawMCs)
        ClassWindow.SetEventProxy(ScrollBar)

    BackButton = ClassWindow.GetControl(14)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = ClassWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    TextAreaControl = ClassWindow.GetControl(12)
    TextAreaControl.SetText(17244)

    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    DoneButton.SetDisabled(True)
    RedrawMCs()
    ClassWindow.Focus()
    return
Esempio n. 8
0
def OnLoad():
    global RaceWindow, TextAreaControl, DoneButton
    global RaceTable, RaceCount, TopIndex, MyChar

    MyChar = GemRB.GetVar("Slot")
    ClassName = GUICommon.GetClassRowName(MyChar)
    TableName = CommonTables.ClassSkills.GetValue(ClassName, "HATERACE")
    if TableName == "*":
        GemRB.SetNextScript("GUICG7")
        return
    RaceWindow = GemRB.LoadWindow(15, "GUICG")
    CharGenCommon.PositionCharGenWin(RaceWindow)
    RaceTable = GemRB.LoadTable(TableName)
    RaceCount = RaceTable.GetRowCount() - LISTSIZE
    if RaceCount < 0:
        RaceCount = 0

    TopIndex = 0
    GemRB.SetVar("TopIndex", 0)
    ScrollBarControl = RaceWindow.GetControl(1)
    ScrollBarControl.SetVarAssoc("TopIndex", RaceCount)
    ScrollBarControl.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, DisplayRaces)
    RaceWindow.SetEventProxy(ScrollBarControl)

    for i in range(LISTSIZE):
        Button = RaceWindow.GetControl(i + 6)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    GemRB.SetVar("HatedRace", 0)

    BackButton = RaceWindow.GetControl(4)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = RaceWindow.GetControl(5)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()
    DoneButton.SetState(IE_GUI_BUTTON_DISABLED)

    TextAreaControl = RaceWindow.GetControl(2)
    TextAreaControl.SetText(17256)

    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    RaceWindow.Focus()
    DisplayRaces()
    return
Esempio n. 9
0
def OnLoad():
    global AlignmentWindow, TextAreaControl, DoneButton
    global MyChar

    MyChar = GemRB.GetVar("Slot")
    Kit = GUICommon.GetKitIndex(MyChar)
    if Kit == 0:
        KitName = GUICommon.GetClassRowName(MyChar)
    else:
        #rowname is just a number, first value row what we need here
        KitName = CommonTables.KitList.GetValue(Kit, 0)

    AlignmentOk = GemRB.LoadTable("ALIGNMNT")

    AlignmentWindow = GemRB.LoadWindow(3, "GUICG")
    CharGenCommon.PositionCharGenWin(AlignmentWindow)

    for i in range(9):
        Button = AlignmentWindow.GetControl(i + 2)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        Button.SetState(IE_GUI_BUTTON_DISABLED)
        Button.SetText(CommonTables.Aligns.GetValue(i, 0))

        if AlignmentOk.GetValue(KitName, CommonTables.Aligns.GetValue(i,
                                                                      4)) != 0:
            Button.SetState(IE_GUI_BUTTON_ENABLED)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, AlignmentPress)
            Button.SetVarAssoc("Alignment", i)

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

    TextAreaControl = AlignmentWindow.GetControl(11)
    TextAreaControl.SetText(9602)

    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    DoneButton.SetDisabled(True)
    AlignmentWindow.Focus()
    return
Esempio n. 10
0
def OnLoad():
    global RaceWindow, TextAreaControl, DoneButton, MyChar

    RaceWindow = GemRB.LoadWindow(8, "GUICG")
    CharGenCommon.PositionCharGenWin(RaceWindow)

    MyChar = GemRB.GetVar("Slot")
    RaceCount = CommonTables.Races.GetRowCount()

    for i in range(2, RaceCount + 2):
        #hack to stop if the race table has more entries than the gui resource
        #this needs to be done because the race table has non-selectable entries
        Button = RaceWindow.GetControl(i)
        if not Button:
            RaceCount = i - 2
            break
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

    GemRB.SetVar("Race", -1)
    for i in range(2, RaceCount + 2):
        Button = RaceWindow.GetControl(i)
        Button.SetText(CommonTables.Races.GetValue(i - 2, 0))
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RacePress)
        Button.SetVarAssoc("Race", i - 2)

    BackButton = RaceWindow.GetControl(i + 2)  #i=8 now (when race count is 7)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = RaceWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()
    DoneButton.SetDisabled(True)

    TextAreaControl = RaceWindow.GetControl(12)
    TextAreaControl.SetText(17237)

    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    RaceWindow.Focus()
    return
Esempio n. 11
0
def OpenSpellsWindow(actor,
                     table,
                     level,
                     diff,
                     kit=0,
                     gen=0,
                     recommend=True,
                     booktype=0):
    """Opens the spells selection window.

	table should refer to the name of the classes MXSPLxxx.2da.
	level contains the current level of the actor.
	diff contains the difference from the old level.
	kit should always be GetKitIndex except when dualclassing.
	gen is true if this is for character generation.
	recommend is used in bg2 for spell recommendation / autopick."""

    global SpellsWindow, DoneButton, SpellsSelectPointsLeft, Spells, chargen, SpellPointsLeftLabel
    global SpellsTextArea, SpellTopIndex, SpellBook, SpellLevel, pc, SpellStart, BonusPoints
    global KitMask, EnhanceGUI, Memorization, SpellBookType, SpellsPickButton, ButtonCount, Class

    #enhance GUI?
    if (GemRB.GetVar("GUIEnhancements") & GE_SCROLLBARS) and not IWD2:
        EnhanceGUI = 1

    # save our pc
    pc = actor
    chargen = gen

    # this ensures compatibility with chargen, sorc, and dual-classing
    if kit == 0:
        KitMask = 0x4000
    else:  # need to implement this if converted to CharGen
        KitMask = kit

    if IWD2:
        # save the spellbook type (class) that corresponds to our table
        SpellBookType = booktype
        if not chargen:
            ButtonCount = 30

    # make sure there is an entry at the given level (bard)
    SpellLearnTable = table
    SpellsToMemoTable = GemRB.LoadTable(table)
    if not SpellsToMemoTable.GetValue(str(level), str(1), GTV_INT):
        if chargen:
            if GameCheck.IsBG2():
                GemRB.SetNextScript("GUICG6")
            elif GameCheck.IsBG1():
                # HACK
                from CharGenCommon import next
                next()
            elif IWD2:
                GemRB.SetNextScript("CharGen7")
        return

    # load our window
    if chargen:
        SpellsWindow = GemRB.LoadWindow(7, "GUICG")

        if GameCheck.IsBG2():
            import CharGenCommon
            CharGenCommon.PositionCharGenWin(SpellsWindow)
        elif GameCheck.IsIWD2():
            import CharOverview
            CharOverview.PositionCharGenWin(SpellsWindow)

        DoneButton = SpellsWindow.GetControl(0)
        SpellsTextArea = SpellsWindow.GetControl(27)
        SpellPointsLeftLabel = SpellsWindow.GetControl(0x1000001b)
        if (EnhanceGUI):
            sb = SpellsWindow.CreateScrollBar(NewScrollBarID, {
                'x': 325,
                'y': 42,
                'w': 16,
                'h': 252
            })
            sb.SetVisible(False)
        SpellStart = 2

        # cancel button only applicable for chargen
        SpellsCancelButton = SpellsWindow.GetControl(29)
        SpellsCancelButton.SetState(IE_GUI_BUTTON_ENABLED)
        SpellsCancelButton.OnPress(SpellsCancelPress)
        SpellsCancelButton.SetText(13727)
        SpellsCancelButton.MakeEscape()

        if (recommend):
            # recommended spell picks
            SpellsPickButton = SpellsWindow.GetControl(30)
            SpellsPickButton.SetState(IE_GUI_BUTTON_ENABLED)
            SpellsPickButton.OnPress(SpellsPickPress)
            SpellsPickButton.SetText(34210)
    else:
        SpellsWindow = GemRB.LoadWindow(8)
        if IWD2:
            DoneButton = SpellsWindow.GetControl(33)
            SpellsTextArea = SpellsWindow.GetControl(30)
            SpellPointsLeftLabel = SpellsWindow.GetControl(0x10000022)
        else:
            DoneButton = SpellsWindow.GetControl(28)
            SpellsTextArea = SpellsWindow.GetControl(26)
            SpellPointsLeftLabel = SpellsWindow.GetControl(0x10000018)
        if (EnhanceGUI):
            sb = SpellsWindow.CreateScrollBar(NewScrollBarID, {
                'x': 290,
                'y': 142,
                'w': 16,
                'h': 252
            })
            sb.SetVisible(False)
            #25th spell button for sorcerers
            SpellsWindow.CreateButton(24, 231, 345, 42, 42)

        SpellStart = 0

    # setup our variables
    GemRB.SetVar("SpellTopIndex", 0)
    Memorization = 0
    Class = GemRB.GetPlayerStat(pc, IE_CLASS)
    if IWD2 and not chargen:
        LUClass = GemRB.GetVar("LUClass")
        LUClassName = CommonTables.Classes.GetRowName(LUClass)
        LUClassID = CommonTables.Classes.GetValue(LUClassName, "ID")
        Class = LUClassID

    # the done button also doubles as a next button
    DoneButton.SetDisabled(True)
    DoneButton.OnPress(SpellsDonePress)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    # adjust the table for the amount of spells available for learning for free
    # bg2 had SPLSRCKN, iwd2 also SPLBRDKN, but all the others lacked the tables
    if SpellLearnTable == "MXSPLSOR" or SpellLearnTable == "MXSPLSRC":
        SpellLearnTable = "SPLSRCKN"
    elif SpellLearnTable == "MXSPLBRD":
        SpellLearnTable = "SPLBRDKN"
    # ... which is also important for mages during chargen and then never again
    elif SpellLearnTable == "MXSPLWIZ":
        SpellLearnTable = "SPLWIZKN"
    else:
        print(
            "OpenSpellsWindow: unhandled spell learning type encountered, falling back to memo table:",
            table)
    SpellLearnTable = GemRB.LoadTable(SpellLearnTable)

    CastingStatValue = 0
    if IWD2:
        # mxsplbon.2da is handled in core, but does also affect learning, at least in chargen
        BonusSpellTable = GemRB.LoadTable("mxsplbon")
        ClassRowName = GUICommon.GetClassRowName(pc)
        CastingStat = CommonTables.ClassSkills.GetValue(
            ClassRowName, "CASTING", GTV_INT)
        CastingStatValue = GemRB.GetPlayerStat(pc, CastingStat)

    AlreadyShown = 0
    for i in range(9):
        # make sure we always have a value to minus (bards)
        SecondPoints = SpellsToMemoTable.GetValue(str(level - diff),
                                                  str(i + 1), GTV_INT)

        # make sure we get more spells of each class before continuing
        SpellsSelectPointsLeft[i] = SpellsToMemoTable.GetValue(
            str(level), str(i + 1), GTV_INT) - SecondPoints
        if SpellsSelectPointsLeft[i] <= 0:
            continue

        SpellsSelectPointsLeft[i] = SpellLearnTable.GetValue(
            str(level), str(i + 1), GTV_INT)
        # luckily the bonus applies both to learning and memorization
        if IWD2 and chargen:
            BonusPoints[i] = BonusSpellTable.GetValue(str(CastingStatValue),
                                                      str(i + 1), GTV_INT)
            SpellsSelectPointsLeft[i] += BonusPoints[i]

        if SpellsSelectPointsLeft[i] <= 0:
            continue
        elif chargen and KitMask != 0x4000 and (not IWD2 or SpellBookType
                                                == IE_IWD2_SPELL_WIZARD):
            # specialists get an extra spell per level
            SpellsSelectPointsLeft[i] += 1
            BonusPoints[i] += 1

        # get all the spells of the given level
        Spells[i] = Spellbook.GetMageSpells(
            KitMask, GemRB.GetPlayerStat(pc, IE_ALIGNMENT), i + 1, Class)

        # dump all the spells we already know
        NumDeleted = 0
        for j in range(len(Spells[i])):
            CurrentIndex = j - NumDeleted  # this ensure we don't go out of range
            if Spellbook.HasSpell(pc, SpellBookType, i,
                                  Spells[i][CurrentIndex][0]) >= 0:
                del Spells[i][CurrentIndex]
                NumDeleted += 1

        # display these spells if it's the first non-zero level
        if AlreadyShown == 0:
            # save the level and spellbook data
            SpellLevel = i
            SpellBook = [0] * len(Spells[i])

            ScrollBar = SpellsWindow.GetControl(NewScrollBarID)
            UpdateScrollBar(ScrollBar, len(Spells[i]))

            # show our spells
            ShowSpells()
            AlreadyShown = 1

    # show the selection window
    if chargen:
        if recommend:
            SpellsWindow.Focus()
        else:
            SpellsWindow.ShowModal(MODAL_SHADOW_NONE)
    else:
        SpellsWindow.ShowModal(MODAL_SHADOW_GRAY)

    return
Esempio n. 12
0
def OnLoad():
    global ColorWindow, DoneButton, PDollButton, ColorTable
    global HairButton, SkinButton, MajorButton, MinorButton
    global HairColor, SkinColor, MajorColor, MinorColor

    ColorWindow = GemRB.LoadWindow(13, "GUICG")
    ColorWindow.SetFlags(WF_ALPHA_CHANNEL, OP_OR)
    import CharGenCommon
    CharGenCommon.PositionCharGenWin(ColorWindow, -6)

    ColorTable = GemRB.LoadTable("clowncol")
    #set these colors to some default
    PortraitTable = GemRB.LoadTable("pictures")
    PortraitName = GemRB.GetToken("LargePortrait")
    PortraitName = PortraitName[0:len(PortraitName) - 1]
    PortraitIndex = PortraitTable.GetRowIndex(PortraitName)
    if PortraitIndex < 0:
        HairColor = PortraitTable.GetValue(0, 1)
        SkinColor = PortraitTable.GetValue(0, 2)
        MinorColor = PortraitTable.GetValue(0, 3)
        MajorColor = PortraitTable.GetValue(0, 4)
    else:
        HairColor = PortraitTable.GetValue(PortraitIndex, 1)
        SkinColor = PortraitTable.GetValue(PortraitIndex, 2)
        MinorColor = PortraitTable.GetValue(PortraitIndex, 3)
        MajorColor = PortraitTable.GetValue(PortraitIndex, 4)

    PDollButton = ColorWindow.GetControl(1)
    PDollButton.SetState(IE_GUI_BUTTON_LOCKED)
    PDollButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR)

    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, HairColor)

    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, SkinColor)

    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, MinorColor)

    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, MajorColor)

    BackButton = ColorWindow.GetControl(13)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    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)
    BGCommon.RefreshPDoll(PDollButton, MinorColor, MajorColor, SkinColor,
                          HairColor)
    ColorWindow.Focus()
    return
Esempio n. 13
0
def SetupProfsWindow(pc,
                     proftype,
                     window,
                     callback,
                     level1=[0, 0, 0],
                     level2=[1, 1, 1],
                     classid=0,
                     scroll=True,
                     profTableOffset=8):
    """Opens the proficiency selection window.

	type specifies the type of selection we are doing; choices are above.
	window specifies the window to be updated.
	callback specifies the function to call on changes.
	classid is sent only during dualclassing to specify the new class."""

    global ProfsOffsetSum, ProfsOffsetButton1, ProfsOffsetLabel, ProfsOffsetStar, OddIDs
    global ProfsOffsetPress, ProfsPointsLeft, ProfsNumButtons, ProfsTopIndex
    global ProfsScrollBar, ProfsTableOffset, ProfsType
    global ProfsWindow, ProfsCallback, ProfsTextArea, ProfsColumn, ProfsTable, ProfCount
    global Profs2ndOffsetButton1, Profs2ndOffsetStar, Profs2ndOffsetLabel, ClassNameSave, ClassWeaponsTable

    # make sure we're within ranges
    GemRB.SetVar("ProfsPointsLeft", 0)
    if not window or not callback or len(level1) != len(level2):
        return

    # save the values we'll point to
    ProfsWindow = window
    ProfsCallback = callback
    ProfsTableOffset = profTableOffset
    ProfsType = type

    if proftype == LUPROFS_TYPE_CHARGEN and (GameCheck.IsBG1()
                                             or GameCheck.IsBG2()):  #chargen
        ProfsOffsetSum = 9
        ProfsOffsetButton1 = 11
        ProfsOffsetStar = 27
        ProfsOffsetLabel = 1
        ProfsOffsetPress = 69
        ProfsNumButtons = 8
        ProfsTextArea = ProfsWindow.GetControl(68)
        ProfsTextArea.SetText(9588)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(78)

        if GameCheck.IsBG2() or GameCheck.IsIWD2():
            import CharGenCommon
            CharGenCommon.PositionCharGenWin(ProfsWindow)
    elif proftype == LUPROFS_TYPE_LEVELUP and GameCheck.IsBG2():  #levelup
        ProfsOffsetSum = 36
        ProfsOffsetButton1 = 1
        ProfsOffsetStar = 48
        ProfsOffsetLabel = 24
        ProfsOffsetPress = 112
        ProfsNumButtons = 7
        ProfsTextArea = ProfsWindow.GetControl(110)
        ProfsScrollBar = ProfsWindow.GetControl(108)
    elif proftype == LUPROFS_TYPE_LEVELUP and GameCheck.IsBG1():  #levelup
        ProfsOffsetSum = 36
        ProfsOffsetButton1 = 1
        ProfsOffsetStar = 48
        ProfsOffsetLabel = 24
        ProfsOffsetPress = 17
        ProfsNumButtons = 8
        ProfsTextArea = ProfsWindow.GetControl(42)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(108)
    elif proftype == LUPROFS_TYPE_LEVELUP and GameCheck.IsIWD1():  #levelup
        ProfsOffsetSum = 36
        ProfsOffsetButton1 = 1
        ProfsOffsetStar = 48
        ProfsOffsetLabel = 24
        ProfsOffsetPress = -1
        ProfsNumButtons = 15  # 8+7, the 7 are done with the following vars
        Profs2ndOffsetButton1 = 150
        Profs2ndOffsetStar = 115
        Profs2ndOffsetLabel = 108
        ProfsTextArea = ProfsWindow.GetControl(42)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(108)
        OddIDs = 0
    elif proftype == LUPROFS_TYPE_DUALCLASS and GameCheck.IsIWD1():  #dualclass
        ProfsOffsetSum = 40
        ProfsOffsetButton1 = 50
        ProfsOffsetStar = 0
        ProfsOffsetLabel = 41
        ProfsOffsetPress = -1  #66
        ProfsNumButtons = 15
        Profs2ndOffsetButton1 = 78
        Profs2ndOffsetStar = 92
        Profs2ndOffsetLabel = 126
        ProfsTextArea = ProfsWindow.GetControl(74)
        ProfsTextArea.SetText(9588)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(None)
        OddIDs = 1
    elif proftype == LUPROFS_TYPE_DUALCLASS and GameCheck.IsBG1():  #dualclass
        ProfsOffsetSum = 40
        ProfsOffsetButton1 = 50
        ProfsOffsetStar = 0
        ProfsOffsetLabel = 41
        ProfsOffsetPress = -1  #FIXME
        ProfsNumButtons = 8
        ProfsTextArea = ProfsWindow.GetControl(74)
        ProfsTextArea.SetText(9588)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(None)
    elif proftype == LUPROFS_TYPE_DUALCLASS:  #dualclass
        ProfsOffsetSum = 40
        ProfsOffsetButton1 = 50
        ProfsOffsetStar = 0
        ProfsOffsetLabel = 41
        ProfsOffsetPress = 66
        ProfsNumButtons = 8
        ProfsTextArea = ProfsWindow.GetControl(74)
        ProfsTextArea.SetText(9588)
        if (scroll):
            ProfsScrollBar = ProfsWindow.GetControl(78)
    else:  #unknown
        return

    #nullify internal variables
    GemRB.SetVar("ProfsTopIndex", 0)
    ProfsPointsLeft = 0
    ProfsTopIndex = 0

    ProfsTable = GemRB.LoadTable("profs")
    if GameCheck.IsIWD1() or GameCheck.IsBG1():
        ClassWeaponsTable = GemRB.LoadTable("clasweap")
    else:
        ClassWeaponsTable = None

    #get the class name
    IsDual = GUICommon.IsDualClassed(pc, 1)
    if classid:  #for dual classes when we can't get the class dualing to
        Class = classid
    elif IsDual[0] == 3:
        Class = CommonTables.KitList.GetValue(IsDual[2], 7)
    elif IsDual[0]:
        Class = GUICommon.GetClassRowName(IsDual[2], "index")
        Class = CommonTables.Classes.GetValue(Class, "ID")
    else:
        Class = GemRB.GetPlayerStat(pc, IE_CLASS)
    ClassName = GUICommon.GetClassRowName(Class, "class")

    # profs.2da has entries for everyone, so no need to muck around
    ProfsRate = ProfsTable.GetValue(ClassName, "RATE")

    #figure out how many prof points we have
    if sum(level1
           ) == 0:  #character is being generated (either chargen or dual)
        ProfsPointsLeft = ProfsTable.GetValue(ClassName, "FIRST_LEVEL")

    ProfIndex = 0
    IsMulti = GUICommon.IsMultiClassed(pc, 1)
    if IsMulti[0] > 1:
        if sum(level1
               ) == 0:  #character is being generated (either chargen or dual)
            # don't give too many points; exact formula unknown, but this works with f/m and f/m/t
            ProfsPointsLeft += sum(level2) // IsMulti[0] // ProfsRate
        else:
            # just look at the fastest prof-gaining class in the bunch and consider their level
            # eg. a m/t should get a point at 3/4 and 7/8 (rate of 4)
            BestRate = 100
            for cls in IsMulti[1:]:
                if cls == 0:
                    break
                ClsName = GUICommon.GetClassRowName(cls, "class")
                Rate = ProfsTable.GetValue(ClsName, "RATE")
                if Rate < BestRate:
                    BestRate = Rate
                    ProfIndex = IsMulti[1:].index(cls)

            ProfsPointsLeft += level2[ProfIndex] // ProfsRate - level1[
                ProfIndex] // ProfsRate
    else:
        if GUICommon.IsDualSwap(pc):
            ProfIndex = 1

        #we need these 2 number to floor before subtracting
        ProfsPointsLeft += level2[ProfIndex] // ProfsRate - level1[
            ProfIndex] // ProfsRate

    #setup prof vars for passing between functions
    ProfsTable = GemRB.LoadTable("weapprof")

    # weapprof has no sorcerer entry
    if ClassName == "SORCERER":
        ClassName = "MAGE"
    ClassNameSave = ClassName

    # if we have the classweapons table, use it
    if ClassWeaponsTable:
        ProfsColumn = ClassWeaponsTable.GetRowIndex(ClassName)
    else:
        Kit = GUICommon.GetKitIndex(pc)
        if Kit and proftype != LUPROFS_TYPE_DUALCLASS and IsMulti[
                0] < 2 and IsDual[0] in [0, 3]:
            #if we do kit with dualclass, we'll get the old kit (usually)
            #also don't want to worry about kitted multis
            ProfsColumn = CommonTables.KitList.GetValue(Kit, 5)
        else:
            ProfsColumn = ProfsTable.GetColumnIndex(ClassName)

    #setup some basic counts
    RowCount = ProfsTable.GetRowCount() - ProfsTableOffset
    ProfCount = RowCount - ProfsNumButtons  #decrease it with the number of controls

    ProfsAssignable = 0
    TwoWeapIndex = ProfsTable.GetRowIndex("2WEAPON")
    for i in range(RowCount):
        ProfName = ProfsTable.GetValue(i + ProfsTableOffset, 1)
        #decrease it with the number of invalid proficiencies
        if ProfName > 0x1000000 or ProfName <= 0:
            ProfCount -= 1

        #we only need the low 3 bits for proficiencies on levelup; otherwise
        #we just set them all to 0
        currentprof = 0
        if proftype == LUPROFS_TYPE_LEVELUP:
            stat = ProfsTable.GetValue(i + ProfsTableOffset, 0)
            if GameCheck.IsBG1():
                stat = stat + IE_PROFICIENCYBASTARDSWORD
            currentprof = GemRB.GetPlayerStat(pc, stat) & 0x07
        else:
            #rangers always get 2 points in 2 weapons style
            if (i + ProfsTableOffset
                ) == TwoWeapIndex and "RANGER" in ClassName.split("_"):
                currentprof = 2
        GemRB.SetVar("Prof " + str(i), currentprof)
        GemRB.SetVar("ProfBase " + str(i), currentprof)

        #see if we can assign to this prof
        if ClassWeaponsTable:
            # this table has profs as rows, so ignore the weird use of the column var
            # it also has different ordering than ProfsTable
            col = ClassWeaponsTable.GetColumnIndex(ProfsTable.GetRowName(i))
            maxprof = ClassWeaponsTable.GetValue(ProfsColumn, col)
        else:
            maxprof = ProfsTable.GetValue(i + ProfsTableOffset, ProfsColumn)
        if maxprof > currentprof:
            ProfsAssignable += maxprof - currentprof

    #correct the profs left if we can't assign that much
    if ProfsPointsLeft > ProfsAssignable:
        ProfsPointsLeft = ProfsAssignable
    GemRB.SetVar("ProfsPointsLeft", ProfsPointsLeft)

    # setup the +/- and info controls
    for i in range(ProfsNumButtons):
        if ProfsOffsetPress != -1:
            Button = ProfsWindow.GetControl(i + ProfsOffsetPress)
            Button.SetVarAssoc("Prof", i)
            Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ProfsJustPress)

        cid = i * 2 + ProfsOffsetButton1
        if Profs2ndOffsetButton1 != -1 and i > 7:
            cid = (i - 8) * 2 + Profs2ndOffsetButton1

        Button = ProfsWindow.GetControl(cid)
        Button.SetVarAssoc("Prof", i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ProfsLeftPress)
        Button.SetActionInterval(200)

        Button = ProfsWindow.GetControl(cid + 1)
        Button.SetVarAssoc("Prof", i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ProfsRightPress)
        Button.SetActionInterval(200)

    if (ProfsScrollBar):
        # proficiencies scrollbar
        ProfsScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE,
                                ProfsScrollBarPress)
        ProfsWindow.SetEventProxy(ProfsScrollBar)
        ProfsScrollBar.SetVarAssoc("ProfsTopIndex", ProfCount)
    ProfsRedraw(1)
    return
Esempio n. 14
0
def OnLoad():
	global KitWindow, TextAreaControl, DoneButton
	global SchoolList, ClassName
	global RowCount, TopIndex, KitTable, Init, MyChar

	MyChar = GemRB.GetVar ("Slot")
	Race = GemRB.GetPlayerStat (MyChar, IE_RACE)
	RaceName = CommonTables.Races.GetRowName(CommonTables.Races.FindValue (3, Race) )

	ClassName = CommonTables.Classes.GetRowName (GemRB.GetPlayerStat (MyChar, IE_HITPOINTS)) # barbarian hack

	KitTable = GemRB.LoadTable("kittable")
	KitTableName = KitTable.GetValue(ClassName, RaceName)
	KitTable = GemRB.LoadTable(KitTableName,1)

	SchoolList = GemRB.LoadTable("magesch")

	#there is a specialist mage window, but it is easier to use
	#the class kit window for both
	KitWindow = GemRB.LoadWindow(22, "GUICG")
	CharGenCommon.PositionCharGenWin(KitWindow)
	
	if ClassName == "MAGE":
		Label = KitWindow.GetControl(0xfffffff)
		Label.SetText(595)

	for i in range(10):
		if i<4:
			Button = KitWindow.GetControl(i+1)
		else:
			Button = KitWindow.GetControl(i+5)
		Button.SetState(IE_GUI_BUTTON_DISABLED)
		Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)

	if not KitTable: # sorcerer or monk
		RowCount = 1
	else:
		if ClassName == "MAGE": # mages
			RowCount = SchoolList.GetRowCount()
		else:
			RowCount = KitTable.GetRowCount()

	TopIndex = 0
	GemRB.SetVar("TopIndex", 0)
	if EnhanceGUI:
		tmpRowCount = RowCount
		if RowCount>10: #create 11 kit button
			extrakit = KitWindow.CreateButton (15, 18, 250, 271, 20)
			extrakit.SetState(IE_GUI_BUTTON_DISABLED)
			extrakit.SetFlags(IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_CAPS, OP_OR)
			extrakit.SetSprites("GUICGBC",0, 0,1,2,3)
			RowCount = 11

		if tmpRowCount>11: #create scroll bar
			ScrollBar = KitWindow.CreateScrollBar(1000, {'x' : 290, 'y' : 50, 'w' : 16, 'h' : 220}, "GUISCRCW")
			ScrollBar.SetVarAssoc ("TopIndex", tmpRowCount-10, 0, tmpRowCount-10)
			ScrollBar.OnChange (RedrawKits)
			KitWindow.SetEventProxy(ScrollBar)

	elif not EnhanceGUI and RowCount>10:
		RowCount = 10

	for i in range(RowCount):
		if i<4:
			Button = KitWindow.GetControl(i+1)
		else:
			Button = KitWindow.GetControl(i+5)
		Button.SetVarAssoc("ButtonPressed", i)
		Button.OnPress (KitPress)

	BackButton = KitWindow.GetControl(8)
	BackButton.SetText(15416)
	BackButton.MakeEscape()
	DoneButton = KitWindow.GetControl(7)
	DoneButton.SetText(11973)
	DoneButton.MakeDefault()

	TextAreaControl = KitWindow.GetControl(5)
	TextAreaControl.SetText(17247)

	DoneButton.OnPress (NextPress)
	BackButton.OnPress (BackPress)
	Init = 1
	RedrawKits()
	KitPress()
	KitWindow.Focus()
	return
Esempio n. 15
0
def OnLoad():
    global AbilityWindow, TextAreaControl, DoneButton
    global PointsLeft, HasStrExtra
    global AbilityTable, Abclasrq, Abclsmod, Abracerq, Abracead
    global KitIndex, Minimum, Maximum, MyChar
    global AllPoints18

    AllPoints18 = 0

    Abracead = GemRB.LoadTable("ABRACEAD")
    if GemRB.HasResource("ABCLSMOD", RES_2DA):
        Abclsmod = GemRB.LoadTable("ABCLSMOD")
    Abclasrq = GemRB.LoadTable("ABCLASRQ")
    Abracerq = GemRB.LoadTable("ABRACERQ")

    MyChar = GemRB.GetVar("Slot")
    Kit = GUICommon.GetKitIndex(MyChar)
    ClassName = GUICommon.GetClassRowName(MyChar)
    if Kit == 0:
        KitName = ClassName
    else:
        #rowname is just a number, first value row what we need here
        KitName = CommonTables.KitList.GetValue(Kit, 0)

    #if the class uses the warrior table for saves, then it may have the extra strength
    HasStrExtra = CommonTables.Classes.GetValue(ClassName, "STREXTRA", GTV_INT)

    KitIndex = Abclasrq.GetRowIndex(KitName)

    AbilityTable = GemRB.LoadTable("ability")
    AbilityWindow = GemRB.LoadWindow(4, "GUICG")
    CharGenCommon.PositionCharGenWin(AbilityWindow)

    Button = AbilityWindow.CreateButton(2000, 0, 0, 0, 0)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GiveAll18)
    Button.SetHotKey("8", 3,
                     True)  # TODO: make defines for CTRL and SHIFT modifiers

    RerollButton = AbilityWindow.GetControl(2)
    RerollButton.SetText(11982)
    StoreButton = AbilityWindow.GetControl(37)
    StoreButton.SetText(17373)
    RecallButton = AbilityWindow.GetControl(38)
    RecallButton.SetText(17374)

    BackButton = AbilityWindow.GetControl(36)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = AbilityWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()
    DoneButton.SetState(IE_GUI_BUTTON_ENABLED)

    RollPress()
    StorePress()
    for i in range(6):
        Button = AbilityWindow.GetControl(i + 30)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, JustPress)
        Button.SetEvent(IE_GUI_MOUSE_LEAVE_BUTTON, EmptyPress)
        Button.SetVarAssoc("Ability", i)
        # delete the labels and use the buttons instead
        AbilityWindow.DeleteControl(i + 0x10000009)
        Button.SetText(AbilityTable.GetValue(i, 0))
        Button.SetFlags(IE_GUI_BUTTON_ALIGN_RIGHT, OP_OR)
        Button.SetState(IE_GUI_BUTTON_LOCKED)

        Button = AbilityWindow.GetControl(i * 2 + 16)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, LeftPress)
        Button.SetVarAssoc("Ability", i)
        Button.SetActionInterval(200)

        Button = AbilityWindow.GetControl(i * 2 + 17)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RightPress)
        Button.SetVarAssoc("Ability", i)
        Button.SetActionInterval(200)

    TextAreaControl = AbilityWindow.GetControl(29)
    TextAreaControl.SetText(17247)

    StoreButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, StorePress)
    RecallButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, RecallPress)
    RerollButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, RollPress)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    AbilityWindow.Focus()
    return
Esempio n. 16
0
def OnLoad():
    global ClassWindow, TextAreaControl, DoneButton, MyChar

    ClassWindow = GemRB.LoadWindow(2, "GUICG")
    CharGenCommon.PositionCharGenWin(ClassWindow)

    MyChar = GemRB.GetVar("Slot")
    Race = CommonTables.Races.FindValue(3,
                                        GemRB.GetPlayerStat(MyChar, IE_RACE))
    RaceName = CommonTables.Races.GetRowName(Race)

    ClassCount = CommonTables.Classes.GetRowCount() + 1

    j = 0
    #radiobutton groups must be set up before doing anything else to them
    for i in range(1, ClassCount):
        ClassName = CommonTables.Classes.GetRowName(i - 1)
        if CommonTables.Classes.GetValue(ClassName, "MULTI"):
            continue
        if j > 7:
            Button = ClassWindow.GetControl(j + 7)
        else:
            Button = ClassWindow.GetControl(j + 2)
        Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
        Button.SetState(IE_GUI_BUTTON_DISABLED)
        j = j + 1

    j = 0
    GemRB.SetVar("MAGESCHOOL", 0)
    HasMulti = 0
    for i in range(1, ClassCount):
        ClassName = CommonTables.Classes.GetRowName(i - 1)
        Allowed = CommonTables.Classes.GetValue(ClassName, RaceName)
        if CommonTables.Classes.GetValue(ClassName, "MULTI"):
            if Allowed != 0:
                HasMulti = 1
            continue
        if j > 7:
            Button = ClassWindow.GetControl(j + 7)
        else:
            Button = ClassWindow.GetControl(j + 2)
        j = j + 1
        t = CommonTables.Classes.GetValue(ClassName, "NAME_REF")
        Button.SetText(t)

        if Allowed == 0:
            continue
        if Allowed == 2:
            GemRB.SetVar("MAGESCHOOL", 5)  #illusionist
        Button.SetState(IE_GUI_BUTTON_ENABLED)
        Button.OnPress(ClassPress)
        Button.SetVarAssoc("Class", i)

    MultiClassButton = ClassWindow.GetControl(10)
    MultiClassButton.SetText(11993)
    if HasMulti == 0:
        MultiClassButton.SetState(IE_GUI_BUTTON_DISABLED)

    BackButton = ClassWindow.GetControl(14)
    BackButton.SetText(15416)
    BackButton.MakeEscape()
    DoneButton = ClassWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    TextAreaControl = ClassWindow.GetControl(13)

    ClassName = GUICommon.GetClassRowName(GemRB.GetVar("Class") - 1, "index")
    if ClassName == "":
        TextAreaControl.SetText(17242)
        DoneButton.SetDisabled(True)
    else:
        TextAreaControl.SetText(
            CommonTables.Classes.GetValue(ClassName, "DESC_REF"))
        DoneButton.SetDisabled(False)

    MultiClassButton.OnPress(MultiClassPress)
    DoneButton.OnPress(NextPress)
    BackButton.OnPress(BackPress)
    ClassWindow.Focus()
    return
Esempio n. 17
0
def OnLoad():
    global AppearanceWindow, PortraitButton, PortraitsTable, LastPortrait
    global Gender

    Gender = GemRB.GetVar("Gender")

    AppearanceWindow = GemRB.LoadWindow(11, "GUICG")
    CharGenCommon.PositionCharGenWin(AppearanceWindow, -6)

    #Load the Portraits Table
    PortraitsTable = GemRB.LoadTable("PICTURES")
    PortraitsStart = PortraitsTable.FindValue(0, 2)
    FemaleCount = PortraitsTable.GetRowCount() - PortraitsStart + 1
    if Gender == 2:
        LastPortrait = GemRB.Roll(1, FemaleCount, PortraitsStart - 1)
    else:
        LastPortrait = GemRB.Roll(1,
                                  PortraitsTable.GetRowCount() - FemaleCount,
                                  0)

    #this control doesn't exist in the demo version (it is unused, so lets just skip it)
    TextAreaControl = AppearanceWindow.GetControl(7)
    if TextAreaControl:
        TextAreaControl.SetText("")

    PortraitButton = AppearanceWindow.GetControl(1)
    PortraitButton.SetFlags(IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE,
                            OP_SET)
    PortraitButton.SetState(IE_GUI_BUTTON_LOCKED)

    LeftButton = AppearanceWindow.GetControl(2)
    RightButton = AppearanceWindow.GetControl(3)

    BackButton = AppearanceWindow.GetControl(5)
    BackButton.SetText(15416)
    BackButton.MakeEscape()

    CustomButton = AppearanceWindow.GetControl(6)
    CustomButton.SetText(17545)

    DoneButton = AppearanceWindow.GetControl(0)
    DoneButton.SetText(11973)
    DoneButton.MakeDefault()

    RightButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, RightPress)
    LeftButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LeftPress)
    BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
    CustomButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CustomPress)
    DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)

    Flag = False
    while True:
        if PortraitsTable.GetValue(LastPortrait, 0) == Gender:
            SetPicture()
            break
        LastPortrait = LastPortrait + 1
        if LastPortrait >= PortraitsTable.GetRowCount():
            LastPortrait = 0
            if Flag:
                SetPicture()
                break
            Flag = True

    AppearanceWindow.Focus()
    return