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

Various fixes about [h|c]pp #6672

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ namespace about
{
namespace
{

credits_data parsed_credits_data;
std::map<std::string, std::vector<std::string>> images_campaigns;
std::vector<std::string> images_general;

void gather_images(const config& from, std::vector<std::string>& to)
{
const auto& im = utils::parenthetical_split(from["images"], ',');
if(!im.empty()) {
to.insert(to.end(), im.begin(), im.end());
}
to.insert(to.end(), im.begin(), im.end());
}

} // namespace
Expand Down Expand Up @@ -106,8 +105,12 @@ std::optional<credits_data::const_iterator> get_campaign_credits(const std::stri

std::vector<std::string> get_background_images(const std::string& campaign)
{
if(!campaign.empty() && !images_campaigns[campaign].empty()) {
return images_campaigns[campaign];
if(campaign.empty()) {
return images_general;
}

if(const auto it = images_campaigns.find(campaign); it != images_campaigns.cend()) {
return it->second;
}

return images_general;
Expand Down
5 changes: 3 additions & 2 deletions src/about.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <optional>
#include <string>
#include <utility>
#include <vector>

class config;
Expand Down Expand Up @@ -49,7 +50,7 @@ struct credits_group
/** Optional group ID. Currently only used for identifying campaigns. */
std::string id;

/** Optional group tite. Currently only used for identifying campaigns. */
/** Optional group title. Currently only used for identifying campaigns. */
t_string header;
};

Expand All @@ -61,7 +62,7 @@ const credits_data& get_credits_data();
/** Gets credits for a given campaign. Returns a null optional if that campaign has no credits. */
std::optional<credits_data::const_iterator> get_campaign_credits(const std::string& campaign);

/** Gets credit background images for a given campaaign. */
/** Gets credit background images for a given campaign. */
std::vector<std::string> get_background_images(const std::string& campaign);

/** Regenerates the credits data. */
Expand Down