예제 #1
0
 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)
예제 #2
0
    def __init__(self, client, inventory=[], player_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(ShopItem(name, title, icon, self.client, dam, hit, arm,
                               gold),
                      is_expandable=True))

        self.shop_inventory_list = Scrollable(height=256,
                                              width=512,
                                              is_fixed_size=True,
                                              content=VerticalContainer(
                                                  invitems, align=HALIGN_LEFT))

        player_invitems = []
        for name, value in player_inventory.items():
            title = value['title']
            icon = value['icon']
            dam = value['dam']
            hit = value['hit']
            arm = value['arm']
            player_invitems.append(
                Frame(PlayerShopItem(name, title, icon, self.client, dam, hit,
                                     arm),
                      is_expandable=True))

        self.player_inventory_list = Scrollable(height=256,
                                                width=512,
                                                is_fixed_size=True,
                                                content=VerticalContainer(
                                                    player_invitems,
                                                    align=HALIGN_LEFT))

        self.exit_button = OneTimeButton(label='Close', on_release=self.close)
        self.inventory_container = HorizontalContainer([
            self.shop_inventory_list, self.player_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)
예제 #3
0
    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))
예제 #4
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)
예제 #5
0
파일: Gui.py 프로젝트: Norberg/molecule
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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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))
예제 #9
0
        "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()
예제 #10
0
    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)
예제 #11
0
                    "region": [0, 16, 16, 16],
                    "frame": [0, 6, 16, 4],
                    "padding": [0, 0, 0, 0]
                },
                "offset": [0, 0]
            },
            "bar": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 64, 16, 16]
                },
                "padding": [0, 0, 0, 0]
            }
        }
    },
    resources_path='../theme/')

# Set up a Manager
Manager(
    # an horizontal layout with two vertical layouts, each one with a slider.
    Scrollable(
        height=100,
        width=200,
        content=VerticalContainer(content=[Button(str(x))
                                           for x in range(10)])),
    window=window,
    batch=batch,
    theme=theme)

pyglet.app.run()
예제 #12
0
class PostWindow(Manager):
    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)
        #self.changeInfos(self.selectedMene)
        #print str(int(time.time()*1000-t1)),"TIMEEE"

    def delete(self, event):
        super(Manager, self).delete()
        g.postWindowOpened = False

    def deletemail(self, event):
        deleteMail(event)
        for c in self.postCont:
            if c._content[0]._content[0].arg == event:
                self.vertCont.remove(c)
                self.postCont.remove(c)
                for d in g.mails:
                    if d["id"] == event:
                        g.mails.remove(d)
        if len(self.postCont) > 0:
            self.openmail(self.postCont[0]._content[0]._content[0].arg)
            self.scrollable.reset_size()
        else:
            self.delete(None)
            g.gameEngine.graphics.normalUI.removeMail()

    def openmail(self, event):
        text = ''
        for c in g.mails:
            if c["id"] == event:
                text = c["t"] + '\n\nt. ' + c["s"]
        self.report.set_text(text)
예제 #13
0
    def __init__(self):
        g.guildWindowOpened = True
        closeBtn = HighlightedButton("",
                                     on_release=self.delete,
                                     width=19,
                                     height=19,
                                     path='delete')
        if g.guildName is None:
            label1 = Label("Guild", bold=True, color=g.loginFontColor)
            horzCont = HorizontalContainer(content=[label1, None, closeBtn])
            label = Label("You are not in a guild", color=g.loginFontColor)
            createBtn = HighlightedButton("Create Guild",
                                          on_release=self.createGuild,
                                          width=120,
                                          height=25)
            frameContent = VerticalContainer(
                content=[horzCont, label, createBtn])
        else:
            label1 = Label(g.guildName, bold=True, color=g.loginFontColor)
            horzCont = HorizontalContainer(content=[label1, None, closeBtn])
            onlineMembers = []
            offlineMembers = []
            for c in guildList:
                if c[2] == 1:
                    onlineMembers.append([c[0], c[1]])
                else:
                    offlineMembers.append([c[0], c[1]])
            onlineMembers.sort()
            offlineMembers.sort()
            members = []
            for c in onlineMembers:
                if c[1] == GUILD_MODERATOR:
                    font_color = g.modColor
                elif c[1] == GUILD_ADMIN:
                    font_color = g.adminColorLighter
                else:
                    font_color = g.loginFontColor
                label = HighlightedButton(c[0],
                                          width=150,
                                          height=24,
                                          path='baroutline_btn',
                                          font_color=font_color,
                                          on_release=self.constructSelect,
                                          argument=c[0],
                                          align=HALIGN_LEFT)
                #whisperBtn = HighlightedButton("",on_release=self.whisper,width=28,height=24,path='chatwhisper',argument=c[0])
                #if c[1]==GUILD_MODERATOR:
                #    label_extra=Label('#Mod#',color=g.modColor)
                #elif c[1]==GUILD_ADMIN:
                #    label_extra=Label('#Admin#',color=g.adminColorLighter)
                #else:
                label_extra = None
                members.append(
                    HorizontalContainer(content=[label, label_extra]))
            for c in offlineMembers:
                if c[1] == GUILD_MODERATOR:
                    font_color = g.errorColor
                elif c[1] == GUILD_ADMIN:
                    font_color = g.adminColor
                else:
                    font_color = g.npcColorLighter
                label = HighlightedButton(c[0],
                                          width=150,
                                          height=24,
                                          path='baroutline_btn',
                                          font_color=font_color,
                                          on_release=self.constructSelect,
                                          argument=c[0],
                                          align=HALIGN_LEFT)
                members.append(label)

            buttons = []
            print g.myGuildAccess
            if g.myGuildAccess > GUILD_MEMBER:
                buttons.append(
                    HighlightedButton("Invite Player",
                                      on_release=invitePlayerGuildPopup,
                                      width=100,
                                      height=24))
            #if g.myGuildAccess==GUILD_ADMIN:
            #    buttons.append(HighlightedButton("Guild Settings",on_release=openSettingsGuild,width=100,height=24))
            #leaveBtn = HighlightedButton("Leave Guild",on_release=self.leaveBtn,width=80,height=24)
            #addBtn = HighlightedButton("",on_release=self.addFriend,width=24,height=24,path='friendadd')
            frameContent = VerticalContainer(content=[
                horzCont,
                Scrollable(height=600,
                           width=400,
                           content=VerticalContainer(
                               content=members, align=HALIGN_LEFT, padding=0)),
                HorizontalContainer(buttons)
            ])
        #horzCont = HorizontalContainer(content=[label1,closeBtn])
        frame = Frame(frameContent)
        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)
예제 #14
0
                           "source": "vscrollbar.png",
                           "region": [0, 16, 16, 16],
                           "frame": [0, 6, 16, 4],
                           "padding": [0, 0, 0, 0]
                       },
                       "offset": [0, 0]
                   },
                   "bar": {
                       "image": {
                           "source": "vscrollbar.png",
                           "region": [0, 64, 16, 16]
                       },
                       "padding": [0, 0, 0, 0]
                    
                   }
               }
              }, resources_path='../theme/')

# Set up a Manager
contenido = VerticalContainer(content=[Label(str(x)) for x in range(10)])

Manager(
    # an horizontal layout with two vertical layouts, each one with a slider.
    Scrollable(height=100, width=200, content=contenido),
    window=window,
    is_movable = False,
    batch=batch,
    theme=theme)

pyglet.app.run()