예제 #1
0
    def __init__(self):
        self.skillWindow = SkillWindow()
        self.menu = gui.FrameDecorator(Menu(textctrl=self.skillWindow))
        self.portraitWindow = PortraitWindow()
        self.statWindow = gui.FrameDecorator(StatusWindow())
        self.charidx = 0

        self.description = gui.FrameDecorator(gui.StaticText(text=['', '']))
예제 #2
0
 def __init__(self):
     self.equipWindow = EquipWindow()
     self.portraitWindow = PortraitWindow()
     self.statWindow = gui.FrameDecorator(StatPreviewWindow())
     self.itemList = InventoryWindow(stats.inventory)
     self.equipMenu = gui.FrameDecorator(Menu(textctrl=self.equipWindow))
     self.itemMenu = gui.FrameDecorator(Menu(textctrl=self.itemList))
     self.charIdx = 0
     self.slotIdx = 0
     self.itemMenu.cursor = _nullCursor
     self.state = self.updateEquipWindow
     self.description = gui.FrameDecorator(gui.StaticText(text=['','']))
예제 #3
0
    def __init__(self, *args):
        self.inv = item.Inventory()
        for iter in args:
            self.inv.give(iter)

        self.itemList = common.ShopWindow(self.inv)
        self.menu = gui.FrameDecorator(menu.Menu(textctrl=self.itemList))
        self.shopbar = gui.FrameDecorator(common.ShopEquipBar())
        self.shopbar.refresh()

        self.description = gui.FrameDecorator(gui.StaticText(text=['', '']))
        self.description.autoSize()
        self.money = gui.FrameDecorator(common.MiscWindow())
        self.money.autoSize()
        self.setDescription('')
예제 #4
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)
예제 #5
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
예제 #6
0
    def __init__(self):
        StatelessProxy.__init__(self)
        if len(self.__dict__) != 0:
            return
        # "static constructor" logic follows

        mm = self.mainMenu = gui.FrameDecorator(Menu())

        self.statbar = gui.FrameDecorator(StatusBar())
        self.statbar.refresh()
        self.statbar.dockRight().dockTop()
        self.miscwindow = gui.FrameDecorator(MiscWindow())
        self.miscwindow.refresh()
        self.miscwindow.dockRight().dockBottom()

        self.setMenuItems(self.createMenuItems())

        mm.autoSize()
        mm.dockTop().dockLeft()
예제 #7
0
def createTextBox(text, **kw):
    wnd = kw.get('wnd', gui.default_window)
    font = kw.get('font', gui.default_font)
    wrap = kw.get('wrap', wordWrap)
    textbox = gui.FrameDecorator(gui.StaticText(wnd=wnd, font=font))
    textbox.addText(*wrap(text, ika.Video.xres -
                          textbox.border * 2, textbox.font))
    textbox.autoSize()  # set the height
    textbox.width = ika.Video.xres - textbox.border * 2  # set the width

    return textbox
예제 #8
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)
예제 #9
0
 def __init__(self):
     self.portraitWindow = PortraitWindow()
     self.statWindow = gui.FrameDecorator(StatusWindow())
     self.equipWindow = gui.FrameDecorator(EquipWindow())
     self.skillWindow = gui.FrameDecorator(SkillWindow())
     self._curChar = 0
예제 #10
0
 def createDescriptionBar(self):
     return gui.FrameDecorator(gui.StaticText(text=['', '']))
예제 #11
0
 def __init__(self, statbar):
     self.statbar = statbar
     self.itemList = self.createInventoryWindow()
     self.menu = gui.FrameDecorator(Menu(textctrl=self.itemList))
     self.description = self.createDescriptionBar()