def __init__(self, window, batch, space, level, height, width): self.space = space self.level = level status_text = pyglet.text.decode_attributed(''' Time: 0 sec \n Points: 0 points \n FPS: 00.00 FPS ''') self.status_doc = Document(status_text, height=height, width=width) status_frame = Frame(self.status_doc) inv_text = pyglet.text.decode_html("<h4>Inventory</h4>") inventory_header = Document(inv_text, width=width) self.inventory_container = VerticalContainer([]) container = VerticalContainer( [inventory_header, self.inventory_container]) self.inventory_frame = Frame(container) container = VerticalContainer([status_frame, self.inventory_frame]) self.manager = Manager(container, window=window, batch=batch, group=RenderingOrder.hud, anchor=ANCHOR_TOP_RIGHT, theme=theme, is_movable=False) self.window = window self.window.push_handlers(on_draw=self.on_draw) self.tick = 0
def __init__(self, client, inventory): self.client = client invitems = [] for name, value in inventory.items(): title = value['title'] equipped = value['equipped'] icon = value['icon'] hit = value['hit'] dam = value['dam'] arm = value['arm'] invitems.append( Frame(InventoryItem(name, title, equipped, icon, self.client, hit, dam, arm), is_expandable=True)) self.close_button = OneTimeButton(label='Close', on_release=self.close) self.inventory_list = Scrollable(height=256, width=512, is_fixed_size=True, content=VerticalContainer( invitems, align=HALIGN_LEFT)) self.inventory_container = VerticalContainer( [self.inventory_list, self.close_button]) Manager.__init__(self, Frame(self.inventory_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True, anchor=ANCHOR_BOTTOM_RIGHT)
def __init__(self, client, inventory=[]): self.client = client invitems = [] for name, value in inventory.items(): title = value['title'] icon = value['icon'] dam = value['dam'] hit = value['hit'] arm = value['arm'] gold = value['value'] invitems.append( Frame(ContainerItem(name, title, icon, self.client, dam, hit, arm, gold), is_expandable=True)) self.container_inventory_list = Scrollable(height=256, width=512, is_fixed_size=True, content=VerticalContainer( invitems, align=HALIGN_LEFT)) self.exit_button = OneTimeButton(label='Close', on_release=self.close) self.inventory_container = HorizontalContainer( [self.container_inventory_list, self.exit_button]) Manager.__init__(self, Frame(self.inventory_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
class HoverWindow(Manager): def __init__(self, content, x, y): self.frame = Frame(content, path='frame_alternative') #print content.__dict__ #print "CONTENTHEIGHT",content.height #print content.__dict__ #frame.expand(content.width,content.label.content_height) #print content.__dict__ Manager.__init__(self, self.frame, window=g.screen, batch=g.guiBatch, is_movable=False, offset=(x, y), theme=g.theme, anchor=ANCHOR_BOTTOM_LEFT) #frame.layout() #try: # #print frame.content.label.content_height # frame.expand(frame._content.width,frame._content.height) # #print frame.content.label.content_height #except Exception, e: # print Exception, e, frame.content.__dict__ #print self._content[0]._content[0].label.content_height #frame.layout() #self.setPos(x-self.width/2,y) #g.selectWindowOpened=True def delete(self, event): g.hoveringType = None super(Manager, self).delete() #g.selectWindowOpened=False #g.cursorTarget=None def setPos(self, x, y): self.set_position(x, y) def updateContent(self, content): oldWidth = self.width oldX = self.x #if type==HOVERING_PING: # self._content[0]._content[0].set_text(text) self.frame.content.delete() self.frame._content[0] = content self.frame.content.set_manager(self) self.frame.content.parent = self.frame self.frame.content.load() self.frame.reset_size() self.frame.layout() self.setPos(oldX + (oldWidth - self.width) / 2, self.y)
def __init__(self, content, x, y): self.frame = Frame(content, path='frame_alternative') #print content.__dict__ #print "CONTENTHEIGHT",content.height #print content.__dict__ #frame.expand(content.width,content.label.content_height) #print content.__dict__ Manager.__init__(self, self.frame, window=g.screen, batch=g.guiBatch, is_movable=False, offset=(x, y), theme=g.theme, anchor=ANCHOR_BOTTOM_LEFT)
def __init__(self, closeButton=True): g.selectMeneWindowOpened = True self.currentMeneID = g.currMeneID self.selectMeneID = None self.meneCont = [] self.meneButtons = [] self.closeButton = closeButton self.constructMeneButtons() selectButton = HighlightedButton("Select Mene", on_release=self.selectMene, width=150, height=30) if closeButton: closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') cont = VerticalContainer(content=[ HorizontalContainer(content=[Spacer(0, 0), closeBtn]), HorizontalContainer(content=self.meneCont), Spacer(0, 10), selectButton ]) else: cont = VerticalContainer(content=[ HorizontalContainer(content=self.meneCont), Spacer(0, 10), selectButton ]) Manager.__init__(self, Frame(cont), window=g.screen, batch=g.guiBatch, is_movable=False, offset=(0, 0), theme=g.theme)
def __init__(self,name,text,a=0): if text[0]=='>': color=g.greentextColor else: color=g.postColor if a>0: if a==ADMIN_MODERATOR: nameColor=g.modColor appendix='#Mod#' elif a==ADMIN_ADMIN: nameColor=g.adminColor appendix='#Admin#' else: nameColor=g.adminColor appendix='#Owner#' else: nameColor=g.nameColor appendix='' if appendix: horz=HorizontalContainer(content=[Label(name,bold=True,color=nameColor),Label(appendix+':',color=nameColor),Label(text,color=color)]) else: horz=HorizontalContainer(content=[Label(name+':',bold=True,color=nameColor),Label(text,color=color)]) Manager.__init__(self, Frame(horz), window=g.screen, batch=g.chatBubbleBatch, anchor=ANCHOR_BOTTOM_LEFT, is_movable=False, offset=(0,0), theme=g.chatTheme)
def __init__(self, window, batch, space, level, height, width): self.space = space self.level = level self.height = height self.width = width progress_text = "Progress: ..." self.progress_doc = Document(progress_text, width=width / 2) objective_doc = Document(level.objective, width=width / 2) left_frame = Frame(VerticalContainer( [objective_doc, None, self.progress_doc]), is_expandable=True) self.left_container = VerticalContainer([left_frame]) victory_formula = level.victory_condition[0] info_frame = self.create_info_frame(victory_formula) self.info_container = VerticalContainer([info_frame]) container = HorizontalContainer( [self.left_container, self.info_container]) self.manager = Manager(container, window=window, batch=batch, group=RenderingOrder.hud, anchor=ANCHOR_BOTTOM_LEFT, theme=theme, is_movable=False) self.window = window self.window.push_handlers(on_draw=self.on_draw) self.tick = 0 self.init_effects(space, level)
def on_mouse_press(self, x, y, button, modifiers): if not self._is_loaded or not self._options or len(self._options) == 0: return """ A mouse press is going to create a manager with the options. """ # if it's already opened, we just close it. if self._pulldown_menu is not None: self._delete_pulldown_menu() return # the function we pass to the manager. def on_escape(_): self._delete_pulldown_menu() width, height = self._manager.window.get_size() x = self.x y = -(height - self.y - 1) + self.height # we set the manager self._pulldown_menu = Manager(Frame(Scrollable(VerticalContainer( list(self._options.values())), height=self.max_height), path=['dropdown', 'pulldown']), window=self._manager.window, batch=self._manager.batch, group=self._manager.root_group.parent, theme=self._manager.theme, is_movable=False, anchor=ANCHOR_TOP_LEFT, offset=(x, y))
def create_folding_description(window, batch, heading, description, chapters=list()): """ window - window batch - batch heading - heading of the widget description - description for the widget chapters - list of tuples (heading,text) """ description_doc = pyglet.text.decode_attributed(description) layout = list() layout.append(SectionHeader(heading)) layout.append(Document(description_doc, width=300)) for chapter in chapters: heading, text = chapter text_doc = pyglet.text.decode_attributed(text) layout.append(FoldingSection(heading, Document(text_doc, width=300), is_open=False)) content = Frame(Scrollable(VerticalContainer(layout, align=HALIGN_LEFT),height=400)) Manager(content, window=window, batch=batch, group=RenderingOrder.gui, anchor=ANCHOR_BOTTOM_RIGHT, theme=theme, is_movable=False)
def __init__(self, title, content=None, x=0, y=0, type=0): g.selectedWindowOpened = True cont = [] self.type = type cont.append(Label(title, color=g.loginFontColor)) for c in content: cont.append( HighlightedButton(c["text"], on_release=c["function"], width=120, height=24, path='empty', argument=c["argument"], align=HALIGN_LEFT)) frame = Frame(VerticalContainer(content=cont, padding=0, align=HALIGN_LEFT), path='frame_alternative') Manager.__init__(self, frame, window=g.screen, batch=g.selectWindowBatch, is_movable=False, offset=(0, 0), theme=g.theme) self.set_position(x, y - self.height)
def __init__(self): quitButton = Button(label="Exit Game",on_press=self.quitGame) closeButton = Button(label="Return",on_press=self.close) Manager.__init__(self, Frame(VerticalContainer(content=[quitButton,closeButton])), window=g.gameEngine.window, batch=g.guiBatch, theme=g.theme, is_movable=False)
def __init__(self): g.postWindowOpened = True label1 = Label("Notifications", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') self.postCont = [] #self.menes = [{"name":"Hitler","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'americanbear'},{"name":"Stalin","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'lorslara'},{"name":"Ebin","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'squadlider'},{"name":"Mao","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'mongolbear'},{"name":"Uusi mene","hp":100,"level":1,"power":50,"defense":40,"speed":60,"sprite":'mongol'},{"name":"Hintti","hp":50,"level":15,"power":60,"defense":50,"speed":70,'sprite':'uusimene'}] #self.selectedMene=self.menes[0]["name"] for c in g.mails: label = Label(c["s"], bold=True, color=g.guiNameColor, font_size=g.theme["font_size"] + 2) label1 = Label(c["t"][:16] + '...', color=g.whiteColor) deleteBtn = HighlightedButton("", on_release=self.deletemail, width=14, height=14, path='delete_alt', argument=c["id"]) openBtn = HighlightedButton("", on_release=self.openmail, width=20, height=21, path='mailopen', argument=c["id"]) self.postCont.append( VerticalContainer(content=[ HorizontalContainer(content=[openBtn, label, deleteBtn]), label1 ], align=HALIGN_LEFT)) self.vertCont = VerticalContainer(self.postCont, align=VALIGN_TOP) self.report = Document("", is_fixed_size=True, height=g.SCREEN_HEIGHT / 2, width=g.SCREEN_WIDTH / 5) self.scrollable = Scrollable(content=self.vertCont, height=g.SCREEN_HEIGHT / 2, width=g.SCREEN_WIDTH / 5) total = HorizontalContainer( content=[self.scrollable, self.report, closeBtn], align=VALIGN_TOP) Manager.__init__( self, Frame(total), window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme) if len(self.postCont) > 0: self.openmail(self.postCont[0]._content[0]._content[0].arg)
def __init__(self): g.reportWindowOpened = True getReport() label1 = Label("Send Ticket", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') horzCont = HorizontalContainer(content=[label1, None, closeBtn]) #self.infoLabel = Label("No reports founds") self.reportInput = TextInput(text="", padding=5, length=16, max_length=400, width=g.SCREEN_WIDTH / 3, height=g.SCREEN_HEIGHT / 3, multiline=True) clearBtn = HighlightedButton("Clear", on_release=self.clear, width=120, height=30) deleteBtn = HighlightedButton("Delete", on_release=self.remove, width=120, height=30) sendBtn = HighlightedButton("Send", on_release=self.send, width=120, height=30) buttons = HorizontalContainer(content=[clearBtn, deleteBtn, sendBtn]) frame = Frame( VerticalContainer(content=[horzCont, self.reportInput, buttons])) Manager.__init__(self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, theme=g.theme) frame.expand(g.SCREEN_WIDTH / 2, height=g.SCREEN_HEIGHT / 4 * 3)
def create_info_frame(self, formula): cml = CachedCml.getMolecule(formula) info_text = pyglet.text.decode_html( "<b>%s</b><br> %s" % (cml.property.get("Name", "Undefined"), cml.property.get("Description", "No Description Available"))) info_doc = Document(info_text, height=self.height, width=self.width / 2, is_fixed_size=True) info_frame = Frame(info_doc) return info_frame
def __init__(self, client): self.client = client self.login_button = OneTimeButton(label="Login", on_release=self.login) self.username_field = TextInput("") self.password_field = TextInput("") self.login_container = VerticalContainer( [self.login_button, self.username_field, self.password_field]) Manager.__init__(self, Frame(self.login_container), window=self.client.window, theme=UI_THEME)
def __init__(self): g.ignoreWindowOpened = True label1 = Label("Ignore List", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') title = [label1, None, closeBtn] ignores = [] for c in ignoreList: ignores.append(c) ignores.sort() ignoreCont = [] for c in ignores: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.guiNameColor) ignoreCont.append(label) #label=Label(c,bold=True,color=g.nameColorLighter) #removeBtn = HighlightedButton("",on_release=self.removeIgnore,width=24,height=24,path='ignoreremove',argument=c) #ignoreCont.append(HorizontalContainer(content=[label,removeBtn])) addBtn = HighlightedButton("Ignore Player", on_release=addIgnorePopup, width=100, height=24) horzCont = HorizontalContainer(content=title) frame = Frame( VerticalContainer(content=[ horzCont, Scrollable(height=400, width=400, content=VerticalContainer(content=ignoreCont, align=HALIGN_LEFT, padding=0)), addBtn ])) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def __init__(self): gameSettingsButton = HighlightedButton(label="Game Settings",on_release=self.gameSettings,width=120,height=30) settingsButton = HighlightedButton(label="Video Settings",on_release=self.settings,width=120,height=30) keybindingsButton = HighlightedButton(label="Keybindings",on_release=self.keybindings,width=120,height=30) helpButton = HighlightedButton(label="Help",on_release=self.help,width=120,height=30) disconnectButton = HighlightedButton(label="Disconnect",on_release=self.disconnect,width=120,height=30) closeButton = HighlightedButton(label="Close",on_release=self.delete,width=120,height=30) quitButton = HighlightedButton(label="Quit",on_release=self.onQuit,width=120,height=30) Manager.__init__(self, Frame(VerticalContainer(content=[gameSettingsButton,settingsButton,keybindingsButton,helpButton,disconnectButton,quitButton,Spacer(0,20),closeButton])), window=g.screen, batch=g.guiBatch, is_movable=False, theme=g.theme)
def __init__(self, client): self.client = client self.connect_button = OneTimeButton(label="Connect", on_release=self.connect) self.server_field = TextInput("localhost") self.port_field = TextInput("10000") self.connect_container = VerticalContainer( [self.connect_button, self.server_field, self.port_field]) Manager.__init__(self, Frame(self.connect_container, path='connectFrame'), window=self.client.window, theme=UI_THEME)
def initNameMene(self): def sendMeneName(event): self.menename = self.nameInput.get_text() if len(self.menename) > 0: self.saveBtn.disabled = True self.naming = True label = Label("Name Your Mene", color=g.postColor, font_size=18, bold=True) #meneTheme = Theme({g.spriteName: { # "image": { # "source": g.spriteName+'_front.png' # }, # "gui_color": [255,255,255,255] # } # },resources_path=g.dataPath+'/menes/' #) #picture = Graphic(g.spriteName,alternative=meneTheme) picture = Graphic( texture=g.gameEngine.resManager.meneSprites[g.spriteName]['front']) self.nameInput = TextInput(text="", padding=2, length=12, max_length=12, width=200, font_size=16) self.saveBtn = HighlightedButton(label="Save", on_release=sendMeneName, width=100, height=40, font_size=16) frame = Frame(VerticalContainer(content=[ label, picture, HorizontalContainer([self.nameInput, self.saveBtn]) ]), path='frame_npc_talk') self.meneMan = Manager(frame, window=self.screen, batch=g.guiBatch, theme=g.theme, offset=(0, 0), is_movable=False)
def manager(self): Manager(Label(""), window=self, batch=self.batch, theme=getTheme()) Manager(Frame(self.document), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_TOP_RIGHT, offset=(-10, -75), is_movable=False) Manager(HorizontalContainer([ OneTimeButton(label="Guardar", on_release=self.saveGame), OneTimeButton(label="Volver", on_release=self.onclose) ]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_BOTTOM_RIGHT, offset=(-50, 15), is_movable=False) self.document.set_text("")
def __init__(self, client): self.client = client self.message_container = VerticalContainer(content=[], align=HALIGN_LEFT) self.messages = Scrollable(height=100, width=300, is_fixed_size=True, content=self.message_container) self.text_input = TextInput("", length=20, max_length=256) self.send_button = OneTimeButton("Send", on_release=self.submit_message) self.enter_field = HorizontalContainer( [self.text_input, self.send_button]) self.chat_window = VerticalContainer([self.messages, self.enter_field]) Manager.__init__(self, Frame(self.chat_window, path='chatFrame'), window=self.client.window, theme=UI_THEME, is_movable=True, anchor=ANCHOR_BOTTOM_LEFT)
def on_mouse_press(self, x, y, button, modifiers): """ A mouse press is going to create a manager with the options. """ # if it's already opened, we just close it. if self._pulldown_menu is not None: self._delete_pulldown_menu() return # the function we pass to the manager. def on_escape(_): self._delete_pulldown_menu() # Compute the anchor point and location for the manager width, height = self._manager.window.get_size() if self.align == VALIGN_TOP: # Dropdown is at the top, pulldown appears below it anchor = ANCHOR_TOP_LEFT x = self.x y = -(height - self.y - 1) else: # Dropdown is at the bottom, pulldown appears above it anchor = ANCHOR_BOTTOM_LEFT x = self.x y = self.y + self.height + 1 # we set the manager self._pulldown_menu = Manager(Frame(Scrollable(VerticalContainer( list(self._options.values())), height=self.max_height, fs=len(self._options)), path=['dropdown', 'pulldown']), window=self._manager.window, batch=self._manager.batch, group=self._manager.root_group.parent, theme=self._manager.theme, is_movable=False, anchor=anchor, offset=(x, y))
def __init__(self, client, name, title, dialog): self.client = client self.name = name title = Label(title, font_size=12) dialog = pyglet.text.decode_text(dialog) document = Document(dialog, width=300, height=100) accept_button = OneTimeButton(label="Ok, I'll do it!", on_release=self.accept) reject_button = OneTimeButton(label="No, Thanks.", on_release=self.reject) text_container = VerticalContainer([title, document]) button_container = HorizontalContainer([accept_button, reject_button]) quest_container = VerticalContainer([text_container, button_container]) Manager.__init__(self, Frame(quest_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self, client, quests): self.client = client quest_list = [] for quest in quests: quest_title = Label(quest['title']) quest_container = HorizontalContainer([quest_title]) quest_list.append(quest_container) close_button = OneTimeButton(label="Close", on_release=self.close) quest_container = VerticalContainer(quest_list) button_container = HorizontalContainer([close_button]) questlog_container = VerticalContainer( [quest_container, button_container]) Manager.__init__(self, Frame(questlog_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self): g.adminWindowOpened = True label1=Label("Admin Menu",bold=True,color=g.loginFontColor) closeBtn = closeBtn =HighlightedButton("",on_release=self.delete,width=19,height=19,path='delete') adminSayBtn=HighlightedButton("Admin say",on_release=self.adminSay,width=120,height=25) muteBtn=HighlightedButton("Mute player",on_release=self.mutePlayer,width=120,height=25) unmuteBtn=HighlightedButton("Unmute player",on_release=self.unmutePlayer,width=120,height=25) teleportBtn=HighlightedButton("Teleport player",on_release=self.teleportPlayer,width=120,height=25) banBtn=HighlightedButton("Ban player",on_release=self.banPlayer,width=120,height=25) unbanBtn=HighlightedButton("Unban player",on_release=self.unbanPlayer,width=120,height=25) reportBtn=HighlightedButton("Reports",on_release=self.reports,width=120,height=25) #addBtn = HighlightedButton("",on_release=self.addFriend,width=24,height=24,path='friendadd') horzCont = HorizontalContainer(content=[label1,closeBtn]) frame = Frame(VerticalContainer(content=[horzCont,adminSayBtn,muteBtn,unmuteBtn,teleportBtn,banBtn,unbanBtn,reportBtn])) Manager.__init__(self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40,int(g.SCREEN_HEIGHT*g.WINDOW_POSY_RELATIVE)), theme=g.theme)
def __init__(self): g.keybindingsWindowOpened = True self.resW = g.SCREEN_WIDTH self.resH = g.SCREEN_HEIGHT self.fullscreen = g.FULLSCREEN self.vsync = g.VSYNC self.screenSelected = g.SCREENSELECTED screens = pyglet.window.get_platform().get_default_display( ).get_screens() screenopts = [] for i in range(len(screens)): screenopts.append(str(i)) if int(self.screenSelected) >= 0 and int( self.screenSelected) < len(screens): screenopts.insert(0, str(self.screenSelected)) options = [] modes = pyglet.window.get_platform().get_default_display( ).get_default_screen().get_modes() for i in modes: if i.width >= 1024 and i.height >= 720: opt = str(int(i.width)) + ':' + str(int(i.height)) if opt not in options: options.append(opt) options.insert(0, str(g.SCREEN_WIDTH) + ':' + str(g.SCREEN_HEIGHT)) titleText = Label("Video Settings", color=g.loginFontColor, font_size=g.theme["font_size"] + 2) windowTypeInfo = Label("Window mode") if g.FULLSCREEN: windowType = Dropdown(['Fullscreen', 'Windowed'], on_select=self.selection) else: windowType = Dropdown(['Windowed', 'Fullscreen'], on_select=self.selection) horz = HorizontalContainer([windowTypeInfo, windowType]) resolutionInfo = Label("Resolution") resolutionType = Dropdown(options, on_select=self.resSelect) horz1 = HorizontalContainer([resolutionInfo, resolutionType]) vsyncBtn = Checkbox("VSync", on_press=self.vsyncSelect, is_pressed=self.vsync, align=HALIGN_LEFT) resolutionInfo = Label("Monitor") resolutionType = Dropdown(screenopts, on_select=self.screenSelect) horz3 = HorizontalContainer([resolutionInfo, resolutionType]) discardBtn = HighlightedButton(label="Discard", on_release=self.delete, width=120, height=30) saveBtn = HighlightedButton(label="Save", on_release=self.onSave, width=120, height=30) horzBtn = HorizontalContainer([discardBtn, saveBtn]) Manager.__init__(self, Frame( VerticalContainer([ titleText, horz, horz1, vsyncBtn, horz3, horzBtn ])), window=g.screen, batch=g.guiBatch, theme=g.theme, is_movable=False)
def __init__(self, name, text, actionType=0): g.npcTalkWindowOpened = True g.cursorRound = -1 self.name = name sendTalkToNpc(name) if actionType == NPC_ACTIONTYPE_SHOP: namecolor = g.npcColor postcolor = g.whiteColor path = 'frame_npc_talk_shop' else: namecolor = g.npcColorLighter postcolor = g.postColor path = 'frame_npc_talk' label1 = Label(name, color=namecolor, bold=True) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') horzCont = HorizontalContainer(content=[label1, None, closeBtn]) self.yourmoney = None w1 = int(300 * (g.SCREEN_WIDTH / 1920.)) + 50 h1 = int(500 * (g.SCREEN_HEIGHT / 1080.)) textArr = text.split('\n\n') realText = "" for c in textArr: if c[0] == '>': realText += '{color ' + str( g.greentextColor) + '}' + c + '\n\n' else: realText += '{color ' + str(postcolor) + '}' + c + '\n\n' realText = realText[:-2] document = pyglet.text.decode_attributed(realText) self.textArea = Document(document, width=w1, height=h1, background=False, font_size=g.chatTheme["font_size"], font_name=g.chatTheme["font"]) if actionType == NPC_ACTIONTYPE_HEAL: healButton = HighlightedButton("Heal my menes", on_release=self.healButton) okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer(content=[ horzCont, self.textArea, HorizontalContainer([healButton, okButton]) ]) elif actionType == NPC_ACTIONTYPE_SHOP: #TODO: When more items, do a loop that adds then dynamically instead of statically like this disabled = False if Items["es"]["cost"] > g.moneyAmount: # print "TAPAHTU" disabled = True self.esButton = AbilityButton( width=50, height=50, argument=Items["es"]["id"], disabled=disabled, on_press=buyItem, texture=g.gameEngine.resManager.items[Items["es"]["sprite"]], outline='abilityoutline', hover=onHover, hoveringType=HOVERING_ITEM, arguments={ 'name': Items["es"]["name"], 'info': Items["es"]["info"], "args": () }) nameLabel = Label(Items["es"]["name"], color=g.npcColor) esCost = Items["es"]["cost"] / 100.0 costLabel = Label("%.2f" % esCost) euroPicture = Graphic("euro") costCont = HorizontalContainer(content=[costLabel, euroPicture]) infoCont = VerticalContainer( content=[Spacer(), nameLabel, costCont], align=HALIGN_LEFT) itemCont = HorizontalContainer(content=[self.esButton, infoCont]) moneyTmp = g.moneyAmount / 100.0 self.yourmoney = Label('%.2f' % moneyTmp) yourmoneyCont = HorizontalContainer( content=[self.yourmoney, Graphic("euro")]) self.yourES = Label('%s' % g.esAmount) yourESCont = HorizontalContainer( content=[self.yourES, Graphic("es_icon")]) okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer(content=[ horzCont, self.textArea, itemCont, Spacer(0, 20), HorizontalContainer(content=[ Spacer(), VerticalContainer(content=[yourmoneyCont, yourESCont], align=HALIGN_RIGHT) ]), okButton ]) else: okButton = HighlightedButton("Goodbye", on_release=self.delete) cont = VerticalContainer( content=[horzCont, self.textArea, okButton]) frame = Frame(cont, path=path) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)
"frame": { "image": { "source": "panel.png", "frame": [8, 8, 16, 16], "padding": [16, 16, 8, 8] } } }, resources_path='../theme/') content = Frame( Scrollable(VerticalContainer([ SectionHeader("Folding"), Document("Click on the section headers below to open them.", width=300), FoldingSection("Folding 1", Document("This is the first folding.", width=300)), FoldingSection("Folding 2", Document("This is the second folding.", width=300), is_open=False), FoldingSection("Folding 3", Document("This is the third folding.", width=300), is_open=False), ], align=HALIGN_LEFT), height=400)) Manager(content, window=window, batch=batch, anchor=ANCHOR_CENTER, theme=theme) pyglet.app.run()
def __init__(self): g.friendWindowOpened = True label1 = Label("Friends List", bold=True, color=g.loginFontColor) closeBtn = HighlightedButton("", on_release=self.delete, width=19, height=19, path='delete') onlineFriends = [] offlineFriends = [] for c in friendList: if c[1] == 1: onlineFriends.append(c[0]) else: offlineFriends.append(c[0]) onlineFriends.sort() offlineFriends.sort() friends = [] for c in onlineFriends: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.loginFontColor) friends.append(label) for c in offlineFriends: label = HighlightedButton(c, width=150, height=24, path='baroutline_btn', on_release=self.constructSelect, argument=c, align=HALIGN_LEFT, font_color=g.npcColorLighter) friends.append(label) addBtn = HighlightedButton("Add Friend", on_release=addFriendPopup, width=100, height=24) horzCont = HorizontalContainer(content=[label1, None, closeBtn]) frame = Frame( VerticalContainer(content=[ horzCont, Scrollable(height=400, width=400, content=VerticalContainer(content=friends, align=HALIGN_LEFT, padding=0)), addBtn ])) Manager.__init__( self, frame, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(40, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE)), theme=g.theme)