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

Show progress in contrib level menus #2040

Closed
wants to merge 24 commits into from
Closed

Conversation

Narre
Copy link
Contributor

@Narre Narre commented Dec 28, 2021

Fixes #1251

I fixed the feature that was broken for so long it got removed entirely. And I made it better.

progress_official
progress_user

@bruhmoent
Copy link
Member

I love it!

@Narre
Copy link
Contributor Author

Narre commented Dec 28, 2021

Feedback please! Should I remove the worlds[i]->get_title() == wm_title in
image
?? I'm not sure if it's a good idea to separate the progress indicator of the add-on and the worldmap just because their titles don't match.

@Semphriss Semphriss self-requested a review December 29, 2021 00:06
@mrkubax10
Copy link
Member

Also maybe don't show progress for levelsets

@Narre
Copy link
Contributor Author

Narre commented Dec 29, 2021

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.

@Narre
Copy link
Contributor Author

Narre commented Dec 29, 2021

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.

Comment on lines +3 to 4
(name (_ "Christmas Special"))
(author "Carsten Wirtz")
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

src/supertux/menu/sorted_contrib_menu.cpp Outdated Show resolved Hide resolved
Comment on lines 43 to 71
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;
Copy link
Member

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 😄

Comment on lines 105 to 113
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));
}
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally thought it may be enough the other way round :D

I think having both counts is good for bigger worlds with more than one worldmap, like
image
For worlds which only have one worldmap (ie the level count in the worldmap and the world are identical), only one will show.

Comment on lines 326 to 332
std::string path;
if (name[0] == '/') {
path = name;
}
else {
path = "/" + name;
}
Copy link
Member

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.)

Comment on lines +64 to 65
std::string last_worldmap_title; /**< the title of the last played worldmap */

Copy link
Member

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.

Copy link
Member

@Semphriss Semphriss left a 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.

Comment on lines 65 to 66
// This is translatable since RTL languages may prefer to put the progress
// info to the left of the title
Copy link
Member

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.

Comment on lines 112 to 113
// This is translatable since RTL languages may prefer to put the progress
// info to the left of the title
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Comment on lines 118 to 120
{
// This is translatable since RTL languages may prefer to put the progress
// info to the left of the title
Copy link
Member

Choose a reason for hiding this comment

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

And here

@Narre
Copy link
Contributor Author

Narre commented Jan 5, 2022

Those titles aren't the names of the Add-Ons (those are in the info file). These are the names of the worldmaps (the stwm "levels"), which don't show up anywhere in the game. I just made them consistent with the Add-On names in info.

Comment on lines 22 to 23
#include "boost/format.hpp"
#include "gui/menu_manager.hpp"
Copy link
Member

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

Copy link
Member

@Zwatotem Zwatotem left a 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)

Comment on lines 49 to 58
{
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;
}
Copy link
Member

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.

Comment on lines 72 to 101
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;
}
}
Copy link
Member

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.

@Narre Narre requested a review from Zwatotem February 7, 2022 16:01
@Semphriss Semphriss self-requested a review February 8, 2022 18:29
Comment on lines 94 to 98
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);
Copy link
Member

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.

@mrkubax10
Copy link
Member

What is left to do for this pull request besides resolving merge conflict?

Remove community island (as it was removed on master)
@Narre
Copy link
Contributor Author

Narre commented Aug 14, 2022

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.

  • The minor annoyance is that the title of the current worldmap is saved in the savegame file in the language SuperTux is set to at the time of saving (loading the particular worldmap), and if the language is changed afterwards, the title will only update after reloading the worldmap. This can be fixed by saving the last worldmap title without translation and translating it directly in sorted_contrib_menu.cpp, however, the m_name variable loaded in worldmap.cpp loads the already translated string and I couldn't figure out where it's pulling it from (or rather, how it's pulling it). Maybe using an actual IDE instead of a plain text editor would help...

  • The design choices include the most obvious one - whether and how (not) to count cutscenes and similar towards the level count. This could be achieved with a bool in the .stwm map, but then the total level count (between all worldmaps) would not see it. This would probably be better addressed separately in another PR since I'm not sure how I would do it and I'm sure there are people better at tackling this than me.

  • The other design choice I thought about is where to show the progress. Currently, in this PR, the progress is shown the way it used to be before this feature broke (next to the world title), but since this line is kinda long now (because for worlds that consist of more than one worldmap, it shows overall progress as well as the progress in the current worldmap). I thought it may be better to show the progress in another manner, for example, at the bottom of the screen alongside the description, but this would require some discussion and when decided, can be done in a single simple commit.

@Narre
Copy link
Contributor Author

Narre commented Aug 14, 2022

Also, before anyone asks, I removed the Community Island to resolve a merge conflict since it was already removed on master

@mrkubax10
Copy link
Member

The other design choice I thought about is where to show the progress. Currently, in this PR, the progress is shown the way it used to be before this feature broke (next to the world title), but since this line is kinda long now (because for worlds that consist of more than one worldmap, it shows overall progress as well as the progress in the current worldmap). I thought it may be better to show the progress in another manner, for example, at the bottom of the screen alongside the description, but this would require some discussion and when decided, can be done in a single simple commit.

Since descriptions aren't usually long I think that moving progress information there is a good idea.

@mrkubax10
Copy link
Member

mrkubax10 commented Aug 20, 2022

The minor annoyance is that the title of the current worldmap is saved in the savegame file in the language SuperTux is set to at the time of saving (loading the particular worldmap), and if the language is changed afterwards, the title will only update after reloading the worldmap. This can be fixed by saving the last worldmap title without translation and translating it directly in sorted_contrib_menu.cpp, however, the m_name variable loaded in worldmap.cpp loads the already translated string and I couldn't figure out where it's pulling it from (or rather, how it's pulling it). Maybe using an actual IDE instead of a plain text editor would help...

This is because the lisp files can contain translations inside of them. Look at this name entry from data/world1/worldmap.stwm:
(name (_ "Icy Island")) (_ means translated string). If I understand this correctly worldmap name is automatically translated in get method of ReaderMapping: https://github.com/SuperTux/supertux/blob/master/src/util/reader_mapping.cpp#L131, which is called there: https://github.com/SuperTux/supertux/blob/master/src/worldmap/worldmap_parser.cpp#L69

@weluvgoatz weluvgoatz added this to the 0.7.0 milestone Oct 7, 2022
@Narre
Copy link
Contributor Author

Narre commented Jul 18, 2023

I'm closing this since it's going to be replaced by #2349.

@Narre Narre closed this Jul 18, 2023
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.

Old levelpacks are marked as new
6 participants