Skip to content

Commit

Permalink
added ability to move forwards and backwards through menu
Browse files Browse the repository at this point in the history
  • Loading branch information
adangert committed Jun 20, 2019
1 parent 4ce7865 commit 9277b2e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
4 changes: 4 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def __new__(cls, value, pretty_name, min_players):
def next(self):
"""Return the next game mode after this one in the list. Wraps around after hitting bottom."""
return Games((self.value + 1) % len(Games))

def previous(self):
"""Return the previous game mode after this one in the list. Wraps around after hitting bottom."""
return Games((self.value - 1) % len(Games))

#These buttons are based off of
#The mapping of PS Move controllers
Expand Down
31 changes: 19 additions & 12 deletions piparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Alive(Enum):

class Selections(Enum):
nothing = 0
change_mode = 1
start_game = 2
change_mode_forward = 1
change_mode_backward = 2
add_game = 3
change_sensitivity = 4
change_instructions = 5
Expand Down Expand Up @@ -198,12 +198,12 @@ def track_move(serial, move_num, move, move_opts, force_color, battery, dead_cou
if move_opts[Opts.holding.value] == Holding.not_holding.value:
#Change game mode and become admin controller
if move_button == common.Button.SELECT:
move_opts[Opts.selection.value] = Selections.change_mode.value
move_opts[Opts.selection.value] = Selections.change_mode_backward.value
move_opts[Opts.holding.value] = Holding.holding.value

#start the game
if move_button == common.Button.START:
move_opts[Opts.selection.value] = Selections.start_game.value
move_opts[Opts.selection.value] = Selections.change_mode_forward.value
move_opts[Opts.holding.value] = Holding.holding.value

#as an admin controller add or remove game from convention mode
Expand Down Expand Up @@ -481,24 +481,31 @@ def game_mode_announcement(self):

def check_change_mode(self):
change_mode = False
change_forward = True
for move, move_opt in self.move_opts.items():
if move_opt[Opts.selection.value] == Selections.change_mode.value:
#remove previous admin, and set new one
if move_opt[Opts.selection.value] == Selections.change_mode_forward.value:
#change the game mode if allowed
if self.ns.settings['move_can_be_admin']:
#if self.admin_move:
#self.force_color[self.admin_move][0] = 0
#self.force_color[self.admin_move][1] = 0
#self.force_color[self.admin_move][2] = 0
#self.admin_move = move
change_mode = True
change_forward = True
move_opt[Opts.selection.value] = Selections.nothing.value

if move_opt[Opts.selection.value] == Selections.change_mode_backward.value:
#change the game mode if allowed
if self.ns.settings['move_can_be_admin']:
change_mode = True
change_forward = False
move_opt[Opts.selection.value] = Selections.nothing.value

if self.command_from_web == 'changemode':
self.command_from_web = ''
change_mode = True

if change_mode:
self.game_mode = self.game_mode.next()
if change_forward:
self.game_mode = self.game_mode.next()
else:
self.game_mode = self.game_mode.previous()
self.update_setting('current_game',self.game_mode.name)
self.reset_controller_game_state()
if not self.ns.settings['play_audio']:
Expand Down

0 comments on commit 9277b2e

Please sign in to comment.