Skip to content

Commit

Permalink
--no-update-check argumment added and backend for update checking added
Browse files Browse the repository at this point in the history
  • Loading branch information
hrubymar10 committed Aug 18, 2018
1 parent e9ea675 commit cda7f0a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/man/wesnoth.6
Expand Up @@ -204,6 +204,9 @@ don't try to validate replay of unit test. Only relevant when used with
.B --nosound
runs the game without sounds and music.
.TP
.B --no-update-check
runs the game without checking for updates. (Available only on macOS and Windows)
.TP
.BI --password \ password
uses
.I password
Expand Down
10 changes: 10 additions & 0 deletions src/commandline_options.cpp
Expand Up @@ -105,6 +105,11 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
nogui(false),
nomusic(false),
nosound(false),
#if defined(__linux__)
noupdatecheck(true),
#else
noupdatecheck(false),
#endif
new_widgets(false),
path(false),
preprocess(false),
Expand Down Expand Up @@ -173,6 +178,9 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
("nodelay", "runs the game without any delays.")
("nomusic", "runs the game without music.")
("nosound", "runs the game without sounds and music.")
#if !defined(__linux__)
("no-update-check", "runs the game without automatic checking for update.")
#endif
("password", po::value<std::string>(), "uses <password> when connecting to a server, ignoring other preferences.")
("path", "prints the path to the data directory and exits.")
("plugin", po::value<std::string>(), "(experimental) load a script which defines a wesnoth plugin. similar to --script below, but lua file should return a function which will be run as a coroutine and periodically woken up with updates.")
Expand Down Expand Up @@ -400,6 +408,8 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
noreplaycheck = true;
if (vm.count("nosound"))
nosound = true;
if (vm.count("no-update-check"))
noupdatecheck = true;
if (vm.count("nogui"))
nogui = true;
if (vm.count("parm"))
Expand Down
2 changes: 2 additions & 0 deletions src/commandline_options.hpp
Expand Up @@ -139,6 +139,8 @@ friend std::ostream& operator<<(std::ostream &os, const commandline_options& cmd
bool nomusic;
/// True if --nosound was given on the command line. Disables sound.
bool nosound;
/// True if --no-update-check was given on the command line. True by default on Linux. Disables automatic update checking.
bool noupdatecheck;
/// True if --new-widgets was given on the command line. Hidden option to enable the new widget toolkit.
bool new_widgets;
/// True if --path was given on the command line. Prints the path to data directory and exits.
Expand Down
5 changes: 5 additions & 0 deletions src/game_launcher.cpp
Expand Up @@ -210,6 +210,11 @@ game_launcher::game_launcher(const commandline_options& cmdline_opts, const char
no_music = true;
if (cmdline_opts_.nosound)
no_sound = true;
if (cmdline_opts_.noupdatecheck) {
preferences::set_update_check(false);
} else {
preferences::set_update_check(true);
}
if (cmdline_opts_.resolution) {
const int xres = std::get<0>(*cmdline_opts_.resolution);
const int yres = std::get<1>(*cmdline_opts_.resolution);
Expand Down
6 changes: 5 additions & 1 deletion src/gui/dialogs/title_screen.cpp
Expand Up @@ -238,7 +238,11 @@ void title_screen::pre_show(window& win)
//
// Version string
//
const std::string& version_string = VGETTEXT("Version $version", {{ "version", game_config::revision }});
std::string version_string = VGETTEXT("Version $version", {{ "version", game_config::revision }});

if (preferences::update_check()) {
version_string += " | " + VGETTEXT("New updated version $new_version available!", {{ "new_version", "1.14.5" }});
}

if(label* version_label = find_widget<label>(&win, "revision_number", false, false)) {
version_label->set_label(version_string);
Expand Down
10 changes: 10 additions & 0 deletions src/preferences/general.cpp
Expand Up @@ -714,6 +714,16 @@ void set_stop_music_in_background(bool ison)
preferences::set("stop_music_in_background", ison);
}

void set_update_check(bool ison)
{
prefs["update_check"] = ison;
}

bool update_check()
{
return get("update_check", false);
}

namespace {
double scroll = 0.2;
}
Expand Down
3 changes: 3 additions & 0 deletions src/preferences/general.hpp
Expand Up @@ -192,6 +192,9 @@ namespace preferences {

bool use_color_cursors();
void _set_color_cursors(bool value);

void set_update_check(bool ison);
bool update_check();

bool joystick_support_enabled();
int joystick_mouse_deadzone();
Expand Down

0 comments on commit cda7f0a

Please sign in to comment.