Add portable RV homes and decor prototype
This commit is contained in:
parent
81decf2b71
commit
fe099f47dd
56 changed files with 5459 additions and 112 deletions
126
ui/home_decor_toolbar.gd
Normal file
126
ui/home_decor_toolbar.gd
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
class_name HomeDecorToolbar
|
||||
extends PanelContainer
|
||||
|
||||
signal placement_mode_requested(mode: int)
|
||||
signal rotate_requested
|
||||
signal store_requested
|
||||
signal cancel_requested
|
||||
|
||||
var _mode_button: Button
|
||||
var _selection_label: Label
|
||||
var _rotate_button: Button
|
||||
var _store_button: Button
|
||||
var _mode: PlayerHomeState.PlacementMode = PlayerHomeState.PlacementMode.GRID
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_build_ui()
|
||||
hide()
|
||||
|
||||
|
||||
func set_active(active: bool) -> void:
|
||||
if visible == active:
|
||||
return
|
||||
visible = active
|
||||
if active and _mode_button != null:
|
||||
_mode_button.call_deferred("grab_focus")
|
||||
|
||||
|
||||
func set_mode(mode: PlayerHomeState.PlacementMode) -> void:
|
||||
_mode = mode
|
||||
if _mode_button != null:
|
||||
_mode_button.text = (
|
||||
"placement: grid"
|
||||
if mode == PlayerHomeState.PlacementMode.GRID
|
||||
else "placement: free"
|
||||
)
|
||||
|
||||
|
||||
func set_selection(instance_id: String, display_name: String = "") -> void:
|
||||
var selected: bool = not instance_id.is_empty()
|
||||
if _selection_label != null:
|
||||
_selection_label.text = (
|
||||
"selected: %s" % display_name
|
||||
if selected else "click decor to select; drag to move"
|
||||
)
|
||||
if _rotate_button != null:
|
||||
_rotate_button.disabled = not selected
|
||||
if _store_button != null:
|
||||
_store_button.disabled = not selected
|
||||
|
||||
|
||||
func report_status(message: String) -> void:
|
||||
if _selection_label != null:
|
||||
_selection_label.text = message
|
||||
|
||||
|
||||
func _build_ui() -> void:
|
||||
custom_minimum_size = Vector2(330.0, 0.0)
|
||||
position = Vector2(925.0, 540.0)
|
||||
z_index = 58
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
add_theme_stylebox_override(
|
||||
"panel",
|
||||
UtilityPageStyle.rounded_style(
|
||||
Color(UtilityPageStyle.OCEAN_PANEL_DEEP, 0.96), 16
|
||||
),
|
||||
)
|
||||
var margin := MarginContainer.new()
|
||||
for side: StringName in [
|
||||
&"margin_left", &"margin_top", &"margin_right", &"margin_bottom",
|
||||
]:
|
||||
margin.add_theme_constant_override(side, 12)
|
||||
add_child(margin)
|
||||
var layout := VBoxContainer.new()
|
||||
layout.add_theme_constant_override("separation", 8)
|
||||
margin.add_child(layout)
|
||||
var title := Label.new()
|
||||
title.text = "RV decor"
|
||||
title.add_theme_font_size_override("font_size", 24)
|
||||
layout.add_child(title)
|
||||
_selection_label = Label.new()
|
||||
_selection_label.text = "click decor to select; drag to move"
|
||||
_selection_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_selection_label.add_theme_font_size_override("font_size", 17)
|
||||
layout.add_child(_selection_label)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
layout.add_child(row)
|
||||
_mode_button = Button.new()
|
||||
_mode_button.text = "placement: grid"
|
||||
_mode_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
UtilityPageStyle.apply_ocean_button(_mode_button)
|
||||
_mode_button.pressed.connect(_toggle_mode)
|
||||
row.add_child(_mode_button)
|
||||
_rotate_button = Button.new()
|
||||
_rotate_button.text = "rotate"
|
||||
_rotate_button.disabled = true
|
||||
UtilityPageStyle.apply_ocean_button(_rotate_button)
|
||||
_rotate_button.pressed.connect(rotate_requested.emit)
|
||||
row.add_child(_rotate_button)
|
||||
var action_row := HBoxContainer.new()
|
||||
action_row.add_theme_constant_override("separation", 8)
|
||||
layout.add_child(action_row)
|
||||
_store_button = Button.new()
|
||||
_store_button.text = "pack up"
|
||||
_store_button.disabled = true
|
||||
_store_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
UtilityPageStyle.apply_ocean_button(_store_button)
|
||||
_store_button.pressed.connect(store_requested.emit)
|
||||
action_row.add_child(_store_button)
|
||||
var cancel_button := Button.new()
|
||||
cancel_button.text = "clear selection"
|
||||
cancel_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
UtilityPageStyle.apply_ocean_button(cancel_button)
|
||||
cancel_button.pressed.connect(cancel_requested.emit)
|
||||
action_row.add_child(cancel_button)
|
||||
|
||||
|
||||
func _toggle_mode() -> void:
|
||||
_mode = (
|
||||
PlayerHomeState.PlacementMode.FREE
|
||||
if _mode == PlayerHomeState.PlacementMode.GRID
|
||||
else PlayerHomeState.PlacementMode.GRID
|
||||
)
|
||||
set_mode(_mode)
|
||||
placement_mode_requested.emit(int(_mode))
|
||||
Loading…
Add table
Add a link
Reference in a new issue