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