From a01fd2ea77443156a5465cab6bdf898472b1a1d5 Mon Sep 17 00:00:00 2001 From: pentarctagon Date: Sat, 11 Nov 2023 23:44:41 -0600 Subject: [PATCH] Show an error when mainline campaigns are missing. 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 #7875 --- src/gui/dialogs/campaign_selection.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/campaign_selection.cpp b/src/gui/dialogs/campaign_selection.cpp index 6c8a4d0461d51..1a1bc5cfd94b2 100644 --- a/src/gui/dialogs/campaign_selection.cpp +++ b/src/gui/dialogs/campaign_selection.cpp @@ -17,9 +17,11 @@ #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/dialogs/message.hpp" #include "gui/widgets/button.hpp" #include "gui/widgets/image.hpp" #include "gui/widgets/listbox.hpp" @@ -288,6 +290,12 @@ void campaign_selection::filter_text_changed(const std::string& text) void campaign_selection::pre_show(window& window) { + std::vector dirs; + filesystem::get_files_in_dir(game_config::path + "/data/campaigns", nullptr, &dirs); + if(dirs.size() <= 1) { + gui2::show_error_message(_("Most mainline campaigns are missing. If you’re on Linux, then this 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.")); + } + text_box* filter = find_widget(&window, "filter_box", false, true); filter->set_text_changed_callback( std::bind(&campaign_selection::filter_text_changed, this, std::placeholders::_2));