Ejemplo n.º 1
0
    def show(self):
        TIME = 35
        self.refresh()

        t = Transition()

        t.addChild(self.itemWnd,
                   startRect=(-self.itemWnd.right, self.itemWnd.top),
                   time=TIME)

        t.addChild(self.descWnd,
                   startRect=(self.descWnd.left, -self.descWnd.bottom),
                   time=TIME)

        t.addChild(self.moneyWnd,
                   startRect=(self.moneyWnd.left,
                              self.moneyWnd.bottom + self.moneyWnd.height),
                   time=TIME)

        for i in range(TIME):
            t.update(1)
            o = i * 128 / TIME  # tint intensity for this frame
            engine.raw_draw()
            ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                               ika.RGB(0, 0, 0, o), True)
            self.draw()
            ika.Video.ShowPage()
            ika.Input.Update()
Ejemplo n.º 2
0
    def hide(self):
        TIME = 40
        t = Transition()

        t.addChild(self.itemWnd,
                   endRect=(self.itemWnd.left,
                            ika.Video.yres + self.itemWnd.height),
                   time=TIME)

        t.addChild(self.descWnd,
                   endRect=(ika.Video.xres + self.descWnd.width,
                            self.descWnd.top),
                   time=TIME)

        t.addChild(self.moneyWnd,
                   endRect=(ika.Video.xres + self.moneyWnd.width,
                            self.moneyWnd.top),
                   time=TIME)

        for i in range(TIME - 1, -1, -1):
            t.update(1)
            o = i * 255 / TIME  # menu opacity for this frame
            engine.raw_draw()
            ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                               ika.RGB(0, 0, 0, o / 2), True)
            self.draw(o)
            ika.Video.ShowPage()
            ika.Input.Update()
Ejemplo n.º 3
0
def message(msg, context=None):
    'Displays a message to the player in a frame.'

    caption = gui.FrameDecorator(gui.StaticText())

    if isinstance(msg, str):
        # wrap such that the window is about three times as wide as it is tall.
        # (assume square characters because it doesn't have to be precise)
        charWidth = 3 * int(math.sqrt(len(msg) / 3))

        # max out at yres - caption.border * 2
        w = min(ika.Video.xres - caption.border * 2,
                charWidth * caption.font.width)
        msg = wrapText(msg, w, caption.font)

    caption.addText(*msg)

    caption.autoSize()
    caption.position = ((ika.Video.xres - caption.width) / 2,
                        (ika.Video.yres - caption.height) / 2)

    draw = context and context.draw or ika.Map.Render

    trans = Transition()
    trans.addChild(caption, startRect=(caption.x, -caption.height))
    trans.execute(draw)

    while not controls.enter():
        draw()
        caption.draw()
        ika.Video.ShowPage()
        ika.Input.Update()

    trans.addChild(caption, endRect=(caption.x, ika.Video.yres))
    trans.execute(draw)
Ejemplo n.º 4
0
    def hide(self):
        t = Transition()
        t.addChild(self.statbar,
                   endRect=(self.statbar.left, -self.statbar.height))
        t.addChild(self.miscwindow,
                   endRect=(self.miscwindow.left, -self.miscwindow.height))
        t.addChild(self.mainMenu, endRect=(ika.Video.xres, self.mainMenu.top))

        t.execute()
Ejemplo n.º 5
0
    def hide(self):
        t = Transition()
        t.addChild(self.statbar, endRect=(self.statbar.left, -self.statbar.height))
        t.addChild(self.miscwindow, endRect=(self.miscwindow.left, -self.miscwindow.height))
        t.addChild(self.mainMenu, endRect=(ika.Video.xres, self.mainMenu.top))

        t.execute()
Ejemplo n.º 6
0
    def show(self):
        self.layout()

        b = self.statbar.border

        t = Transition()
        t.addChild(self.statbar,
                   startRect=(self.statbar.left, ika.Video.yres + b))
        t.addChild(self.miscwindow,
                   startRect=(self.miscwindow.left, ika.Video.yres + b))
        t.addChild(self.mainMenu,
                   startRect=(-self.mainMenu.width - b, self.mainMenu.top))

        t.execute()
Ejemplo n.º 7
0
    def show(self):
        self.layout()

        b = self.statbar.border

        t = Transition()
        t.addChild(self.statbar, startRect=(self.statbar.left, ika.Video.yres + b))
        t.addChild(self.miscwindow, startRect=(self.miscwindow.left, ika.Video.yres + b))
        t.addChild(self.mainMenu, startRect=(-self.mainMenu.width - b, self.mainMenu.top))

        t.execute()
Ejemplo n.º 8
0
 def hide(self):
     TIME = 40
     self.update()
     t = Transition()
     t.addChild(self.control_menu,
                endRect=(self.control_menu.Left,
                         240 + self.control_menu.Top),
                time=TIME - 5)
     t.addChild(self.header, endRect=(self.header.Left, -40), time=TIME - 5)
     for i in range(TIME):
         t.update(1)
         self.draw()
         ika.Video.ShowPage()
         ika.Input.Update()
Ejemplo n.º 9
0
def Shop(*args):
    menu = ShopMenu(*args)
    trans = Transition()
    menu.startShow(trans)
    trans.execute()
    menu.execute()
    menu.startHide(trans)
    trans.execute()
Ejemplo n.º 10
0
def message(msg, context = None):
    'Displays a message to the player in a frame.'

    caption = gui.FrameDecorator(gui.StaticText())

    if isinstance(msg, str):
        # wrap such that the window is about three times as wide as it is tall.
        # (assume square characters because it doesn't have to be precise)
        charWidth = 3 * int(math.sqrt(len(msg) / 3))

        # max out at yres - caption.border * 2
        w = min(ika.Video.xres - caption.border * 2, charWidth * caption.font.width)
        msg = wrapText(msg, w, caption.font)

    caption.addText(*msg)

    caption.autoSize()
    caption.position = (
        (ika.Video.xres - caption.width) / 2,
        (ika.Video.yres - caption.height) / 2
        )

    draw = context and context.draw or ika.Map.Render

    trans = Transition()
    trans.addChild(caption, startRect=(caption.x, -caption.height))
    trans.execute(draw)

    while not controls.enter():
        draw()
        caption.draw()
        ika.Video.ShowPage()
        ika.Input.Update()

    trans.addChild(caption, endRect=(caption.x, ika.Video.yres))
    trans.execute(draw)
Ejemplo n.º 11
0
    def show(self, usebackground=False):
        # assume the backbuffer is already filled
        if not usebackground:
            self.images = effects.createBlurImages()
        TIME = 40

        self.update()

        t = Transition()
        t.addChild(self.statWnd,
                   startRect=(-self.statWnd.Right, self.statWnd.Top),
                   time=TIME - 5)
        t.addChild(self.attribWnd,
                   startRect=(-self.attribWnd.Right, self.attribWnd.Top),
                   time=TIME - 5)
        t.addChild(self.magWnd,
                   startRect=(ika.Video.xres, self.magWnd.Top),
                   time=TIME - 5)
        t.addChild(self.menu,
                   startRect=(ika.Video.xres, self.menu.Top),
                   time=TIME - 5)
        #t.addChild(self.inv, startRect=(ika.Video.xres, self.inv.Top), time=TIME - 5)
        t.addChild(self.timer,
                   startRect=(-self.timer.Right, self.timer.Top),
                   time=TIME - 5)
        t.addChild(self.mapname,
                   startRect=(ika.Video.xres, self.mapname.Top),
                   time=TIME - 5)
        for i in range(TIME):
            t.update(1)
            o = i * 128 / TIME  # tint intensity for this frame
            f = i * len(self.images) / TIME  # blur image to draw

            if not usebackground:
                ika.Video.ScaleBlit(self.images[f], 0, 0, ika.Video.xres,
                                    ika.Video.yres, ika.Opaque)
                ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                                   ika.RGB(0, 0, 0, o), True)
            else:
                ika.Video.ScaleBlit(self.background, 0, 0, ika.Video.xres,
                                    ika.Video.yres, ika.Opaque)
                ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                                   ika.RGB(0, 0, 0, 128), True)

            self.draw()
            ika.Video.ShowPage()
            ika.Input.Update()

        self.background = self.images[-1]
Ejemplo n.º 12
0
def selectCharacter(parent=None, caption='Use on whom?'):
    # A menu to select a character from the active roster.
    # TODO: maybe make this a bit more elaborate.
    caption = gui.FrameDecorator(gui.StaticText(text=caption))
    menu = gui.FrameDecorator(Menu())
    caption.autoSize()

    for char in stats.activeRoster:
        menu.addText(char.name)

    menu.autoSize()
    menu.width = max(menu.width, caption.width)
    caption.width = menu.width

    layout = VerticalBoxLayout(pad=8, children=[caption, menu])
    layout.layout()
    layout.position = ((ika.Video.xres - layout.width) / 2,
                       (ika.Video.yres - layout.height) / 2)

    menu.x += layout.x
    menu.y += layout.y
    caption.x += layout.x
    caption.y += layout.y

    draw = parent and parent.draw or ika.Map.Render

    trans = Transition()
    trans.addChild(caption, startRect=(caption.x, -caption.height))
    trans.addChild(menu, startRect=(menu.x, ika.Video.yres))
    trans.execute(draw)

    result = None
    while result is None:
        result = menu.update()

        draw()
        caption.draw()
        menu.draw()
        ika.Video.ShowPage()

    trans.addChild(caption, endRect=(caption.x, -caption.height))
    trans.addChild(menu, endRect=(menu.x, ika.Video.yres))
    trans.execute(draw)

    return result
Ejemplo n.º 13
0
def selectCharacter(parent = None, caption = 'Use on whom?'):
    # A menu to select a character from the active roster.
    # TODO: maybe make this a bit more elaborate.
    caption = gui.FrameDecorator(gui.StaticText(text=caption))
    menu = gui.FrameDecorator(Menu())
    caption.autoSize()

    for char in stats.activeRoster:
        menu.addText(char.name)

    menu.autoSize()
    menu.width = max(menu.width, caption.width)
    caption.width = menu.width

    layout = VerticalBoxLayout(pad=8, children=[caption, menu])
    layout.layout()
    layout.position = (
        (ika.Video.xres - layout.width) / 2,
        (ika.Video.yres - layout.height) / 2
        )

    menu.x += layout.x
    menu.y += layout.y
    caption.x += layout.x
    caption.y += layout.y

    draw = parent and parent.draw or ika.Map.Render

    trans = Transition()
    trans.addChild(caption, startRect=(caption.x, -caption.height))
    trans.addChild(menu, startRect=(menu.x, ika.Video.yres))
    trans.execute(draw)

    result = None
    while result is None:
        result = menu.update()

        draw()
        caption.draw()
        menu.draw()
        ika.Video.ShowPage()

    trans.addChild(caption, endRect=(caption.x, -caption.height))
    trans.addChild(menu, endRect=(menu.x, ika.Video.yres))
    trans.execute(draw)

    return result
Ejemplo n.º 14
0
def Shop(*args):
    menu = ShopMenu(*args)
    trans = Transition()
    menu.startShow(trans);   trans.execute()
    menu.execute()
    menu.startHide(trans);   trans.execute()
Ejemplo n.º 15
0
    def hide(self, usebackground=False):
        TIME = 40
        t = Transition()
        t.addChild(self.statWnd,
                   endRect=(-self.statWnd.Right, self.statWnd.Top),
                   time=TIME - 5)
        t.addChild(self.attribWnd,
                   endRect=(-self.attribWnd.Right, self.attribWnd.Top),
                   time=TIME - 5)
        t.addChild(self.magWnd,
                   endRect=(ika.Video.xres, self.magWnd.Top),
                   time=TIME - 5)
        t.addChild(self.menu,
                   endRect=(ika.Video.xres, self.menu.Top),
                   time=TIME - 5)
        #t.addChild(self.inv, endRect=(ika.Video.xres, self.inv.Top), time=TIME - 5)
        t.addChild(self.timer,
                   endRect=(-self.timer.Right, self.timer.Top),
                   time=TIME - 5)
        t.addChild(self.mapname,
                   endRect=(ika.Video.xres, self.mapname.Top),
                   time=TIME - 5)

        for i in range(TIME - 1, -1, -1):
            t.update(1)
            o = i * 255 / TIME  # menu opacity for this frame
            f = i * len(self.images) / TIME  # blur image to draw
            if not usebackground:
                ika.Video.ScaleBlit(self.images[f], 0, 0, ika.Video.xres,
                                    ika.Video.yres, ika.Opaque)
                ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                                   ika.RGB(0, 0, 0, o / 2), True)
                self.draw(o)
            else:
                ika.Video.ScaleBlit(self.background, 0, 0, ika.Video.xres,
                                    ika.Video.yres, ika.Opaque)
                ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                                   ika.RGB(0, 0, 0, 128), True)
                self.draw(255)

            ika.Video.ShowPage()
            ika.Input.Update()
Ejemplo n.º 16
0
    def runMenu(self, menu):
        # Save window positions, so we can put them back later.
        mainMenuPos = self.mainMenu.rect
        statBarPos = self.statbar.rect
        miscWndPos = self.miscwindow.rect

        t = Transition()
        menu.startShow(t)
        t.addChild(self.mainMenu,
                   endRect=(ika.Video.xres + 20, self.mainMenu.y))
        t.addChild(self.statbar,
                   endRect=(self.statbar.x,
                            -(self.statbar.height + self.statbar.border * 2)))
        t.addChild(self.miscwindow,
                   endRect=(self.miscwindow.x,
                            ika.Video.yres + self.miscwindow.border * 2))
        t.execute()

        result = menu.execute()

        menu.startHide(t)
        self.mainMenu.x = -self.mainMenu.width  # put the menu at stage left
        t.addChild(self.mainMenu,
                   endRect=mainMenuPos)  # restore the menu's position
        t.addChild(self.statbar, endRect=statBarPos)
        t.addChild(self.miscwindow, endRect=miscWndPos)
        t.execute()

        return result
Ejemplo n.º 17
0
def text(text, **kw):
    # gather arguments
    draw = kw.get('draw', ika.Map.Render)
    portrait = kw.get('portrait', None)
    caption = kw.get('caption', None)

    # create the text frame
    textbox = createTextBox(text, **kw)
    textbox.dockLeft().dockBottom()  # set the position

    # handle the portrait (if any)
    if portrait is not None:
        if isinstance(portrait, (str, ika.Canvas, ika.Image)):
            portrait = gui.Picture(image=portrait)
        elif portrait is not None and not isinstance(portrait, gui.Picture):
            assert False, 'portrait argument must be a string, Canvas, Image, Picture, or None'
        portrait.dockLeft().dockBottom(textbox)

    if caption is not None:
        caption = gui.FrameDecorator(gui.StaticText(text=caption))
        caption.autoSize()
        caption.dockRight().dockBottom(textbox)

    # Do the swoosh-in
    trans = Transition()
    trans.addChild(textbox, startRect=(textbox.x, ika.Video.yres))
    if portrait is not None:
        trans.addChild(portrait, startRect=(-portrait.width, portrait.y))
    if caption is not None:
        trans.addChild(caption, startRect=(ika.Video.xres, caption.y))
    trans.execute(draw)

    # unpress
    controls.enter()
    controls.joy_enter()
    controls.ui_accept()

    # Let the player read
    while not (controls.enter() or controls.joy_enter()
               or controls.ui_accept()):
        draw()
        trans.draw()

        ika.Video.ShowPage()
        ika.Input.Update()

    # swoosh-out
    trans.addChild(textbox, endRect=(textbox.x, ika.Video.yres))
    if portrait is not None:
        trans.addChild(portrait, endRect=(portrait.x, ika.Video.yres))
    if caption is not None:
        trans.addChild(caption, endRect=(ika.Video.xres, caption.y))
    trans.execute(draw)
Ejemplo n.º 18
0
    def runMenu(self, menu):
        # Save window positions, so we can put them back later.
        mainMenuPos = self.mainMenu.rect
        statBarPos = self.statbar.rect
        miscWndPos = self.miscwindow.rect

        t = Transition()
        menu.startShow(t)
        t.addChild(self.mainMenu, endRect=(ika.Video.xres + 20, self.mainMenu.y) )
        t.addChild(self.statbar, endRect=(self.statbar.x, -(self.statbar.height + self.statbar.border * 2)))
        t.addChild(self.miscwindow, endRect=(self.miscwindow.x, ika.Video.yres + self.miscwindow.border * 2))
        t.execute()

        result = menu.execute()

        menu.startHide(t)
        self.mainMenu.x = -self.mainMenu.width  # put the menu at stage left
        t.addChild(self.mainMenu, endRect=mainMenuPos)       # restore the menu's position
        t.addChild(self.statbar, endRect=statBarPos)
        t.addChild(self.miscwindow, endRect=miscWndPos)
        t.execute()

        return result