module Godot::EditorScriptCreation

Defined in:

libgodot/editor_script_creation.cr

Constant Summary

COMMON_BASE_TYPES = ["Node", "Node2D", "Node3D", "CharacterBody3D", "CharacterBody2D", "Control", "Camera3D", "Area3D", "Area2D", "RigidBody3D", "RigidBody2D", "Resource", "RefCounted"]
ID_CRYSTAL_SCRIPT = 889901_i64
ID_SCENE_ATTACH = 889902_i64
TEMPLATES = ["Standard Node (_ready & _process)", "Physics Movement (CharacterBody)", "Tool Script (@[Tool] In-Editor Execution)", "Empty Class"]

Class Method Summary

Class Method Detail

def self.adapt_script_create_dialog_path(scd : Node) : Void #

Adapts the file path inside a native ScriptCreateDialog to ensure a clean .cr extension when Crystal is selected


[View source]
def self.cleanup : Void #

[View source]
def self.cleanup_on_shutdown : Void #

[View source]
def self.ensure_cr_extension(path : String) : String #

Normalizes a path to end with exactly one .cr extension, stripping duplicate dots or other extensions


[View source]
def self.find_all_children(parent : Node, type_name : String) : Array(Node) #

Recursively discovers all child nodes matching the specified Godot class name


[View source]
def self.fix_script_create_dialog(scd : Node) : Void #

Repairs a Godot native ScriptCreateDialog's language menu:

  • Updates index 1 (CrystalLanguage) text to "Crystal" and sets official Crystal icon
  • Prunes any out-of-bounds surplus items (count must never exceed ScriptServer language count)
  • Ensures valid selection index so it never shows broken red icon or empty fields
  • Sets up live path adaptation when language is switched

[View source]
def self.generate_template_code(class_name : String, base_type : String, tmpl_idx : Int64) : String #

[View source]
def self.get_create_dialog_selected_type(cd : Node) : String #

Retrieves the selected type from a Godot CreateDialog by inspecting its Tree control


[View source]
def self.hook_create_new_submenu(fs_dock : Node, sub_node : Node) : Void #

Hooks dynamically created "Create New" submenus in FileSystemDock


[View source]
def self.setup(ed_iface : EditorInterface, base_ctrl : Control) : Void #

Sets up all editor integration entry points: toolbar button, FileSystem dock menus, SceneTree menus, and ScriptCreateDialog interception


[View source]
def self.setup_filesystem_dock_menus(ed_iface : EditorInterface) : Void #
  1. FileSystem Dock Context Menu & Create New Menu

[View source]
def self.setup_scene_tree_dock_menus(ed_iface : EditorInterface, base_ctrl : Control) : Void #
  1. SceneTree Dock Node Context Menu ("Attach/New Crystal Script...")

[View source]
def self.setup_script_create_dialog_interception(ed_iface : EditorInterface, base_ctrl : Control) : Void #

Intercepts Godot's built-in ScriptCreateDialog whenever CrystalScript is selected in "Create New Resource" (FileSystem Dock -> Create New -> Resource -> CrystalScript) and repairs native ScriptCreateDialog instances so they never show broken red icons.


[View source]
def self.setup_toolbar_button(ed_iface : EditorInterface, base_ctrl : Control) : Void #
  1. Top Toolbar "+ Script" Button

[View source]
def self.show_dialog(initial_path : String = "", default_name : String = "", default_base : String = "") : Void #
  1. Interactive Dialog Presentation

[View source]
def self.to_snake_case(str : String) : String #

Converts CamelCase to snake_case for clean Crystal file naming


[View source]