initial commit

This commit is contained in:
2023-05-24 00:27:34 +03:00
commit 11ee2c7949
174 changed files with 13452 additions and 0 deletions

View File

@ -0,0 +1,46 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends PopupMenu
class_name ActionPopupMenu
var action_map:Dictionary = {}
func _ready():
id_pressed.connect(on_id_pressed)
func add_action_item(action:CyclopsAction):
# var id:int = action_map.size()
var id:int = action_map.size() + 1000
add_item(action.name, id, action.accellerator)
action_map[id] = action
#func add_separator(label:String, id:int = -1):
# pass
func on_id_pressed(id:int):
var action:CyclopsAction = action_map[id]
action._execute()

View File

@ -0,0 +1,166 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends PanelContainer
class_name EditorToolbar
var editor_plugin:CyclopsLevelBuilder:
get:
return editor_plugin
set(value):
editor_plugin = value
editor_plugin.active_node_changed.connect(on_active_node_changed)
#var editor_plugin:CyclopsLevelBuilder
#var action_map:Array[CyclopsAction]
func on_active_node_changed():
update_grid()
# Called when the node enters the scene tree for the first time.
func _ready():
$HBoxContainer/grid_size.clear()
$HBoxContainer/grid_size.add_item("1/16", 0)
$HBoxContainer/grid_size.add_item("1/8", 1)
$HBoxContainer/grid_size.add_item("1/4", 2)
$HBoxContainer/grid_size.add_item("1/2", 3)
$HBoxContainer/grid_size.add_item("1", 4)
$HBoxContainer/grid_size.add_item("2", 5)
$HBoxContainer/grid_size.add_item("4", 6)
$HBoxContainer/grid_size.add_item("8", 7)
$HBoxContainer/grid_size.add_item("16", 8)
$HBoxContainer/MenuBar/Menu.clear()
$HBoxContainer/MenuBar/Menu.add_action_item(ActionToolDuplicate.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionMergeSelectedBlocks.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionDeleteSelectedBlocks.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionSnapToGrid.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_separator()
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateX90Ccw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateX90Cw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateX180.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionMirrorSelectionX2.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_separator()
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateY90Ccw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateY90Cw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateY180.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionMirrorSelectionY2.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_separator()
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateZ90Ccw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateZ90Cw.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionRotateZ180.new(editor_plugin))
$HBoxContainer/MenuBar/Menu.add_action_item(ActionMirrorSelectionZ.new(editor_plugin))
update_grid()
func update_grid():
if !editor_plugin:
return
if editor_plugin.active_node:
var size:int = editor_plugin.get_global_scene().grid_size
$HBoxContainer/grid_size.select(size + 4)
$HBoxContainer/display_mode.select(editor_plugin.display_mode)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_grid_size_item_selected(index):
# if Engine.is_editor_hint():
#print("_on_grid_size_item_selected " + str(index))
# if editor_plugin.active_node:
editor_plugin.get_global_scene().grid_size = index - 4
func _on_bn_move_pressed():
editor_plugin.switch_to_tool(ToolBlock.new())
func _on_bn_clip_pressed():
editor_plugin.switch_to_tool(ToolClip.new())
func _on_bn_vertex_pressed():
editor_plugin.switch_to_tool(ToolEditVertex.new())
func _on_bn_edge_pressed():
editor_plugin.switch_to_tool(ToolEditEdge.new())
func _on_bn_face_pressed():
editor_plugin.switch_to_tool(ToolEditFace.new())
func _on_check_lock_uvs_toggled(button_pressed):
editor_plugin.lock_uvs = button_pressed
func _on_bn_prism_pressed():
editor_plugin.switch_to_tool(ToolPrism.new())
func _on_bn_cylinder_pressed():
editor_plugin.switch_to_tool(ToolCylinder.new())
func _on_bn_stairs_pressed():
editor_plugin.switch_to_tool(ToolStairs.new())
func _on_bn_duplicate_pressed():
editor_plugin.switch_to_tool(ToolDuplicate.new())
func _on_bn_delete_pressed():
var blocks_root:CyclopsBlocks = editor_plugin.active_node
var cmd:CommandDeleteBlocks = CommandDeleteBlocks.new()
cmd.blocks_root_path = blocks_root.get_path()
cmd.builder = editor_plugin
if cmd.will_change_anything():
var undo:EditorUndoRedoManager = editor_plugin.get_undo_redo()
cmd.add_to_undo_manager(undo)
func _on_bn_flip_x_pressed():
var action:ActionMirrorSelectionX2 = ActionMirrorSelectionX2.new(editor_plugin)
action._execute()
func _on_bn_flip_y_pressed():
var action:ActionMirrorSelectionY2 = ActionMirrorSelectionY2.new(editor_plugin)
action._execute()
func _on_bn_flip_z_pressed():
var action:ActionMirrorSelectionZ = ActionMirrorSelectionZ.new(editor_plugin)
action._execute()
func _on_display_mode_item_selected(index):
editor_plugin.display_mode = index

View File

@ -0,0 +1,217 @@
[gd_scene load_steps=6 format=3 uid="uid://c3cl77r65dexu"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/editor_toolbar.gd" id="1_o71fd"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/action_popup_menu.gd" id="2_ni0c8"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_o7kxq"]
[sub_resource type="Theme" id="Theme_0hxey"]
PanelContainer/styles/panel = SubResource("StyleBoxEmpty_o7kxq")
[sub_resource type="ButtonGroup" id="ButtonGroup_i8xwa"]
[node name="PanelContainer" type="PanelContainer"]
offset_right = 739.0
offset_bottom = 31.0
size_flags_horizontal = 3
theme = SubResource("Theme_0hxey")
script = ExtResource("1_o71fd")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="bn_block" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click and drag in empty space or on unselected block to create a new block.
Click and drag on a selected block to move it in the XZ plane. Hold Alt to drag along the Y axis.
Ctrl-click and drag on the face of a block to move the face along its normal.
Escape or right click to cancel drawing the block.
Click on block to select it. Shift-Click toggles, Ctrl-Click adds and Shift-Ctrl Click subtracts.
Click in empty space to clear selection."
toggle_mode = true
button_pressed = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Block"
[node name="bn_prism" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on surface of block or in empty space to begin creating base of a prism.
Click to add new point. Backspace to remove the last point you added. You can also right click on a point to remove it.
Press Enter to extrude base.
Press Enter again to finish extruding and create block."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Prism"
[node name="bn_cylinder" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on surface of block or in empty space to begin creating base of a cylinder.
Release the mouse to enter height drawing mode. If you have the tube option selected, you will draw the second ring instead.
Use the mouse wheel to change the number of sides of the cylinder while drawing."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Cylinder"
[node name="bn_stairs" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on surface of block or in empty space to begin creating base of a stair case.
Release mouse button and drag upwards to adjust the height of the stairs.
Use the mouse wheel to change the direction the stairs face. Ctrl-Wheel to change the height of each step, Ctrl-Shift-Wheel to change the depth of each step."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Stairs"
[node name="bn_clip" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on surface of block to place first cutting point.
Click again to place second cutting point. This will define the plane block will be cut along.
If you press Enter at this point, the block will be cut. The cutting plane will be defined by the cutting line you've drawn and the normal of the plane it is on.
You can optionally place a third cutting point. If you do, the three placed points will define the cutting plane when you press Enter.
Press Backspace to delete the last cutting point you placed."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Clip"
[node name="bn_vertex" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on a vertex to select it. Shift Click to toggle selecton, Ctrl Click to add to selection, Shift-Ctrl click to subtract from selection.
Click and drag to move vertex in XZ plane. Hold Alt to drag along Y axis. Click and drag on a selected vertex to move all selected vertices.
Hover the mouse over a different block and press Alt-Q to switch to editing that block."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Vertex"
[node name="bn_edge" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on an edge to select it. Shift Click to toggle selecton, Ctrl Click to add to selection, Shift-Ctrl click to subtract from selection.
Click and drag to move edge in XZ plane. Hold Alt to drag along Y axis. Click and drag on a selected edge to move all selected edges.
Hover the mouse over a different block and press Alt-Q to switch to editing that block."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Edge"
[node name="bn_face" type="Button" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Click on a face to select it. Shift Click to toggle selecton, Ctrl Click to add to selection, Shift-Ctrl click to subtract from selection.
Click and drag to move face in XZ plane. Hold Alt to drag along Y axis. Click and drag on a selected face to move all selected faces.
Hover the mouse over a different block and press Alt-Q to switch to editing that block."
toggle_mode = true
button_group = SubResource("ButtonGroup_i8xwa")
text = "Face"
[node name="MenuBar" type="MenuBar" parent="HBoxContainer"]
layout_mode = 2
[node name="Menu" type="PopupMenu" parent="HBoxContainer/MenuBar"]
item_count = 18
item_0/text = "Duplicate Selected Blocks"
item_0/id = 1000
item_1/text = "Delete Selected Blocks"
item_1/id = 1001
item_2/text = "Snap to grid"
item_2/id = 1002
item_3/text = ""
item_3/id = -1
item_3/separator = true
item_4/text = "Rotate 90 Ccw X"
item_4/id = 1003
item_5/text = "Rotate 90 Cw X"
item_5/id = 1004
item_6/text = "Rotate 180 X"
item_6/id = 1005
item_7/text = "Mirror Selection X"
item_7/id = 1006
item_8/text = ""
item_8/id = -1
item_8/separator = true
item_9/text = "Rotate 90 Ccw Y"
item_9/id = 1007
item_10/text = "Rotate 90 Cw Y"
item_10/id = 1008
item_11/text = "Rotate 180 Y"
item_11/id = 1009
item_12/text = "Mirror Selection Y"
item_12/id = 1010
item_13/text = ""
item_13/id = -1
item_13/separator = true
item_14/text = "Rotate 90 Ccw Z"
item_14/id = 1011
item_15/text = "Rotate 90 Cw Z"
item_15/id = 1012
item_16/text = "Rotate 180 Z"
item_16/id = 1013
item_17/text = "Mirror Selection Z"
item_17/id = 1014
script = ExtResource("2_ni0c8")
[node name="check_lock_uvs" type="CheckBox" parent="HBoxContainer"]
layout_mode = 2
text = "Lock UVs"
[node name="grid_size" type="OptionButton" parent="HBoxContainer"]
layout_mode = 2
tooltip_text = "Grid snapping size"
item_count = 9
selected = 0
popup/item_0/text = "1/16"
popup/item_0/id = 0
popup/item_1/text = "1/8"
popup/item_1/id = 1
popup/item_2/text = "1/4"
popup/item_2/id = 2
popup/item_3/text = "1/2"
popup/item_3/id = 3
popup/item_4/text = "1"
popup/item_4/id = 4
popup/item_5/text = "2"
popup/item_5/id = 5
popup/item_6/text = "4"
popup/item_6/id = 6
popup/item_7/text = "8"
popup/item_7/id = 7
popup/item_8/text = "16"
popup/item_8/id = 8
[node name="display_mode" type="OptionButton" parent="HBoxContainer"]
layout_mode = 2
item_count = 2
selected = 1
popup/item_0/text = "Wireframe"
popup/item_0/id = 0
popup/item_1/text = "Textured"
popup/item_1/id = 1
[connection signal="pressed" from="HBoxContainer/bn_block" to="." method="_on_bn_move_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_prism" to="." method="_on_bn_prism_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_cylinder" to="." method="_on_bn_cylinder_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_stairs" to="." method="_on_bn_stairs_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_clip" to="." method="_on_bn_clip_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_vertex" to="." method="_on_bn_vertex_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_edge" to="." method="_on_bn_edge_pressed"]
[connection signal="pressed" from="HBoxContainer/bn_face" to="." method="_on_bn_face_pressed"]
[connection signal="toggled" from="HBoxContainer/check_lock_uvs" to="." method="_on_check_lock_uvs_toggled"]
[connection signal="item_selected" from="HBoxContainer/grid_size" to="." method="_on_grid_size_item_selected"]
[connection signal="item_selected" from="HBoxContainer/display_mode" to="." method="_on_display_mode_item_selected"]

View File

@ -0,0 +1,41 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Control
class_name StickyToolbar
var plugin:CyclopsLevelBuilder
# Called when the node enters the scene tree for the first time.
func _ready():
$HBoxContainer/PanelContainer.visible = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_texture_button_toggled(button_pressed):
$HBoxContainer/PanelContainer.visible = button_pressed

View File

@ -0,0 +1,41 @@
[gd_scene load_steps=8 format=3 uid="uid://c4smddvlwx54s"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/sticky_toolbar.gd" id="1_52wtc"]
[ext_resource type="Texture2D" uid="uid://d0krdms4l6ns4" path="res://addons/cyclops_level_builder/art/cyclops_3.png" id="2_0mx5n"]
[ext_resource type="Texture2D" uid="uid://cg3yjatinkymb" path="res://addons/cyclops_level_builder/art/cyclops_4.png" id="3_5oy58"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_h0l71"]
[sub_resource type="Theme" id="Theme_dgoud"]
PanelContainer/styles/panel = SubResource("StyleBoxEmpty_h0l71")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6pjef"]
[sub_resource type="Theme" id="Theme_nckdr"]
PanelContainer/styles/panel = SubResource("StyleBoxEmpty_6pjef")
[node name="PanelContainer" type="PanelContainer"]
offset_right = 70.0
offset_bottom = 31.0
theme = SubResource("Theme_dgoud")
script = ExtResource("1_52wtc")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="CyclopsButton" type="TextureButton" parent="HBoxContainer"]
layout_mode = 2
toggle_mode = true
texture_normal = ExtResource("2_0mx5n")
texture_pressed = ExtResource("3_5oy58")
[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer"]
visible = false
layout_mode = 2
theme = SubResource("Theme_nckdr")
[node name="Button" type="Button" parent="HBoxContainer/PanelContainer"]
layout_mode = 2
text = "Block"
[connection signal="toggled" from="HBoxContainer/CyclopsButton" to="." method="_on_texture_button_toggled"]