Skip to content

Commit edab528

Browse files
committed
Use ScriptExportMode enum in EditorExportPreset
1 parent d599946 commit edab528

File tree

8 files changed

+59
-11
lines changed

8 files changed

+59
-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 script export mode.
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ String EditorExportPreset::get_script_encryption_key() const {
510510
return script_key;
511511
}
512512

513-
void EditorExportPreset::set_script_export_mode(int p_mode) {
513+
void EditorExportPreset::set_script_export_mode(ScriptExportMode p_mode) {
514514
script_mode = p_mode;
515515
EditorExport::singleton->save_presets();
516516
}
517517

518-
int EditorExportPreset::get_script_export_mode() const {
518+
EditorExportPreset::ScriptExportMode EditorExportPreset::get_script_export_mode() const {
519519
return script_mode;
520520
}
521521

editor/export/editor_export_preset.h

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

9696
String script_key;
97-
int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
97+
ScriptExportMode script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
9898

9999
protected:
100100
bool _set(const StringName &p_name, const Variant &p_value);
@@ -179,8 +179,8 @@ class EditorExportPreset : public RefCounted {
179179
void set_script_encryption_key(const String &p_key);
180180
String get_script_encryption_key() const;
181181

182-
void set_script_export_mode(int p_mode);
183-
int get_script_export_mode() const;
182+
void set_script_export_mode(ScriptExportMode p_mode);
183+
ScriptExportMode get_script_export_mode() const;
184184

185185
Variant _get_or_env(const StringName &p_name, const String &p_env_var) const {
186186
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
@@ -417,7 +417,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
417417
script_key_error->hide();
418418
}
419419

420-
int script_export_mode = current->get_script_export_mode();
420+
int script_export_mode = int(current->get_script_export_mode());
421421
script_mode->select(script_export_mode);
422422

423423
updating = false;
@@ -652,7 +652,7 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
652652
return is_valid;
653653
}
654654

655-
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
655+
void ProjectExportDialog::_script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode) {
656656
if (updating) {
657657
return;
658658
}

editor/export/project_export.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ProjectExportDialog : public ConfirmationDialog {
202202
void _script_encryption_key_changed(const String &p_key);
203203
bool _validate_script_encryption_key(const String &p_key);
204204

205-
void _script_export_mode_changed(int p_mode);
205+
void _script_export_mode_changed(EditorExportPreset::ScriptExportMode p_mode);
206206

207207
void _open_key_help_link();
208208

misc/extension_api_validation/4.4-stable.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,10 @@ Validate extension JSON: JSON file: Field was added in a way that breaks compati
267267
Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/RichTextLabel/methods/push_underline': arguments
268268

269269
Optional "color" argument added. Compatibility methods registered.
270+
271+
272+
GH-107167
273+
---------
274+
Validate extension JSON: Error: Field 'classes/EditorExportPreset/methods/get_script_export_mode': meta was removed.
275+
276+
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)