Allow configuring the script filename casing rule
Defaults to "Auto", which detects the casing based on the preference of the currently selected language (C# for example prefers PascalCase whereas GDScript prefers snake_case).
This commit is contained in:
parent
a07dd0d6a5
commit
2bd714e34e
15 changed files with 103 additions and 57 deletions
|
|
@ -535,6 +535,13 @@ TypedArray<int> ScriptLanguage::CodeCompletionOption::get_option_cached_characte
|
|||
return charac;
|
||||
}
|
||||
|
||||
void ScriptLanguage::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(SCRIPT_NAME_CASING_AUTO);
|
||||
BIND_ENUM_CONSTANT(SCRIPT_NAME_CASING_PASCAL_CASE);
|
||||
BIND_ENUM_CONSTANT(SCRIPT_NAME_CASING_SNAKE_CASE);
|
||||
BIND_ENUM_CONSTANT(SCRIPT_NAME_CASING_KEBAB_CASE);
|
||||
}
|
||||
|
||||
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
|
||||
if (script->is_placeholder_fallback_enabled()) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@ public:
|
|||
|
||||
class ScriptLanguage : public Object {
|
||||
GDCLASS(ScriptLanguage, Object)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_name() const = 0;
|
||||
|
||||
|
|
@ -224,6 +228,13 @@ public:
|
|||
TEMPLATE_PROJECT
|
||||
};
|
||||
|
||||
enum ScriptNameCasing {
|
||||
SCRIPT_NAME_CASING_AUTO,
|
||||
SCRIPT_NAME_CASING_PASCAL_CASE,
|
||||
SCRIPT_NAME_CASING_SNAKE_CASE,
|
||||
SCRIPT_NAME_CASING_KEBAB_CASE,
|
||||
};
|
||||
|
||||
struct ScriptTemplate {
|
||||
String inherit = "Object";
|
||||
String name;
|
||||
|
|
@ -260,6 +271,7 @@ public:
|
|||
virtual bool can_make_function() const { return true; }
|
||||
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
|
||||
virtual bool overrides_external_editor() { return false; }
|
||||
virtual ScriptNameCasing preferred_file_name_casing() const { return SCRIPT_NAME_CASING_SNAKE_CASE; }
|
||||
|
||||
// Keep enums in sync with:
|
||||
// scene/gui/code_edit.h - CodeEdit::CodeCompletionKind
|
||||
|
|
@ -405,6 +417,8 @@ public:
|
|||
virtual ~ScriptLanguage() {}
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ScriptLanguage::ScriptNameCasing);
|
||||
|
||||
extern uint8_t script_encryption_key[32];
|
||||
|
||||
class PlaceHolderScriptInstance : public ScriptInstance {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ void ScriptLanguageExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_can_make_function);
|
||||
GDVIRTUAL_BIND(_open_in_external_editor, "script", "line", "column");
|
||||
GDVIRTUAL_BIND(_overrides_external_editor);
|
||||
GDVIRTUAL_BIND(_preferred_file_name_casing);
|
||||
|
||||
GDVIRTUAL_BIND(_complete_code, "code", "path", "owner");
|
||||
GDVIRTUAL_BIND(_lookup_code, "code", "symbol", "path", "owner");
|
||||
|
|
|
|||
|
|
@ -376,6 +376,7 @@ public:
|
|||
EXBIND0RC(bool, can_make_function)
|
||||
EXBIND3R(Error, open_in_external_editor, const Ref<Script> &, int, int)
|
||||
EXBIND0R(bool, overrides_external_editor)
|
||||
EXBIND0RC(ScriptNameCasing, preferred_file_name_casing)
|
||||
|
||||
GDVIRTUAL3RC(Dictionary, _complete_code, const String &, const String &, Object *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue