Exemplo n.º 1
0
    def __init__(self,
                 name,
                 title,
                 icon,
                 client,
                 dam,
                 hit,
                 arm,
                 gold,
                 desc=""):

        self.client = client
        self.name = name
        self.title = title
        icon = Graphic(path=['icons', icon])
        title = Label(self.title)
        gold = Label("%sg" % gold, color=[230, 244, 68, 255])
        stats = HorizontalContainer([
            Label(str(dam), color=[255, 100, 100, 255]),
            Label(str(hit), color=[100, 100, 255, 255]),
            Label(str(arm), color=[100, 255, 100, 255]),
        ])

        take_button = OneTimeButton(label='Take', on_release=self.take)

        HorizontalContainer.__init__(self,
                                     [icon, title, gold, stats, take_button],
                                     align=HALIGN_LEFT)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    def __init__(self,
                 name,
                 title,
                 equipped,
                 icon,
                 client,
                 hit,
                 dam,
                 arm,
                 desc=""):

        self.client = client
        self.name = name
        self.title = title
        icon = Graphic(path=['icons', icon])
        title = Label(self.title)
        stats = HorizontalContainer([
            Label(str(dam), color=[255, 100, 100, 255]),
            Label(str(hit), color=[100, 100, 255, 255]),
            Label(str(arm), color=[100, 255, 100, 255]),
        ])
        button_text = 'Equip '
        if equipped:
            button_text = 'Remove'

        equip_button = Button(label=button_text,
                              is_pressed=equipped,
                              on_press=self.equip)
        use_button = OneTimeButton(label='Use', on_release=self.use)
        drop_button = OneTimeButton(label='Drop', on_release=self.confirm_drop)

        HorizontalContainer.__init__(
            self, [icon, title, stats, equip_button, use_button, drop_button],
            align=HALIGN_LEFT)
Exemplo n.º 4
0
    def __init__(self, window, controls, bodies):
        self.window = window
        self.controls = controls
        self.bodies = bodies

        self.fps_counter = FPSCounter(window, self.fps_update)

        # Setup HUD elements
        self.label_fps = Label("", bold=True, font_name="Arial", font_size=12, color=(127, 127, 127, 127))
        self.label_time = Label("", bold=True, font_name="Arial", font_size=18, color=(127, 127, 127, 127))
        self.label_help = BetterLabel(load_string('help.txt'), bold=False, font_name="Arial", font_size=18, color=(170, 170, 170, 255), multiline=True, lblwidth=600)
        self.label_planet_info = BetterLabel("", bold=False, font_name="Arial", font_size=12, color=(170, 170, 170, 255), multiline=True, lblwidth=400, lblalign='right')
        self.managers = [
            Manager(self.label_fps, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT),
            Manager(self.label_time, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT)
        ]
        self.label_help_manager = Manager(self.label_help, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT, offset=(0, -17))
        self.label_planet_info_manager = Manager(self.label_planet_info, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_RIGHT, offset=(-180, 36))

        body_buttons = []
        for body in self.bodies:
            body_buttons.append(BodyButton(self, body).button)

        self.managers_when_not_locked = [
            Manager(VerticalContainer(body_buttons, align=HALIGN_RIGHT), window=window, theme=ThemeFromPath("theme/bodybutton"), is_movable=False, anchor=ANCHOR_TOP_RIGHT)
        ]
Exemplo n.º 5
0
 def constructMeneButtons(self):
     for mene in meneList:
         if mene.hp <= 0:
             disabled = True
         else:
             disabled = False
         if g.gameEngine.fightScreen.myMene.ID == mene.ID:
             ispressed = True
             self.selectMeneID = mene.ID
         else:
             ispressed = False
         button = Button("",
                         on_press=self.updateWindow,
                         disabled=disabled,
                         width=TILESIZE * 2,
                         height=TILESIZE * 2,
                         argument=mene.ID,
                         texture=g.gameEngine.resManager.meneSprites[
                             mene.spriteName]["portraitlarge"],
                         is_pressed=ispressed,
                         outline='menewindowbutton')
         nameLabel = Label(mene.name, bold=True, color=g.npcColor)
         lvlLabel = Label("Lvl: %s" % mene.level)
         hpBar = HpBar(height=20,
                       width=64 * 2,
                       maxhp=mene.maxhp,
                       currenthp=mene.hp)
         self.meneCont.append(
             VerticalContainer(content=[button, nameLabel, lvlLabel, hpBar],
                               padding=0))
         self.meneButtons.append(button)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
def bagHoverTemplate(money, es):
    moneyTmp = money / 100.0
    moneyCont = HorizontalContainer(
        content=[Label("%.2f" %
                       moneyTmp), Graphic("euro")])
    esCont = HorizontalContainer(
        content=[Label("%s" % es), Graphic('es_icon')])
    return VerticalContainer(content=[esCont, moneyCont], align=HALIGN_RIGHT)
Exemplo n.º 8
0
def LabelFactory(model ,path):
        binding = Binding(context=model, path=path)
        label = Label(path='label')
        binding.setter = lambda value: label.set_text(value)
        if label.is_loaded:
            binding.apply_binding()

        return label
Exemplo n.º 9
0
class GUI:
    """
    Controls the GUI (HUD) of this application
    """

    def __init__(self, window, controls, bodies):
        self.window = window
        self.controls = controls
        self.bodies = bodies

        self.fps_counter = FPSCounter(window, self.fps_update)

        # Setup HUD elements
        self.label_fps = Label("", bold=True, font_name="Arial", font_size=12, color=(127, 127, 127, 127))
        self.label_time = Label("", bold=True, font_name="Arial", font_size=18, color=(127, 127, 127, 127))
        self.label_help = BetterLabel(load_string('help.txt'), bold=False, font_name="Arial", font_size=18, color=(170, 170, 170, 255), multiline=True, lblwidth=600)
        self.label_planet_info = BetterLabel("", bold=False, font_name="Arial", font_size=12, color=(170, 170, 170, 255), multiline=True, lblwidth=400, lblalign='right')
        self.managers = [
            Manager(self.label_fps, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT),
            Manager(self.label_time, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT)
        ]
        self.label_help_manager = Manager(self.label_help, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT, offset=(0, -17))
        self.label_planet_info_manager = Manager(self.label_planet_info, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_RIGHT, offset=(-180, 36))

        body_buttons = []
        for body in self.bodies:
            body_buttons.append(BodyButton(self, body).button)

        self.managers_when_not_locked = [
            Manager(VerticalContainer(body_buttons, align=HALIGN_RIGHT), window=window, theme=ThemeFromPath("theme/bodybutton"), is_movable=False, anchor=ANCHOR_TOP_RIGHT)
        ]

    def fps_update(self, fps):
        self.label_fps.set_text(str(fps) + "fps")

    def update_time(self, timestep, solarsystem_time):
        self.label_time.set_text("1 second = " + str(floor(timestep / 60 / 60)) + "hours. Current Date: " + str(J2000 + datetime.timedelta(seconds=solarsystem_time)))

    def draw(self):
        if self.controls.draw_help_label:
            self.label_help_manager.draw()

        if self.controls.selected_body:
            body = self.controls.selected_body
            text = ""
            text += "Name: " + body.name + "\n"
            text += "Position: " + str(round(body.xyz.x, 2)) + " " + str(round(body.xyz.y, 2)) + " " + str(round(body.xyz.z, 2)) + "\n"
            text += "Rotation Period: " + str(round(body.sidereal_rotation_period / 60 / 60 / 24, 2)) + "days\n"
            self.label_planet_info.set_text(text)
            self.label_planet_info_manager.draw()

        for manager in self.managers:
            manager.draw()

        if not self.controls.mouse_locked:
            for manager in self.managers_when_not_locked:
                manager.draw()
Exemplo n.º 10
0
 def __init__(self, path: str = None, binding: Binding = None):
     Viewer.__init__(self)
     Label.__init__(self)
     self.path = 'label' if path is None else path
     # ...
     if binding is not None:
         binding.setter = lambda value: self.set_text(value)
     # ...
     pass
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def initManager(self):
     self.mode = MODE_CONNECTING
     self.guiBatch = pyglet.graphics.Batch()
     self.statusText = Label("Connecting", color=(255, 255, 255, 255))
     self.downloadText = Label("", color=(255, 255, 255, 255))
     self.manager = Manager(VerticalContainer(
         [self.statusText, self.downloadText]),
                            window=self.screen,
                            batch=self.guiBatch,
                            theme=theme)
 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))
class StatsWindow(Manager):
    coinsText=None
    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 updateCoinText(self,coinAmount):
        self.coinsText.set_text("Coins: %s" % str(coinAmount))
Exemplo n.º 15
0
def abilityHoverTemplate(args):
    cont = []
    if 'name' in args:
        cont.append(
            Label(args['name'], bold=True, font_size=g.theme['font_size'] + 1))
    if 'type' in args:
        cont.append(Label(args['type']))
    if 'info' in args:
        cont.append(
            Label(args['info'].format(*args['args']),
                  width=TILESIZE * 4,
                  multiline=True,
                  color=g.loginFontColor))
    return VerticalContainer(cont, align=HALIGN_LEFT, padding=0)
Exemplo n.º 16
0
 def __init__(self,width=0,height=0,path=None,alternative=None,outline=None,hover=None,hoveringType=None,arguments=None,is_pressed=False,on_press=None,disabled=False,argument=None,buttonNumber=None):
     Graphic.__init__(self,path=path, width=width,height=height, alternative=alternative,outline=outline)
     TwoStateController.__init__(self,is_pressed=is_pressed,on_press=on_press)
     Label.__init__(self,str(buttonNumber),color=(255,255,255,255))
     self.ol=outline
     self.hover=hover
     self.args=arguments
     self.arg=argument
     self.disabled=disabled
     #self.hoverContent=hoverContent
     self.hovering=False
     self.hoveringType = hoveringType
     self.bN=buttonNumber
     self.pressing=False
Exemplo n.º 17
0
 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 manager(self):

        self.managerList += [
            Manager(HorizontalContainer(
                [OneTimeButton(label="Continuar",
                               on_release=self.nextWindow)]),
                    window=self,
                    batch=self.batch,
                    theme=getTheme(),
                    anchor=ANCHOR_BOTTOM_RIGHT,
                    offset=(-80, 5),
                    is_movable=False)
        ]

        self.managerList += [
            Manager(VerticalContainer([
                Checkbox(label="El CPU Inicia        ",
                         on_press=self.setCPUStarts,
                         is_pressed=self.CPUStarts),
                Checkbox(label="El CPU es blancas",
                         on_press=self.setCPUPlayWhite,
                         is_pressed=self.CPUPlayWhite),
                Label(""),
                Label("Enroque de negras"),
                Checkbox(label="Lado de la Reina ",
                         on_press=self.setBlackQueenCastling,
                         is_pressed=self.blackQueenCastling),
                Checkbox(label="Lado del Rey       ",
                         on_press=self.setBlackKingCastling,
                         is_pressed=self.blackKingCastling),
                Label(""),
                Label("Enroque de blancas"),
                Checkbox(label="Lado de la Reina ",
                         on_press=self.setWhiteQueenCastling,
                         is_pressed=self.whiteQueenCastling),
                Checkbox(label="Lado del Rey       ",
                         on_press=self.setWhiteKingCastling,
                         is_pressed=self.whiteKingCastling)
            ]),
                    window=self,
                    batch=self.batch,
                    theme=getTheme(),
                    anchor=ANCHOR_RIGHT,
                    offset=(-50, -95),
                    is_movable=False)
        ]
Exemplo n.º 19
0
    def add_message(self, message):

        step = 40
        for i in range(0, len(message), step):
            self.message_container.add(
                Label("> " + message[i:step], font_name='Lucida Grande'))
            step += 40

        self.text_input.set_text("")
Exemplo n.º 20
0
    def submit_message(self, state):

        message = self.text_input.get_text()
        self.text_input.set_text("")

        if message[0] == "/":
            self.message_container.add(
                Label("> " + message,
                      font_name='Lucida Grande',
                      color=[200, 200, 255, 255]))
            self.client.command(message[1:].split(' '))
        else:
            self.client.chat(message)
Exemplo n.º 21
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)
Exemplo n.º 22
0
    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)
Exemplo n.º 23
0
    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)
Exemplo n.º 24
0
 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("")
Exemplo n.º 25
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)
Exemplo n.º 26
0
    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)
Exemplo n.º 27
0
def create_ui_element(xe: Et, children: []):
    d = parse_attributes(**xe.attrib)
    if xe.tag == VerticalContainer.__name__:
        # align=HALIGN_CENTER, padding=5
        return VerticalContainer(children,
                                 align=d.get('align', 0),
                                 padding=d.get('padding', 5))
    if xe.tag == HorizontalContainer.__name__:
        # align=HALIGN_CENTER, padding=5
        return HorizontalContainer(children,
                                   align=d.get('align', 0),
                                   padding=d.get('padding', 5))
    elif xe.tag == Label.__name__:
        return Label(text=d.get('text'),
                     bold=d.get('bold', False),
                     italic=d.get('italic', False),
                     font_name=d.get('font_name', None),
                     font_size=d.get('font_size', None),
                     color=d.get('color', None),
                     path=d.get('path', None))
    elif xe.tag == Button.__name__:
        return Button(**xe.attrib)
    else:
        raise NotImplemented()
Exemplo n.º 28
0
 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)
Exemplo n.º 29
0
class MeneStats(Manager):
    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 updateLevel(self, level):
        self.levelLabel.set_text("Lvl: " + str(level))

    def updateInfo(self, name, level, hp, maxhp):
        self.levelLabel.set_text("Lvl: " + str(level))
        self.nameLabel.set_text(name)
        self.hpBar.setHP(hp, maxhp=maxhp)

    def setPos(self, x, y):
        self.set_position(x, y)

    def delete(self):
        super(Manager, self).delete()
Exemplo n.º 30
0
 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)
Exemplo n.º 31
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)
Exemplo n.º 32
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)