Beispiel #1
0
def SetupClockWindowControls(Window):
    # time button
    Button = Window.GetControl(0)
    Clock.CreateClockButton(Button)

    # 41627 - Return to the Game World
    Button = Window.GetControl(2)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUICommonWindows.CloseTopWindow)
    Button.SetTooltip(41627)

    # Select all characters
    Button = Window.GetControl(1)
    Button.SetTooltip(41659)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUICommon.SelectAllOnPress)

    # Abort current action
    Button = Window.GetControl(3)
    Button.SetTooltip(41655)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUICommonWindows.ActionStopPressed)

    # Formations
    import GUIWORLD
    Button = Window.GetControl(4)
    Button.SetTooltip(44945)
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, GUIWORLD.OpenFormationWindow)

    return
Beispiel #2
0
def OpenContainerWindow():
    global ContainerWindow, Container

    if ContainerWindow:
        return

    global HideOnClose
    HideOnClose = IsGameGUIHidden()

    if HideOnClose:
        SetGameGUIHidden(False)
        # must use a timed event because SetGameGUIHidden(False) sets a flag to unhide the gui next frame
        # AFIK not needed, commented out in case it turns out there are conditions we will need it
        # GemRB.SetTimedEvent (lambda: GemRB.GetView ("MSGWIN").SetVisible(False), 1)
    else:
        GemRB.GetView("MSGWIN").SetVisible(False)
        ActWin = GemRB.GetView("ACTWIN")
        if ActWin:
            ActWin.SetVisible(False)

    ContainerWindow = Window = GemRB.LoadWindow(8, GUICommon.GetWindowPack(),
                                                WINDOW_BOTTOM | WINDOW_HCENTER)
    # fix wrong height in the guiw10.chu and reposition
    # that chu is also used as a base for some arbitrary resolutions
    if GameCheck.IsBG2() and GemRB.GetSystemVariable(SV_HEIGHT) >= 768:
        Size = Window.GetSize()
        Pos = Window.GetPos()
        Window.SetSize(Size[0], 90)
        Window.SetPos(Pos[0], GemRB.GetSystemVariable(SV_HEIGHT) - 90)

    if not GameCheck.IsIWD2() and not GameCheck.IsGemRBDemo(
    ) and not GameCheck.IsPST():
        # container window shouldnt be in front
        GemRB.GetView("OPTWIN").Focus()
        GemRB.GetView("PORTWIN").Focus()

    Container = GemRB.GetContainer(0)

    # Gears (time) when options pane is down
    if GameCheck.IsBG2():
        import Clock
        Clock.CreateClockButton(Window.GetControl(62))

    # 0-5 - Ground Item
    for i in range(ground_size):
        Button = Window.GetControl(i)
        Button.SetVarAssoc("LeftIndex", i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, TakeItemContainer)
        if GameCheck.IsPST():
            Button.SetFont("NUMBER")
            Button.SetFlags(
                IE_GUI_BUTTON_ALIGN_RIGHT | IE_GUI_BUTTON_ALIGN_BOTTOM, OP_OR)

    # 10-13 - Personal Item
    for i in range(4):
        Button = Window.GetControl(i + 10)
        Button.SetVarAssoc("RightIndex", i)
        Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, DropItemContainer)
        if GameCheck.IsPST():
            Button.SetFont("NUMBER")
            Button.SetFlags(
                IE_GUI_BUTTON_ALIGN_RIGHT | IE_GUI_BUTTON_ALIGN_BOTTOM, OP_OR)

    # left scrollbar (container)
    ScrollBar = Window.GetControl(52)
    ScrollBar.SetVisible(
        True)  # unhide because in PST it is linked to a TextArea
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawContainerWindow)

    # right scrollbar (inventory)
    ScrollBar = Window.GetControl(53)
    ScrollBar.SetVisible(
        True)  # unhide because in PST it is linked to a TextArea
    ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, RedrawContainerWindow)

    # encumbrance and inventory icon
    # iwd has a handy button
    Button = Window.GetControl(54)
    if Button:
        if GameCheck.IsPST():
            Button.SetFont("NUMBER")
            Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
        Button.CreateLabel(
            0x10000045, "NUMBER", "",
            IE_FONT_ALIGN_LEFT | IE_FONT_ALIGN_TOP | IE_FONT_SINGLE_LINE)
        Button.CreateLabel(
            0x10000046, "NUMBER", "",
            IE_FONT_ALIGN_RIGHT | IE_FONT_ALIGN_BOTTOM | IE_FONT_SINGLE_LINE)
    else:
        Window.CreateLabel(
            0x10000045, 323, 14, 60, 15, "NUMBER", "0:",
            IE_FONT_ALIGN_LEFT | IE_FONT_ALIGN_TOP | IE_FONT_SINGLE_LINE)
        Window.CreateLabel(
            0x10000046, 323, 20, 80, 15, "NUMBER", "0:",
            IE_FONT_ALIGN_RIGHT | IE_FONT_ALIGN_TOP | IE_FONT_SINGLE_LINE)

    # container icon
    Button = Window.GetControl(50)
    if GameCheck.IsPST():
        Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
    Button.SetState(IE_GUI_BUTTON_LOCKED)

    if not GameCheck.IsPST():
        Table = GemRB.LoadTable("containr")
        row = Container['Type']
        tmp = Table.GetValue(row, 0)
        if tmp != '*':
            GemRB.PlaySound(tmp)
        tmp = Table.GetValue(row, 1)
        if tmp != '*':
            Button.SetSprites(tmp, 0, 0, 0, 0, 0)

    # Done
    Button = Window.GetControl(51)
    if GameCheck.IsPST():
        Button.SetText(1403)
    else:
        Button.SetText("")

    Button.MakeEscape()
    Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, LeaveContainer)

    GemRB.SetVar("LeftTopIndex", 0)
    GemRB.SetVar("RightTopIndex", 0)
    UpdateContainerWindow()