mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Automatically hide and show the tiles panel when the current cel is a tilemap cel
This commit is contained in:
parent
020be20566
commit
281c205290
|
@ -20,23 +20,23 @@ layout_mode = 2
|
|||
mouse_default_cursor_shape = 2
|
||||
text = "Place tiles"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
[node name="ModeButtonsContainer" type="HFlowContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Manual" type="CheckBox" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Manual" type="CheckBox" parent="VBoxContainer/ModeButtonsContainer"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
button_group = SubResource("ButtonGroup_uxnt0")
|
||||
text = "Manual"
|
||||
|
||||
[node name="Auto" type="CheckBox" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Auto" type="CheckBox" parent="VBoxContainer/ModeButtonsContainer"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
button_pressed = true
|
||||
button_group = SubResource("ButtonGroup_uxnt0")
|
||||
text = "Auto"
|
||||
|
||||
[node name="Stack" type="CheckBox" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Stack" type="CheckBox" parent="VBoxContainer/ModeButtonsContainer"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
button_group = SubResource("ButtonGroup_uxnt0")
|
||||
|
@ -53,6 +53,6 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
|
||||
[connection signal="toggled" from="VBoxContainer/PlaceTiles" to="." method="_on_place_tiles_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/HBoxContainer/Manual" to="." method="_on_manual_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/HBoxContainer/Auto" to="." method="_on_auto_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/HBoxContainer/Stack" to="." method="_on_stack_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/ModeButtonsContainer/Manual" to="." method="_on_manual_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/ModeButtonsContainer/Auto" to="." method="_on_auto_toggled"]
|
||||
[connection signal="toggled" from="VBoxContainer/ModeButtonsContainer/Stack" to="." method="_on_stack_toggled"]
|
||||
|
|
|
@ -372,9 +372,13 @@ func _setup_panels_submenu(item: String) -> void:
|
|||
panels_submenu.set_name("panels_submenu")
|
||||
panels_submenu.hide_on_checkable_item_selection = false
|
||||
for element in ui_elements:
|
||||
panels_submenu.add_check_item(element.name)
|
||||
if element.name == "Tiles":
|
||||
continue
|
||||
var id := ui_elements.find(element)
|
||||
panels_submenu.add_check_item(element.name, id)
|
||||
var is_hidden: bool = main_ui.is_control_hidden(element)
|
||||
panels_submenu.set_item_checked(ui_elements.find(element), !is_hidden)
|
||||
var index := panels_submenu.get_item_index(id)
|
||||
panels_submenu.set_item_checked(index, !is_hidden)
|
||||
|
||||
panels_submenu.id_pressed.connect(_panels_submenu_id_pressed)
|
||||
window_menu.add_child(panels_submenu)
|
||||
|
@ -763,9 +767,10 @@ func _snap_to_submenu_id_pressed(id: int) -> void:
|
|||
func _panels_submenu_id_pressed(id: int) -> void:
|
||||
if zen_mode:
|
||||
return
|
||||
var element_visible := panels_submenu.is_item_checked(id)
|
||||
var index := panels_submenu.get_item_index(id)
|
||||
var element_visible := panels_submenu.is_item_checked(index)
|
||||
main_ui.set_control_hidden(ui_elements[id], element_visible)
|
||||
panels_submenu.set_item_checked(id, !element_visible)
|
||||
panels_submenu.set_item_checked(index, !element_visible)
|
||||
|
||||
|
||||
func _layouts_submenu_id_pressed(id: int) -> void:
|
||||
|
@ -787,8 +792,9 @@ func set_layout(id: int) -> void:
|
|||
layouts_submenu.set_item_checked(offset, offset == (id + 1))
|
||||
|
||||
for i in ui_elements.size():
|
||||
var index := panels_submenu.get_item_index(i)
|
||||
var is_hidden := main_ui.is_control_hidden(ui_elements[i])
|
||||
panels_submenu.set_item_checked(i, !is_hidden)
|
||||
panels_submenu.set_item_checked(index, !is_hidden)
|
||||
|
||||
if zen_mode: # Turn zen mode off
|
||||
Global.control.find_child("TabsContainer").visible = true
|
||||
|
@ -866,9 +872,11 @@ func _toggle_show_mouse_guides() -> void:
|
|||
|
||||
func _toggle_zen_mode() -> void:
|
||||
for i in ui_elements.size():
|
||||
if ui_elements[i].name == "Main Canvas":
|
||||
var index := panels_submenu.get_item_index(i)
|
||||
var name := ui_elements[i].name
|
||||
if name == "Main Canvas" or name == "Tiles":
|
||||
continue
|
||||
if !panels_submenu.is_item_checked(i):
|
||||
if !panels_submenu.is_item_checked(index):
|
||||
continue
|
||||
main_ui.set_control_hidden(ui_elements[i], !zen_mode)
|
||||
Global.control.find_child("TabsContainer").visible = zen_mode
|
||||
|
|
11
src/UI/UI.gd
11
src/UI/UI.gd
|
@ -3,16 +3,25 @@ extends Panel
|
|||
var shader_disabled := false
|
||||
var transparency_material: ShaderMaterial
|
||||
|
||||
@onready var dockable_container: DockableContainer = $DockableContainer
|
||||
@onready var main_canvas_container := find_child("Main Canvas") as Container
|
||||
@onready var tiles: TileSetPanel = $DockableContainer/Tiles
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.cel_switched.connect(_on_cel_switched)
|
||||
transparency_material = material
|
||||
main_canvas_container.property_list_changed.connect(_re_configure_shader)
|
||||
update_transparent_shader()
|
||||
dockable_container.set_control_hidden.call_deferred(tiles, true)
|
||||
|
||||
|
||||
func _re_configure_shader():
|
||||
func _on_cel_switched() -> void:
|
||||
var cel := Global.current_project.get_current_cel()
|
||||
dockable_container.set_control_hidden(tiles, cel is not CelTileMap)
|
||||
|
||||
|
||||
func _re_configure_shader() -> void:
|
||||
await get_tree().process_frame
|
||||
if get_window() != main_canvas_container.get_window():
|
||||
material = null
|
||||
|
|
Loading…
Reference in a new issue