Skip to content

Commit

Permalink
Merge pull request #31 from JohnnyonFlame/port_info_popup-pr1
Browse files Browse the repository at this point in the history
[Staging] Completing port_info_popup behavior and sfx overhauls.
  • Loading branch information
kloptops authored Nov 7, 2023
2 parents 2c68cf2 + 7f8d061 commit 83f7d7c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 24 deletions.
63 changes: 43 additions & 20 deletions PortMaster/pylibs/pugscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,18 @@ def set_buttons(self, key_map):
def button_activate(self):
if 'button_bar' not in self.tags:
return

self.gui.sounds.play(self.tags['button_bar'].button_sound, volume=self.tags['button_bar'].button_sound_volume)

def button_back(self):
if 'button_bar' not in self.tags:
return

if self.tags['button_bar'].button_sound_alt is None:
self.button_activate()
else:
self.gui.sounds.play(self.tags['button_bar'].button_sound_alt, volume=self.tags['button_bar'].button_sound_alt_volume)


class BlankScene(BaseScene):
def __init__(self, gui):
Expand Down Expand Up @@ -408,7 +417,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.do_cancel()
return True

Expand Down Expand Up @@ -622,7 +631,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -796,7 +805,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -893,7 +902,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -951,7 +960,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -1010,7 +1019,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -1126,7 +1135,7 @@ def do_update(self, events):
return True

elif events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -1242,7 +1251,7 @@ def do_update(self, events):
return True

if events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

Expand Down Expand Up @@ -1332,25 +1341,31 @@ def __init__(self, gui, options):


class PortInfoPopup(BaseScene):
def __init__(self, gui):
def __init__(self, gui, parent):
super().__init__(gui)
self.scene_title = _("Port Info Popup")

self.parent_info_scene = parent
self.load_regions("port_info_popup", [])

if 'installed' in self.parent_info_scene.port_attrs:
self.set_buttons({'DOWN': _('Hide Information'), 'A': _('Reinstall'), 'Y': _('Uninstall'), 'B': _('Back')})
else:
self.set_buttons({'DOWN': _('Hide Information'), 'A': _('Install'), 'B': _('Back')})


def do_update(self, events):
super().do_update(events)

if events.was_pressed('UP'):
if events.was_pressed('DOWN'):
self.button_back()
self.gui.pop_scene()
return True

if events.was_pressed('DOWN'):
if events.was_pressed('UP'):
return True

return False


class PortInfoScene(BaseScene):
def __init__(self, gui, port_name, action):
super().__init__(gui)
Expand All @@ -1362,12 +1377,17 @@ def __init__(self, gui, port_name, action):
self.action = action
self.ready = False
self.update_port()
buttons = {}

if 'installed' in self.port_attrs:
self.set_buttons({'A': _('Reinstall'), 'Y': _('Uninstall'), 'B': _('Back')})
if 'port_info_popup' in self.gui.theme_data:
buttons['UP'] = _('Show Information')

if 'installed' in self.port_attrs:
buttons.update({'A': _('Reinstall'), 'Y': _('Uninstall'), 'B': _('Back')})
else:
self.set_buttons({'A': _('Install'), 'B': _('Back')})
buttons.update({'A': _('Install'), 'B': _('Back')})

self.set_buttons(buttons)

def update_port(self):
if self.gui.hm is None:
Expand Down Expand Up @@ -1407,13 +1427,15 @@ def do_update(self, events):
self.gui.pop_scene('port_info')

if events.was_pressed('B'):
self.button_activate()
self.button_back()
self.gui.pop_scene()
return True

if events.was_pressed('DOWN'):
if events.was_pressed('UP'):
if 'port_info_popup' in self.gui.theme_data:
self.gui.push_scene('port_info', PortInfoPopup(self.gui))
scene = PortInfoPopup(self.gui, self)
scene.button_activate()
self.gui.push_scene('port_info', scene)

return True

Expand Down Expand Up @@ -1675,6 +1697,7 @@ def do_update(self, events):
return True

if events.was_pressed('B') or events.was_pressed('X'):
self.button_back()
self.gui.pop_scene()
return True

Expand Down
10 changes: 6 additions & 4 deletions PortMaster/pylibs/pySDL2gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,8 @@ def __init__(self, gui, data, name=None, number=0, rects=None):
self.click_sound_volume = self._verify_int('click-sound-volume', 128, optional=True, minimum=0, maximum=128)
self.button_sound = self._verify_text('button-sound', optional=True)
self.button_sound_volume = self._verify_int('button-sound-volume', 128, optional=True, minimum=0, maximum=128)
self.button_sound_alt = self._verify_text('button-sound-alt', optional=True)
self.button_sound_alt_volume = self._verify_int('button-sound-alt-volume', 128, optional=True, minimum=0, maximum=128)

self.scrollable = self._verify_bool('scrollable', False, True)

Expand Down Expand Up @@ -2641,25 +2643,25 @@ def update(self):
if self.gui.events.was_pressed('L1'):
self.list_select(self.selected - self.page_size, direction=-1, allow_wrap=False)

self.gui.sounds.play(self.click_sound)
self.gui.sounds.play(self.click_sound, volume=self.click_sound_volume)
changed = True

elif self.gui.events.was_pressed('R1'):
self.list_select(self.selected + self.page_size, direction=1, allow_wrap=False)

self.gui.sounds.play(self.click_sound)
self.gui.sounds.play(self.click_sound, volume=self.click_sound_volume)
changed = True

elif self.gui.events.was_pressed('UP'):
self.list_select(self.selected - 1, direction=-1, allow_wrap=True)

self.gui.sounds.play(self.click_sound)
self.gui.sounds.play(self.click_sound, volume=self.click_sound_volume)
changed = True

elif self.gui.events.was_pressed('DOWN'):
self.list_select(self.selected + 1, direction=1, allow_wrap=True)

self.gui.sounds.play(self.click_sound)
self.gui.sounds.play(self.click_sound, volume=self.click_sound_volume)
changed = True

elif self.gui.events.was_pressed('LEFT'):
Expand Down

0 comments on commit 83f7d7c

Please sign in to comment.