2014-02-10 01:10:30 +00:00
/*************************************************************************/
2017-09-01 14:07:55 +00:00
/* project_settings.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
/*************************************************************************/
2022-01-13 08:45:09 +00:00
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 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. */
/*************************************************************************/
2018-01-04 23:50:27 +00:00
2017-07-19 20:00:46 +00:00
# include "project_settings.h"
2017-01-16 07:04:19 +00:00
2018-09-11 16:13:45 +00:00
# include "core/bind/core_bind.h"
# include "core/core_string_names.h"
# include "core/io/file_access_network.h"
# include "core/io/file_access_pack.h"
# include "core/io/marshalls.h"
# include "core/os/dir_access.h"
# include "core/os/file_access.h"
# include "core/os/keyboard.h"
# include "core/os/os.h"
# include "core/variant_parser.h"
2017-06-12 01:27:07 +00:00
# include <zlib.h>
2021-10-13 20:16:52 +00:00
const String ProjectSettings : : PROJECT_DATA_DIR_NAME_SUFFIX = " import " ;
2021-05-04 14:00:45 +00:00
ProjectSettings * ProjectSettings : : singleton = nullptr ;
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
ProjectSettings * ProjectSettings : : get_singleton ( ) {
2014-02-10 01:10:30 +00:00
return singleton ;
}
2021-09-10 17:52:41 +00:00
String ProjectSettings : : get_project_data_dir_name ( ) const {
2021-09-10 17:52:41 +00:00
return project_data_dir_name ;
2021-09-10 17:52:41 +00:00
}
String ProjectSettings : : get_project_data_path ( ) const {
2021-09-10 17:52:41 +00:00
return " res:// " + get_project_data_dir_name ( ) ;
2021-09-10 17:52:41 +00:00
}
2017-07-19 20:00:46 +00:00
String ProjectSettings : : get_resource_path ( ) const {
2014-02-10 01:10:30 +00:00
return resource_path ;
} ;
2017-07-19 20:00:46 +00:00
String ProjectSettings : : localize_path ( const String & p_path ) const {
2021-09-09 14:48:37 +00:00
if ( resource_path . empty ( ) | | p_path . begins_with ( " res:// " ) | | p_path . begins_with ( " user:// " ) | |
2021-05-05 10:44:11 +00:00
( p_path . is_abs_path ( ) & & ! p_path . begins_with ( resource_path ) ) ) {
2014-02-10 01:10:30 +00:00
return p_path . simplify_path ( ) ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
DirAccess * dir = DirAccess : : create ( DirAccess : : ACCESS_FILESYSTEM ) ;
2017-03-05 15:44:50 +00:00
String path = p_path . replace ( " \\ " , " / " ) . simplify_path ( ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
if ( dir - > change_dir ( path ) = = OK ) {
2014-02-10 01:10:30 +00:00
String cwd = dir - > get_current_dir ( ) ;
2017-03-05 15:44:50 +00:00
cwd = cwd . replace ( " \\ " , " / " ) ;
2014-02-10 01:10:30 +00:00
memdelete ( dir ) ;
2019-05-30 14:03:12 +00:00
// Ensure that we end with a '/'.
// This is important to ensure that we do not wrongly localize the resource path
// in an absolute path that just happens to contain this string but points to a
// different folder (e.g. "/my/project" as resource_path would be contained in
// "/my/project_data", even though the latter is not part of res://.
// `plus_file("")` is an easy way to ensure we have a trailing '/'.
const String res_path = resource_path . plus_file ( " " ) ;
2019-07-03 07:53:52 +00:00
// DirAccess::get_current_dir() is not guaranteed to return a path that with a trailing '/',
// so we must make sure we have it as well in order to compare with 'res_path'.
cwd = cwd . plus_file ( " " ) ;
2019-05-30 14:03:12 +00:00
if ( ! cwd . begins_with ( res_path ) ) {
2014-02-10 01:10:30 +00:00
return p_path ;
} ;
2019-05-30 14:03:12 +00:00
return cwd . replace_first ( res_path , " res:// " ) ;
2014-02-10 01:10:30 +00:00
} else {
memdelete ( dir ) ;
2022-01-08 21:40:44 +00:00
int sep = path . rfind ( " / " ) ;
2014-02-10 01:10:30 +00:00
if ( sep = = - 1 ) {
2017-03-05 15:44:50 +00:00
return " res:// " + path ;
2014-02-10 01:10:30 +00:00
} ;
2016-05-02 02:12:30 +00:00
2014-02-10 01:10:30 +00:00
String parent = path . substr ( 0 , sep ) ;
String plocal = localize_path ( parent ) ;
if ( plocal = = " " ) {
return " " ;
} ;
2019-12-20 05:49:01 +00:00
// Only strip the starting '/' from 'path' if its parent ('plocal') ends with '/'
if ( plocal [ plocal . length ( ) - 1 ] = = ' / ' ) {
sep + = 1 ;
}
2019-11-26 12:42:18 +00:00
return plocal + path . substr ( sep , path . size ( ) - sep ) ;
2014-02-10 01:10:30 +00:00
} ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_initial_value ( const String & p_name , const Variant & p_value ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
2017-03-05 15:44:50 +00:00
props [ p_name ] . initial = p_value ;
2014-02-10 01:10:30 +00:00
}
2018-07-19 21:58:15 +00:00
void ProjectSettings : : set_restart_if_changed ( const String & p_name , bool p_restart ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
2018-07-19 21:58:15 +00:00
props [ p_name ] . restart_if_changed = p_restart ;
}
2014-02-10 01:10:30 +00:00
2021-10-05 20:10:12 +00:00
void ProjectSettings : : set_hide_from_editor ( const String & p_name , bool p_hide_from_editor ) {
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
props [ p_name ] . hide_from_editor = p_hide_from_editor ;
}
2021-10-10 20:40:32 +00:00
void ProjectSettings : : set_ignore_value_in_docs ( const String & p_name , bool p_ignore ) {
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
# ifdef DEBUG_METHODS_ENABLED
props [ p_name ] . ignore_value_in_docs = p_ignore ;
# endif
}
bool ProjectSettings : : get_ignore_value_in_docs ( const String & p_name ) const {
ERR_FAIL_COND_V_MSG ( ! props . has ( p_name ) , false , " Request for nonexistent project setting: " + p_name + " . " ) ;
# ifdef DEBUG_METHODS_ENABLED
return props [ p_name ] . ignore_value_in_docs ;
# else
return false ;
# endif
}
2017-07-19 20:00:46 +00:00
String ProjectSettings : : globalize_path ( const String & p_path ) const {
2014-02-10 01:10:30 +00:00
if ( p_path . begins_with ( " res:// " ) ) {
if ( resource_path ! = " " ) {
2017-03-05 15:44:50 +00:00
return p_path . replace ( " res:/ " , resource_path ) ;
2014-02-10 01:10:30 +00:00
} ;
return p_path . replace ( " res:// " , " " ) ;
2017-09-10 08:33:54 +00:00
} else if ( p_path . begins_with ( " user:// " ) ) {
2017-11-17 14:25:22 +00:00
String data_dir = OS : : get_singleton ( ) - > get_user_data_dir ( ) ;
2017-09-10 08:33:54 +00:00
if ( data_dir ! = " " ) {
return p_path . replace ( " user:/ " , data_dir ) ;
} ;
return p_path . replace ( " user:// " , " " ) ;
}
2014-02-10 01:10:30 +00:00
return p_path ;
}
2021-10-01 10:47:28 +00:00
void ProjectSettings : : update ( ) {
if ( _dirty_this_frame ) {
// A signal is sent a single time at the end of the frame when project settings
// are changed. This allows objects to respond.
// Alternatively objects outside the signal system can query ProjectSettings::has_changes()
if ( _dirty_this_frame = = 2 ) {
emit_signal ( " project_settings_changed " ) ;
}
_dirty_this_frame - - ;
}
}
2017-07-19 20:00:46 +00:00
bool ProjectSettings : : _set ( const StringName & p_name , const Variant & p_value ) {
2014-02-10 01:10:30 +00:00
_THREAD_SAFE_METHOD_
2016-03-08 23:00:52 +00:00
2021-10-01 10:47:28 +00:00
// marking the project settings as dirty allows them only to be
// checked when dirty.
_dirty_this_frame = 2 ;
2021-05-05 10:44:11 +00:00
if ( p_value . get_type ( ) = = Variant : : NIL ) {
2014-02-10 01:10:30 +00:00
props . erase ( p_name ) ;
2021-05-05 10:44:11 +00:00
} else {
2017-07-19 20:00:46 +00:00
if ( p_name = = CoreStringNames : : get_singleton ( ) - > _custom_features ) {
2018-06-27 11:37:55 +00:00
Vector < String > custom_feature_array = String ( p_value ) . split ( " , " ) ;
2017-07-19 20:00:46 +00:00
for ( int i = 0 ; i < custom_feature_array . size ( ) ; i + + ) {
custom_features . insert ( custom_feature_array [ i ] ) ;
}
return true ;
}
if ( ! disable_feature_overrides ) {
int dot = p_name . operator String ( ) . find ( " . " ) ;
if ( dot ! = - 1 ) {
Vector < String > s = p_name . operator String ( ) . split ( " . " ) ;
bool override_valid = false ;
for ( int i = 1 ; i < s . size ( ) ; i + + ) {
String feature = s [ i ] . strip_edges ( ) ;
2017-10-02 19:38:39 +00:00
if ( OS : : get_singleton ( ) - > has_feature ( feature ) | | custom_features . has ( feature ) ) {
2017-07-19 20:00:46 +00:00
override_valid = true ;
break ;
}
}
if ( override_valid ) {
feature_overrides [ s [ 0 ] ] = p_name ;
}
}
}
2014-02-10 01:10:30 +00:00
if ( props . has ( p_name ) ) {
2021-05-05 10:44:11 +00:00
if ( ! props [ p_name ] . overridden ) {
2017-03-05 15:44:50 +00:00
props [ p_name ] . variant = p_value ;
2021-05-05 10:44:11 +00:00
}
2015-12-16 02:39:36 +00:00
2014-02-10 01:10:30 +00:00
} else {
2017-07-18 00:05:38 +00:00
props [ p_name ] = VariantContainer ( p_value , last_order + + ) ;
2014-02-10 01:10:30 +00:00
}
}
return true ;
}
2017-07-19 20:00:46 +00:00
bool ProjectSettings : : _get ( const StringName & p_name , Variant & r_ret ) const {
2014-02-10 01:10:30 +00:00
_THREAD_SAFE_METHOD_
2017-07-19 20:00:46 +00:00
StringName name = p_name ;
if ( ! disable_feature_overrides & & feature_overrides . has ( name ) ) {
name = feature_overrides [ name ] ;
}
if ( ! props . has ( name ) ) {
2021-06-18 11:26:58 +00:00
WARN_PRINT ( " Property not found: " + String ( name ) ) ;
2014-02-10 01:10:30 +00:00
return false ;
2017-01-15 00:56:22 +00:00
}
2017-07-19 20:00:46 +00:00
r_ret = props [ name ] . variant ;
2014-02-10 01:10:30 +00:00
return true ;
}
struct _VCSort {
String name ;
Variant : : Type type ;
int order ;
int flags ;
2017-03-05 15:44:50 +00:00
bool operator < ( const _VCSort & p_vcs ) const { return order = = p_vcs . order ? name < p_vcs . name : order < p_vcs . order ; }
2014-02-10 01:10:30 +00:00
} ;
2017-07-19 20:00:46 +00:00
void ProjectSettings : : _get_property_list ( List < PropertyInfo > * p_list ) const {
2014-02-10 01:10:30 +00:00
_THREAD_SAFE_METHOD_
Set < _VCSort > vclist ;
2016-03-08 23:00:52 +00:00
2017-03-05 15:44:50 +00:00
for ( Map < StringName , VariantContainer > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
const VariantContainer * v = & E - > get ( ) ;
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( v - > hide_from_editor ) {
2014-02-10 01:10:30 +00:00
continue ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
_VCSort vc ;
2017-03-05 15:44:50 +00:00
vc . name = E - > key ( ) ;
vc . order = v - > order ;
vc . type = v - > variant . get_type ( ) ;
2021-05-05 10:44:11 +00:00
if ( vc . name . begins_with ( " input/ " ) | | vc . name . begins_with ( " import/ " ) | | vc . name . begins_with ( " export/ " ) | | vc . name . begins_with ( " /remap " ) | | vc . name . begins_with ( " /locale " ) | | vc . name . begins_with ( " /autoload " ) ) {
2017-03-05 15:44:50 +00:00
vc . flags = PROPERTY_USAGE_STORAGE ;
2021-05-05 10:44:11 +00:00
} else {
2017-03-05 15:44:50 +00:00
vc . flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2018-07-19 21:58:15 +00:00
if ( v - > restart_if_changed ) {
vc . flags | = PROPERTY_USAGE_RESTART_IF_CHANGED ;
}
2014-02-10 01:10:30 +00:00
vclist . insert ( vc ) ;
}
2017-03-05 15:44:50 +00:00
for ( Set < _VCSort > : : Element * E = vclist . front ( ) ; E ; E = E - > next ( ) ) {
2017-07-19 20:00:46 +00:00
String prop_info_name = E - > get ( ) . name ;
int dot = prop_info_name . find ( " . " ) ;
2021-05-05 10:44:11 +00:00
if ( dot ! = - 1 ) {
2017-07-19 20:00:46 +00:00
prop_info_name = prop_info_name . substr ( 0 , dot ) ;
2021-05-05 10:44:11 +00:00
}
2017-07-19 20:00:46 +00:00
if ( custom_prop_info . has ( prop_info_name ) ) {
PropertyInfo pi = custom_prop_info [ prop_info_name ] ;
2017-03-05 15:44:50 +00:00
pi . name = E - > get ( ) . name ;
pi . usage = E - > get ( ) . flags ;
p_list - > push_back ( pi ) ;
2021-05-05 10:44:11 +00:00
} else {
2017-03-05 15:44:50 +00:00
p_list - > push_back ( PropertyInfo ( E - > get ( ) . type , E - > get ( ) . name , PROPERTY_HINT_NONE , " " , E - > get ( ) . flags ) ) ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
}
}
2020-07-13 16:22:06 +00:00
bool ProjectSettings : : _load_resource_pack ( const String & p_pack , bool p_replace_files , int p_offset ) {
2021-05-05 10:44:11 +00:00
if ( PackedData : : get_singleton ( ) - > is_disabled ( ) ) {
2014-02-10 01:10:30 +00:00
return false ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2020-07-13 16:22:06 +00:00
bool ok = PackedData : : get_singleton ( ) - > add_pack ( p_pack , p_replace_files , p_offset ) = = OK ;
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( ! ok ) {
2014-02-10 01:10:30 +00:00
return false ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
//if data.pck is found, all directory access will be from here
DirAccess : : make_default < DirAccessPack > ( DirAccess : : ACCESS_RESOURCES ) ;
2017-03-05 15:44:50 +00:00
using_datapack = true ;
2014-02-10 01:10:30 +00:00
return true ;
}
2018-12-21 11:20:48 +00:00
void ProjectSettings : : _convert_to_last_version ( int p_from_version ) {
if ( p_from_version < = 3 ) {
2018-02-21 21:06:34 +00:00
// Converts the actions from array to dictionary (array of events to dictionary with deadzone + events)
for ( Map < StringName , ProjectSettings : : VariantContainer > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
Variant value = E - > get ( ) . variant ;
if ( String ( E - > key ( ) ) . begins_with ( " input/ " ) & & value . get_type ( ) = = Variant : : ARRAY ) {
Array array = value ;
Dictionary action ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
action [ " events " ] = array ;
E - > get ( ) . variant = action ;
}
}
}
}
2018-10-24 18:04:36 +00:00
/*
* This method is responsible for loading a project . godot file and / or data file
* using the following merit order :
* - If using NetworkClient , try to lookup project file or fail .
* - If - - main - pack was passed by the user ( ` p_main_pack ` ) , load it or fail .
2020-05-25 15:50:16 +00:00
* - Search for project PCKs automatically . For each step we try loading a potential
* PCK , and if it doesn ' t work , we proceed to the next step . If any step succeeds ,
* we try loading the project settings , and abort if it fails . Steps :
* o Bundled PCK in the executable .
* o [ macOS only ] PCK with same basename as the binary in the . app resource dir .
* o PCK with same basename as the binary in the binary ' s directory . We handle both
* changing the extension to ' . pck ' ( e . g . ' win_game . exe ' - > ' win_game . pck ' ) and
* appending ' . pck ' to the binary name ( e . g . ' linux_game ' - > ' linux_game . pck ' ) .
* o PCK with the same basename as the binary in the current working directory .
* Same as above for the two possible PCK file names .
2018-10-24 18:04:36 +00:00
* - On relevant platforms ( Android / iOS ) , lookup project file in OS resource path .
* If found , load it or fail .
* - Lookup project file in passed ` p_path ` ( - - path passed by the user ) , i . e . we
* are running from source code .
* If not found and ` p_upwards ` is true ( - - upwards passed by the user ) , look for
* project files in parent folders up to the system root ( used to run a game
* from command line while in a subfolder ) .
* If a project file is found , load it or fail .
* If nothing was found , error out .
*/
2021-11-22 15:10:31 +00:00
Error ProjectSettings : : _setup ( const String & p_path , const String & p_main_pack , bool p_upwards , bool p_ignore_override ) {
2022-08-26 13:01:22 +00:00
if ( OS : : get_singleton ( ) - > get_resource_dir ( ) ! = " " ) {
// OS will call ProjectSettings->get_resource_path which will be empty if not overridden!
// If the OS would rather use a specific location, then it will not be empty.
resource_path = OS : : get_singleton ( ) - > get_resource_dir ( ) . replace ( " \\ " , " / " ) ;
if ( resource_path ! = " " & & resource_path [ resource_path . length ( ) - 1 ] = = ' / ' ) {
resource_path = resource_path . substr ( 0 , resource_path . length ( ) - 1 ) ; // Chop end.
}
}
2018-10-24 18:04:36 +00:00
// If looking for files in a network client, use it directly
2017-04-29 15:56:51 +00:00
2017-02-21 03:05:15 +00:00
if ( FileAccessNetworkClient : : get_singleton ( ) ) {
2018-02-19 13:53:59 +00:00
Error err = _load_settings_text_or_binary ( " res://project.godot " , " res://project.binary " ) ;
2021-11-22 15:10:31 +00:00
if ( err = = OK & & ! p_ignore_override ) {
2018-02-19 13:53:59 +00:00
// Optional, we don't mind if it fails
_load_settings_text ( " res://override.cfg " ) ;
2017-02-21 03:05:15 +00:00
}
2018-02-19 13:53:59 +00:00
return err ;
2017-02-21 03:05:15 +00:00
}
2018-10-24 18:04:36 +00:00
// Attempt with a user-defined main pack first
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
if ( p_main_pack ! = " " ) {
2014-06-28 02:21:45 +00:00
bool ok = _load_resource_pack ( p_main_pack ) ;
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( ! ok , ERR_CANT_OPEN , " Cannot open resource pack ' " + p_main_pack + " '. " ) ;
2017-04-29 15:56:51 +00:00
2018-02-19 13:53:59 +00:00
Error err = _load_settings_text_or_binary ( " res://project.godot " , " res://project.binary " ) ;
2021-11-22 15:10:31 +00:00
if ( err = = OK & & ! p_ignore_override ) {
2018-02-19 13:53:59 +00:00
// Load override from location of the main pack
// Optional, we don't mind if it fails
_load_settings_text ( p_main_pack . get_base_dir ( ) . plus_file ( " override.cfg " ) ) ;
2014-06-28 02:21:45 +00:00
}
2018-02-19 13:53:59 +00:00
return err ;
2014-06-28 02:21:45 +00:00
}
2018-10-24 18:04:36 +00:00
String exec_path = OS : : get_singleton ( ) - > get_executable_path ( ) ;
2017-03-05 15:44:50 +00:00
if ( exec_path ! = " " ) {
2020-05-25 15:50:16 +00:00
// We do several tests sequentially until one succeeds to find a PCK,
// and if so we attempt loading it at the end.
2019-03-25 19:56:33 +00:00
2020-05-25 15:50:16 +00:00
// Attempt with PCK bundled into executable.
bool found = _load_resource_pack ( exec_path ) ;
2019-03-25 19:56:33 +00:00
2020-05-25 15:50:16 +00:00
// Attempt with exec_name.pck.
// (This is the usual case when distributing a Godot game.)
2018-10-24 18:04:36 +00:00
String exec_dir = exec_path . get_base_dir ( ) ;
String exec_filename = exec_path . get_file ( ) ;
String exec_basename = exec_filename . get_basename ( ) ;
2020-05-25 15:50:16 +00:00
// Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
// or the exec path's basename + '.pck' (Windows).
// We need to test both possibilities as extensions for Linux binaries are optional
// (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
2014-02-10 01:10:30 +00:00
2020-01-10 16:02:29 +00:00
# ifdef OSX_ENABLED
if ( ! found ) {
2020-05-25 15:50:16 +00:00
// Attempt to load PCK from macOS .app bundle resources.
2020-12-02 09:04:44 +00:00
found = _load_resource_pack ( OS : : get_singleton ( ) - > get_bundle_resource_dir ( ) . plus_file ( exec_basename + " .pck " ) ) | | _load_resource_pack ( OS : : get_singleton ( ) - > get_bundle_resource_dir ( ) . plus_file ( exec_filename + " .pck " ) ) ;
2020-01-10 16:02:29 +00:00
}
# endif
2019-03-25 19:56:33 +00:00
if ( ! found ) {
2020-05-25 15:50:16 +00:00
// Try to load data pack at the location of the executable.
// As mentioned above, we have two potential names to attempt.
2020-04-16 16:41:59 +00:00
found = _load_resource_pack ( exec_dir . plus_file ( exec_basename + " .pck " ) ) | | _load_resource_pack ( exec_dir . plus_file ( exec_filename + " .pck " ) ) ;
2020-05-25 15:50:16 +00:00
}
2020-04-16 16:41:59 +00:00
2020-05-25 15:50:16 +00:00
if ( ! found ) {
// If we couldn't find them next to the executable, we attempt
// the current working directory. Same story, two tests.
found = _load_resource_pack ( exec_basename + " .pck " ) | | _load_resource_pack ( exec_filename + " .pck " ) ;
2019-03-25 19:56:33 +00:00
}
2020-05-25 15:50:16 +00:00
// If we opened our package, try and load our project.
2017-09-08 01:39:32 +00:00
if ( found ) {
2018-02-19 13:53:59 +00:00
Error err = _load_settings_text_or_binary ( " res://project.godot " , " res://project.binary " ) ;
2021-11-22 15:10:31 +00:00
if ( err = = OK & & ! p_ignore_override ) {
2020-05-25 15:50:16 +00:00
// Load override from location of the executable.
// Optional, we don't mind if it fails.
2018-02-19 13:53:59 +00:00
_load_settings_text ( exec_path . get_base_dir ( ) . plus_file ( " override.cfg " ) ) ;
2014-02-10 01:10:30 +00:00
}
2018-02-19 13:53:59 +00:00
return err ;
2014-02-10 01:10:30 +00:00
}
}
2016-03-08 23:00:52 +00:00
2020-05-25 15:50:16 +00:00
// Try to use the filesystem for files, according to OS.
// (Only Android -when reading from pck- and iOS use this.)
2017-02-21 03:05:15 +00:00
2018-10-24 18:04:36 +00:00
if ( OS : : get_singleton ( ) - > get_resource_dir ( ) ! = " " ) {
2018-02-19 13:53:59 +00:00
Error err = _load_settings_text_or_binary ( " res://project.godot " , " res://project.binary " ) ;
2021-11-22 15:10:31 +00:00
if ( err = = OK & & ! p_ignore_override ) {
2020-05-25 15:50:16 +00:00
// Optional, we don't mind if it fails.
2018-02-19 13:53:59 +00:00
_load_settings_text ( " res://override.cfg " ) ;
2014-02-10 01:10:30 +00:00
}
2018-02-19 13:53:59 +00:00
return err ;
2014-02-10 01:10:30 +00:00
}
2018-10-24 18:04:36 +00:00
// Nothing was found, try to find a project file in provided path (`p_path`)
// or, if requested (`p_upwards`) in parent directories.
2014-02-10 01:10:30 +00:00
2017-02-21 03:05:15 +00:00
DirAccess * d = DirAccess : : create ( DirAccess : : ACCESS_FILESYSTEM ) ;
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( ! d , ERR_CANT_CREATE , " Cannot create DirAccess for path ' " + p_path + " '. " ) ;
2017-02-21 03:05:15 +00:00
d - > change_dir ( p_path ) ;
2015-11-14 21:43:14 +00:00
2017-02-21 03:05:15 +00:00
String current_dir = d - > get_current_dir ( ) ;
2018-10-24 18:04:36 +00:00
String candidate = current_dir ;
2017-02-21 03:05:15 +00:00
bool found = false ;
2018-02-19 13:53:59 +00:00
Error err ;
2015-11-14 21:43:14 +00:00
2017-03-05 15:44:50 +00:00
while ( true ) {
2018-02-19 13:53:59 +00:00
err = _load_settings_text_or_binary ( current_dir . plus_file ( " project.godot " ) , current_dir . plus_file ( " project.binary " ) ) ;
2021-11-22 15:10:31 +00:00
if ( err = = OK & & ! p_ignore_override ) {
2020-05-25 15:50:16 +00:00
// Optional, we don't mind if it fails.
2018-02-19 13:53:59 +00:00
_load_settings_text ( current_dir . plus_file ( " override.cfg " ) ) ;
2017-03-05 15:44:50 +00:00
candidate = current_dir ;
found = true ;
2017-02-21 03:05:15 +00:00
break ;
2014-02-10 01:10:30 +00:00
}
2017-10-10 12:45:54 +00:00
if ( p_upwards ) {
2018-10-24 18:04:36 +00:00
// Try to load settings ascending through parent directories
2017-10-10 12:45:54 +00:00
d - > change_dir ( " .. " ) ;
2021-05-05 10:44:11 +00:00
if ( d - > get_current_dir ( ) = = current_dir ) {
2018-10-24 18:04:36 +00:00
break ; // not doing anything useful
2021-05-05 10:44:11 +00:00
}
2017-10-10 12:45:54 +00:00
current_dir = d - > get_current_dir ( ) ;
} else {
break ;
}
2017-02-21 03:05:15 +00:00
}
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
resource_path = candidate ;
2020-05-25 15:50:16 +00:00
resource_path = resource_path . replace ( " \\ " , " / " ) ; // Windows path to Unix path just in case.
2017-02-21 03:05:15 +00:00
memdelete ( d ) ;
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( ! found ) {
2018-02-19 13:53:59 +00:00
return err ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2020-05-25 15:50:16 +00:00
if ( resource_path . length ( ) & & resource_path [ resource_path . length ( ) - 1 ] = = ' / ' ) {
resource_path = resource_path . substr ( 0 , resource_path . length ( ) - 1 ) ; // Chop end.
}
2014-02-10 01:10:30 +00:00
return OK ;
}
2021-11-22 15:10:31 +00:00
Error ProjectSettings : : setup ( const String & p_path , const String & p_main_pack , bool p_upwards , bool p_ignore_override ) {
Error err = _setup ( p_path , p_main_pack , p_upwards , p_ignore_override ) ;
2018-11-18 13:56:21 +00:00
if ( err = = OK ) {
String custom_settings = GLOBAL_DEF ( " application/config/project_settings_override " , " " ) ;
if ( custom_settings ! = " " ) {
_load_settings_text ( custom_settings ) ;
}
}
2021-09-10 17:52:41 +00:00
// Updating the default value after the project settings have loaded.
2021-10-13 20:16:52 +00:00
bool use_hidden_directory = GLOBAL_GET ( " application/config/use_hidden_project_data_directory " ) ;
project_data_dir_name = ( use_hidden_directory ? " . " : " " ) + PROJECT_DATA_DIR_NAME_SUFFIX ;
2021-09-10 17:52:41 +00:00
2020-07-13 11:38:35 +00:00
// Using GLOBAL_GET on every block for compressing can be slow, so assigning here.
Compression : : zstd_long_distance_matching = GLOBAL_GET ( " compression/formats/zstd/long_distance_matching " ) ;
Compression : : zstd_level = GLOBAL_GET ( " compression/formats/zstd/compression_level " ) ;
Compression : : zstd_window_log_size = GLOBAL_GET ( " compression/formats/zstd/window_log_size " ) ;
Compression : : zlib_level = GLOBAL_GET ( " compression/formats/zlib/compression_level " ) ;
Compression : : gzip_level = GLOBAL_GET ( " compression/formats/gzip/compression_level " ) ;
2018-11-18 13:56:21 +00:00
return err ;
}
2017-10-05 18:34:34 +00:00
bool ProjectSettings : : has_setting ( String p_var ) const {
2014-02-10 01:10:30 +00:00
_THREAD_SAFE_METHOD_
2022-03-07 11:33:07 +00:00
return props . has ( p_var ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_registering_order ( bool p_enable ) {
2017-03-05 15:44:50 +00:00
registering_order = p_enable ;
2015-12-16 02:39:36 +00:00
}
2014-02-10 01:10:30 +00:00
2019-07-10 09:54:12 +00:00
Error ProjectSettings : : _load_settings_binary ( const String & p_path ) {
2014-02-10 01:10:30 +00:00
Error err ;
2017-03-05 15:44:50 +00:00
FileAccess * f = FileAccess : : open ( p_path , FileAccess : : READ , & err ) ;
if ( err ! = OK ) {
2014-02-10 01:10:30 +00:00
return err ;
}
uint8_t hdr [ 4 ] ;
2017-03-05 15:44:50 +00:00
f - > get_buffer ( hdr , 4 ) ;
if ( hdr [ 0 ] ! = ' E ' | | hdr [ 1 ] ! = ' C ' | | hdr [ 2 ] ! = ' F ' | | hdr [ 3 ] ! = ' G ' ) {
2014-02-10 01:10:30 +00:00
memdelete ( f ) ;
2019-08-15 02:57:49 +00:00
ERR_FAIL_V_MSG ( ERR_FILE_CORRUPT , " Corrupted header in binary project.binary (not ECFG). " ) ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
uint32_t count = f - > get_32 ( ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( uint32_t i = 0 ; i < count ; i + + ) {
uint32_t slen = f - > get_32 ( ) ;
2014-02-10 01:10:30 +00:00
CharString cs ;
2017-03-05 15:44:50 +00:00
cs . resize ( slen + 1 ) ;
cs [ slen ] = 0 ;
f - > get_buffer ( ( uint8_t * ) cs . ptr ( ) , slen ) ;
2014-02-10 01:10:30 +00:00
String key ;
key . parse_utf8 ( cs . ptr ( ) ) ;
2017-03-05 15:44:50 +00:00
uint32_t vlen = f - > get_32 ( ) ;
2014-02-10 01:10:30 +00:00
Vector < uint8_t > d ;
d . resize ( vlen ) ;
2017-11-25 03:07:54 +00:00
f - > get_buffer ( d . ptrw ( ) , vlen ) ;
2014-02-10 01:10:30 +00:00
Variant value ;
2021-05-04 14:00:45 +00:00
err = decode_variant ( value , d . ptr ( ) , d . size ( ) , nullptr , true ) ;
2019-08-15 02:57:49 +00:00
ERR_CONTINUE_MSG ( err ! = OK , " Error decoding property: " + key + " . " ) ;
2017-03-05 15:44:50 +00:00
set ( key , value ) ;
2014-02-10 01:10:30 +00:00
}
2019-11-20 15:22:16 +00:00
f - > close ( ) ;
memdelete ( f ) ;
2014-02-10 01:10:30 +00:00
return OK ;
}
2018-02-19 13:53:59 +00:00
2019-07-10 09:54:12 +00:00
Error ProjectSettings : : _load_settings_text ( const String & p_path ) {
2014-02-10 01:10:30 +00:00
Error err ;
2017-03-05 15:44:50 +00:00
FileAccess * f = FileAccess : : open ( p_path , FileAccess : : READ , & err ) ;
2014-02-10 01:10:30 +00:00
2018-02-21 08:07:47 +00:00
if ( ! f ) {
// FIXME: Above 'err' error code is ERR_FILE_CANT_OPEN if the file is missing
// This needs to be streamlined if we want decent error reporting
return ERR_FILE_NOT_FOUND ;
}
2014-02-10 01:10:30 +00:00
2017-01-11 19:15:40 +00:00
VariantParser : : StreamFile stream ;
2017-03-05 15:44:50 +00:00
stream . f = f ;
2014-02-10 01:10:30 +00:00
2017-01-11 19:15:40 +00:00
String assign ;
Variant value ;
VariantParser : : Tag next_tag ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
int lines = 0 ;
2017-01-11 19:15:40 +00:00
String error_text ;
String section ;
2018-12-21 11:20:48 +00:00
int config_version = 0 ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
while ( true ) {
assign = Variant ( ) ;
2017-01-11 19:15:40 +00:00
next_tag . fields . clear ( ) ;
2017-03-05 15:44:50 +00:00
next_tag . name = String ( ) ;
2014-02-10 01:10:30 +00:00
2021-05-04 14:00:45 +00:00
err = VariantParser : : parse_tag_assign_eof ( & stream , lines , error_text , next_tag , assign , value , nullptr , true ) ;
2017-03-05 15:44:50 +00:00
if ( err = = ERR_FILE_EOF ) {
2017-01-11 19:15:40 +00:00
memdelete ( f ) ;
2018-12-21 11:20:48 +00:00
// If we're loading a project.godot from source code, we can operate some
// ProjectSettings conversions if need be.
_convert_to_last_version ( config_version ) ;
2021-02-11 00:08:49 +00:00
last_save_time = FileAccess : : get_modified_time ( get_resource_path ( ) . plus_file ( " project.godot " ) ) ;
2017-01-11 19:15:40 +00:00
return OK ;
2017-03-05 15:44:50 +00:00
} else if ( err ! = OK ) {
2021-06-16 10:56:25 +00:00
ERR_PRINT ( " Error parsing " + p_path + " at line " + itos ( lines ) + " : " + error_text + " File might be corrupted. " ) ;
2017-01-11 19:15:40 +00:00
memdelete ( f ) ;
return err ;
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
if ( assign ! = String ( ) ) {
if ( section = = String ( ) & & assign = = " config_version " ) {
2018-12-21 11:20:48 +00:00
config_version = value ;
if ( config_version > CONFIG_VERSION ) {
2017-02-05 00:02:52 +00:00
memdelete ( f ) ;
2019-08-15 02:57:49 +00:00
ERR_FAIL_V_MSG ( ERR_FILE_CANT_OPEN , vformat ( " Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d. " , p_path , config_version , CONFIG_VERSION ) ) ;
2017-02-05 00:02:52 +00:00
}
2017-07-26 13:28:54 +00:00
} else {
2018-07-15 22:29:00 +00:00
if ( section = = String ( ) ) {
set ( assign , value ) ;
} else {
set ( section + " / " + assign , value ) ;
}
2017-02-05 00:02:52 +00:00
}
2017-03-05 15:44:50 +00:00
} else if ( next_tag . name ! = String ( ) ) {
section = next_tag . name ;
2017-01-11 19:15:40 +00:00
}
2014-02-10 01:10:30 +00:00
}
}
2019-07-10 09:54:12 +00:00
Error ProjectSettings : : _load_settings_text_or_binary ( const String & p_text_path , const String & p_bin_path ) {
2020-10-21 22:12:18 +00:00
// Attempt first to load the binary project.godot file.
Error err = _load_settings_binary ( p_bin_path ) ;
if ( err = = OK ) {
return OK ;
} else if ( err ! = ERR_FILE_NOT_FOUND ) {
// If the file exists but can't be loaded, we want to know it.
ERR_PRINT ( " Couldn't load file ' " + p_bin_path + " ', error code " + itos ( err ) + " . " ) ;
}
2018-02-19 13:53:59 +00:00
2020-10-21 22:12:18 +00:00
// Fallback to text-based project.godot file if binary was not found.
err = _load_settings_text ( p_text_path ) ;
if ( err = = OK ) {
2018-02-19 13:53:59 +00:00
return OK ;
2020-10-21 22:12:18 +00:00
} else if ( err ! = ERR_FILE_NOT_FOUND ) {
ERR_PRINT ( " Couldn't load file ' " + p_text_path + " ', error code " + itos ( err ) + " . " ) ;
2018-02-19 13:53:59 +00:00
}
2020-10-21 22:12:18 +00:00
return err ;
2018-02-19 13:53:59 +00:00
}
2017-07-19 20:00:46 +00:00
int ProjectSettings : : get_order ( const String & p_name ) const {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( ! props . has ( p_name ) , - 1 , " Request for nonexistent project setting: " + p_name + " . " ) ;
2014-02-10 01:10:30 +00:00
return props [ p_name ] . order ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_order ( const String & p_name , int p_order ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
2017-03-05 15:44:50 +00:00
props [ p_name ] . order = p_order ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_builtin_order ( const String & p_name ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
2017-07-18 00:05:38 +00:00
if ( props [ p_name ] . order > = NO_BUILTIN_ORDER_BASE ) {
props [ p_name ] . order = last_builtin_order + + ;
}
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : clear ( const String & p_name ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_MSG ( ! props . has ( p_name ) , " Request for nonexistent project setting: " + p_name + " . " ) ;
2014-02-10 01:10:30 +00:00
props . erase ( p_name ) ;
}
2017-07-19 20:00:46 +00:00
Error ProjectSettings : : save ( ) {
2021-02-11 00:08:49 +00:00
Error error = save_custom ( get_resource_path ( ) . plus_file ( " project.godot " ) ) ;
if ( error = = OK ) {
last_save_time = FileAccess : : get_modified_time ( get_resource_path ( ) . plus_file ( " project.godot " ) ) ;
}
return error ;
2014-02-10 01:10:30 +00:00
}
2021-05-04 12:20:36 +00:00
Error ProjectSettings : : _save_settings_binary ( const String & p_file , const Map < String , List < String > > & props , const CustomMap & p_custom , const String & p_custom_features ) {
2014-02-10 01:10:30 +00:00
Error err ;
2017-03-05 15:44:50 +00:00
FileAccess * file = FileAccess : : open ( p_file , FileAccess : : WRITE , & err ) ;
2019-08-15 02:57:49 +00:00
ERR_FAIL_COND_V_MSG ( err ! = OK , err , " Couldn't save project.binary at " + p_file + " . " ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
uint8_t hdr [ 4 ] = { ' E ' , ' C ' , ' F ' , ' G ' } ;
file - > store_buffer ( hdr , 4 ) ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
int count = 0 ;
2014-02-10 01:10:30 +00:00
2021-05-04 12:20:36 +00:00
for ( Map < String , List < String > > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
2017-03-05 15:44:50 +00:00
for ( List < String > : : Element * F = E - > get ( ) . front ( ) ; F ; F = F - > next ( ) ) {
2014-02-10 01:10:30 +00:00
count + + ;
}
}
2017-07-19 20:00:46 +00:00
if ( p_custom_features ! = String ( ) ) {
file - > store_32 ( count + 1 ) ;
//store how many properties are saved, add one for custom featuers, which must always go first
String key = CoreStringNames : : get_singleton ( ) - > _custom_features ;
2021-06-16 08:32:03 +00:00
file - > store_pascal_string ( key ) ;
2017-07-19 20:00:46 +00:00
int len ;
2021-05-04 14:00:45 +00:00
err = encode_variant ( p_custom_features , nullptr , len , false ) ;
2017-07-19 20:00:46 +00:00
if ( err ! = OK ) {
memdelete ( file ) ;
ERR_FAIL_V ( err ) ;
}
Vector < uint8_t > buff ;
buff . resize ( len ) ;
2019-03-26 15:52:42 +00:00
err = encode_variant ( p_custom_features , buff . ptrw ( ) , len , false ) ;
2017-07-19 20:00:46 +00:00
if ( err ! = OK ) {
memdelete ( file ) ;
ERR_FAIL_V ( err ) ;
}
file - > store_32 ( len ) ;
file - > store_buffer ( buff . ptr ( ) , buff . size ( ) ) ;
} else {
file - > store_32 ( count ) ; //store how many properties are saved
}
2014-02-10 01:10:30 +00:00
2021-05-04 12:20:36 +00:00
for ( Map < String , List < String > > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
2017-03-05 15:44:50 +00:00
for ( List < String > : : Element * F = E - > get ( ) . front ( ) ; F ; F = F - > next ( ) ) {
2014-02-10 01:10:30 +00:00
String key = F - > get ( ) ;
2021-05-05 10:44:11 +00:00
if ( E - > key ( ) ! = " " ) {
2017-03-05 15:44:50 +00:00
key = E - > key ( ) + " / " + key ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
Variant value ;
2021-05-05 10:44:11 +00:00
if ( p_custom . has ( key ) ) {
2017-03-05 15:44:50 +00:00
value = p_custom [ key ] ;
2021-05-05 10:44:11 +00:00
} else {
2014-02-10 01:10:30 +00:00
value = get ( key ) ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2021-06-16 08:32:03 +00:00
file - > store_pascal_string ( key ) ;
2014-02-10 01:10:30 +00:00
int len ;
2021-05-04 14:00:45 +00:00
err = encode_variant ( value , nullptr , len , true ) ;
2021-05-05 10:44:11 +00:00
if ( err ! = OK ) {
2014-02-10 01:10:30 +00:00
memdelete ( file ) ;
2021-05-05 10:44:11 +00:00
}
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( err ! = OK , ERR_INVALID_DATA , " Error when trying to encode Variant. " ) ;
2014-02-10 01:10:30 +00:00
Vector < uint8_t > buff ;
buff . resize ( len ) ;
2019-04-15 13:30:54 +00:00
err = encode_variant ( value , buff . ptrw ( ) , len , true ) ;
2021-05-05 10:44:11 +00:00
if ( err ! = OK ) {
2014-02-10 01:10:30 +00:00
memdelete ( file ) ;
2021-05-05 10:44:11 +00:00
}
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( err ! = OK , ERR_INVALID_DATA , " Error when trying to encode Variant. " ) ;
2014-02-10 01:10:30 +00:00
file - > store_32 ( len ) ;
2017-03-05 15:44:50 +00:00
file - > store_buffer ( buff . ptr ( ) , buff . size ( ) ) ;
2014-02-10 01:10:30 +00:00
}
}
file - > close ( ) ;
memdelete ( file ) ;
return OK ;
}
2021-05-04 12:20:36 +00:00
Error ProjectSettings : : _save_settings_text ( const String & p_file , const Map < String , List < String > > & props , const CustomMap & p_custom , const String & p_custom_features ) {
2014-02-10 01:10:30 +00:00
Error err ;
2017-03-05 15:44:50 +00:00
FileAccess * file = FileAccess : : open ( p_file , FileAccess : : WRITE , & err ) ;
2014-02-10 01:10:30 +00:00
2019-08-15 02:57:49 +00:00
ERR_FAIL_COND_V_MSG ( err ! = OK , err , " Couldn't save project.godot - " + p_file + " . " ) ;
2014-02-10 01:10:30 +00:00
2017-07-26 13:28:54 +00:00
file - > store_line ( " ; Engine configuration file. " ) ;
file - > store_line ( " ; It's best edited using the editor UI and not directly, " ) ;
file - > store_line ( " ; since the parameters that go here are not all obvious. " ) ;
2017-10-09 06:34:32 +00:00
file - > store_line ( " ; " ) ;
file - > store_line ( " ; Format: " ) ;
2017-07-26 13:28:54 +00:00
file - > store_line ( " ; [section] ; section goes between [] " ) ;
file - > store_line ( " ; param=value ; assign values to parameters " ) ;
file - > store_line ( " " ) ;
2018-12-21 11:20:48 +00:00
file - > store_string ( " config_version= " + itos ( CONFIG_VERSION ) + " \n " ) ;
2021-05-05 10:44:11 +00:00
if ( p_custom_features ! = String ( ) ) {
2017-07-25 19:02:38 +00:00
file - > store_string ( " custom_features= \" " + p_custom_features + " \" \n " ) ;
2021-05-05 10:44:11 +00:00
}
2017-07-25 19:02:38 +00:00
file - > store_string ( " \n " ) ;
2017-02-05 00:02:52 +00:00
2021-05-04 12:20:36 +00:00
for ( Map < String , List < String > > : : Element * E = props . front ( ) ; E ; E = E - > next ( ) ) {
2021-05-05 10:44:11 +00:00
if ( E ! = props . front ( ) ) {
2014-02-10 01:10:30 +00:00
file - > store_string ( " \n " ) ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( E - > key ( ) ! = " " ) {
2017-03-05 15:44:50 +00:00
file - > store_string ( " [ " + E - > key ( ) + " ] \n \n " ) ;
2021-05-05 10:44:11 +00:00
}
2017-03-05 15:44:50 +00:00
for ( List < String > : : Element * F = E - > get ( ) . front ( ) ; F ; F = F - > next ( ) ) {
2014-02-10 01:10:30 +00:00
String key = F - > get ( ) ;
2021-05-05 10:44:11 +00:00
if ( E - > key ( ) ! = " " ) {
2017-03-05 15:44:50 +00:00
key = E - > key ( ) + " / " + key ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
Variant value ;
2021-05-05 10:44:11 +00:00
if ( p_custom . has ( key ) ) {
2017-03-05 15:44:50 +00:00
value = p_custom [ key ] ;
2021-05-05 10:44:11 +00:00
} else {
2014-02-10 01:10:30 +00:00
value = get ( key ) ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2017-01-11 19:15:40 +00:00
String vstr ;
2017-03-05 15:44:50 +00:00
VariantWriter : : write_to_string ( value , vstr ) ;
2019-12-20 02:03:15 +00:00
file - > store_string ( F - > get ( ) . property_name_encode ( ) + " = " + vstr + " \n " ) ;
2014-02-10 01:10:30 +00:00
}
}
file - > close ( ) ;
memdelete ( file ) ;
return OK ;
}
2015-06-30 14:28:43 +00:00
2017-07-19 20:00:46 +00:00
Error ProjectSettings : : _save_custom_bnd ( const String & p_file ) { // add other params as dictionary and array?
2015-06-30 14:28:43 +00:00
return save_custom ( p_file ) ;
} ;
2017-07-26 13:28:54 +00:00
Error ProjectSettings : : save_custom ( const String & p_path , const CustomMap & p_custom , const Vector < String > & p_custom_features , bool p_merge_with_current ) {
2019-09-25 08:28:50 +00:00
ERR_FAIL_COND_V_MSG ( p_path = = " " , ERR_INVALID_PARAMETER , " Project settings save path cannot be empty. " ) ;
2014-02-10 01:10:30 +00:00
Set < _VCSort > vclist ;
2017-07-26 13:28:54 +00:00
if ( p_merge_with_current ) {
for ( Map < StringName , VariantContainer > : : Element * G = props . front ( ) ; G ; G = G - > next ( ) ) {
const VariantContainer * v = & G - > get ( ) ;
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( v - > hide_from_editor ) {
2017-07-26 13:28:54 +00:00
continue ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2021-05-05 10:44:11 +00:00
if ( p_custom . has ( G - > key ( ) ) ) {
2017-07-26 13:28:54 +00:00
continue ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2017-07-26 13:28:54 +00:00
_VCSort vc ;
vc . name = G - > key ( ) ; //*k;
vc . order = v - > order ;
vc . type = v - > variant . get_type ( ) ;
vc . flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE ;
2021-05-05 10:44:11 +00:00
if ( v - > variant = = v - > initial ) {
2017-07-26 13:28:54 +00:00
continue ;
2021-05-05 10:44:11 +00:00
}
2014-02-10 01:10:30 +00:00
2017-07-26 13:28:54 +00:00
vclist . insert ( vc ) ;
}
2014-02-10 01:10:30 +00:00
}
2017-03-05 15:44:50 +00:00
for ( const Map < String , Variant > : : Element * E = p_custom . front ( ) ; E ; E = E - > next ( ) ) {
2017-07-26 13:28:54 +00:00
// Lookup global prop to store in the same order
Map < StringName , VariantContainer > : : Element * global_prop = props . find ( E - > key ( ) ) ;
2014-02-10 01:10:30 +00:00
_VCSort vc ;
2017-03-05 15:44:50 +00:00
vc . name = E - > key ( ) ;
2017-07-26 13:28:54 +00:00
vc . order = global_prop ? global_prop - > get ( ) . order : 0xFFFFFFF ;
2017-03-05 15:44:50 +00:00
vc . type = E - > get ( ) . get_type ( ) ;
vc . flags = PROPERTY_USAGE_STORAGE ;
2014-02-10 01:10:30 +00:00
vclist . insert ( vc ) ;
}
2021-05-04 12:20:36 +00:00
Map < String , List < String > > props ;
2014-02-10 01:10:30 +00:00
2017-03-05 15:44:50 +00:00
for ( Set < _VCSort > : : Element * E = vclist . front ( ) ; E ; E = E - > next ( ) ) {
2014-02-10 01:10:30 +00:00
String category = E - > get ( ) . name ;
String name = E - > get ( ) . name ;
int div = category . find ( " / " ) ;
2021-05-05 10:44:11 +00:00
if ( div < 0 ) {
2017-03-05 15:44:50 +00:00
category = " " ;
2021-05-05 10:44:11 +00:00
} else {
2017-03-05 15:44:50 +00:00
category = category . substr ( 0 , div ) ;
name = name . substr ( div + 1 , name . size ( ) ) ;
2014-02-10 01:10:30 +00:00
}
props [ category ] . push_back ( name ) ;
}
2017-07-19 20:00:46 +00:00
String custom_features ;
for ( int i = 0 ; i < p_custom_features . size ( ) ; i + + ) {
2021-05-05 10:44:11 +00:00
if ( i > 0 ) {
2017-07-19 20:00:46 +00:00
custom_features + = " , " ;
2021-05-05 10:44:11 +00:00
}
2017-07-19 20:00:46 +00:00
String f = p_custom_features [ i ] . strip_edges ( ) . replace ( " \" " , " " ) ;
custom_features + = f ;
}
2021-02-24 15:37:29 +00:00
if ( p_path . ends_with ( " .godot " ) | | p_path . ends_with ( " override.cfg " ) ) {
2017-07-19 20:00:46 +00:00
return _save_settings_text ( p_path , props , p_custom , custom_features ) ;
2021-02-24 15:37:29 +00:00
} else if ( p_path . ends_with ( " .binary " ) ) {
2017-07-19 20:00:46 +00:00
return _save_settings_binary ( p_path , props , p_custom , custom_features ) ;
2021-02-24 15:37:29 +00:00
} else {
2019-08-15 02:57:49 +00:00
ERR_FAIL_V_MSG ( ERR_FILE_UNRECOGNIZED , " Unknown config file format: " + p_path + " . " ) ;
2014-02-10 01:10:30 +00:00
}
}
2021-03-09 15:16:24 +00:00
Variant _GLOBAL_DEF_ALIAS ( const String & p_var , const String & p_old_name , const Variant & p_default , bool p_restart_if_changed ) {
// if the new name setting isn't present, try the old one
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( p_var ) ) {
if ( ProjectSettings : : get_singleton ( ) - > has_setting ( p_old_name ) ) {
// if the old setting is present, get the value and set it in the new setting
Variant value = ProjectSettings : : get_singleton ( ) - > get ( p_old_name ) ;
ProjectSettings : : get_singleton ( ) - > set ( p_var , value ) ;
}
}
return _GLOBAL_DEF ( p_var , p_default , p_restart_if_changed ) ;
}
2021-10-10 20:40:32 +00:00
Variant _GLOBAL_DEF ( const String & p_var , const Variant & p_default , bool p_restart_if_changed , bool p_ignore_value_in_docs ) {
2017-07-18 00:05:38 +00:00
Variant ret ;
2018-02-25 20:05:40 +00:00
if ( ! ProjectSettings : : get_singleton ( ) - > has_setting ( p_var ) ) {
2017-07-19 20:00:46 +00:00
ProjectSettings : : get_singleton ( ) - > set ( p_var , p_default ) ;
2017-01-05 12:16:00 +00:00
}
2018-02-25 20:05:40 +00:00
ret = ProjectSettings : : get_singleton ( ) - > get ( p_var ) ;
2017-07-19 20:00:46 +00:00
ProjectSettings : : get_singleton ( ) - > set_initial_value ( p_var , p_default ) ;
ProjectSettings : : get_singleton ( ) - > set_builtin_order ( p_var ) ;
2018-07-19 21:58:15 +00:00
ProjectSettings : : get_singleton ( ) - > set_restart_if_changed ( p_var , p_restart_if_changed ) ;
2021-10-10 20:40:32 +00:00
ProjectSettings : : get_singleton ( ) - > set_ignore_value_in_docs ( p_var , p_ignore_value_in_docs ) ;
2017-07-18 00:05:38 +00:00
return ret ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
Vector < String > ProjectSettings : : get_optimizer_presets ( ) const {
2014-02-10 01:10:30 +00:00
List < PropertyInfo > pi ;
2017-07-19 20:00:46 +00:00
ProjectSettings : : get_singleton ( ) - > get_property_list ( & pi ) ;
2014-02-10 01:10:30 +00:00
Vector < String > names ;
2017-03-05 15:44:50 +00:00
for ( List < PropertyInfo > : : Element * E = pi . front ( ) ; E ; E = E - > next ( ) ) {
2021-05-05 10:44:11 +00:00
if ( ! E - > get ( ) . name . begins_with ( " optimizer_presets/ " ) ) {
2014-02-10 01:10:30 +00:00
continue ;
2021-05-05 10:44:11 +00:00
}
2017-03-05 15:44:50 +00:00
names . push_back ( E - > get ( ) . name . get_slicec ( ' / ' , 1 ) ) ;
2014-02-10 01:10:30 +00:00
}
names . sort ( ) ;
return names ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : _add_property_info_bind ( const Dictionary & p_info ) {
2016-08-16 20:10:53 +00:00
ERR_FAIL_COND ( ! p_info . has ( " name " ) ) ;
ERR_FAIL_COND ( ! p_info . has ( " type " ) ) ;
PropertyInfo pinfo ;
pinfo . name = p_info [ " name " ] ;
ERR_FAIL_COND ( ! props . has ( pinfo . name ) ) ;
pinfo . type = Variant : : Type ( p_info [ " type " ] . operator int ( ) ) ;
ERR_FAIL_INDEX ( pinfo . type , Variant : : VARIANT_MAX ) ;
2021-05-05 10:44:11 +00:00
if ( p_info . has ( " hint " ) ) {
2016-08-16 20:10:53 +00:00
pinfo . hint = PropertyHint ( p_info [ " hint " ] . operator int ( ) ) ;
2021-05-05 10:44:11 +00:00
}
if ( p_info . has ( " hint_string " ) ) {
2016-08-16 20:10:53 +00:00
pinfo . hint_string = p_info [ " hint_string " ] ;
2021-05-05 10:44:11 +00:00
}
2016-08-16 20:10:53 +00:00
set_custom_property_info ( pinfo . name , pinfo ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_custom_property_info ( const String & p_prop , const PropertyInfo & p_info ) {
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND ( ! props . has ( p_prop ) ) ;
2017-03-05 15:44:50 +00:00
custom_prop_info [ p_prop ] = p_info ;
custom_prop_info [ p_prop ] . name = p_prop ;
2014-02-10 01:10:30 +00:00
}
2018-05-26 18:19:38 +00:00
const Map < StringName , PropertyInfo > & ProjectSettings : : get_custom_property_info ( ) const {
return custom_prop_info ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : set_disable_feature_overrides ( bool p_disable ) {
disable_feature_overrides = p_disable ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
bool ProjectSettings : : is_using_datapack ( ) const {
2014-02-19 14:57:14 +00:00
return using_datapack ;
}
2014-02-10 01:10:30 +00:00
2017-07-19 20:00:46 +00:00
bool ProjectSettings : : property_can_revert ( const String & p_name ) {
2021-05-05 10:44:11 +00:00
if ( ! props . has ( p_name ) ) {
2017-01-05 12:16:00 +00:00
return false ;
2021-05-05 10:44:11 +00:00
}
2017-01-05 12:16:00 +00:00
2017-03-05 15:44:50 +00:00
return props [ p_name ] . initial ! = props [ p_name ] . variant ;
2017-01-05 12:16:00 +00:00
}
2017-07-19 20:00:46 +00:00
Variant ProjectSettings : : property_get_revert ( const String & p_name ) {
2021-05-05 10:44:11 +00:00
if ( ! props . has ( p_name ) ) {
2017-01-05 12:16:00 +00:00
return Variant ( ) ;
2021-05-05 10:44:11 +00:00
}
2017-01-05 12:16:00 +00:00
return props [ p_name ] . initial ;
}
2017-01-03 02:03:46 +00:00
2017-10-05 18:34:34 +00:00
void ProjectSettings : : set_setting ( const String & p_setting , const Variant & p_value ) {
set ( p_setting , p_value ) ;
}
Variant ProjectSettings : : get_setting ( const String & p_setting ) const {
return get ( p_setting ) ;
}
2018-07-18 08:22:59 +00:00
bool ProjectSettings : : has_custom_feature ( const String & p_feature ) const {
return custom_features . has ( p_feature ) ;
}
2017-07-19 20:00:46 +00:00
void ProjectSettings : : _bind_methods ( ) {
2017-10-05 18:34:34 +00:00
ClassDB : : bind_method ( D_METHOD ( " has_setting " , " name " ) , & ProjectSettings : : has_setting ) ;
ClassDB : : bind_method ( D_METHOD ( " set_setting " , " name " , " value " ) , & ProjectSettings : : set_setting ) ;
ClassDB : : bind_method ( D_METHOD ( " get_setting " , " name " ) , & ProjectSettings : : get_setting ) ;
2017-09-10 13:37:49 +00:00
ClassDB : : bind_method ( D_METHOD ( " set_order " , " name " , " position " ) , & ProjectSettings : : set_order ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " get_order " , " name " ) , & ProjectSettings : : get_order ) ;
ClassDB : : bind_method ( D_METHOD ( " set_initial_value " , " name " , " value " ) , & ProjectSettings : : set_initial_value ) ;
ClassDB : : bind_method ( D_METHOD ( " add_property_info " , " hint " ) , & ProjectSettings : : _add_property_info_bind ) ;
ClassDB : : bind_method ( D_METHOD ( " clear " , " name " ) , & ProjectSettings : : clear ) ;
ClassDB : : bind_method ( D_METHOD ( " localize_path " , " path " ) , & ProjectSettings : : localize_path ) ;
ClassDB : : bind_method ( D_METHOD ( " globalize_path " , " path " ) , & ProjectSettings : : globalize_path ) ;
ClassDB : : bind_method ( D_METHOD ( " save " ) , & ProjectSettings : : save ) ;
2020-07-13 16:22:06 +00:00
ClassDB : : bind_method ( D_METHOD ( " load_resource_pack " , " pack " , " replace_files " , " offset " ) , & ProjectSettings : : _load_resource_pack , DEFVAL ( true ) , DEFVAL ( 0 ) ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " property_can_revert " , " name " ) , & ProjectSettings : : property_can_revert ) ;
2017-08-09 11:19:41 +00:00
ClassDB : : bind_method ( D_METHOD ( " property_get_revert " , " name " ) , & ProjectSettings : : property_get_revert ) ;
2017-07-19 20:00:46 +00:00
ClassDB : : bind_method ( D_METHOD ( " save_custom " , " file " ) , & ProjectSettings : : _save_custom_bnd ) ;
2021-10-01 10:47:28 +00:00
ADD_SIGNAL ( MethodInfo ( " project_settings_changed " ) ) ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
ProjectSettings : : ProjectSettings ( ) {
2020-07-13 11:38:35 +00:00
// Initialization of engine variables should be done in the setup() method,
// so that the values can be overridden from project.godot or project.binary.
2016-03-08 23:00:52 +00:00
2017-03-05 15:44:50 +00:00
singleton = this ;
2017-07-18 00:05:38 +00:00
last_order = NO_BUILTIN_ORDER_BASE ;
last_builtin_order = 0 ;
2017-07-19 20:00:46 +00:00
disable_feature_overrides = false ;
2017-03-05 15:44:50 +00:00
registering_order = true ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
Array events ;
Dictionary action ;
2017-05-20 15:38:03 +00:00
Ref < InputEventKey > key ;
Ref < InputEventJoypadButton > joyb ;
2014-02-10 01:10:30 +00:00
2017-07-18 00:05:38 +00:00
GLOBAL_DEF ( " application/config/name " , " " ) ;
2019-08-17 16:20:17 +00:00
GLOBAL_DEF ( " application/config/description " , " " ) ;
custom_prop_info [ " application/config/description " ] = PropertyInfo ( Variant : : STRING , " application/config/description " , PROPERTY_HINT_MULTILINE_TEXT ) ;
2017-07-18 00:05:38 +00:00
GLOBAL_DEF ( " application/run/main_scene " , " " ) ;
2018-07-26 09:48:12 +00:00
custom_prop_info [ " application/run/main_scene " ] = PropertyInfo ( Variant : : STRING , " application/run/main_scene " , PROPERTY_HINT_FILE , " *.tscn,*.scn,*.res " ) ;
2017-07-18 00:05:38 +00:00
GLOBAL_DEF ( " application/run/disable_stdout " , false ) ;
GLOBAL_DEF ( " application/run/disable_stderr " , false ) ;
2021-10-13 20:16:52 +00:00
GLOBAL_DEF_RST ( " application/config/use_hidden_project_data_directory " , true ) ;
2017-11-26 18:00:53 +00:00
GLOBAL_DEF ( " application/config/use_custom_user_dir " , false ) ;
GLOBAL_DEF ( " application/config/custom_user_dir_name " , " " ) ;
2018-11-18 13:56:21 +00:00
GLOBAL_DEF ( " application/config/project_settings_override " , " " ) ;
2022-05-12 14:38:59 +00:00
GLOBAL_DEF ( " display/window/size/width " , 1024 ) ;
ProjectSettings : : get_singleton ( ) - > set_custom_property_info ( " display/window/size/width " , PropertyInfo ( Variant : : INT , " display/window/size/width " , PROPERTY_HINT_RANGE , " 0,7680,1,or_greater " ) ) ; // 8K resolution
GLOBAL_DEF ( " display/window/size/height " , 600 ) ;
ProjectSettings : : get_singleton ( ) - > set_custom_property_info ( " display/window/size/height " , PropertyInfo ( Variant : : INT , " display/window/size/height " , PROPERTY_HINT_RANGE , " 0,4320,1,or_greater " ) ) ; // 8K resolution
GLOBAL_DEF ( " display/window/size/resizable " , true ) ;
GLOBAL_DEF ( " display/window/size/borderless " , false ) ;
GLOBAL_DEF ( " display/window/size/fullscreen " , false ) ;
GLOBAL_DEF ( " display/window/size/always_on_top " , false ) ;
GLOBAL_DEF ( " display/window/size/test_width " , 0 ) ;
ProjectSettings : : get_singleton ( ) - > set_custom_property_info ( " display/window/size/test_width " , PropertyInfo ( Variant : : INT , " display/window/size/test_width " , PROPERTY_HINT_RANGE , " 0,7680,1,or_greater " ) ) ; // 8K resolution
GLOBAL_DEF ( " display/window/size/test_height " , 0 ) ;
ProjectSettings : : get_singleton ( ) - > set_custom_property_info ( " display/window/size/test_height " , PropertyInfo ( Variant : : INT , " display/window/size/test_height " , PROPERTY_HINT_RANGE , " 0,4320,1,or_greater " ) ) ; // 8K resolution
2019-04-05 15:19:25 +00:00
GLOBAL_DEF ( " audio/default_bus_layout " , " res://default_bus_layout.tres " ) ;
custom_prop_info [ " audio/default_bus_layout " ] = PropertyInfo ( Variant : : STRING , " audio/default_bus_layout " , PROPERTY_HINT_FILE , " *.tres " ) ;
2022-08-18 15:34:12 +00:00
GLOBAL_DEF_RST ( " audio/2d_panning_strength " , 1.0f ) ;
custom_prop_info [ " audio/2d_panning_strength " ] = PropertyInfo ( Variant : : REAL , " audio/2d_panning_strength " , PROPERTY_HINT_RANGE , " 0,4,0.01 " ) ;
GLOBAL_DEF_RST ( " audio/3d_panning_strength " , 1.0f ) ;
custom_prop_info [ " audio/3d_panning_strength " ] = PropertyInfo ( Variant : : REAL , " audio/3d_panning_strength " , PROPERTY_HINT_RANGE , " 0,4,0.01 " ) ;
2014-02-10 01:10:30 +00:00
2019-02-04 21:59:51 +00:00
PoolStringArray extensions = PoolStringArray ( ) ;
extensions . push_back ( " gd " ) ;
2021-05-05 10:44:11 +00:00
if ( Engine : : get_singleton ( ) - > has_singleton ( " GodotSharp " ) ) {
2019-02-04 21:59:51 +00:00
extensions . push_back ( " cs " ) ;
2021-05-05 10:44:11 +00:00
}
2021-06-29 05:13:05 +00:00
extensions . push_back ( " gdshader " ) ;
2019-02-04 21:59:51 +00:00
extensions . push_back ( " shader " ) ;
2020-02-07 18:51:50 +00:00
GLOBAL_DEF ( " editor/main_run_args " , " " ) ;
2022-06-19 09:42:54 +00:00
GLOBAL_DEF ( " editor/scene_naming " , 0 ) ; // Sync enum values with EditorNode.
ProjectSettings : : get_singleton ( ) - > set_custom_property_info ( " editor/scene_naming " , PropertyInfo ( Variant : : INT , " editor/scene_naming " , PROPERTY_HINT_ENUM , " Auto,PascalCase,snake_case " ) ) ;
2019-02-04 21:59:51 +00:00
GLOBAL_DEF ( " editor/search_in_file_extensions " , extensions ) ;
custom_prop_info [ " editor/search_in_file_extensions " ] = PropertyInfo ( Variant : : POOL_STRING_ARRAY , " editor/search_in_file_extensions " ) ;
2019-08-22 15:59:43 +00:00
GLOBAL_DEF ( " editor/script_templates_search_path " , " res://script_templates " ) ;
custom_prop_info [ " editor/script_templates_search_path " ] = PropertyInfo ( Variant : : STRING , " editor/script_templates_search_path " , PROPERTY_HINT_DIR ) ;
2022-06-19 09:42:54 +00:00
GLOBAL_DEF ( " editor/version_control_autoload_on_startup " , false ) ;
GLOBAL_DEF ( " editor/version_control_plugin_name " , " " ) ;
2020-06-25 09:59:31 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
2017-08-06 13:26:07 +00:00
key - > set_scancode ( KEY_ENTER ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
2017-08-06 13:26:07 +00:00
key - > set_scancode ( KEY_KP_ENTER ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_SPACE ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_BUTTON_0 ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_accept " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_accept " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_SPACE ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_BUTTON_3 ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_select " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_select " ) ;
2015-06-06 12:44:38 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_ESCAPE ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_BUTTON_1 ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_cancel " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_cancel " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_TAB ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_focus_next " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_focus_next " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_TAB ) ;
key - > set_shift ( true ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_focus_prev " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_focus_prev " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_LEFT ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_DPAD_LEFT ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_left " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_left " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_RIGHT ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_DPAD_RIGHT ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_right " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_right " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_UP ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_DPAD_UP ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_up " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_up " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_DOWN ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
2017-05-20 15:38:03 +00:00
joyb . instance ( ) ;
joyb - > set_button_index ( JOY_DPAD_DOWN ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( joyb ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_down " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_down " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_PAGEUP ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_page_up " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_page_up " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2017-05-20 15:38:03 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_PAGEDOWN ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_page_down " , action ) ;
2015-12-14 21:36:53 +00:00
input_presets . push_back ( " input/ui_page_down " ) ;
2014-02-10 01:10:30 +00:00
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2018-02-23 11:17:15 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_HOME ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_home " , action ) ;
2018-02-23 11:17:15 +00:00
input_presets . push_back ( " input/ui_home " ) ;
2018-08-14 16:44:22 +00:00
action = Dictionary ( ) ;
action [ " deadzone " ] = Variant ( 0.5f ) ;
events = Array ( ) ;
2018-02-23 11:17:15 +00:00
key . instance ( ) ;
key - > set_scancode ( KEY_END ) ;
2018-08-14 16:44:22 +00:00
events . push_back ( key ) ;
action [ " events " ] = events ;
GLOBAL_DEF ( " input/ui_end " , action ) ;
2018-02-23 11:17:15 +00:00
input_presets . push_back ( " input/ui_end " ) ;
2017-07-18 00:05:38 +00:00
custom_prop_info [ " display/window/handheld/orientation " ] = PropertyInfo ( Variant : : STRING , " display/window/handheld/orientation " , PROPERTY_HINT_ENUM , " landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor " ) ;
2017-03-05 15:44:50 +00:00
custom_prop_info [ " rendering/threads/thread_model " ] = PropertyInfo ( Variant : : INT , " rendering/threads/thread_model " , PROPERTY_HINT_ENUM , " Single-Unsafe,Single-Safe,Multi-Threaded " ) ;
custom_prop_info [ " physics/2d/thread_model " ] = PropertyInfo ( Variant : : INT , " physics/2d/thread_model " , PROPERTY_HINT_ENUM , " Single-Unsafe,Single-Safe,Multi-Threaded " ) ;
2017-07-19 20:00:46 +00:00
custom_prop_info [ " rendering/quality/intended_usage/framebuffer_allocation " ] = PropertyInfo ( Variant : : INT , " rendering/quality/intended_usage/framebuffer_allocation " , PROPERTY_HINT_ENUM , " 2D,2D Without Sampling,3D,3D Without Effects " ) ;
2014-02-10 01:10:30 +00:00
2022-03-02 00:10:18 +00:00
// Required to make the project setting appear even if the physics engine is GodotPhysics,
// while also making it appear in the ProjectSettings class documentation.
GLOBAL_DEF ( " physics/3d/smooth_trimesh_collision " , false ) ;
2021-03-27 17:58:12 +00:00
GLOBAL_DEF ( " rendering/quality/filters/sharpen_intensity " , 0.0 ) ;
custom_prop_info [ " rendering/quality/filters/sharpen_intensity " ] = PropertyInfo ( Variant : : REAL , " rendering/quality/filters/sharpen_intensity " , PROPERTY_HINT_RANGE , " 0,1 " ) ;
2017-07-18 00:05:38 +00:00
GLOBAL_DEF ( " debug/settings/profiler/max_functions " , 16384 ) ;
2018-10-05 16:43:53 +00:00
custom_prop_info [ " debug/settings/profiler/max_functions " ] = PropertyInfo ( Variant : : INT , " debug/settings/profiler/max_functions " , PROPERTY_HINT_RANGE , " 128,65535,1 " ) ;
2017-06-12 01:27:07 +00:00
2020-07-13 11:38:35 +00:00
GLOBAL_DEF ( " compression/formats/zstd/long_distance_matching " , Compression : : zstd_long_distance_matching ) ;
2017-10-26 20:42:02 +00:00
custom_prop_info [ " compression/formats/zstd/long_distance_matching " ] = PropertyInfo ( Variant : : BOOL , " compression/formats/zstd/long_distance_matching " ) ;
2020-07-13 11:38:35 +00:00
GLOBAL_DEF ( " compression/formats/zstd/compression_level " , Compression : : zstd_level ) ;
2017-07-18 00:05:38 +00:00
custom_prop_info [ " compression/formats/zstd/compression_level " ] = PropertyInfo ( Variant : : INT , " compression/formats/zstd/compression_level " , PROPERTY_HINT_RANGE , " 1,22,1 " ) ;
2020-07-13 11:38:35 +00:00
GLOBAL_DEF ( " compression/formats/zstd/window_log_size " , Compression : : zstd_window_log_size ) ;
2017-10-26 20:42:02 +00:00
custom_prop_info [ " compression/formats/zstd/window_log_size " ] = PropertyInfo ( Variant : : INT , " compression/formats/zstd/window_log_size " , PROPERTY_HINT_RANGE , " 10,30,1 " ) ;
2020-07-13 11:38:35 +00:00
GLOBAL_DEF ( " compression/formats/zlib/compression_level " , Compression : : zlib_level ) ;
2017-07-18 00:05:38 +00:00
custom_prop_info [ " compression/formats/zlib/compression_level " ] = PropertyInfo ( Variant : : INT , " compression/formats/zlib/compression_level " , PROPERTY_HINT_RANGE , " -1,9,1 " ) ;
2017-10-26 20:42:02 +00:00
2020-07-13 11:38:35 +00:00
GLOBAL_DEF ( " compression/formats/gzip/compression_level " , Compression : : gzip_level ) ;
2017-07-18 00:05:38 +00:00
custom_prop_info [ " compression/formats/gzip/compression_level " ] = PropertyInfo ( Variant : : INT , " compression/formats/gzip/compression_level " , PROPERTY_HINT_RANGE , " -1,9,1 " ) ;
2017-06-12 01:27:07 +00:00
2019-03-07 09:40:44 +00:00
// Would ideally be defined in an Android-specific file, but then it doesn't appear in the docs
GLOBAL_DEF ( " android/modules " , " " ) ;
2017-03-05 15:44:50 +00:00
using_datapack = false ;
2014-02-10 01:10:30 +00:00
}
2017-07-19 20:00:46 +00:00
ProjectSettings : : ~ ProjectSettings ( ) {
2021-05-04 14:00:45 +00:00
singleton = nullptr ;
2014-02-10 01:10:30 +00:00
}