Пример #1
0
    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
Пример #2
0
 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)
Пример #3
0
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)
Пример #4
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)
Пример #5
0
 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
Пример #6
0
    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)
Пример #7
0
 def __init__(self):
     g.reportAnswerWindowOpened = True
     self._reportid=-1
     getReport(True)
     label1=Label("Answer to 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.report = Document("",is_fixed_size=True,width=g.SCREEN_WIDTH/3,height=g.SCREEN_HEIGHT/4)
     self.reportInput = TextInput(text="",padding=0,length=16,max_length=500,width=g.SCREEN_WIDTH/3,height=g.SCREEN_HEIGHT/4,multiline=True)
     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=[deleteBtn,Spacer(0,0),sendBtn])
     frame = Frame(VerticalContainer(content=[horzCont,self.report,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)    
Пример #8
0
    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)
Пример #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, textPositions, castlingRigths, starts, CPUPlaysWhite,
                 pwindow, batch):
        super(ChessGUI,
              self).__init__(900,
                             600,
                             resizable=False,
                             caption='Chess',
                             config=pyglet.gl.Config(double_buffer=True),
                             vsync=False)
        pyglet.clock.schedule_interval(self.updatePosition, 1 / 60)
        self.board_imgs = [[None for _ in range(8)] for _ in range(8)]
        self.board = []
        self.window = pwindow
        self.batch = batch

        self.CPUPlaysWhite = CPUPlaysWhite
        self.castlingRigths = castlingRigths
        self.starts = starts

        if (starts == "b"):
            self.turn = "N"
        else:
            self.turn = "B"
        if CPUPlaysWhite:
            self.playerTurn = "N"
        else:
            self.playerTurn = "B"

        self.selectedPiece = []
        self.board_normal = pyglet.sprite.Sprite(self.chessboard)
        self.board_flipped = pyglet.sprite.Sprite(self.chessboardInv)
        self.hoverSprite = pyglet.sprite.Sprite(self.hoverImg)
        self.danger = pyglet.sprite.Sprite(self.dangerImg)
        self.piece_held = None
        self.textPositions = textPositions

        self.createBoard(textPositions)
        self.inFunction = False
        self.draws = 0

        self.game = Game(
            self.stdNotationToChess(self.board) + " " + starts + " " +
            castlingRigths + " - 0 1")
        self.wQueen = pyglet.sprite.Sprite(self.spritesheet[7], 131.25, 225)
        self.wRook = pyglet.sprite.Sprite(self.spritesheet[10], 218.75, 225)
        self.wBishop = pyglet.sprite.Sprite(self.spritesheet[8], 306.25, 225)
        self.wKnight = pyglet.sprite.Sprite(self.spritesheet[9], 393.75, 225)
        self.bQueen = pyglet.sprite.Sprite(self.spritesheet[1], 131.25, 225)
        self.bRook = pyglet.sprite.Sprite(self.spritesheet[4], 218.75, 225)
        self.bBishop = pyglet.sprite.Sprite(self.spritesheet[2], 306.25, 225)
        self.bKnight = pyglet.sprite.Sprite(self.spritesheet[3], 393.75, 225)
        self.background = pyglet.sprite.Sprite(self.backgroundImg)
        self.document = Document(pyglet.text.decode_attributed("\n" * 23),
                                 width=250,
                                 height=400)
        self.manager()
        self.numero = 0
        self.announcedFinal = False
        self.instanteInicial = None
        self.instanteFinal = None
        self.lineCont = 1
        self.annotations = ""
Пример #11
0
                },
                "offset": [0, 0]
            },
            "bar": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 64, 16, 16]
                },
                "padding": [0, 0, 0, 0]
            }
        }
    },
    resources_path='../theme')

document = pyglet.text.decode_attributed('''
In {bold True}Pyglet-gui{bold False} you can use
{underline (255, 255, 255, 255)}pyglet{underline None}'s documents in a
scrollable window.

You can also {font_name "Courier New"}change fonts{font_name Lucia Grande},
{italic True}italicize your text{italic False} and use all features of Pyglet's document.
''')

# Set up a Manager
Manager(Document(document, width=300, height=50),
        window=window,
        batch=batch,
        theme=theme)

pyglet.app.run()
Пример #12
0
    def __init__(self):
        w1 = int(350 * (g.SCREEN_WIDTH / 1920.))
        h1 = int(300 * (g.SCREEN_HEIGHT / 1080.))
        if w1 > 300:
            g.chatTheme["font_size"] = 11
            g.theme["font_size"] = 11
            g.theme["button"]["font_size"] = 11
        elif w1 > 250:
            g.chatTheme["font_size"] = 12
            g.theme["font_size"] = 12
            g.theme["button"]["font_size"] = 12
            w1 = int(w1 * 1.1)
        elif w1 > 200:
            g.chatTheme["font_size"] = 11
            g.theme["font_size"] = 11
            g.theme["button"]["font_size"] = 11
            w1 = int(w1 * 1.2)
        elif w1 > 175:
            g.chatTheme["font_size"] = 10
            g.theme["font_size"] = 10
            g.theme["button"]["font_size"] = 10
            w1 = int(w1 * 1.3)
        else:
            g.chatTheme["font_size"] = 9
            g.theme["font_size"] = 9
            g.theme["button"]["font_size"] = 9
            w1 = int(w1 * 1.3)
        self.chatInput = TextInput(text="",
                                   padding=0,
                                   length=16,
                                   max_length=MAX_CHAT_INPUT,
                                   width=w1 - 5 - 50)
        sendButton = HighlightedButton(label="Send",
                                       on_release=self.sendMessage,
                                       width=50,
                                       height=35)
        realtext = '{font_size ' + str(
            g.chatTheme["font_size"]) + '}{background_color ' + str(
                g.postBgColor
            ) + '}{font_name "' + g.chatTheme["font"] + '"}{wrap "char"} '
        document = pyglet.text.decode_attributed(realtext)
        self.textArea = Document(document,
                                 width=w1,
                                 height=h1,
                                 background=True,
                                 font_size=g.chatTheme["font_size"],
                                 font_name=g.chatTheme["font"],
                                 chat=True)

        vertCont = VerticalContainer(content=[
            self.textArea,
            HorizontalContainer(content=[self.chatInput, sendButton])
        ],
                                     align=HALIGN_LEFT)
        Manager.__init__(self,
                         vertCont,
                         window=g.screen,
                         batch=g.guiBatch,
                         theme=g.chatTheme,
                         anchor=ANCHOR_BOTTOM_LEFT,
                         offset=(g.SCREEN_WIDTH * 0.05, g.SCREEN_HEIGHT * 0.1),
                         is_movable=False)
Пример #13
0
                },
                "padding": [0, 0, 0, 0]
            }
        }
    },
    resources_path='../theme')

document = pyglet.text.decode_attributed('''
In {bold True}Pyglet-gui{bold False} you can use
{underline (255, 255, 255, 255)}pyglet{underline None}'s documents in a
scrollable window.

You can also {font_name "Courier New"}change fonts{font_name Lucia Grande},
{italic True}italicize your text{italic False} and use all features of Pyglet's document.
''')
so = Document(document, width=300, height=50)


def f(y):
    document = "Hola mundo"
    so.set_text(document + so.get_text())


# Set up a Manager
Manager(so, window=window, batch=batch, theme=theme)
Manager(VerticalContainer([Button(label="Persistent button", on_press=f)]),
        window=window,
        batch=batch,
        theme=theme)

pyglet.app.run()