Skip to content

Allow to hide information about pages in the menu#471

Merged
Ayuto merged 4 commits into
Source-Python-Dev-Team:masterfrom
dronelektron:menu/optional-page-info
Apr 19, 2025
Merged

Allow to hide information about pages in the menu#471
Ayuto merged 4 commits into
Source-Python-Dev-Team:masterfrom
dronelektron:menu/optional-page-info

Conversation

@dronelektron

Copy link
Copy Markdown
Contributor

Sometimes it is not necessary to show navigation, for example, in the admin menu (as in SM)

else:
buffer = ''

buffer += '\n'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That whole block looks quite logically redundant to me. Couldn't we just extend buffer as we go? For example (untested):

buffer = ''
if self.title:
    buffer += _translate_text(self.title, player_index)
if self.show_pages:
    buffer += f' [{page.index + 1}/{self.page_count}]'
buffer = buffer.strip() + '\n'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. Changed and tested the code, everything works fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest the following changes:

buffer = ''
if self.title:
    buffer += _translate_text(self.title, player_index)
if self.show_pages:
    if buffer:
        buffer += ' '
    buffer += f'[{page.index + 1}/{self.page_count}]'
if buffer:
    buffer += '\n'

For 2 reasons:

  • We don't want to add a leading space if there is no title.
  • We don't want to add a new line if there is no title and no pagination.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, thank you! Ideally, we should also add the same features to ESC menus for consistency.

@dronelektron dronelektron May 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for "ListESCMenu" and "PagedESCMenu"

P.S. This type of menu works in "dod" as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I noticed a bug that the "ESC" menu does not close if you click the "Close" button (bottom right) or the cross (top right). Is it normal?

@dronelektron dronelektron May 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to add translation for the "Back", "Next" and "Close" buttons. Or make them language-neutral (at least), such as "<", ">" and "X", but this will be in a separate pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I noticed a bug that the "ESC" menu does not close if you click the "Close" button (bottom right) or the cross (top right). Is it normal?

I'm not entirely sure, but I think the client does not tell the server when the menu is closed via these buttons, so it is getting resent until a selection is actually made.

@dronelektron dronelektron May 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider these two buttons as selection "0" (Close)?

Do not add a leading space if there is no title.
Do not add a new line if there is no title and no pagination.
@Ayuto

Ayuto commented Apr 19, 2025

Copy link
Copy Markdown
Member

Thank you!

@Ayuto Ayuto merged commit 9c78577 into Source-Python-Dev-Team:master Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants