-
-
Notifications
You must be signed in to change notification settings - Fork 402
Add ability to sort save files by name or date #9793
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
Conversation
0639f48
to
4df04ce
Compare
Hi @usidedown , without UI changes most of players would never even know about this feature. We have to provide a user-friendly solution and do not rely on the configuration file which is served only for developers. This is a UX design of how we can implement sorting mechanism (provided by @OogaBoogaCode in Discord - https://discord.com/channels/733093692860137523/963076826673070130/1338909387158454445): The initial PR was here: #9560 but I don't know why the author removed everything. To change UI you can start looking at dialog_selectfile.cpp file, |
798830f
to
db9c2d7
Compare
@ihhub UI part is done, let me know how it looks. I'm slightly worried about the performance of clicking the sort button. Not sure if it's worth improving though. There are 2 "heavy" operations:
What do you think? |
Hi @usidedown , don't worry about sorting or search as we are handling at max < 1000 items so this operation is heavy in theory, in reality rendering would be much longer. If we avoid any I/O operations while changing sorting then it doesn't impact the performance too much. And as usual we can always improve performance later. |
@usidedown , could you please also resolve merge conflicts to proceed with the review? |
@ihhub Is the proposed UI design acceptable? I got the impression from discord that we want something different. |
b953f23
to
ee2edb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @usidedown , I put several comments in this pull request. Could you please take a look at them in your free time?
5a5acb4
to
d352958
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @usidedown , I added few more comments here. Would you mind to take a look at them?
0f73122
to
3932fe1
Compare
fd07389
to
36f350c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @usidedown , I added 2 more comments here. Would you mind to take a look at them?
@ihhub thanks for the review |
@zenseii your design definitely looks better! |
Thanks! I can push the needed changes as I did some of them already for the screenshot (it was less work than photoshopping it). I'll expand the height of the header cells too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @usidedown I just made a few changes:
-
Renamed the
Settings::changeSaveFileSortingMethod()
to theSettings::toggleSaveFileSortingMethod()
- it seems to me that this variant reflects its essence better. -
Moved the
CaseInsensitiveCompare()
to thetools.h
(asfheroes2::compareStringsCaseInsensitively()
) since this function is "relatively generic" and can be used in multiple places... But for now it is used just inmaps_fileinfo.cpp
. -
Moved all comparators to the single place so that there will be no confusion if there is a need to change something.
-
Fixed the issue like this:
fheroes2.engine.version_.1.1.8.2025-06-07.22-48-18.mp4
std::lower_bound()
doesn't mean "equality" per se. -
Fixed the similar issue on the case-sensitive filesystems. Given that the current sorting is case-insensitive, there can be multiple "identical" file names with different case.
-
Added a few assertions (for the debug builds only) to check that lists are properly sorted/partitioned before calling
std::lower_bound()
orstd::equal_range()
on them. Attempting to call these functions on an incorrectly sorted list causes undefined behavior.
Could you please take a look at these changes to make sure I didn't miss anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oleg-derevenetz thank you so much for these fixes!
Code looks correct overall, but I have minor suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (1/1)
Hi, @usidedown. I've added the header cells and radio buttons. Things are a bit more crammed in the dialog now. Ideally the way the size of the dialog is setup according to resolution and number of save files should be reworked, but for now I think this is good enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @usidedown, I left several comments. Could you please take a look when you have time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, @usidedown.
You can also mark in the PR topic that there are UI improvements. :)
@usidedown , many thanks for this feature! |
Solves #1211
Introduces a new configuration
save file sorting
that changes the way sorting works in the load dialog✅ Allows sorting by timestamp rather than filename
✅ Doesn't change the default behavior
❌No UI improvements✅ Awesome UI thanks to @zenseii