2014-02-10 01:10:30 +00:00
/**************************************************************************/
/* project_export.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
2018-01-04 23:50:27 +00:00
2014-02-10 01:10:30 +00:00
# include "project_export.h"
2018-08-18 13:07:23 +00:00
2020-11-07 22:33:38 +00:00
# include "core/config/project_settings.h"
2022-07-20 22:45:01 +00:00
# include "core/version.h"
# include "editor/editor_file_system.h"
2022-02-12 01:46:22 +00:00
# include "editor/editor_node.h"
2022-07-20 22:45:01 +00:00
# include "editor/editor_properties.h"
2022-11-19 11:45:49 +00:00
# include "editor/editor_settings.h"
2023-08-13 00:33:39 +00:00
# include "editor/editor_string_names.h"
2022-07-20 22:45:01 +00:00
# include "editor/export/editor_export.h"
2023-04-07 16:59:49 +00:00
# include "editor/gui/editor_file_dialog.h"
2023-06-20 02:50:09 +00:00
# include "editor/import/resource_importer_texture_settings.h"
2024-01-15 12:14:55 +00:00
# include "editor/themes/editor_scale.h"
2022-11-19 11:45:49 +00:00
# include "scene/gui/check_box.h"
2022-08-01 14:04:35 +00:00
# include "scene/gui/check_button.h"
2022-11-19 11:45:49 +00:00
# include "scene/gui/item_list.h"
2022-07-20 22:45:01 +00:00
# include "scene/gui/link_button.h"
2024-02-23 13:51:47 +00:00
# include "scene/gui/margin_container.h"
2022-11-19 11:45:49 +00:00
# include "scene/gui/menu_button.h"
# include "scene/gui/option_button.h"
2022-12-20 21:49:11 +00:00
# include "scene/gui/popup_menu.h"
2022-11-19 11:45:49 +00:00
# include "scene/gui/split_container.h"
2023-04-07 16:59:49 +00:00
# include "scene/gui/tab_container.h"
2022-11-19 11:45:49 +00:00
# include "scene/gui/texture_rect.h"
2022-07-20 22:45:01 +00:00
# include "scene/gui/tree.h"
2014-02-10 01:10:30 +00:00
2023-06-20 02:50:09 +00:00
void ProjectExportTextureFormatError : : _on_fix_texture_format_pressed ( ) {
ProjectSettings : : get_singleton ( ) - > set_setting ( setting_identifier , true ) ;
ProjectSettings : : get_singleton ( ) - > save ( ) ;
EditorFileSystem : : get_singleton ( ) - > scan_changes ( ) ;
emit_signal ( " texture_format_enabled " ) ;
}
void ProjectExportTextureFormatError : : _bind_methods ( ) {
ADD_SIGNAL ( MethodInfo ( " texture_format_enabled " ) ) ;
}
void ProjectExportTextureFormatError : : _notification ( int p_what ) {
switch ( p_what ) {
case NOTIFICATION_THEME_CHANGED : {
2023-08-13 00:33:39 +00:00
texture_format_error_label - > add_theme_color_override ( " font_color " , get_theme_color ( SNAME ( " error_color " ) , EditorStringName ( Editor ) ) ) ;
2023-06-20 02:50:09 +00:00
} break ;
}
}
void ProjectExportTextureFormatError : : show_for_texture_format ( const String & p_friendly_name , const String & p_setting_identifier ) {
texture_format_error_label - > set_text ( vformat ( TTR ( " Target platform requires '%s' texture compression. Enable 'Import %s' to fix. " ) , p_friendly_name , p_friendly_name . replace ( " / " , " " ) ) ) ;
setting_identifier = p_setting_identifier ;
show ( ) ;
}
ProjectExportTextureFormatError : : ProjectExportTextureFormatError ( ) {
// Set up the label.
texture_format_error_label = memnew ( Label ) ;
add_child ( texture_format_error_label ) ;
// Set up the fix button.
fix_texture_format_button = memnew ( LinkButton ) ;
fix_texture_format_button - > set_v_size_flags ( Control : : SIZE_SHRINK_CENTER ) ;
fix_texture_format_button - > set_text ( TTR ( " Fix Import " ) ) ;
add_child ( fix_texture_format_button ) ;
fix_texture_format_button - > connect ( " pressed " , callable_mp ( this , & ProjectExportTextureFormatError : : _on_fix_texture_format_pressed ) ) ;
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _notification ( int p_what ) {
2017-03-02 21:43:56 +00:00
switch ( p_what ) {
2020-03-06 17:00:16 +00:00
case NOTIFICATION_VISIBILITY_CHANGED : {
if ( ! is_visible ( ) ) {
EditorSettings : : get_singleton ( ) - > set_project_metadata ( " dialog_bounds " , " export " , Rect2 ( get_position ( ) , get_size ( ) ) ) ;
}
} break ;
2022-02-16 14:17:55 +00:00
2023-12-04 12:18:48 +00:00
case NOTIFICATION_THEME_CHANGED : {
duplicate_preset - > set_icon ( presets - > get_editor_theme_icon ( SNAME ( " Duplicate " ) ) ) ;
delete_preset - > set_icon ( presets - > get_editor_theme_icon ( SNAME ( " Remove " ) ) ) ;
} break ;
2017-03-02 21:43:56 +00:00
case NOTIFICATION_READY : {
2023-08-13 00:33:39 +00:00
duplicate_preset - > set_icon ( presets - > get_editor_theme_icon ( SNAME ( " Duplicate " ) ) ) ;
delete_preset - > set_icon ( presets - > get_editor_theme_icon ( SNAME ( " Remove " ) ) ) ;
2020-02-21 17:28:45 +00:00
connect ( " confirmed " , callable_mp ( this , & ProjectExportDialog : : _export_pck_zip ) ) ;
2019-11-04 15:29:09 +00:00
_update_export_all ( ) ;
2018-02-25 16:04:16 +00:00
} break ;
2014-02-10 01:10:30 +00:00
}
}
2016-01-27 10:23:12 +00:00
void ProjectExportDialog : : popup_export ( ) {
2017-02-20 02:19:30 +00:00
add_preset - > get_popup ( ) - > clear ( ) ;
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_platform_count ( ) ; i + + ) {
Ref < EditorExportPlatform > plat = EditorExport : : get_singleton ( ) - > get_export_platform ( i ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
add_preset - > get_popup ( ) - > add_icon_item ( plat - > get_logo ( ) , plat - > get_name ( ) ) ;
2014-02-10 01:10:30 +00:00
}
2017-02-20 02:19:30 +00:00
_update_presets ( ) ;
2018-07-18 11:46:02 +00:00
if ( presets - > get_current ( ) > = 0 ) {
2018-12-23 18:28:29 +00:00
_update_current_preset ( ) ; // triggers rescan for templates if newly installed
2018-07-18 11:46:02 +00:00
}
2017-03-02 21:43:56 +00:00
// Restore valid window bounds or pop up at default size.
2018-12-04 15:52:56 +00:00
Rect2 saved_size = EditorSettings : : get_singleton ( ) - > get_project_metadata ( " dialog_bounds " , " export " , Rect2 ( ) ) ;
if ( saved_size ! = Rect2 ( ) ) {
popup ( saved_size ) ;
2017-03-02 21:43:56 +00:00
} else {
2019-04-26 19:36:44 +00:00
popup_centered_clamped ( Size2 ( 900 , 700 ) * EDSCALE , 0.8 ) ;
2017-03-02 21:43:56 +00:00
}
2014-02-10 01:10:30 +00:00
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _add_preset ( int p_platform ) {
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_platform ( p_platform ) - > create_preset ( ) ;
ERR_FAIL_COND ( ! preset . is_valid ( ) ) ;
2014-02-10 01:10:30 +00:00
2022-09-29 09:53:28 +00:00
String preset_name = EditorExport : : get_singleton ( ) - > get_export_platform ( p_platform ) - > get_name ( ) ;
2017-02-20 02:19:30 +00:00
bool make_runnable = true ;
int attempt = 1 ;
while ( true ) {
bool valid = true ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > p = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
if ( p - > get_platform ( ) = = preset - > get_platform ( ) & & p - > is_runnable ( ) ) {
make_runnable = false ;
}
2022-09-29 09:53:28 +00:00
if ( p - > get_name ( ) = = preset_name ) {
2017-02-20 02:19:30 +00:00
valid = false ;
break ;
}
}
2014-02-10 01:10:30 +00:00
2020-05-14 14:41:43 +00:00
if ( valid ) {
2017-02-20 02:19:30 +00:00
break ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
attempt + + ;
2022-09-29 09:53:28 +00:00
preset_name = EditorExport : : get_singleton ( ) - > get_export_platform ( p_platform ) - > get_name ( ) + " " + itos ( attempt ) ;
2016-01-27 10:23:12 +00:00
}
2022-09-29 09:53:28 +00:00
preset - > set_name ( preset_name ) ;
2020-05-14 14:41:43 +00:00
if ( make_runnable ) {
2017-02-20 02:19:30 +00:00
preset - > set_runnable ( make_runnable ) ;
2020-05-14 14:41:43 +00:00
}
2017-02-20 02:19:30 +00:00
EditorExport : : get_singleton ( ) - > add_export_preset ( preset ) ;
_update_presets ( ) ;
_edit_preset ( EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) - 1 ) ;
2014-02-10 01:10:30 +00:00
}
2020-04-24 07:45:14 +00:00
void ProjectExportDialog : : _force_update_current_preset_parameters ( ) {
// Force the parameters section to refresh its UI.
parameters - > edit ( nullptr ) ;
_update_current_preset ( ) ;
}
2018-12-23 18:28:29 +00:00
void ProjectExportDialog : : _update_current_preset ( ) {
_edit_preset ( presets - > get_current ( ) ) ;
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _update_presets ( ) {
updating = true ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
Ref < EditorExportPreset > current ;
2020-05-14 14:41:43 +00:00
if ( presets - > get_current ( ) > = 0 & & presets - > get_current ( ) < presets - > get_item_count ( ) ) {
2018-12-23 18:28:29 +00:00
current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
int current_idx = - 1 ;
presets - > clear ( ) ;
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
if ( preset = = current ) {
current_idx = i ;
}
2014-02-10 01:10:30 +00:00
2022-09-29 09:53:28 +00:00
String preset_name = preset - > get_name ( ) ;
2020-05-14 14:41:43 +00:00
if ( preset - > is_runnable ( ) ) {
2022-09-29 09:53:28 +00:00
preset_name + = " ( " + TTR ( " Runnable " ) + " ) " ;
2020-05-14 14:41:43 +00:00
}
2022-12-20 21:49:11 +00:00
preset - > update_files ( ) ;
2022-09-29 09:53:28 +00:00
presets - > add_item ( preset_name , preset - > get_platform ( ) - > get_logo ( ) ) ;
2017-02-20 02:19:30 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
if ( current_idx ! = - 1 ) {
presets - > select ( current_idx ) ;
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
updating = false ;
2014-02-10 01:10:30 +00:00
}
2018-11-03 15:56:31 +00:00
void ProjectExportDialog : : _update_export_all ( ) {
2019-06-26 13:08:25 +00:00
bool can_export = EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) > 0 ;
2018-11-03 15:56:31 +00:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
bool needs_templates ;
String error ;
2021-12-09 09:42:46 +00:00
if ( preset - > get_export_path ( ) . is_empty ( ) | | ! preset - > get_platform ( ) - > can_export ( preset , error , needs_templates ) ) {
2018-11-03 15:56:31 +00:00
can_export = false ;
break ;
}
}
2019-11-04 15:29:09 +00:00
export_all_button - > set_disabled ( ! can_export ) ;
2018-11-03 15:56:31 +00:00
if ( can_export ) {
2022-08-25 10:42:17 +00:00
export_all_button - > set_tooltip_text ( TTR ( " Export the project for all the presets defined. " ) ) ;
2018-11-03 15:56:31 +00:00
} else {
2022-08-25 10:42:17 +00:00
export_all_button - > set_tooltip_text ( TTR ( " All presets must have an export path defined for Export All to work. " ) ) ;
2018-11-03 15:56:31 +00:00
}
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _edit_preset ( int p_index ) {
if ( p_index < 0 | | p_index > = presets - > get_item_count ( ) ) {
name - > set_text ( " " ) ;
name - > set_editable ( false ) ;
2018-11-12 19:04:58 +00:00
export_path - > hide ( ) ;
2024-02-16 22:05:50 +00:00
advanced_options - > set_disabled ( true ) ;
2017-02-20 02:19:30 +00:00
runnable - > set_disabled ( true ) ;
2020-04-01 23:20:12 +00:00
parameters - > edit ( nullptr ) ;
2020-12-21 10:26:41 +00:00
presets - > deselect_all ( ) ;
2018-10-28 18:13:38 +00:00
duplicate_preset - > set_disabled ( true ) ;
2017-02-20 02:19:30 +00:00
delete_preset - > set_disabled ( true ) ;
sections - > hide ( ) ;
2017-03-21 02:31:41 +00:00
export_error - > hide ( ) ;
export_templates_error - > hide ( ) ;
2017-02-20 02:19:30 +00:00
return ;
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
Ref < EditorExportPreset > current = EditorExport : : get_singleton ( ) - > get_export_preset ( p_index ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
updating = true ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
presets - > select ( p_index ) ;
sections - > show ( ) ;
name - > set_editable ( true ) ;
2018-11-12 19:04:58 +00:00
export_path - > show ( ) ;
2018-10-28 18:13:38 +00:00
duplicate_preset - > set_disabled ( false ) ;
2017-02-20 02:19:30 +00:00
delete_preset - > set_disabled ( false ) ;
2022-07-11 22:13:38 +00:00
get_ok_button ( ) - > set_disabled ( false ) ;
2017-02-20 02:19:30 +00:00
name - > set_text ( current - > get_name ( ) ) ;
2018-11-12 19:04:58 +00:00
List < String > extension_list = current - > get_platform ( ) - > get_binary_extensions ( current ) ;
Vector < String > extension_vector ;
for ( int i = 0 ; i < extension_list . size ( ) ; i + + ) {
extension_vector . push_back ( " *. " + extension_list [ i ] ) ;
}
export_path - > setup ( extension_vector , false , true ) ;
export_path - > update_property ( ) ;
2024-02-16 22:05:50 +00:00
advanced_options - > set_disabled ( false ) ;
advanced_options - > set_pressed ( current - > are_advanced_options_enabled ( ) ) ;
2017-02-20 02:19:30 +00:00
runnable - > set_disabled ( false ) ;
runnable - > set_pressed ( current - > is_runnable ( ) ) ;
2024-02-12 22:16:48 +00:00
if ( parameters - > get_edited_object ( ) ! = current . ptr ( ) ) {
current - > update_value_overrides ( ) ;
}
2023-03-09 08:41:52 +00:00
parameters - > set_object_class ( current - > get_platform ( ) - > get_class_name ( ) ) ;
2017-02-20 02:19:30 +00:00
parameters - > edit ( current . ptr ( ) ) ;
export_filter - > select ( current - > get_export_filter ( ) ) ;
include_filters - > set_text ( current - > get_include_filter ( ) ) ;
2023-07-20 21:27:40 +00:00
include_label - > set_text ( _get_resource_export_header ( current - > get_export_filter ( ) ) ) ;
2017-02-20 02:19:30 +00:00
exclude_filters - > set_text ( current - > get_exclude_filter ( ) ) ;
2022-12-20 21:49:11 +00:00
server_strip_message - > set_visible ( current - > get_export_filter ( ) = = EditorExportPreset : : EXPORT_CUSTOMIZED ) ;
2017-02-20 02:19:30 +00:00
_fill_resource_tree ( ) ;
2014-02-10 01:10:30 +00:00
2017-03-21 02:31:41 +00:00
bool needs_templates ;
String error ;
if ( ! current - > get_platform ( ) - > can_export ( current , error , needs_templates ) ) {
2021-12-09 09:42:46 +00:00
if ( ! error . is_empty ( ) ) {
2018-08-17 09:27:26 +00:00
Vector < String > items = error . split ( " \n " , false ) ;
2017-03-21 02:31:41 +00:00
error = " " ;
for ( int i = 0 ; i < items . size ( ) ; i + + ) {
2020-05-14 14:41:43 +00:00
if ( i > 0 ) {
2017-03-21 02:31:41 +00:00
error + = " \n " ;
2020-05-14 14:41:43 +00:00
}
2017-03-21 02:31:41 +00:00
error + = " - " + items [ i ] ;
}
export_error - > set_text ( error ) ;
export_error - > show ( ) ;
} else {
export_error - > hide ( ) ;
}
2020-05-14 14:41:43 +00:00
if ( needs_templates ) {
2017-03-21 02:31:41 +00:00
export_templates_error - > show ( ) ;
2020-05-14 14:41:43 +00:00
} else {
2017-04-21 23:15:42 +00:00
export_templates_error - > hide ( ) ;
2020-05-14 14:41:43 +00:00
}
2017-03-21 02:31:41 +00:00
2022-01-10 11:18:59 +00:00
export_warning - > hide ( ) ;
2017-03-28 01:21:21 +00:00
export_button - > set_disabled ( true ) ;
2017-03-21 02:31:41 +00:00
} else {
2022-01-10 11:18:59 +00:00
if ( error ! = String ( ) ) {
Vector < String > items = error . split ( " \n " , false ) ;
error = " " ;
for ( int i = 0 ; i < items . size ( ) ; i + + ) {
if ( i > 0 ) {
error + = " \n " ;
}
error + = " - " + items [ i ] ;
}
export_warning - > set_text ( error ) ;
export_warning - > show ( ) ;
} else {
export_warning - > hide ( ) ;
}
2017-06-21 09:11:38 +00:00
export_error - > hide ( ) ;
2017-03-21 02:31:41 +00:00
export_templates_error - > hide ( ) ;
2017-03-28 01:21:21 +00:00
export_button - > set_disabled ( false ) ;
2017-03-21 02:31:41 +00:00
}
2017-07-19 20:00:46 +00:00
custom_features - > set_text ( current - > get_custom_features ( ) ) ;
_update_feature_list ( ) ;
2018-11-03 15:56:31 +00:00
_update_export_all ( ) ;
2020-03-06 17:00:16 +00:00
child_controls_changed ( ) ;
2017-07-19 20:00:46 +00:00
2023-06-20 02:50:09 +00:00
if ( ( feature_set . has ( " s3tc " ) | | feature_set . has ( " bptc " ) ) & & ! ResourceImporterTextureSettings : : should_import_s3tc_bptc ( ) ) {
export_texture_format_error - > show_for_texture_format ( " S3TC/BPTC " , " rendering/textures/vram_compression/import_s3tc_bptc " ) ;
} else if ( ( feature_set . has ( " etc2 " ) | | feature_set . has ( " astc " ) ) & & ! ResourceImporterTextureSettings : : should_import_etc2_astc ( ) ) {
export_texture_format_error - > show_for_texture_format ( " ETC2/ASTC " , " rendering/textures/vram_compression/import_etc2_astc " ) ;
} else {
export_texture_format_error - > hide ( ) ;
}
2020-04-28 17:51:29 +00:00
String enc_in_filters_str = current - > get_enc_in_filter ( ) ;
String enc_ex_filters_str = current - > get_enc_ex_filter ( ) ;
if ( ! updating_enc_filters ) {
enc_in_filters - > set_text ( enc_in_filters_str ) ;
enc_ex_filters - > set_text ( enc_ex_filters_str ) ;
}
bool enc_pck_mode = current - > get_enc_pck ( ) ;
enc_pck - > set_pressed ( enc_pck_mode ) ;
enc_directory - > set_disabled ( ! enc_pck_mode ) ;
enc_in_filters - > set_editable ( enc_pck_mode ) ;
enc_ex_filters - > set_editable ( enc_pck_mode ) ;
script_key - > set_editable ( enc_pck_mode ) ;
bool enc_directory_mode = current - > get_enc_directory ( ) ;
enc_directory - > set_pressed ( enc_directory_mode ) ;
2018-12-23 18:28:29 +00:00
String key = current - > get_script_encryption_key ( ) ;
if ( ! updating_script_key ) {
script_key - > set_text ( key ) ;
}
2020-04-28 17:51:29 +00:00
if ( enc_pck_mode ) {
2018-12-23 18:28:29 +00:00
script_key - > set_editable ( true ) ;
bool key_valid = _validate_script_encryption_key ( key ) ;
if ( key_valid ) {
script_key_error - > hide ( ) ;
} else {
script_key_error - > show ( ) ;
}
} else {
script_key - > set_editable ( false ) ;
script_key_error - > hide ( ) ;
}
2024-01-22 14:31:55 +00:00
int script_export_mode = current - > get_script_export_mode ( ) ;
script_mode - > select ( script_export_mode ) ;
2017-02-20 02:19:30 +00:00
updating = false ;
2014-02-26 13:08:17 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectExportDialog : : _update_feature_list ( ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-07-19 20:00:46 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2023-06-20 02:50:09 +00:00
List < String > features_list ;
2017-07-19 20:00:46 +00:00
2023-06-20 02:50:09 +00:00
current - > get_platform ( ) - > get_platform_features ( & features_list ) ;
current - > get_platform ( ) - > get_preset_features ( current , & features_list ) ;
2017-07-19 20:00:46 +00:00
String custom = current - > get_custom_features ( ) ;
Vector < String > custom_list = custom . split ( " , " ) ;
for ( int i = 0 ; i < custom_list . size ( ) ; i + + ) {
String f = custom_list [ i ] . strip_edges ( ) ;
2021-12-09 09:42:46 +00:00
if ( ! f . is_empty ( ) ) {
2023-06-20 02:50:09 +00:00
features_list . push_back ( f ) ;
2017-07-19 20:00:46 +00:00
}
}
2023-06-20 02:50:09 +00:00
feature_set . clear ( ) ;
for ( const String & E : features_list ) {
feature_set . insert ( E ) ;
2017-07-19 20:00:46 +00:00
}
custom_feature_display - > clear ( ) ;
2022-07-07 11:38:12 +00:00
String text ;
2022-05-19 15:00:06 +00:00
bool first = true ;
2023-06-20 02:50:09 +00:00
for ( const String & E : feature_set ) {
2022-05-19 15:00:06 +00:00
if ( ! first ) {
2022-07-07 11:38:12 +00:00
text + = " , " ;
2022-05-19 15:00:06 +00:00
} else {
first = false ;
2017-07-19 20:00:46 +00:00
}
2022-07-07 11:38:12 +00:00
text + = E ;
2017-07-19 20:00:46 +00:00
}
2022-07-07 11:38:12 +00:00
custom_feature_display - > add_text ( text ) ;
2017-07-19 20:00:46 +00:00
}
void ProjectExportDialog : : _custom_features_changed ( const String & p_text ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2017-07-19 20:00:46 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2017-07-19 20:00:46 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-07-19 20:00:46 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_custom_features ( p_text ) ;
_update_feature_list ( ) ;
}
void ProjectExportDialog : : _tab_changed ( int ) {
_update_feature_list ( ) ;
}
2017-03-28 01:21:21 +00:00
void ProjectExportDialog : : _update_parameters ( const String & p_edited_property ) {
2018-12-23 18:28:29 +00:00
_update_current_preset ( ) ;
2017-03-28 01:21:21 +00:00
}
2024-02-16 22:05:50 +00:00
void ProjectExportDialog : : _advanced_options_pressed ( ) {
if ( updating ) {
return ;
}
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_advanced_options_enabled ( advanced_options - > is_pressed ( ) ) ;
_update_presets ( ) ;
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _runnable_pressed ( ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-15 05:01:39 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-02-20 02:19:30 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2014-02-15 05:01:39 +00:00
2017-02-20 02:19:30 +00:00
if ( runnable - > is_pressed ( ) ) {
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > p = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
if ( p - > get_platform ( ) = = current - > get_platform ( ) ) {
p - > set_runnable ( current = = p ) ;
}
2014-02-15 05:01:39 +00:00
}
2017-02-20 02:19:30 +00:00
} else {
current - > set_runnable ( false ) ;
2014-02-10 01:10:30 +00:00
}
2017-02-20 02:19:30 +00:00
_update_presets ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _name_changed ( const String & p_string ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2014-02-13 21:03:28 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-13 21:03:28 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-02-20 02:19:30 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2015-12-13 04:08:36 +00:00
2017-02-20 02:19:30 +00:00
current - > set_name ( p_string ) ;
_update_presets ( ) ;
2014-02-13 21:03:28 +00:00
}
2018-11-12 19:04:58 +00:00
void ProjectExportDialog : : set_export_path ( const String & p_value ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-12 19:04:58 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_export_path ( p_value ) ;
}
String ProjectExportDialog : : get_export_path ( ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-12 19:04:58 +00:00
ERR_FAIL_COND_V ( current . is_null ( ) , String ( " " ) ) ;
return current - > get_export_path ( ) ;
}
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > ProjectExportDialog : : get_current_preset ( ) const {
return EditorExport : : get_singleton ( ) - > get_export_preset ( presets - > get_current ( ) ) ;
}
2019-01-18 16:01:24 +00:00
void ProjectExportDialog : : _export_path_changed ( const StringName & p_property , const Variant & p_value , const String & p_field , bool p_changing ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2018-11-06 01:01:34 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2018-11-06 01:01:34 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-06 01:01:34 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2018-11-12 19:04:58 +00:00
current - > set_export_path ( p_value ) ;
2018-11-06 01:01:34 +00:00
_update_presets ( ) ;
2019-11-04 15:29:09 +00:00
_update_export_all ( ) ;
2018-11-06 01:01:34 +00:00
}
2020-04-28 17:51:29 +00:00
void ProjectExportDialog : : _enc_filters_changed ( const String & p_filters ) {
if ( updating ) {
return ;
}
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_enc_in_filter ( enc_in_filters - > get_text ( ) ) ;
current - > set_enc_ex_filter ( enc_ex_filters - > get_text ( ) ) ;
updating_enc_filters = true ;
_update_current_preset ( ) ;
updating_enc_filters = false ;
}
void ProjectExportDialog : : _open_key_help_link ( ) {
2023-01-14 16:38:00 +00:00
OS : : get_singleton ( ) - > shell_open ( vformat ( " %s/contributing/development/compiling/compiling_with_script_encryption_key.html " , VERSION_DOCS_URL ) ) ;
2020-04-28 17:51:29 +00:00
}
void ProjectExportDialog : : _enc_pck_changed ( bool p_pressed ) {
if ( updating ) {
return ;
}
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_enc_pck ( p_pressed ) ;
enc_directory - > set_disabled ( ! p_pressed ) ;
enc_in_filters - > set_editable ( p_pressed ) ;
enc_ex_filters - > set_editable ( p_pressed ) ;
script_key - > set_editable ( p_pressed ) ;
_update_current_preset ( ) ;
}
void ProjectExportDialog : : _enc_directory_changed ( bool p_pressed ) {
if ( updating ) {
return ;
}
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_enc_directory ( p_pressed ) ;
_update_current_preset ( ) ;
}
2018-12-23 18:28:29 +00:00
void ProjectExportDialog : : _script_encryption_key_changed ( const String & p_key ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2018-12-23 18:28:29 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_script_encryption_key ( p_key ) ;
updating_script_key = true ;
_update_current_preset ( ) ;
updating_script_key = false ;
}
bool ProjectExportDialog : : _validate_script_encryption_key ( const String & p_key ) {
bool is_valid = false ;
2020-12-15 12:04:21 +00:00
if ( ! p_key . is_empty ( ) & & p_key . is_valid_hex_number ( false ) & & p_key . length ( ) = = 64 ) {
2018-12-23 18:28:29 +00:00
is_valid = true ;
}
return is_valid ;
}
2024-01-22 14:31:55 +00:00
void ProjectExportDialog : : _script_export_mode_changed ( int p_mode ) {
if ( updating ) {
return ;
}
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_script_export_mode ( p_mode ) ;
_update_current_preset ( ) ;
}
2018-10-28 18:13:38 +00:00
void ProjectExportDialog : : _duplicate_preset ( ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2018-10-28 18:13:38 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2018-10-28 18:13:38 +00:00
Ref < EditorExportPreset > preset = current - > get_platform ( ) - > create_preset ( ) ;
ERR_FAIL_COND ( ! preset . is_valid ( ) ) ;
2022-09-29 09:53:28 +00:00
String preset_name = current - > get_name ( ) + " (copy) " ;
2018-10-28 18:13:38 +00:00
bool make_runnable = true ;
while ( true ) {
bool valid = true ;
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > p = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
if ( p - > get_platform ( ) = = preset - > get_platform ( ) & & p - > is_runnable ( ) ) {
make_runnable = false ;
}
2022-09-29 09:53:28 +00:00
if ( p - > get_name ( ) = = preset_name ) {
2018-10-28 18:13:38 +00:00
valid = false ;
break ;
}
}
2020-05-14 14:41:43 +00:00
if ( valid ) {
2018-10-28 18:13:38 +00:00
break ;
2020-05-14 14:41:43 +00:00
}
2018-10-28 18:13:38 +00:00
2022-09-29 09:53:28 +00:00
preset_name + = " (copy) " ;
2018-10-28 18:13:38 +00:00
}
2022-09-29 09:53:28 +00:00
preset - > set_name ( preset_name ) ;
2020-05-14 14:41:43 +00:00
if ( make_runnable ) {
2018-10-28 18:13:38 +00:00
preset - > set_runnable ( make_runnable ) ;
2020-05-14 14:41:43 +00:00
}
2024-02-16 22:05:50 +00:00
preset - > set_advanced_options_enabled ( current - > are_advanced_options_enabled ( ) ) ;
2022-12-20 21:49:11 +00:00
preset - > set_dedicated_server ( current - > is_dedicated_server ( ) ) ;
2018-10-28 18:13:38 +00:00
preset - > set_export_filter ( current - > get_export_filter ( ) ) ;
preset - > set_include_filter ( current - > get_include_filter ( ) ) ;
preset - > set_exclude_filter ( current - > get_exclude_filter ( ) ) ;
preset - > set_custom_features ( current - > get_custom_features ( ) ) ;
2023-07-04 13:39:23 +00:00
for ( const KeyValue < StringName , Variant > & E : current - > get_values ( ) ) {
preset - > set ( E . key , E . value ) ;
2018-10-28 18:13:38 +00:00
}
EditorExport : : get_singleton ( ) - > add_export_preset ( preset ) ;
_update_presets ( ) ;
_edit_preset ( EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) - 1 ) ;
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _delete_preset ( ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
delete_confirm - > set_text ( vformat ( TTR ( " Delete preset '%s'? " ) , current - > get_name ( ) ) ) ;
2020-03-06 17:00:16 +00:00
delete_confirm - > popup_centered ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _delete_preset_confirm ( ) {
int idx = presets - > get_current ( ) ;
2017-09-04 18:45:18 +00:00
_edit_preset ( - 1 ) ;
2019-04-23 15:49:15 +00:00
export_button - > set_disabled ( true ) ;
2020-12-14 18:37:30 +00:00
get_ok_button ( ) - > set_disabled ( true ) ;
2017-02-20 02:19:30 +00:00
EditorExport : : get_singleton ( ) - > remove_export_preset ( idx ) ;
_update_presets ( ) ;
2019-11-04 15:29:09 +00:00
// The Export All button might become enabled (if all other presets have an export path defined),
// or it could be disabled (if there are no presets anymore).
_update_export_all ( ) ;
2014-02-13 21:03:28 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
Variant ProjectExportDialog : : get_drag_data_fw ( const Point2 & p_point , Control * p_from ) {
if ( p_from = = presets ) {
2017-09-10 13:37:49 +00:00
int pos = presets - > get_item_at_position ( p_point , true ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
if ( pos > = 0 ) {
Dictionary d ;
d [ " type " ] = " export_preset " ;
d [ " preset " ] = pos ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
HBoxContainer * drag = memnew ( HBoxContainer ) ;
TextureRect * tr = memnew ( TextureRect ) ;
tr - > set_texture ( presets - > get_item_icon ( pos ) ) ;
drag - > add_child ( tr ) ;
Label * label = memnew ( Label ) ;
label - > set_text ( presets - > get_item_text ( pos ) ) ;
drag - > add_child ( label ) ;
2014-02-10 01:10:30 +00:00
2020-03-06 17:00:16 +00:00
presets - > set_drag_preview ( drag ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
return d ;
}
}
2016-11-26 14:30:46 +00:00
2017-02-20 02:19:30 +00:00
return Variant ( ) ;
2016-11-26 14:30:46 +00:00
}
2017-02-20 02:19:30 +00:00
bool ProjectExportDialog : : can_drop_data_fw ( const Point2 & p_point , const Variant & p_data , Control * p_from ) const {
if ( p_from = = presets ) {
Dictionary d = p_data ;
2020-05-14 14:41:43 +00:00
if ( ! d . has ( " type " ) | | String ( d [ " type " ] ) ! = " export_preset " ) {
2017-02-20 02:19:30 +00:00
return false ;
2020-05-14 14:41:43 +00:00
}
2016-11-26 14:30:46 +00:00
2020-05-14 14:41:43 +00:00
if ( presets - > get_item_at_position ( p_point , true ) < 0 & & ! presets - > is_pos_at_end_of_items ( p_point ) ) {
2017-02-20 02:19:30 +00:00
return false ;
2020-05-14 14:41:43 +00:00
}
2016-11-26 14:30:46 +00:00
}
2017-02-20 02:19:30 +00:00
return true ;
2016-11-26 14:30:46 +00:00
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : drop_data_fw ( const Point2 & p_point , const Variant & p_data , Control * p_from ) {
if ( p_from = = presets ) {
Dictionary d = p_data ;
int from_pos = d [ " preset " ] ;
2016-11-26 14:30:46 +00:00
2017-02-20 02:19:30 +00:00
int to_pos = - 1 ;
2016-11-26 14:30:46 +00:00
2017-09-10 13:37:49 +00:00
if ( presets - > get_item_at_position ( p_point , true ) > = 0 ) {
to_pos = presets - > get_item_at_position ( p_point , true ) ;
2016-11-26 14:30:46 +00:00
}
2014-02-10 01:10:30 +00:00
2020-05-14 14:41:43 +00:00
if ( to_pos = = - 1 & & ! presets - > is_pos_at_end_of_items ( p_point ) ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2020-05-14 14:41:43 +00:00
if ( to_pos = = from_pos ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
} else if ( to_pos > from_pos ) {
2017-02-20 02:19:30 +00:00
to_pos - - ;
}
2014-10-23 10:04:21 +00:00
2017-02-20 02:19:30 +00:00
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( from_pos ) ;
EditorExport : : get_singleton ( ) - > remove_export_preset ( from_pos ) ;
EditorExport : : get_singleton ( ) - > add_export_preset ( preset , to_pos ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
_update_presets ( ) ;
2020-05-14 14:41:43 +00:00
if ( to_pos > = 0 ) {
2017-02-20 02:19:30 +00:00
_edit_preset ( to_pos ) ;
2020-05-14 14:41:43 +00:00
} else {
2017-02-20 02:19:30 +00:00
_edit_preset ( presets - > get_item_count ( ) - 1 ) ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
}
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _export_type_changed ( int p_which ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2014-02-10 01:10:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2014-02-10 01:10:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
EditorExportPreset : : ExportFilter filter_type = ( EditorExportPreset : : ExportFilter ) p_which ;
current - > set_export_filter ( filter_type ) ;
current - > set_dedicated_server ( filter_type = = EditorExportPreset : : EXPORT_CUSTOMIZED ) ;
server_strip_message - > set_visible ( filter_type = = EditorExportPreset : : EXPORT_CUSTOMIZED ) ;
// Default to stripping everything when first switching to server build.
if ( filter_type = = EditorExportPreset : : EXPORT_CUSTOMIZED & & current - > get_customized_files_count ( ) = = 0 ) {
current - > set_file_export_mode ( " res:// " , EditorExportPreset : : MODE_FILE_STRIP ) ;
}
2023-07-20 21:27:40 +00:00
include_label - > set_text ( _get_resource_export_header ( current - > get_export_filter ( ) ) ) ;
2022-12-20 21:49:11 +00:00
2017-02-20 02:19:30 +00:00
updating = true ;
_fill_resource_tree ( ) ;
updating = false ;
2014-02-10 01:10:30 +00:00
}
2023-07-20 21:27:40 +00:00
String ProjectExportDialog : : _get_resource_export_header ( EditorExportPreset : : ExportFilter p_filter ) const {
switch ( p_filter ) {
case EditorExportPreset : : EXCLUDE_SELECTED_RESOURCES :
return TTR ( " Resources to exclude: " ) ;
case EditorExportPreset : : EXPORT_CUSTOMIZED :
return TTR ( " Resources to override export behavior: " ) ;
default :
return TTR ( " Resources to export: " ) ;
}
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _filter_changed ( const String & p_filter ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2014-02-10 01:10:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
current - > set_include_filter ( include_filters - > get_text ( ) ) ;
current - > set_exclude_filter ( exclude_filters - > get_text ( ) ) ;
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _fill_resource_tree ( ) {
include_files - > clear ( ) ;
include_label - > hide ( ) ;
include_margin - > hide ( ) ;
2014-02-10 01:10:30 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
EditorExportPreset : : ExportFilter f = current - > get_export_filter ( ) ;
2014-02-10 01:10:30 +00:00
2017-02-21 03:05:15 +00:00
if ( f = = EditorExportPreset : : EXPORT_ALL_RESOURCES ) {
2017-02-20 02:19:30 +00:00
return ;
2014-02-10 01:10:30 +00:00
}
2022-12-20 21:49:11 +00:00
TreeItem * root = include_files - > create_item ( ) ;
if ( f = = EditorExportPreset : : EXPORT_CUSTOMIZED ) {
include_files - > set_columns ( 2 ) ;
include_files - > set_column_expand ( 1 , false ) ;
include_files - > set_column_custom_minimum_width ( 1 , 250 * EDSCALE ) ;
} else {
include_files - > set_columns ( 1 ) ;
}
2017-02-20 02:19:30 +00:00
include_label - > show ( ) ;
include_margin - > show ( ) ;
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
_fill_tree ( EditorFileSystem : : get_singleton ( ) - > get_filesystem ( ) , root , current , f ) ;
2023-01-30 20:34:05 +00:00
if ( f = = EditorExportPreset : : EXPORT_CUSTOMIZED ) {
_propagate_file_export_mode ( include_files - > get_root ( ) , EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) ;
}
2022-12-20 21:49:11 +00:00
}
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
void ProjectExportDialog : : _setup_item_for_file_mode ( TreeItem * p_item , EditorExportPreset : : FileExportMode p_mode ) {
if ( p_mode = = EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) {
p_item - > set_checked ( 0 , false ) ;
p_item - > set_cell_mode ( 1 , TreeItem : : CELL_MODE_STRING ) ;
p_item - > set_editable ( 1 , false ) ;
p_item - > set_selectable ( 1 , false ) ;
2024-01-15 12:14:55 +00:00
p_item - > set_custom_color ( 1 , get_theme_color ( SNAME ( " font_disabled_color " ) , EditorStringName ( Editor ) ) ) ;
2022-12-20 21:49:11 +00:00
} else {
p_item - > set_checked ( 0 , true ) ;
p_item - > set_cell_mode ( 1 , TreeItem : : CELL_MODE_CUSTOM ) ;
p_item - > set_editable ( 1 , true ) ;
p_item - > set_selectable ( 1 , true ) ;
2023-01-30 20:34:05 +00:00
p_item - > clear_custom_color ( 1 ) ;
2022-12-20 21:49:11 +00:00
}
2023-01-30 20:34:05 +00:00
p_item - > set_metadata ( 1 , p_mode ) ;
2017-02-20 02:19:30 +00:00
}
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
bool ProjectExportDialog : : _fill_tree ( EditorFileSystemDirectory * p_dir , TreeItem * p_item , Ref < EditorExportPreset > & current , EditorExportPreset : : ExportFilter p_export_filter ) {
2020-11-14 15:02:14 +00:00
p_item - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
2021-07-17 21:22:52 +00:00
p_item - > set_icon ( 0 , presets - > get_theme_icon ( SNAME ( " folder " ) , SNAME ( " FileDialog " ) ) ) ;
2017-02-20 02:19:30 +00:00
p_item - > set_text ( 0 , p_dir - > get_name ( ) + " / " ) ;
2020-11-14 15:02:14 +00:00
p_item - > set_editable ( 0 , true ) ;
p_item - > set_metadata ( 0 , p_dir - > get_path ( ) ) ;
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
if ( p_export_filter = = EditorExportPreset : : EXPORT_CUSTOMIZED ) {
_setup_item_for_file_mode ( p_item , current - > get_file_export_mode ( p_dir - > get_path ( ) ) ) ;
}
2017-02-20 02:19:30 +00:00
bool used = false ;
for ( int i = 0 ; i < p_dir - > get_subdir_count ( ) ; i + + ) {
TreeItem * subdir = include_files - > create_item ( p_item ) ;
2022-12-20 21:49:11 +00:00
if ( _fill_tree ( p_dir - > get_subdir ( i ) , subdir , current , p_export_filter ) ) {
2017-02-20 02:19:30 +00:00
used = true ;
2018-10-06 20:20:41 +00:00
} else {
memdelete ( subdir ) ;
2014-02-10 01:10:30 +00:00
}
}
2017-02-20 02:19:30 +00:00
for ( int i = 0 ; i < p_dir - > get_file_count ( ) ; i + + ) {
String type = p_dir - > get_file_type ( i ) ;
2022-12-20 21:49:11 +00:00
if ( p_export_filter = = EditorExportPreset : : EXPORT_SELECTED_SCENES & & type ! = " PackedScene " ) {
2017-02-20 02:19:30 +00:00
continue ;
2020-05-14 14:41:43 +00:00
}
2021-09-23 21:09:15 +00:00
if ( type = = " TextFile " ) {
continue ;
}
2014-06-11 13:41:03 +00:00
2017-02-20 02:19:30 +00:00
TreeItem * file = include_files - > create_item ( p_item ) ;
file - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
file - > set_text ( 0 , p_dir - > get_file ( i ) ) ;
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
String path = p_dir - > get_file_path ( i ) ;
2014-02-10 01:10:30 +00:00
2018-09-02 21:40:51 +00:00
file - > set_icon ( 0 , EditorNode : : get_singleton ( ) - > get_class_icon ( type ) ) ;
2017-02-20 02:19:30 +00:00
file - > set_editable ( 0 , true ) ;
file - > set_metadata ( 0 , path ) ;
2022-12-20 21:49:11 +00:00
if ( p_export_filter = = EditorExportPreset : : EXPORT_CUSTOMIZED ) {
_setup_item_for_file_mode ( file , current - > get_file_export_mode ( path ) ) ;
} else {
file - > set_checked ( 0 , current - > has_export_file ( path ) ) ;
file - > propagate_check ( 0 ) ;
}
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
used = true ;
2017-02-20 02:19:30 +00:00
}
return used ;
2014-02-10 01:10:30 +00:00
}
2023-01-30 20:34:05 +00:00
void ProjectExportDialog : : _propagate_file_export_mode ( TreeItem * p_item , EditorExportPreset : : FileExportMode p_inherited_export_mode ) {
EditorExportPreset : : FileExportMode file_export_mode = ( EditorExportPreset : : FileExportMode ) ( int ) p_item - > get_metadata ( 1 ) ;
2023-05-03 14:47:33 +00:00
bool is_inherited = false ;
2023-01-30 20:34:05 +00:00
if ( file_export_mode = = EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) {
file_export_mode = p_inherited_export_mode ;
2023-05-03 14:47:33 +00:00
is_inherited = true ;
2023-01-30 20:34:05 +00:00
}
if ( file_export_mode = = EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) {
p_item - > set_text ( 1 , " " ) ;
} else {
2023-05-03 14:47:33 +00:00
String text = file_mode_popup - > get_item_text ( file_mode_popup - > get_item_index ( file_export_mode ) ) ;
if ( is_inherited ) {
text + = " " + TTR ( " (Inherited) " ) ;
}
p_item - > set_text ( 1 , text ) ;
2023-01-30 20:34:05 +00:00
}
for ( int i = 0 ; i < p_item - > get_child_count ( ) ; i + + ) {
_propagate_file_export_mode ( p_item - > get_child ( i ) , file_export_mode ) ;
}
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _tree_changed ( ) {
2020-05-14 14:41:43 +00:00
if ( updating ) {
2014-02-10 01:10:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 14:41:43 +00:00
if ( current . is_null ( ) ) {
2017-02-20 02:19:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2017-02-20 02:19:30 +00:00
TreeItem * item = include_files - > get_edited ( ) ;
2020-05-14 14:41:43 +00:00
if ( ! item ) {
2014-02-10 01:10:30 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2014-02-10 01:10:30 +00:00
2022-12-20 21:49:11 +00:00
if ( current - > get_export_filter ( ) = = EditorExportPreset : : EXPORT_CUSTOMIZED ) {
EditorExportPreset : : FileExportMode file_mode = EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ;
String path = item - > get_metadata ( 0 ) ;
if ( item - > is_checked ( 0 ) ) {
file_mode = current - > get_file_export_mode ( path , EditorExportPreset : : MODE_FILE_STRIP ) ;
}
current - > set_file_export_mode ( path , file_mode ) ;
2023-01-30 20:34:05 +00:00
_setup_item_for_file_mode ( item , file_mode ) ;
_propagate_file_export_mode ( include_files - > get_root ( ) , EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) ;
2022-12-20 21:49:11 +00:00
} else {
item - > propagate_check ( 0 ) ;
}
2021-09-17 15:50:24 +00:00
}
2014-02-10 01:10:30 +00:00
2021-09-17 15:50:24 +00:00
void ProjectExportDialog : : _check_propagated_to_item ( Object * p_obj , int column ) {
Ref < EditorExportPreset > current = get_current_preset ( ) ;
if ( current . is_null ( ) ) {
return ;
}
TreeItem * item = Object : : cast_to < TreeItem > ( p_obj ) ;
String path = item - > get_metadata ( 0 ) ;
if ( item & & ! path . ends_with ( " / " ) ) {
bool added = item - > is_checked ( 0 ) ;
2020-11-14 15:02:14 +00:00
if ( added ) {
current - > add_export_file ( path ) ;
} else {
current - > remove_export_file ( path ) ;
}
}
}
2022-12-20 21:49:11 +00:00
void ProjectExportDialog : : _tree_popup_edited ( bool p_arrow_clicked ) {
Rect2 bounds = include_files - > get_custom_popup_rect ( ) ;
bounds . position + = get_global_canvas_transform ( ) . get_origin ( ) ;
bounds . size * = get_global_canvas_transform ( ) . get_scale ( ) ;
if ( ! is_embedding_subwindows ( ) ) {
bounds . position + = get_position ( ) ;
}
file_mode_popup - > popup ( bounds ) ;
}
void ProjectExportDialog : : _set_file_export_mode ( int p_id ) {
Ref < EditorExportPreset > current = get_current_preset ( ) ;
if ( current . is_null ( ) ) {
return ;
}
TreeItem * item = include_files - > get_edited ( ) ;
String path = item - > get_metadata ( 0 ) ;
2023-01-30 20:34:05 +00:00
EditorExportPreset : : FileExportMode file_export_mode = ( EditorExportPreset : : FileExportMode ) p_id ;
current - > set_file_export_mode ( path , file_export_mode ) ;
item - > set_metadata ( 1 , file_export_mode ) ;
_propagate_file_export_mode ( include_files - > get_root ( ) , EditorExportPreset : : MODE_FILE_NOT_CUSTOMIZED ) ;
2022-12-20 21:49:11 +00:00
}
2017-02-21 03:05:15 +00:00
void ProjectExportDialog : : _export_pck_zip ( ) {
2020-06-26 11:53:18 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
String dir = current - > get_export_path ( ) . get_base_dir ( ) ;
export_pck_zip - > set_current_dir ( dir ) ;
2020-07-11 16:45:19 +00:00
export_pck_zip - > popup_file_dialog ( ) ;
2017-02-21 03:05:15 +00:00
}
void ProjectExportDialog : : _export_pck_zip_selected ( const String & p_path ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-02-21 03:05:15 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
ERR_FAIL_COND ( platform . is_null ( ) ) ;
2024-03-21 08:42:38 +00:00
const Dictionary & fd_option = export_pck_zip - > get_selected_options ( ) ;
bool export_debug = fd_option . get ( TTR ( " Export With Debug " ) , true ) ;
2017-02-21 03:05:15 +00:00
if ( p_path . ends_with ( " .zip " ) ) {
2024-03-21 08:42:38 +00:00
platform - > export_zip ( current , export_debug , p_path ) ;
2017-02-21 03:05:15 +00:00
} else if ( p_path . ends_with ( " .pck " ) ) {
2024-03-21 08:42:38 +00:00
platform - > export_pack ( current , export_debug , p_path ) ;
2024-03-06 17:14:21 +00:00
} else {
ERR_FAIL_MSG ( " Path must end with .pck or .zip " ) ;
2017-02-21 03:05:15 +00:00
}
}
2017-03-21 02:31:41 +00:00
void ProjectExportDialog : : _open_export_template_manager ( ) {
hide ( ) ;
2023-02-15 14:35:16 +00:00
EditorNode : : get_singleton ( ) - > open_export_template_manager ( ) ;
2017-03-21 02:31:41 +00:00
}
2018-08-31 08:48:40 +00:00
void ProjectExportDialog : : _validate_export_path ( const String & p_path ) {
// Disable export via OK button or Enter key if LineEdit has an empty filename
2021-12-09 09:42:46 +00:00
bool invalid_path = ( p_path . get_file ( ) . get_basename ( ) . is_empty ( ) ) ;
2018-08-31 08:48:40 +00:00
// Check if state change before needlessly messing with signals
2020-12-14 18:37:30 +00:00
if ( invalid_path & & export_project - > get_ok_button ( ) - > is_disabled ( ) ) {
2018-08-31 08:48:40 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2020-12-14 18:37:30 +00:00
if ( ! invalid_path & & ! export_project - > get_ok_button ( ) - > is_disabled ( ) ) {
2018-08-31 08:48:40 +00:00
return ;
2020-05-14 14:41:43 +00:00
}
2018-08-31 08:48:40 +00:00
if ( invalid_path ) {
2020-12-14 18:37:30 +00:00
export_project - > get_ok_button ( ) - > set_disabled ( true ) ;
2020-12-06 15:09:18 +00:00
export_project - > get_line_edit ( ) - > disconnect ( " text_submitted " , callable_mp ( export_project , & EditorFileDialog : : _file_submitted ) ) ;
2018-08-31 08:48:40 +00:00
} else {
2020-12-14 18:37:30 +00:00
export_project - > get_ok_button ( ) - > set_disabled ( false ) ;
2020-12-06 15:09:18 +00:00
export_project - > get_line_edit ( ) - > connect ( " text_submitted " , callable_mp ( export_project , & EditorFileDialog : : _file_submitted ) ) ;
2018-08-31 08:48:40 +00:00
}
}
2017-03-21 22:34:26 +00:00
void ProjectExportDialog : : _export_project ( ) {
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-03-21 22:34:26 +00:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
ERR_FAIL_COND ( platform . is_null ( ) ) ;
2019-04-24 18:52:15 +00:00
export_project - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2017-03-21 22:34:26 +00:00
export_project - > clear_filters ( ) ;
2017-12-12 21:09:48 +00:00
2018-10-29 21:18:49 +00:00
List < String > extension_list = platform - > get_binary_extensions ( current ) ;
for ( int i = 0 ; i < extension_list . size ( ) ; i + + ) {
2022-03-05 04:32:38 +00:00
// TRANSLATORS: This is the name of a project export file format. %s will be replaced by the platform name.
2022-07-04 21:26:26 +00:00
export_project - > add_filter ( " *. " + extension_list [ i ] , vformat ( TTR ( " %s Export " ) , platform - > get_name ( ) ) ) ;
2018-10-29 21:18:49 +00:00
}
2021-12-09 09:42:46 +00:00
if ( ! current - > get_export_path ( ) . is_empty ( ) ) {
2019-08-22 20:14:45 +00:00
export_project - > set_current_path ( current - > get_export_path ( ) ) ;
2018-08-31 08:48:40 +00:00
} else {
2018-10-29 21:18:49 +00:00
if ( extension_list . size ( ) > = 1 ) {
export_project - > set_current_file ( default_filename + " . " + extension_list [ 0 ] ) ;
2018-10-27 13:53:05 +00:00
} else {
export_project - > set_current_file ( default_filename ) ;
}
2018-08-31 08:48:40 +00:00
}
2020-02-27 21:49:16 +00:00
// Ensure that signal is connected if previous attempt left it disconnected
// with _validate_export_path.
// FIXME: This is a hack, we should instead change EditorFileDialog to allow
2021-06-16 16:43:34 +00:00
// disabling validation by the "text_submitted" signal.
2020-12-06 15:09:18 +00:00
if ( ! export_project - > get_line_edit ( ) - > is_connected ( " text_submitted " , callable_mp ( export_project , & EditorFileDialog : : _file_submitted ) ) ) {
2020-12-14 18:37:30 +00:00
export_project - > get_ok_button ( ) - > set_disabled ( false ) ;
2020-12-06 15:09:18 +00:00
export_project - > get_line_edit ( ) - > connect ( " text_submitted " , callable_mp ( export_project , & EditorFileDialog : : _file_submitted ) ) ;
2017-03-21 22:34:26 +00:00
}
2020-03-06 17:00:16 +00:00
export_project - > set_file_mode ( EditorFileDialog : : FILE_MODE_SAVE_FILE ) ;
2020-07-11 16:45:19 +00:00
export_project - > popup_file_dialog ( ) ;
2017-03-21 22:34:26 +00:00
}
void ProjectExportDialog : : _export_project_to_path ( const String & p_path ) {
2017-10-28 08:57:29 +00:00
// Save this name for use in future exports (but drop the file extension)
2018-08-31 08:48:40 +00:00
default_filename = p_path . get_file ( ) . get_basename ( ) ;
2017-10-28 08:57:29 +00:00
EditorSettings : : get_singleton ( ) - > set_project_metadata ( " export_options " , " default_filename " , default_filename ) ;
2017-03-21 22:34:26 +00:00
2018-12-23 18:28:29 +00:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2023-11-20 13:44:38 +00:00
ERR_FAIL_COND_MSG ( current . is_null ( ) , " Failed to start the export: current preset is invalid. " ) ;
2017-03-21 22:34:26 +00:00
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
2023-11-20 13:44:38 +00:00
ERR_FAIL_COND_MSG ( platform . is_null ( ) , " Failed to start the export: current preset has no valid platform. " ) ;
2018-10-27 13:53:05 +00:00
current - > set_export_path ( p_path ) ;
2017-03-21 22:34:26 +00:00
2023-11-20 13:44:38 +00:00
exporting = true ;
2022-06-03 15:34:24 +00:00
platform - > clear_messages ( ) ;
2024-02-12 22:16:48 +00:00
current - > update_value_overrides ( ) ;
2024-03-21 08:42:38 +00:00
Dictionary fd_option = export_project - > get_selected_options ( ) ;
bool export_debug = fd_option . get ( TTR ( " Export With Debug " ) , true ) ;
Error err = platform - > export_project ( current , export_debug , current - > get_export_path ( ) , 0 ) ;
2022-06-03 15:34:24 +00:00
result_dialog_log - > clear ( ) ;
if ( err ! = ERR_SKIP ) {
if ( platform - > fill_log_messages ( result_dialog_log , err ) ) {
result_dialog - > popup_centered_ratio ( 0.5 ) ;
2019-02-22 09:21:34 +00:00
}
2017-10-12 22:38:42 +00:00
}
2023-11-20 13:44:38 +00:00
exporting = false ;
2017-03-21 22:34:26 +00:00
}
2018-11-03 15:56:31 +00:00
void ProjectExportDialog : : _export_all_dialog ( ) {
2022-09-14 03:48:33 +00:00
# ifndef ANDROID_ENABLED
2018-11-03 15:56:31 +00:00
export_all_dialog - > show ( ) ;
2020-03-06 17:00:16 +00:00
export_all_dialog - > popup_centered ( Size2 ( 300 , 80 ) ) ;
2022-09-14 03:48:33 +00:00
# endif
2018-11-03 15:56:31 +00:00
}
void ProjectExportDialog : : _export_all_dialog_action ( const String & p_str ) {
export_all_dialog - > hide ( ) ;
2019-06-26 13:08:25 +00:00
_export_all ( p_str ! = " release " ) ;
2018-11-03 15:56:31 +00:00
}
void ProjectExportDialog : : _export_all ( bool p_debug ) {
2023-11-20 13:44:38 +00:00
exporting = true ;
2022-06-03 15:34:24 +00:00
bool show_dialog = false ;
2023-11-20 13:44:38 +00:00
2023-12-06 14:18:35 +00:00
{ // Scope for the editor progress, we must free it before showing the dialog at the end.
String export_target = p_debug ? TTR ( " Debug " ) : TTR ( " Release " ) ;
EditorProgress ep ( " exportall " , TTR ( " Exporting All " ) + " " + export_target , EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) , true ) ;
2018-11-03 15:56:31 +00:00
2023-12-06 14:18:35 +00:00
result_dialog_log - > clear ( ) ;
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
if ( preset . is_null ( ) ) {
exporting = false ;
ERR_FAIL_MSG ( " Failed to start the export: one of the presets is invalid. " ) ;
}
2018-11-03 15:56:31 +00:00
2023-12-06 14:18:35 +00:00
Ref < EditorExportPlatform > platform = preset - > get_platform ( ) ;
if ( platform . is_null ( ) ) {
exporting = false ;
ERR_FAIL_MSG ( " Failed to start the export: one of the presets has no valid platform. " ) ;
}
ep . step ( preset - > get_name ( ) , i ) ;
platform - > clear_messages ( ) ;
2024-02-12 22:16:48 +00:00
preset - > update_value_overrides ( ) ;
2023-12-06 14:18:35 +00:00
Error err = platform - > export_project ( preset , p_debug , preset - > get_export_path ( ) , 0 ) ;
if ( err = = ERR_SKIP ) {
exporting = false ;
return ;
}
bool has_messages = platform - > fill_log_messages ( result_dialog_log , err ) ;
show_dialog = show_dialog | | has_messages ;
2018-11-03 15:56:31 +00:00
}
2022-06-03 15:34:24 +00:00
}
2023-12-06 14:18:35 +00:00
2022-06-03 15:34:24 +00:00
if ( show_dialog ) {
result_dialog - > popup_centered_ratio ( 0.5 ) ;
2018-11-03 15:56:31 +00:00
}
2023-11-20 13:44:38 +00:00
exporting = false ;
2018-11-03 15:56:31 +00:00
}
2017-02-20 02:19:30 +00:00
void ProjectExportDialog : : _bind_methods ( ) {
2018-11-12 19:04:58 +00:00
ClassDB : : bind_method ( " set_export_path " , & ProjectExportDialog : : set_export_path ) ;
ClassDB : : bind_method ( " get_export_path " , & ProjectExportDialog : : get_export_path ) ;
2018-12-23 18:28:29 +00:00
ClassDB : : bind_method ( " get_current_preset " , & ProjectExportDialog : : get_current_preset ) ;
2018-11-12 19:04:58 +00:00
ADD_PROPERTY ( PropertyInfo ( Variant : : STRING , " export_path " ) , " set_export_path " , " get_export_path " ) ;
2017-02-20 02:19:30 +00:00
}
2018-08-31 08:48:40 +00:00
2017-02-20 02:19:30 +00:00
ProjectExportDialog : : ProjectExportDialog ( ) {
2017-03-02 21:43:56 +00:00
set_title ( TTR ( " Export " ) ) ;
2023-03-19 16:26:22 +00:00
set_clamp_to_embedder ( true ) ;
2017-03-02 21:43:56 +00:00
2017-03-21 02:31:41 +00:00
VBoxContainer * main_vb = memnew ( VBoxContainer ) ;
add_child ( main_vb ) ;
2023-12-04 12:18:48 +00:00
2019-01-11 16:54:00 +00:00
HSplitContainer * hbox = memnew ( HSplitContainer ) ;
2017-03-21 02:31:41 +00:00
main_vb - > add_child ( hbox ) ;
2020-03-06 17:00:16 +00:00
hbox - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Presets list.
2017-02-20 02:19:30 +00:00
VBoxContainer * preset_vb = memnew ( VBoxContainer ) ;
preset_vb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbox - > add_child ( preset_vb ) ;
2021-07-08 13:29:15 +00:00
Label * l = memnew ( Label ( TTR ( " Presets " ) ) ) ;
l - > set_theme_type_variation ( " HeaderSmall " ) ;
2017-02-20 02:19:30 +00:00
HBoxContainer * preset_hb = memnew ( HBoxContainer ) ;
2021-07-08 13:29:15 +00:00
preset_hb - > add_child ( l ) ;
2017-02-20 02:19:30 +00:00
preset_hb - > add_spacer ( ) ;
preset_vb - > add_child ( preset_hb ) ;
add_preset = memnew ( MenuButton ) ;
2018-04-22 17:36:01 +00:00
add_preset - > set_text ( TTR ( " Add... " ) ) ;
2020-02-21 17:28:45 +00:00
add_preset - > get_popup ( ) - > connect ( " index_pressed " , callable_mp ( this , & ProjectExportDialog : : _add_preset ) ) ;
2017-02-20 02:19:30 +00:00
preset_hb - > add_child ( add_preset ) ;
MarginContainer * mc = memnew ( MarginContainer ) ;
preset_vb - > add_child ( mc ) ;
2020-03-06 17:00:16 +00:00
mc - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 02:19:30 +00:00
presets = memnew ( ItemList ) ;
2024-01-23 21:29:45 +00:00
presets - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2023-01-14 02:37:19 +00:00
SET_DRAG_FORWARDING_GCD ( presets , ProjectExportDialog ) ;
2017-02-20 02:19:30 +00:00
mc - > add_child ( presets ) ;
2020-02-21 17:28:45 +00:00
presets - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _edit_preset ) ) ;
2020-06-19 18:49:04 +00:00
duplicate_preset = memnew ( Button ) ;
2022-08-25 10:42:17 +00:00
duplicate_preset - > set_tooltip_text ( TTR ( " Duplicate " ) ) ;
2020-06-19 18:49:04 +00:00
duplicate_preset - > set_flat ( true ) ;
2018-10-28 18:13:38 +00:00
preset_hb - > add_child ( duplicate_preset ) ;
2020-02-21 17:28:45 +00:00
duplicate_preset - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _duplicate_preset ) ) ;
2020-06-19 18:49:04 +00:00
delete_preset = memnew ( Button ) ;
2022-08-25 10:42:17 +00:00
delete_preset - > set_tooltip_text ( TTR ( " Delete " ) ) ;
2020-06-19 18:49:04 +00:00
delete_preset - > set_flat ( true ) ;
2017-02-20 02:19:30 +00:00
preset_hb - > add_child ( delete_preset ) ;
2020-02-21 17:28:45 +00:00
delete_preset - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _delete_preset ) ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Preset settings.
2017-02-20 02:19:30 +00:00
VBoxContainer * settings_vb = memnew ( VBoxContainer ) ;
settings_vb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbox - > add_child ( settings_vb ) ;
name = memnew ( LineEdit ) ;
settings_vb - > add_margin_child ( TTR ( " Name: " ) , name ) ;
2020-02-21 17:28:45 +00:00
name - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _name_changed ) ) ;
2024-02-16 22:05:50 +00:00
2017-02-20 02:19:30 +00:00
runnable = memnew ( CheckButton ) ;
runnable - > set_text ( TTR ( " Runnable " ) ) ;
2022-08-25 10:42:17 +00:00
runnable - > set_tooltip_text ( TTR ( " If checked, the preset will be available for use in one-click deploy. \n Only one preset per platform may be marked as runnable. " ) ) ;
2020-02-21 17:28:45 +00:00
runnable - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _runnable_pressed ) ) ;
2024-02-16 22:05:50 +00:00
advanced_options = memnew ( CheckButton ) ;
advanced_options - > set_text ( TTR ( " Advanced Options " ) ) ;
advanced_options - > set_tooltip_text ( TTR ( " If checked, the advanced options will be shown. " ) ) ;
advanced_options - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _advanced_options_pressed ) ) ;
HBoxContainer * preset_configs_container = memnew ( HBoxContainer ) ;
preset_configs_container - > add_spacer ( true ) ;
preset_configs_container - > add_child ( advanced_options ) ;
preset_configs_container - > add_child ( runnable ) ;
settings_vb - > add_child ( preset_configs_container ) ;
2017-02-20 02:19:30 +00:00
2018-11-12 19:04:58 +00:00
export_path = memnew ( EditorPropertyPath ) ;
settings_vb - > add_child ( export_path ) ;
export_path - > set_label ( TTR ( " Export Path " ) ) ;
export_path - > set_object_and_property ( this , " export_path " ) ;
export_path - > set_save_mode ( ) ;
2020-02-21 17:28:45 +00:00
export_path - > connect ( " property_changed " , callable_mp ( this , & ProjectExportDialog : : _export_path_changed ) ) ;
2018-11-06 01:01:34 +00:00
2020-01-08 12:29:49 +00:00
// Subsections.
2017-02-20 02:19:30 +00:00
sections = memnew ( TabContainer ) ;
2019-01-26 18:41:36 +00:00
sections - > set_use_hidden_tabs_for_min_size ( true ) ;
2022-05-27 02:12:09 +00:00
sections - > set_theme_type_variation ( " TabContainerOdd " ) ;
2017-02-20 02:19:30 +00:00
settings_vb - > add_child ( sections ) ;
2020-03-06 17:00:16 +00:00
sections - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Main preset parameters.
2018-08-18 13:07:23 +00:00
parameters = memnew ( EditorInspector ) ;
2017-02-20 02:19:30 +00:00
sections - > add_child ( parameters ) ;
parameters - > set_name ( TTR ( " Options " ) ) ;
2020-03-06 17:00:16 +00:00
parameters - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-03-09 08:41:52 +00:00
parameters - > set_use_doc_hints ( true ) ;
2020-02-21 17:28:45 +00:00
parameters - > connect ( " property_edited " , callable_mp ( this , & ProjectExportDialog : : _update_parameters ) ) ;
2020-04-24 07:45:14 +00:00
EditorExport : : get_singleton ( ) - > connect ( " export_presets_updated " , callable_mp ( this , & ProjectExportDialog : : _force_update_current_preset_parameters ) ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Resources export parameters.
2017-02-20 02:19:30 +00:00
VBoxContainer * resources_vb = memnew ( VBoxContainer ) ;
sections - > add_child ( resources_vb ) ;
resources_vb - > set_name ( TTR ( " Resources " ) ) ;
export_filter = memnew ( OptionButton ) ;
export_filter - > add_item ( TTR ( " Export all resources in the project " ) ) ;
export_filter - > add_item ( TTR ( " Export selected scenes (and dependencies) " ) ) ;
export_filter - > add_item ( TTR ( " Export selected resources (and dependencies) " ) ) ;
2020-11-15 00:54:24 +00:00
export_filter - > add_item ( TTR ( " Export all resources in the project except resources checked below " ) ) ;
2022-12-20 21:49:11 +00:00
export_filter - > add_item ( TTR ( " Export as dedicated server " ) ) ;
2017-02-20 02:19:30 +00:00
resources_vb - > add_margin_child ( TTR ( " Export Mode: " ) , export_filter ) ;
2020-02-21 17:28:45 +00:00
export_filter - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _export_type_changed ) ) ;
2017-02-20 02:19:30 +00:00
include_label = memnew ( Label ) ;
include_label - > set_text ( TTR ( " Resources to export: " ) ) ;
resources_vb - > add_child ( include_label ) ;
include_margin = memnew ( MarginContainer ) ;
2020-03-06 17:00:16 +00:00
include_margin - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 02:19:30 +00:00
resources_vb - > add_child ( include_margin ) ;
include_files = memnew ( Tree ) ;
include_margin - > add_child ( include_files ) ;
2024-03-17 08:28:18 +00:00
include_files - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2020-02-21 17:28:45 +00:00
include_files - > connect ( " item_edited " , callable_mp ( this , & ProjectExportDialog : : _tree_changed ) ) ;
2021-09-17 15:50:24 +00:00
include_files - > connect ( " check_propagated_to_item " , callable_mp ( this , & ProjectExportDialog : : _check_propagated_to_item ) ) ;
2022-12-20 21:49:11 +00:00
include_files - > connect ( " custom_popup_edited " , callable_mp ( this , & ProjectExportDialog : : _tree_popup_edited ) ) ;
server_strip_message = memnew ( Label ) ;
server_strip_message - > set_visible ( false ) ;
server_strip_message - > set_autowrap_mode ( TextServer : : AUTOWRAP_WORD_SMART ) ;
2023-12-14 02:41:22 +00:00
server_strip_message - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 1 ) ) ;
2022-12-20 21:49:11 +00:00
resources_vb - > add_child ( server_strip_message ) ;
{
List < StringName > resource_names ;
ClassDB : : get_inheriters_from_class ( " Resource " , & resource_names ) ;
PackedStringArray strippable ;
2021-08-01 19:47:20 +00:00
for ( const StringName & resource_name : resource_names ) {
2022-12-20 21:49:11 +00:00
if ( ClassDB : : has_method ( resource_name , " create_placeholder " , true ) ) {
strippable . push_back ( resource_name ) ;
}
}
strippable . sort ( ) ;
String message = TTR ( " \" Strip Visuals \" will replace the following resources with placeholders: " ) + " " ;
message + = String ( " , " ) . join ( strippable ) ;
server_strip_message - > set_text ( message ) ;
}
file_mode_popup = memnew ( PopupMenu ) ;
add_child ( file_mode_popup ) ;
file_mode_popup - > add_item ( TTR ( " Strip Visuals " ) , EditorExportPreset : : MODE_FILE_STRIP ) ;
file_mode_popup - > add_item ( TTR ( " Keep " ) , EditorExportPreset : : MODE_FILE_KEEP ) ;
file_mode_popup - > add_item ( TTR ( " Remove " ) , EditorExportPreset : : MODE_FILE_REMOVE ) ;
file_mode_popup - > connect ( " id_pressed " , callable_mp ( this , & ProjectExportDialog : : _set_file_export_mode ) ) ;
2017-02-20 02:19:30 +00:00
include_filters = memnew ( LineEdit ) ;
2019-10-05 14:45:12 +00:00
resources_vb - > add_margin_child (
TTR ( " Filters to export non-resource files/folders \n (comma-separated, e.g: *.json, *.txt, docs/*) " ) ,
include_filters ) ;
2020-02-21 17:28:45 +00:00
include_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _filter_changed ) ) ;
2017-02-20 02:19:30 +00:00
exclude_filters = memnew ( LineEdit ) ;
2019-10-05 14:45:12 +00:00
resources_vb - > add_margin_child (
TTR ( " Filters to exclude files/folders from project \n (comma-separated, e.g: *.json, *.txt, docs/*) " ) ,
exclude_filters ) ;
2020-02-21 17:28:45 +00:00
exclude_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _filter_changed ) ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Feature tags.
2017-07-19 20:00:46 +00:00
VBoxContainer * feature_vb = memnew ( VBoxContainer ) ;
feature_vb - > set_name ( TTR ( " Features " ) ) ;
custom_features = memnew ( LineEdit ) ;
2020-02-21 17:28:45 +00:00
custom_features - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _custom_features_changed ) ) ;
2017-07-19 20:00:46 +00:00
feature_vb - > add_margin_child ( TTR ( " Custom (comma-separated): " ) , custom_features ) ;
custom_feature_display = memnew ( RichTextLabel ) ;
2020-03-06 17:00:16 +00:00
custom_feature_display - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2020-04-05 03:08:53 +00:00
feature_vb - > add_margin_child ( TTR ( " Feature List: " ) , custom_feature_display , true ) ;
2017-07-19 20:00:46 +00:00
sections - > add_child ( feature_vb ) ;
2024-01-22 14:31:55 +00:00
// Encryption export parameters.
2020-01-08 12:29:49 +00:00
2020-04-28 17:51:29 +00:00
VBoxContainer * sec_vb = memnew ( VBoxContainer ) ;
sec_vb - > set_name ( TTR ( " Encryption " ) ) ;
enc_pck = memnew ( CheckButton ) ;
enc_pck - > connect ( " toggled " , callable_mp ( this , & ProjectExportDialog : : _enc_pck_changed ) ) ;
2021-06-24 08:00:48 +00:00
enc_pck - > set_text ( TTR ( " Encrypt Exported PCK " ) ) ;
2020-04-28 17:51:29 +00:00
sec_vb - > add_child ( enc_pck ) ;
enc_directory = memnew ( CheckButton ) ;
enc_directory - > connect ( " toggled " , callable_mp ( this , & ProjectExportDialog : : _enc_directory_changed ) ) ;
2021-07-19 19:10:05 +00:00
enc_directory - > set_text ( TTR ( " Encrypt Index (File Names and Info) " ) ) ;
2020-04-28 17:51:29 +00:00
sec_vb - > add_child ( enc_directory ) ;
enc_in_filters = memnew ( LineEdit ) ;
enc_in_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _enc_filters_changed ) ) ;
sec_vb - > add_margin_child (
TTR ( " Filters to include files/folders \n (comma-separated, e.g: *.tscn, *.tres, scenes/*) " ) ,
enc_in_filters ) ;
enc_ex_filters = memnew ( LineEdit ) ;
enc_ex_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _enc_filters_changed ) ) ;
sec_vb - > add_margin_child (
2022-03-10 03:22:36 +00:00
TTR ( " Filters to exclude files/folders \n (comma-separated, e.g: *.ctex, *.import, music/*) " ) ,
2020-04-28 17:51:29 +00:00
enc_ex_filters ) ;
2018-12-23 18:28:29 +00:00
script_key = memnew ( LineEdit ) ;
2020-02-21 17:28:45 +00:00
script_key - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _script_encryption_key_changed ) ) ;
2018-12-23 18:28:29 +00:00
script_key_error = memnew ( Label ) ;
2021-07-28 17:40:45 +00:00
script_key_error - > set_text ( String : : utf8 ( " • " ) + TTR ( " Invalid Encryption Key (must be 64 hexadecimal characters long) " ) ) ;
2023-09-13 11:14:07 +00:00
script_key_error - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_editor_theme ( ) - > get_color ( SNAME ( " error_color " ) , EditorStringName ( Editor ) ) ) ;
2021-06-24 08:00:48 +00:00
sec_vb - > add_margin_child ( TTR ( " Encryption Key (256-bits as hexadecimal): " ) , script_key ) ;
2020-04-28 17:51:29 +00:00
sec_vb - > add_child ( script_key_error ) ;
sections - > add_child ( sec_vb ) ;
Label * sec_info = memnew ( Label ) ;
sec_info - > set_text ( TTR ( " Note: Encryption key needs to be stored in the binary, \n you need to build the export templates from source. " ) ) ;
sec_vb - > add_child ( sec_info ) ;
LinkButton * sec_more_info = memnew ( LinkButton ) ;
sec_more_info - > set_text ( TTR ( " More Info... " ) ) ;
sec_more_info - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _open_key_help_link ) ) ;
sec_vb - > add_child ( sec_more_info ) ;
2018-12-23 18:28:29 +00:00
2024-01-22 14:31:55 +00:00
// Script export parameters.
VBoxContainer * script_vb = memnew ( VBoxContainer ) ;
script_vb - > set_name ( TTR ( " Scripts " ) ) ;
script_mode = memnew ( OptionButton ) ;
script_vb - > add_margin_child ( TTR ( " GDScript Export Mode: " ) , script_mode ) ;
script_mode - > add_item ( TTR ( " Text (easier debugging) " ) , ( int ) EditorExportPreset : : MODE_SCRIPT_TEXT ) ;
script_mode - > add_item ( TTR ( " Binary tokens (faster loading) " ) , ( int ) EditorExportPreset : : MODE_SCRIPT_BINARY_TOKENS ) ;
2024-01-26 17:49:31 +00:00
script_mode - > add_item ( TTR ( " Compressed binary tokens (smaller files) " ) , ( int ) EditorExportPreset : : MODE_SCRIPT_BINARY_TOKENS_COMPRESSED ) ;
2024-01-22 14:31:55 +00:00
script_mode - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _script_export_mode_changed ) ) ;
2024-01-26 17:49:31 +00:00
2024-01-22 14:31:55 +00:00
sections - > add_child ( script_vb ) ;
2020-02-21 17:28:45 +00:00
sections - > connect ( " tab_changed " , callable_mp ( this , & ProjectExportDialog : : _tab_changed ) ) ;
2017-07-19 20:00:46 +00:00
2020-01-08 12:29:49 +00:00
// Disable by default.
2017-02-20 02:19:30 +00:00
name - > set_editable ( false ) ;
2018-11-12 19:04:58 +00:00
export_path - > hide ( ) ;
2024-02-16 22:05:50 +00:00
advanced_options - > set_disabled ( true ) ;
2017-02-20 02:19:30 +00:00
runnable - > set_disabled ( true ) ;
2018-10-28 18:13:38 +00:00
duplicate_preset - > set_disabled ( true ) ;
2017-02-20 02:19:30 +00:00
delete_preset - > set_disabled ( true ) ;
2018-12-23 18:28:29 +00:00
script_key_error - > hide ( ) ;
2017-02-20 02:19:30 +00:00
sections - > hide ( ) ;
2020-04-01 23:20:12 +00:00
parameters - > edit ( nullptr ) ;
2017-02-20 02:19:30 +00:00
2020-01-08 12:29:49 +00:00
// Deletion dialog.
2017-02-20 02:19:30 +00:00
delete_confirm = memnew ( ConfirmationDialog ) ;
add_child ( delete_confirm ) ;
2022-07-08 00:31:19 +00:00
delete_confirm - > set_ok_button_text ( TTR ( " Delete " ) ) ;
2020-02-21 17:28:45 +00:00
delete_confirm - > connect ( " confirmed " , callable_mp ( this , & ProjectExportDialog : : _delete_preset_confirm ) ) ;
2014-02-10 01:10:30 +00:00
2020-01-08 12:29:49 +00:00
// Export buttons, dialogs and errors.
2022-07-08 00:31:19 +00:00
set_cancel_button_text ( TTR ( " Close " ) ) ;
set_ok_button_text ( TTR ( " Export PCK/ZIP... " ) ) ;
2024-01-14 19:16:57 +00:00
get_ok_button ( ) - > set_tooltip_text ( TTR ( " Export the project resources as a PCK or ZIP package. This is not a playable build, only the project data without a Godot executable. " ) ) ;
2022-09-14 03:48:33 +00:00
get_ok_button ( ) - > set_disabled ( true ) ;
# ifdef ANDROID_ENABLED
export_button = memnew ( Button ) ;
export_button - > hide ( ) ;
# else
2019-11-04 15:29:09 +00:00
export_button = add_button ( TTR ( " Export Project... " ) , ! DisplayServer : : get_singleton ( ) - > get_swap_cancel_ok ( ) , " export " ) ;
2024-01-14 19:16:57 +00:00
export_button - > set_tooltip_text ( TTR ( " Export the project as a playable build (Godot executable and project data) for the selected preset. " ) ) ;
2022-09-14 03:48:33 +00:00
# endif
2020-02-21 17:28:45 +00:00
export_button - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _export_project ) ) ;
2018-08-31 08:48:40 +00:00
// Disable initially before we select a valid preset
export_button - > set_disabled ( true ) ;
2017-02-21 03:05:15 +00:00
2018-11-03 15:56:31 +00:00
export_all_dialog = memnew ( ConfirmationDialog ) ;
add_child ( export_all_dialog ) ;
2021-07-19 19:10:05 +00:00
export_all_dialog - > set_title ( TTR ( " Export All " ) ) ;
2019-11-04 15:29:09 +00:00
export_all_dialog - > set_text ( TTR ( " Choose an export mode: " ) ) ;
2020-12-14 18:37:30 +00:00
export_all_dialog - > get_ok_button ( ) - > hide ( ) ;
2018-11-03 15:56:31 +00:00
export_all_dialog - > add_button ( TTR ( " Debug " ) , true , " debug " ) ;
export_all_dialog - > add_button ( TTR ( " Release " ) , true , " release " ) ;
2020-02-21 17:28:45 +00:00
export_all_dialog - > connect ( " custom_action " , callable_mp ( this , & ProjectExportDialog : : _export_all_dialog_action ) ) ;
2022-09-14 03:48:33 +00:00
# ifdef ANDROID_ENABLED
export_all_dialog - > hide ( ) ;
2018-11-03 15:56:31 +00:00
2022-09-14 03:48:33 +00:00
export_all_button = memnew ( Button ) ;
export_all_button - > hide ( ) ;
# else
2019-11-04 15:29:09 +00:00
export_all_button = add_button ( TTR ( " Export All... " ) , ! DisplayServer : : get_singleton ( ) - > get_swap_cancel_ok ( ) , " export " ) ;
2022-09-14 03:48:33 +00:00
# endif
2020-02-21 17:28:45 +00:00
export_all_button - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _export_all_dialog ) ) ;
2018-11-03 15:56:31 +00:00
export_all_button - > set_disabled ( true ) ;
2019-04-24 18:52:15 +00:00
export_pck_zip = memnew ( EditorFileDialog ) ;
2022-07-04 21:26:26 +00:00
export_pck_zip - > add_filter ( " *.zip " , TTR ( " ZIP File " ) ) ;
export_pck_zip - > add_filter ( " *.pck " , TTR ( " Godot Project Pack " ) ) ;
2019-04-24 18:52:15 +00:00
export_pck_zip - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2020-03-06 17:00:16 +00:00
export_pck_zip - > set_file_mode ( EditorFileDialog : : FILE_MODE_SAVE_FILE ) ;
2017-02-21 03:05:15 +00:00
add_child ( export_pck_zip ) ;
2020-02-21 17:28:45 +00:00
export_pck_zip - > connect ( " file_selected " , callable_mp ( this , & ProjectExportDialog : : _export_pck_zip_selected ) ) ;
2017-02-21 03:05:15 +00:00
2023-06-20 02:50:09 +00:00
// Export warnings and errors bottom section.
export_texture_format_error = memnew ( ProjectExportTextureFormatError ) ;
main_vb - > add_child ( export_texture_format_error ) ;
export_texture_format_error - > hide ( ) ;
export_texture_format_error - > connect ( " texture_format_enabled " , callable_mp ( this , & ProjectExportDialog : : _update_current_preset ) ) ;
2017-03-21 02:31:41 +00:00
export_error = memnew ( Label ) ;
main_vb - > add_child ( export_error ) ;
export_error - > hide ( ) ;
2023-09-13 11:14:07 +00:00
export_error - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_editor_theme ( ) - > get_color ( SNAME ( " error_color " ) , EditorStringName ( Editor ) ) ) ;
2017-03-21 02:31:41 +00:00
2022-01-10 11:18:59 +00:00
export_warning = memnew ( Label ) ;
main_vb - > add_child ( export_warning ) ;
export_warning - > hide ( ) ;
2023-09-13 11:14:07 +00:00
export_warning - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_editor_theme ( ) - > get_color ( SNAME ( " warning_color " ) , EditorStringName ( Editor ) ) ) ;
2022-01-10 11:18:59 +00:00
2017-03-21 02:31:41 +00:00
export_templates_error = memnew ( HBoxContainer ) ;
main_vb - > add_child ( export_templates_error ) ;
export_templates_error - > hide ( ) ;
Label * export_error2 = memnew ( Label ) ;
export_templates_error - > add_child ( export_error2 ) ;
2023-09-13 11:14:07 +00:00
export_error2 - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_editor_theme ( ) - > get_color ( SNAME ( " error_color " ) , EditorStringName ( Editor ) ) ) ;
2021-07-28 17:40:45 +00:00
export_error2 - > set_text ( String : : utf8 ( " • " ) + TTR ( " Export templates for this platform are missing: " ) + " " ) ;
2017-03-21 02:31:41 +00:00
2022-06-03 15:34:24 +00:00
result_dialog = memnew ( AcceptDialog ) ;
result_dialog - > set_title ( TTR ( " Project Export " ) ) ;
result_dialog_log = memnew ( RichTextLabel ) ;
result_dialog_log - > set_custom_minimum_size ( Size2 ( 300 , 80 ) * EDSCALE ) ;
result_dialog - > add_child ( result_dialog_log ) ;
main_vb - > add_child ( result_dialog ) ;
result_dialog - > hide ( ) ;
2017-10-12 22:38:42 +00:00
2017-03-21 02:31:41 +00:00
LinkButton * download_templates = memnew ( LinkButton ) ;
download_templates - > set_text ( TTR ( " Manage Export Templates " ) ) ;
2020-03-06 17:00:16 +00:00
download_templates - > set_v_size_flags ( Control : : SIZE_SHRINK_CENTER ) ;
2017-03-21 02:31:41 +00:00
export_templates_error - > add_child ( download_templates ) ;
2020-02-21 17:28:45 +00:00
download_templates - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _open_export_template_manager ) ) ;
2017-03-21 02:31:41 +00:00
2023-06-20 02:50:09 +00:00
// Export project file dialog.
2019-04-24 18:52:15 +00:00
export_project = memnew ( EditorFileDialog ) ;
export_project - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2017-03-21 22:34:26 +00:00
add_child ( export_project ) ;
2020-02-21 17:28:45 +00:00
export_project - > connect ( " file_selected " , callable_mp ( this , & ProjectExportDialog : : _export_project_to_path ) ) ;
export_project - > get_line_edit ( ) - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _validate_export_path ) ) ;
2017-03-21 22:34:26 +00:00
2024-03-21 08:42:38 +00:00
export_project - > add_option ( TTR ( " Export With Debug " ) , Vector < String > ( ) , true ) ;
export_pck_zip - > add_option ( TTR ( " Export With Debug " ) , Vector < String > ( ) , true ) ;
2018-04-26 21:08:19 +00:00
2017-02-21 03:05:15 +00:00
set_hide_on_ok ( false ) ;
2018-08-31 08:48:40 +00:00
default_filename = EditorSettings : : get_singleton ( ) - > get_project_metadata ( " export_options " , " default_filename " , " " ) ;
// If no default set, use project name
2021-12-09 09:42:46 +00:00
if ( default_filename . is_empty ( ) ) {
2018-08-31 08:48:40 +00:00
// If no project name defined, use a sane default
2022-10-18 14:43:37 +00:00
default_filename = GLOBAL_GET ( " application/config/name " ) ;
2021-12-09 09:42:46 +00:00
if ( default_filename . is_empty ( ) ) {
2018-08-31 08:48:40 +00:00
default_filename = " UnnamedProject " ;
}
2018-04-17 21:10:30 +00:00
}
2014-02-10 01:10:30 +00:00
}
ProjectExportDialog : : ~ ProjectExportDialog ( ) {
}