Merge pull request 'Add Camera Bounds Data' (#9) from editor-camera-bounds into main

Reviewed-on: #9
This commit is contained in:
kayomn 2023-01-22 23:57:46 +01:00
commit f3e630849b
17 changed files with 218 additions and 50 deletions

BIN
editor.scn (Stored with Git LFS)

Binary file not shown.

View File

@ -1,14 +0,0 @@
[remap]
importer="image"
type="Image"
uid="uid://drok88h02tdre"
path="res://.godot/imported/brush_hard_circle_mask.png-e647df7b970f00cdf2f3f2ac38ad8257.image"
[deps]
source_file="res://editor/brush_hard_circle_mask.png"
dest_files=["res://.godot/imported/brush_hard_circle_mask.png-e647df7b970f00cdf2f3f2ac38ad8257.image"]
[params]

View File

@ -1,14 +0,0 @@
[remap]
importer="image"
type="Image"
uid="uid://bbdh4btpg08do"
path="res://.godot/imported/brush_soft_circle_mask.png-5af527bedd556c2d7ed38b029e34527e.image"
[deps]
source_file="res://editor/brush_soft_circle_mask.png"
dest_files=["res://.godot/imported/brush_soft_circle_mask.png-5af527bedd556c2d7ed38b029e34527e.image"]
[params]

BIN
editor/menus_theme.res (Stored with Git LFS)

Binary file not shown.

BIN
map_editor.scn (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
shader_type spatial;
render_mode shadows_disabled, unshaded, cull_disabled;
void fragment() {
if (FRONT_FACING) {
ALBEDO = vec3(1.0, 0.0, 0.0);
ALPHA = 0.5;
} else {
ALBEDO = vec3(0.0, 1.0, 0.0);
ALPHA = 0.1;
}
}

View File

@ -0,0 +1,14 @@
[remap]
importer="image"
type="Image"
uid="uid://drok88h02tdre"
path="res://.godot/imported/brush_hard_circle_mask.png-b5b7b3c7aa50923306e69fd4680a2d65.image"
[deps]
source_file="res://map_editor/brush_hard_circle_mask.png"
dest_files=["res://.godot/imported/brush_hard_circle_mask.png-b5b7b3c7aa50923306e69fd4680a2d65.image"]
[params]

View File

@ -0,0 +1,14 @@
[remap]
importer="image"
type="Image"
uid="uid://bbdh4btpg08do"
path="res://.godot/imported/brush_soft_circle_mask.png-f4362d74cca7ee83b36212049a3b11fb.image"
[deps]
source_file="res://map_editor/brush_soft_circle_mask.png"
dest_files=["res://.godot/imported/brush_soft_circle_mask.png-f4362d74cca7ee83b36212049a3b11fb.image"]
[params]

BIN
map_editor/camera_boundary_mesh.res (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,143 @@
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

BIN
map_editor/menus_theme.res (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -98,9 +98,7 @@ func _input(event: InputEvent) -> void:
if (event is InputEventMouseMotion) and self._is_drag_panning:
var global_basis := self.global_transform.basis
var camera_settings := GameSettings.camera_settings
var dampened_speed :=\
camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER
var dampened_speed := camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER
self._target_position += dampened_speed.y * (-global_basis.z) *\
event.relative.y * (-1.0 if camera_settings.is_y_inverted else 1.0)
@ -161,6 +159,12 @@ func _ready() -> void:
self.select_mode_changed.emit(SelectMode.NONE))
##
##
##
func in_select_area() -> bool:
return self._select_mode != SelectMode.NONE
##
## Returns [code]true[/code] if the player controller is currently selecting a location on the
## screen, otherwise [code]false[/code].
@ -181,17 +185,6 @@ func is_selecting() -> bool:
func get_cursor_point() -> Vector2:
return self._cursor_point
##
## Returns the current [enum SelectMode] being used for selections.
##
## The general use-case for this function is to peek through the player controller abstraction and
## see what supported hardware interface is currently being used to select in the world. This is
## useful for handling input-specific behaviors, such as showing a mouse cursor when a mouse input
## device is being used.
##
func get_select_mode() -> int:
return self._select_mode
##
## Attempts to convert the screen coordinates in [code]screen_point[/code] into 2D worldspace
## coordinate relative to an infinite ground plane at y offset [code]0.0[/code].

View File

@ -19,6 +19,11 @@ _global_script_classes=[{
"language": &"GDScript",
"path": "res://user_interface/button_selection.gd"
}, {
"base": "Node",
"class": &"MapEditorController",
"language": &"GDScript",
"path": "res://map_editor/map_editor_controller.gd"
}, {
"base": "Node3D",
"class": &"PlayerController",
"language": &"GDScript",
@ -42,6 +47,7 @@ _global_script_classes=[{
_global_script_class_icons={
"DynamicTerrainInstance3D": "",
"ItemSelection": "",
"MapEditorController": "",
"PlayerController": "",
"Settings": "",
"TerrainInstance3D": "",
@ -51,7 +57,7 @@ _global_script_class_icons={
[application]
config/name="Protectorate"
run/main_scene="res://editor.scn"
run/main_scene="res://map_editor.scn"
config/use_custom_user_dir=true
config/features=PackedStringArray("4.0", "Forward Plus")
config/icon="res://icon.png"

View File

@ -16,7 +16,18 @@ var item_count: int:
return _button_group.get_buttons().size()
func _get_configuration_warnings() -> PackedStringArray:
return PackedStringArray()
var warnings := PackedStringArray()
var children := get_children()
if not(children.is_empty()):
var self_class_name := get_class()
for child in get_children():
warnings.append(
"{0} can only have Button children, but {1} is of type {2}".format(
[self_class_name, child.name, child.get_class()]))
return warnings
##
## Adds a new item with no text and only [code]icon[/code] as the icon to the selection.