Skip to content

Commit b603be2

Browse files
committed
Merge pull request #107167 from Mickeon/actually-use-script-export-mode-what-the-hell
Use ScriptExportMode enum in EditorExportPreset
2 parents 46cfb80 + 14ede94 commit b603be2

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_preset.h"
32+
#include "editor_export_preset.compat.inc"
3233

3334
#include "core/config/project_settings.h"
3435
#include "core/io/dir_access.h"
@@ -549,12 +550,12 @@ String EditorExportPreset::get_script_encryption_key() const {
549550
return script_key;
550551
}
551552

552-
void EditorExportPreset::set_script_export_mode(int p_mode) {
553+
void EditorExportPreset::set_script_export_mode(ScriptExportMode p_mode) {
553554
script_mode = p_mode;
554555
EditorExport::singleton->save_presets();
555556
}
556557

557-
int EditorExportPreset::get_script_export_mode() const {
558+
EditorExportPreset::ScriptExportMode EditorExportPreset::get_script_export_mode() const {
558559
return script_mode;
559560
}
560561

editor/export/editor_export_preset.h

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

100100
String script_key;
101-
int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
101+
ScriptExportMode script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
102102

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

110110
static void _bind_methods();
111111

112+
#ifndef DISABLE_DEPRECATED
113+
int _get_script_export_mode_bind_compat_107167() const;
114+
static void _bind_compatibility_methods();
115+
#endif
116+
112117
public:
113118
Ref<EditorExportPlatform> get_platform() const;
114119

@@ -199,8 +204,8 @@ class EditorExportPreset : public RefCounted {
199204
void set_script_encryption_key(const String &p_key);
200205
String get_script_encryption_key() const;
201206

202-
void set_script_export_mode(int p_mode);
203-
int get_script_export_mode() const;
207+
void set_script_export_mode(ScriptExportMode p_mode);
208+
ScriptExportMode get_script_export_mode() const;
204209

205210
Variant _get_or_env(const StringName &p_name, const String &p_env_var) const {
206211
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
@@ -433,7 +433,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
433433
script_key_error->hide();
434434
}
435435

436-
int script_export_mode = current->get_script_export_mode();
436+
int script_export_mode = int(current->get_script_export_mode());
437437
script_mode->select(script_export_mode);
438438

439439
updating = false;
@@ -703,7 +703,7 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
703703
return is_valid;
704704
}
705705

706-
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
706+
void ProjectExportDialog::_script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode) {
707707
if (updating) {
708708
return;
709709
}

editor/export/project_export.h

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

222-
void _script_export_mode_changed(int p_mode);
222+
void _script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode);
223223

224224
void _open_key_help_link();
225225

misc/extension_api_validation/4.5-stable.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,11 @@ Validate extension JSON: API was removed: classes/EditorFileDialog/properties/op
225225
Validate extension JSON: API was removed: classes/EditorFileDialog/properties/show_hidden_files
226226

227227
The errors are false-positives. The removed methods are now part of the new parent class.
228+
229+
230+
GH-107167
231+
---------
232+
Validate extension JSON: Error: Field 'classes/EditorExportPreset/methods/get_script_export_mode': meta was removed.
233+
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".
234+
235+
Change return type from `int` to `EditorExportPreset.ScriptExportMode` enum. Compatibility method 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)