Skip to content

Commit 36c701b

Browse files
committed
Use ScriptExportMode enum in EditorExportPreset
1 parent cb3af5a commit 36c701b

File tree

8 files changed

+66
-11
lines changed

8 files changed

+66
-11
lines changed

doc/classes/EditorExportPreset.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
</description>
130130
</method>
131131
<method name="get_script_export_mode" qualifiers="const">
132-
<return type="int" />
132+
<return type="int" enum="EditorExportPreset.ScriptExportMode" />
133133
<description>
134134
Returns the export mode used by GDScript files. [code]0[/code] for "Text", [code]1[/code] for "Binary tokens", and [code]2[/code] for "Compressed binary tokens (smaller files)".
135135
</description>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**************************************************************************/
2+
/* editor_export_preset.compat.inc */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
30+
31+
#ifndef DISABLE_DEPRECATED
32+
33+
int EditorExportPreset::_get_script_export_mode_bind_compat_107167() const {
34+
return get_script_export_mode();
35+
}
36+
37+
void EditorExportPreset::_bind_compatibility_methods() {
38+
ClassDB::bind_compatibility_method(D_METHOD("get_script_export_mode"), &EditorExportPreset::_get_script_export_mode_bind_compat_107167);
39+
}
40+
41+
#endif

editor/export/editor_export_preset.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/**************************************************************************/
3030

3131
#include "editor_export.h"
32+
#include "editor_export_preset.compat.inc"
3233

3334
#include "core/config/project_settings.h"
3435
#include "core/io/dir_access.h"
@@ -503,12 +504,12 @@ String EditorExportPreset::get_script_encryption_key() const {
503504
return script_key;
504505
}
505506

506-
void EditorExportPreset::set_script_export_mode(int p_mode) {
507+
void EditorExportPreset::set_script_export_mode(ScriptExportMode p_mode) {
507508
script_mode = p_mode;
508509
EditorExport::singleton->save_presets();
509510
}
510511

511-
int EditorExportPreset::get_script_export_mode() const {
512+
EditorExportPreset::ScriptExportMode EditorExportPreset::get_script_export_mode() const {
512513
return script_mode;
513514
}
514515

editor/export/editor_export_preset.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class EditorExportPreset : public RefCounted {
9393
uint64_t seed = 0;
9494

9595
String script_key;
96-
int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
96+
ScriptExportMode script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
9797

9898
protected:
9999
bool _set(const StringName &p_name, const Variant &p_value);
@@ -104,6 +104,11 @@ class EditorExportPreset : public RefCounted {
104104

105105
static void _bind_methods();
106106

107+
#ifndef DISABLE_DEPRECATED
108+
int _get_script_export_mode_bind_compat_107167() const;
109+
static void _bind_compatibility_methods();
110+
#endif
111+
107112
public:
108113
Ref<EditorExportPlatform> get_platform() const;
109114

@@ -177,8 +182,8 @@ class EditorExportPreset : public RefCounted {
177182
void set_script_encryption_key(const String &p_key);
178183
String get_script_encryption_key() const;
179184

180-
void set_script_export_mode(int p_mode);
181-
int get_script_export_mode() const;
185+
void set_script_export_mode(ScriptExportMode p_mode);
186+
ScriptExportMode get_script_export_mode() const;
182187

183188
Variant _get_or_env(const StringName &p_name, const String &p_env_var) const {
184189
return get_or_env(p_name, p_env_var);

editor/export/project_export.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
421421
script_key_error->hide();
422422
}
423423

424-
int script_export_mode = current->get_script_export_mode();
424+
int script_export_mode = int(current->get_script_export_mode());
425425
script_mode->select(script_export_mode);
426426

427427
updating = false;
@@ -668,7 +668,7 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
668668
return is_valid;
669669
}
670670

671-
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
671+
void ProjectExportDialog::_script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode) {
672672
if (updating) {
673673
return;
674674
}

editor/export/project_export.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class ProjectExportDialog : public ConfirmationDialog {
204204
void _script_encryption_key_visibility_changed(bool p_visible);
205205
bool _validate_script_encryption_key(const String &p_key);
206206

207-
void _script_export_mode_changed(int p_mode);
207+
void _script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode);
208208

209209
void _open_key_help_link();
210210

misc/extension_api_validation/4.5-stable.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,11 @@ Validate extension JSON: Error: Field 'builtin_classes/PackedVector3Array/method
9999
Validate extension JSON: Error: Field 'builtin_classes/PackedVector4Array/methods/duplicate': is_const changed value in new API, from false to true.
100100

101101
Duplicate method made const. Compatibility methods registered.
102+
103+
104+
GH-107167
105+
---------
106+
Validate extension JSON: Error: Field 'classes/EditorExportPreset/methods/get_script_export_mode': meta was removed.
107+
Validate extension JSON: Error: Field 'classes/EditorExportPreset/methods/get_script_export_mode/return_value': type changed value in new API, from "int" to "enum::EditorExportPreset.ScriptExportMode".
108+
109+
Change return type from `int` to `EditorExportPreset.ScriptExportMode` enum. Compatibility methods registered.

modules/gdscript/register_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Ref<GDScriptEditorTranslationParserPlugin> gdscript_translation_parser_plugin;
7878
class EditorExportGDScript : public EditorExportPlugin {
7979
GDCLASS(EditorExportGDScript, EditorExportPlugin);
8080

81-
static constexpr int DEFAULT_SCRIPT_MODE = EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
82-
int script_mode = DEFAULT_SCRIPT_MODE;
81+
static constexpr EditorExportPreset::ScriptExportMode DEFAULT_SCRIPT_MODE = EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
82+
EditorExportPreset::ScriptExportMode script_mode = DEFAULT_SCRIPT_MODE;
8383

8484
protected:
8585
virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) override {

0 commit comments

Comments
 (0)