-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Show progress in contrib level menus #2040
Conversation
I love it! |
Also maybe don't show progress for levelsets |
Why though? Is there a particular reason why the progress of levelsets shouldn't be shown? There is no rule saying that all non-test levels must be in a worldmap, it's just that most people choose to create a worldmap for their levels, but there's nothing stopping them from creating a levelset of playable levels, and then the progress makes sense there. |
Also I decided to remove that check that would separate world and worldmaps if their titles didn't match since I don't think it makes much sense. I originally had that in place before I implemented the total world level count so I couldn't check if the numbers were the same but now I feel it makes things less intuitive and unnecessary. |
(name (_ "Christmas Special")) | ||
(author "Carsten Wirtz") |
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.
Were the name changes intended to be part of this PR? (They weren't mentioned in the PR desc)
There's also Community Island 2020
-> Community Island
and Haloween 2014
-> Halloween Special
.
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.
I renamed them because I originally had that check in place that would show both names from info
and the name of the worldmap if the titles didn't match even if the level counts did. I removed that check now (that's what I wanted feedback about, but ultimately decided was pointless and removed it), so the titles don't need to be changed anymore. I still think it's better this way (the worldmap titles are consistent with the title in the info
file), but if you think I should change them back, I will. These don't show up anywhere in the game anyway.
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.
As a matter of principle, it would be preferable to discuss add-on renamings with the community, just to ensure that the new name makes sense and that everybody is fine with it.
std::string title_str; | ||
const auto savegame = Savegame::from_file(worlds[i]->get_savegame_filename()); | ||
if (worlds[i]->is_levelset()) | ||
title_str = "[" + worlds[i]->get_title() + "]"; | ||
{ | ||
uint32_t level_count = 0, solved_count = 0; | ||
const auto& state = savegame->get_levelset_state(worlds[i]->get_basedir()); | ||
for (const auto& level_state : state.level_states) | ||
{ | ||
if (level_state.filename.empty() || level_state.filename.back() == '~') continue; | ||
if (level_state.solved) ++solved_count; | ||
++level_count; | ||
} | ||
if (!level_count) | ||
{ | ||
title_str = str(boost::format(_("[%s] *NEW*")) % worlds[i]->get_title()); | ||
} | ||
else | ||
{ | ||
/* This is translatable since RTL languages may prefer to put the progress | ||
info to the left of the title */ | ||
title_str = str(boost::format(_("[%s] (%u/%u; %u%%)")) % worlds[i]->get_title() % | ||
solved_count % level_count % (100 * solved_count / level_count)); | ||
} | ||
} | ||
else | ||
title_str = worlds[i]->get_title(); | ||
{ | ||
uint32_t island_level_count = 0, island_solved_count = 0, | ||
world_level_count = 0, world_solved_count = 0; | ||
auto wm_filename = savegame->get_player_status().last_worldmap; |
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.
Please add some empty lines in here, it feels cramped 😄
else | ||
{ | ||
/* This is translatable since RTL languages may prefer to put the progress | ||
info to the left of the title */ | ||
title_str = str(boost::format(_("%s (%u/%u; %u%%) - %s (%u/%u; %u%%)")) % worlds[i]->get_title() % | ||
world_solved_count % world_level_count % (100 * world_solved_count / world_level_count) % | ||
wm_title % island_solved_count % island_level_count % | ||
(island_level_count ? (100 * island_solved_count / island_level_count) : 100)); | ||
} |
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.
Is there a reason to duplicate the count for a world and for a worldmap? Isn't the world's stats 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.
src/supertux/savegame.cpp
Outdated
std::string path; | ||
if (name[0] == '/') { | ||
path = name; | ||
} | ||
else { | ||
path = "/" + name; | ||
} |
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.
This check seems needless - it should be on the caller to ensure that there is a leading slash if a leading slash is necessary. (Also, it would be preferable to use the FileUtils where possible.)
std::string last_worldmap_title; /**< the title of the last played worldmap */ | ||
|
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.
Marking this in case the worldmap data gets removed, this variable will be unnecessary.
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.
There are a few superfluous comments, and I'd like to bring up the topic of renaming the add-ons with the community before finalizing this. Requesting changes only to remember about it, but once those are done, this PR will be clean and ready to merge.
// This is translatable since RTL languages may prefer to put the progress | ||
// info to the left of the title |
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.
This should be obvious from the context; this comment is not required.
// This is translatable since RTL languages may prefer to put the progress | ||
// info to the left of the title |
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.
Same here
{ | ||
// This is translatable since RTL languages may prefer to put the progress | ||
// info to the left of the title |
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.
And here
Those titles aren't the names of the Add-Ons (those are in the |
#include "boost/format.hpp" | ||
#include "gui/menu_manager.hpp" |
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.
One small detail: There should be an empty line between headers from dependencies (SDL, Physfs, Boost, etc.) and headers from the source directory
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.
Please apply the suggestions that I highlighted. (Or inform me why they shouldn't be)
{ | ||
uint32_t level_count = 0, solved_count = 0; | ||
const auto& state = savegame->get_levelset_state(worlds[i]->get_basedir()); | ||
|
||
for (const auto& level_state : state.level_states) | ||
{ | ||
if (level_state.filename.empty() || level_state.filename.back() == '~') continue; | ||
if (level_state.solved) ++solved_count; | ||
++level_count; | ||
} |
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.
I feel like this counting logic doesn't belong here, and could be better reused, if it was moved to a dedicated LevelsetState
method.
uint32_t island_level_count = 0, island_solved_count = 0, | ||
world_level_count = 0, world_solved_count = 0; | ||
std::string wm_filename = savegame->get_player_status().last_worldmap; | ||
|
||
if (wm_filename.empty()) | ||
wm_filename = worlds[i]->get_worldmap_filename(); | ||
|
||
wm_filename = "/" + wm_filename; | ||
|
||
const auto& state = savegame->get_worldmap_state(wm_filename); | ||
for (const auto& level_state : state.level_states) | ||
{ | ||
if (level_state.filename.empty()) continue; | ||
if (level_state.solved) ++island_solved_count; | ||
++island_level_count; | ||
} | ||
|
||
const auto levelset = std::unique_ptr<Levelset>(new Levelset(worlds[i]->get_basedir(), true)); | ||
world_level_count = levelset->get_num_levels(); | ||
const auto world_list = savegame->get_worldmaps(); | ||
|
||
for (const auto& world : world_list) | ||
{ | ||
const auto& world_state = savegame->get_worldmap_state(world); | ||
for (const auto& level_state : world_state.level_states) | ||
{ | ||
if (level_state.filename.empty()) continue; | ||
if (level_state.solved) ++world_solved_count; | ||
} | ||
} |
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.
Same as before, but for WorldmapState
as well. The code is being repeated at this point.
title_str = str(boost::format(_("%s (%u/%u; %u%%) - %s (%u/%u; %u%%)")) % worlds[i]->get_title() % | ||
world_level_count.first % world_level_count.second % | ||
(100 * world_level_count.first / world_level_count.second) % | ||
wm_title % island_level_count.first % island_level_count.second % | ||
percentage); |
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.
That line is quite long; is it necessary that both the world and the worldmap get their info there? I doubt most level designers would care to set both to significantly different values. It would be better to only retain the world info; island-specific info is unnecessary and better fit inside the world itself if necessary.
What is left to do for this pull request besides resolving merge conflict? |
Remove community island (as it was removed on master)
I think I'm (for the most part) done with this PR. However, there is one minor annoyance I'm not sure how to fix and a few design choices that may be worth considering, but can be addressed in another PR.
|
Also, before anyone asks, I removed the Community Island to resolve a merge conflict since it was already removed on |
Since descriptions aren't usually long I think that moving progress information there is a good idea. |
This is because the lisp files can contain translations inside of them. Look at this |
I'm closing this since it's going to be replaced by #2349. |
Fixes #1251
I fixed the feature that was broken for so long it got removed entirely. And I made it better.