Skip to content

Commit

Permalink
Show an error when mainline campaigns are missing.
Browse files Browse the repository at this point in the history
A Linux packaging issue has, for apparently multiple years now, resulted in Wesnoth getting installed with only the tutorial campaign available. So, check for that and alert the player that there's an issue so they don't think Wesnoth actually only has a tutorial available.

Fixes wesnoth#7875
  • Loading branch information
Pentarctagon committed Nov 13, 2023
1 parent ec0f8f9 commit b34b6e2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/gui/dialogs/campaign_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

#include "gui/dialogs/campaign_selection.hpp"

#include "filesystem.hpp"
#include "font/text_formatting.hpp"
#include "gui/dialogs/campaign_difficulty.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/dialogs/campaign_difficulty.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/image.hpp"
#include "gui/widgets/listbox.hpp"
Expand Down Expand Up @@ -339,6 +340,27 @@ void campaign_selection::pre_show(window& window)
page_ids_.push_back(campaign["id"]);
}

std::vector<std::string> dirs;
filesystem::get_files_in_dir(game_config::path + "/data/campaigns", nullptr, &dirs);
if(dirs.size() <= 1) {
config missing;
missing["icon"] = "units/unknown-unit.png";
missing["name"] = _("Missing Campaigns");
missing["completed"] = false;
missing["id"] = "missing-campaign";

add_campaign_to_tree(missing);

widget_data data;
widget_item item;

item["label"] = _("Most mainline campaigns are missing. If you’re on Linux, then this most likely means the incorrect package was installed. To get the rest of the campaigns you will need to either: correctly install the wesnoth metapackage, install each campaign’s package one by one, or install Wesnoth via Steam or Flatpak.");
data.emplace("description", item);

pages.add_page(data);
page_ids_.push_back("missing-campaign");
}

//
// Set up Mods selection dropdown
//
Expand Down

0 comments on commit b34b6e2

Please sign in to comment.