コード例 #1
0
ファイル: button.py プロジェクト: oriolrg/yorg
 def __init__(self, parent, owner, menu_props, img_path, msg_btn_x, cb,
              usr_name, tooltip):
     GameObject.__init__(self)
     self.owner = owner
     lab_args = menu_props.label_args
     lab_args['scale'] = .046
     #lab_args['text_fg'] = menu_props.text_normal_col
     self.btn = ImgBtn(parent=parent,
                       scale=(.024, .024),
                       pos=(msg_btn_x, .01),
                       frame_col=(1, 1, 1, 1),
                       frame_texture=img_path,
                       cmd=cb,
                       extra_args=[usr_name],
                       **menu_props.imgbtn_args)
     self.btn.bind(ENTER, self.on_enter)
     self.btn.bind(EXIT, self.on_exit)
     self.tooltip_btn = Btn(parent=parent,
                            scale=(.024, .024),
                            pos=(msg_btn_x, .01),
                            frame_col=(1, 1, 1, 0),
                            frame_size=(-1, 1, -1, 1),
                            cmd=None,
                            **menu_props.imgbtn_args)
     self.tooltip_btn.bind(ENTER, self.on_enter)
     self.tooltip_btn.bind(EXIT, self.on_exit)
     self.on_create()
     self.tooltip = Label(text=tooltip,
                          pos=self.btn.get_pos() + self.tooltip_offset,
                          parent=parent,
                          text_wordwrap=10,
                          text_align=self.tooltip_align,
                          **lab_args)
     self.tooltip.set_bin('gui-popup', 10)
     self.tooltip.hide()
コード例 #2
0
 def __bld_car(self, cars_per_row, row, col):
     t_a = self.menu_args.text_args.copy()
     del t_a['scale']
     gprops = self.props.gameprops
     z_offset = 0 if len(gprops.cars_names) > cars_per_row else .35
     num_car_row = len(gprops.cars_names) - cars_per_row if row == 1 else \
         min(cars_per_row, len(gprops.cars_names))
     x_offset = .4 * (cars_per_row - num_car_row)
     btn = ImgBtn(scale=.32,
                  pos=(-1.4 + col * .64 + x_offset, 1,
                       .4 - z_offset - row * .7),
                  frameColor=(0, 0, 0, 0),
                  image=gprops.car_path %
                  gprops.cars_names[col + row * cars_per_row],
                  command=self.on_car,
                  extraArgs=[gprops.cars_names[col + row * cars_per_row]],
                  **self.menu_args.imgbtn_args)
     widgets = [btn]
     txt = Text(gprops.cars_names[col + row * cars_per_row],
                pos=(-1.4 + col * .64 + x_offset,
                     .64 - z_offset - row * .7),
                scale=.072,
                **t_a)
     name = Text('',
                 pos=(-1.4 + col * .64 + x_offset,
                      .04 - z_offset - row * .7),
                 scale=.046,
                 **t_a)
     btn._name_txt = name
     widgets += [txt, name]
     car_name = gprops.cars_names[col + row * cars_per_row]
     cfg_fpath = gprops.phys_path % car_name
     with open(cfg_fpath) as phys_file:
         cfg = load(phys_file)
     speed = int(round((cfg['max_speed'] / 120.0 - 1) * 100))
     fric = int(round((cfg['friction_slip'][0] / 2.6 - 1) * 100))
     roll = -int(round((cfg['roll_influence'][0] / .21 - 1) * 100))
     sign = lambda x: '\1green\1+\2' if x > 0 else ''
     psign = lambda x, sgn=sign: '+' if x == 0 else sgn(x)
     __col_ = lambda x: '\1green\1%s\2' if x > 0 else '\1red\1%s\2'
     _col_ = lambda x, __col=__col_: __col(x) % x
     pcol = lambda x, _col=_col_: x if x == 0 else _col(x)
     txt_lst = [(_('adherence'), fric, .11), (_('speed'), speed, .27),
                (_('stability'), roll, .19)]
     widgets += map(
         lambda txt_def: self.__add_txt(*txt_def + (
             psign, pcol, col, x_offset, z_offset, row)), txt_lst)
     return widgets
コード例 #3
0
    def bld_page(self):
        menu_gui = self.mdt.menu.gui
        self.pagewidgets = [
            OnscreenText(text=_('Select the car'),
                         pos=(0, .8),
                         **menu_gui.menu_args.text_args)
        ]
        self.track_path = self.mdt.menu.track  # we should pass it
        t_a = self.mdt.menu.gui.menu_args.text_args.copy()
        del t_a['scale']
        for row, col in product(range(2), range(4)):
            if row == 1 and col == 3:
                break
            self.pagewidgets += [
                ImgBtn(scale=.32,
                       pos=(-1.2 + .4 * row + col * .8, 1, .4 - row * .7),
                       frameColor=(0, 0, 0, 0),
                       image=self.props.car_path %
                       self.props.cars[col + row * 4],
                       command=self.on_car,
                       extraArgs=[self.props.cars[col + row * 4]],
                       **self.mdt.menu.gui.menu_args.imgbtn_args)
            ]
            self.pagewidgets += [
                OnscreenText(self.props.cars[col + row * 4],
                             pos=(-1.2 + .4 * row + col * .8, .64 - row * .7),
                             scale=.072,
                             **t_a)
            ]
            cpath = self.props.phys_path % self.props.cars[col + row * 4]
            with open(cpath) as phys_file:
                cfg = load(phys_file)
            speed = cfg['max_speed'] / 140.0
            fric = cfg['friction_slip'] / 3.0
            roll = cfg['roll_influence'] / .2
            speed = int(round((speed - 1) * 100))
            fric = int(round((fric - 1) * 100))
            roll = -int(round((roll - 1) * 100))
            sign = lambda x: '\1green\1+\2' if x > 0 else ''
            psign = lambda x: '+' if x == 0 else sign(x)
            __col = lambda x: '\1green\1%s\2' if x > 0 else '\1red\1%s\2'
            _col = lambda x: __col(x) % x
            pcol = lambda x: x if x == 0 else _col(x)

            def add_txt(txt, val, pos_z):
                self.pagewidgets += [
                    OnscreenText('%s: %s%s%%' % (txt, psign(val), pcol(val)),
                                 pos=(-.9 + .4 * row + col * .8,
                                      pos_z - row * .7),
                                 scale=.052,
                                 align=TextNode.A_right,
                                 **t_a)
                ]

            txt_lst = [(_('adherence'), fric, .11), (_('speed'), speed, .27),
                       (_('stability'), roll, .19)]
            map(lambda txt_def: add_txt(*txt_def), txt_lst)
        map(self.add_widget, self.pagewidgets)
        self.current_cars = {}
        ThanksPageGui.bld_page(self)
コード例 #4
0
ファイル: trackpage.py プロジェクト: xinxinxinxinxin/yorg
 def build(self):
     txt = Text(_('Select the track'),
                pos=(-.2, .8),
                **self.menu_args.text_args)
     self.add_widgets([txt])
     t_a = self.menu_args.text_args.copy()
     t_a['scale'] = .06
     tracks_per_row = 3
     gprops = self.props.gameprops
     for row, col in product(range(2), range(tracks_per_row)):
         if row * tracks_per_row + col >= len(gprops.season_tracks):
             break
         z_offset = 0 if len(gprops.season_tracks) > tracks_per_row else .35
         num_tracks = len(gprops.season_tracks) - tracks_per_row \
             if row == 1 else min(tracks_per_row, len(gprops.season_tracks))
         x_offset = .3 * (tracks_per_row - num_tracks)
         btn = ImgBtn(
             scale=.3,
             pos=(-.8 + col * .6 + x_offset, 1, .4 - z_offset - row * .7),
             frameColor=(0, 0, 0, 0),
             image=gprops.track_img %
             gprops.season_tracks[col + row * tracks_per_row],
             command=self.on_track,
             extraArgs=[gprops.season_tracks[col + row * tracks_per_row]],
             **self.menu_args.imgbtn_args)
         txt = Text(gprops.tracks_tr()[col + row * tracks_per_row],
                    pos=(-.8 + col * .6 + x_offset,
                         .14 - z_offset - row * .7),
                    **t_a)
         self.add_widgets([btn, txt])
     ThanksPageGui.build(self, exit_behav=self.eng.server.is_active)
コード例 #5
0
ファイル: button.py プロジェクト: cflavio/yorg
 def __init__(self, parent, owner, menu_props, img_path, msg_btn_x, cb,
              usr_name, tooltip):
     GameObject.__init__(self)
     self.owner = owner
     lab_args = menu_props.label_args
     lab_args['scale'] = .046
     #lab_args['text_fg'] = menu_props.text_normal_col
     self.btn = ImgBtn(
         parent=parent, scale=(.024, .024), pos=(msg_btn_x, .01),
         frame_col=(1, 1, 1, 1), frame_texture=img_path, cmd=cb,
         extra_args=[usr_name], **menu_props.imgbtn_args)
     self.btn.bind(ENTER, self.on_enter)
     self.btn.bind(EXIT, self.on_exit)
     self.tooltip_btn = Btn(
         parent=parent, scale=(.024, .024), pos=(msg_btn_x, .01),
         frame_col=(1, 1, 1, 0), frame_size=(-1, 1, -1, 1), cmd=None,
         **menu_props.imgbtn_args)
     self.tooltip_btn.bind(ENTER, self.on_enter)
     self.tooltip_btn.bind(EXIT, self.on_exit)
     self.on_create()
     self.tooltip = Label(
         text=tooltip, pos=self.btn.get_pos() + self.tooltip_offset,
         parent=parent, text_wordwrap=10, text_align=self.tooltip_align,
         **lab_args)
     self.tooltip.set_bin('gui-popup', 10)
     self.tooltip.hide()
コード例 #6
0
 def bld_page(self):
     menu_gui = self.mdt.menu.gui
     widgets = [
         OnscreenText(text=_('Select the track'),
                      pos=(0, .8),
                      **menu_gui.menu_args.text_args)
     ]
     t_a = self.mdt.menu.gui.menu_args.text_args.copy()
     t_a['scale'] = .08
     for i in range(len(self.props.tracks)):
         widgets += [
             ImgBtn(scale=.5,
                    pos=(-1.05 + i * 1.05, 1, .1),
                    frameColor=(0, 0, 0, 0),
                    image=self.props.track_img % self.props.tracks[i],
                    command=self.on_track,
                    extraArgs=[self.props.tracks[i]],
                    **self.mdt.menu.gui.menu_args.imgbtn_args)
         ]
         widgets += [
             OnscreenText(self.props.tracks_tr()[i],
                          pos=(-1.05 + i * 1.05, -.32),
                          **t_a)
         ]
     map(self.add_widget, widgets)
     ThanksPageGui.bld_page(self)
コード例 #7
0
ファイル: carpage.py プロジェクト: cflavio/yorg
 def __bld_car(self, cars_per_row, row, col):
     t_a = self.menu_props.text_args.copy()
     del t_a['scale']
     gprops = self.props.gameprops
     z_offset = 0 if len(gprops.cars_names) > cars_per_row else .35
     num_car_row = len(gprops.cars_names) - cars_per_row if row == 1 else \
         min(cars_per_row, len(gprops.cars_names))
     x_offset = .4 * (cars_per_row - num_car_row)
     btn = ImgBtn(
         scale=(.32, .32),
         pos=(-.96 + col * .64 + x_offset, .4 - z_offset - row * .7),
         frame_col=(0, 0, 0, 0),
         img=gprops.car_path % gprops.cars_names[col + row*cars_per_row],
         cmd=self.on_car,
         extra_args=[
             gprops.cars_names[col + row * cars_per_row]],
         **self.menu_props.imgbtn_args)
     widgets = [btn]
     txt = Text(
         gprops.cars_names[col + row * cars_per_row],
         pos=(-.96 + col * .64 + x_offset, .64 - z_offset - row * .7),
         scale=.072, **t_a)
     name = Text(
         '',
         pos=(-.96 + col * .64 + x_offset, .04 - z_offset - row * .7),
         scale=.046, **t_a)
     btn._name_txt = name
     widgets += [txt, name]
     car_name = gprops.cars_names[col + row * cars_per_row]
     cfg_fpath = gprops.phys_path % car_name
     with open(cfg_fpath) as phys_file:
         cfg = load(phys_file)
     speed = int(round((cfg['max_speed'] / 120.0 - 1) * 100))
     fric = int(round((cfg['friction_slip'][0] / 2.6 - 1) * 100))
     roll = -int(round((cfg['roll_influence'][0] / .21 - 1) * 100))
     sign = lambda x: '\1green\1+\2' if x > 0 else ''
     psign = lambda x, sgn=sign: '+' if x == 0 else sgn(x)
     __col_ = lambda x: '\1green\1%s\2' if x > 0 else '\1red\1%s\2'
     _col_ = lambda x, __col=__col_: __col(x) % x
     pcol = lambda x, _col=_col_: x if x == 0 else _col(x)
     txt_lst = [(_('adherence'), fric, .11), (_('speed'), speed, .27),
                (_('stability'), roll, .19)]
     widgets += list(map(lambda txt_def: self.__add_txt(
         *txt_def + (psign, pcol, col, x_offset, z_offset, row)), txt_lst))
     return widgets
コード例 #8
0
 def __init__(self, parent, owner, menu_args, img_path, msg_btn_x, cb,
              usr_name, tooltip):
     GameObject.__init__(self)
     self.owner = owner
     lab_args = menu_args.label_args
     lab_args['scale'] = .046
     #lab_args['text_fg'] = menu_args.text_normal
     self.btn = ImgBtn(parent=parent,
                       scale=.024,
                       pos=(msg_btn_x, 1, .01),
                       frameColor=(1, 1, 1, 1),
                       frameTexture=img_path,
                       command=cb,
                       extraArgs=[usr_name],
                       **menu_args.imgbtn_args)
     self.btn.bind(ENTER, self.on_enter)
     self.btn.bind(EXIT, self.on_exit)
     self.tooltip_btn = DirectButton(parent=parent,
                                     scale=.024,
                                     pos=(msg_btn_x, 1, .01),
                                     frameColor=(1, 1, 1, 0),
                                     frameSize=(-1, 1, -1, 1),
                                     command=None,
                                     **menu_args.imgbtn_args)
     self.tooltip_btn.bind(ENTER, self.on_enter)
     self.tooltip_btn.bind(EXIT, self.on_exit)
     self.on_create()
     self.tooltip = DirectLabel(text=tooltip,
                                pos=self.btn.get_pos() +
                                self.tooltip_offset,
                                parent=parent,
                                text_wordwrap=10,
                                text_bg=(.2, .2, .2, .8),
                                text_align=self.tooltip_align,
                                **lab_args)
     self.tooltip.set_bin('gui-popup', 10)
     self.tooltip.hide()
コード例 #9
0
 def __init__(self, menu_args):
     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_args = menu_args
     t_a = menu_args.text_args
     t_a['scale'] = .05
     t_a['fg'] = menu_args.text_normal
     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,
                             pos=(.7, 1, .42),
                             frameColor=(1, 1, 1, 1),
                             frameTexture='assets/images/gui/arrow.txo',
                             command=self.on_arrow,
                             **menu_args.imgbtn_args)
     self.arrow_btn.disable()
     self.close_btn = ImgBtn(parent=self.msg_frm,
                             scale=.024,
                             pos=(.76, 1, .42),
                             frameColor=(1, 1, 1, 1),
                             frameTexture='assets/images/gui/close.txo',
                             command=self.on_close,
                             **menu_args.imgbtn_args)
     self.close_btn.disable()
     self.ent = Entry(scale=.04,
                      pos=(0, 1, .03),
                      entryFont=menu_args.font,
                      width=19.5,
                      frameColor=menu_args.btn_color,
                      parent=self.msg_frm,
                      initialText=_('write here your message'),
                      command=self.on_typed_msg,
                      focusInCommand=self.on_focus,
                      focusInExtraArgs=['in'],
                      focusOutCommand=self.on_focus,
                      focusOutExtraArgs=['out'],
                      text_fg=menu_args.text_active)
     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_args.label_args
     lab_args['scale'] = .046
     lab_args['text_fg'] = menu_args.text_normal
     self.lab_frm = Btn(frameSize=(-.02, .64, -.01, .05),
                        frameColor=(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 = DirectLabel(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()
コード例 #10
0
    def show(self, race_ranking, lap_times, players):
        track = self.rprops.track_path
        self.players = players
        self.result_frm = DirectFrame(frameColor=(.8, .8, .8, .64),
                                      frameSize=(-2, 2, -1, 1))
        laps = len(lap_times)
        text_bg = self.rprops.season_props.gameprops.menu_props.text_normal_col
        pars = {
            'scale': .1,
            'fg': text_bg,
            'font': self.rprops.season_props.gameprops.menu_props.font
        }
        self.__res_txts = [
            OnscreenText(str(round(lap_times[i], 2)),
                         pos=(0, .52 - .2 * (i + 1)),
                         **pars) for i in range(laps)
        ]
        self.__res_txts += [OnscreenText(_('LAP'), pos=(-.6, .68), **pars)]
        self.__res_txts += [OnscreenText(_('TIME'), pos=(0, .68), **pars)]
        self.__res_txts += [
            OnscreenText(_('RANKING'),
                         pos=(.5, .68),
                         align=TextNode.A_left,
                         **pars)
        ]
        self.__res_txts += [
            OnscreenText(str(i), pos=(-.6, .52 - .2 * i), **pars)
            for i in range(1, 4)
        ]
        race_ranking_sorted = sorted(race_ranking.items(), key=lambda x: x[1])
        race_ranking_sorted = reversed([el[0] for el in race_ranking_sorted])

        for i, car in enumerate(race_ranking_sorted):
            dpars = i, car, .76, .54, str(i + 1) + '. %s'
            txt, img = RankingGui.set_drv_txt_img(self, *dpars, self.players)
            self.__res_txts += [txt, img]
        self.__res_txts += [
            OnscreenText(_('share:'),
                         pos=(-.1, -.82),
                         align=TextNode.A_right,
                         **pars)
        ]
        self._buttons = []

        min_time = min(lap_times or [0])
        facebook_url = self.rprops.share_urls[0]
        twitter_url = self.rprops.share_urls[1]
        twitter_url = twitter_url.format(time=round(min_time, 2), track=track)
        # plus_url = self.rprops.share_urls[2]
        # tumblr_url = self.rprops.share_urls[3]
        sites = [('facebook', facebook_url), ('twitter', twitter_url)]
        # ('google_plus', plus_url), ('tumblr', tumblr_url)
        menu_props = self.rprops.season_props.gameprops.menu_props
        self._buttons += [
            ImgBtn(scale=(.078, .078),
                   pos=(.02 + i * .18, -.79),
                   frame_col=(0, 0, 0, 0),
                   img=menu_props.social_imgs_dirpath % site[0],
                   cmd=self.eng.open_browser,
                   extra_args=[site[1]],
                   over_snd=menu_props.over_sfx,
                   click_snd=menu_props.click_sfx)
            for i, site in enumerate(sites)
        ]

        def step():
            if self.eng.server.is_active:
                self.eng.server.send([NetMsgs.end_race])
            self.notify('on_race_step', race_ranking)
            self.destroy()
            GameObject.destroy(self)

        cont_btn = Btn(
            text=_('Continue'),
            pos=(0, -.6),
            cmd=step,
            **self.rprops.season_props.gameprops.menu_props.btn_args)
        self._buttons += [cont_btn]
        for i in range(self.eng.joystick_mgr.joystick_lib.num_joysticks):
            self.accept('joypad%s-face_a-up' % i, step)
コード例 #11
0
ファイル: driverpage.py プロジェクト: cflavio/yorg
    def build(self, exit_behav):
        self.drv_info = self.props.gameprops.drivers_info
        menu_props = self.menu_props
        widgets = [Text(_('Select the driver'), pos=(0, .8),
                                **menu_props.text_args)]
        t_a = self.menu_props.text_args.copy()
        del t_a['scale']
        self.name = Text(_('Write your name:'), pos=(-.1, .6), 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, .3 - 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, .01 - 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'), .09), (_('speed'), .21),
                       (_('stability'), .15)]
            widgets += list(map(
                lambda lab_def: self._add_lab(*(lab_def + (row, col))),
                lab_lst))
            txt_lst = [(self.drv_info[idx - 1].adherence, .09),
                       (self.drv_info[idx - 1].speed, .21),
                       (self.drv_info[idx - 1].stability, .15)]
            widgets += list(map(
                lambda txt_def: self._add_txt(
                    *txt_def + (psign, pcol, col, row)),
                txt_lst))
        self.sel_drv_img = Img(
            self.props.gameprops.cars_img % self.mediator.car,
            parent=base.a2dBottomLeft, pos=(.3, .4), scale=.28)
        instr_txt = _(
            'If you use the keyboard, press FIRE to edit the field, then '
            "ENTER when you're done")
        instr = Text(instr_txt, pos=(1.4, .6), scale=.042, wordwrap=16, **t_a)
        widgets += [self.sel_drv_img, self.name, instr]
        self.add_widgets(widgets)
        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.set_shader(shader)
        self.sel_drv_img.set_transparent()
        self.t_s = TextureStage('ts')
        self.t_s.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.set_texture(self.t_s, tex)
        ThanksPageGui.build(self, exit_behav=exit_behav)
コード例 #12
0
class MessageFrm(GameObject):
    def __init__(self, menu_args):
        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_args = menu_args
        t_a = menu_args.text_args
        t_a['scale'] = .05
        t_a['fg'] = menu_args.text_normal
        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,
                                pos=(.7, 1, .42),
                                frameColor=(1, 1, 1, 1),
                                frameTexture='assets/images/gui/arrow.txo',
                                command=self.on_arrow,
                                **menu_args.imgbtn_args)
        self.arrow_btn.disable()
        self.close_btn = ImgBtn(parent=self.msg_frm,
                                scale=.024,
                                pos=(.76, 1, .42),
                                frameColor=(1, 1, 1, 1),
                                frameTexture='assets/images/gui/close.txo',
                                command=self.on_close,
                                **menu_args.imgbtn_args)
        self.close_btn.disable()
        self.ent = Entry(scale=.04,
                         pos=(0, 1, .03),
                         entryFont=menu_args.font,
                         width=19.5,
                         frameColor=menu_args.btn_color,
                         parent=self.msg_frm,
                         initialText=_('write here your message'),
                         command=self.on_typed_msg,
                         focusInCommand=self.on_focus,
                         focusInExtraArgs=['in'],
                         focusOutCommand=self.on_focus,
                         focusOutExtraArgs=['out'],
                         text_fg=menu_args.text_active)
        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_args.label_args
        lab_args['scale'] = .046
        lab_args['text_fg'] = menu_args.text_normal
        self.lab_frm = Btn(frameSize=(-.02, .64, -.01, .05),
                           frameColor=(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 = DirectLabel(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()

    def on_enter(self, pos):
        self.tooltip.show()

    def on_exit(self, pos):
        self.tooltip.hide()

    def show(self):
        self.msg_frm.show()

    def hide(self):
        self.msg_frm.hide()

    def add_msg_txt(self, msg):
        self.msg_txt['text'] += ('\n' if self.msg_txt['text'] else '') + msg
        txt_height = self.msg_txt.textNode.getUpperLeft3d()[2] - \
            self.msg_txt.textNode.getLowerRight3d()[2]
        self.txt_frm['canvasSize'] = (-.02, .72, .28 - txt_height, .28)

    def set_title(self, title):
        ttitle = self.trunc(title, 32)
        fix_name = lambda name: name if '@' not in name else name.split('@')[
            0] + '\1smaller\1@' + name.split('@')[1] + '\2'
        if title:
            if ',' in ttitle:
                is_muc = True
                ttitle = ttitle
                names = ttitle.split(',')
                names = [name.strip() for name in names]
                names = [fix_name(name) for name in names]
                ttitle = ', '.join(names)
            else:
                ttitle = fix_name(ttitle)
        self.dst_txt['text'] = ttitle
        self.tooltip['text'] = title

    @staticmethod
    def trunc(name, lgt):
        if len(name) > lgt: return name[:lgt] + '...'
        return name

    def set_chat(self, chat):
        self.curr_chat = chat
        self.set_title(chat.title)
        self.msg_txt['text'] = '\n'.join(chat.messages)
        txt_height = self.msg_txt.textNode.getUpperLeft3d()[2] - \
            self.msg_txt.textNode.getLowerRight3d()[2]
        self.txt_frm['canvasSize'] = (-.02, .72, .28 - txt_height, .28)
        if not self.chats:
            self.close_btn.disable()
            self.ent['state'] = DISABLED
        elif len(self.chats) == 1:
            self.close_btn.enable()
            self.ent['state'] = NORMAL
            self.arrow_btn.disable()
        else:
            self.close_btn.enable()
            self.ent['state'] = NORMAL
            self.arrow_btn.enable()
        if all(_chat.read for _chat in self.chats):
            self.arrow_btn['frameTexture'] = 'assets/images/gui/arrow.txo'
        else:
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_arrow(self):
        chat_idx = self.chats.index(self.curr_chat)
        next_idx = (chat_idx + 1) % len(self.chats)
        chat = self.chats[next_idx]
        self.set_title(chat.title)
        chat.read = True
        self.set_chat(chat)

    @property
    def open_chats(self):
        return [chat for chat in self.chats if not chat.closed]

    def on_close(self):
        if self.curr_chat not in self.open_chats: return
        curr_idx = self.open_chats.index(self.curr_chat)
        #self.chats.remove(self.curr_chat)
        self.curr_chat.closed = True
        if self.open_chats:
            self.set_chat(self.open_chats[curr_idx - 1])
        else:
            self.set_chat(Chat(''))
            self.notify('on_close_all_chats')

    def on_typed_msg(self, val):
        self.add_msg_txt('\1italic\1' + _('you') + '\2: ' + val)
        self.ent.set('')
        if self.curr_chat.dst not in self.presences_sent and \
                not str(self.curr_chat.dst).startswith('yorg'):
            self.eng.xmpp.client.send_presence(
                pfrom=self.eng.xmpp.client.boundjid.full,
                pto=self.curr_chat.dst)
            self.presences_sent += [self.curr_chat.dst]
        if str(self.curr_chat.dst).startswith('yorg'):
            self.eng.xmpp.client.send_message(
                mfrom=self.eng.xmpp.client.boundjid.full,
                mto=self.curr_chat.dst,
                mtype='groupchat',
                mbody=val)
        else:
            self.eng.xmpp.client.send_message(
                mfrom=self.eng.xmpp.client.boundjid.full,
                mto=self.curr_chat.dst,
                msubject='chat',
                mbody=val)
        msg = '\1italic\1' + _('you') + '\2: ' + val
        self.curr_chat.messages += [msg]
        self.ent['focus'] = 1

    def on_msg(self, msg):
        src = str(JID(msg['from']).bare)
        src = src.split('@')[0] + '\1smaller\1@' + src.split('@')[1] + '\2'
        str_msg = '\1italic\1' + src + '\2: ' + str(msg['body'])
        chat = self.__find_chat(msg['from'])
        if not chat:
            chat = Chat(msg['from'])
            self.chats += [chat]
        chat.messages += [str_msg]
        if self.dst_txt['text'] == '':
            self.set_chat(chat)
        elif JID(self.curr_chat.dst).bare == JID(msg['from']).bare:
            self.add_msg_txt(str_msg)
        else:
            chat.read = False
            chat.closed = False
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_groupchat_msg(self, msg):
        if str(JID(msg['from']).bare) == self.curr_match_room:
            if self.match_msg_frm:  # we're still in the room page
                self.match_msg_frm.on_groupchat_msg(msg)
        src = str(JID(msg['mucnick']))
        src = src.split('@')[0] + '\1smaller\1@' + src.split('@')[1] + '\2'
        self.eng.log('received groupchat message from %s in the chat %s' %
                     (msg['mucnick'], JID(msg['from']).bare))
        str_msg = '\1italic\1' + src + '\2: ' + str(msg['body'])
        chat = self.curr_chat
        if not chat:
            chat = MUC(str(JID(msg['from']).bare))
            self.chats += [chat]
        chat.messages += [str_msg]
        if self.dst_txt['text'] == '':
            self.set_chat(chat)
        elif self.curr_chat.dst == str(JID(msg['from']).bare):
            self.add_msg_txt(str_msg)
        else:
            chat.read = False
            chat.closed = False
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_presence_available_room(self, msg):
        if str(JID(msg['from']).bare) == self.curr_match_room:
            self.match_msg_frm.on_presence_available_room(msg)
        room = str(JID(msg['muc']['room']).bare)
        nick = str(msg['muc']['nick'])
        self.eng.log('user %s has logged in the chat %s' % (nick, room))
        chat = self.__find_chat(room)
        chat.users += [nick]
        if str(JID(msg['from']).bare) != self.curr_match_room:
            if self.curr_chat.dst == room:
                self.set_title(chat.title)

    def on_presence_unavailable_room(self, msg):
        if self.match_msg_frm and str(JID(
                msg['from']).bare) == self.curr_match_room:
            self.match_msg_frm.on_presence_unavailable_room(msg)
            return
        room = str(JID(msg['muc']['room']).bare)
        nick = str(msg['muc']['nick'])
        self.eng.log('user %s has left the chat %s' % (nick, room))
        chat = self.__find_chat(room)
        if nick == self.eng.xmpp.client.boundjid.bare:
            self.on_close()
        else:
            chat.users.remove(nick)
            if self.curr_chat.dst == room:
                self.set_title(chat.title)

    def __find_chat(self, dst):
        chats = [chat for chat in self.chats if chat.dst == dst]
        if chats: return chats[0]

    def add_chat(self, usr):
        self.set_title(JID(usr).bare)
        chat = self.__find_chat(usr)
        if not chat:
            chat = Chat(usr)
            self.chats += [chat]
        self.set_chat(chat)
        self.ent['focus'] = 1

    def add_groupchat(self, room, usr):
        self.set_title(usr)
        chat = self.__find_chat(room)
        if not chat:
            chat = MUC(room)
            self.chats += [chat]
        chat.users += [usr]
        self.set_chat(chat)
        self.add_match_chat(room, usr)

    def remove_groupchat(self):
        self.match_msg_frm.detach(self.on_match_msg_focus)
        self.match_msg_frm = self.match_msg_frm.destroy()

    def on_focus(self, val):
        if val and self.ent.get() == _('write here your message'):
            self.ent.set('')
        self.notify('on_msg_focus', val)

    def on_match_msg_focus(self, val):
        self.notify('on_msg_focus', val)

    def on_room_back(self):
        self.curr_match_room = None
        self.match_msg_frm.destroy()

    def add_match_chat(self, room, usr):
        if self.curr_match_room: return
        self.curr_match_room = room
        self.match_msg_frm = MatchMsgFrm(self.menu_args)
        self.match_msg_frm.attach(self.on_match_msg_focus)
        self.match_msg_frm.add_groupchat(room, usr)
コード例 #13
0
 def show(self, players):
     self.background = OnscreenImage(
         self.sprops.gameprops.menu_props.background_img_path,
         scale=(1.77778, 1, 1))
     self.background.setBin('background', 10)
     bprops = {'scale': (.4, .4), 'cmd': self.on_btn}
     self.txt = OnscreenText(
         text=_('What do you want to upgrade?'),
         scale=.1,
         pos=(0, .76),
         font=loader.loadFont(self.sprops.font),
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.buttons = [
         ImgBtn(pos=(-1.2, .1),
                img=self.sprops.tuning_imgs[0],
                extra_args=['engine'],
                **bprops)
     ]
     self.buttons += [
         ImgBtn(pos=(0, .1),
                img=self.sprops.tuning_imgs[1],
                extra_args=['tires'],
                **bprops)
     ]
     self.buttons += [
         ImgBtn(pos=(1.2, .1),
                img=self.sprops.tuning_imgs[2],
                extra_args=['suspensions'],
                **bprops)
     ]
     self._set_events()
     # tuning = self.mediator.car2tuning[self.sprops.player_car_name]
     player_car_name = [
         player.car for player in players if player.kind == Player.human
     ][0]
     tuning = [
         player.tuning for player in players
         if player.car == player_car_name
     ][0]
     self.upg1_txt = OnscreenText(
         text=_('current upgrades: +') + str(tuning.engine),
         scale=.06,
         pos=(-1.53, -.36),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.upg2_txt = OnscreenText(
         text=_('current upgrades: +') + str(tuning.tires),
         scale=.06,
         pos=(-.35, -.36),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.upg3_txt = OnscreenText(
         text=_('current upgrades: +') + str(tuning.suspensions),
         scale=.06,
         pos=(.85, -.36),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.hint1_txt = OnscreenText(
         text=_("engine: it increases car's maximum speed"),
         scale=.06,
         pos=(-1.53, -.46),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.hint2_txt = OnscreenText(
         text=_("tires: they increase car's adherence"),
         scale=.06,
         pos=(-.35, -.46),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
     self.hint3_txt = OnscreenText(
         text=_("suspensions: they increase car's stability"),
         scale=.06,
         pos=(.85, -.46),
         font=loader.loadFont(self.sprops.font),
         wordwrap=12,
         align=TextNode.ALeft,
         fg=self.sprops.gameprops.menu_props.text_normal_col)
コード例 #14
0
ファイル: driverpage.py プロジェクト: cflavio/yorg
    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)
        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=self.props.gameprops.player_name or _('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)
コード例 #15
0
ファイル: driverpage.py プロジェクト: oriolrg/yorg
    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)
コード例 #16
0
    def build(self, exit_behav):
        self.drv_info = self.props.gameprops.drivers_info
        menu_args = self.menu_args
        widgets = [Text(_('Select the driver'), pos=(-.2, .8),
                                **menu_args.text_args)]
        t_a = self.menu_args.text_args.copy()
        del t_a['scale']
        self.name = Text(_('Write your name:'), pos=(-.3, .6), 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, pos=(-.95 + col * .5, 1, .3 - row * .64),
                frameColor=(0, 0, 0, 0),
                image=self.props.gameprops.drivers_img.path % idx,
                command=self.on_click, extraArgs=[idx],
                **self.menu_args.imgbtn_args)
            name = Text(
                '',
                pos=(-.95 + col * .5, .01 - row * .64),
                scale=.046, **t_a)
            drv_btn._name_txt = name
            widgets += [drv_btn, name]
            self.drivers += [widgets[-1]]
            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'), .09), (_('speed'), .21),
                       (_('stability'), .15)]
            widgets += map(
                lambda lab_def: self.__add_lab(*(lab_def + (row, col))),
                lab_lst)
            txt_lst = [(self.drv_info[idx - 1].adherence, .09),
                       (self.drv_info[idx - 1].speed, .21),
                       (self.drv_info[idx - 1].stability, .15)]
            widgets += map(
                lambda txt_def: self.__add_txt(
                    *txt_def + (psign, pcol, col, row)),
                txt_lst)
        self.sel_drv_img = Img(
            self.props.gameprops.cars_img % self.mediator.car,
            parent=base.a2dBottomLeft, pos=(.3, 1, .4), scale=.28)
        widgets += [self.sel_drv_img, self.name]
        self.add_widgets(widgets)
        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.set_shader(shader)
        self.sel_drv_img.set_transparency(True)
        self.t_s = TextureStage('ts')
        self.t_s.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.set_texture(self.t_s, tex)
        ThanksPageGui.build(self, exit_behav=exit_behav)
コード例 #17
0
ファイル: messagefrm.py プロジェクト: cflavio/yorg
class MessageFrm(GameObject):

    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()

    def on_enter(self, pos):
        self.tooltip.show()

    def on_exit(self, pos):
        self.tooltip.hide()

    def show(self):
        self.msg_frm.show()

    def hide(self):
        self.msg_frm.hide()

    def add_msg_txt(self, msg):
        self.msg_txt['text'] += ('\n' if self.msg_txt['text'] else '') + msg
        txt_height = self.msg_txt.textNode.getUpperLeft3d()[2] - \
            self.msg_txt.textNode.getLowerRight3d()[2]
        self.txt_frm['canvasSize'] = (-.02, .72, .28 - txt_height, .28)

    def set_title(self, title):
        ttitle = self.trunc(title, 32)
        fix_name = lambda name: name if '@' not in name else name.split('@')[0] + '\1smaller\1@' + name.split('@')[1] + '\2'
        if title:
            if ',' in ttitle:
                is_muc = True
                ttitle = ttitle
                names = ttitle.split(',')
                names = [name.strip() for name in names]
                names = [fix_name(name) for name in names]
                ttitle = ', '.join(names)
            else:
                ttitle = fix_name(ttitle)
        self.dst_txt['text'] = ttitle
        self.tooltip['text'] = title

    @staticmethod
    def trunc(name, lgt):
        if len(name) > lgt: return name[:lgt] + '...'
        return name

    def set_chat(self, chat):
        self.curr_chat = chat
        self.set_title(chat.title)
        self.msg_txt['text'] = '\n'.join(chat.messages)
        txt_height = self.msg_txt.textNode.getUpperLeft3d()[2] - \
            self.msg_txt.textNode.getLowerRight3d()[2]
        self.txt_frm['canvasSize'] = (-.02, .72, .28 - txt_height, .28)
        if not self.chats:
            self.close_btn.disable()
            self.ent['state'] = DISABLED
        elif len(self.chats) == 1:
            self.close_btn.enable()
            self.ent['state'] = NORMAL
            self.arrow_btn.disable()
        else:
            self.close_btn.enable()
            self.ent['state'] = NORMAL
            self.arrow_btn.enable()
        if all(_chat.read for _chat in self.chats):
            self.arrow_btn['frameTexture'] = 'assets/images/gui/arrow.txo'
        else:
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_arrow(self):
        chat_idx = self.chats.index(self.curr_chat)
        next_idx = (chat_idx + 1) % len(self.chats)
        chat = self.chats[next_idx]
        self.set_title(chat.title)
        chat.read = True
        self.set_chat(chat)

    @property
    def open_chats(self):
        return [chat for chat in self.chats if not chat.closed]

    def on_close(self):
        if self.curr_chat not in self.open_chats: return
        curr_idx = self.open_chats.index(self.curr_chat)
        #self.chats.remove(self.curr_chat)
        self.curr_chat.closed = True
        if self.open_chats:
            self.set_chat(self.open_chats[curr_idx - 1])
        else:
            self.set_chat(Chat(''))
            self.notify('on_close_all_chats')

    def on_typed_msg(self, val):
        self.add_msg_txt('\1italic\1' + _('you') + '\2: ' + val)
        self.ent.set('')
        #if self.curr_chat.dst not in self.presences_sent and \
        #        not str(self.curr_chat.dst).startswith('yorg'):
        #    self.eng.xmpp.client.send_presence(
        #        pfrom=self.eng.xmpp.client.boundjid.full,
        #        pto=self.curr_chat.dst)
        #    self.presences_sent += [self.curr_chat.dst]
        #if str(self.curr_chat.dst).startswith('yorg'):
        #    self.eng.xmpp.client.send_message(
        #        mfrom=self.eng.xmpp.client.boundjid.full,
        #        mto=self.curr_chat.dst,
        #        mtype='groupchat',
        #        mbody=val)
        #else:
        #    self.eng.xmpp.client.send_message(
        #        mfrom=self.eng.xmpp.client.boundjid.full,
        #        mto=self.curr_chat.dst,
        #        msubject='chat',
        #        mbody=val)
        if len(self.curr_chat.dst) > 12 and all(char.isdigit() for char in self.curr_chat.dst[-12:]):
            self.eng.client.send([
                'msg_room', self.eng.client.myid, self.curr_chat.dst, val])
        else:
            self.eng.client.send(['msg', self.eng.client.myid, self.curr_chat.dst, val])
        msg = '\1italic\1' + _('you') + '\2: ' + val
        self.curr_chat.messages += [msg]
        self.ent['focus'] = 1

    def on_msg(self, from_, to, txt):
        #src = str(JID(msg['from']).bare)
        #src = src.split('@')[0] + '\1smaller\1@' + src.split('@')[1] + '\2'
        str_msg = '\1italic\1' + from_ + '\2: ' + txt
        chat = self.__find_chat(from_)
        if not chat:
            chat = Chat(from_)
            self.chats += [chat]
        chat.messages += [str_msg]
        if self.dst_txt['text'] == '':
            self.set_chat(chat)
        elif self.curr_chat.dst == from_:
            self.add_msg_txt(str_msg)
        else:
            chat.read = False
            chat.closed = False
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_groupchat_msg(self, from_, to, txt):
        #if str(JID(msg['from']).bare) == self.curr_match_room:
        if to == self.curr_match_room:
            if self.match_msg_frm:  # we're still in the room page
                self.match_msg_frm.on_groupchat_msg(from_, to, txt)
        #src = str(JID(msg['mucnick']))
        #src = src.split('@')[0] + '\1smaller\1@' + src.split('@')[1] + '\2'
        src = from_
        #self.eng.log('received groupchat message from %s in the chat %s' %(msg['mucnick'], JID(msg['from']).bare))
        self.eng.log('received groupchat message from %s in the chat %s' % (from_, to))
        #str_msg = '\1italic\1' + src + '\2: ' + str(msg['body'])
        str_msg = '\1italic\1' + src + '\2: ' + txt
        chat = self.curr_chat
        if not chat:
            #chat = MUC(str(JID(msg['from']).bare))
            chat = MUC(to)
            self.chats += [chat]
        chat.messages += [str_msg]
        if self.dst_txt['text'] == '':
            self.set_chat(chat)
        #elif self.curr_chat.dst == str(JID(msg['from']).bare):
        elif self.curr_chat.dst == to:
            self.add_msg_txt(str_msg)
        else:
            chat.read = False
            chat.closed = False
            self.arrow_btn['frameTexture'] = 'assets/images/gui/message.txo'

    def on_presence_available_room(self, uid, room):
        if room == self.curr_match_room:
            self.match_msg_frm.on_presence_available_room(uid, room)
        #room = str(JID(msg['muc']['room']).bare)
        #nick = str(msg['muc']['nick'])
        self.eng.log('user %s has logged in the chat %s' %(uid, room))
        chat = self.__find_chat(room)
        chat.users += [uid]
        if room != self.curr_match_room:
            if self.curr_chat.dst == room:
                self.set_title(chat.title)

    def on_presence_unavailable_room(self, uid, room_name):
        if self.match_msg_frm and room_name == self.curr_match_room:
            self.match_msg_frm.on_presence_unavailable_room(uid, room_name)
            return
        room = room_name
        nick = uid
        self.eng.log('user %s has left the chat %s' %(nick, room))
        chat = self.__find_chat(room)
        if nick == self.eng.client.myid:
            self.on_close()
        else:
            chat.users.remove(nick)
            if self.curr_chat.dst == room:
                self.set_title(chat.title)

    def __find_chat(self, dst):
        chats = [chat for chat in self.chats if chat.dst == dst]
        if chats: return chats[0]

    def add_chat(self, usr):
        #self.set_title(JID(usr).bare)
        chat = self.__find_chat(usr)
        if not chat:
            chat = Chat(usr)
            self.chats += [chat]
        self.set_chat(chat)
        self.ent['focus'] = 1

    def add_groupchat(self, room, usr):
        self.set_title(usr)
        chat = self.__find_chat(room)
        if not chat:
            chat = MUC(room)
            self.chats += [chat]
        chat.users += [usr]
        self.set_chat(chat)
        self.add_match_chat(room, usr)

    def remove_groupchat(self):
        self.match_msg_frm.detach(self.on_match_msg_focus)
        self.match_msg_frm = self.match_msg_frm.destroy()

    def on_focus(self, val):
        if val and self.ent.get() == _('write here your message'):
            self.ent.set('')
        self.notify('on_msg_focus', val)

    def on_match_msg_focus(self, val):
        self.notify('on_msg_focus', val)

    def on_room_back(self):
        self.curr_match_room = None
        self.match_msg_frm.destroy()

    def add_match_chat(self, room, usr):
        if self.curr_match_room: return
        self.curr_match_room = room
        self.match_msg_frm = MatchMsgFrm(self.menu_props)
        self.match_msg_frm.attach(self.on_match_msg_focus)
        self.match_msg_frm.add_groupchat(room, usr)
コード例 #18
0
class MPBtn(GameObject):

    tooltip_align = TextNode.A_right
    tooltip_offset = (.01, 0, -.08)

    def __init__(self, parent, owner, menu_args, img_path, msg_btn_x, cb,
                 usr_name, tooltip):
        GameObject.__init__(self)
        self.owner = owner
        lab_args = menu_args.label_args
        lab_args['scale'] = .046
        #lab_args['text_fg'] = menu_args.text_normal
        self.btn = ImgBtn(parent=parent,
                          scale=.024,
                          pos=(msg_btn_x, 1, .01),
                          frameColor=(1, 1, 1, 1),
                          frameTexture=img_path,
                          command=cb,
                          extraArgs=[usr_name],
                          **menu_args.imgbtn_args)
        self.btn.bind(ENTER, self.on_enter)
        self.btn.bind(EXIT, self.on_exit)
        self.tooltip_btn = DirectButton(parent=parent,
                                        scale=.024,
                                        pos=(msg_btn_x, 1, .01),
                                        frameColor=(1, 1, 1, 0),
                                        frameSize=(-1, 1, -1, 1),
                                        command=None,
                                        **menu_args.imgbtn_args)
        self.tooltip_btn.bind(ENTER, self.on_enter)
        self.tooltip_btn.bind(EXIT, self.on_exit)
        self.on_create()
        self.tooltip = DirectLabel(text=tooltip,
                                   pos=self.btn.get_pos() +
                                   self.tooltip_offset,
                                   parent=parent,
                                   text_wordwrap=10,
                                   text_bg=(.2, .2, .2, .8),
                                   text_align=self.tooltip_align,
                                   **lab_args)
        self.tooltip.set_bin('gui-popup', 10)
        self.tooltip.hide()

    def on_create(self):
        self.btn.hide()
        self.tooltip_btn.hide()

    def is_hidden(self):
        return self.btn.is_hidden()

    def show(self):
        if self.btn['state'] == DISABLED:
            self.tooltip_btn.show()
        else:
            self.tooltip_btn.hide()
        return self.btn.show()

    def hide(self):
        self.tooltip_btn.hide()
        return self.btn.hide()

    def enable(self):
        self.tooltip_btn.hide()
        return self.btn.enable()

    def disable(self):
        self.tooltip_btn.show()
        return self.btn.disable()

    def on_enter(self, pos):
        self.owner.on_enter(pos)
        self.tooltip.show()

    def on_exit(self, pos):
        self.owner.on_exit(pos)
        self.tooltip.hide()
コード例 #19
0
    def bld_page(self):
        self.skills = [drv[2] for drv in self.props.drivers]
        menu_gui = self.mdt.menu.gui
        menu_args = self.mdt.menu.gui.menu_args
        widgets = [
            OnscreenText(text=_('Select the driver'),
                         pos=(0, .8),
                         **menu_gui.menu_args.text_args)
        ]
        self.track_path = self.mdt.menu.track
        t_a = self.mdt.menu.gui.menu_args.text_args.copy()
        del t_a['scale']
        name = OnscreenText(_('Write your name:'),
                            pos=(-.1, .6),
                            scale=.06,
                            align=TextNode.A_right,
                            **t_a)
        self.ent = DirectEntry(scale=.08,
                               pos=(0, 1, .6),
                               entryFont=menu_args.font,
                               width=12,
                               frameColor=menu_args.btn_color,
                               initialText=self.props.player_name
                               or _('your name'))
        self.ent.onscreenText['fg'] = menu_args.text_fg
        self.drivers = []
        for row, col in product(range(2), range(4)):
            idx = (col + 1) + row * 4
            widgets += [
                ImgBtn(scale=.24,
                       pos=(-.75 + col * .5, 1, .25 - row * .5),
                       frameColor=(0, 0, 0, 0),
                       image=self.props.drivers_img[0] % idx,
                       command=self.on_click,
                       extraArgs=[idx],
                       **self.mdt.menu.gui.menu_args.imgbtn_args)
            ]
            self.drivers += [widgets[-1]]
            sign = lambda x: '\1green\1+\2' if x > 0 else ''
            psign = lambda x: '+' if x == 0 else sign(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)

            def add_lab(txt, pos_z):
                return OnscreenText(txt + ':',
                                    pos=(-.95 + col * .5, pos_z - row * .5),
                                    scale=.046,
                                    align=TextNode.A_left,
                                    **t_a)

            def add_txt(val, pos_z):
                return OnscreenText('%s%s%%' % (psign(val), pcol(val)),
                                    pos=(-.55 + col * .5, pos_z - row * .5),
                                    scale=.052,
                                    align=TextNode.A_right,
                                    **t_a)

            lab_lst = [(_('adherence'), .04), (_('speed'), .16),
                       (_('stability'), .1)]
            widgets += map(lambda lab_def: add_lab(*lab_def), lab_lst)
            txt_lst = [(self.skills[idx - 1][1], .04),
                       (self.skills[idx - 1][0], .16),
                       (self.skills[idx - 1][2], .1)]
            widgets += map(lambda txt_def: add_txt(*txt_def), txt_lst)
        self.img = OnscreenImage(self.props.cars_img % self.mdt.car,
                                 parent=base.a2dBottomRight,
                                 pos=(-.38, 1, .38),
                                 scale=.32)
        widgets += [self.img, name, self.ent]
        map(self.add_widget, widgets)
        fpath = eng.curr_path + 'yyagl/assets/shaders/filter.vert'
        with open(fpath) as ffilter:
            vert = ffilter.read()
        shader = Shader.make(Shader.SL_GLSL, vert, frag)
        self.img.setShader(shader)
        self.img.setTransparency(True)
        self.t_s = TextureStage('ts')
        self.t_s.setMode(TextureStage.MDecal)
        empty_img = PNMImage(1, 1)
        empty_img.add_alpha()
        empty_img.alpha_fill(0)
        tex = Texture()
        tex.load(empty_img)
        self.img.setTexture(self.t_s, tex)
        ThanksPageGui.bld_page(self)
        self.update_tsk = taskMgr.add(self.update_text, 'update text')
        self.enable_buttons(False)
コード例 #20
0
ファイル: button.py プロジェクト: cflavio/yorg
class MPBtn(GameObject):

    tooltip_align = TextNode.A_right
    tooltip_offset = (.01, 0, -.08)

    def __init__(self, parent, owner, menu_props, img_path, msg_btn_x, cb,
                 usr_name, tooltip):
        GameObject.__init__(self)
        self.owner = owner
        lab_args = menu_props.label_args
        lab_args['scale'] = .046
        #lab_args['text_fg'] = menu_props.text_normal_col
        self.btn = ImgBtn(
            parent=parent, scale=(.024, .024), pos=(msg_btn_x, .01),
            frame_col=(1, 1, 1, 1), frame_texture=img_path, cmd=cb,
            extra_args=[usr_name], **menu_props.imgbtn_args)
        self.btn.bind(ENTER, self.on_enter)
        self.btn.bind(EXIT, self.on_exit)
        self.tooltip_btn = Btn(
            parent=parent, scale=(.024, .024), pos=(msg_btn_x, .01),
            frame_col=(1, 1, 1, 0), frame_size=(-1, 1, -1, 1), cmd=None,
            **menu_props.imgbtn_args)
        self.tooltip_btn.bind(ENTER, self.on_enter)
        self.tooltip_btn.bind(EXIT, self.on_exit)
        self.on_create()
        self.tooltip = Label(
            text=tooltip, pos=self.btn.get_pos() + self.tooltip_offset,
            parent=parent, text_wordwrap=10, text_align=self.tooltip_align,
            **lab_args)
        self.tooltip.set_bin('gui-popup', 10)
        self.tooltip.hide()

    def on_create(self):
        self.btn.hide()
        self.tooltip_btn.hide()

    def is_hidden(self): return self.btn.hidden

    def show(self):
        if self.btn['state'] == DISABLED:
            self.tooltip_btn.show()
        else:
            self.tooltip_btn.hide()
        return self.btn.show()

    def hide(self):
        self.tooltip_btn.hide()
        return self.btn.hide()

    def enable(self):
        self.tooltip_btn.hide()
        return self.btn.enable()

    def disable(self):
        self.tooltip_btn.show()
        return self.btn.disable()

    def on_enter(self, pos):
        self.owner.on_enter(pos)
        self.tooltip.show()

    def on_exit(self, pos):
        self.owner.on_exit(pos)
        self.tooltip.hide()
コード例 #21
0
ファイル: messagefrm.py プロジェクト: cflavio/yorg
 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()