8000 Added open container button. · BraindeadBZH/godot_card_engine@30fb154 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Added open container button.
Browse files Browse the repository at this point in the history
  • Loading branch information
BraindeadBZH committed Jan 7, 2021
1 parent e607c07 commit 30fb154
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions addons/cardengine/container/container_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func update_container(modified_cont: ContainerData) -> void:
emit_signal("changed")


func open(id: String) -> void:
CardEngine.open_scene(FMT_IMPL_SCENE % [_folder, id, id])


func delete_container(cont: ContainerData) -> void:
if Utils.directory_remove_recursive(FMT_PRIVATE_FOLDER % [_private_folder, cont.id]):
_containers.erase(cont.id)
Expand Down
4 changes: 4 additions & 0 deletions addons/cardengine/core/card_engine_instance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ func scan_for_new_files() -> void:

func open_for_edit(res: Resource) -> void:
_plugin.get_editor_interface().edit_resource(res)


func open_scene(path: String) -> void:
_plugin.get_editor_interface().open_scene_from_path(path)
15 changes: 12 additions & 3 deletions addons/cardengine/ui/card_engine_ui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ __meta__ = {
}

[node name="Databases" type="Control" parent="Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
Expand Down Expand Up @@ -272,7 +273,6 @@ disabled = true
text = "Delete"

[node name="Containers" type="Control" parent="Tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
Expand Down Expand Up @@ -304,9 +304,16 @@ margin_bottom = 20.0
disabled = true
text = "Edit container"

[node name="DeleteBtn" type="Button" parent="Tabs/Containers/ContainersLayout/Toolbar"]
[node name="OpenBtn" type="Button" parent="Tabs/Containers/ContainersLayout/Toolbar"]
margin_left = 225.0
margin_right = 344.0
margin_right = 336.0
margin_bottom = 20.0
disabled = true
text = "Open container"

[node name="DeleteBtn" type="Button" parent="Tabs/Containers/ContainersLayout/Toolbar"]
margin_left = 340.0
margin_right = 459.0
margin_bottom = 20.0
disabled = true
text = "Delete container"
Expand Down Expand Up @@ -626,6 +633,7 @@ margin_top = 24.0
margin_right = 1272.0
margin_bottom = 684.0
size_flags_vertical = 3
items = [ "mana_double: Double the Mana", null, false, "mana_incr: Mana +1", null, false, "mana_decr: Mana -1", null, false ]

[node name="Dialogs" type="Control" parent="."]
visible = false
Expand Down Expand Up @@ -684,6 +692,7 @@ margin_bottom = -4.0
[connection signal="pressed" from="Tabs/Cards/CardLayout/DataLayout/TextsToolLayout/DelTxtBtn" to="Tabs/Cards" method="_on_DelTxtBtn_pressed"]
[connection signal="pressed" from="Tabs/Containers/ContainersLayout/Toolbar/CreateBtn" to="Tabs/Containers" method="_on_CreateBtn_pressed"]
[connection signal="pressed" from="Tabs/Containers/ContainersLayout/Toolbar/EditBtn" to="Tabs/Containers" method="_on_EditBtn_pressed"]
[connection signal="pressed" from="Tabs/Containers/ContainersLayout/Toolbar/OpenBtn" to="Tabs/Containers" method="_on_OpenBtn_pressed"]
[connection signal="pressed" from="Tabs/Containers/ContainersLayout/Toolbar/DeleteBtn" to="Tabs/Containers" method="_on_DeleteBtn_pressed"]
[connection signal="item_activated" from="Tabs/Containers/ContainersLayout/ContainerList" to="Tabs/Containers" method="_on_ContainerList_item_activated"]
[connection signal="item_selected" from="Tabs/Containers/ContainersLayout/ContainerList" to="Tabs/Containers" method="_on_ContainerList_item_selected"]
Expand Down
7 changes: 7 additions & 0 deletions addons/cardengine/ui/containers_ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var _selected_cont: int = -1
onready var _manager = CardEngine.cont()
onready var _cont_list = $ContainersLayout/ContainerList
onready var _edit_btn = $ContainersLayout/Toolbar/EditBtn
onready var _open_btn = $ContainersLayout/Toolbar/OpenBtn
onready var _delete_btn = $ContainersLayout/Toolbar/DeleteBtn


Expand All @@ -31,6 +32,7 @@ func _on_Containers_changed() -> void:

_cont_list.clear()
_edit_btn.disabled = true
_open_btn.disabled = true
_delete_btn.disabled = true

var containers = CardEngine.cont().containers()
Expand All @@ -48,6 +50,10 @@ func _on_EditBtn_pressed() -> void:
_main_ui.show_edit_container_dialog(_cont_list.get_item_metadata(_selected_cont))


func _on_OpenBtn_pressed() -> void:
_manager.open(_cont_list.get_item_metadata(_selected_cont))


func _on_DeleteBtn_pressed() -> void:
_main_ui.show_confirmation_dialog(
"Delete container", funcref(self, "delete_container"))
Expand All @@ -56,6 +62,7 @@ func _on_DeleteBtn_pressed() -> void:
func _on_ContainerList_item_selected(index) -> void:
_selected_cont = index
_edit_btn.disabled = false
_open_btn.disabled = false
_delete_btn.disabled = false


Expand Down

0 comments on commit 30fb154

Please sign in to comment.
0