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)
def __init__(self, name, level, hp, maxhp): self.nameLabel = Label(name, color=g.whiteColor, font_size=g.theme["font_size"] + 2, bold=True) self.levelLabel = Label('Lvl: ' + str(level), color=g.whiteColor, font_size=g.theme["font_size"] + 2, bold=True) self.hpBar = HpBar() Manager.__init__( self, VerticalContainer(content=[ HorizontalContainer( content=[self.nameLabel, None, self.levelLabel]), self.hpBar ], align=HALIGN_LEFT), window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT, offset=(0, 0), theme=g.theme) self.hpBar.setHP(hp, maxhp)
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, 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, text="", ok="Ok", cancel="Cancel", window=None, batch=None, group=None, theme=None, on_ok=None, on_cancel=None): def on_ok_click(_): if on_ok is not None: on_ok(self) self.delete() def on_cancel_click(_): if on_cancel is not None: on_cancel(self) self.delete() Manager.__init__(self, content=Frame( VerticalContainer([ Label(text), HorizontalContainer([ Button(ok, on_press=on_ok_click), None, Button(cancel, on_press=on_cancel_click) ]) ])), window=window, batch=batch, group=group, theme=theme, is_movable=True)
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, ability1=None, ability2=None, ability3=None, ability4=None): self.a1 = ability1 self.a2 = ability2 self.a3 = ability3 self.a4 = ability4 #self.abilityCont=[] abilityButtons = [] for i in xrange(4): abilityButtons.append( Graphic(width=100, height=100, path='abilityoutline')) self.abilityCont = HorizontalContainer(content=abilityButtons, align=VALIGN_BOTTOM) Manager.__init__(self, self.abilityCont, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_BOTTOM, offset=(0, 0), theme=g.theme) self.constructAbilityButtons()
def __init__(self): g.partyWindowOpened = True #label1=Label("Friends List",bold=True,color=g.loginFontColor) #closeBtn =HighlightedButton("",on_release=self.delete,width=19,height=19,path='delete') party = [] for member in g.partyMembers: leader = None if member.access: leader = 'partyleader' party.append( PartyMemberButton(on_press=self.constructSelect, label=member.name, width=64, height=64, argument=member.name, texture=member.texture, outline='partymember', font_valign=VALIGN_BOTTOM, font=g.defaultFont.name, font_color=g.partyColor, font_size=10, leader=leader)) test = VerticalContainer(content=party) Manager.__init__(self, test, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_LEFT, offset=(g.SCREEN_WIDTH * 0.05, int(g.SCREEN_HEIGHT * g.WINDOW_POSY_RELATIVE * 1.3)), theme=g.theme)
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): newgameButton=Button(label="New Game", on_press=self.newGame) quitButton=Button(label="Quit Game", on_press=self.quitGame) Manager.__init__(self, VerticalContainer(content=[newgameButton,Spacer(0,20),quitButton]), 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): self.coinsText = Label("Coins: 0") Manager.__init__(self, self.coinsText, window=g.gameEngine.window, batch=g.guiBatch, theme=g.theme, is_movable=False, anchor=ANCHOR_TOP, offset=(0,-25))
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, text="", window=None, batch=None, group=None, theme=None, on_escape=None, have_focus=False): def on_ok(_): if on_escape is not None: on_escape(self) self.delete() button = FocusButton("Ok", on_press=on_ok) Manager.__init__(self, content=Frame(VerticalContainer( [Label(text), button])), window=window, batch=batch, group=group, theme=theme, is_movable=True) Manager.set_next_focus(self, 1)
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 __init__(self, text="", window=None, textcolor=None,batch=None, group=None, width=None, theme=None, on_escape=None, have_focus=False,font_size=None): def on_ok(_): if on_escape is not None: on_escape(self) self.delete() #button = FocusButton("Ok", on_press=on_ok) button=HighlightedButton("Ok",on_release=on_ok,height=35,width=80) Manager.__init__(self, content=Frame(VerticalContainer( [Label(text,color=textcolor,font_size=font_size,width=width,multiline=True), Spacer(min_height=5),button])), window=window, batch=batch, group=group, theme=theme, is_movable=True) Manager.set_next_focus(self, 1)
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): 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 __init__(self, text="", ok="Ok", cancel="Cancel", window=None, batch=None, group=None, theme=None, on_ok=None, on_cancel=None, argument=None,offset=(0,0)): self.arg=argument def on_ok_click(_): if on_ok is not None: on_ok(self.arg) self.delete() def on_cancel_click(_): if on_cancel is not None: on_cancel(self.arg) self.delete() Manager.__init__(self, content=Frame( VerticalContainer([ Label(text), HorizontalContainer([HighlightedButton(ok, on_release=on_ok_click), HighlightedButton(cancel, on_release=on_cancel_click)] )]) ), window=window, batch=batch, group=group, theme=theme, is_movable=True,offset=offset)
def __init__(self, text="", ok="Ok", cancel="Cancel", window=None, batch=None, group=None, theme=None, on_ok=None, on_cancel=None): def on_ok_click(_): if on_ok is not None: on_ok(self) self.delete() def on_cancel_click(_): if on_cancel is not None: on_cancel(self) self.delete() Manager.__init__(self, content=Frame( VerticalContainer([ Label(text), HorizontalContainer([Button(ok, on_press=on_ok_click), None, Button(cancel, on_press=on_cancel_click)] )]) ), window=window, batch=batch, group=group, theme=theme, is_movable=True)
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 __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, text="", window=None, batch=None, group=None, theme=None, on_escape=None, have_focus=False): def on_ok(_): if on_escape is not None: on_escape(self) self.delete() button = FocusButton("Ok", on_press=on_ok) Manager.__init__(self, content=Frame(VerticalContainer([Label(text), button])), window=window, batch=batch, group=group, theme=theme, is_movable=True) Manager.set_next_focus(self, 1)
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): friendBtn = HighlightedButton("", on_release=self.openFriends, width=32, height=32, path='btn_friendwindow') ignoreBtn = HighlightedButton("", on_release=self.openIgnores, width=32, height=32, path='btn_ignorewindow') #meneBtn = HighlightedButton("",on_release=self.openMenes,width=50,height=50,path='es') meneBtn = HighlightedButton("", on_release=self.openMenes, width=50, height=50, path='menes') fightBtn = HighlightedButton("", on_release=self.openMenes, width=50, height=50, path='es') if g.latencyType == PING_TYPE_GREEN: path = 'ping_green' elif g.latencyType == PING_TYPE_YELLOW: path = 'ping_yellow' else: path = 'ping_red' self.latencyBtn = HoverGraphic(width=15, height=32, path=path, hover=onHover, hoveringType=HOVERING_PING) guildBtn = HighlightedButton("", on_release=self.openGuild, width=32, height=32, path='guild') settingsBtn = HighlightedButton("", on_release=self.openSettings, width=32, height=32, path='settings') self.mailBtn = HighlightedButton("", on_release=self.openMail, width=32, height=32, path='mail') bagBtn = HoverGraphic(width=32, height=32, path='bag', hover=onHover, hoveringType=HOVERING_BAG, showHighlight=True) self.horzCont = HorizontalContainer(content=[ friendBtn, ignoreBtn, meneBtn, fightBtn, guildBtn, self.latencyBtn, settingsBtn, bagBtn ], align=VALIGN_BOTTOM) Manager.__init__(self, self.horzCont, window=g.screen, batch=g.guiBatch, is_movable=False, anchor=ANCHOR_BOTTOM, offset=(0, 20), theme=g.theme) if len(g.mails) > 0: self.addMail()
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)
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)
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)