Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor uilist code clean-up #40023

Merged
merged 7 commits into from
May 3, 2020
Merged

Minor uilist code clean-up #40023

merged 7 commits into from
May 3, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Apr 30, 2020

Summary

SUMMARY: Interface "Minor uilist code clean-up"

Purpose of change

Clean up uilist related code a bit.

Describe the solution

Removed class ui_container and merged its members into uilist. This class probably was intended to act as a super class of all in-game menus, but unfortunately it seems that never happened.

Removed uilist::redraw and uilist_callback::redraw. The former one has already been fully incorporated into uilist::show, while the latter one was never used anywhere.

Removed uilist::refresh and incorporated its code into uilist::show where it was called.

Changed all uilist_callback::select overrides to uilist_callback::refresh overrides. To be honest, I cannot for the life of me fathom why uilist_callback::select was used as a redraw callback, nor why uilist_callback::select itself was called in the display code of uilist. Its name suggests that it is a callback that fires when the selection of uilist changes, while its implementation acted like a redraw callback, so this was either a misnomer of the callback function or an extremely poor implementation of the functionality.

Changed uilist_callback::select to fire when the selection actually changes instead of on each redraw. It is not removed because the callback is still useful in future migration of some UIs to ui_adatpor.

Finally, reordered and removed some member fields and functions of uilist to improve memory alignment and reduce bloat.

Testing

Every menu that uses the affected callback classes was tested and working as intended.

@Qrox Qrox requested a review from KorGgenT as a code owner April 30, 2020 06:17
src/ui.h Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` labels Apr 30, 2020
Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

Thanks!

@ifreund ifreund merged commit 8cea0fc into CleverRaven:master May 3, 2020
@Qrox Qrox deleted the uilist branch May 4, 2020 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants