def createContents(self): #txt = [gui.StaticText(text=''), gui.StaticText(text='Inventory') ] txt = [gui.StaticText(text=''), gui.StaticText(text=' Items')] tnt = 0 strengthrunes = 0 magicrunes = 0 for k in savedata.__dict__.keys(): if k.startswith('dynamite') and savedata.__dict__[k] == 'True': tnt += 1 if k.startswith('strength') and savedata.__dict__[k] == 'True': strengthrunes += 1 if tnt: txt += [self.icons['tnt'], gui.StaticText(text=' - %i' % tnt)] if strengthrunes: txt += [ self.icons['strength'], gui.StaticText(text=' - %i' % strengthrunes) ] #else: # txt += [gui.StaticText(text=''),gui.StaticText(text='')] return tuple(txt)
class ItemDescWindow(ShopWindow): def __init__(self, *args, **kw): super(ItemDescWindow, self).__init__(*args, **kw) self.item = None def createContents(self): if self.item: price = self.item.totalPrice if price <= engine.player.stats.money: yellow = "#[FF00FFFF]" white = "#[FFFFFFFF]" red = "#[FFAAAAFF]" blue = "#[FFFFAAAA]" gold = "#[FFAAFFFF]" green = "#[FFAAFFAA]" else: yellow = white = red = blue = gold = green = "#[FFAAAAAA]" attribsLabel = gui.ColumnedTextLabel(columns=3, pad=10) attribsLabel.addText('%sBase' % red, "%s..." % white, "%s%i" % (gold, self.item.price)) [ attribsLabel.addText('%s%s' % (blue, ` a `), "%s..." % white, "%s%i" % (white, a.price)) for a in self.item.attribs ] attribsLabel.addText('%sTotal' % gold, "%s..." % gold, "%s%i" % (gold, price)) attribsLabel.autoSize() dormantLabel = gui.ColumnedTextLabel(columns=3, pad=10) if self.item.dormant: [ dormantLabel.addText('%s%s' % (green, ` a `), "%s..." % green, "%s%i" % (green, a.price)) for a in self.item.dormant ] else: dormantLabel.addText('None', '', '') dormantLabel.autoSize() descText = wrapText(self.item.desc, self.width, gui.default_font) for i in range(len(descText)): descText[i] = '%s%s' % (white, descText[i]) return [ gui.StaticText(text='%s%s' % (yellow, self.item.name)), gui.ScrollableTextLabel(text=descText), gui.StaticText(text=''), attribsLabel, gui.StaticText(text=''), gui.StaticText(text='%sDormant Attributes:' % green), dormantLabel, ]
def update(self, icons): if self.save: stats = self.save.stats self.layout.setChildren([ layout.HorizontalBoxLayout( gui.StaticText(text='HP%03i/%03i' % (stats.hp, stats.maxhp)), layout.Spacer(width=16), gui.StaticText(text='Lv. %02i' % stats.level) ), layout.FlexGridLayout(cols=4, children = ( gui.StaticText(text='Anastasia'), layout.Spacer(), layout.Spacer(), gui.StaticText(text='Lv %02i' % stats.level), gui.StaticText(text='Att:%02i ' % stats.att), gui.StaticText(text='Mag:%02i ' % stats.mag), gui.StaticText(text='Def:%02i ' % stats.pres), gui.StaticText(text='Res:%02i ' % stats.mres) ) ) ]) self.layout.layout() self.autoSize() else: raise Exception
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)
def __init__(self, x=0, y=0, width=0, height=0, *args, **kwargs): super(TextFrame, self).__init__(x, y, width, height, *args, **kwargs) # way cool. since keyword arguments are passed on, the font will be # set properly. additionally, text will be added just like StaticText. # Consistency totally rules. self.__text = gui.StaticText(0, 0, width, height, *args, **kwargs) self.addChild(self.__text) self.autoSize()
def createContents(self): stats = system.engine.player.stats tnt = 0 for k in savedata.__dict__.keys(): if k.startswith('dynamite') and savedata.__dict__[k] == 'True': tnt += 1 return ( #gui.StaticText(text='Stats:'),gui.StaticText(text=''), self.icons['att'], gui.StaticText(text=' - %02i' % stats.att), self.icons['mag'], gui.StaticText(text=' - %02i' % stats.mag), self.icons['pres'], gui.StaticText(text=' - %02i' % stats.pres), self.icons['tnt'], gui.StaticText(text=' - %02i' % tnt))
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=['', '']))
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
def update(self, icons): if self.save: stats = self.save.stats m='' #if debug: m+=self.save.fname if self.save.mapName in automapdata: m+=automapdata[self.save.mapName][5] c = [] if debug: c += [ layout.HorizontalBoxLayout( gui.StaticText(text=self.save.fname[6:])) ] #using [6:] to remove saves/ from the text c += [ layout.HorizontalBoxLayout( gui.StaticText(text=m), ), layout.HorizontalBoxLayout( gui.StaticText(text='HP. %03i/%03i' % (stats.hp, stats.maxhp)), layout.Spacer(width=16), gui.StaticText(text='Lv. %02i' % stats.level) ), layout.FlexGridLayout(5, icons['att'], gui.StaticText(text='%02i ' % stats.att), icons['mag'], gui.StaticText(text='%02i ' % stats.mag), gui.StaticText(text=' Time'), icons['pres'], gui.StaticText(text='%02i ' % stats.pres), icons['tnt'], gui.StaticText(text='% i ' % stats.tnt), gui.StaticText(text=' '+self.save.time) ) ] self.layout.setChildren(c) self.layout.layout() self.autoSize() self.width = 140 #hack! Don't want windows autosized.. else: assert False
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=['','']))
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)
def createContents(self): stats = system.engine.player.stats return ( gui.StaticText(text='Level %02i' % stats.level), gui.StaticText(text='Exp'), gui.StaticText(text=' %05i/' % stats.exp), gui.StaticText(text=' %05i' % stats.next), # expbar thingie goes here gui.StaticText(text='HP'), gui.StaticText(text=' %03i/%03i' % (stats.hp, stats.maxhp)), # hp bar gui.StaticText(text='MP'), gui.StaticText(text=' %03i/%03i' % (stats.mp, stats.maxmp)), # mp bar )
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('')
def refresh(self, char): self.client.removeAllChildren() portrait = gui.Picture(image=char.portrait) text = gui.StaticText(text=[ char.name, 'Lv %i' % char.level, 'HP\t%i/%i' % (char.hp, char.maxHP), 'MP\t%i/%i' % (char.mp, char.maxMP), ]) t2 = gui.StaticText(text=[ 'Exp\t%i' % char.stats.exp, 'Next\t%i' % (char.expneeded - char.stats.exp) ]) portrait.position = (0, 0) text.position = (portrait.right, 0) t2.position = (0, portrait.bottom + 2) self.client.addChildren(portrait, text, t2) text.autoSize() t2.autoSize() self.autoSize()
def createContents(self): txt = ['Magic:'] p = system.engine.player.stats if p.heal: txt.append('Healing Rain') #txt.append('') if p.rend: txt.append('Hearth Rend') #txt.append('') if p.gale: txt.append('Crushing Gale') #txt.append('') if p.bolt: txt.append('Bolt Storm') #txt.append('') return (gui.StaticText(text=txt), )
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
def createDescriptionBar(self): return gui.FrameDecorator(gui.StaticText(text=['', '']))
def createContents(self): self.text = gui.StaticText(text=` self.amount `) return [gui.Picture(image="gfx/items/icon_seashell.png"), self.text]
def createContents(self): txt = ['Time: ' + system.engine.time] return (gui.StaticText(text=txt), )
[ attribsLabel.addText('%s%s' % (blue, ` a `), "%s..." % white, "%s%i" % (white, a.price)) for a in self.item.attribs ] [ attribsLabel.addText('%s%s' % (blue, ` a `), "%s..." % white, "%s%i" % (white, a.price)) for a in self.menu.adding ] attribsLabel.addText('%sTotal' % gold, "%s..." % gold, "%s%i" % (gold, price)) attribsLabel.autoSize() return [ gui.StaticText(text='%s%s' % (yellow, self.item.name)), gui.StaticText(text=''), attribsLabel, gui.StaticText(text=''), gui.StaticText(text='%sDormant Attributes:' % green), self.menu, ] else: return [] class MoneyWindow(ShopWindow): def __init__(self): super(MoneyWindow, self).__init__() self.amount = engine.player.stats.money
def createContents(self): txt = [automap.automapdata[system.engine.mapName][5]] return (gui.StaticText(text=txt), )