def __init__(self, mediator, mainpage_props): self.__feed_type = '' self.__date_field = '' self.props = mainpage_props self.load_settings() self.conn_attempted = False self.ver_check = VersionChecker() MainPageGui.__init__(self, mediator, self.props.gameprops.menu_args) if self.ver_check.is_uptodate(): options = self.props.opt_file user = options['settings']['xmpp']['usr'] password = options['settings']['xmpp']['pwd'] parser = argparse.ArgumentParser() parser.add_argument('--user') parser.add_argument('--pwd') parser.add_argument('--win_orig') args = parser.parse_args() if args.user and args.pwd: user = args.user password = args.pwd if user and password and not self.eng.xmpp.client: # if user: # if platform.startswith('linux'): set_keyring(Keyring()) # pwd = get_password('ya2_rog', user) # if not pwd: pwd = password # set_password('ya2_rog', user, pwd) # self.eng.xmpp.start(user, pwd) self.eng.xmpp.start(user, pwd, self.on_ok, self.on_ko, self.props.gameprops.xmpp_debug) if not (user and password): self.on_ko()
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 __init__(self, mediator, mainpage_props): self.__feed_type = '' self.__date_field = '' self.props = mainpage_props self.load_settings() self.conn_attempted = False if not self.eng.client.netw_thr or \ not self.eng.client.netw_thr.is_running: self.eng.client.restart() self.ver_check = VersionChecker() MainPageGui.__init__(self, mediator, self.props.gameprops.menu_props) if self.ver_check.is_uptodate(): options = self.props.opt_file user = options['settings']['login']['usr'] password = options['settings']['login']['pwd'] parser = argparse.ArgumentParser() parser.add_argument('--user') parser.add_argument('--pwd') parser.add_argument('--win_orig') parser.add_argument('--optfile') args = parser.parse_args(EngineLogic.cmd_line()) if args.user and args.pwd: user = args.user password = args.pwd if user and password and self.eng.client.is_server_up: # if user: # if platform.startswith('linux'): set_keyring(Keyring()) # pwd = get_password('ya2_rog', user) # if not pwd: pwd = password # set_password('ya2_rog', user, pwd) # self.eng.xmpp.start(user, pwd) #self.eng.xmpp.start(user, pwd, self.on_ok, self.on_ko, self.props.gameprops.xmpp_debug) self.eng.client.register_rpc('login') while not self.eng.client.netw_thr: pass # wait for the thread ret_val = 'ok' if not self.eng.client.authenticated: ret_val = self.eng.client.login(user, password) if ret_val in [ 'invalid_nick', 'unregistered_nick', 'wrong_pwd' ]: self.on_ko(ret_val) #return self.on_ko(ret_val) taskMgr.doMethodLater(.1, lambda task: self.on_ok(), 'x') # otherwise the menu is not attached to the page yet if not (user and password): self.on_ko()
def build(self): sp_cb = lambda: self.notify('on_push_page', 'singleplayer', [self.props]) mp_cb = lambda: self.notify('on_push_page', 'multiplayer', [self.props]) supp_cb = lambda: self.eng.open_browser(self.props.support_url) cred_cb = lambda: self.notify('on_push_page', 'credits') 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.notify('on_exit'))] widgets = [ Btn(text='', pos=(0, .64 - i * .23), cmd=menu[2], tra_src=menu_data[i][0], tra_tra=menu_data[i][1], **self.props.gameprops.menu_props.btn_args) for i, menu in enumerate(menu_data) ] logo_img = Img(self.props.title_img, scale=(.64, 1, .64 * (380.0 / 772)), parent=base.a2dTopLeft, pos=(.65, -.32)) widgets += [logo_img] lab_args = self.props.gameprops.menu_props.label_args lab_args['scale'] = .12 lab_args['text_fg'] = self.props.gameprops.menu_props.text_err_col wip_lab = Label(text='', pos=(-.05, -1.58), parent=base.a2dTopRight, text_wordwrap=10, text_align=TextNode.A_right, tra_src='Note: the game is work-in-progress', tra_tra=_('Note: the game is work-in-progress'), **lab_args) self.widgets += [wip_lab] self.add_widgets(widgets) self.set_news() MainPageGui.build(self) if not self.ver_check.is_uptodate(): self.widgets[2]['state'] = DISABLED
def __init__(self, mdt, menu, mainpage_props): self.menu = menu self.props = mainpage_props self.load_settings() MainPageGui.__init__(self, mdt, menu)
def show(self): MainPageGui.show(self) self.widgets[5]['text'] = self.get_label()
def destroy(self): self.ver_check.destroy() MainPageGui.destroy(self)
def build(self): sp_cb = lambda: self.notify('on_push_page', 'singleplayer', [self.props]) supp_cb = lambda: self.eng.open_browser(self.props.support_url) cred_cb = lambda: self.notify('on_push_page', 'credits') menu_data = [('Single Player', _('Single Player'), sp_cb), ('Options', _('Options'), self.on_options), ('Support us', _('Support us'), supp_cb), ('Credits', _('Credits'), cred_cb), ('Not up-to-date', self.get_label(), self.on_loginout), ('Quit', _('Quit'), lambda: self.notify('on_exit'))] widgets = [ Btn(text='', pos=(0, 1, .64 - i * .23), command=menu[2], tra_src=menu_data[i][0], tra_tra=menu_data[i][1], **self.props.gameprops.menu_args.btn_args) for i, menu in enumerate(menu_data) ] logo_img = Img(self.props.title_img, scale=(.64, 1, .64 * (380.0 / 772)), parent=base.a2dTopLeft, pos=(.65, 1, -.32)) widgets += [logo_img] lab_args = self.props.gameprops.menu_args.label_args lab_args['scale'] = .12 lab_args['text_fg'] = self.props.gameprops.menu_args.text_err wip_lab = Label(text='', pos=(.05, 1, -.76), parent=base.a2dTopLeft, text_wordwrap=10, text_align=TextNode.A_left, tra_src='Note: the game is work-in-progress', tra_tra=_('Note: the game is work-in-progress'), **lab_args) self.widgets += [wip_lab] self.add_widgets(widgets) self.set_news() MainPageGui.build(self) if not self.ver_check.is_uptodate(): self.widgets[5]['state'] = DISABLED try: sock = socket(AF_INET, SOCK_DGRAM) sock.connect(('ya2.it', 8080)) local_addr = sock.getsockname()[0] igdc = IGDClient(local_addr, edebug=True) prots = ['TCP', 'UDP'] try: map(lambda prot: igdc.DeletePortMapping(9099, prot), prots) except (TypeError, ExpatError, UPNPError) as e: print e import traceback traceback.print_exc() map(lambda prot: igdc.AddPortMapping(local_addr, 9099, prot, 9099), prots) self.eng.upnp = True except (TypeError, timeout, ExpatError, gaierror) as e: print e import traceback traceback.print_exc() self.eng.upnp = False