144 lines
2.5 KiB
GDScript3
144 lines
2.5 KiB
GDScript3
|
class_name MapEditorController extends Node
|
||
|
|
||
|
##
|
||
|
## Default elevation height for terrain.
|
||
|
##
|
||
|
const DEFAULT_ELEVATION := 0.5
|
||
|
|
||
|
var _brush_selected := 0
|
||
|
|
||
|
@export
|
||
|
var _registered_brushes: Array[Image] = []
|
||
|
|
||
|
@export
|
||
|
var _registered_paints: Array[TerrainPaint] = []
|
||
|
|
||
|
var _paint_selected_erase := 0
|
||
|
|
||
|
var _paint_selected_blue := 0
|
||
|
|
||
|
var _paint_selected_green := 0
|
||
|
|
||
|
var _paint_selected_red := 0
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
var smooth_elevation := DEFAULT_ELEVATION
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func disable_controls() -> void:
|
||
|
set_process(false)
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func enable_controls() -> void:
|
||
|
set_process(true)
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_registered_brushes() -> Array[Image]:
|
||
|
return _registered_brushes
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_registered_paints() -> Array[TerrainPaint]:
|
||
|
return _registered_paints
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_selected_brush() -> int:
|
||
|
return _brush_selected
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_selected_paint_blue() -> int:
|
||
|
return _paint_selected_blue
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_selected_paint_erase() -> int:
|
||
|
return _paint_selected_erase
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_selected_paint_green() -> int:
|
||
|
return _paint_selected_green
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func get_selected_paint_red() -> int:
|
||
|
return _paint_selected_red
|
||
|
|
||
|
##
|
||
|
## Registers [code]brush_mask[/code] as a usable brush option in the editor.
|
||
|
##
|
||
|
func register_brush(brush_mask: Image) -> void:
|
||
|
_registered_brushes.append(brush_mask)
|
||
|
|
||
|
##
|
||
|
## Registers [code]terrain_paint[/code] as a usable paint option in the editor.
|
||
|
##
|
||
|
func register_paint(terrain_paint: TerrainPaint) -> void:
|
||
|
_registered_paints.append(terrain_paint)
|
||
|
|
||
|
##
|
||
|
## Resets the editor settings to their initial values.
|
||
|
##
|
||
|
func reset() -> void:
|
||
|
select_brush(0)
|
||
|
select_paint_erase(0)
|
||
|
select_paint_red(0)
|
||
|
select_paint_green(0)
|
||
|
select_paint_blue(0)
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func select_brush(selected_index: int) -> void:
|
||
|
assert((selected_index >= 0) or (selected_index < _registered_brushes.size()))
|
||
|
|
||
|
_brush_selected = selected_index
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func select_paint_blue(selected_index: int) -> void:
|
||
|
assert((selected_index >= 0) or (selected_index < _registered_paints.size()))
|
||
|
|
||
|
_paint_selected_blue = selected_index
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func select_paint_erase(selected_index: int) -> void:
|
||
|
assert((selected_index >= 0) or (selected_index < _registered_paints.size()))
|
||
|
|
||
|
_paint_selected_erase = selected_index
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func select_paint_green(selected_index: int) -> void:
|
||
|
assert((selected_index >= 0) or (selected_index < _registered_paints.size()))
|
||
|
|
||
|
_paint_selected_green = selected_index
|
||
|
|
||
|
##
|
||
|
##
|
||
|
##
|
||
|
func select_paint_red(selected_index: int) -> void:
|
||
|
assert((selected_index >= 0) or (selected_index < _registered_paints.size()))
|
||
|
|
||
|
_paint_selected_red = selected_index
|