def build_page(self): eng.init_gfx() self.font = self.menu.gui.menu_args.font self.text_fg = self.menu.gui.menu_args.text_fg self.text_bg = self.menu.gui.menu_args.text_bg self.text_err = self.menu.gui.menu_args.text_err self.load_txt = OnscreenText(text=_('LOADING...'), scale=.2, pos=(0, .72), font=self.font, fg=(.75, .75, .75, 1), wordwrap=12) track_number = '' if not self.props.single_race: track_num = self.props.tracks.index(self.props.track_path) + 1 track_number = ' (%s/2)' % track_num track_txt = OnscreenText(text=_('track: ') + self.props.track_name_transl + track_number, scale=.08, pos=(0, .56), font=self.font, fg=self.text_bg, wordwrap=12) self.set_grid() self.set_ranking() self.set_controls() self.widgets += [self.load_txt, track_txt] PageGui.build_page(self, False)
def build(self, back_btn=True): frm = Frame(frame_size=(-1.5, 1.5, -.9, .9), frame_col=(.95, .95, .7, .85)) question_txt = _( "What do you want to do?\n\nNote: use '%s' for pausing the game.") question_txt = question_txt % self.keys.pause menu_props = self.menu_props txt = Text(question_txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_props.text_active_col, font=menu_props.font) on_back = lambda: self.on_end(True) on_end = lambda: self.on_end(False) menu_data = [('back to the game', _('back to the game'), on_back), ('back to the main menu', _('back to the main menu'), on_end)] btn_args = menu_props.btn_args btn_visit = Btn(text=menu_data[0][1], pos=(0, 0), cmd=menu_data[0][2], text_scale=.8, **btn_args) btn_dont_visit = Btn(text=menu_data[1][1], pos=(0, -.5), cmd=menu_data[1][2], text_scale=.8, **btn_args) self.add_widgets([frm, txt, btn_visit, btn_dont_visit]) PageGui.build(self, False) self.eng.show_cursor()
def build(self, back_btn=True): frm = Frame( frame_size=(-1.5, 1.5, -.9, .9), frame_col=(.95, .95, .7, .85)) question_txt = _( "What do you want to do?\n\nNote: use '%s' for pausing the game.") question_txt = question_txt % self.keys.pause menu_props = self.menu_props txt = Text( question_txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_props.text_active_col, font=menu_props.font) on_back = lambda: self.on_end(True) on_end = lambda: self.on_end(False) menu_data = [ ('back to the game', _('back to the game'), on_back), ('back to the main menu', _('back to the main menu'), on_end)] btn_args = menu_props.btn_args btn_visit = Btn( text=menu_data[0][1], pos=(0, 0), cmd=menu_data[0][2], text_scale=.8, **btn_args) btn_dont_visit = Btn( text=menu_data[1][1], pos=(0, -.5), cmd=menu_data[1][2], text_scale=.8, **btn_args) self.add_widgets([frm, txt, btn_visit, btn_dont_visit]) PageGui.build(self, False) self.eng.show_cursor()
def build_page(self): menu_args = self.menu.gui.menu_args self.frm = DirectFrame(frameSize=(-1.5, 1.5, -.9, .9), frameColor=(.95, .95, .7, .85)) txt = _( 'Please, visit our site after exiting!\n\nIt helps us! Thank you!') self.txt = OnscreenText(text=txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_args.text_fg, font=menu_args.font) menu_data = [('visit our site after exiting', _('visit our site after exiting'), lambda: self.on_end(True)), ("don't visit our site after exiting", _("don't visit our site after exiting"), lambda: self.on_end(False))] btn_args = self.menu.gui.btn_args btn_args['frameSize'] = (-12, 12, -.8, 1.2) btn_visit = DirectButton(text=menu_data[0][1], pos=(0, 1, 0), command=menu_data[0][2], text_scale=.9, **btn_args) btn_dont_visit = DirectButton(text=menu_data[1][1], pos=(0, 1, -.5), command=menu_data[1][2], text_scale=.7, **btn_args) widgets = [self.frm, self.txt, btn_visit, btn_dont_visit] map(self.add_widget, widgets) PageGui.build_page(self, False)
def build(self, back_btn=True): # parameters differ from overridden self.eng.init_gfx() self.font = self.mediator.menu.gui.menu_props.font self.text_fg = self.mediator.menu.gui.menu_props.text_active_col self.text_bg = self.mediator.menu.gui.menu_props.text_normal_col self.text_err_col = self.mediator.menu.gui.menu_props.text_err_col self.load_txt = Text(_('LOADING...'), scale=.2, pos=(0, .78), font=self.font, fg=(.75, .75, .75, 1), wordwrap=12) track_number = '' if not self.rprops.season_props.single_race: track_names = self.rprops.season_props.gameprops.season_tracks track_num = track_names.index(self.rprops.track_name) + 1 track_number = ' (%s/%s)' % (track_num, len(track_names)) track_txt = Text(_('track: ') + self.track_name_transl + track_number, scale=.08, pos=(0, .62), font=self.font, fg=self.text_bg, wordwrap=12) self.set_wld_img() self.set_grid() self.set_ranking() self.set_controls() self.set_upgrades() self.add_widgets([self.load_txt, track_txt]) PageGui.build(self, False)
def __init__(self, mediator, menu, rprops, track_name_transl, ranking, players): self.rprops = rprops self.track_name_transl = track_name_transl self.ranking = ranking self._players = players PageGui.__init__(self, mediator, menu.gui.menu_props)
def build(self, back_btn=True): menu_props = self.menu_props frm = Frame( frame_size=(-1.5, 1.5, -.9, .9), frame_col=(.95, .95, .7, .85)) txt = _( 'Please, visit our site after exiting!\n\nIt helps us! Thank you!') txt = Text( txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_props.text_active_col, font=menu_props.font) menu_data = [ ('visit our site after exiting', _('visit our site after exiting'), lambda: self.on_end(True)), ("don't visit our site after exiting", _("don't visit our site after exiting"), lambda: self.on_end(False))] btn_args = self.menu_props.btn_args btn_args['frame_size'] = (-12, 12, -.8, 1.2) btn_visit = Btn( text=menu_data[0][1], pos=(0, 0), cmd=menu_data[0][2], text_scale=.9, **btn_args) btn_dont_visit = Btn( text=menu_data[1][1], pos=(0, -.5), cmd=menu_data[1][2], text_scale=.7, **btn_args) widgets = [frm, txt, btn_visit, btn_dont_visit] self.add_widgets(widgets) PageGui.build(self, False)
def build_page(self): self.frm = DirectFrame(frameSize=(-1.5, 1.5, -.9, .9), frameColor=(.95, .95, .7, .85)) txt = _("What do you want to do?\n\nNB Use 'p' for pausing the game.") menu_args = self.menu.gui.menu_args self.txt = OnscreenText(text=txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_args.text_fg, font=menu_args.font) on_back = lambda: self.on_end(True) on_end = lambda: self.on_end(False) menu_data = [('back to the game', _('back to the game'), on_back), ('back to the main menu', _('back to the main menu'), on_end)] btn_args = self.menu.gui.btn_args btn_visit = DirectButton(text=menu_data[0][1], pos=(0, 1, 0), command=menu_data[0][2], text_scale=.8, **btn_args) btn_dont_visit = DirectButton(text=menu_data[1][1], pos=(0, 1, -.5), command=menu_data[1][2], text_scale=.8, **btn_args) map(self.add_widget, [self.frm, self.txt, btn_visit, btn_dont_visit]) PageGui.build_page(self, False) eng.hide_cursor() eng.show_standard_cursor() eng.do_later(.01, eng.toggle_pause, [False])
def build(self, back_btn=True): frm = Frame( frameSize=(-1.5, 1.5, -.9, .9), frameColor=(.95, .95, .7, .85)) question_txt = _( "What do you want to do?\n\nNote: use '%s' for pausing the game.") question_txt = question_txt % self.keys.pause menu_args = self.menu_args txt = Text( question_txt, pos=(0, .64), scale=.08, wordwrap=32, fg=menu_args.text_active, font=menu_args.font) on_back = lambda: self.on_end(True) on_end = lambda: self.on_end(False) menu_data = [ ('back to the game', _('back to the game'), on_back), ('back to the main menu', _('back to the main menu'), on_end)] btn_args = menu_args.btn_args btn_visit = Btn( text=menu_data[0][1], pos=(0, 1, 0), command=menu_data[0][2], text_scale=.8, **btn_args) btn_dont_visit = Btn( text=menu_data[1][1], pos=(0, 1, -.5), command=menu_data[1][2], text_scale=.8, **btn_args) self.add_widgets([frm, txt, btn_visit, btn_dont_visit]) PageGui.build(self, False) if self.eng.lib.version().startswith('1.10'): self.eng.show_cursor() else: self.eng.hide_cursor() self.eng.show_standard_cursor()
def __init__(self, mediator, menu_props, rprops, sprops, ranking, players): self.rprops = rprops self.sprops = sprops # self.drivers = sprops.drivers self.ranking = ranking self.menu_props = menu_props self.__players = players PageGui.__init__(self, mediator, menu_props)
def translate(self): PageGui.translate(self) curr_lang = self.eng.lang_mgr.lang idx = [ lang for lang in enumerate(self.eng.cfg.lang_cfg.languages) if lang[1][1] == curr_lang ][0][0] self.lang_opt.set(idx, fCommand=0)
def add_lab(txt, txt_tr, pos_z): lab = DirectLabel(text='', pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(lab, txt, txt_tr) self.pagewidgets += [lab] return lab
def bld_page(self): menu_args = self.menu_args t_a = menu_args.text_args t_a['fg'] = menu_args.text_bg t_a['scale'] = .06 self.add_widget(OnscreenText( text=_('Thanks to: ') + Utils().get_thanks(1)[0], pos=(.05, .05), align=TextNode.A_left, parent=base.a2dBottomLeft, **t_a)) PageGui.bld_page(self)
def build_page(self): menu_gui = self.menu.gui text = ', '.join(Utils().get_all_thanks()) txt = OnscreenText(text=text, pos=(0, .6), wordwrap=32, **menu_gui.text_args) self.add_widget(txt) PageGui.build_page(self)
def build_page(self): mp_props = MultiplayerPageProps( self.props.cars, self.props.car_path, self.props.phys_path, self.props.tracks, self.props.tracks_tr, self.props.track_img, self.props.player_name, self.props.drivers_img, self.props.cars_img, self.props.drivers) sp_props = SingleplayerPageProps( self.props.cars, self.props.car_path, self.props.phys_path, self.props.tracks, self.props.tracks_tr, self.props.track_img, self.props.player_name, self.props.drivers_img, self.props.cars_img, self.props.has_save, self.props.season, self.props.season_tracks, self.props.drivers) sp_cb = lambda: self.menu.push_page( SingleplayerPage(self.menu, sp_props)) mp_cb = lambda: self.menu.push_page( MultiplayerPage(self.menu, mp_props)) supp_cb = lambda: eng.open_browser(self.props.support_url) cred_cb = lambda: self.menu.push_page(CreditPage(self.menu)) menu_data = [('Single Player', _('Single Player'), sp_cb), ('Multiplayer', _('Multiplayer'), mp_cb), ('Options', _('Options'), self.on_options), ('Support us', _('Support us'), supp_cb), ('Credits', _('Credits'), cred_cb), ('Quit', _('Quit'), lambda: self.mdt.menu.gui.notify('on_exit'))] menu_gui = self.menu.gui widgets = [ DirectButton(text='', pos=(0, 1, .45 - i * .23), command=menu[2], **menu_gui.btn_args) for i, menu in enumerate(menu_data) ] for i, wdg in enumerate(widgets): PageGui.transl_text(wdg, menu_data[i][0], menu_data[i][1]) if not self.props.multiplayer: widgets[-5]['state'] = DISABLED _fg = menu_gui.btn_args['text_fg'] _fc = widgets[-5]['frameColor'] clc = lambda val: max(0, val) fgc = (_fg[0] - .3, _fg[1] - .3, _fg[2] - .3, _fg[3]) widgets[-5]['text_fg'] = fgc fcc = (clc(_fc[0] - .3), clc(_fc[1] - .3), clc(_fc[2] - .3), _fc[3]) widgets[-5]['frameColor'] = fcc widgets += [ OnscreenImage(self.props.title_img, scale=(.8, 1, .8 * (380.0 / 772)), parent=base.a2dTopRight, pos=(-.8, 1, -.4)) ] widgets[-1].setTransparency(True) map(self.add_widget, widgets) self.set_news() MainPageGui.build_page(self)
def bld_page(self): menu_args = self.menu_args self.pagewidgets = [] self.buttons = [] joypad_lab = DirectLabel(text=_('Use the joypad when present'), pos=(-.1, 1, .8), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(joypad_lab, 'Use the joypad when present', _('Use the joypad when present')) self._joypad_cb = DirectCheckButton( pos=(.09, 1, .82), text='', indicatorValue=self.joystick, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) if not has_pygame(): self._joypad_cb['state'] = DISABLED def add_lab(text, pos_z): self.pagewidgets += [ DirectLabel(text=text, pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) ] def add_btn(text, pos_z): btn = DirectButton(pos=(.46, 1, pos_z), text=text, command=self.start_rec, **menu_args.btn_args) btn['extraArgs'] = [btn] self.pagewidgets += [btn] self.buttons += [btn] buttons_data = [(_('Accelerate'), 'forward', .6), (_('Brake/Reverse'), 'rear', .4), (_('Left'), 'left', .2), (_('Right'), 'right', 0), (_('Weapon'), 'button', -.2), (_('Respawn'), 'respawn', -.4)] for btn_data in buttons_data: add_lab(btn_data[0], btn_data[2]) add_btn(self.keys[btn_data[1]], btn_data[2]) l_a = menu_args.label_args.copy() l_a['scale'] = .065 self.hint_lab = DirectLabel(text=_('Press the key to record it'), pos=(0, 1, -.6), **l_a) self.hint_lab.hide() self.pagewidgets += [joypad_lab, self._joypad_cb, self.hint_lab] map(self.add_widget, self.pagewidgets) ThanksPageGui.bld_page(self)
def build(self, back_btn=True, exit_behav=False): menu_props = self.menu_props t_a = menu_props.text_args t_a['fg'] = menu_props.text_normal_col t_a['scale'] = .06 thanks_txt = Text( _('Thanks to: ') + ThanksNames.get_thanks(1, 3)[0], pos=(.05, .05), align=TextNode.A_left, parent='bottomleft', wordwrap=64, **t_a) self.add_widgets([thanks_txt]) PageGui.build(self, back_btn, exit_behav)
def build(self, back_btn=True, exit_behav=False): menu_args = self.menu_args t_a = menu_args.text_args t_a['fg'] = menu_args.text_normal t_a['scale'] = .06 thanks_txt = Text(_('Thanks to: ') + ThanksNames.get_thanks(1, 3)[0], pos=(.05, .05), align=TextNode.A_left, parent='bottomleft', wordwrap=64, **t_a) self.add_widgets([thanks_txt]) PageGui.build(self, back_btn, exit_behav)
def build(self, back_btn=True): # parameters differ from overridden self.eng.init_gfx() self.font = self.menu_props.font self.text_fg = self.menu_props.text_active_col self.text_bg = self.menu_props.text_normal_col self.text_err_col = self.menu_props.text_err_col # items = self.ranking.carname2points.items() items = [(player.car, player.points) for player in self.__players] sorted_ranking = reversed(sorted(items, key=lambda el: el[1])) txt = Text(_('Ranking'), scale=.1, pos=(0, .76), font=self.font, fg=self.text_bg) self.add_widgets([txt]) for i, car in enumerate(sorted_ranking): txt, img = RankingGui.set_drv_txt_img(self, i, car[0], 0, .52, str(car[1]) + ' %s', self.__players) self.add_widgets([txt, img]) track = self.rprops.track_name ntracks = len(self.sprops.gameprops.season_tracks) if self.sprops.gameprops.season_tracks.index(track) == ntracks - 1: cont_btn_cmd = self.notify cont_btn_ea = ['on_ranking_next_race'] img = Img('assets/images/gui/trophy.txo', parent=base.a2dRightCenter, pos=(-.58, 0), scale=.55) img.set_transparent() txt = Text(_('Congratulations!'), fg=(.8, .6, .2, 1), scale=.16, pos=(0, -.3), font=loader.loadFont(self.sprops.font), parent='leftcenter') txt.set_r(-79) self.add_widgets([txt, img]) else: cont_btn_cmd = self.notify cont_btn_ea = ['on_ranking_end', self.__players] cont_btn = Btn(text=_('Continue'), pos=(0, -.8), cmd=cont_btn_cmd, extra_args=cont_btn_ea, **self.menu_props.btn_args) self.add_widgets([cont_btn]) PageGui.build(self, False)
def update_texts(self): PageGui.update_texts(self) curr_lang = LangMgr().curr_lang self._lang_opt.set({'en': 0, 'it': 1}[curr_lang], fCommand=0)
def destroy(self): if hasattr(self.mdt.menu, 'track'): del self.mdt.menu.track PageGui.destroy(self)
def destroy(self): self.sel_drv_img = None PageGui.destroy(self)
def destroy(self): self.img = None taskMgr.remove(self.update_tsk) PageGui.destroy(self)
def __init__(self, mediator, menu_props, keys): self.keys = keys PageGui.__init__(self, mediator, menu_props)
def __init__(self, mdt, menu, loadingpagegui_props): self.props = loadingpagegui_props PageGui.__init__(self, mdt, menu)
def __init__(self, mediator, menu_args, keys): self.keys = keys PageGui.__init__(self, mediator, menu_args)
def bld_page(self): menu_args = self.menu_args self.pagewidgets = [] def add_lab(txt, txt_tr, pos_z): lab = DirectLabel(text='', pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(lab, txt, txt_tr) self.pagewidgets += [lab] return lab add_lab('Language', _('Language'), .7) self._lang_opt = DirectOptionMenu(text='', items=eng.languages, pos=(.49, 1, .7), initialitem=self.props.lang, command=self.__change_lang, **menu_args.option_args) add_lab('Volume', _('Volume'), .5) self._vol_slider = DirectSlider(pos=(.52, 0, .53), scale=.49, value=self.props.volume, frameColor=menu_args.btn_color, thumb_frameColor=menu_args.text_fg, command=self.__on_volume) add_lab('Fullscreen', _('Fullscreen'), .3) self._fullscreen_cb = DirectCheckButton( pos=(.12, 1, .32), text='', indicatorValue=self.props.fullscreen, indicator_frameColor=menu_args.text_fg, command=lambda val: eng.toggle_fullscreen(), **menu_args.checkbtn_args) add_lab('Resolution', _('Resolution'), .1) res2vec = lambda res: LVector2i(*[int(val) for val in res.split('x')]) self._res_opt = DirectOptionMenu( text='', items=[ 'x'.join([str(el_res) for el_res in res]) for res in eng.resolutions ], pos=(.49, 1, .1), initialitem='x'.join(str(res) for res in eng.closest_res), command=lambda res: eng.set_resolution(res2vec(res)), **menu_args.option_args) add_lab('Antialiasing', _('Antialiasing'), -.1) aa_next_lab = DirectLabel(text='', pos=(.2, 1, -.1), text_align=TextNode.ALeft, **menu_args.label_args) PageGui.transl_text(aa_next_lab, '(from the next execution)', _('(from the next execution)')) self._aa_cb = DirectCheckButton(pos=(.12, 1, -.07), text='', indicatorValue=self.props.aa, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) add_lab('Shaders', _('Shaders'), -.3) self._shaders_cb = DirectCheckButton( pos=(.12, 1, -.27), text='', indicatorValue=self.props.shaders, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) # bld_in = lambda: self.menu.logic.push_page( # InputPage(self.menu, self.props.joystick, self.props.keys)) # it doesn't work if we go forward and back between options and input: # we should update keys input_btn = DirectButton(text='', pos=(0, 1, -.5), command=self.on_input_btn, **menu_args.btn_args) PageGui.transl_text(input_btn, 'Configure input', _('Configure input')) self.pagewidgets += [ self._lang_opt, self._vol_slider, self._fullscreen_cb, self._res_opt, self._aa_cb, aa_next_lab, input_btn, self._shaders_cb ] map(self.add_widget, self.pagewidgets) idx = LangMgr().lang_codes.index(self.props.lang) self.__change_lang(eng.languages[idx]) ThanksPageGui.bld_page(self)
def translate(self): PageGui.translate(self) curr_lang = self.eng.lang_mgr.lang idx = [lang for lang in enumerate(self.eng.cfg.lang_cfg.languages) if lang[1][1] == curr_lang][0][0] self.lang_opt.set(idx, 0)