2014-02-10 02:10:30 +01:00
/*************************************************************************/
/* project_export.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
2017-08-27 14:16:55 +02:00
/* https://godotengine.org */
2014-02-10 02:10:30 +01:00
/*************************************************************************/
2020-01-01 11:16:22 +01:00
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
2014-02-10 02:10:30 +01:00
/* */
/* 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-05 00:50:27 +01:00
2014-02-10 02:10:30 +01:00
# include "project_export.h"
2018-08-18 15:07:23 +02:00
2020-11-07 23:33:38 +01:00
# include "core/config/project_settings.h"
2018-09-11 18:13:45 +02:00
# include "core/io/image_loader.h"
# include "core/io/resource_loader.h"
# include "core/io/resource_saver.h"
# include "core/os/dir_access.h"
# include "core/os/file_access.h"
# include "core/os/os.h"
2020-11-07 23:33:38 +01:00
# include "core/string/compressed_translation.h"
2017-03-05 16:44:50 +01:00
# include "editor_data.h"
# include "editor_node.h"
2019-12-24 08:17:23 +01:00
# include "editor_scale.h"
2017-03-05 16:44:50 +01:00
# include "editor_settings.h"
2014-02-10 02:10:30 +01:00
# include "scene/gui/box_container.h"
2017-02-20 03:19:30 +01:00
# include "scene/gui/margin_container.h"
2017-03-05 16:44:50 +01:00
# include "scene/gui/scroll_container.h"
# include "scene/gui/tab_container.h"
2020-03-03 14:36:29 +01:00
# include "servers/display_server.h"
2014-02-10 02:10:30 +01:00
2020-03-06 18:00:16 +01:00
void ProjectExportDialog : : _theme_changed ( ) {
2020-03-12 13:37:40 +01:00
duplicate_preset - > set_icon ( presets - > get_theme_icon ( " Duplicate " , " EditorIcons " ) ) ;
delete_preset - > set_icon ( presets - > get_theme_icon ( " Remove " , " EditorIcons " ) ) ;
2020-03-06 18:00:16 +01:00
}
2020-05-14 14:29:06 +02:00
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _notification ( int p_what ) {
2017-03-02 22:43:56 +01:00
switch ( p_what ) {
2020-03-06 18:00:16 +01:00
case NOTIFICATION_VISIBILITY_CHANGED : {
if ( ! is_visible ( ) ) {
EditorSettings : : get_singleton ( ) - > set_project_metadata ( " dialog_bounds " , " export " , Rect2 ( get_position ( ) , get_size ( ) ) ) ;
}
} break ;
2017-03-02 22:43:56 +01:00
case NOTIFICATION_READY : {
2020-03-12 13:37:40 +01:00
duplicate_preset - > set_icon ( presets - > get_theme_icon ( " Duplicate " , " EditorIcons " ) ) ;
delete_preset - > set_icon ( presets - > get_theme_icon ( " Remove " , " EditorIcons " ) ) ;
2020-02-21 18:28:45 +01:00
connect ( " confirmed " , callable_mp ( this , & ProjectExportDialog : : _export_pck_zip ) ) ;
2018-02-25 17:04:16 +01:00
} break ;
2014-02-10 02:10:30 +01:00
}
}
2016-01-27 11:23:12 +01:00
void ProjectExportDialog : : popup_export ( ) {
2017-02-20 03:19:30 +01:00
add_preset - > get_popup ( ) - > clear ( ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_platform_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
Ref < EditorExportPlatform > plat = EditorExport : : get_singleton ( ) - > get_export_platform ( i ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
add_preset - > get_popup ( ) - > add_icon_item ( plat - > get_logo ( ) , plat - > get_name ( ) ) ;
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01:00
_update_presets ( ) ;
2018-07-18 13:46:02 +02:00
if ( presets - > get_current ( ) > = 0 ) {
2018-12-23 19:28:29 +01:00
_update_current_preset ( ) ; // triggers rescan for templates if newly installed
2018-07-18 13:46:02 +02:00
}
2017-03-02 22:43:56 +01:00
// Restore valid window bounds or pop up at default size.
2018-12-04 16:52:56 +01:00
Rect2 saved_size = EditorSettings : : get_singleton ( ) - > get_project_metadata ( " dialog_bounds " , " export " , Rect2 ( ) ) ;
if ( saved_size ! = Rect2 ( ) ) {
popup ( saved_size ) ;
2017-03-02 22:43:56 +01:00
} else {
2019-04-26 21:36:44 +02:00
popup_centered_clamped ( Size2 ( 900 , 700 ) * EDSCALE , 0.8 ) ;
2017-03-02 22:43:56 +01:00
}
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01: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 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
String name = EditorExport : : get_singleton ( ) - > get_export_platform ( p_platform ) - > get_name ( ) ;
2017-03-05 16:44:50 +01:00
bool make_runnable = true ;
int attempt = 1 ;
while ( true ) {
bool valid = true ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > p = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
2017-03-05 16:44:50 +01:00
if ( p - > get_platform ( ) = = preset - > get_platform ( ) & & p - > is_runnable ( ) ) {
make_runnable = false ;
2017-02-20 03:19:30 +01:00
}
2017-03-05 16:44:50 +01:00
if ( p - > get_name ( ) = = name ) {
valid = false ;
2017-02-20 03:19:30 +01:00
break ;
}
}
2014-02-10 02:10:30 +01:00
2020-05-14 16:41:43 +02:00
if ( valid ) {
2017-02-20 03:19:30 +01:00
break ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
attempt + + ;
2017-03-05 16:44:50 +01:00
name = EditorExport : : get_singleton ( ) - > get_export_platform ( p_platform ) - > get_name ( ) + " " + itos ( attempt ) ;
2016-01-27 11:23:12 +01:00
}
2017-02-20 03:19:30 +01:00
preset - > set_name ( name ) ;
2020-05-14 16:41:43 +02:00
if ( make_runnable ) {
2017-02-20 03:19:30 +01:00
preset - > set_runnable ( make_runnable ) ;
2020-05-14 16:41:43 +02:00
}
2017-02-20 03:19:30 +01:00
EditorExport : : get_singleton ( ) - > add_export_preset ( preset ) ;
_update_presets ( ) ;
2017-03-05 16:44:50 +01:00
_edit_preset ( EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) - 1 ) ;
2014-02-10 02:10:30 +01:00
}
2020-04-24 09:45:14 +02: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 19:28:29 +01:00
void ProjectExportDialog : : _update_current_preset ( ) {
_edit_preset ( presets - > get_current ( ) ) ;
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _update_presets ( ) {
2017-03-05 16:44:50 +01:00
updating = true ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > current ;
2020-05-14 16:41:43 +02:00
if ( presets - > get_current ( ) > = 0 & & presets - > get_current ( ) < presets - > get_item_count ( ) ) {
2018-12-23 19:28:29 +01:00
current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
int current_idx = - 1 ;
2017-02-20 03:19:30 +01:00
presets - > clear ( ) ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
2017-03-05 16:44:50 +01:00
if ( preset = = current ) {
current_idx = i ;
2017-02-20 03:19:30 +01:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
String name = preset - > get_name ( ) ;
2020-05-14 16:41:43 +02:00
if ( preset - > is_runnable ( ) ) {
2017-03-05 16:44:50 +01:00
name + = " ( " + TTR ( " Runnable " ) + " ) " ;
2020-05-14 16:41:43 +02:00
}
2020-06-10 11:41:42 +02:00
preset - > update_files_to_export ( ) ;
2017-03-05 16:44:50 +01:00
presets - > add_item ( name , preset - > get_platform ( ) - > get_logo ( ) ) ;
2017-02-20 03:19:30 +01:00
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
if ( current_idx ! = - 1 ) {
2017-02-20 03:19:30 +01:00
presets - > select ( current_idx ) ;
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
updating = false ;
2014-02-10 02:10:30 +01:00
}
2018-11-03 16:56:31 +01:00
void ProjectExportDialog : : _update_export_all ( ) {
2019-06-26 15:08:25 +02:00
bool can_export = EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) > 0 ;
2018-11-03 16:56:31 +01: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 ;
if ( preset - > get_export_path ( ) = = " " | | ! preset - > get_platform ( ) - > can_export ( preset , error , needs_templates ) ) {
can_export = false ;
break ;
}
}
if ( can_export ) {
export_all_button - > set_disabled ( false ) ;
} else {
export_all_button - > set_disabled ( true ) ;
}
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _edit_preset ( int p_index ) {
2017-03-05 16:44:50 +01:00
if ( p_index < 0 | | p_index > = presets - > get_item_count ( ) ) {
2017-02-20 03:19:30 +01:00
name - > set_text ( " " ) ;
name - > set_editable ( false ) ;
2018-11-12 20:04:58 +01:00
export_path - > hide ( ) ;
2017-02-20 03:19:30 +01:00
runnable - > set_disabled ( true ) ;
2020-04-02 01:20:12 +02:00
parameters - > edit ( nullptr ) ;
2018-07-18 13:46:02 +02:00
presets - > unselect_all ( ) ;
2018-10-28 19:13:38 +01:00
duplicate_preset - > set_disabled ( true ) ;
2017-02-20 03:19:30 +01:00
delete_preset - > set_disabled ( true ) ;
sections - > hide ( ) ;
2017-03-21 03:31:41 +01:00
export_error - > hide ( ) ;
export_templates_error - > hide ( ) ;
2017-02-20 03:19:30 +01:00
return ;
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > current = EditorExport : : get_singleton ( ) - > get_export_preset ( p_index ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
updating = true ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
presets - > select ( p_index ) ;
sections - > show ( ) ;
name - > set_editable ( true ) ;
2018-11-12 20:04:58 +01:00
export_path - > show ( ) ;
2018-10-28 19:13:38 +01:00
duplicate_preset - > set_disabled ( false ) ;
2017-02-20 03:19:30 +01:00
delete_preset - > set_disabled ( false ) ;
name - > set_text ( current - > get_name ( ) ) ;
2018-11-12 20:04:58 +01: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 ( ) ;
2017-02-20 03:19:30 +01:00
runnable - > set_disabled ( false ) ;
runnable - > set_pressed ( current - > is_runnable ( ) ) ;
parameters - > edit ( current . ptr ( ) ) ;
export_filter - > select ( current - > get_export_filter ( ) ) ;
include_filters - > set_text ( current - > get_include_filter ( ) ) ;
exclude_filters - > set_text ( current - > get_exclude_filter ( ) ) ;
_fill_resource_tree ( ) ;
2014-02-10 02:10:30 +01:00
2017-03-21 03:31:41 +01:00
bool needs_templates ;
String error ;
if ( ! current - > get_platform ( ) - > can_export ( current , error , needs_templates ) ) {
if ( error ! = String ( ) ) {
2018-08-17 11:27:26 +02:00
Vector < String > items = error . split ( " \n " , false ) ;
2017-03-21 03:31:41 +01:00
error = " " ;
for ( int i = 0 ; i < items . size ( ) ; i + + ) {
2020-05-14 16:41:43 +02:00
if ( i > 0 ) {
2017-03-21 03:31:41 +01:00
error + = " \n " ;
2020-05-14 16:41:43 +02:00
}
2017-03-21 03:31:41 +01:00
error + = " - " + items [ i ] ;
}
export_error - > set_text ( error ) ;
export_error - > show ( ) ;
} else {
export_error - > hide ( ) ;
}
2020-05-14 16:41:43 +02:00
if ( needs_templates ) {
2017-03-21 03:31:41 +01:00
export_templates_error - > show ( ) ;
2020-05-14 16:41:43 +02:00
} else {
2017-04-22 01:15:42 +02:00
export_templates_error - > hide ( ) ;
2020-05-14 16:41:43 +02:00
}
2017-03-21 03:31:41 +01:00
2017-03-28 03:21:21 +02:00
export_button - > set_disabled ( true ) ;
2019-10-16 11:54:04 +02:00
get_ok ( ) - > set_disabled ( true ) ;
2017-03-21 23:34:26 +01:00
2017-03-21 03:31:41 +01:00
} else {
2017-06-21 11:11:38 +02:00
export_error - > hide ( ) ;
2017-03-21 03:31:41 +01:00
export_templates_error - > hide ( ) ;
2017-03-28 03:21:21 +02:00
export_button - > set_disabled ( false ) ;
2019-10-16 11:54:04 +02:00
get_ok ( ) - > set_disabled ( false ) ;
2017-03-21 03:31:41 +01:00
}
2017-07-19 22:00:46 +02:00
custom_features - > set_text ( current - > get_custom_features ( ) ) ;
_update_feature_list ( ) ;
2018-11-03 16:56:31 +01:00
_update_export_all ( ) ;
2020-03-06 18:00:16 +01:00
child_controls_changed ( ) ;
2017-07-19 22:00:46 +02:00
2020-04-28 19:51:29 +02: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 19:28:29 +01:00
int script_export_mode = current - > get_script_export_mode ( ) ;
script_mode - > select ( script_export_mode ) ;
String key = current - > get_script_encryption_key ( ) ;
if ( ! updating_script_key ) {
script_key - > set_text ( key ) ;
}
2020-04-28 19:51:29 +02:00
if ( enc_pck_mode ) {
2018-12-23 19:28:29 +01: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 ( ) ;
}
2017-03-05 16:44:50 +01:00
updating = false ;
2014-02-26 14:08:17 +01:00
}
2017-07-19 22:00:46 +02:00
void ProjectExportDialog : : _update_feature_list ( ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-07-19 22:00:46 +02:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
Set < String > fset ;
List < String > features ;
current - > get_platform ( ) - > get_platform_features ( & features ) ;
current - > get_platform ( ) - > get_preset_features ( current , & features ) ;
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 ( ) ;
if ( f ! = String ( ) ) {
features . push_back ( f ) ;
}
}
for ( List < String > : : Element * E = features . front ( ) ; E ; E = E - > next ( ) ) {
fset . insert ( E - > get ( ) ) ;
}
custom_feature_display - > clear ( ) ;
for ( Set < String > : : Element * E = fset . front ( ) ; E ; E = E - > next ( ) ) {
String f = E - > get ( ) ;
if ( E - > next ( ) ) {
f + = " , " ;
}
custom_feature_display - > add_text ( f ) ;
}
}
void ProjectExportDialog : : _custom_features_changed ( const String & p_text ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2017-07-19 22:00:46 +02:00
return ;
2020-05-14 16:41:43 +02:00
}
2017-07-19 22:00:46 +02:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-07-19 22:00:46 +02: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 03:21:21 +02:00
void ProjectExportDialog : : _update_parameters ( const String & p_edited_property ) {
2018-12-23 19:28:29 +01:00
_update_current_preset ( ) ;
2017-03-28 03:21:21 +02:00
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _runnable_pressed ( ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-15 06:01:39 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-02-20 03:19:30 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2014-02-15 06:01:39 +01:00
2017-02-20 03:19:30 +01:00
if ( runnable - > is_pressed ( ) ) {
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > p = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
2017-03-05 16:44:50 +01:00
if ( p - > get_platform ( ) = = current - > get_platform ( ) ) {
p - > set_runnable ( current = = p ) ;
2017-02-20 03:19:30 +01:00
}
2014-02-15 06:01:39 +01:00
}
2017-02-20 03:19:30 +01:00
} else {
current - > set_runnable ( false ) ;
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01:00
_update_presets ( ) ;
2014-02-10 02:10:30 +01:00
}
2017-03-05 16:44:50 +01:00
void ProjectExportDialog : : _name_changed ( const String & p_string ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2014-02-13 22:03:28 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-13 22:03:28 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-02-20 03:19:30 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2015-12-13 05:08:36 +01:00
2017-02-20 03:19:30 +01:00
current - > set_name ( p_string ) ;
_update_presets ( ) ;
2014-02-13 22:03:28 +01:00
}
2018-11-12 20:04:58 +01:00
void ProjectExportDialog : : set_export_path ( const String & p_value ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-12 20:04:58 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_export_path ( p_value ) ;
}
String ProjectExportDialog : : get_export_path ( ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-12 20:04:58 +01:00
ERR_FAIL_COND_V ( current . is_null ( ) , String ( " " ) ) ;
return current - > get_export_path ( ) ;
}
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > ProjectExportDialog : : get_current_preset ( ) const {
return EditorExport : : get_singleton ( ) - > get_export_preset ( presets - > get_current ( ) ) ;
}
2019-01-18 17:01:24 +01:00
void ProjectExportDialog : : _export_path_changed ( const StringName & p_property , const Variant & p_value , const String & p_field , bool p_changing ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2018-11-06 02:01:34 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-11-06 02:01:34 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2018-11-06 02:01:34 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2018-11-12 20:04:58 +01:00
current - > set_export_path ( p_value ) ;
2018-11-06 02:01:34 +01:00
_update_presets ( ) ;
}
2020-04-28 19:51:29 +02: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 ( ) {
OS : : get_singleton ( ) - > shell_open ( " https://docs.godotengine.org/en/latest/development/compiling/compiling_with_script_encryption_key.html " ) ;
}
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 19:28:29 +01:00
void ProjectExportDialog : : _script_export_mode_changed ( int p_mode ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2018-12-23 19:28:29 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
ERR_FAIL_COND ( current . is_null ( ) ) ;
current - > set_script_export_mode ( p_mode ) ;
_update_current_preset ( ) ;
}
void ProjectExportDialog : : _script_encryption_key_changed ( const String & p_key ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2018-12-23 19:28:29 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-12-23 19:28:29 +01: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 ;
if ( ! p_key . empty ( ) & & p_key . is_valid_hex_number ( false ) & & p_key . length ( ) = = 64 ) {
is_valid = true ;
}
return is_valid ;
}
2018-10-28 19:13:38 +01:00
void ProjectExportDialog : : _duplicate_preset ( ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2018-10-28 19:13:38 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-10-28 19:13:38 +01:00
Ref < EditorExportPreset > preset = current - > get_platform ( ) - > create_preset ( ) ;
ERR_FAIL_COND ( ! preset . is_valid ( ) ) ;
2019-05-23 14:45:17 +02:00
String name = current - > get_name ( ) + " (copy) " ;
2018-10-28 19:13:38 +01: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 ;
}
if ( p - > get_name ( ) = = name ) {
valid = false ;
break ;
}
}
2020-05-14 16:41:43 +02:00
if ( valid ) {
2018-10-28 19:13:38 +01:00
break ;
2020-05-14 16:41:43 +02:00
}
2018-10-28 19:13:38 +01:00
2019-05-23 14:45:17 +02:00
name + = " (copy) " ;
2018-10-28 19:13:38 +01:00
}
preset - > set_name ( name ) ;
2020-05-14 16:41:43 +02:00
if ( make_runnable ) {
2018-10-28 19:13:38 +01:00
preset - > set_runnable ( make_runnable ) ;
2020-05-14 16:41:43 +02:00
}
2018-10-28 19:13:38 +01: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 ( ) ) ;
for ( const List < PropertyInfo > : : Element * E = current - > get_properties ( ) . front ( ) ; E ; E = E - > next ( ) ) {
preset - > set ( E - > get ( ) . name , current - > get ( E - > get ( ) . name ) ) ;
}
EditorExport : : get_singleton ( ) - > add_export_preset ( preset ) ;
_update_presets ( ) ;
_edit_preset ( EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) - 1 ) ;
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _delete_preset ( ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
delete_confirm - > set_text ( vformat ( TTR ( " Delete preset '%s'? " ) , current - > get_name ( ) ) ) ;
2020-03-06 18:00:16 +01:00
delete_confirm - > popup_centered ( ) ;
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _delete_preset_confirm ( ) {
int idx = presets - > get_current ( ) ;
2017-09-04 20:45:18 +02:00
_edit_preset ( - 1 ) ;
2019-04-23 17:49:15 +02:00
export_button - > set_disabled ( true ) ;
2019-10-16 11:54:04 +02:00
get_ok ( ) - > set_disabled ( true ) ;
2017-02-20 03:19:30 +01:00
EditorExport : : get_singleton ( ) - > remove_export_preset ( idx ) ;
_update_presets ( ) ;
2014-02-13 22:03:28 +01:00
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
Variant ProjectExportDialog : : get_drag_data_fw ( const Point2 & p_point , Control * p_from ) {
if ( p_from = = presets ) {
2017-09-10 15:37:49 +02:00
int pos = presets - > get_item_at_position ( p_point , true ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
if ( pos > = 0 ) {
2017-02-20 03:19:30 +01:00
Dictionary d ;
2017-03-05 16:44:50 +01:00
d [ " type " ] = " export_preset " ;
d [ " preset " ] = pos ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
HBoxContainer * drag = memnew ( HBoxContainer ) ;
2017-02-20 03:19:30 +01:00
TextureRect * tr = memnew ( TextureRect ) ;
tr - > set_texture ( presets - > get_item_icon ( pos ) ) ;
drag - > add_child ( tr ) ;
2017-03-05 16:44:50 +01:00
Label * label = memnew ( Label ) ;
2017-02-20 03:19:30 +01:00
label - > set_text ( presets - > get_item_text ( pos ) ) ;
drag - > add_child ( label ) ;
2014-02-10 02:10:30 +01:00
2020-03-06 18:00:16 +01:00
presets - > set_drag_preview ( drag ) ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
return d ;
}
}
2016-11-26 15:30:46 +01:00
2017-02-20 03:19:30 +01:00
return Variant ( ) ;
2016-11-26 15:30:46 +01:00
}
2017-03-05 16:44:50 +01:00
bool ProjectExportDialog : : can_drop_data_fw ( const Point2 & p_point , const Variant & p_data , Control * p_from ) const {
if ( p_from = = presets ) {
2017-02-20 03:19:30 +01:00
Dictionary d = p_data ;
2020-05-14 16:41:43 +02:00
if ( ! d . has ( " type " ) | | String ( d [ " type " ] ) ! = " export_preset " ) {
2017-02-20 03:19:30 +01:00
return false ;
2020-05-14 16:41:43 +02:00
}
2016-11-26 15:30:46 +01:00
2020-05-14 16:41:43 +02:00
if ( presets - > get_item_at_position ( p_point , true ) < 0 & & ! presets - > is_pos_at_end_of_items ( p_point ) ) {
2017-02-20 03:19:30 +01:00
return false ;
2020-05-14 16:41:43 +02:00
}
2016-11-26 15:30:46 +01:00
}
2017-02-20 03:19:30 +01:00
return true ;
2016-11-26 15:30:46 +01:00
}
2017-03-05 16:44:50 +01: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 ;
2017-02-20 03:19:30 +01:00
int from_pos = d [ " preset " ] ;
2016-11-26 15:30:46 +01:00
2017-03-05 16:44:50 +01:00
int to_pos = - 1 ;
2016-11-26 15:30:46 +01:00
2017-09-10 15:37:49 +02:00
if ( presets - > get_item_at_position ( p_point , true ) > = 0 ) {
to_pos = presets - > get_item_at_position ( p_point , true ) ;
2016-11-26 15:30:46 +01:00
}
2014-02-10 02:10:30 +01:00
2020-05-14 16:41:43 +02:00
if ( to_pos = = - 1 & & ! presets - > is_pos_at_end_of_items ( p_point ) ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2020-05-14 16:41:43 +02:00
if ( to_pos = = from_pos ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
} else if ( to_pos > from_pos ) {
2017-02-20 03:19:30 +01:00
to_pos - - ;
}
2014-10-23 12:04:21 +02:00
2017-02-20 03:19:30 +01:00
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( from_pos ) ;
EditorExport : : get_singleton ( ) - > remove_export_preset ( from_pos ) ;
2017-03-05 16:44:50 +01:00
EditorExport : : get_singleton ( ) - > add_export_preset ( preset , to_pos ) ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
_update_presets ( ) ;
2020-05-14 16:41:43 +02:00
if ( to_pos > = 0 ) {
2017-02-20 03:19:30 +01:00
_edit_preset ( to_pos ) ;
2020-05-14 16:41:43 +02:00
} else {
2017-03-05 16:44:50 +01:00
_edit_preset ( presets - > get_item_count ( ) - 1 ) ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
}
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _export_type_changed ( int p_which ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2014-02-10 02:10:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2014-02-10 02:10:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
current - > set_export_filter ( EditorExportPreset : : ExportFilter ( p_which ) ) ;
2017-03-05 16:44:50 +01:00
updating = true ;
2017-02-20 03:19:30 +01:00
_fill_resource_tree ( ) ;
2017-03-05 16:44:50 +01:00
updating = false ;
2014-02-10 02:10:30 +01:00
}
2017-03-05 16:44:50 +01:00
void ProjectExportDialog : : _filter_changed ( const String & p_filter ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2014-02-10 02:10:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
current - > set_include_filter ( include_filters - > get_text ( ) ) ;
current - > set_exclude_filter ( exclude_filters - > get_text ( ) ) ;
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _fill_resource_tree ( ) {
include_files - > clear ( ) ;
include_label - > hide ( ) ;
include_margin - > hide ( ) ;
2014-02-10 02:10:30 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
EditorExportPreset : : ExportFilter f = current - > get_export_filter ( ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
if ( f = = EditorExportPreset : : EXPORT_ALL_RESOURCES ) {
2017-02-20 03:19:30 +01:00
return ;
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01:00
include_label - > show ( ) ;
include_margin - > show ( ) ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
TreeItem * root = include_files - > create_item ( ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
_fill_tree ( EditorFileSystem : : get_singleton ( ) - > get_filesystem ( ) , root , current , f = = EditorExportPreset : : EXPORT_SELECTED_SCENES ) ;
2017-02-20 03:19:30 +01:00
}
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
bool ProjectExportDialog : : _fill_tree ( EditorFileSystemDirectory * p_dir , TreeItem * p_item , Ref < EditorExportPreset > & current , bool p_only_scenes ) {
2020-11-14 16:02:14 +01:00
p_item - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
2020-03-12 13:37:40 +01:00
p_item - > set_icon ( 0 , presets - > get_theme_icon ( " folder " , " FileDialog " ) ) ;
2017-03-05 16:44:50 +01:00
p_item - > set_text ( 0 , p_dir - > get_name ( ) + " / " ) ;
2020-11-14 16:02:14 +01:00
p_item - > set_editable ( 0 , true ) ;
p_item - > set_metadata ( 0 , p_dir - > get_path ( ) ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
bool used = false ;
2020-11-14 16:02:14 +01:00
bool checked = true ;
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_dir - > get_subdir_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
TreeItem * subdir = include_files - > create_item ( p_item ) ;
2018-10-06 22:20:41 +02:00
if ( _fill_tree ( p_dir - > get_subdir ( i ) , subdir , current , p_only_scenes ) ) {
2017-03-05 16:44:50 +01:00
used = true ;
2020-11-14 16:02:14 +01:00
checked = checked & & subdir - > is_checked ( 0 ) ;
2018-10-06 22:20:41 +02:00
} else {
memdelete ( subdir ) ;
2014-02-10 02:10:30 +01:00
}
}
2017-03-05 16:44:50 +01:00
for ( int i = 0 ; i < p_dir - > get_file_count ( ) ; i + + ) {
2017-02-20 03:19:30 +01:00
String type = p_dir - > get_file_type ( i ) ;
2020-05-14 16:41:43 +02:00
if ( p_only_scenes & & type ! = " PackedScene " ) {
2017-02-20 03:19:30 +01:00
continue ;
2020-05-14 16:41:43 +02:00
}
2014-06-11 15:41:03 +02:00
2017-02-20 03:19:30 +01:00
TreeItem * file = include_files - > create_item ( p_item ) ;
2017-03-05 16:44:50 +01:00
file - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
file - > set_text ( 0 , p_dir - > get_file ( i ) ) ;
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
String path = p_dir - > get_file_path ( i ) ;
2014-02-10 02:10:30 +01:00
2018-09-02 23:40:51 +02:00
file - > set_icon ( 0 , EditorNode : : get_singleton ( ) - > get_class_icon ( type ) ) ;
2017-03-05 16:44:50 +01:00
file - > set_editable ( 0 , true ) ;
file - > set_checked ( 0 , current - > has_export_file ( path ) ) ;
file - > set_metadata ( 0 , path ) ;
2020-11-14 16:02:14 +01:00
checked = checked & & file - > is_checked ( 0 ) ;
2014-02-10 02:10:30 +01:00
2017-03-05 16:44:50 +01:00
used = true ;
2017-02-20 03:19:30 +01:00
}
2014-02-10 02:10:30 +01:00
2020-11-14 16:02:14 +01:00
p_item - > set_checked ( 0 , checked ) ;
2017-02-20 03:19:30 +01:00
return used ;
2014-02-10 02:10:30 +01:00
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _tree_changed ( ) {
2020-05-14 16:41:43 +02:00
if ( updating ) {
2014-02-10 02:10:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2020-05-14 16:41:43 +02:00
if ( current . is_null ( ) ) {
2017-02-20 03:19:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
TreeItem * item = include_files - > get_edited ( ) ;
2020-05-14 16:41:43 +02:00
if ( ! item ) {
2014-02-10 02:10:30 +01:00
return ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
2017-02-20 03:19:30 +01:00
String path = item - > get_metadata ( 0 ) ;
bool added = item - > is_checked ( 0 ) ;
2014-02-10 02:10:30 +01:00
2020-11-14 16:02:14 +01:00
if ( path . ends_with ( " / " ) ) {
_check_dir_recursive ( item , added ) ;
2017-02-20 03:19:30 +01:00
} else {
2020-11-14 16:02:14 +01:00
if ( added ) {
current - > add_export_file ( path ) ;
} else {
current - > remove_export_file ( path ) ;
}
}
_refresh_parent_checks ( item ) ; // Makes parent folder checked if all files/folders are checked.
}
void ProjectExportDialog : : _check_dir_recursive ( TreeItem * p_dir , bool p_checked ) {
for ( TreeItem * child = p_dir - > get_children ( ) ; child ; child = child - > get_next ( ) ) {
String path = child - > get_metadata ( 0 ) ;
child - > set_checked ( 0 , p_checked ) ;
if ( path . ends_with ( " / " ) ) {
_check_dir_recursive ( child , p_checked ) ;
} else {
if ( p_checked ) {
get_current_preset ( ) - > add_export_file ( path ) ;
} else {
get_current_preset ( ) - > remove_export_file ( path ) ;
}
}
2017-02-20 03:19:30 +01:00
}
2014-02-10 02:10:30 +01:00
}
2020-11-14 16:02:14 +01:00
void ProjectExportDialog : : _refresh_parent_checks ( TreeItem * p_item ) {
TreeItem * parent = p_item - > get_parent ( ) ;
if ( ! parent ) {
return ;
}
bool checked = true ;
for ( TreeItem * child = parent - > get_children ( ) ; child ; child = child - > get_next ( ) ) {
checked = checked & & child - > is_checked ( 0 ) ;
if ( ! checked ) {
break ;
}
}
parent - > set_checked ( 0 , checked ) ;
_refresh_parent_checks ( parent ) ;
}
2017-02-21 04:05:15 +01:00
void ProjectExportDialog : : _export_pck_zip ( ) {
2020-07-11 18:45:19 +02:00
export_pck_zip - > popup_file_dialog ( ) ;
2017-02-21 04:05:15 +01:00
}
2017-03-05 16:44:50 +01:00
void ProjectExportDialog : : _export_pck_zip_selected ( const String & p_path ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
2017-02-21 04:05:15 +01:00
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
2017-03-05 16:44:50 +01:00
ERR_FAIL_COND ( platform . is_null ( ) ) ;
2017-02-21 04:05:15 +01:00
if ( p_path . ends_with ( " .zip " ) ) {
2018-04-26 23:08:19 +02:00
platform - > export_zip ( current , export_pck_zip_debug - > is_pressed ( ) , p_path ) ;
2017-02-21 04:05:15 +01:00
} else if ( p_path . ends_with ( " .pck " ) ) {
2018-04-26 23:08:19 +02:00
platform - > export_pack ( current , export_pck_zip_debug - > is_pressed ( ) , p_path ) ;
2017-02-21 04:05:15 +01:00
}
}
2017-03-21 03:31:41 +01:00
void ProjectExportDialog : : _open_export_template_manager ( ) {
EditorNode : : get_singleton ( ) - > open_export_template_manager ( ) ;
hide ( ) ;
}
2018-08-31 10:48:40 +02:00
void ProjectExportDialog : : _validate_export_path ( const String & p_path ) {
// Disable export via OK button or Enter key if LineEdit has an empty filename
bool invalid_path = ( p_path . get_file ( ) . get_basename ( ) = = " " ) ;
// Check if state change before needlessly messing with signals
2020-05-14 16:41:43 +02:00
if ( invalid_path & & export_project - > get_ok ( ) - > is_disabled ( ) ) {
2018-08-31 10:48:40 +02:00
return ;
2020-05-14 16:41:43 +02:00
}
if ( ! invalid_path & & ! export_project - > get_ok ( ) - > is_disabled ( ) ) {
2018-08-31 10:48:40 +02:00
return ;
2020-05-14 16:41:43 +02:00
}
2018-08-31 10:48:40 +02:00
if ( invalid_path ) {
export_project - > get_ok ( ) - > set_disabled ( true ) ;
2020-02-19 20:27:19 +01:00
export_project - > get_line_edit ( ) - > disconnect_compat ( " text_entered " , export_project , " _file_entered " ) ;
2018-08-31 10:48:40 +02:00
} else {
export_project - > get_ok ( ) - > set_disabled ( false ) ;
2020-02-19 20:27:19 +01:00
export_project - > get_line_edit ( ) - > connect_compat ( " text_entered " , export_project , " _file_entered " ) ;
2018-08-31 10:48:40 +02:00
}
}
2017-03-21 23:34:26 +01:00
void ProjectExportDialog : : _export_project ( ) {
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-03-21 23:34:26 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
ERR_FAIL_COND ( platform . is_null ( ) ) ;
2019-04-24 20:52:15 +02:00
export_project - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2017-03-21 23:34:26 +01:00
export_project - > clear_filters ( ) ;
2017-12-12 22:09:48 +01:00
2018-10-29 22:18:49 +01:00
List < String > extension_list = platform - > get_binary_extensions ( current ) ;
for ( int i = 0 ; i < extension_list . size ( ) ; i + + ) {
export_project - > add_filter ( " *. " + extension_list [ i ] + " ; " + platform - > get_name ( ) + " Export " ) ;
}
2019-08-22 22:14:45 +02:00
if ( current - > get_export_path ( ) ! = " " ) {
export_project - > set_current_path ( current - > get_export_path ( ) ) ;
2018-08-31 10:48:40 +02:00
} else {
2018-10-29 22:18:49 +01:00
if ( extension_list . size ( ) > = 1 ) {
export_project - > set_current_file ( default_filename + " . " + extension_list [ 0 ] ) ;
2018-10-27 15:53:05 +02:00
} else {
export_project - > set_current_file ( default_filename ) ;
}
2018-08-31 10:48:40 +02:00
}
2020-02-27 22:49:16 +01: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
// disabling validation by the "text_entered" signal.
2020-02-19 20:27:19 +01:00
if ( ! export_project - > get_line_edit ( ) - > is_connected_compat ( " text_entered " , export_project , " _file_entered " ) ) {
2018-08-31 10:48:40 +02:00
export_project - > get_ok ( ) - > set_disabled ( false ) ;
2020-02-19 20:27:19 +01:00
export_project - > get_line_edit ( ) - > connect_compat ( " text_entered " , export_project , " _file_entered " ) ;
2017-03-21 23:34:26 +01:00
}
2020-03-06 18:00:16 +01:00
export_project - > set_file_mode ( EditorFileDialog : : FILE_MODE_SAVE_FILE ) ;
2020-07-11 18:45:19 +02:00
export_project - > popup_file_dialog ( ) ;
2017-03-21 23:34:26 +01:00
}
void ProjectExportDialog : : _export_project_to_path ( const String & p_path ) {
2017-10-28 10:57:29 +02:00
// Save this name for use in future exports (but drop the file extension)
2018-08-31 10:48:40 +02:00
default_filename = p_path . get_file ( ) . get_basename ( ) ;
2017-10-28 10:57:29 +02:00
EditorSettings : : get_singleton ( ) - > set_project_metadata ( " export_options " , " default_filename " , default_filename ) ;
2017-03-21 23:34:26 +01:00
2018-12-23 19:28:29 +01:00
Ref < EditorExportPreset > current = get_current_preset ( ) ;
2017-03-21 23:34:26 +01:00
ERR_FAIL_COND ( current . is_null ( ) ) ;
Ref < EditorExportPlatform > platform = current - > get_platform ( ) ;
ERR_FAIL_COND ( platform . is_null ( ) ) ;
2018-10-27 15:53:05 +02:00
current - > set_export_path ( p_path ) ;
2017-03-21 23:34:26 +01:00
Error err = platform - > export_project ( current , export_debug - > is_pressed ( ) , p_path , 0 ) ;
2018-12-19 19:50:40 +01:00
if ( err ! = OK & & err ! = ERR_SKIP ) {
2019-02-22 10:21:34 +01:00
if ( err = = ERR_FILE_NOT_FOUND ) {
error_dialog - > set_text ( vformat ( TTR ( " Failed to export the project for platform '%s'. \n Export templates seem to be missing or invalid. " ) , platform - > get_name ( ) ) ) ;
} else { // Assume misconfiguration. FIXME: Improve error handling and preset config validation.
error_dialog - > set_text ( vformat ( TTR ( " Failed to export the project for platform '%s'. \n This might be due to a configuration issue in the export preset or your export settings. " ) , platform - > get_name ( ) ) ) ;
}
2019-11-06 17:03:04 +01:00
ERR_PRINT ( vformat ( " Failed to export the project for platform '%s'. " , platform - > get_name ( ) ) ) ;
2017-10-13 00:38:42 +02:00
error_dialog - > show ( ) ;
2020-03-06 18:00:16 +01:00
error_dialog - > popup_centered ( Size2 ( 300 , 80 ) ) ;
2017-10-13 00:38:42 +02:00
}
2017-03-21 23:34:26 +01:00
}
2018-11-03 16:56:31 +01:00
void ProjectExportDialog : : _export_all_dialog ( ) {
export_all_dialog - > show ( ) ;
2020-03-06 18:00:16 +01:00
export_all_dialog - > popup_centered ( Size2 ( 300 , 80 ) ) ;
2018-11-03 16:56:31 +01:00
}
void ProjectExportDialog : : _export_all_dialog_action ( const String & p_str ) {
export_all_dialog - > hide ( ) ;
2019-06-26 15:08:25 +02:00
_export_all ( p_str ! = " release " ) ;
2018-11-03 16:56:31 +01:00
}
void ProjectExportDialog : : _export_all ( bool p_debug ) {
String mode = p_debug ? TTR ( " Debug " ) : TTR ( " Release " ) ;
2018-12-19 19:50:40 +01:00
EditorProgress ep ( " exportall " , TTR ( " Exporting All " ) + " " + mode , EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) , true ) ;
2018-11-03 16:56:31 +01:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
Ref < EditorExportPreset > preset = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) ;
ERR_FAIL_COND ( preset . is_null ( ) ) ;
Ref < EditorExportPlatform > platform = preset - > get_platform ( ) ;
ERR_FAIL_COND ( platform . is_null ( ) ) ;
ep . step ( preset - > get_name ( ) , i ) ;
Error err = platform - > export_project ( preset , p_debug , preset - > get_export_path ( ) , 0 ) ;
2018-12-19 19:50:40 +01:00
if ( err ! = OK & & err ! = ERR_SKIP ) {
2019-03-05 08:52:45 +01:00
if ( err = = ERR_FILE_BAD_PATH ) {
error_dialog - > set_text ( TTR ( " The given export path doesn't exist: " ) + " \n " + preset - > get_export_path ( ) . get_base_dir ( ) ) ;
} else {
error_dialog - > set_text ( TTR ( " Export templates for this platform are missing/corrupted: " ) + " " + platform - > get_name ( ) ) ;
}
2018-11-03 16:56:31 +01:00
error_dialog - > show ( ) ;
2020-03-06 18:00:16 +01:00
error_dialog - > popup_centered ( Size2 ( 300 , 80 ) ) ;
2018-11-03 16:56:31 +01:00
ERR_PRINT ( " Failed to export project " ) ;
}
}
}
2017-02-20 03:19:30 +01:00
void ProjectExportDialog : : _bind_methods ( ) {
2017-03-05 16:44:50 +01:00
ClassDB : : bind_method ( " get_drag_data_fw " , & ProjectExportDialog : : get_drag_data_fw ) ;
ClassDB : : bind_method ( " can_drop_data_fw " , & ProjectExportDialog : : can_drop_data_fw ) ;
ClassDB : : bind_method ( " drop_data_fw " , & ProjectExportDialog : : drop_data_fw ) ;
2018-11-03 16:56:31 +01:00
ClassDB : : bind_method ( " _export_all " , & ProjectExportDialog : : _export_all ) ;
2018-11-12 20:04:58 +01:00
ClassDB : : bind_method ( " set_export_path " , & ProjectExportDialog : : set_export_path ) ;
ClassDB : : bind_method ( " get_export_path " , & ProjectExportDialog : : get_export_path ) ;
2018-12-23 19:28:29 +01:00
ClassDB : : bind_method ( " get_current_preset " , & ProjectExportDialog : : get_current_preset ) ;
2018-11-12 20:04:58 +01:00
ADD_PROPERTY ( PropertyInfo ( Variant : : STRING , " export_path " ) , " set_export_path " , " get_export_path " ) ;
2017-02-20 03:19:30 +01:00
}
2018-08-31 10:48:40 +02:00
2017-02-20 03:19:30 +01:00
ProjectExportDialog : : ProjectExportDialog ( ) {
2017-03-02 22:43:56 +01:00
set_title ( TTR ( " Export " ) ) ;
2017-03-21 03:31:41 +01:00
VBoxContainer * main_vb = memnew ( VBoxContainer ) ;
2020-03-06 18:00:16 +01:00
main_vb - > connect ( " theme_changed " , callable_mp ( this , & ProjectExportDialog : : _theme_changed ) ) ;
2017-03-21 03:31:41 +01:00
add_child ( main_vb ) ;
2019-01-11 17:54:00 +01:00
HSplitContainer * hbox = memnew ( HSplitContainer ) ;
2017-03-21 03:31:41 +01:00
main_vb - > add_child ( hbox ) ;
2020-03-06 18:00:16 +01:00
hbox - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 03:19:30 +01:00
2020-01-08 13:29:49 +01:00
// Presets list.
2017-03-05 16:44:50 +01:00
VBoxContainer * preset_vb = memnew ( VBoxContainer ) ;
2017-02-20 03:19:30 +01:00
preset_vb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbox - > add_child ( preset_vb ) ;
2017-03-05 16:44:50 +01:00
HBoxContainer * preset_hb = memnew ( HBoxContainer ) ;
2017-02-20 03:19:30 +01:00
preset_hb - > add_child ( memnew ( Label ( TTR ( " Presets " ) ) ) ) ;
preset_hb - > add_spacer ( ) ;
preset_vb - > add_child ( preset_hb ) ;
2017-03-05 16:44:50 +01:00
add_preset = memnew ( MenuButton ) ;
2018-04-22 19:36:01 +02:00
add_preset - > set_text ( TTR ( " Add... " ) ) ;
2020-02-21 18:28:45 +01:00
add_preset - > get_popup ( ) - > connect ( " index_pressed " , callable_mp ( this , & ProjectExportDialog : : _add_preset ) ) ;
2017-02-20 03:19:30 +01:00
preset_hb - > add_child ( add_preset ) ;
2017-03-05 16:44:50 +01:00
MarginContainer * mc = memnew ( MarginContainer ) ;
2017-02-20 03:19:30 +01:00
preset_vb - > add_child ( mc ) ;
2020-03-06 18:00:16 +01:00
mc - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-03-05 16:44:50 +01:00
presets = memnew ( ItemList ) ;
2020-03-06 18:00:16 +01:00
# ifndef _MSC_VER
# warning must reimplement drag forward
# endif
//presets->set_drag_forwarding(this);
2017-02-20 03:19:30 +01:00
mc - > add_child ( presets ) ;
2020-02-21 18:28:45 +01:00
presets - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _edit_preset ) ) ;
2020-06-19 20:49:04 +02:00
duplicate_preset = memnew ( Button ) ;
duplicate_preset - > set_flat ( true ) ;
2018-10-28 19:13:38 +01:00
preset_hb - > add_child ( duplicate_preset ) ;
2020-02-21 18:28:45 +01:00
duplicate_preset - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _duplicate_preset ) ) ;
2020-06-19 20:49:04 +02:00
delete_preset = memnew ( Button ) ;
delete_preset - > set_flat ( true ) ;
2017-02-20 03:19:30 +01:00
preset_hb - > add_child ( delete_preset ) ;
2020-02-21 18:28:45 +01:00
delete_preset - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _delete_preset ) ) ;
2017-02-20 03:19:30 +01:00
2020-01-08 13:29:49 +01:00
// Preset settings.
2017-03-05 16:44:50 +01:00
VBoxContainer * settings_vb = memnew ( VBoxContainer ) ;
2017-02-20 03:19:30 +01:00
settings_vb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbox - > add_child ( settings_vb ) ;
name = memnew ( LineEdit ) ;
2017-03-05 16:44:50 +01:00
settings_vb - > add_margin_child ( TTR ( " Name: " ) , name ) ;
2020-02-21 18:28:45 +01:00
name - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _name_changed ) ) ;
2017-02-20 03:19:30 +01:00
runnable = memnew ( CheckButton ) ;
runnable - > set_text ( TTR ( " Runnable " ) ) ;
2019-11-14 15:11:31 +01:00
runnable - > set_tooltip ( 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 18:28:45 +01:00
runnable - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _runnable_pressed ) ) ;
2017-02-20 03:19:30 +01:00
settings_vb - > add_child ( runnable ) ;
2018-11-12 20:04:58 +01: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 18:28:45 +01:00
export_path - > connect ( " property_changed " , callable_mp ( this , & ProjectExportDialog : : _export_path_changed ) ) ;
2018-11-06 02:01:34 +01:00
2020-01-08 13:29:49 +01:00
// Subsections.
2017-03-05 16:44:50 +01:00
sections = memnew ( TabContainer ) ;
2017-05-02 22:13:12 +02:00
sections - > set_tab_align ( TabContainer : : ALIGN_LEFT ) ;
2019-01-26 19:41:36 +01:00
sections - > set_use_hidden_tabs_for_min_size ( true ) ;
2017-02-20 03:19:30 +01:00
settings_vb - > add_child ( sections ) ;
2020-03-06 18:00:16 +01:00
sections - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 03:19:30 +01:00
2020-01-08 13:29:49 +01:00
// Main preset parameters.
2018-08-18 15:07:23 +02:00
parameters = memnew ( EditorInspector ) ;
2017-02-20 03:19:30 +01:00
sections - > add_child ( parameters ) ;
parameters - > set_name ( TTR ( " Options " ) ) ;
2020-03-06 18:00:16 +01:00
parameters - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2020-02-21 18:28:45 +01:00
parameters - > connect ( " property_edited " , callable_mp ( this , & ProjectExportDialog : : _update_parameters ) ) ;
2020-04-24 09:45:14 +02:00
EditorExport : : get_singleton ( ) - > connect ( " export_presets_updated " , callable_mp ( this , & ProjectExportDialog : : _force_update_current_preset_parameters ) ) ;
2017-02-20 03:19:30 +01:00
2020-01-08 13:29:49 +01:00
// Resources export parameters.
2017-03-05 16:44:50 +01:00
VBoxContainer * resources_vb = memnew ( VBoxContainer ) ;
2017-02-20 03:19:30 +01:00
sections - > add_child ( resources_vb ) ;
resources_vb - > set_name ( TTR ( " Resources " ) ) ;
2017-03-05 16:44:50 +01:00
export_filter = memnew ( OptionButton ) ;
2017-02-20 03:19:30 +01:00
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) " ) ) ;
2017-03-05 16:44:50 +01:00
resources_vb - > add_margin_child ( TTR ( " Export Mode: " ) , export_filter ) ;
2020-02-21 18:28:45 +01:00
export_filter - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _export_type_changed ) ) ;
2017-02-20 03:19:30 +01:00
2017-03-05 16:44:50 +01:00
include_label = memnew ( Label ) ;
2017-02-20 03:19:30 +01:00
include_label - > set_text ( TTR ( " Resources to export: " ) ) ;
resources_vb - > add_child ( include_label ) ;
2017-03-05 16:44:50 +01:00
include_margin = memnew ( MarginContainer ) ;
2020-03-06 18:00:16 +01:00
include_margin - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-02-20 03:19:30 +01:00
resources_vb - > add_child ( include_margin ) ;
include_files = memnew ( Tree ) ;
include_margin - > add_child ( include_files ) ;
2020-02-21 18:28:45 +01:00
include_files - > connect ( " item_edited " , callable_mp ( this , & ProjectExportDialog : : _tree_changed ) ) ;
2017-02-20 03:19:30 +01:00
2017-03-05 16:44:50 +01:00
include_filters = memnew ( LineEdit ) ;
2019-10-05 16:45:12 +02: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 18:28:45 +01:00
include_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _filter_changed ) ) ;
2017-02-20 03:19:30 +01:00
2017-03-05 16:44:50 +01:00
exclude_filters = memnew ( LineEdit ) ;
2019-10-05 16:45:12 +02: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 18:28:45 +01:00
exclude_filters - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _filter_changed ) ) ;
2017-02-20 03:19:30 +01:00
2020-04-28 19:51:29 +02:00
script_mode = memnew ( OptionButton ) ;
resources_vb - > add_margin_child ( TTR ( " Script Export Mode: " ) , script_mode ) ;
script_mode - > add_item ( TTR ( " Text " ) , ( int ) EditorExportPreset : : MODE_SCRIPT_TEXT ) ;
script_mode - > add_item ( TTR ( " Compiled " ) , ( int ) EditorExportPreset : : MODE_SCRIPT_COMPILED ) ;
script_mode - > connect ( " item_selected " , callable_mp ( this , & ProjectExportDialog : : _script_export_mode_changed ) ) ;
2020-01-08 13:29:49 +01:00
// Feature tags.
2017-07-19 22:00:46 +02:00
VBoxContainer * feature_vb = memnew ( VBoxContainer ) ;
feature_vb - > set_name ( TTR ( " Features " ) ) ;
custom_features = memnew ( LineEdit ) ;
2020-02-21 18:28:45 +01:00
custom_features - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _custom_features_changed ) ) ;
2017-07-19 22:00:46 +02:00
feature_vb - > add_margin_child ( TTR ( " Custom (comma-separated): " ) , custom_features ) ;
custom_feature_display = memnew ( RichTextLabel ) ;
2020-03-06 18:00:16 +01:00
custom_feature_display - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2020-04-05 05:08:53 +02:00
feature_vb - > add_margin_child ( TTR ( " Feature List: " ) , custom_feature_display , true ) ;
2017-07-19 22:00:46 +02:00
sections - > add_child ( feature_vb ) ;
2020-01-08 13:29:49 +01:00
// Script export parameters.
2018-12-23 19:28:29 +01:00
updating_script_key = false ;
2020-04-28 19:51:29 +02:00
updating_enc_filters = false ;
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 ) ) ;
enc_pck - > set_text ( TTR ( " Encrypt exported PCK " ) ) ;
sec_vb - > add_child ( enc_pck ) ;
enc_directory = memnew ( CheckButton ) ;
enc_directory - > connect ( " toggled " , callable_mp ( this , & ProjectExportDialog : : _enc_directory_changed ) ) ;
enc_directory - > set_text ( " Encrypt index (file names and info). " ) ;
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 (
TTR ( " Filters to exclude files/folders \n (comma-separated, e.g: *.stex, *.import, music/*) " ) ,
enc_ex_filters ) ;
2018-12-23 19:28:29 +01:00
script_key = memnew ( LineEdit ) ;
2020-02-21 18:28:45 +01:00
script_key - > connect ( " text_changed " , callable_mp ( this , & ProjectExportDialog : : _script_encryption_key_changed ) ) ;
2018-12-23 19:28:29 +01:00
script_key_error = memnew ( Label ) ;
script_key_error - > set_text ( " - " + TTR ( " Invalid Encryption Key (must be 64 characters long) " ) ) ;
2020-03-12 13:37:40 +01:00
script_key_error - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_theme_color ( " error_color " , " Editor " ) ) ;
2020-04-28 19:51:29 +02:00
sec_vb - > add_margin_child ( TTR ( " Encryption Key (256-bits as hex): " ) , script_key ) ;
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 19:28:29 +01:00
2020-02-21 18:28:45 +01:00
sections - > connect ( " tab_changed " , callable_mp ( this , & ProjectExportDialog : : _tab_changed ) ) ;
2017-07-19 22:00:46 +02:00
2020-01-08 13:29:49 +01:00
// Disable by default.
2017-02-20 03:19:30 +01:00
name - > set_editable ( false ) ;
2018-11-12 20:04:58 +01:00
export_path - > hide ( ) ;
2017-02-20 03:19:30 +01:00
runnable - > set_disabled ( true ) ;
2018-10-28 19:13:38 +01:00
duplicate_preset - > set_disabled ( true ) ;
2017-02-20 03:19:30 +01:00
delete_preset - > set_disabled ( true ) ;
2018-12-23 19:28:29 +01:00
script_key_error - > hide ( ) ;
2017-02-20 03:19:30 +01:00
sections - > hide ( ) ;
2020-04-02 01:20:12 +02:00
parameters - > edit ( nullptr ) ;
2017-02-20 03:19:30 +01:00
2020-01-08 13:29:49 +01:00
// Deletion dialog.
2017-03-05 16:44:50 +01:00
delete_confirm = memnew ( ConfirmationDialog ) ;
2017-02-20 03:19:30 +01:00
add_child ( delete_confirm ) ;
delete_confirm - > get_ok ( ) - > set_text ( TTR ( " Delete " ) ) ;
2020-02-21 18:28:45 +01:00
delete_confirm - > connect ( " confirmed " , callable_mp ( this , & ProjectExportDialog : : _delete_preset_confirm ) ) ;
2014-02-10 02:10:30 +01:00
2020-01-08 13:29:49 +01:00
// Export buttons, dialogs and errors.
2017-03-05 16:44:50 +01:00
updating = false ;
2014-02-10 02:10:30 +01:00
2017-10-11 19:15:44 +02:00
get_cancel ( ) - > set_text ( TTR ( " Close " ) ) ;
2017-08-23 22:25:14 +02:00
get_ok ( ) - > set_text ( TTR ( " Export PCK/Zip " ) ) ;
2020-07-09 01:02:38 +02:00
export_button = add_button ( TTR ( " Export Project " ) , ! DisplayServer : : get_singleton ( ) - > get_swap_cancel_ok ( ) , " export " ) ;
2020-02-21 18:28:45 +01:00
export_button - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _export_project ) ) ;
2018-08-31 10:48:40 +02:00
// Disable initially before we select a valid preset
export_button - > set_disabled ( true ) ;
2019-10-16 11:54:04 +02:00
get_ok ( ) - > set_disabled ( true ) ;
2017-02-21 04:05:15 +01:00
2018-11-03 16:56:31 +01:00
export_all_dialog = memnew ( ConfirmationDialog ) ;
add_child ( export_all_dialog ) ;
export_all_dialog - > set_title ( " Export All " ) ;
export_all_dialog - > set_text ( TTR ( " Export mode? " ) ) ;
export_all_dialog - > get_ok ( ) - > hide ( ) ;
export_all_dialog - > add_button ( TTR ( " Debug " ) , true , " debug " ) ;
export_all_dialog - > add_button ( TTR ( " Release " ) , true , " release " ) ;
2020-02-21 18:28:45 +01:00
export_all_dialog - > connect ( " custom_action " , callable_mp ( this , & ProjectExportDialog : : _export_all_dialog_action ) ) ;
2018-11-03 16:56:31 +01:00
2020-07-09 01:02:38 +02:00
export_all_button = add_button ( TTR ( " Export All " ) , ! DisplayServer : : get_singleton ( ) - > get_swap_cancel_ok ( ) , " export " ) ;
2020-02-21 18:28:45 +01:00
export_all_button - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _export_all_dialog ) ) ;
2018-11-03 16:56:31 +01:00
export_all_button - > set_disabled ( true ) ;
2019-04-24 20:52:15 +02:00
export_pck_zip = memnew ( EditorFileDialog ) ;
2019-12-16 06:18:44 +01:00
export_pck_zip - > add_filter ( " *.zip ; " + TTR ( " ZIP File " ) ) ;
export_pck_zip - > add_filter ( " *.pck ; " + TTR ( " Godot Game Pack " ) ) ;
2019-04-24 20:52:15 +02:00
export_pck_zip - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2020-03-06 18:00:16 +01:00
export_pck_zip - > set_file_mode ( EditorFileDialog : : FILE_MODE_SAVE_FILE ) ;
2017-02-21 04:05:15 +01:00
add_child ( export_pck_zip ) ;
2020-02-21 18:28:45 +01:00
export_pck_zip - > connect ( " file_selected " , callable_mp ( this , & ProjectExportDialog : : _export_pck_zip_selected ) ) ;
2017-02-21 04:05:15 +01:00
2017-03-21 03:31:41 +01:00
export_error = memnew ( Label ) ;
main_vb - > add_child ( export_error ) ;
export_error - > hide ( ) ;
2020-03-12 13:37:40 +01:00
export_error - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_theme_color ( " error_color " , " Editor " ) ) ;
2017-03-21 03:31:41 +01: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 ) ;
2020-03-12 13:37:40 +01:00
export_error2 - > add_theme_color_override ( " font_color " , EditorNode : : get_singleton ( ) - > get_gui_base ( ) - > get_theme_color ( " error_color " , " Editor " ) ) ;
2017-03-21 03:31:41 +01:00
export_error2 - > set_text ( " - " + TTR ( " Export templates for this platform are missing: " ) + " " ) ;
2017-10-13 00:38:42 +02:00
error_dialog = memnew ( AcceptDialog ) ;
error_dialog - > set_title ( " Error " ) ;
error_dialog - > set_text ( TTR ( " Export templates for this platform are missing/corrupted: " ) + " " ) ;
main_vb - > add_child ( error_dialog ) ;
error_dialog - > hide ( ) ;
2017-03-21 03:31:41 +01:00
LinkButton * download_templates = memnew ( LinkButton ) ;
download_templates - > set_text ( TTR ( " Manage Export Templates " ) ) ;
2020-03-06 18:00:16 +01:00
download_templates - > set_v_size_flags ( Control : : SIZE_SHRINK_CENTER ) ;
2017-03-21 03:31:41 +01:00
export_templates_error - > add_child ( download_templates ) ;
2020-02-21 18:28:45 +01:00
download_templates - > connect ( " pressed " , callable_mp ( this , & ProjectExportDialog : : _open_export_template_manager ) ) ;
2017-03-21 03:31:41 +01:00
2019-04-24 20:52:15 +02:00
export_project = memnew ( EditorFileDialog ) ;
export_project - > set_access ( EditorFileDialog : : ACCESS_FILESYSTEM ) ;
2017-03-21 23:34:26 +01:00
add_child ( export_project ) ;
2020-02-21 18:28:45 +01: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 23:34:26 +01:00
2019-01-20 23:50:46 +01:00
export_debug = memnew ( CheckBox ) ;
2017-03-21 23:34:26 +01:00
export_debug - > set_text ( TTR ( " Export With Debug " ) ) ;
export_debug - > set_pressed ( true ) ;
export_project - > get_vbox ( ) - > add_child ( export_debug ) ;
2019-01-20 23:50:46 +01:00
export_pck_zip_debug = memnew ( CheckBox ) ;
2018-04-26 23:08:19 +02:00
export_pck_zip_debug - > set_text ( TTR ( " Export With Debug " ) ) ;
export_pck_zip_debug - > set_pressed ( true ) ;
export_pck_zip - > get_vbox ( ) - > add_child ( export_pck_zip_debug ) ;
2017-02-21 04:05:15 +01:00
set_hide_on_ok ( false ) ;
2017-02-20 03:19:30 +01:00
editor_icons = " EditorIcons " ;
2017-10-28 10:57:29 +02:00
2018-08-31 10:48:40 +02:00
default_filename = EditorSettings : : get_singleton ( ) - > get_project_metadata ( " export_options " , " default_filename " , " " ) ;
// If no default set, use project name
2018-04-17 23:10:30 +02:00
if ( default_filename = = " " ) {
2018-08-31 10:48:40 +02:00
// If no project name defined, use a sane default
2018-04-17 23:10:30 +02:00
default_filename = ProjectSettings : : get_singleton ( ) - > get ( " application/config/name " ) ;
2018-08-31 10:48:40 +02:00
if ( default_filename = = " " ) {
default_filename = " UnnamedProject " ;
}
2018-04-17 23:10:30 +02:00
}
2018-11-03 16:56:31 +01:00
_update_export_all ( ) ;
2014-02-10 02:10:30 +01:00
}
ProjectExportDialog : : ~ ProjectExportDialog ( ) {
}