Add Auto update check mode
This commit is contained in:
parent
551ce8d47f
commit
ecc00b1238
4 changed files with 20 additions and 18 deletions
|
|
@ -1253,8 +1253,9 @@
|
|||
<member name="network/connection/check_for_updates" type="int" setter="" getter="">
|
||||
Specifies how the engine should check for updates.
|
||||
- [b]Disable Update Checks[/b] will block the engine from checking updates (see also [member network/connection/network_mode]).
|
||||
- [b]Check Newest Preview[/b] (default for preview versions) will check for the newest available development snapshot.
|
||||
- [b]Check Newest Stable[/b] (default for stable versions) will check for the newest available stable version.
|
||||
- [b]Auto[/b] (default) will check for newest stable or unstable version, depending on which version are you currently using. Switch to another option if you want to lock in.
|
||||
- [b]Check Newest Preview[/b] will check for the newest available development snapshot.
|
||||
- [b]Check Newest Stable[/b] will check for the newest available stable version.
|
||||
- [b]Check Newest Patch[/b] will check for the latest available stable version, but only within the same minor version. E.g. if your version is [code]4.3.stable[/code], you will be notified about [code]4.3.1.stable[/code], but not [code]4.4.stable[/code].
|
||||
All update modes will ignore builds with different major versions (e.g. Godot 4 -> Godot 5).
|
||||
</member>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "engine_update_label.h"
|
||||
|
||||
#include "core/io/json.h"
|
||||
#include "core/version.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/settings/editor_settings.h"
|
||||
#include "scene/main/http_request.h"
|
||||
|
|
@ -79,14 +80,16 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||
}
|
||||
|
||||
UpdateMode update_mode = UpdateMode(int(EDITOR_GET("network/connection/check_for_updates")));
|
||||
if (update_mode == UpdateMode::AUTO) {
|
||||
if (_get_version_type(GODOT_VERSION_STATUS) == VersionType::STABLE) {
|
||||
update_mode = UpdateMode::NEWEST_STABLE;
|
||||
} else {
|
||||
update_mode = UpdateMode::NEWEST_UNSTABLE;
|
||||
}
|
||||
}
|
||||
bool stable_only = update_mode == UpdateMode::NEWEST_STABLE || update_mode == UpdateMode::NEWEST_PATCH;
|
||||
|
||||
const Dictionary current_version_info = Engine::get_singleton()->get_version_info();
|
||||
int current_major = current_version_info.get("major", 0);
|
||||
int current_minor = current_version_info.get("minor", 0);
|
||||
int current_patch = current_version_info.get("patch", 0);
|
||||
available_newer_version = String();
|
||||
|
||||
for (const Variant &data_bit : version_array) {
|
||||
const Dictionary version_info = data_bit;
|
||||
|
||||
|
|
@ -98,7 +101,7 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||
}
|
||||
|
||||
int minor = version_bits[1].to_int();
|
||||
if (version_bits[0].to_int() != current_major || minor < current_minor) {
|
||||
if (version_bits[0].to_int() != GODOT_VERSION_MAJOR || minor < GODOT_VERSION_MINOR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -107,11 +110,11 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||
patch = version_bits[2].to_int();
|
||||
}
|
||||
|
||||
if (minor == current_minor && patch < current_patch) {
|
||||
if (minor == GODOT_VERSION_MINOR && patch < GODOT_VERSION_PATCH) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (update_mode == UpdateMode::NEWEST_PATCH && minor > current_minor) {
|
||||
if (update_mode == UpdateMode::NEWEST_PATCH && minor > GODOT_VERSION_MINOR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +129,7 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||
int release_index;
|
||||
VersionType release_type = _get_version_type(release_string, &release_index);
|
||||
|
||||
if (minor > current_minor || patch > current_patch) {
|
||||
if (minor > GODOT_VERSION_MINOR || patch > GODOT_VERSION_PATCH) {
|
||||
if (stable_only && release_type != VersionType::STABLE) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -136,7 +139,7 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||
}
|
||||
|
||||
int current_version_index;
|
||||
VersionType current_version_type = _get_version_type(current_version_info.get("status", "unknown"), ¤t_version_index);
|
||||
VersionType current_version_type = _get_version_type(GODOT_VERSION_STATUS, ¤t_version_index);
|
||||
|
||||
if (int(release_type) > int(current_version_type)) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class EngineUpdateLabel : public LinkButton {
|
|||
public:
|
||||
enum class UpdateMode {
|
||||
DISABLED,
|
||||
AUTO,
|
||||
NEWEST_UNSTABLE,
|
||||
NEWEST_STABLE,
|
||||
NEWEST_PATCH,
|
||||
|
|
@ -86,7 +87,7 @@ private:
|
|||
void _set_message(const String &p_message, const Color &p_color);
|
||||
void _set_status(UpdateStatus p_status);
|
||||
|
||||
VersionType _get_version_type(const String &p_string, int *r_index) const;
|
||||
VersionType _get_version_type(const String &p_string, int *r_index = nullptr) const;
|
||||
String _extract_sub_string(const String &p_line) const;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -480,11 +480,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/project_manager_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_PRIMARY, project_manager_screen_hints)
|
||||
|
||||
{
|
||||
EngineUpdateLabel::UpdateMode default_update_mode = EngineUpdateLabel::UpdateMode::NEWEST_UNSTABLE;
|
||||
if (String(GODOT_VERSION_STATUS) == String("stable")) {
|
||||
default_update_mode = EngineUpdateLabel::UpdateMode::NEWEST_STABLE;
|
||||
}
|
||||
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "network/connection/check_for_updates", int(default_update_mode), "Disable Update Checks,Check Newest Preview,Check Newest Stable,Check Newest Patch"); // Uses EngineUpdateLabel::UpdateMode.
|
||||
const String update_hint = vformat("Disable Update Checks,Auto (%s),Check Newest Preview,Check Newest Stable,Check Newest Patch", (str_compare(GODOT_VERSION_STATUS, "stable") == 0) ? "Stable" : "Preview");
|
||||
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "network/connection/check_for_updates", EngineUpdateLabel::UpdateMode::AUTO, update_hint);
|
||||
}
|
||||
|
||||
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/use_embedded_menu", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue