2014-02-10 01:10:30 +00:00
/*************************************************************************/
2017-09-01 14:07:55 +00:00
/* project_settings_editor.cpp */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
2017-08-27 12:16:55 +00:00
/* https://godotengine.org */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
2017-01-01 21:01:57 +00:00
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
2017-04-07 22:11:42 +00:00
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
2014-02-10 01:10:30 +00: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. */
/*************************************************************************/
2017-07-19 20:00:46 +00:00
# include "project_settings_editor.h"
2017-01-16 07:04:19 +00:00
2017-08-26 15:46:49 +00:00
# include "core/global_constants.h"
# include "core/os/keyboard.h"
# include "core/project_settings.h"
# include "core/translation.h"
# include "editor/editor_node.h"
2014-02-10 01:10:30 +00:00
# include "scene/gui/margin_container.h"
2017-03-05 15:44:50 +00:00
# include "scene/gui/tab_container.h"
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
ProjectSettingsEditor * ProjectSettingsEditor : : singleton = NULL ;
2017-03-05 15:44:50 +00:00
static const char * _button_names [ JOY_BUTTON_MAX ] = {
2017-03-18 11:31:14 +00:00
" PS Cross, XBox A, Nintendo B " ,
2017-03-05 15:44:50 +00:00
" PS Circle, XBox B, Nintendo A " ,
" PS Square, XBox X, Nintendo Y " ,
" PS Triangle, XBox Y, Nintendo X " ,
" L, L1 " ,
" R, R1 " ,
" L2 " ,
" R2 " ,
" L3 " ,
" R3 " ,
" Select, Nintendo - " ,
" Start, Nintendo + " ,
" D-Pad Up " ,
" D-Pad Down " ,
" D-Pad Left " ,
" D-Pad Right "
2014-02-10 01:10:30 +00:00
} ;
2017-03-05 15:44:50 +00:00
static const char * _axis_names [ JOY_AXIS_MAX * 2 ] = {
2016-04-28 13:53:49 +00:00
" (Left Stick Left) " ,
" (Left Stick Right) " ,
" (Left Stick Up) " ,
" (Left Stick Down) " ,
" (Right Stick Left) " ,
" (Right Stick Right) " ,
" (Right Stick Up) " ,
" (Right Stick Down) " ,
2017-03-05 15:44:50 +00:00
" " , " " , " " , " " ,
2016-04-28 13:53:49 +00:00
" " , " (L2) " ,
" " , " (R2) "
} ;
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _notification ( int p_what ) {
2014-02-10 01:10:30 +00:00
2017-03-02 21:43:56 +00:00
switch ( p_what ) {
case NOTIFICATION_ENTER_TREE : {
2017-07-19 20:00:46 +00:00
globals_editor - > edit ( ProjectSettings : : get_singleton ( ) ) ;
2014-02-10 01:10:30 +00:00
2017-07-12 18:38:47 +00:00
search_button - > set_icon ( get_icon ( " Search " , " EditorIcons " ) ) ;
2017-03-05 15:44:50 +00:00
clear_button - > set_icon ( get_icon ( " Close " , " EditorIcons " ) ) ;
2016-03-06 14:22:21 +00:00
2017-10-28 02:35:09 +00:00
action_add_error - > add_color_override ( " font_color " , get_color ( " error_color " , " Editor " ) ) ;
2017-03-05 15:44:50 +00:00
translation_list - > connect ( " button_pressed " , this , " _translation_delete " ) ;
2017-03-02 21:43:56 +00:00
_update_actions ( ) ;
2017-05-20 15:38:03 +00:00
popup_add - > add_icon_item ( get_icon ( " Keyboard " , " EditorIcons " ) , TTR ( " Key " ) , INPUT_KEY ) ; //"Key " - because the word 'key' has already been used as a key animation
popup_add - > add_icon_item ( get_icon ( " JoyButton " , " EditorIcons " ) , TTR ( " Joy Button " ) , INPUT_JOY_BUTTON ) ;
popup_add - > add_icon_item ( get_icon ( " JoyAxis " , " EditorIcons " ) , TTR ( " Joy Axis " ) , INPUT_JOY_MOTION ) ;
popup_add - > add_icon_item ( get_icon ( " Mouse " , " EditorIcons " ) , TTR ( " Mouse Button " ) , INPUT_MOUSE_BUTTON ) ;
2016-01-23 19:05:27 +00:00
2017-03-02 21:43:56 +00:00
List < String > tfn ;
2017-03-05 15:44:50 +00:00
ResourceLoader : : get_recognized_extensions_for_type ( " Translation " , & tfn ) ;
for ( List < String > : : Element * E = tfn . front ( ) ; E ; E = E - > next ( ) ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
translation_file_open - > add_filter ( " *. " + E - > get ( ) ) ;
2017-03-02 21:43:56 +00:00
}
2014-02-10 01:10:30 +00:00
2017-03-02 21:43:56 +00:00
List < String > rfn ;
2017-03-05 15:44:50 +00:00
ResourceLoader : : get_recognized_extensions_for_type ( " Resource " , & rfn ) ;
for ( List < String > : : Element * E = rfn . front ( ) ; E ; E = E - > next ( ) ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
translation_res_file_open - > add_filter ( " *. " + E - > get ( ) ) ;
translation_res_option_file_open - > add_filter ( " *. " + E - > get ( ) ) ;
2017-03-02 21:43:56 +00:00
}
} break ;
case NOTIFICATION_POPUP_HIDE : {
EditorSettings : : get_singleton ( ) - > set ( " interface/dialogs/project_settings_bounds " , get_rect ( ) ) ;
} break ;
2017-05-02 20:13:12 +00:00
case EditorSettings : : NOTIFICATION_EDITOR_SETTINGS_CHANGED : {
_update_actions ( ) ;
} break ;
2014-02-10 01:10:30 +00:00
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _action_selected ( ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
TreeItem * ti = input_editor - > get_selected ( ) ;
2016-02-12 15:41:50 +00:00
if ( ! ti | | ! ti - > is_editable ( 0 ) )
return ;
2017-03-05 15:44:50 +00:00
add_at = " input/ " + ti - > get_text ( 0 ) ;
2017-06-24 12:35:36 +00:00
edit_idx = - 1 ;
2016-02-12 15:41:50 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _action_edited ( ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
TreeItem * ti = input_editor - > get_selected ( ) ;
2014-02-10 01:10:30 +00:00
if ( ! ti )
return ;
2017-03-05 15:44:50 +00:00
String new_name = ti - > get_text ( 0 ) ;
String old_name = add_at . substr ( add_at . find ( " / " ) + 1 , add_at . length ( ) ) ;
2016-02-12 15:41:50 +00:00
2017-03-05 15:44:50 +00:00
if ( new_name = = old_name )
2016-02-12 15:41:50 +00:00
return ;
2017-03-05 15:44:50 +00:00
if ( new_name . find ( " / " ) ! = - 1 | | new_name . find ( " : " ) ! = - 1 | | new_name = = " " ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
ti - > set_text ( 0 , old_name ) ;
add_at = " input/ " + old_name ;
2016-02-12 15:41:50 +00:00
2016-05-18 22:08:12 +00:00
message - > set_text ( TTR ( " Invalid action (anything goes but '/' or ':'). " ) ) ;
2017-07-31 18:19:45 +00:00
message - > popup_centered ( Size2 ( 300 , 100 ) * EDSCALE ) ;
2014-02-10 01:10:30 +00:00
return ;
2016-02-12 15:41:50 +00:00
}
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
String action_prop = " input/ " + new_name ;
2016-02-12 15:41:50 +00:00
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( action_prop ) ) {
2016-02-12 15:41:50 +00:00
2017-03-05 15:44:50 +00:00
ti - > set_text ( 0 , old_name ) ;
add_at = " input/ " + old_name ;
2016-02-12 15:41:50 +00:00
2017-03-05 15:44:50 +00:00
message - > set_text ( vformat ( TTR ( " Action '%s' already exists! " ) , new_name ) ) ;
2017-07-31 18:19:45 +00:00
message - > popup_centered ( Size2 ( 300 , 100 ) * EDSCALE ) ;
2016-02-12 15:41:50 +00:00
return ;
}
2017-07-19 20:00:46 +00:00
int order = ProjectSettings : : get_singleton ( ) - > get_order ( add_at ) ;
Array va = ProjectSettings : : get_singleton ( ) - > get ( add_at ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
setting = true ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Rename Input Action Event " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " clear " , add_at ) ;
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , action_prop , va ) ;
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set_order " , action_prop , order ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " clear " , action_prop ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , add_at , va ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set_order " , add_at , order ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
2017-03-05 15:44:50 +00:00
setting = false ;
2016-02-12 15:41:50 +00:00
2017-03-05 15:44:50 +00:00
add_at = action_prop ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _device_input_add ( ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEvent > ie ;
2017-03-05 15:44:50 +00:00
String name = add_at ;
2017-06-24 12:35:36 +00:00
int idx = edit_idx ;
2017-09-06 21:13:05 +00:00
Array old_val = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
Array arr = old_val . duplicate ( ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
switch ( add_type ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
case INPUT_MOUSE_BUTTON : {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventMouseButton > mb ;
mb . instance ( ) ;
mb - > set_button_index ( device_index - > get_selected ( ) + 1 ) ;
mb - > set_device ( device_id - > get_value ( ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < arr . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventMouseButton > aie = arr [ i ] ;
if ( aie . is_null ( ) )
continue ;
if ( aie - > get_device ( ) = = mb - > get_device ( ) & & aie - > get_button_index ( ) = = mb - > get_button_index ( ) ) {
2017-03-05 15:44:50 +00:00
return ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
}
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
ie = mb ;
2014-02-10 01:10:30 +00:00
} break ;
2017-05-20 15:38:03 +00:00
case INPUT_JOY_MOTION : {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventJoypadMotion > jm ;
jm . instance ( ) ;
jm - > set_axis ( device_index - > get_selected ( ) > > 1 ) ;
jm - > set_axis_value ( device_index - > get_selected ( ) & 1 ? 1 : - 1 ) ;
jm - > set_device ( device_id - > get_value ( ) ) ;
2016-01-02 12:37:16 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < arr . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventJoypadMotion > aie = arr [ i ] ;
if ( aie . is_null ( ) )
continue ;
if ( aie - > get_device ( ) = = jm - > get_device ( ) & & aie - > get_axis ( ) = = jm - > get_axis ( ) & & aie - > get_axis_value ( ) = = jm - > get_axis_value ( ) ) {
2017-03-05 15:44:50 +00:00
return ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
}
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
ie = jm ;
2014-02-10 01:10:30 +00:00
} break ;
2017-05-20 15:38:03 +00:00
case INPUT_JOY_BUTTON : {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventJoypadButton > jb ;
jb . instance ( ) ;
jb - > set_button_index ( device_index - > get_selected ( ) ) ;
jb - > set_device ( device_id - > get_value ( ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < arr . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventJoypadButton > aie = arr [ i ] ;
if ( aie . is_null ( ) )
continue ;
if ( aie - > get_device ( ) = = jb - > get_device ( ) & & aie - > get_button_index ( ) = = jb - > get_button_index ( ) ) {
2017-03-05 15:44:50 +00:00
return ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
}
2017-05-20 15:38:03 +00:00
ie = jb ;
2014-02-10 01:10:30 +00:00
} break ;
2017-03-05 15:44:50 +00:00
default : { }
2014-02-10 01:10:30 +00:00
}
2017-06-24 12:35:36 +00:00
if ( idx < 0 | | idx > = arr . size ( ) ) {
arr . push_back ( ie ) ;
} else {
arr [ idx ] = ie ;
}
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Input Action Event " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , name , arr ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , name , old_val ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
2017-02-13 06:57:46 +00:00
_show_last_added ( ie , name ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _press_a_key_confirm ( ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
if ( last_wait_for_key . is_null ( ) )
2014-02-10 01:10:30 +00:00
return ;
2017-05-20 15:38:03 +00:00
Ref < InputEventKey > ie ;
ie . instance ( ) ;
ie - > set_scancode ( last_wait_for_key - > get_scancode ( ) ) ;
ie - > set_shift ( last_wait_for_key - > get_shift ( ) ) ;
ie - > set_alt ( last_wait_for_key - > get_alt ( ) ) ;
ie - > set_control ( last_wait_for_key - > get_control ( ) ) ;
ie - > set_metakey ( last_wait_for_key - > get_metakey ( ) ) ;
2017-03-05 15:44:50 +00:00
String name = add_at ;
2017-06-24 12:35:36 +00:00
int idx = edit_idx ;
2014-02-10 01:10:30 +00:00
2017-09-06 21:13:05 +00:00
Array old_val = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
Array arr = old_val . duplicate ( ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < arr . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEventKey > aie = arr [ i ] ;
if ( aie . is_null ( ) )
continue ;
if ( aie - > get_scancode_with_modifiers ( ) = = ie - > get_scancode_with_modifiers ( ) ) {
2014-02-10 01:10:30 +00:00
return ;
}
}
2017-06-24 12:35:36 +00:00
if ( idx < 0 | | idx > = arr . size ( ) ) {
arr . push_back ( ie ) ;
} else {
arr [ idx ] = ie ;
}
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Input Action Event " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , name , arr ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , name , old_val ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
2017-02-13 06:57:46 +00:00
_show_last_added ( ie , name ) ;
2016-08-22 23:14:04 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _show_last_added ( const Ref < InputEvent > & p_event , const String & p_name ) {
2016-08-22 23:14:04 +00:00
TreeItem * r = input_editor - > get_root ( ) ;
2017-02-13 06:57:46 +00:00
String name = p_name ;
2017-03-05 15:44:50 +00:00
name . erase ( 0 , 6 ) ;
2016-08-22 23:14:04 +00:00
if ( ! r )
return ;
2017-03-05 15:44:50 +00:00
r = r - > get_children ( ) ;
2016-08-22 23:14:04 +00:00
if ( ! r )
return ;
bool found = false ;
2017-03-05 15:44:50 +00:00
while ( r ) {
2017-02-13 06:57:46 +00:00
if ( r - > get_text ( 0 ) ! = name ) {
2017-03-05 15:44:50 +00:00
r = r - > get_next ( ) ;
2017-02-13 06:57:46 +00:00
continue ;
}
2016-08-22 23:14:04 +00:00
TreeItem * child = r - > get_children ( ) ;
2017-03-05 15:44:50 +00:00
while ( child ) {
2016-08-22 23:14:04 +00:00
Variant input = child - > get_meta ( " __input " ) ;
2017-03-05 15:44:50 +00:00
if ( p_event = = input ) {
2016-08-22 23:14:04 +00:00
child - > select ( 0 ) ;
found = true ;
break ;
}
2017-03-05 15:44:50 +00:00
child = child - > get_next ( ) ;
2016-08-22 23:14:04 +00:00
}
if ( found ) break ;
2017-03-05 15:44:50 +00:00
r = r - > get_next ( ) ;
2016-08-22 23:14:04 +00:00
}
2014-02-10 01:10:30 +00:00
2016-08-22 23:14:04 +00:00
if ( found ) input_editor - > ensure_cursor_is_visible ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _wait_for_key ( const Ref < InputEvent > & p_event ) {
2017-05-20 15:38:03 +00:00
Ref < InputEventKey > k = p_event ;
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
if ( k . is_valid ( ) & & k - > is_pressed ( ) & & k - > get_scancode ( ) ! = 0 ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
last_wait_for_key = p_event ;
2017-05-20 15:38:03 +00:00
String str = keycode_get_string ( k - > get_scancode ( ) ) . capitalize ( ) ;
if ( k - > get_metakey ( ) )
2017-10-13 09:12:58 +00:00
str = vformat ( " %s+ " , find_keycode_name ( KEY_META ) ) + str ;
2017-05-20 15:38:03 +00:00
if ( k - > get_shift ( ) )
2017-03-05 15:44:50 +00:00
str = TTR ( " Shift+ " ) + str ;
2017-05-20 15:38:03 +00:00
if ( k - > get_alt ( ) )
2017-03-05 15:44:50 +00:00
str = TTR ( " Alt+ " ) + str ;
2017-05-20 15:38:03 +00:00
if ( k - > get_control ( ) )
2017-03-05 15:44:50 +00:00
str = TTR ( " Control+ " ) + str ;
2014-02-10 01:10:30 +00:00
press_a_key_label - > set_text ( str ) ;
press_a_key - > accept_event ( ) ;
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _add_item ( int p_item , Ref < InputEvent > p_exiting_event ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
add_type = InputType ( p_item ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
switch ( add_type ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
case INPUT_KEY : {
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
press_a_key_label - > set_text ( TTR ( " Press a Key.. " ) ) ;
2017-05-20 15:38:03 +00:00
last_wait_for_key = Ref < InputEvent > ( ) ;
2017-03-05 15:44:50 +00:00
press_a_key - > popup_centered ( Size2 ( 250 , 80 ) * EDSCALE ) ;
2014-02-10 01:10:30 +00:00
press_a_key - > grab_focus ( ) ;
} break ;
2017-05-20 15:38:03 +00:00
case INPUT_MOUSE_BUTTON : {
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
device_index_label - > set_text ( TTR ( " Mouse Button Index: " ) ) ;
2014-02-10 01:10:30 +00:00
device_index - > clear ( ) ;
2016-05-04 01:25:37 +00:00
device_index - > add_item ( TTR ( " Left Button " ) ) ;
device_index - > add_item ( TTR ( " Right Button " ) ) ;
device_index - > add_item ( TTR ( " Middle Button " ) ) ;
device_index - > add_item ( TTR ( " Wheel Up Button " ) ) ;
device_index - > add_item ( TTR ( " Wheel Down Button " ) ) ;
device_index - > add_item ( TTR ( " Button 6 " ) ) ;
device_index - > add_item ( TTR ( " Button 7 " ) ) ;
device_index - > add_item ( TTR ( " Button 8 " ) ) ;
device_index - > add_item ( TTR ( " Button 9 " ) ) ;
2017-07-31 18:19:45 +00:00
device_input - > popup_centered_minsize ( Size2 ( 350 , 95 ) * EDSCALE ) ;
2017-06-24 12:35:36 +00:00
Ref < InputEventMouseButton > mb = p_exiting_event ;
if ( mb . is_valid ( ) ) {
device_index - > select ( mb - > get_button_index ( ) - 1 ) ;
device_id - > set_value ( mb - > get_device ( ) ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Change " ) ) ;
} else {
device_id - > set_value ( 0 ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Add " ) ) ;
}
2014-02-10 01:10:30 +00:00
} break ;
2017-05-20 15:38:03 +00:00
case INPUT_JOY_MOTION : {
2014-02-10 01:10:30 +00:00
2017-01-08 20:05:51 +00:00
device_index_label - > set_text ( TTR ( " Joypad Axis Index: " ) ) ;
2014-02-10 01:10:30 +00:00
device_index - > clear ( ) ;
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < JOY_AXIS_MAX * 2 ; i + + ) {
2016-01-02 12:37:16 +00:00
2016-04-28 13:53:49 +00:00
String desc = _axis_names [ i ] ;
2017-03-05 15:44:50 +00:00
device_index - > add_item ( TTR ( " Axis " ) + " " + itos ( i / 2 ) + " " + ( i & 1 ? " + " : " - " ) + desc ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-31 18:19:45 +00:00
device_input - > popup_centered_minsize ( Size2 ( 350 , 95 ) * EDSCALE ) ;
2014-02-10 01:10:30 +00:00
2017-06-24 12:35:36 +00:00
Ref < InputEventJoypadMotion > jm = p_exiting_event ;
if ( jm . is_valid ( ) ) {
device_index - > select ( jm - > get_axis ( ) * 2 + ( jm - > get_axis_value ( ) > 0 ? 1 : 0 ) ) ;
device_id - > set_value ( jm - > get_device ( ) ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Change " ) ) ;
} else {
device_id - > set_value ( 0 ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Add " ) ) ;
}
2014-02-10 01:10:30 +00:00
} break ;
2017-05-20 15:38:03 +00:00
case INPUT_JOY_BUTTON : {
2014-02-10 01:10:30 +00:00
2017-01-08 20:05:51 +00:00
device_index_label - > set_text ( TTR ( " Joypad Button Index: " ) ) ;
2014-02-10 01:10:30 +00:00
device_index - > clear ( ) ;
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < JOY_BUTTON_MAX ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
device_index - > add_item ( itos ( i ) + " : " + String ( _button_names [ i ] ) ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-31 18:19:45 +00:00
device_input - > popup_centered_minsize ( Size2 ( 350 , 95 ) * EDSCALE ) ;
2014-02-10 01:10:30 +00:00
2017-06-24 12:35:36 +00:00
Ref < InputEventJoypadButton > jb = p_exiting_event ;
if ( jb . is_valid ( ) ) {
device_index - > select ( jb - > get_button_index ( ) ) ;
device_id - > set_value ( jb - > get_device ( ) ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Change " ) ) ;
} else {
device_id - > set_value ( 0 ) ;
device_input - > get_ok ( ) - > set_text ( TTR ( " Add " ) ) ;
}
2014-02-10 01:10:30 +00:00
} break ;
2017-03-05 15:44:50 +00:00
default : { }
2014-02-10 01:10:30 +00:00
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _edit_item ( Ref < InputEvent > p_exiting_event ) {
2017-06-24 12:35:36 +00:00
InputType ie_type ;
if ( ( Ref < InputEventKey > ( p_exiting_event ) ) . is_valid ( ) ) {
ie_type = INPUT_KEY ;
} else if ( ( Ref < InputEventJoypadButton > ( p_exiting_event ) ) . is_valid ( ) ) {
ie_type = INPUT_JOY_BUTTON ;
} else if ( ( Ref < InputEventMouseButton > ( p_exiting_event ) ) . is_valid ( ) ) {
ie_type = INPUT_MOUSE_BUTTON ;
} else if ( ( Ref < InputEventJoypadMotion > ( p_exiting_event ) ) . is_valid ( ) ) {
ie_type = INPUT_JOY_MOTION ;
} else {
return ;
}
_add_item ( ie_type , p_exiting_event ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _action_activated ( ) {
2017-06-24 12:35:36 +00:00
TreeItem * ti = input_editor - > get_selected ( ) ;
if ( ! ti | | ti - > get_parent ( ) = = input_editor - > get_root ( ) )
return ;
String name = " input/ " + ti - > get_parent ( ) - > get_text ( 0 ) ;
int idx = ti - > get_metadata ( 0 ) ;
2017-07-19 20:00:46 +00:00
Array va = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
2017-06-24 12:35:36 +00:00
ERR_FAIL_INDEX ( idx , va . size ( ) ) ;
Ref < InputEvent > ie = va [ idx ] ;
if ( ie . is_null ( ) )
return ;
add_at = name ;
edit_idx = idx ;
_edit_item ( ie ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _action_button_pressed ( Object * p_obj , int p_column , int p_id ) {
2014-02-10 01:10:30 +00:00
2017-08-24 20:58:51 +00:00
TreeItem * ti = Object : : cast_to < TreeItem > ( p_obj ) ;
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND ( ! ti ) ;
2017-03-05 15:44:50 +00:00
if ( p_id = = 1 ) {
2017-03-29 15:29:38 +00:00
Point2 ofs = input_editor - > get_global_position ( ) ;
2017-03-05 15:44:50 +00:00
Rect2 ir = input_editor - > get_item_rect ( ti ) ;
2017-06-03 22:25:13 +00:00
ir . position . y - = input_editor - > get_scroll ( ) . y ;
ofs + = ir . position + ir . size ;
2017-03-05 15:44:50 +00:00
ofs . x - = 100 ;
2017-03-29 15:29:38 +00:00
popup_add - > set_position ( ofs ) ;
2014-02-10 01:10:30 +00:00
popup_add - > popup ( ) ;
2017-03-05 15:44:50 +00:00
add_at = " input/ " + ti - > get_text ( 0 ) ;
2017-06-24 12:35:36 +00:00
edit_idx = - 1 ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
} else if ( p_id = = 2 ) {
2014-02-10 01:10:30 +00:00
//remove
2017-03-05 15:44:50 +00:00
if ( ti - > get_parent ( ) = = input_editor - > get_root ( ) ) {
2014-02-10 01:10:30 +00:00
//remove main thing
2017-03-05 15:44:50 +00:00
String name = " input/ " + ti - > get_text ( 0 ) ;
2017-07-19 20:00:46 +00:00
Variant old_val = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
int order = ProjectSettings : : get_singleton ( ) - > get_order ( name ) ;
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Input Action " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " clear " , name ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , name , old_val ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set_order " , name , order ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
} else {
//remove action
2017-03-05 15:44:50 +00:00
String name = " input/ " + ti - > get_parent ( ) - > get_text ( 0 ) ;
2017-07-19 20:00:46 +00:00
Variant old_val = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
2014-02-10 01:10:30 +00:00
int idx = ti - > get_metadata ( 0 ) ;
Array va = old_val ;
2017-03-05 15:44:50 +00:00
ERR_FAIL_INDEX ( idx , va . size ( ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = idx ; i < va . size ( ) - 1 ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
va [ i ] = va [ i + 1 ] ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
va . resize ( va . size ( ) - 1 ) ;
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Erase Input Action Event " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , name , va ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , name , old_val ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-06-24 12:35:36 +00:00
} else if ( p_id = = 3 ) {
//edit
if ( ti - > get_parent ( ) = = input_editor - > get_root ( ) ) {
ti - > set_as_cursor ( 0 ) ;
input_editor - > edit_selected ( ) ;
} else {
//edit action
String name = " input/ " + ti - > get_parent ( ) - > get_text ( 0 ) ;
int idx = ti - > get_metadata ( 0 ) ;
2017-07-19 20:00:46 +00:00
Array va = ProjectSettings : : get_singleton ( ) - > get ( name ) ;
2017-06-24 12:35:36 +00:00
ERR_FAIL_INDEX ( idx , va . size ( ) ) ;
Ref < InputEvent > ie = va [ idx ] ;
if ( ie . is_null ( ) )
return ;
ti - > set_as_cursor ( 0 ) ;
add_at = name ;
edit_idx = idx ;
_edit_item ( ie ) ;
}
2014-02-10 01:10:30 +00:00
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _update_actions ( ) {
2014-02-10 01:10:30 +00:00
if ( setting )
return ;
input_editor - > clear ( ) ;
TreeItem * root = input_editor - > create_item ( ) ;
input_editor - > set_hide_root ( true ) ;
List < PropertyInfo > props ;
2017-07-19 20:00:46 +00:00
ProjectSettings : : get_singleton ( ) - > get_property_list ( & props ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( List < PropertyInfo > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
const PropertyInfo & pi = E - > get ( ) ;
2014-02-10 01:10:30 +00:00
if ( ! pi . name . begins_with ( " input/ " ) )
continue ;
2017-03-05 15:44:50 +00:00
String name = pi . name . get_slice ( " / " , 1 ) ;
if ( name = = " " )
2014-02-10 01:10:30 +00:00
continue ;
2017-03-05 15:44:50 +00:00
TreeItem * item = input_editor - > create_item ( root ) ;
item - > set_text ( 0 , name ) ;
2017-04-24 19:41:17 +00:00
item - > add_button ( 0 , get_icon ( " Add " , " EditorIcons " ) , 1 , false , TTR ( " Add Event " ) ) ;
2017-07-19 20:00:46 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > get_input_presets ( ) . find ( pi . name ) ) {
2017-04-24 19:41:17 +00:00
item - > add_button ( 0 , get_icon ( " Remove " , " EditorIcons " ) , 2 , false , TTR ( " Remove " ) ) ;
2017-03-05 15:44:50 +00:00
item - > set_editable ( 0 , true ) ;
2015-12-15 07:45:34 +00:00
}
2017-03-05 15:44:50 +00:00
item - > set_custom_bg_color ( 0 , get_color ( " prop_subsection " , " Editor " ) ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Array actions = ProjectSettings : : get_singleton ( ) - > get ( pi . name ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < actions . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-05-20 15:38:03 +00:00
Ref < InputEvent > ie = actions [ i ] ;
if ( ie . is_null ( ) )
2014-02-10 01:10:30 +00:00
continue ;
TreeItem * action = input_editor - > create_item ( item ) ;
2017-05-20 15:38:03 +00:00
Ref < InputEventKey > k = ie ;
if ( k . is_valid ( ) ) {
String str = keycode_get_string ( k - > get_scancode ( ) ) . capitalize ( ) ;
if ( k - > get_metakey ( ) )
2017-10-13 09:12:58 +00:00
str = vformat ( " %s+ " , find_keycode_name ( KEY_META ) ) + str ;
2017-05-20 15:38:03 +00:00
if ( k - > get_shift ( ) )
str = TTR ( " Shift+ " ) + str ;
if ( k - > get_alt ( ) )
str = TTR ( " Alt+ " ) + str ;
if ( k - > get_control ( ) )
str = TTR ( " Control+ " ) + str ;
action - > set_text ( 0 , str ) ;
action - > set_icon ( 0 , get_icon ( " Keyboard " , " EditorIcons " ) ) ;
}
Ref < InputEventJoypadButton > jb = ie ;
if ( jb . is_valid ( ) ) {
String str = TTR ( " Device " ) + " " + itos ( jb - > get_device ( ) ) + " , " + TTR ( " Button " ) + " " + itos ( jb - > get_button_index ( ) ) ;
if ( jb - > get_button_index ( ) > = 0 & & jb - > get_button_index ( ) < JOY_BUTTON_MAX )
str + = String ( ) + " ( " + _button_names [ jb - > get_button_index ( ) ] + " ). " ;
else
str + = " . " ;
action - > set_text ( 0 , str ) ;
action - > set_icon ( 0 , get_icon ( " JoyButton " , " EditorIcons " ) ) ;
}
Ref < InputEventMouseButton > mb = ie ;
if ( mb . is_valid ( ) ) {
String str = TTR ( " Device " ) + " " + itos ( mb - > get_device ( ) ) + " , " ;
switch ( mb - > get_button_index ( ) ) {
case BUTTON_LEFT : str + = TTR ( " Left Button. " ) ; break ;
case BUTTON_RIGHT : str + = TTR ( " Right Button. " ) ; break ;
case BUTTON_MIDDLE : str + = TTR ( " Middle Button. " ) ; break ;
case BUTTON_WHEEL_UP : str + = TTR ( " Wheel Up. " ) ; break ;
case BUTTON_WHEEL_DOWN : str + = TTR ( " Wheel Down. " ) ; break ;
default : str + = TTR ( " Button " ) + " " + itos ( mb - > get_button_index ( ) ) + " . " ;
}
action - > set_text ( 0 , str ) ;
action - > set_icon ( 0 , get_icon ( " Mouse " , " EditorIcons " ) ) ;
}
Ref < InputEventJoypadMotion > jm = ie ;
if ( jm . is_valid ( ) ) {
int ax = jm - > get_axis ( ) ;
int n = 2 * ax + ( jm - > get_axis_value ( ) < 0 ? 0 : 1 ) ;
String desc = _axis_names [ n ] ;
String str = TTR ( " Device " ) + " " + itos ( jm - > get_device ( ) ) + " , " + TTR ( " Axis " ) + " " + itos ( ax ) + " " + ( jm - > get_axis_value ( ) < 0 ? " - " : " + " ) + desc + " . " ;
action - > set_text ( 0 , str ) ;
action - > set_icon ( 0 , get_icon ( " JoyAxis " , " EditorIcons " ) ) ;
2014-02-10 01:10:30 +00:00
}
2017-06-24 12:35:36 +00:00
action - > add_button ( 0 , get_icon ( " Edit " , " EditorIcons " ) , 3 , false , TTR ( " Edit " ) ) ;
2017-04-24 19:41:17 +00:00
action - > add_button ( 0 , get_icon ( " Remove " , " EditorIcons " ) , 2 , false , TTR ( " Remove " ) ) ;
2017-03-05 15:44:50 +00:00
action - > set_metadata ( 0 , i ) ;
2016-08-22 23:14:04 +00:00
action - > set_meta ( " __input " , ie ) ;
2014-02-10 01:10:30 +00:00
}
}
2017-09-01 21:08:50 +00:00
_action_check ( action_name - > get_text ( ) ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : popup_project_settings ( ) {
2014-02-10 01:10:30 +00:00
2017-03-02 21:43:56 +00:00
// Restore valid window bounds or pop up at default size.
2017-10-05 18:34:34 +00:00
if ( EditorSettings : : get_singleton ( ) - > has_setting ( " interface/dialogs/project_settings_bounds " ) ) {
2017-03-02 21:43:56 +00:00
popup ( EditorSettings : : get_singleton ( ) - > get ( " interface/dialogs/project_settings_bounds " ) ) ;
} else {
popup_centered_ratio ( ) ;
}
2016-03-06 14:22:21 +00:00
globals_editor - > update_category_list ( ) ;
2014-02-10 01:10:30 +00:00
_update_translations ( ) ;
2016-07-04 23:22:28 +00:00
autoload_settings - > update_autoload ( ) ;
2016-02-28 02:10:44 +00:00
plugin_settings - > update_plugins ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _item_selected ( ) {
2014-02-10 01:10:30 +00:00
2015-12-16 02:39:36 +00:00
TreeItem * ti = globals_editor - > get_property_editor ( ) - > get_scene_tree ( ) - > get_selected ( ) ;
2014-02-10 01:10:30 +00:00
if ( ! ti )
return ;
if ( ! ti - > get_parent ( ) )
return ;
2016-01-10 20:08:02 +00:00
category - > set_text ( globals_editor - > get_current_section ( ) ) ;
2014-02-10 01:10:30 +00:00
property - > set_text ( ti - > get_text ( 0 ) ) ;
2017-07-19 20:00:46 +00:00
popup_copy_to_feature - > set_disabled ( false ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _item_adds ( String ) {
2014-02-10 01:10:30 +00:00
_item_add ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _item_add ( ) {
2014-02-10 01:10:30 +00:00
Variant value ;
2017-03-05 15:44:50 +00:00
switch ( type - > get_selected ( ) ) {
case 0 : value = false ; break ;
case 1 : value = 0 ; break ;
case 2 : value = 0.0 ; break ;
case 3 : value = " " ; break ;
2014-02-10 01:10:30 +00:00
}
2016-03-06 14:22:21 +00:00
String catname = category - > get_text ( ) . strip_edges ( ) ;
String propname = property - > get_text ( ) . strip_edges ( ) ;
2017-03-05 15:44:50 +00:00
String name = catname ! = " " ? catname + " / " + propname : propname ;
2016-03-06 14:22:21 +00:00
2017-08-23 20:25:14 +00:00
undo_redo - > create_action ( TTR ( " Add Global Property " ) ) ;
2016-07-07 13:10:12 +00:00
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , name , value ) ;
2016-07-07 13:10:12 +00:00
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( name ) ) {
2017-07-19 20:00:46 +00:00
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , name , ProjectSettings : : get_singleton ( ) - > get ( name ) ) ;
2016-07-07 13:10:12 +00:00
} else {
2017-07-19 20:00:46 +00:00
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , name , Variant ( ) ) ;
2016-07-07 13:10:12 +00:00
}
undo_redo - > add_do_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_undo_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
undo_redo - > commit_action ( ) ;
2016-03-06 14:22:21 +00:00
globals_editor - > set_current_section ( catname ) ;
_settings_changed ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _item_del ( ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
String path = globals_editor - > get_property_editor ( ) - > get_selected_path ( ) ;
if ( path = = String ( ) ) {
2017-08-26 10:57:32 +00:00
EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " Select a setting item first! " ) ) ;
2017-07-19 20:00:46 +00:00
return ;
}
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
String property = globals_editor - > get_current_section ( ) . plus_file ( path ) ;
2016-03-06 14:22:21 +00:00
2017-10-05 18:34:34 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( property ) ) {
2017-11-13 11:16:03 +00:00
EditorNode : : get_singleton ( ) - > show_warning ( vformat ( TTR ( " No property '%s' exists. " ) , property ) ) ;
2017-07-19 20:00:46 +00:00
return ;
}
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
if ( ProjectSettings : : get_singleton ( ) - > get_order ( property ) < ProjectSettings : : NO_BUILTIN_ORDER_BASE ) {
2017-11-13 11:16:03 +00:00
EditorNode : : get_singleton ( ) - > show_warning ( vformat ( TTR ( " Setting '%s' is internal, and it can't be deleted. " ) , property ) ) ;
2017-07-19 20:00:46 +00:00
return ;
}
2016-07-07 13:10:12 +00:00
2017-07-19 20:00:46 +00:00
print_line ( " to delete.. " + property ) ;
undo_redo - > create_action ( TTR ( " Delete Item " ) ) ;
Variant value = ProjectSettings : : get_singleton ( ) - > get ( property ) ;
int order = ProjectSettings : : get_singleton ( ) - > get_order ( property ) ;
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " clear " , property ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , property , value ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set_order " , property , order ) ;
2016-07-07 13:10:12 +00:00
undo_redo - > add_do_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_undo_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
undo_redo - > commit_action ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-09-01 21:08:50 +00:00
void ProjectSettingsEditor : : _action_check ( String p_action ) {
2014-02-10 01:10:30 +00:00
2017-09-01 21:08:50 +00:00
if ( p_action = = " " ) {
2014-02-10 01:10:30 +00:00
2017-09-01 21:08:50 +00:00
action_add - > set_disabled ( true ) ;
} else {
2014-02-10 01:10:30 +00:00
2017-09-01 21:08:50 +00:00
if ( p_action . find ( " / " ) ! = - 1 | | p_action . find ( " : " ) ! = - 1 ) {
2017-10-28 02:35:09 +00:00
action_add_error - > set_text ( TTR ( " Can't contain '/' or ':' " ) ) ;
action_add_error - > show ( ) ;
2017-09-01 21:08:50 +00:00
action_add - > set_disabled ( true ) ;
return ;
}
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " input/ " + p_action ) ) {
2017-10-28 02:35:09 +00:00
action_add_error - > set_text ( TTR ( " Already existing " ) ) ;
action_add_error - > show ( ) ;
2017-09-01 21:08:50 +00:00
action_add - > set_disabled ( true ) ;
return ;
}
action_add - > set_disabled ( false ) ;
2014-02-10 01:10:30 +00:00
}
2017-10-28 02:35:09 +00:00
action_add_error - > hide ( ) ;
2017-09-01 21:08:50 +00:00
}
void ProjectSettingsEditor : : _action_adds ( String ) {
if ( ! action_add - > is_disabled ( ) ) {
_action_add ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-09-01 21:08:50 +00:00
}
void ProjectSettingsEditor : : _action_add ( ) {
2014-02-10 01:10:30 +00:00
Array va ;
2017-09-01 21:08:50 +00:00
String name = " input/ " + action_name - > get_text ( ) ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Input Action Event " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , name , va ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " clear " , name ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_actions " ) ;
undo_redo - > add_undo_method ( this , " _update_actions " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
TreeItem * r = input_editor - > get_root ( ) ;
if ( ! r )
return ;
2017-03-05 15:44:50 +00:00
r = r - > get_children ( ) ;
2014-02-10 01:10:30 +00:00
if ( ! r )
return ;
2017-03-05 15:44:50 +00:00
while ( r - > get_next ( ) )
r = r - > get_next ( ) ;
2014-02-10 01:10:30 +00:00
if ( ! r )
return ;
r - > select ( 0 ) ;
input_editor - > ensure_cursor_is_visible ( ) ;
2017-10-28 02:35:09 +00:00
action_add_error - > hide ( ) ;
2017-10-31 16:59:30 +00:00
action_name - > clear ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _item_checked ( const String & p_item , bool p_check ) {
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _save ( ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Error err = ProjectSettings : : get_singleton ( ) - > save ( ) ;
2017-03-05 15:44:50 +00:00
message - > set_text ( err ! = OK ? TTR ( " Error saving settings. " ) : TTR ( " Settings saved OK. " ) ) ;
2017-07-31 18:19:45 +00:00
message - > popup_centered ( Size2 ( 300 , 100 ) * EDSCALE ) ;
2014-02-10 01:10:30 +00:00
}
2017-08-28 16:15:41 +00:00
void ProjectSettingsEditor : : _settings_prop_edited ( const String & p_name ) {
// Method needed to discard the mandatory argument of the property_edited signal
_settings_changed ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _settings_changed ( ) {
2014-02-10 01:10:30 +00:00
timer - > start ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : queue_save ( ) {
2016-02-28 02:10:44 +00:00
_settings_changed ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _copy_to_platform_about_to_show ( ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Set < String > presets ;
presets . insert ( " s3tc " ) ;
presets . insert ( " etc " ) ;
presets . insert ( " etc2 " ) ;
presets . insert ( " pvrtc " ) ;
presets . insert ( " debug " ) ;
presets . insert ( " release " ) ;
2017-10-02 19:38:39 +00:00
presets . insert ( " 32 " ) ;
presets . insert ( " 64 " ) ;
2017-07-19 20:00:46 +00:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_platform_count ( ) ; i + + ) {
List < String > p ;
EditorExport : : get_singleton ( ) - > get_export_platform ( i ) - > get_platform_features ( & p ) ;
for ( List < String > : : Element * E = p . front ( ) ; E ; E = E - > next ( ) ) {
presets . insert ( E - > get ( ) ) ;
}
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
for ( int i = 0 ; i < EditorExport : : get_singleton ( ) - > get_export_preset_count ( ) ; i + + ) {
List < String > p ;
EditorExport : : get_singleton ( ) - > get_export_preset ( i ) - > get_platform ( ) - > get_preset_features ( EditorExport : : get_singleton ( ) - > get_export_preset ( i ) , & p ) ;
for ( List < String > : : Element * E = p . front ( ) ; E ; E = E - > next ( ) ) {
presets . insert ( E - > get ( ) ) ;
}
String custom = EditorExport : : get_singleton ( ) - > get_export_preset ( i ) - > 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 ( ) ) {
presets . insert ( f ) ;
}
}
}
popup_copy_to_feature - > get_popup ( ) - > clear ( ) ;
int id = 0 ;
for ( Set < String > : : Element * E = presets . front ( ) ; E ; E = E - > next ( ) ) {
popup_copy_to_feature - > get_popup ( ) - > add_item ( E - > get ( ) , id + + ) ;
}
}
void ProjectSettingsEditor : : _copy_to_platform ( int p_which ) {
String path = globals_editor - > get_property_editor ( ) - > get_selected_path ( ) ;
if ( path = = String ( ) ) {
2017-09-02 14:19:06 +00:00
EditorNode : : get_singleton ( ) - > show_warning ( TTR ( " Select a setting item first! " ) ) ;
2014-02-10 01:10:30 +00:00
return ;
}
2017-07-19 20:00:46 +00:00
String property = globals_editor - > get_current_section ( ) . plus_file ( path ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
undo_redo - > create_action ( TTR ( " Override for Feature " ) ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Variant value = ProjectSettings : : get_singleton ( ) - > get ( property ) ;
if ( property . find ( " . " ) ! = - 1 ) { //overwriting overwrite, keep overwrite
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " clear " , property ) ;
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , property , value ) ;
}
String feature = popup_copy_to_feature - > get_popup ( ) - > get_item_text ( p_which ) ;
String new_path = property + " . " + feature ;
undo_redo - > add_do_method ( ProjectSettings : : get_singleton ( ) , " set " , new_path , value ) ;
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( new_path ) ) {
2017-07-19 20:00:46 +00:00
undo_redo - > add_undo_method ( ProjectSettings : : get_singleton ( ) , " set " , new_path , ProjectSettings : : get_singleton ( ) - > get ( new_path ) ) ;
}
undo_redo - > add_do_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_undo_method ( globals_editor , " update_category_list " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
undo_redo - > commit_action ( ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : add_translation ( const String & p_translation ) {
2014-02-10 01:10:30 +00:00
_translation_add ( p_translation ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_add ( const String & p_path ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
PoolStringArray translations = ProjectSettings : : get_singleton ( ) - > get ( " locale/translations " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < translations . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
if ( translations [ i ] = = p_path )
2014-02-10 01:10:30 +00:00
return ; //exists
}
translations . push_back ( p_path ) ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Translation " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translations " , translations ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translations " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translations " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_file_open ( ) {
2014-02-10 01:10:30 +00:00
translation_file_open - > popup_centered_ratio ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_delete ( Object * p_item , int p_column , int p_button ) {
2014-02-10 01:10:30 +00:00
2017-08-24 20:58:51 +00:00
TreeItem * ti = Object : : cast_to < TreeItem > ( p_item ) ;
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND ( ! ti ) ;
2017-03-05 15:44:50 +00:00
int idx = ti - > get_metadata ( 0 ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
PoolStringArray translations = ProjectSettings : : get_singleton ( ) - > get ( " locale/translations " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
ERR_FAIL_INDEX ( idx , translations . size ( ) ) ;
2014-02-10 01:10:30 +00:00
translations . remove ( idx ) ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Remove Translation " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translations " , translations ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translations " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translations " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_file_open ( ) {
2014-02-10 01:10:30 +00:00
translation_res_file_open - > popup_centered_ratio ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_add ( const String & p_path ) {
2014-02-10 01:10:30 +00:00
Variant prev ;
Dictionary remaps ;
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) ) {
2017-07-19 20:00:46 +00:00
remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2017-03-05 15:44:50 +00:00
prev = remaps ;
2014-02-10 01:10:30 +00:00
}
if ( remaps . has ( p_path ) )
return ; //pointless already has it
2017-03-05 15:44:50 +00:00
remaps [ p_path ] = PoolStringArray ( ) ;
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Add Remapped Path " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , remaps ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , prev ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_option_file_open ( ) {
2014-02-10 01:10:30 +00:00
translation_res_option_file_open - > popup_centered_ratio ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_option_add ( const String & p_path ) {
2014-02-10 01:10:30 +00:00
2017-10-05 18:34:34 +00:00
ERR_FAIL_COND ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Dictionary remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2014-02-10 01:10:30 +00:00
TreeItem * k = translation_remap - > get_selected ( ) ;
ERR_FAIL_COND ( ! k ) ;
String key = k - > get_metadata ( 0 ) ;
ERR_FAIL_COND ( ! remaps . has ( key ) ) ;
2017-01-11 03:52:51 +00:00
PoolStringArray r = remaps [ key ] ;
2017-03-05 15:44:50 +00:00
r . push_back ( p_path + " : " + " en " ) ;
remaps [ key ] = r ;
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Resource Remap Add Remap " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , remaps ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_select ( ) {
2014-02-10 01:10:30 +00:00
if ( updating_translations )
return ;
call_deferred ( " _update_translations " ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_option_changed ( ) {
2014-02-10 01:10:30 +00:00
if ( updating_translations )
return ;
2017-10-05 18:34:34 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) )
2014-02-10 01:10:30 +00:00
return ;
2017-07-19 20:00:46 +00:00
Dictionary remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2014-02-10 01:10:30 +00:00
TreeItem * k = translation_remap - > get_selected ( ) ;
ERR_FAIL_COND ( ! k ) ;
TreeItem * ed = translation_remap_options - > get_edited ( ) ;
ERR_FAIL_COND ( ! ed ) ;
String key = k - > get_metadata ( 0 ) ;
int idx = ed - > get_metadata ( 0 ) ;
String path = ed - > get_metadata ( 1 ) ;
int which = ed - > get_range ( 1 ) ;
Vector < String > langs = TranslationServer : : get_all_locales ( ) ;
2017-03-05 15:44:50 +00:00
ERR_FAIL_INDEX ( which , langs . size ( ) ) ;
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND ( ! remaps . has ( key ) ) ;
2017-01-11 03:52:51 +00:00
PoolStringArray r = remaps [ key ] ;
2017-03-05 15:44:50 +00:00
ERR_FAIL_INDEX ( idx , r . size ( ) ) ;
2017-10-17 15:27:54 +00:00
if ( translation_locales_idxs_remap . size ( ) > 0 ) {
r . set ( idx , path + " : " + langs [ translation_locales_idxs_remap [ which ] ] ) ;
} else {
r . set ( idx , path + " : " + langs [ which ] ) ;
}
2017-03-05 15:44:50 +00:00
remaps [ key ] = r ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
updating_translations = true ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Change Resource Remap Language " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , remaps ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
2017-03-05 15:44:50 +00:00
updating_translations = false ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_delete ( Object * p_item , int p_column , int p_button ) {
2014-02-10 01:10:30 +00:00
if ( updating_translations )
return ;
2017-10-05 18:34:34 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) )
2014-02-10 01:10:30 +00:00
return ;
2017-07-19 20:00:46 +00:00
Dictionary remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2014-02-10 01:10:30 +00:00
2017-08-24 20:58:51 +00:00
TreeItem * k = Object : : cast_to < TreeItem > ( p_item ) ;
2014-02-10 01:10:30 +00:00
String key = k - > get_metadata ( 0 ) ;
ERR_FAIL_COND ( ! remaps . has ( key ) ) ;
remaps . erase ( key ) ;
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Remove Resource Remap " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , remaps ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _translation_res_option_delete ( Object * p_item , int p_column , int p_button ) {
2014-02-10 01:10:30 +00:00
if ( updating_translations )
return ;
2017-10-05 18:34:34 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) )
2014-02-10 01:10:30 +00:00
return ;
2017-07-19 20:00:46 +00:00
Dictionary remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2014-02-10 01:10:30 +00:00
TreeItem * k = translation_remap - > get_selected ( ) ;
ERR_FAIL_COND ( ! k ) ;
2017-08-24 20:58:51 +00:00
TreeItem * ed = Object : : cast_to < TreeItem > ( p_item ) ;
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND ( ! ed ) ;
String key = k - > get_metadata ( 0 ) ;
int idx = ed - > get_metadata ( 0 ) ;
ERR_FAIL_COND ( ! remaps . has ( key ) ) ;
2017-01-11 03:52:51 +00:00
PoolStringArray r = remaps [ key ] ;
2017-10-15 01:43:02 +00:00
ERR_FAIL_INDEX ( idx , r . size ( ) ) ;
2014-02-10 01:10:30 +00:00
r . remove ( idx ) ;
2017-03-05 15:44:50 +00:00
remaps [ key ] = r ;
2014-02-10 01:10:30 +00:00
2016-05-04 01:25:37 +00:00
undo_redo - > create_action ( TTR ( " Remove Resource Remap Option " ) ) ;
2017-07-19 20:00:46 +00:00
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , remaps ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/translation_remaps " , ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ) ;
2017-03-05 15:44:50 +00:00
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
undo_redo - > commit_action ( ) ;
}
2017-10-17 15:27:54 +00:00
void ProjectSettingsEditor : : _translation_filter_option_changed ( ) {
int sel_id = translation_locale_filter_mode - > get_selected_id ( ) ;
TreeItem * t = translation_filter - > get_selected ( ) ;
String locale = t - > get_tooltip ( 0 ) ;
bool checked = t - > is_checked ( 0 ) ;
Variant prev ;
Array f_locales_all ;
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/locale_filter " ) ) {
f_locales_all = ProjectSettings : : get_singleton ( ) - > get ( " locale/locale_filter " ) ;
prev = f_locales_all ;
if ( f_locales_all . size ( ) ! = 2 ) {
f_locales_all . clear ( ) ;
f_locales_all . append ( sel_id ) ;
f_locales_all . append ( Array ( ) ) ;
}
} else {
f_locales_all . append ( sel_id ) ;
f_locales_all . append ( Array ( ) ) ;
}
Array f_locales = f_locales_all [ 1 ] ;
int l_idx = f_locales . find ( locale ) ;
if ( checked ) {
if ( l_idx = = - 1 ) {
f_locales . append ( locale ) ;
}
} else {
if ( l_idx ! = - 1 ) {
f_locales . remove ( l_idx ) ;
}
}
f_locales = f_locales . sort ( ) ;
undo_redo - > create_action ( TTR ( " Changed Locale Filter " ) ) ;
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/locale_filter " , f_locales_all ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/locale_filter " , prev ) ;
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
undo_redo - > commit_action ( ) ;
}
void ProjectSettingsEditor : : _translation_filter_mode_changed ( int p_mode ) {
int sel_id = translation_locale_filter_mode - > get_selected_id ( ) ;
Variant prev ;
Array f_locales_all ;
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/locale_filter " ) ) {
f_locales_all = ProjectSettings : : get_singleton ( ) - > get ( " locale/locale_filter " ) ;
prev = f_locales_all ;
if ( f_locales_all . size ( ) ! = 2 ) {
f_locales_all . clear ( ) ;
f_locales_all . append ( sel_id ) ;
f_locales_all . append ( Array ( ) ) ;
} else {
f_locales_all [ 0 ] = sel_id ;
}
} else {
f_locales_all . append ( sel_id ) ;
f_locales_all . append ( Array ( ) ) ;
}
undo_redo - > create_action ( TTR ( " Changed Locale Filter Mode " ) ) ;
undo_redo - > add_do_property ( ProjectSettings : : get_singleton ( ) , " locale/locale_filter " , f_locales_all ) ;
undo_redo - > add_undo_property ( ProjectSettings : : get_singleton ( ) , " locale/locale_filter " , prev ) ;
undo_redo - > add_do_method ( this , " _update_translations " ) ;
undo_redo - > add_undo_method ( this , " _update_translations " ) ;
undo_redo - > add_do_method ( this , " _settings_changed " ) ;
undo_redo - > add_undo_method ( this , " _settings_changed " ) ;
undo_redo - > commit_action ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _update_translations ( ) {
2014-02-10 01:10:30 +00:00
//update translations
if ( updating_translations )
return ;
2017-03-05 15:44:50 +00:00
updating_translations = true ;
2014-02-10 01:10:30 +00:00
translation_list - > clear ( ) ;
TreeItem * root = translation_list - > create_item ( NULL ) ;
translation_list - > set_hide_root ( true ) ;
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translations " ) ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
PoolStringArray translations = ProjectSettings : : get_singleton ( ) - > get ( " locale/translations " ) ;
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < translations . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
TreeItem * t = translation_list - > create_item ( root ) ;
2017-03-05 15:44:50 +00:00
t - > set_editable ( 0 , false ) ;
t - > set_text ( 0 , translations [ i ] . replace_first ( " res:// " , " " ) ) ;
t - > set_tooltip ( 0 , translations [ i ] ) ;
t - > set_metadata ( 0 , i ) ;
2017-11-10 20:42:20 +00:00
t - > add_button ( 0 , get_icon ( " Remove " , " EditorIcons " ) , 0 , false , TTR ( " Remove " ) ) ;
2014-02-10 01:10:30 +00:00
}
}
2017-10-17 15:27:54 +00:00
Vector < String > langs = TranslationServer : : get_all_locales ( ) ;
Vector < String > names = TranslationServer : : get_all_locale_names ( ) ;
//update filter tab
Array l_filter_all ;
bool is_arr_empty = true ;
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/locale_filter " ) ) {
l_filter_all = ProjectSettings : : get_singleton ( ) - > get ( " locale/locale_filter " ) ;
if ( l_filter_all . size ( ) = = 2 ) {
translation_locale_filter_mode - > select ( l_filter_all [ 0 ] ) ;
is_arr_empty = false ;
}
}
if ( is_arr_empty ) {
l_filter_all . append ( 0 ) ;
l_filter_all . append ( Array ( ) ) ;
translation_locale_filter_mode - > select ( 0 ) ;
}
int filter_mode = l_filter_all [ 0 ] ;
Array l_filter = l_filter_all [ 1 ] ;
int s = names . size ( ) ;
if ( ! translation_locales_list_created ) {
translation_locales_list_created = true ;
translation_filter - > clear ( ) ;
root = translation_filter - > create_item ( NULL ) ;
translation_filter - > set_hide_root ( true ) ;
translation_filter_treeitems . resize ( s ) ;
for ( int i = 0 ; i < s ; i + + ) {
String n = names [ i ] ;
String l = langs [ i ] ;
TreeItem * t = translation_filter - > create_item ( root ) ;
t - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
t - > set_text ( 0 , n ) ;
t - > set_editable ( 0 , true ) ;
t - > set_tooltip ( 0 , l ) ;
t - > set_checked ( 0 , l_filter . has ( l ) ) ;
translation_filter_treeitems [ i ] = t ;
}
} else {
for ( int i = 0 ; i < s ; i + + ) {
TreeItem * t = translation_filter_treeitems [ i ] ;
t - > set_checked ( 0 , l_filter . has ( t - > get_tooltip ( 0 ) ) ) ;
}
}
2014-02-10 01:10:30 +00:00
//update translation remaps
String remap_selected ;
if ( translation_remap - > get_selected ( ) ) {
remap_selected = translation_remap - > get_selected ( ) - > get_metadata ( 0 ) ;
}
translation_remap - > clear ( ) ;
translation_remap_options - > clear ( ) ;
root = translation_remap - > create_item ( NULL ) ;
TreeItem * root2 = translation_remap_options - > create_item ( NULL ) ;
translation_remap - > set_hide_root ( true ) ;
translation_remap_options - > set_hide_root ( true ) ;
translation_res_option_add_button - > set_disabled ( true ) ;
2017-10-17 15:27:54 +00:00
translation_locales_idxs_remap . clear ( ) ;
translation_locales_idxs_remap . resize ( l_filter . size ( ) ) ;
int fl_idx_count = translation_locales_idxs_remap . size ( ) ;
String langnames = " " ;
int l_idx = 0 ;
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < names . size ( ) ; i + + ) {
2017-10-17 15:27:54 +00:00
if ( filter_mode = = SHOW_ONLY_SELECTED_LOCALES & & fl_idx_count ! = 0 ) {
if ( l_filter . size ( ) > 0 ) {
if ( l_filter . find ( langs [ i ] ) ! = - 1 ) {
if ( langnames . length ( ) > 0 )
langnames + = " , " ;
langnames + = names [ i ] ;
translation_locales_idxs_remap [ l_idx ] = i ;
l_idx + + ;
}
}
} else {
if ( i > 0 )
langnames + = " , " ;
langnames + = names [ i ] ;
}
2014-02-10 01:10:30 +00:00
}
2017-10-05 18:34:34 +00:00
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( " locale/translation_remaps " ) ) {
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
Dictionary remaps = ProjectSettings : : get_singleton ( ) - > get ( " locale/translation_remaps " ) ;
2014-02-10 01:10:30 +00:00
List < Variant > rk ;
remaps . get_key_list ( & rk ) ;
Vector < String > keys ;
2017-03-05 15:44:50 +00:00
for ( List < Variant > : : Element * E = rk . front ( ) ; E ; E = E - > next ( ) ) {
2014-02-10 01:10:30 +00:00
keys . push_back ( E - > get ( ) ) ;
}
keys . sort ( ) ;
2017-03-05 15:44:50 +00:00
for ( int i = 0 ; i < keys . size ( ) ; i + + ) {
2014-02-10 01:10:30 +00:00
TreeItem * t = translation_remap - > create_item ( root ) ;
2017-03-05 15:44:50 +00:00
t - > set_editable ( 0 , false ) ;
t - > set_text ( 0 , keys [ i ] . replace_first ( " res:// " , " " ) ) ;
t - > set_tooltip ( 0 , keys [ i ] ) ;
t - > set_metadata ( 0 , keys [ i ] ) ;
2017-11-10 20:42:20 +00:00
t - > add_button ( 0 , get_icon ( " Remove " , " EditorIcons " ) , 0 , false , TTR ( " Remove " ) ) ;
2017-03-05 15:44:50 +00:00
if ( keys [ i ] = = remap_selected ) {
2014-02-10 01:10:30 +00:00
t - > select ( 0 ) ;
translation_res_option_add_button - > set_disabled ( false ) ;
2017-01-11 03:52:51 +00:00
PoolStringArray selected = remaps [ keys [ i ] ] ;
2017-03-05 15:44:50 +00:00
for ( int j = 0 ; j < selected . size ( ) ; j + + ) {
2014-02-10 01:10:30 +00:00
String s = selected [ j ] ;
int qp = s . find_last ( " : " ) ;
2017-03-05 15:44:50 +00:00
String path = s . substr ( 0 , qp ) ;
String locale = s . substr ( qp + 1 , s . length ( ) ) ;
2014-02-10 01:10:30 +00:00
TreeItem * t2 = translation_remap_options - > create_item ( root2 ) ;
2017-03-05 15:44:50 +00:00
t2 - > set_editable ( 0 , false ) ;
t2 - > set_text ( 0 , path . replace_first ( " res:// " , " " ) ) ;
t2 - > set_tooltip ( 0 , path ) ;
t2 - > set_metadata ( 0 , j ) ;
2017-11-10 20:42:20 +00:00
t2 - > add_button ( 0 , get_icon ( " Remove " , " EditorIcons " ) , 0 , false , TTR ( " Remove " ) ) ;
2017-03-05 15:44:50 +00:00
t2 - > set_cell_mode ( 1 , TreeItem : : CELL_MODE_RANGE ) ;
t2 - > set_text ( 1 , langnames ) ;
t2 - > set_editable ( 1 , true ) ;
t2 - > set_metadata ( 1 , path ) ;
2014-02-10 01:10:30 +00:00
int idx = langs . find ( locale ) ;
2017-10-17 15:27:54 +00:00
//print_line("find " + locale + " at " + itos(idx));
2017-03-05 15:44:50 +00:00
if ( idx < 0 )
idx = 0 ;
2014-02-10 01:10:30 +00:00
2017-10-17 15:27:54 +00:00
int f_idx = translation_locales_idxs_remap . find ( idx ) ;
if ( f_idx ! = - 1 & & fl_idx_count > 0 & & filter_mode = = SHOW_ONLY_SELECTED_LOCALES ) {
t2 - > set_range ( 1 , f_idx ) ;
} else {
t2 - > set_range ( 1 , idx ) ;
}
2014-02-10 01:10:30 +00:00
}
}
}
}
2017-03-05 15:44:50 +00:00
updating_translations = false ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _toggle_search_bar ( bool p_pressed ) {
2016-01-23 19:05:27 +00:00
globals_editor - > get_property_editor ( ) - > set_use_filter ( p_pressed ) ;
if ( p_pressed ) {
search_bar - > show ( ) ;
add_prop_bar - > hide ( ) ;
search_box - > grab_focus ( ) ;
search_box - > select_all ( ) ;
} else {
search_bar - > hide ( ) ;
add_prop_bar - > show ( ) ;
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _clear_search_box ( ) {
2016-01-23 19:05:27 +00:00
2017-03-05 15:44:50 +00:00
if ( search_box - > get_text ( ) = = " " )
2016-01-23 19:05:27 +00:00
return ;
search_box - > clear ( ) ;
globals_editor - > get_property_editor ( ) - > update_tree ( ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : set_plugins_page ( ) {
2016-03-12 13:44:12 +00:00
2017-03-05 15:44:50 +00:00
tab_container - > set_current_tab ( plugin_settings - > get_index ( ) ) ;
2016-03-12 13:44:12 +00:00
}
2017-09-03 13:29:56 +00:00
TabContainer * ProjectSettingsEditor : : get_tabs ( ) {
return tab_container ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettingsEditor : : _bind_methods ( ) {
ClassDB : : bind_method ( D_METHOD ( " _item_selected " ) , & ProjectSettingsEditor : : _item_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " _item_add " ) , & ProjectSettingsEditor : : _item_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _item_adds " ) , & ProjectSettingsEditor : : _item_adds ) ;
ClassDB : : bind_method ( D_METHOD ( " _item_del " ) , & ProjectSettingsEditor : : _item_del ) ;
ClassDB : : bind_method ( D_METHOD ( " _item_checked " ) , & ProjectSettingsEditor : : _item_checked ) ;
ClassDB : : bind_method ( D_METHOD ( " _save " ) , & ProjectSettingsEditor : : _save ) ;
ClassDB : : bind_method ( D_METHOD ( " _action_add " ) , & ProjectSettingsEditor : : _action_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _action_adds " ) , & ProjectSettingsEditor : : _action_adds ) ;
2017-09-01 21:08:50 +00:00
ClassDB : : bind_method ( D_METHOD ( " _action_check " ) , & ProjectSettingsEditor : : _action_check ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " _action_selected " ) , & ProjectSettingsEditor : : _action_selected ) ;
ClassDB : : bind_method ( D_METHOD ( " _action_edited " ) , & ProjectSettingsEditor : : _action_edited ) ;
ClassDB : : bind_method ( D_METHOD ( " _action_activated " ) , & ProjectSettingsEditor : : _action_activated ) ;
ClassDB : : bind_method ( D_METHOD ( " _action_button_pressed " ) , & ProjectSettingsEditor : : _action_button_pressed ) ;
ClassDB : : bind_method ( D_METHOD ( " _update_actions " ) , & ProjectSettingsEditor : : _update_actions ) ;
ClassDB : : bind_method ( D_METHOD ( " _wait_for_key " ) , & ProjectSettingsEditor : : _wait_for_key ) ;
ClassDB : : bind_method ( D_METHOD ( " _add_item " ) , & ProjectSettingsEditor : : _add_item , DEFVAL ( Variant ( ) ) ) ;
ClassDB : : bind_method ( D_METHOD ( " _device_input_add " ) , & ProjectSettingsEditor : : _device_input_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _press_a_key_confirm " ) , & ProjectSettingsEditor : : _press_a_key_confirm ) ;
2017-08-28 16:15:41 +00:00
ClassDB : : bind_method ( D_METHOD ( " _settings_prop_edited " ) , & ProjectSettingsEditor : : _settings_prop_edited ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " _copy_to_platform " ) , & ProjectSettingsEditor : : _copy_to_platform ) ;
ClassDB : : bind_method ( D_METHOD ( " _update_translations " ) , & ProjectSettingsEditor : : _update_translations ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_delete " ) , & ProjectSettingsEditor : : _translation_delete ) ;
ClassDB : : bind_method ( D_METHOD ( " _settings_changed " ) , & ProjectSettingsEditor : : _settings_changed ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_add " ) , & ProjectSettingsEditor : : _translation_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_file_open " ) , & ProjectSettingsEditor : : _translation_file_open ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_add " ) , & ProjectSettingsEditor : : _translation_res_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_file_open " ) , & ProjectSettingsEditor : : _translation_res_file_open ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_option_add " ) , & ProjectSettingsEditor : : _translation_res_option_add ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_option_file_open " ) , & ProjectSettingsEditor : : _translation_res_option_file_open ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_select " ) , & ProjectSettingsEditor : : _translation_res_select ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_option_changed " ) , & ProjectSettingsEditor : : _translation_res_option_changed ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_delete " ) , & ProjectSettingsEditor : : _translation_res_delete ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_res_option_delete " ) , & ProjectSettingsEditor : : _translation_res_option_delete ) ;
2017-10-17 15:27:54 +00:00
ClassDB : : bind_method ( D_METHOD ( " _translation_filter_option_changed " ) , & ProjectSettingsEditor : : _translation_filter_option_changed ) ;
ClassDB : : bind_method ( D_METHOD ( " _translation_filter_mode_changed " ) , & ProjectSettingsEditor : : _translation_filter_mode_changed ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " _clear_search_box " ) , & ProjectSettingsEditor : : _clear_search_box ) ;
ClassDB : : bind_method ( D_METHOD ( " _toggle_search_bar " ) , & ProjectSettingsEditor : : _toggle_search_bar ) ;
ClassDB : : bind_method ( D_METHOD ( " _copy_to_platform_about_to_show " ) , & ProjectSettingsEditor : : _copy_to_platform_about_to_show ) ;
2017-09-03 13:29:56 +00:00
ClassDB : : bind_method ( D_METHOD ( " get_tabs " ) , & ProjectSettingsEditor : : get_tabs ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
ProjectSettingsEditor : : ProjectSettingsEditor ( EditorData * p_data ) {
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
singleton = this ;
2017-05-01 15:44:52 +00:00
set_title ( TTR ( " Project Settings (project.godot) " ) ) ;
2017-03-02 21:43:56 +00:00
set_resizable ( true ) ;
2017-03-05 15:44:50 +00:00
undo_redo = & p_data - > get_undo_redo ( ) ;
data = p_data ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
tab_container = memnew ( TabContainer ) ;
2017-05-02 20:13:12 +00:00
tab_container - > set_tab_align ( TabContainer : : ALIGN_LEFT ) ;
2014-02-10 01:10:30 +00:00
add_child ( tab_container ) ;
2017-03-05 15:44:50 +00:00
VBoxContainer * props_base = memnew ( VBoxContainer ) ;
2015-11-21 16:42:15 +00:00
props_base - > set_alignment ( BoxContainer : : ALIGN_BEGIN ) ;
props_base - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2014-02-10 01:10:30 +00:00
tab_container - > add_child ( props_base ) ;
2016-05-04 01:25:37 +00:00
props_base - > set_name ( TTR ( " General " ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
HBoxContainer * hbc = memnew ( HBoxContainer ) ;
2015-11-21 16:42:15 +00:00
hbc - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
props_base - > add_child ( hbc ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
search_button = memnew ( ToolButton ) ;
2016-01-23 19:05:27 +00:00
search_button - > set_toggle_mode ( true ) ;
search_button - > set_pressed ( false ) ;
2016-05-04 01:25:37 +00:00
search_button - > set_text ( TTR ( " Search " ) ) ;
2016-01-23 19:05:27 +00:00
hbc - > add_child ( search_button ) ;
2017-03-05 15:44:50 +00:00
search_button - > connect ( " toggled " , this , " _toggle_search_bar " ) ;
2016-01-23 19:05:27 +00:00
2017-03-05 15:44:50 +00:00
hbc - > add_child ( memnew ( VSeparator ) ) ;
2016-01-23 19:05:27 +00:00
2017-03-05 15:44:50 +00:00
add_prop_bar = memnew ( HBoxContainer ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbc - > add_child ( add_prop_bar ) ;
2017-03-05 15:44:50 +00:00
Label * l = memnew ( Label ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( l ) ;
2016-05-04 01:25:37 +00:00
l - > set_text ( TTR ( " Category: " ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
category = memnew ( LineEdit ) ;
2015-11-21 16:42:15 +00:00
category - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( category ) ;
2017-03-05 15:44:50 +00:00
category - > connect ( " text_entered " , this , " _item_adds " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( l ) ;
2016-05-04 01:25:37 +00:00
l - > set_text ( TTR ( " Property: " ) ) ;
2015-11-21 16:42:15 +00:00
2017-03-05 15:44:50 +00:00
property = memnew ( LineEdit ) ;
2015-11-21 16:42:15 +00:00
property - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( property ) ;
2017-03-05 15:44:50 +00:00
property - > connect ( " text_entered " , this , " _item_adds " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( l ) ;
2016-05-04 01:25:37 +00:00
l - > set_text ( TTR ( " Type: " ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
type = memnew ( OptionButton ) ;
2015-11-21 16:42:15 +00:00
type - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( type ) ;
2014-02-10 01:10:30 +00:00
type - > add_item ( " bool " ) ;
type - > add_item ( " int " ) ;
type - > add_item ( " float " ) ;
type - > add_item ( " string " ) ;
2017-03-05 15:44:50 +00:00
Button * add = memnew ( Button ) ;
2016-01-23 19:05:27 +00:00
add_prop_bar - > add_child ( add ) ;
2016-05-04 01:25:37 +00:00
add - > set_text ( TTR ( " Add " ) ) ;
2017-03-05 15:44:50 +00:00
add - > connect ( " pressed " , this , " _item_add " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
search_bar = memnew ( HBoxContainer ) ;
2016-01-23 19:05:27 +00:00
search_bar - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
hbc - > add_child ( search_bar ) ;
search_bar - > hide ( ) ;
2017-03-05 15:44:50 +00:00
search_box = memnew ( LineEdit ) ;
2016-01-23 19:05:27 +00:00
search_box - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
search_bar - > add_child ( search_box ) ;
2017-03-05 15:44:50 +00:00
clear_button = memnew ( ToolButton ) ;
2016-01-23 19:05:27 +00:00
search_bar - > add_child ( clear_button ) ;
2017-03-05 15:44:50 +00:00
clear_button - > connect ( " pressed " , this , " _clear_search_box " ) ;
2016-01-23 19:05:27 +00:00
2017-03-05 15:44:50 +00:00
globals_editor = memnew ( SectionedPropertyEditor ) ;
2015-11-21 16:42:15 +00:00
props_base - > add_child ( globals_editor ) ;
2017-01-05 12:16:00 +00:00
globals_editor - > get_property_editor ( ) - > set_undo_redo ( EditorNode : : get_singleton ( ) - > get_undo_redo ( ) ) ;
2017-07-19 20:00:46 +00:00
globals_editor - > get_property_editor ( ) - > set_property_selectable ( true ) ;
2015-12-16 02:39:36 +00:00
//globals_editor->hide_top_label();
2015-11-21 16:42:15 +00:00
globals_editor - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2017-07-18 00:05:38 +00:00
globals_editor - > register_search_box ( search_box ) ;
2017-03-05 15:44:50 +00:00
globals_editor - > get_property_editor ( ) - > get_scene_tree ( ) - > connect ( " cell_selected " , this , " _item_selected " ) ;
globals_editor - > get_property_editor ( ) - > connect ( " property_toggled " , this , " _item_checked " , varray ( ) , CONNECT_DEFERRED ) ;
2017-08-28 16:15:41 +00:00
globals_editor - > get_property_editor ( ) - > connect ( " property_edited " , this , " _settings_prop_edited " ) ;
2015-11-21 16:42:15 +00:00
2017-07-19 20:00:46 +00:00
Button * del = memnew ( Button ) ;
hbc - > add_child ( del ) ;
del - > set_text ( TTR ( " Delete " ) ) ;
del - > connect ( " pressed " , this , " _item_del " ) ;
2015-11-21 16:42:15 +00:00
2017-07-19 20:00:46 +00:00
add_prop_bar - > add_child ( memnew ( VSeparator ) ) ;
2015-11-21 16:42:15 +00:00
2017-07-19 20:00:46 +00:00
popup_copy_to_feature = memnew ( MenuButton ) ;
popup_copy_to_feature - > set_text ( TTR ( " Override For.. " ) ) ;
popup_copy_to_feature - > set_disabled ( true ) ;
add_prop_bar - > add_child ( popup_copy_to_feature ) ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
popup_copy_to_feature - > get_popup ( ) - > connect ( " id_pressed " , this , " _copy_to_platform " ) ;
popup_copy_to_feature - > get_popup ( ) - > connect ( " about_to_show " , this , " _copy_to_platform_about_to_show " ) ;
2016-05-04 01:25:37 +00:00
get_ok ( ) - > set_text ( TTR ( " Close " ) ) ;
2014-02-10 01:10:30 +00:00
set_hide_on_ok ( true ) ;
2017-09-01 21:08:50 +00:00
message = memnew ( AcceptDialog ) ;
2014-02-10 01:10:30 +00:00
add_child ( message ) ;
2017-03-05 15:44:50 +00:00
Control * input_base = memnew ( Control ) ;
2016-05-04 01:25:37 +00:00
input_base - > set_name ( TTR ( " Input Map " ) ) ;
2014-02-10 01:10:30 +00:00
tab_container - > add_child ( input_base ) ;
2017-03-05 15:44:50 +00:00
VBoxContainer * vbc = memnew ( VBoxContainer ) ;
2016-07-27 15:29:51 +00:00
input_base - > add_child ( vbc ) ;
2017-08-08 02:55:24 +00:00
vbc - > set_anchor_and_margin ( MARGIN_TOP , ANCHOR_BEGIN , 0 ) ;
vbc - > set_anchor_and_margin ( MARGIN_BOTTOM , ANCHOR_END , 0 ) ;
vbc - > set_anchor_and_margin ( MARGIN_LEFT , ANCHOR_BEGIN , 0 ) ;
vbc - > set_anchor_and_margin ( MARGIN_RIGHT , ANCHOR_END , 0 ) ;
2016-07-27 15:29:51 +00:00
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-07-27 15:29:51 +00:00
vbc - > add_child ( l ) ;
2016-05-04 01:25:37 +00:00
l - > set_text ( TTR ( " Action: " ) ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
hbc = memnew ( HBoxContainer ) ;
2016-07-27 15:29:51 +00:00
vbc - > add_child ( hbc ) ;
2017-03-05 15:44:50 +00:00
action_name = memnew ( LineEdit ) ;
2016-07-27 15:29:51 +00:00
action_name - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
hbc - > add_child ( action_name ) ;
2017-03-05 15:44:50 +00:00
action_name - > connect ( " text_entered " , this , " _action_adds " ) ;
2017-09-01 21:08:50 +00:00
action_name - > connect ( " text_changed " , this , " _action_check " ) ;
2014-02-10 01:10:30 +00:00
2017-10-28 02:35:09 +00:00
action_add_error = memnew ( Label ) ;
hbc - > add_child ( action_add_error ) ;
action_add_error - > hide ( ) ;
2017-03-05 15:44:50 +00:00
add = memnew ( Button ) ;
2016-07-27 15:29:51 +00:00
hbc - > add_child ( add ) ;
2017-07-31 18:19:45 +00:00
add - > set_custom_minimum_size ( Size2 ( 150 , 0 ) * EDSCALE ) ;
2016-05-04 01:25:37 +00:00
add - > set_text ( TTR ( " Add " ) ) ;
2017-09-01 21:08:50 +00:00
add - > set_disabled ( true ) ;
2017-03-05 15:44:50 +00:00
add - > connect ( " pressed " , this , " _action_add " ) ;
2017-09-01 21:08:50 +00:00
action_add = add ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
input_editor = memnew ( Tree ) ;
2016-07-27 15:29:51 +00:00
vbc - > add_child ( input_editor ) ;
input_editor - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 15:44:50 +00:00
input_editor - > connect ( " item_edited " , this , " _action_edited " ) ;
2017-06-24 12:35:36 +00:00
input_editor - > connect ( " item_activated " , this , " _action_activated " ) ;
2017-03-05 15:44:50 +00:00
input_editor - > connect ( " cell_selected " , this , " _action_selected " ) ;
input_editor - > connect ( " button_pressed " , this , " _action_button_pressed " ) ;
popup_add = memnew ( PopupMenu ) ;
2014-02-10 01:10:30 +00:00
add_child ( popup_add ) ;
2017-03-05 15:44:50 +00:00
popup_add - > connect ( " id_pressed " , this , " _add_item " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
press_a_key = memnew ( ConfirmationDialog ) ;
2014-02-10 01:10:30 +00:00
press_a_key - > set_focus_mode ( FOCUS_ALL ) ;
add_child ( press_a_key ) ;
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-05-04 01:25:37 +00:00
l - > set_text ( TTR ( " Press a Key.. " ) ) ;
2017-09-21 22:12:33 +00:00
l - > set_anchors_and_margins_preset ( Control : : PRESET_WIDE ) ;
2014-02-10 01:10:30 +00:00
l - > set_align ( Label : : ALIGN_CENTER ) ;
2017-03-05 15:44:50 +00:00
l - > set_margin ( MARGIN_TOP , 20 ) ;
l - > set_anchor_and_margin ( MARGIN_BOTTOM , ANCHOR_BEGIN , 30 ) ;
press_a_key_label = l ;
2014-02-10 01:10:30 +00:00
press_a_key - > add_child ( l ) ;
2017-03-05 15:44:50 +00:00
press_a_key - > connect ( " gui_input " , this , " _wait_for_key " ) ;
press_a_key - > connect ( " confirmed " , this , " _press_a_key_confirm " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
device_input = memnew ( ConfirmationDialog ) ;
2014-02-10 01:10:30 +00:00
add_child ( device_input ) ;
2016-05-04 01:25:37 +00:00
device_input - > get_ok ( ) - > set_text ( TTR ( " Add " ) ) ;
2017-03-05 15:44:50 +00:00
device_input - > connect ( " confirmed " , this , " _device_input_add " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
hbc = memnew ( HBoxContainer ) ;
2016-08-04 14:51:58 +00:00
device_input - > add_child ( hbc ) ;
2017-03-05 15:44:50 +00:00
VBoxContainer * vbc_left = memnew ( VBoxContainer ) ;
2016-08-04 14:51:58 +00:00
hbc - > add_child ( vbc_left ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-08-04 14:51:58 +00:00
l - > set_text ( TTR ( " Device: " ) ) ;
vbc_left - > add_child ( l ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
device_id = memnew ( SpinBox ) ;
2017-01-04 04:16:14 +00:00
device_id - > set_value ( 0 ) ;
2016-08-04 14:51:58 +00:00
vbc_left - > add_child ( device_id ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
VBoxContainer * vbc_right = memnew ( VBoxContainer ) ;
2016-08-04 14:51:58 +00:00
hbc - > add_child ( vbc_right ) ;
vbc_right - > set_h_size_flags ( SIZE_EXPAND_FILL ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
l = memnew ( Label ) ;
2016-08-04 14:51:58 +00:00
l - > set_text ( TTR ( " Index: " ) ) ;
vbc_right - > add_child ( l ) ;
2017-03-05 15:44:50 +00:00
device_index_label = l ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
device_index = memnew ( OptionButton ) ;
2016-08-04 14:51:58 +00:00
vbc_right - > add_child ( device_index ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
setting = false ;
2014-02-10 01:10:30 +00:00
//translations
2017-03-05 15:44:50 +00:00
TabContainer * translations = memnew ( TabContainer ) ;
2017-05-02 20:13:12 +00:00
translations - > set_tab_align ( TabContainer : : ALIGN_LEFT ) ;
2016-05-04 01:25:37 +00:00
translations - > set_name ( TTR ( " Localization " ) ) ;
2014-02-10 01:10:30 +00:00
tab_container - > add_child ( translations ) ;
2017-10-17 15:27:54 +00:00
//remap for properly select language in popup
translation_locales_idxs_remap = Vector < int > ( ) ;
2017-11-11 02:09:46 +00:00
translation_locales_list_created = false ;
2014-02-10 01:10:30 +00:00
{
2017-03-05 15:44:50 +00:00
VBoxContainer * tvb = memnew ( VBoxContainer ) ;
2014-02-10 01:10:30 +00:00
translations - > add_child ( tvb ) ;
2016-05-04 01:25:37 +00:00
tvb - > set_name ( TTR ( " Translations " ) ) ;
2017-03-05 15:44:50 +00:00
HBoxContainer * thb = memnew ( HBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( thb ) ;
2017-03-05 15:44:50 +00:00
thb - > add_child ( memnew ( Label ( TTR ( " Translations: " ) ) ) ) ;
2014-02-10 01:10:30 +00:00
thb - > add_spacer ( ) ;
2017-03-05 15:44:50 +00:00
Button * addtr = memnew ( Button ( TTR ( " Add.. " ) ) ) ;
addtr - > connect ( " pressed " , this , " _translation_file_open " ) ;
2014-02-10 01:10:30 +00:00
thb - > add_child ( addtr ) ;
2017-08-08 02:55:24 +00:00
VBoxContainer * tmc = memnew ( VBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( tmc ) ;
tmc - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 15:44:50 +00:00
translation_list = memnew ( Tree ) ;
2014-02-10 01:10:30 +00:00
translation_list - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
tmc - > add_child ( translation_list ) ;
2017-03-05 15:44:50 +00:00
translation_file_open = memnew ( EditorFileDialog ) ;
2014-02-10 01:10:30 +00:00
add_child ( translation_file_open ) ;
2015-06-06 12:44:38 +00:00
translation_file_open - > set_mode ( EditorFileDialog : : MODE_OPEN_FILE ) ;
2017-03-05 15:44:50 +00:00
translation_file_open - > connect ( " file_selected " , this , " _translation_add " ) ;
2014-02-10 01:10:30 +00:00
}
{
2017-03-05 15:44:50 +00:00
VBoxContainer * tvb = memnew ( VBoxContainer ) ;
2014-02-10 01:10:30 +00:00
translations - > add_child ( tvb ) ;
2016-05-04 01:25:37 +00:00
tvb - > set_name ( TTR ( " Remaps " ) ) ;
2017-03-05 15:44:50 +00:00
HBoxContainer * thb = memnew ( HBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( thb ) ;
2017-03-05 15:44:50 +00:00
thb - > add_child ( memnew ( Label ( TTR ( " Resources: " ) ) ) ) ;
2014-02-10 01:10:30 +00:00
thb - > add_spacer ( ) ;
2017-03-05 15:44:50 +00:00
Button * addtr = memnew ( Button ( TTR ( " Add.. " ) ) ) ;
addtr - > connect ( " pressed " , this , " _translation_res_file_open " ) ;
2014-02-10 01:10:30 +00:00
thb - > add_child ( addtr ) ;
2017-08-08 02:55:24 +00:00
VBoxContainer * tmc = memnew ( VBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( tmc ) ;
tmc - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 15:44:50 +00:00
translation_remap = memnew ( Tree ) ;
2014-02-10 01:10:30 +00:00
translation_remap - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 15:44:50 +00:00
translation_remap - > connect ( " cell_selected " , this , " _translation_res_select " ) ;
2014-02-10 01:10:30 +00:00
tmc - > add_child ( translation_remap ) ;
2017-03-05 15:44:50 +00:00
translation_remap - > connect ( " button_pressed " , this , " _translation_res_delete " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
translation_res_file_open = memnew ( EditorFileDialog ) ;
2014-02-10 01:10:30 +00:00
add_child ( translation_res_file_open ) ;
2015-06-06 12:44:38 +00:00
translation_res_file_open - > set_mode ( EditorFileDialog : : MODE_OPEN_FILE ) ;
2017-03-05 15:44:50 +00:00
translation_res_file_open - > connect ( " file_selected " , this , " _translation_res_add " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
thb = memnew ( HBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( thb ) ;
2017-03-05 15:44:50 +00:00
thb - > add_child ( memnew ( Label ( TTR ( " Remaps by Locale: " ) ) ) ) ;
2014-02-10 01:10:30 +00:00
thb - > add_spacer ( ) ;
2017-03-05 15:44:50 +00:00
addtr = memnew ( Button ( TTR ( " Add.. " ) ) ) ;
addtr - > connect ( " pressed " , this , " _translation_res_option_file_open " ) ;
translation_res_option_add_button = addtr ;
2014-02-10 01:10:30 +00:00
thb - > add_child ( addtr ) ;
2017-08-08 02:55:24 +00:00
tmc = memnew ( VBoxContainer ) ;
2014-02-10 01:10:30 +00:00
tvb - > add_child ( tmc ) ;
tmc - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
2017-03-05 15:44:50 +00:00
translation_remap_options = memnew ( Tree ) ;
2014-02-10 01:10:30 +00:00
translation_remap_options - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
tmc - > add_child ( translation_remap_options ) ;
translation_remap_options - > set_columns ( 2 ) ;
2017-03-05 15:44:50 +00:00
translation_remap_options - > set_column_title ( 0 , TTR ( " Path " ) ) ;
translation_remap_options - > set_column_title ( 1 , TTR ( " Locale " ) ) ;
2014-02-10 01:10:30 +00:00
translation_remap_options - > set_column_titles_visible ( true ) ;
2017-03-05 15:44:50 +00:00
translation_remap_options - > set_column_expand ( 0 , true ) ;
translation_remap_options - > set_column_expand ( 1 , false ) ;
translation_remap_options - > set_column_min_width ( 1 , 200 ) ;
translation_remap_options - > connect ( " item_edited " , this , " _translation_res_option_changed " ) ;
translation_remap_options - > connect ( " button_pressed " , this , " _translation_res_option_delete " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
translation_res_option_file_open = memnew ( EditorFileDialog ) ;
2014-02-10 01:10:30 +00:00
add_child ( translation_res_option_file_open ) ;
2015-06-06 12:44:38 +00:00
translation_res_option_file_open - > set_mode ( EditorFileDialog : : MODE_OPEN_FILE ) ;
2017-03-05 15:44:50 +00:00
translation_res_option_file_open - > connect ( " file_selected " , this , " _translation_res_option_add " ) ;
2014-02-10 01:10:30 +00:00
}
2017-10-17 15:27:54 +00:00
{
VBoxContainer * tvb = memnew ( VBoxContainer ) ;
translations - > add_child ( tvb ) ;
tvb - > set_name ( TTR ( " Locales Filter " ) ) ;
VBoxContainer * tmc = memnew ( VBoxContainer ) ;
tmc - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
tvb - > add_child ( tmc ) ;
translation_locale_filter_mode = memnew ( OptionButton ) ;
translation_locale_filter_mode - > add_item ( TTR ( " Show all locales " ) , SHOW_ALL_LOCALES ) ;
translation_locale_filter_mode - > add_item ( TTR ( " Show only selected locales " ) , SHOW_ONLY_SELECTED_LOCALES ) ;
translation_locale_filter_mode - > select ( 0 ) ;
tmc - > add_margin_child ( TTR ( " Filter mode: " ) , translation_locale_filter_mode ) ;
translation_locale_filter_mode - > connect ( " item_selected " , this , " _translation_filter_mode_changed " ) ;
translation_filter = memnew ( Tree ) ;
translation_filter - > set_v_size_flags ( SIZE_EXPAND_FILL ) ;
translation_filter - > set_columns ( 1 ) ;
tmc - > add_child ( memnew ( Label ( TTR ( " Locales: " ) ) ) ) ;
tmc - > add_child ( translation_filter ) ;
translation_filter - > connect ( " item_edited " , this , " _translation_filter_option_changed " ) ;
}
2017-12-07 23:49:44 +00:00
autoload_settings = memnew ( EditorAutoloadSettings ) ;
autoload_settings - > set_name ( TTR ( " AutoLoad " ) ) ;
tab_container - > add_child ( autoload_settings ) ;
autoload_settings - > connect ( " autoload_changed " , this , " _settings_changed " ) ;
2014-02-10 01:10:30 +00:00
2017-12-07 23:49:44 +00:00
plugin_settings = memnew ( EditorPluginSettings ) ;
plugin_settings - > set_name ( TTR ( " Plugins " ) ) ;
tab_container - > add_child ( plugin_settings ) ;
2016-02-28 02:10:44 +00:00
2017-03-05 15:44:50 +00:00
timer = memnew ( Timer ) ;
2014-02-10 01:10:30 +00:00
timer - > set_wait_time ( 1.5 ) ;
2017-07-19 20:00:46 +00:00
timer - > connect ( " timeout " , ProjectSettings : : get_singleton ( ) , " save " ) ;
2014-02-10 01:10:30 +00:00
timer - > set_one_shot ( true ) ;
add_child ( timer ) ;
2017-03-05 15:44:50 +00:00
updating_translations = false ;
2014-02-10 01:10:30 +00:00
}