Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addons/source-python/packages/source-python/menus/esc.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class PagedESCMenu(SimpleESCMenu, _PagedMenuBase):

def __init__(
self, data=None, select_callback=None, build_callback=None,
description=None, title=None, title_color=WHITE, fill=True):
description=None, title=None, title_color=WHITE, fill=True,
parent_menu=None):
"""Initialize the object.

:param iterable|None data: See :meth:`menus.base._BaseMenu.__init__`.
Expand All @@ -182,6 +183,7 @@ def __init__(
data, select_callback, build_callback,
description, title, title_color)
self.fill = fill
self.parent_menu = parent_menu

@staticmethod
def _get_max_item_count():
Expand Down Expand Up @@ -284,6 +286,10 @@ def _select(self, player_index, choice_index):

# Display previous page?
if choice_index == 6:
# Is the player on the first page, and do we have a parent menu?
if not page_index and self.parent_menu is not None:
return self.parent_menu

self.set_player_page(player_index, page_index - 1)
return self

Expand Down
9 changes: 7 additions & 2 deletions addons/source-python/packages/source-python/menus/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(
self, data=None, select_callback=None,
build_callback=None, description=None,
title=None, top_separator='-' * 30, bottom_separator='-' * 30,
fill=True):
fill=True, parent_menu=None):
"""Initialize the object.

:param iterable|None data: See :meth:`menus.base._BaseMenu.__init__`.
Expand All @@ -165,6 +165,7 @@ def __init__(
self.top_separator = top_separator
self.bottom_separator = bottom_separator
self.fill = fill
self.parent_menu = parent_menu

@staticmethod
def _get_max_item_count():
Expand Down Expand Up @@ -242,7 +243,7 @@ def _format_footer(self, player_index, page, slots):

# TODO: Add translations
# Add "Back" option
back_selectable = page.index > 0
back_selectable = page.index > 0 or self.parent_menu is not None
buffer += PagedRadioOption(
'Back', highlight=back_selectable)._render(
player_index, BUTTON_BACK)
Expand Down Expand Up @@ -295,6 +296,10 @@ def _select(self, player_index, choice_index):

# Display previous page?
if choice_index == BUTTON_BACK:
# Is the player on the first page, and do we have a parent menu?
if not page.index and self.parent_menu is not None:
return self.parent_menu

self.set_player_page(player_index, page.index - 1)
return self

Expand Down