Beispiel #1
0
 def build(self):
     menu_props = self.menu_props
     t_a = menu_props.text_args.copy()
     # del t_a['scale']
     jid_lab = Text(_('Your user id:'), pos=(-.05, .4),
                            align='right', **t_a)
     pwd_lab = Text(_('Your password:'******'right', **t_a)
     init_txt = self.props.opt_file['settings']['login']['usr'] if \
         self.props.opt_file['settings']['login']['usr'] else \
         _('your user id')
     self.jid_ent = Entry(
         scale=.08, pos=(.05, .4), entry_font=menu_props.font, width=12,
         frame_col=menu_props.btn_col, initial_text=init_txt,
         text_fg=menu_props.text_active_col, on_tab=self.on_tab,
         on_click=self.on_click)
     self.pwd_ent = Entry(
         scale=.08, pos=(.05, .2), entry_font=menu_props.font, width=12,
         frame_col=menu_props.btn_col, obscured=True,
         text_fg=menu_props.text_active_col, cmd=self.start)
     start_btn = Btn(
         text=_('Log-in'), pos=(0, 0), cmd=self.start,
         **self.props.gameprops.menu_props.btn_args)
     widgets = [self.jid_ent, self.pwd_ent, start_btn, jid_lab,
                pwd_lab]
     self.add_widgets(widgets)
     self.eng.attach_obs(self.on_frame)
     ThanksPageGui.build(self)
Beispiel #2
0
 def build(self):
     menu_props = self.menu_props
     t_a = menu_props.text_args.copy()
     # del t_a['scale']
     email_lab = Text(_('Your email:'),
                      pos=(-.65, .4),
                      align='right',
                      **t_a)
     jid_lab = Text(_('Your user id:'),
                    pos=(-.65, .2),
                    align='right',
                    **t_a)
     pwd_lab = Text(_('Your password:'******'right',
                    **t_a)
     init_txt = self.props.opt_file['settings']['login']['usr'] if \
         self.props.opt_file['settings']['login']['usr'] else \
         _('your user id')
     self.email_ent = Entry(scale=.08,
                            pos=(-.55, .4),
                            entry_font=menu_props.font,
                            width=20,
                            frame_col=menu_props.btn_col,
                            initial_text=_('your email'),
                            text_fg=menu_props.text_active_col,
                            on_tab=self.on_tab_email,
                            on_click=self.on_click_email)
     self.jid_ent = Entry(scale=.08,
                          pos=(-.55, .2),
                          entry_font=menu_props.font,
                          width=20,
                          frame_col=menu_props.btn_col,
                          initial_text=init_txt,
                          text_fg=menu_props.text_active_col,
                          on_tab=self.on_tab_id,
                          on_click=self.on_click_id)
     self.pwd_ent = Entry(scale=.08,
                          pos=(-.55, 0),
                          entry_font=menu_props.font,
                          width=20,
                          frame_col=menu_props.btn_col,
                          obscured=True,
                          text_fg=menu_props.text_active_col,
                          cmd=self.register)
     start_btn = Btn(text=_('Register'),
                     pos=(0, -.2),
                     cmd=self.register,
                     **self.props.gameprops.menu_props.btn_args)
     t_a['scale'] = .06
     widgets = [
         self.jid_ent, self.pwd_ent, start_btn, jid_lab, pwd_lab, email_lab,
         self.email_ent
     ]
     self.add_widgets(widgets)
     self.eng.attach_obs(self.on_frame)
     ThanksPageGui.build(self)
Beispiel #3
0
 def __init__(self,
              attr_name,
              init_val,
              pos,
              val_range,
              callback,
              args=None):
     # unused val_range
     GameObject.__init__(self)
     self.__callback = callback
     self.__args = args or []
     self.__lab = OnscreenText(text=attr_name,
                               pos=pos,
                               align=TextNode.ARight,
                               fg=(1, 1, 1, 1),
                               parent=base.a2dTopLeft,
                               scale=.046)
     slider_pos = LVector3f(pos[0], 1, pos[1]) + (.05, 0, .01)
     self.__slider = Entry(pos=slider_pos,
                           initial_text=str(init_val),
                           cmd=self.__set_attr,
                           parent=base.a2dTopLeft,
                           scale=.05,
                           frame_col=(0, 0, 0, .2),
                           text_fg=(1, 1, 1, 1))
     # txt_pos = LVector3f(pos[0], pos[1], 1) + (.6, 0, 0)
     self.widgets = [self.__slider, self.__lab]
     self.toggle()
Beispiel #4
0
 def build(self):
     menu_props = self.menu_props
     all_names = self.props.gameprops.player_names + self.props.gameprops.stored_player_names[
         len(self.props.gameprops.player_names):]
     self.ent = Entry(
         scale=.08,
         pos=(0, .6),
         entry_font=menu_props.font,
         width=12,
         frame_col=menu_props.btn_col,
         initial_text=all_names[0] if all_names else _('your name'),
         text_fg=menu_props.text_active_col)
     self.add_widgets([self.ent])
     self.update_tsk = taskMgr.add(self.update_text, 'update text')
     DriverPageGui.build(self, exit_behav=False)
     self.enable_buttons(False)
Beispiel #5
0
 def __init__(self, menu_props):
     GameObject.__init__(self)
     self.eng.log('created match message form')
     self.chat = None
     self.msg_frm = Frame(
         frame_size=(-.02, 3.49, 0, 1.22),
         frame_col=(.2, .2, .2, .5),
         pos=(.04, -1.69), parent=base.a2dTopLeft)
     t_a = menu_props.text_args
     t_a['scale'] = .05
     t_a['fg'] = menu_props.text_normal_col
     self.dst_txt = Text(
         txt='', pos=(0, 1.16), parent=self.msg_frm, align='left',
         **t_a)
     self.ent = Entry(
         scale=.04, pos=(0, .03), entry_font=menu_props.font, width=86,
         frame_col=menu_props.btn_col, parent=self.msg_frm,
         initial_text=_('write here your message'),
         cmd=self.on_typed_msg, focus_in_cmd=self.on_focus,
         focus_in_args=['in'], focus_out_cmd=self.on_focus,
         focus_out_args=['out'], text_fg=menu_props.text_active_col)
     self.ent['state'] = DISABLED
     self.txt_frm = ScrolledFrame(
         frame_sz=(-.02, 2.46, -.02, 1.02),
         canvas_sz=(-.02, 2.42, -.02, 1.02),
         scrollbar_width=.036,
         frame_col=(1, 1, 1, .0),
         pos=(.02, .11), parent=self.msg_frm)
     t_a['scale'] = .046
     self.msg_txt = Text(
         txt='', pos=(0, .24), parent=self.txt_frm.canvas,
         align='left', wordwrap=52, **t_a)
     lab_args = menu_props.label_args
     lab_args['scale'] = .046
     lab_args['text_fg'] = menu_props.text_normal_col
     self.lab_frm = Btn(
         frame_size=(-.02, 2.5, -.01, .05),
         frame_col=(1, 1, 1, 0),
         pos=(0, 1.15), parent=self.msg_frm)
     self.lab_frm.bind(ENTER, self.on_enter)
     self.lab_frm.bind(EXIT, self.on_exit)
     self.tooltip = Label(
         text='', pos=(2.4, -.06), parent=self.lab_frm, text_wordwrap=50,
         text_align=TextNode.A_right, **lab_args)
     self.tooltip.set_bin('gui-popup', 10)
     self.tooltip.hide()
     self.eng.client.attach(self.on_groupchat_msg)
Beispiel #6
0
 def __init__(self, menu_props):
     GameObject.__init__(self)
     self.eng.log('created message form')
     self.chats = []
     self.curr_chat = None
     self.curr_match_room = None
     self.msg_frm = DirectFrame(
         frameSize=(-.02, .8, 0, .45),
         frameColor=(.2, .2, .2, .5),
         pos=(-.82, 1, .02), parent=base.a2dBottomRight)
     self.presences_sent = []
     self.menu_props = menu_props
     t_a = menu_props.text_args
     t_a['scale'] = .05
     t_a['fg'] = menu_props.text_normal_col
     self.dst_txt = OnscreenText(
         text='', pos=(0, .4), parent=self.msg_frm, align=TextNode.A_left,
         **t_a)
     self.arrow_btn = ImgBtn(
         parent=self.msg_frm, scale=(.024, .024), pos=(.7, 1, .42),
         frame_col=(1, 1, 1, 1),
         frame_texture='assets/images/gui/arrow.txo',
         cmd=self.on_arrow,
         **menu_props.imgbtn_args)
     self.arrow_btn.disable()
     self.close_btn = ImgBtn(
         parent=self.msg_frm, scale=(.024, .024), pos=(.76, 1, .42),
         frame_col=(1, 1, 1, 1),
         frame_texture='assets/images/gui/close.txo',
         cmd=self.on_close,
         **menu_props.imgbtn_args)
     self.close_btn.disable()
     self.ent = Entry(
         scale=.04, pos=(0, .03), entry_font=menu_props.font, width=19.5,
         frame_col=menu_props.btn_col, parent=self.msg_frm,
         initial_text=_('write here your message'),
         cmd=self.on_typed_msg, focus_in_cmd=self.on_focus,
         focus_in_args=['in'], focus_out_cmd=self.on_focus,
         focus_out_args=['out'], text_fg=menu_props.text_active_col)
     self.ent['state'] = DISABLED
     self.txt_frm = DirectScrolledFrame(
         frameSize=(-.02, .76, -.02, .28),
         canvasSize=(-.02, .72, -.02, .28),
         scrollBarWidth=.036,
         verticalScroll_relief=FLAT,
         verticalScroll_frameColor=(.2, .2, .2, .4),
         verticalScroll_thumb_relief=FLAT,
         verticalScroll_thumb_frameColor=(.8, .8, .8, .6),
         verticalScroll_incButton_relief=FLAT,
         verticalScroll_incButton_frameColor=(.8, .8, .8, .6),
         verticalScroll_decButton_relief=FLAT,
         verticalScroll_decButton_frameColor=(.8, .8, .8, .6),
         horizontalScroll_relief=FLAT,
         frameColor=(1, 1, 1, 0),
         pos=(.02, 1, .11), parent=self.msg_frm)
     t_a['scale'] = .046
     self.msg_txt = OnscreenText(
         text='', pos=(0, .24), parent=self.txt_frm.getCanvas(),
         align=TextNode.A_left, wordwrap=14, **t_a)
     lab_args = menu_props.label_args
     lab_args['scale'] = .046
     lab_args['text_fg'] = menu_props.text_normal_col
     self.lab_frm = Btn(
         frame_size=(-.02, .64, -.01, .05),
         frame_col=(1, 1, 1, 0),
         pos=(0, 1, .4), parent=self.msg_frm)
     self.lab_frm.bind(ENTER, self.on_enter)
     self.lab_frm.bind(EXIT, self.on_exit)
     self.tooltip = Label(
         text='', pos=(.78, 1, -.06),
         parent=self.lab_frm, text_wordwrap=16,# text_bg=(.2, .2, .2, .8),
         text_align=TextNode.A_right, **lab_args)
     self.tooltip.set_bin('gui-popup', 10)
     self.tooltip.hide()
Beispiel #7
0
    def build(self):
        self.drv_info = self.props.gameprops.drivers_info
        menu_props = self.menu_props
        widgets = [
            Text(_('Select the drivers'), pos=(0, .91), **menu_props.text_args)
        ]
        t_a = self.menu_props.text_args.copy()
        del t_a['scale']
        self.name = Text(_('Write your names:'),
                         pos=(-.1, .7),
                         scale=.06,
                         align='right',
                         wordwrap=128,
                         **t_a)
        self.drivers = []
        for row, col in product(range(2), range(4)):
            idx = col + row * 4
            drv_btn = ImgBtn(scale=(.24, .24),
                             pos=(-.75 + col * .5, .1 - row * .64),
                             frame_col=(0, 0, 0, 0),
                             img=self.props.gameprops.drivers_img.path % idx,
                             cmd=self.on_click,
                             extra_args=[idx],
                             **self.menu_props.imgbtn_args)
            name = Text('',
                        pos=(-.75 + col * .5, -.19 - row * .64),
                        scale=.046,
                        **t_a)
            drv_btn._name_txt = name
            widgets += [drv_btn, name]
            self.drivers += [widgets[-2]]
            sign = lambda pos_x: '\1green\1+\2' if pos_x > 0 else ''
            psign = lambda pos_x, sgn=sign: '+' if pos_x == 0 else sgn(pos_x)

            def ppcol(x):
                return '\1green\1%s\2' % x if x > 0 else '\1red\1%s\2' % x

            pcol = lambda x: x if x == 0 else ppcol(x)
            lab_lst = [(_('adherence'), -.11), (_('speed'), .01),
                       (_('stability'), -.05)]
            widgets += list(
                map(lambda lab_def: self._add_lab(*(lab_def + (row, col))),
                    lab_lst))
            txt_lst = [(self.drv_info[idx - 1].adherence, -.11),
                       (self.drv_info[idx - 1].speed, .01),
                       (self.drv_info[idx - 1].stability, -.05)]
            widgets += list(
                map(
                    lambda txt_def: self._add_txt(*txt_def +
                                                  (psign, pcol, col, row)),
                    txt_lst))
        self.sel_drv_img = []
        self.tss = []
        instr_txt = _(
            'If you use the keyboard, press FIRE to edit the field, then '
            "ENTER when you're done. Other players can't move while someone "
            'is writing (since, with keyboards, some letters may be bound to '
            'movements).')
        instr = Text(instr_txt, pos=(1.28, .8), scale=.042, wordwrap=24, **t_a)
        widgets += [self.name, instr]
        for i, car in enumerate(self.mediator.cars):
            self.sel_drv_img += [
                Img(self.props.gameprops.cars_img % car,
                    parent=base.a2dBottomLeft,
                    pos=(.3, 1.74 - i * .46),
                    scale=.22)
            ]
            widgets += [self.sel_drv_img[-1]]
            ffilterpath = self.eng.curr_path + 'yyagl/assets/shaders/filter.vert'
            with open(ffilterpath) as ffilter:
                vert = ffilter.read()
            shader = load_shader(vert, frag)
            if shader:
                self.sel_drv_img[-1].set_shader(shader)
            self.sel_drv_img[-1].set_transparent()
            self.tss += [TextureStage('ts')]
            self.tss[-1].set_mode(TextureStage.MDecal)
            empty_img = PNMImage(1, 1)
            empty_img.add_alpha()
            empty_img.alpha_fill(0)
            tex = Texture()
            tex.load(empty_img)
            self.sel_drv_img[-1].set_texture(self.tss[-1], tex)
        all_names = self.props.gameprops.player_names + self.props.gameprops.stored_player_names[
            len(self.props.gameprops.player_names):]
        self.ents = [
            Entry(scale=.06,
                  pos=(0, .8 - .12 * i),
                  entry_font=menu_props.font,
                  width=12,
                  frame_col=menu_props.btn_col,
                  initial_text=all_names[i]
                  if i < len(all_names) else _('your name'),
                  text_fg=menu_props.text_active_col)
            for i in range(len(self.mediator.cars))
        ]
        self.add_widgets(self.ents)
        self.add_widgets(widgets)
        ThanksPageGui.build(self, exit_behav=False)
        self.update_tsk = taskMgr.add(self.update_text, 'update text')
        self.enable_buttons(False)