Permalink
Browse files

refactoring of pages

  • Loading branch information...
cflavio committed Dec 2, 2018
1 parent 8903ead commit 57368730a9e1229e1410ca26f076cb5827088a52
@@ -279,15 +279,18 @@ class CarPage(Page):
gui_cls = CarPageGui
def __init__(self, carpage_props, track_path):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, carpage_props, track_path])]]
GameObject.__init__(self, init_lst)
self.carpage_props = carpage_props
self.track_path = track_path
Page.__init__(self, carpage_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.carpage_props, self.track_path])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -303,14 +306,18 @@ class CarPageClient(CarPage):
gui_cls = CarPageGuiClient
class CarPageLocalMP(CarPage):
class CarPageLocalMP(CarPage, PageFacade):
gui_cls = CarPageLocalMPGui
def __init__(self, carpage_props, track_path, players):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, carpage_props, track_path, players])]]
GameObject.__init__(self, init_lst)
self.carpage_props = carpage_props
self.track_path = track_path
self.players = players
Page.__init__(self, carpage_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls,
[self, self.carpage_props, self.track_path, self.players])]]
@@ -504,15 +504,17 @@ class DriverPage(Page):
def __init__(self, track, car, driverpage_props):
self.track = track
self.car = car
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, driverpage_props])]]
GameObject.__init__(self, init_lst)
self.driverpage_props = driverpage_props
Page.__init__(self, driverpage_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.driverpage_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -526,12 +528,15 @@ class DriverPageMP(DriverPage):
def __init__(self, track, cars, driverpage_props, players):
self.track = track
self.cars = cars
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, driverpage_props, players])]]
GameObject.__init__(self, init_lst)
self.driverpage_props = driverpage_props
self.players = players
DriverPage.__init__(self, driverpage_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.driverpage_props, self.players])]]
class DriverPageServer(DriverPage):
@@ -67,12 +67,15 @@ class InGamePageMultiplayer(Page):
gui_cls = InGamePageGuiMultiplayer
def __init__(self, menu_props, keys):
PageFacade.__init__(self)
self.keys = keys
self.menu_props = menu_props
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.menu_props, keys])]]
GameObject.__init__(self, init_lst)
PageFacade.__init__(self)
Page.__init__(self, menu_props)
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.menu_props, self.keys])]]
class InGamePage(InGamePageMultiplayer):
@@ -217,15 +217,19 @@ class InputPage4(Page):
def __init__(self, menu_props, joysticks, keys):
self.menu_props = menu_props
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.menu_props, joysticks, keys])]]
GameObject.__init__(self, init_lst)
self.joysticks = joysticks
self.keys = keys
Page.__init__(self, menu_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls,
[self, self.menu_props, self.joysticks, self.keys])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -125,17 +125,19 @@ def destroy(self):
ThanksPageGui.destroy(self)
class LogInPage(Page):
class LogInPage(Page, PageFacade):
gui_cls = LogInPageGui
def __init__(self, mp_props):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, mp_props])]]
GameObject.__init__(self, init_lst)
self.mp_props = mp_props
Page.__init__(self, mp_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.mp_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -246,13 +246,16 @@ class YorgMainPage(MainPage, PageFacade):
gui_cls = YorgMainPageGui
def __init__(self, mainpage_props):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, mainpage_props])]]
GameObject.__init__(self, init_lst)
# don't construct it using GameObject
self.mainpage_props = mainpage_props
MainPage.__init__(self, mainpage_props)
PageFacade.__init__(self)
@property
def init_lst(self):
return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.mainpage_props])]]
def destroy(self):
GameObject.destroy(self)
MainPage.destroy(self)
PageFacade.destroy(self)
@@ -34,17 +34,19 @@ def on_btn(self, num):
self.notify('on_push_page', 'trackpagelocalmp', [self.props])
class NumPlayersPage(Page):
class NumPlayersPage(Page, PageFacade):
gui_cls = NumPlayersPageGui
def __init__(self, mp_props):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, mp_props])]]
GameObject.__init__(self, init_lst)
self.mp_props = mp_props
Page.__init__(self, mp_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.mp_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -139,18 +139,20 @@ def _on_back(self):
self.notify('on_back', 'options_page', [dct])
class OptionPage(Page):
class OptionPage(Page, PageFacade):
gui_cls = OptionPageGui
def __init__(self, menu_props, option_props):
self.menu_props = menu_props
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.menu_props, option_props])]]
GameObject.__init__(self, init_lst)
self.option_props = option_props
Page.__init__(self, menu_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst (self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.menu_props, self.option_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -145,17 +145,19 @@ def destroy(self):
ThanksPageGui.destroy(self)
class RegisterPage(Page):
class RegisterPage(Page, PageFacade):
gui_cls = RegisterPageGui
def __init__(self, mp_props):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, mp_props])]]
GameObject.__init__(self, init_lst)
self.mp_props = mp_props
Page.__init__(self, mp_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.mp_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
@@ -26,17 +26,17 @@ def build(self):
self.props.opt_file['settings']['login']['usr'] else \
_('your user id')
self.email_ent = Entry(
scale=.08, pos=(-.15, 1, .4), entryFont=menu_props.font, width=12,
frameColor=menu_props.btn_col, initialText=_('your email'),
scale=.08, pos=(-.15, .4), entry_font=menu_props.font, width=12,
frame_col=menu_props.btn_col, initial_text=_('your email'),
text_fg=menu_props.text_active_col, on_tab=self.on_tab_email,
on_click=self.on_click_email)
self.jid_ent = Entry(
scale=.08, pos=(-.15, 1, .2), entryFont=menu_props.font, width=12,
frameColor=menu_props.btn_col, initialText=init_txt,
scale=.08, pos=(-.15, .2), entry_font=menu_props.font, width=12,
frame_col=menu_props.btn_col, initial_text=init_txt,
text_fg=menu_props.text_active_col, on_tab=self.on_tab_id,
on_click=self.on_click_id)
start_btn = Btn(
text=_('Reset'), pos=(-.2, 1, -.2), command=self.reset,
text=_('Reset'), pos=(-.2, -.2), cmd=self.reset,
**self.props.gameprops.menu_props.btn_args)
t_a['scale'] = .06
widgets = [self.jid_ent, start_btn, jid_lab, email_lab, self.email_ent]
@@ -49,7 +49,7 @@ def process_msg(data_lst, sender):
print sender, data_lst
self.eng.client.start(process_msg)
self.eng.client.register_rpc('reset')
self.ret_val = ret_val = self.eng.client.reset(self.jid_ent.get(), self.email_ent.get())
self.ret_val = ret_val = self.eng.client.reset(self.jid_ent.text, self.email_ent.text)
ok_txt = _(
"We've sent an email to you (please check your spam folder if you "
"can't find it) with the instructions for completing the reset.")
@@ -72,26 +72,26 @@ def on_reset_dlg(self):
def on_frame(self):
init_txt = _('your user id')
curr_txt = self.jid_ent.get()
curr_txt = self.jid_ent.text
if curr_txt == init_txt[:-1]:
self.jid_ent.set('')
elif curr_txt.startswith(init_txt) and len(curr_txt) == len(init_txt) + 1:
self.jid_ent.set(curr_txt[-1:])
init_txt = _('your email')
curr_txt = self.email_ent.get()
curr_txt = self.email_ent.text
if curr_txt == init_txt[:-1]:
self.email_ent.set('')
elif curr_txt.startswith(init_txt) and len(curr_txt) == len(init_txt) + 1:
self.email_ent.set(curr_txt[-1:])
def on_click_email(self, pos):
init_txt = _('your email')
curr_txt = self.email_ent.get()
curr_txt = self.email_ent.text
if curr_txt == init_txt: self.email_ent.set('')
def on_click_id(self, pos):
init_txt = _('your user id')
curr_txt = self.jid_ent.get()
curr_txt = self.jid_ent.text
if curr_txt == init_txt: self.jid_ent.set('')
def on_tab_email(self):
@@ -103,9 +103,9 @@ def on_tab_id(self):
self.jid_ent['focus'] = 0
def on_ok(self):
self.props.opt_file['settings']['login']['usr'] = self.jid_ent.get()
self.props.opt_file['settings']['login']['usr'] = self.jid_ent.text
if self.store_cb['indicatorValue']:
self.props.opt_file['settings']['login']['pwd'] = self.pwd_ent.get()
self.props.opt_file['settings']['login']['pwd'] = self.pwd_ent.text
self.props.opt_file.store()
self._on_back()
self.notify('on_login')
@@ -120,17 +120,19 @@ def destroy(self):
ThanksPageGui.destroy(self)
class ResetPage(Page):
class ResetPage(Page, PageFacade):
gui_cls = ResetPageGui
def __init__(self, mp_props):
init_lst = [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, mp_props])]]
GameObject.__init__(self, init_lst)
self.mp_props = mp_props
Page.__init__(self, mp_props)
PageFacade.__init__(self)
# invoke Page's __init__
@property
def init_lst(self): return [
[('event', self.event_cls, [self])],
[('gui', self.gui_cls, [self, self.mp_props])]]
def destroy(self):
GameObject.destroy(self)
Page.destroy(self)
PageFacade.destroy(self)
Oops, something went wrong.

0 comments on commit 5736873

Please sign in to comment.