style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit. This is a baseline formatting pass to ensure consistent style: - Normalizes indentation and spacing - Wraps long lines to 100 characters - Removes trailing whitespace - Standardizes blank lines between functions 68 files reformatted, 8 files left unchanged (3rd-party addon files with parse errors excluded).
This commit is contained in:
@@ -32,13 +32,13 @@ const ES_TOOL_SETTINGS: String = "terrain3d/tool_settings/"
|
||||
const NONE: int = 0x0
|
||||
const ALLOW_LARGER: int = 0x1
|
||||
const ALLOW_SMALLER: int = 0x2
|
||||
const ALLOW_OUT_OF_BOUNDS: int = 0x3 # LARGER|SMALLER
|
||||
const ALLOW_OUT_OF_BOUNDS: int = 0x3 # LARGER|SMALLER
|
||||
const NO_LABEL: int = 0x4
|
||||
const ADD_SEPARATOR: int = 0x8 # Add a vertical line before this entry
|
||||
const ADD_SPACER: int = 0x10 # Add a space before this entry
|
||||
const NO_SAVE: int = 0x20 # Don't save this in EditorSettings
|
||||
const ADD_SEPARATOR: int = 0x8 # Add a vertical line before this entry
|
||||
const ADD_SPACER: int = 0x10 # Add a space before this entry
|
||||
const NO_SAVE: int = 0x20 # Don't save this in EditorSettings
|
||||
|
||||
var plugin: EditorPlugin # Actually Terrain3DEditorPlugin, but Godot still has CRC errors
|
||||
var plugin: EditorPlugin # Actually Terrain3DEditorPlugin, but Godot still has CRC errors
|
||||
var brush_preview_material: ShaderMaterial
|
||||
var select_brush_button: Button
|
||||
var selected_brush_imgs: Array
|
||||
@@ -56,109 +56,400 @@ func _ready() -> void:
|
||||
for setting in ["lift_floor", "flatten_peaks", "lift_flatten", "automatic_regions"]:
|
||||
plugin.erase_setting(ES_TOOL_SETTINGS + setting)
|
||||
|
||||
# Setup buttons
|
||||
# Setup buttons
|
||||
main_list = HFlowContainer.new()
|
||||
add_child(main_list, true)
|
||||
|
||||
|
||||
add_brushes(main_list)
|
||||
|
||||
add_setting({ "name":"instructions", "label":"Click the terrain to add a region. CTRL+Click to remove. Or select another tool on the left.",
|
||||
"type":SettingType.LABEL, "list":main_list, "flags":NO_LABEL|NO_SAVE })
|
||||
add_setting(
|
||||
{
|
||||
"name": "instructions",
|
||||
"label":
|
||||
"Click the terrain to add a region. CTRL+Click to remove. Or select another tool on the left.",
|
||||
"type": SettingType.LABEL,
|
||||
"list": main_list,
|
||||
"flags": NO_LABEL | NO_SAVE
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"size", "type":SettingType.SLIDER, "list":main_list, "default":20, "unit":"m",
|
||||
"range":Vector3(0.1, 200, 1), "flags":ALLOW_LARGER|ADD_SPACER })
|
||||
|
||||
add_setting({ "name":"strength", "type":SettingType.SLIDER, "list":main_list, "default":33,
|
||||
"unit":"%", "range":Vector3(1, 100, 1), "flags":ALLOW_LARGER })
|
||||
add_setting(
|
||||
{
|
||||
"name": "size",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 20,
|
||||
"unit": "m",
|
||||
"range": Vector3(0.1, 200, 1),
|
||||
"flags": ALLOW_LARGER | ADD_SPACER
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"height", "type":SettingType.SLIDER, "list":main_list, "default":20,
|
||||
"unit":"m", "range":Vector3(-500, 500, 0.1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting({ "name":"height_picker", "type":SettingType.PICKER, "list":main_list,
|
||||
"default":Terrain3DEditor.HEIGHT, "flags":NO_LABEL })
|
||||
|
||||
add_setting({ "name":"color", "type":SettingType.COLOR_SELECT, "list":main_list,
|
||||
"default":Color.WHITE, "flags":ADD_SEPARATOR })
|
||||
add_setting({ "name":"color_picker", "type":SettingType.PICKER, "list":main_list,
|
||||
"default":Terrain3DEditor.COLOR, "flags":NO_LABEL })
|
||||
add_setting(
|
||||
{
|
||||
"name": "strength",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 33,
|
||||
"unit": "%",
|
||||
"range": Vector3(1, 100, 1),
|
||||
"flags": ALLOW_LARGER
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"roughness", "type":SettingType.SLIDER, "list":main_list, "default":-65,
|
||||
"unit":"%", "range":Vector3(-100, 100, 1), "flags":ADD_SEPARATOR })
|
||||
add_setting({ "name":"roughness_picker", "type":SettingType.PICKER, "list":main_list,
|
||||
"default":Terrain3DEditor.ROUGHNESS, "flags":NO_LABEL })
|
||||
add_setting(
|
||||
{
|
||||
"name": "height",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 20,
|
||||
"unit": "m",
|
||||
"range": Vector3(-500, 500, 0.1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "height_picker",
|
||||
"type": SettingType.PICKER,
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.HEIGHT,
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"enable_texture", "label":"Texture", "type":SettingType.CHECKBOX,
|
||||
"list":main_list, "default":true, "flags":ADD_SEPARATOR })
|
||||
add_setting(
|
||||
{
|
||||
"name": "color",
|
||||
"type": SettingType.COLOR_SELECT,
|
||||
"list": main_list,
|
||||
"default": Color.WHITE,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "color_picker",
|
||||
"type": SettingType.PICKER,
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.COLOR,
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"texture_filter", "label":"Texture Filter", "type":SettingType.CHECKBOX,
|
||||
"list":main_list, "default":false, "flags":ADD_SEPARATOR })
|
||||
add_setting(
|
||||
{
|
||||
"name": "roughness",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": -65,
|
||||
"unit": "%",
|
||||
"range": Vector3(-100, 100, 1),
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "roughness_picker",
|
||||
"type": SettingType.PICKER,
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.ROUGHNESS,
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
|
||||
add_setting({ "name":"margin", "type":SettingType.SLIDER, "list":main_list, "default":0,
|
||||
"unit":"", "range":Vector3(-50, 50, 1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting(
|
||||
{
|
||||
"name": "enable_texture",
|
||||
"label": "Texture",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": true,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
|
||||
add_setting(
|
||||
{
|
||||
"name": "texture_filter",
|
||||
"label": "Texture Filter",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": false,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
|
||||
add_setting(
|
||||
{
|
||||
"name": "margin",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 0,
|
||||
"unit": "",
|
||||
"range": Vector3(-50, 50, 1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
|
||||
# Slope painting filter
|
||||
add_setting({ "name":"slope", "type":SettingType.DOUBLE_SLIDER, "list":main_list, "default":Vector2(0, 90),
|
||||
"unit":"°", "range":Vector3(0, 90, 1), "flags":ADD_SEPARATOR })
|
||||
|
||||
add_setting({ "name":"enable_angle", "label":"Angle", "type":SettingType.CHECKBOX,
|
||||
"list":main_list, "default":true, "flags":ADD_SEPARATOR })
|
||||
add_setting({ "name":"angle", "type":SettingType.SLIDER, "list":main_list, "default":0,
|
||||
"unit":"%", "range":Vector3(0, 337.5, 22.5), "flags":NO_LABEL })
|
||||
add_setting({ "name":"angle_picker", "type":SettingType.PICKER, "list":main_list,
|
||||
"default":Terrain3DEditor.ANGLE, "flags":NO_LABEL })
|
||||
add_setting({ "name":"dynamic_angle", "label":"Dynamic", "type":SettingType.CHECKBOX,
|
||||
"list":main_list, "default":false, "flags":ADD_SPACER })
|
||||
|
||||
add_setting({ "name":"enable_scale", "label":"Scale", "type":SettingType.CHECKBOX,
|
||||
"list":main_list, "default":true, "flags":ADD_SEPARATOR })
|
||||
add_setting({ "name":"scale", "label":"±", "type":SettingType.SLIDER, "list":main_list, "default":0,
|
||||
"unit":"%", "range":Vector3(-60, 80, 20), "flags":NO_LABEL })
|
||||
add_setting({ "name":"scale_picker", "type":SettingType.PICKER, "list":main_list,
|
||||
"default":Terrain3DEditor.SCALE, "flags":NO_LABEL })
|
||||
add_setting(
|
||||
{
|
||||
"name": "slope",
|
||||
"type": SettingType.DOUBLE_SLIDER,
|
||||
"list": main_list,
|
||||
"default": Vector2(0, 90),
|
||||
"unit": "°",
|
||||
"range": Vector3(0, 90, 1),
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
|
||||
add_setting(
|
||||
{
|
||||
"name": "enable_angle",
|
||||
"label": "Angle",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": true,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "angle",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 0,
|
||||
"unit": "%",
|
||||
"range": Vector3(0, 337.5, 22.5),
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "angle_picker",
|
||||
"type": SettingType.PICKER,
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.ANGLE,
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "dynamic_angle",
|
||||
"label": "Dynamic",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": false,
|
||||
"flags": ADD_SPACER
|
||||
}
|
||||
)
|
||||
|
||||
add_setting(
|
||||
{
|
||||
"name": "enable_scale",
|
||||
"label": "Scale",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": true,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "scale",
|
||||
"label": "±",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": main_list,
|
||||
"default": 0,
|
||||
"unit": "%",
|
||||
"range": Vector3(-60, 80, 20),
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "scale_picker",
|
||||
"type": SettingType.PICKER,
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.SCALE,
|
||||
"flags": NO_LABEL
|
||||
}
|
||||
)
|
||||
|
||||
## Slope sculpting brush
|
||||
add_setting({ "name":"gradient_points", "type":SettingType.MULTI_PICKER, "label":"Points",
|
||||
"list":main_list, "default":Terrain3DEditor.SCULPT, "flags":ADD_SEPARATOR })
|
||||
add_setting({ "name":"drawable", "type":SettingType.CHECKBOX, "list":main_list, "default":false,
|
||||
"flags":ADD_SEPARATOR })
|
||||
add_setting(
|
||||
{
|
||||
"name": "gradient_points",
|
||||
"type": SettingType.MULTI_PICKER,
|
||||
"label": "Points",
|
||||
"list": main_list,
|
||||
"default": Terrain3DEditor.SCULPT,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "drawable",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": false,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
settings["drawable"].toggled.connect(_on_drawable_toggled)
|
||||
|
||||
|
||||
## Instancer
|
||||
height_list = create_submenu(main_list, "Height", Layout.VERTICAL)
|
||||
add_setting({ "name":"height_offset", "type":SettingType.SLIDER, "list":height_list, "default":0,
|
||||
"unit":"m", "range":Vector3(-10, 10, 0.05), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting({ "name":"random_height", "label":"Random Height ±", "type":SettingType.SLIDER,
|
||||
"list":height_list, "default":0, "unit":"m", "range":Vector3(0, 10, 0.05),
|
||||
"flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting(
|
||||
{
|
||||
"name": "height_offset",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": height_list,
|
||||
"default": 0,
|
||||
"unit": "m",
|
||||
"range": Vector3(-10, 10, 0.05),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_height",
|
||||
"label": "Random Height ±",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": height_list,
|
||||
"default": 0,
|
||||
"unit": "m",
|
||||
"range": Vector3(0, 10, 0.05),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
|
||||
scale_list = create_submenu(main_list, "Scale", Layout.VERTICAL)
|
||||
add_setting({ "name":"fixed_scale", "type":SettingType.SLIDER, "list":scale_list, "default":100,
|
||||
"unit":"%", "range":Vector3(1, 1000, 1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting({ "name":"random_scale", "label":"Random Scale ±", "type":SettingType.SLIDER, "list":scale_list,
|
||||
"default":20, "unit":"%", "range":Vector3(0, 99, 1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting(
|
||||
{
|
||||
"name": "fixed_scale",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": scale_list,
|
||||
"default": 100,
|
||||
"unit": "%",
|
||||
"range": Vector3(1, 1000, 1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_scale",
|
||||
"label": "Random Scale ±",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": scale_list,
|
||||
"default": 20,
|
||||
"unit": "%",
|
||||
"range": Vector3(0, 99, 1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
|
||||
rotation_list = create_submenu(main_list, "Rotation", Layout.VERTICAL)
|
||||
add_setting({ "name":"fixed_spin", "label":"Fixed Spin (Around Y)", "type":SettingType.SLIDER, "list":rotation_list,
|
||||
"default":0, "unit":"°", "range":Vector3(0, 360, 1) })
|
||||
add_setting({ "name":"random_spin", "type":SettingType.SLIDER, "list":rotation_list, "default":360,
|
||||
"unit":"°", "range":Vector3(0, 360, 1) })
|
||||
add_setting({ "name":"fixed_tilt", "label":"Fixed Tilt", "type":SettingType.SLIDER, "list":rotation_list,
|
||||
"default":0, "unit":"°", "range":Vector3(-85, 85, 1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting({ "name":"random_tilt", "label":"Random Tilt ±", "type":SettingType.SLIDER, "list":rotation_list,
|
||||
"default":10, "unit":"°", "range":Vector3(0, 85, 1), "flags":ALLOW_OUT_OF_BOUNDS })
|
||||
add_setting({ "name":"align_to_normal", "type":SettingType.CHECKBOX, "list":rotation_list, "default":false })
|
||||
|
||||
add_setting(
|
||||
{
|
||||
"name": "fixed_spin",
|
||||
"label": "Fixed Spin (Around Y)",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": rotation_list,
|
||||
"default": 0,
|
||||
"unit": "°",
|
||||
"range": Vector3(0, 360, 1)
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_spin",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": rotation_list,
|
||||
"default": 360,
|
||||
"unit": "°",
|
||||
"range": Vector3(0, 360, 1)
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "fixed_tilt",
|
||||
"label": "Fixed Tilt",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": rotation_list,
|
||||
"default": 0,
|
||||
"unit": "°",
|
||||
"range": Vector3(-85, 85, 1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_tilt",
|
||||
"label": "Random Tilt ±",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": rotation_list,
|
||||
"default": 10,
|
||||
"unit": "°",
|
||||
"range": Vector3(0, 85, 1),
|
||||
"flags": ALLOW_OUT_OF_BOUNDS
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "align_to_normal",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": rotation_list,
|
||||
"default": false
|
||||
}
|
||||
)
|
||||
|
||||
color_list = create_submenu(main_list, "Color", Layout.VERTICAL)
|
||||
add_setting({ "name":"vertex_color", "type":SettingType.COLOR_SELECT, "list":color_list,
|
||||
"default":Color.WHITE })
|
||||
add_setting({ "name":"random_hue", "label":"Random Hue Shift ±", "type":SettingType.SLIDER,
|
||||
"list":color_list, "default":0, "unit":"°", "range":Vector3(0, 360, 1) })
|
||||
add_setting({ "name":"random_darken", "type":SettingType.SLIDER, "list":color_list, "default":50,
|
||||
"unit":"%", "range":Vector3(0, 100, 1) })
|
||||
#add_setting({ "name":"blend_mode", "type":SettingType.OPTION, "list":color_list, "default":0,
|
||||
#"range":Vector3(0, 3, 1) })
|
||||
add_setting(
|
||||
{
|
||||
"name": "vertex_color",
|
||||
"type": SettingType.COLOR_SELECT,
|
||||
"list": color_list,
|
||||
"default": Color.WHITE
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_hue",
|
||||
"label": "Random Hue Shift ±",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": color_list,
|
||||
"default": 0,
|
||||
"unit": "°",
|
||||
"range": Vector3(0, 360, 1)
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "random_darken",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": color_list,
|
||||
"default": 50,
|
||||
"unit": "%",
|
||||
"range": Vector3(0, 100, 1)
|
||||
}
|
||||
)
|
||||
#add_setting({ "name":"blend_mode", "type":SettingType.OPTION, "list":color_list, "default":0,
|
||||
#"range":Vector3(0, 3, 1) })
|
||||
|
||||
if DisplayServer.is_touchscreen_available():
|
||||
add_setting({ "name":"invert", "label":"Invert", "type":SettingType.CHECKBOX, "list":main_list, "default":false, "flags":ADD_SEPARATOR })
|
||||
add_setting(
|
||||
{
|
||||
"name": "invert",
|
||||
"label": "Invert",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": main_list,
|
||||
"default": false,
|
||||
"flags": ADD_SEPARATOR
|
||||
}
|
||||
)
|
||||
|
||||
var spacer: Control = Control.new()
|
||||
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
@@ -166,22 +457,67 @@ func _ready() -> void:
|
||||
|
||||
## Advanced Settings Menu
|
||||
advanced_list = create_submenu(main_list, "", Layout.VERTICAL, false)
|
||||
add_setting({ "name":"auto_regions", "label":"Add regions while sculpting", "type":SettingType.CHECKBOX,
|
||||
"list":advanced_list, "default":true })
|
||||
add_setting({ "name":"align_to_view", "type":SettingType.CHECKBOX, "list":advanced_list,
|
||||
"default":true })
|
||||
add_setting({ "name":"show_cursor_while_painting", "type":SettingType.CHECKBOX, "list":advanced_list,
|
||||
"default":true })
|
||||
add_setting(
|
||||
{
|
||||
"name": "auto_regions",
|
||||
"label": "Add regions while sculpting",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": advanced_list,
|
||||
"default": true
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "align_to_view",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": advanced_list,
|
||||
"default": true
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "show_cursor_while_painting",
|
||||
"type": SettingType.CHECKBOX,
|
||||
"list": advanced_list,
|
||||
"default": true
|
||||
}
|
||||
)
|
||||
advanced_list.add_child(HSeparator.new(), true)
|
||||
add_setting({ "name":"gamma", "type":SettingType.SLIDER, "list":advanced_list, "default":1.0,
|
||||
"unit":"γ", "range":Vector3(0.1, 2.0, 0.01) })
|
||||
add_setting({ "name":"jitter", "type":SettingType.SLIDER, "list":advanced_list, "default":50,
|
||||
"unit":"%", "range":Vector3(0, 100, 1) })
|
||||
add_setting({ "name":"crosshair_threshold", "type":SettingType.SLIDER, "list":advanced_list, "default":16.,
|
||||
"unit":"m", "range":Vector3(0, 200, 1) })
|
||||
add_setting(
|
||||
{
|
||||
"name": "gamma",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": advanced_list,
|
||||
"default": 1.0,
|
||||
"unit": "γ",
|
||||
"range": Vector3(0.1, 2.0, 0.01)
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "jitter",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": advanced_list,
|
||||
"default": 50,
|
||||
"unit": "%",
|
||||
"range": Vector3(0, 100, 1)
|
||||
}
|
||||
)
|
||||
add_setting(
|
||||
{
|
||||
"name": "crosshair_threshold",
|
||||
"type": SettingType.SLIDER,
|
||||
"list": advanced_list,
|
||||
"default": 16.,
|
||||
"unit": "m",
|
||||
"range": Vector3(0, 200, 1)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func create_submenu(p_parent: Control, p_button_name: String, p_layout: Layout, p_hover_pop: bool = true) -> Container:
|
||||
func create_submenu(
|
||||
p_parent: Control, p_button_name: String, p_layout: Layout, p_hover_pop: bool = true
|
||||
) -> Container:
|
||||
var menu_button: Button = Button.new()
|
||||
if p_button_name.is_empty():
|
||||
menu_button.icon = get_theme_icon("GuiTabMenuHl", "EditorIcons")
|
||||
@@ -190,7 +526,7 @@ func create_submenu(p_parent: Control, p_button_name: String, p_layout: Layout,
|
||||
menu_button.set_toggle_mode(true)
|
||||
menu_button.set_v_size_flags(SIZE_SHRINK_CENTER)
|
||||
menu_button.toggled.connect(_on_show_submenu.bind(menu_button))
|
||||
|
||||
|
||||
var submenu: PopupPanel = PopupPanel.new()
|
||||
submenu.popup_hide.connect(menu_button.set_pressed.bind(false))
|
||||
var panel_style: StyleBox = get_theme_stylebox("panel", "PopupMenu").duplicate()
|
||||
@@ -201,38 +537,40 @@ func create_submenu(p_parent: Control, p_button_name: String, p_layout: Layout,
|
||||
# Pop up menu on hover, hide on exit
|
||||
if p_hover_pop:
|
||||
menu_button.mouse_entered.connect(_on_show_submenu.bind(true, menu_button))
|
||||
|
||||
|
||||
submenu.mouse_entered.connect(func(): submenu.set_meta("mouse_entered", true))
|
||||
|
||||
submenu.mouse_exited.connect(func():
|
||||
# On mouse_exit, hide popup unless LineEdit focused
|
||||
var focused_element: Control = submenu.gui_get_focus_owner()
|
||||
if not focused_element is LineEdit:
|
||||
_on_show_submenu(false, menu_button)
|
||||
submenu.set_meta("mouse_entered", false)
|
||||
return
|
||||
|
||||
focused_element.focus_exited.connect(func():
|
||||
# Close submenu once lineedit loses focus
|
||||
if not submenu.get_meta("mouse_entered"):
|
||||
|
||||
submenu.mouse_exited.connect(
|
||||
func():
|
||||
# On mouse_exit, hide popup unless LineEdit focused
|
||||
var focused_element: Control = submenu.gui_get_focus_owner()
|
||||
if not focused_element is LineEdit:
|
||||
_on_show_submenu(false, menu_button)
|
||||
submenu.set_meta("mouse_entered", false)
|
||||
)
|
||||
return
|
||||
|
||||
focused_element.focus_exited.connect(
|
||||
func():
|
||||
# Close submenu once lineedit loses focus
|
||||
if not submenu.get_meta("mouse_entered"):
|
||||
_on_show_submenu(false, menu_button)
|
||||
submenu.set_meta("mouse_entered", false)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
var sublist: Container
|
||||
match(p_layout):
|
||||
match p_layout:
|
||||
Layout.GRID:
|
||||
sublist = GridContainer.new()
|
||||
Layout.VERTICAL:
|
||||
sublist = VBoxContainer.new()
|
||||
Layout.HORIZONTAL, _:
|
||||
sublist = HBoxContainer.new()
|
||||
|
||||
|
||||
p_parent.add_child(menu_button, true)
|
||||
menu_button.add_child(submenu, true)
|
||||
submenu.add_child(sublist, true)
|
||||
|
||||
|
||||
return sublist
|
||||
|
||||
|
||||
@@ -240,25 +578,27 @@ func _on_show_submenu(p_toggled: bool, p_button: Button) -> void:
|
||||
# Don't show if mouse already down (from painting)
|
||||
if p_toggled and Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
return
|
||||
|
||||
# Hide menu if mouse is not in button or panel
|
||||
var button_rect: Rect2 = Rect2(p_button.get_screen_transform().origin, p_button.get_global_rect().size)
|
||||
|
||||
# Hide menu if mouse is not in button or panel
|
||||
var button_rect: Rect2 = Rect2(
|
||||
p_button.get_screen_transform().origin, p_button.get_global_rect().size
|
||||
)
|
||||
var in_button: bool = button_rect.has_point(DisplayServer.mouse_get_position())
|
||||
var popup: PopupPanel = p_button.get_child(0)
|
||||
var popup_rect: Rect2 = Rect2(popup.position, popup.size)
|
||||
var in_popup: bool = popup_rect.has_point(DisplayServer.mouse_get_position())
|
||||
if not p_toggled and ( in_button or in_popup ):
|
||||
if not p_toggled and (in_button or in_popup):
|
||||
return
|
||||
|
||||
|
||||
# Hide all submenus before possibly enabling the current one
|
||||
get_tree().call_group("terrain3d_submenus", "set_visible", false)
|
||||
popup.set_visible(p_toggled)
|
||||
var popup_pos: Vector2 = p_button.get_screen_transform().origin
|
||||
popup_pos.y -= popup.size.y
|
||||
if popup.get_child_count()>0 and popup.get_child(0) == advanced_list:
|
||||
if popup.get_child_count() > 0 and popup.get_child(0) == advanced_list:
|
||||
popup_pos.x -= popup.size.x - p_button.size.x
|
||||
popup.set_position(popup_pos)
|
||||
|
||||
|
||||
|
||||
func add_brushes(p_parent: Control) -> void:
|
||||
var brush_list: GridContainer = create_submenu(p_parent, "Brush", Layout.GRID)
|
||||
@@ -267,7 +607,7 @@ func add_brushes(p_parent: Control) -> void:
|
||||
var brush_button_group: ButtonGroup = ButtonGroup.new()
|
||||
brush_button_group.pressed.connect(_on_setting_changed)
|
||||
var default_brush_btn: Button
|
||||
|
||||
|
||||
var dir: DirAccess = DirAccess.open(BRUSH_PATH)
|
||||
if dir:
|
||||
dir.list_dir_begin()
|
||||
@@ -283,7 +623,7 @@ func add_brushes(p_parent: Control) -> void:
|
||||
thumbimg = Terrain3DUtil.black_to_alpha(thumbimg)
|
||||
thumbimg.convert(Image.FORMAT_LA8)
|
||||
var thumbtex: ImageTexture = ImageTexture.create_from_image(thumbimg)
|
||||
|
||||
|
||||
var brush_btn: Button = Button.new()
|
||||
brush_btn.set_custom_minimum_size(Vector2.ONE * 100)
|
||||
brush_btn.set_button_icon(thumbtex)
|
||||
@@ -296,8 +636,8 @@ func add_brushes(p_parent: Control) -> void:
|
||||
brush_btn.mouse_exited.connect(_on_brush_hover.bind(false, brush_btn))
|
||||
brush_list.add_child(brush_btn, true)
|
||||
if file_name == DEFAULT_BRUSH:
|
||||
default_brush_btn = brush_btn
|
||||
|
||||
default_brush_btn = brush_btn
|
||||
|
||||
var lbl: Label = Label.new()
|
||||
brush_btn.name = file_name.get_basename().to_pascal_case()
|
||||
brush_btn.add_child(lbl, true)
|
||||
@@ -308,16 +648,16 @@ func add_brushes(p_parent: Control) -> void:
|
||||
lbl.add_theme_constant_override("shadow_offset_x", 1)
|
||||
lbl.add_theme_constant_override("shadow_offset_y", 1)
|
||||
lbl.add_theme_font_size_override("font_size", 16)
|
||||
|
||||
|
||||
file_name = dir.get_next()
|
||||
|
||||
|
||||
brush_list.columns = sqrt(brush_list.get_child_count()) + 2
|
||||
|
||||
|
||||
if not default_brush_btn:
|
||||
default_brush_btn = brush_button_group.get_buttons()[0]
|
||||
default_brush_btn.set_pressed(true)
|
||||
_generate_brush_texture(default_brush_btn)
|
||||
|
||||
|
||||
settings["brush"] = brush_button_group
|
||||
|
||||
select_brush_button = brush_list.get_parent().get_parent()
|
||||
@@ -352,7 +692,11 @@ func _on_picked(p_type: Terrain3DEditor.Tool, p_color: Color, p_global_position:
|
||||
Terrain3DEditor.ROUGHNESS:
|
||||
# This converts 0,1 to -100,100
|
||||
# It also quantizes explicitly so picked values matches painted values
|
||||
settings["roughness"].value = round(200. * float(int(p_color.a * 255.) / 255. - .5)) if not is_nan(p_color.r) else 0.
|
||||
settings["roughness"].value = (
|
||||
round(200. * float(int(p_color.a * 255.) / 255. - .5))
|
||||
if not is_nan(p_color.r)
|
||||
else 0.
|
||||
)
|
||||
Terrain3DEditor.ANGLE:
|
||||
settings["angle"].value = p_color.r
|
||||
Terrain3DEditor.SCALE:
|
||||
@@ -365,7 +709,9 @@ func _on_point_pick(p_type: Terrain3DEditor.Tool, p_name: String) -> void:
|
||||
emit_signal("picking", p_type, _on_point_picked.bind(p_name))
|
||||
|
||||
|
||||
func _on_point_picked(p_type: Terrain3DEditor.Tool, p_color: Color, p_global_position: Vector3, p_name: String) -> void:
|
||||
func _on_point_picked(
|
||||
p_type: Terrain3DEditor.Tool, p_color: Color, p_global_position: Vector3, p_name: String
|
||||
) -> void:
|
||||
assert(p_type == Terrain3DEditor.SCULPT)
|
||||
var point: Vector3 = p_global_position
|
||||
point.y = p_color.r
|
||||
@@ -375,7 +721,7 @@ func _on_point_picked(p_type: Terrain3DEditor.Tool, p_color: Color, p_global_pos
|
||||
|
||||
func add_setting(p_args: Dictionary) -> void:
|
||||
var p_name: StringName = p_args.get("name", "")
|
||||
var p_label: String = p_args.get("label", "") # Optional replacement for name
|
||||
var p_label: String = p_args.get("label", "") # Optional replacement for name
|
||||
var p_type: SettingType = p_args.get("type", SettingType.TYPE_MAX)
|
||||
var p_list: Control = p_args.get("list")
|
||||
var p_default: Variant = p_args.get("default")
|
||||
@@ -385,13 +731,13 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
var p_maximum: float = p_range.y
|
||||
var p_step: float = p_range.z
|
||||
var p_flags: int = p_args.get("flags", NONE)
|
||||
|
||||
|
||||
if p_name.is_empty() or p_type == SettingType.TYPE_MAX:
|
||||
return
|
||||
|
||||
var container: HBoxContainer = HBoxContainer.new()
|
||||
container.set_v_size_flags(SIZE_EXPAND_FILL)
|
||||
var control: Control # Houses the setting to be saved
|
||||
var control: Control # Houses the setting to be saved
|
||||
var pending_children: Array[Control]
|
||||
|
||||
match p_type:
|
||||
@@ -404,17 +750,21 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
SettingType.CHECKBOX:
|
||||
var checkbox := CheckBox.new()
|
||||
if !(p_flags & NO_SAVE):
|
||||
checkbox.set_pressed_no_signal(plugin.get_setting(ES_TOOL_SETTINGS + p_name, p_default))
|
||||
checkbox.toggled.connect( (
|
||||
func(value, path):
|
||||
plugin.set_setting(path, value)
|
||||
).bind(ES_TOOL_SETTINGS + p_name) )
|
||||
checkbox.set_pressed_no_signal(
|
||||
plugin.get_setting(ES_TOOL_SETTINGS + p_name, p_default)
|
||||
)
|
||||
checkbox.toggled.connect(
|
||||
(
|
||||
(func(value, path): plugin.set_setting(path, value))
|
||||
. bind(ES_TOOL_SETTINGS + p_name)
|
||||
)
|
||||
)
|
||||
else:
|
||||
checkbox.set_pressed_no_signal(p_default)
|
||||
checkbox.set_pressed_no_signal(p_default)
|
||||
checkbox.pressed.connect(_on_setting_changed)
|
||||
pending_children.push_back(checkbox)
|
||||
control = checkbox
|
||||
|
||||
|
||||
SettingType.COLOR_SELECT:
|
||||
var picker := ColorPickerButton.new()
|
||||
picker.set_custom_minimum_size(Vector2(100, 25))
|
||||
@@ -422,10 +772,12 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
picker.get_picker().set_color_mode(ColorPicker.MODE_HSV)
|
||||
if !(p_flags & NO_SAVE):
|
||||
picker.set_pick_color(plugin.get_setting(ES_TOOL_SETTINGS + p_name, p_default))
|
||||
picker.color_changed.connect( (
|
||||
func(value, path):
|
||||
plugin.set_setting(path, value)
|
||||
).bind(ES_TOOL_SETTINGS + p_name) )
|
||||
picker.color_changed.connect(
|
||||
(
|
||||
(func(value, path): plugin.set_setting(path, value))
|
||||
. bind(ES_TOOL_SETTINGS + p_name)
|
||||
)
|
||||
)
|
||||
else:
|
||||
picker.set_pick_color(p_default)
|
||||
picker.color_changed.connect(_on_setting_changed)
|
||||
@@ -479,12 +831,12 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
slider.set_allow_greater(true)
|
||||
if p_flags & ALLOW_SMALLER:
|
||||
slider.set_allow_lesser(true)
|
||||
|
||||
|
||||
pending_children.push_back(slider)
|
||||
pending_children.push_back(spin_slider)
|
||||
control = spin_slider
|
||||
|
||||
else: # DOUBLE_SLIDER
|
||||
|
||||
else: # DOUBLE_SLIDER
|
||||
var label := Label.new()
|
||||
label.set_custom_minimum_size(Vector2(60, 0))
|
||||
label.set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER)
|
||||
@@ -495,7 +847,7 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
pending_children.push_back(slider)
|
||||
pending_children.push_back(label)
|
||||
control = slider
|
||||
|
||||
|
||||
slider.set_min(p_minimum)
|
||||
slider.set_max(p_maximum)
|
||||
slider.set_step(p_step)
|
||||
@@ -505,10 +857,12 @@ func add_setting(p_args: Dictionary) -> void:
|
||||
|
||||
if !(p_flags & NO_SAVE):
|
||||
slider.set_value(plugin.get_setting(ES_TOOL_SETTINGS + p_name, p_default))
|
||||
slider.value_changed.connect( (
|
||||
func(value, path):
|
||||
plugin.set_setting(path, value)
|
||||
).bind(ES_TOOL_SETTINGS + p_name) )
|
||||
slider.value_changed.connect(
|
||||
(
|
||||
(func(value, path): plugin.set_setting(path, value))
|
||||
. bind(ES_TOOL_SETTINGS + p_name)
|
||||
)
|
||||
)
|
||||
else:
|
||||
slider.set_value(p_default)
|
||||
|
||||
@@ -569,11 +923,14 @@ func get_setting(p_setting: String) -> Variant:
|
||||
value = object.get_value()
|
||||
# Adjust widths of all sliders on update of values
|
||||
var digits: float = count_digits(value)
|
||||
var width: float = clamp( (1 + count_digits(value)) * 19., 50, 80) * clamp(EditorInterface.get_editor_scale(), .9, 2)
|
||||
var width: float = (
|
||||
clamp((1 + count_digits(value)) * 19., 50, 80)
|
||||
* clamp(EditorInterface.get_editor_scale(), .9, 2)
|
||||
)
|
||||
object.set_custom_minimum_size(Vector2(width, 0))
|
||||
elif object is DoubleSlider:
|
||||
value = object.get_value()
|
||||
elif object is ButtonGroup: # "brush"
|
||||
elif object is ButtonGroup: # "brush"
|
||||
value = selected_brush_imgs
|
||||
elif object is CheckBox:
|
||||
value = object.is_pressed()
|
||||
@@ -588,11 +945,11 @@ func get_setting(p_setting: String) -> Variant:
|
||||
|
||||
func set_setting(p_setting: String, p_value: Variant) -> void:
|
||||
var object: Object = settings.get(p_setting)
|
||||
if object is DoubleSlider: # Expects p_value is Vector2
|
||||
if object is DoubleSlider: # Expects p_value is Vector2
|
||||
object.set_value(p_value)
|
||||
elif object is Range:
|
||||
object.set_value(p_value)
|
||||
elif object is ButtonGroup: # Expects p_value is Array [ "button name", boolean ]
|
||||
elif object is ButtonGroup: # Expects p_value is Array [ "button name", boolean ]
|
||||
if p_value is Array and p_value.size() == 2:
|
||||
for button in object.get_buttons():
|
||||
if button.name == p_value[0]:
|
||||
@@ -601,8 +958,8 @@ func set_setting(p_setting: String, p_value: Variant) -> void:
|
||||
object.button_pressed = p_value
|
||||
elif object is ColorPickerButton:
|
||||
object.color = p_value
|
||||
plugin.set_setting(ES_TOOL_SETTINGS + p_setting, p_value) # Signal doesn't fire on CPB
|
||||
elif object is MultiPicker: # Expects p_value is PackedVector3Array
|
||||
plugin.set_setting(ES_TOOL_SETTINGS + p_setting, p_value) # Signal doesn't fire on CPB
|
||||
elif object is MultiPicker: # Expects p_value is PackedVector3Array
|
||||
object.points = p_value
|
||||
_on_setting_changed(object)
|
||||
|
||||
@@ -644,7 +1001,7 @@ func _generate_brush_texture(p_btn: Button) -> void:
|
||||
img = img.duplicate()
|
||||
img.resize(1024, 1024, Image.INTERPOLATE_CUBIC)
|
||||
var tex: ImageTexture = ImageTexture.create_from_image(img)
|
||||
selected_brush_imgs = [ img, tex ]
|
||||
selected_brush_imgs = [img, tex]
|
||||
|
||||
|
||||
func _on_drawable_toggled(p_button_pressed: bool) -> void:
|
||||
@@ -671,23 +1028,22 @@ func _get_brush_preview_material() -> ShaderMaterial:
|
||||
return brush_preview_material
|
||||
|
||||
|
||||
# Counts digits of a number including negative sign, decimal points, and up to 3 decimals
|
||||
# Counts digits of a number including negative sign, decimal points, and up to 3 decimals
|
||||
func count_digits(p_value: float) -> int:
|
||||
var count: int = 1
|
||||
for i in range(5, 0, -1):
|
||||
if abs(p_value) >= pow(10, i):
|
||||
count = i+1
|
||||
count = i + 1
|
||||
break
|
||||
if p_value - floor(p_value) >= .1:
|
||||
count += 1 # For the decimal
|
||||
if p_value*10 - floor(p_value*10.) >= .1:
|
||||
count += 1 # For the decimal
|
||||
if p_value * 10 - floor(p_value * 10.) >= .1:
|
||||
count += 1
|
||||
if p_value*100 - floor(p_value*100.) >= .1:
|
||||
if p_value * 100 - floor(p_value * 100.) >= .1:
|
||||
count += 1
|
||||
if p_value*1000 - floor(p_value*1000.) >= .1:
|
||||
if p_value * 1000 - floor(p_value * 1000.) >= .1:
|
||||
count += 1
|
||||
# Negative sign
|
||||
if p_value < 0:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
Reference in New Issue
Block a user