Adds missing data
This commit is contained in:
parent
e6391d9fdd
commit
53cdcc3433
620 changed files with 47293 additions and 151 deletions
46
addons/cyclops_level_builder/menu/action_popup_menu.gd
Normal file
46
addons/cyclops_level_builder/menu/action_popup_menu.gd
Normal 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()
|
||||
|
||||
|
||||
231
addons/cyclops_level_builder/menu/editor_toolbar.gd
Normal file
231
addons/cyclops_level_builder/menu/editor_toolbar.gd
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
# 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)
|
||||
|
||||
build_ui()
|
||||
|
||||
|
||||
var tool_button_group = ButtonGroup.new()
|
||||
var override_shortcuts: Dictionary = {} #Dictionary[InputEvent, String]
|
||||
var currently_in_3d := false
|
||||
|
||||
func on_active_node_changed():
|
||||
update_grid()
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
%Menu.clear()
|
||||
%Menu.add_action_item(ActionToolDuplicate.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionMergeSelectedBlocks.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionSubtractBlock.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionIntersectBlock.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionDeleteSelectedBlocks.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionSnapToGrid.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionMergeVerticesCenter.new(editor_plugin))
|
||||
%Menu.add_separator()
|
||||
%Menu.add_action_item(ActionConvertToMesh.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionExportAsGltf.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionExportAsGodotScene.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionExportAsCyclops.new(editor_plugin))
|
||||
%Menu.add_separator()
|
||||
%Menu.add_action_item(ActionRotateX90Ccw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateX90Cw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateX180.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionMirrorSelectionX2.new(editor_plugin))
|
||||
%Menu.add_separator()
|
||||
%Menu.add_action_item(ActionRotateY90Ccw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateY90Cw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateY180.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionMirrorSelectionY2.new(editor_plugin))
|
||||
%Menu.add_separator()
|
||||
%Menu.add_action_item(ActionRotateZ90Ccw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateZ90Cw.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionRotateZ180.new(editor_plugin))
|
||||
%Menu.add_action_item(ActionMirrorSelectionZ.new(editor_plugin))
|
||||
|
||||
var global_scene = get_node("/root/CyclopsAutoload")
|
||||
|
||||
global_scene.xray_mode_changed.connect(on_xray_mode_changed)
|
||||
%bn_xray.button_pressed = global_scene.xray_mode
|
||||
|
||||
update_grid()
|
||||
|
||||
|
||||
|
||||
|
||||
var prev_button_pressed: Button = null
|
||||
func _press_button_line(button: Button) -> void:
|
||||
if prev_button_pressed != null:
|
||||
var line := prev_button_pressed.get_node_or_null('line')
|
||||
if line != null:
|
||||
prev_button_pressed.remove_child(line)
|
||||
line.queue_free()
|
||||
prev_button_pressed = null
|
||||
|
||||
var new_line := ColorRect.new()
|
||||
new_line.anchor_left = 0.05
|
||||
new_line.anchor_top = 0.9
|
||||
new_line.anchor_right = 0.95
|
||||
new_line.anchor_bottom = 0.94
|
||||
button.add_child(new_line)
|
||||
new_line.name = 'line'
|
||||
prev_button_pressed = button
|
||||
|
||||
|
||||
func build_ui():
|
||||
#Tools
|
||||
for child in %ToolButtonContainer.get_children():
|
||||
%ToolButtonContainer.remove_child(child)
|
||||
|
||||
%snap_options.clear()
|
||||
|
||||
if !editor_plugin:
|
||||
return
|
||||
|
||||
editor_plugin.main_screen_changed.connect(_on_main_screen_changed)
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
var config:CyclopsConfig = editor_plugin.config
|
||||
for tag: ToolTag in config.tool_tags:
|
||||
# print("adding tag %s" % tag.name)
|
||||
var bn:Button = Button.new()
|
||||
if tag.icon:
|
||||
bn.icon = tag.icon
|
||||
else:
|
||||
bn.text = tag.name
|
||||
|
||||
bn.name = tag.name
|
||||
|
||||
if !tag.input_events.is_empty(): #InputEvent
|
||||
if tag.input_events_override: #bool
|
||||
for v: InputEvent in tag.input_events:
|
||||
override_shortcuts[v] = tag.name #for _input function
|
||||
else:
|
||||
bn.shortcut = Shortcut.new()
|
||||
for v: InputEvent in tag.input_events:
|
||||
bn.shortcut.events.append(v)
|
||||
|
||||
bn.tooltip_text = tag.tooltip
|
||||
bn.pressed.connect(func():
|
||||
_press_button_line(bn)
|
||||
tag._activate(editor_plugin)
|
||||
)
|
||||
# print("adding bn %s" % tag.name)
|
||||
|
||||
%ToolButtonContainer.add_child(bn)
|
||||
|
||||
%display_mode.select(editor_plugin.display_mode)
|
||||
|
||||
#Snapping
|
||||
for tag in config.snapping_tags:
|
||||
if tag.icon:
|
||||
%snap_options.add_icon_item(tag.icon, tag.name)
|
||||
else:
|
||||
%snap_options.add_item(tag.name)
|
||||
|
||||
func update_grid():
|
||||
if !editor_plugin:
|
||||
return
|
||||
|
||||
#var size:int = editor_plugin.get_global_scene().grid_size
|
||||
#$HBoxContainer/grid_size.select(size + 4)
|
||||
|
||||
$HBoxContainer/display_mode.select(editor_plugin.display_mode)
|
||||
|
||||
|
||||
|
||||
func _on_main_screen_changed(screen_name: String):
|
||||
currently_in_3d = (screen_name == '3D')
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if !currently_in_3d: return
|
||||
|
||||
for v: InputEvent in override_shortcuts:
|
||||
if event.is_match(v, true) and event.is_pressed() and not event.is_echo():
|
||||
var button := %ToolButtonContainer.get_node_or_null(override_shortcuts[v] as String) as Button
|
||||
if button:
|
||||
button.pressed.emit() #simulate press
|
||||
break
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
#func _on_grid_size_item_selected(index):
|
||||
#editor_plugin.get_global_scene().grid_size = index - 4
|
||||
|
||||
|
||||
|
||||
func _on_check_lock_uvs_toggled(button_pressed):
|
||||
editor_plugin.lock_uvs = button_pressed
|
||||
|
||||
|
||||
|
||||
func _on_display_mode_item_selected(index:int):
|
||||
editor_plugin.display_mode = index
|
||||
|
||||
|
||||
func on_xray_mode_changed(value:bool):
|
||||
%bn_xray.button_pressed = value
|
||||
|
||||
func _on_bn_xray_toggled(button_pressed:bool):
|
||||
if !editor_plugin:
|
||||
return
|
||||
|
||||
var global_scene:CyclopsGlobalScene = editor_plugin.get_global_scene()
|
||||
global_scene.xray_mode = button_pressed
|
||||
|
||||
#
|
||||
#func _on_bn_snap_settings_pressed():
|
||||
## var rect:Rect2 = %bn_snap_settings.get_rect()
|
||||
#
|
||||
#var rect:Rect2 = %bn_snap_settings.get_global_rect()
|
||||
#var new_rect:Rect2 = Rect2(rect.position.x, rect.position.y + rect.size.y, 200, 100)
|
||||
#%snap_settings_popup.popup_on_parent(new_rect)
|
||||
##print("snap popup2 ", rect)
|
||||
|
||||
|
||||
func _on_snap_options_item_selected(index:int):
|
||||
var tag:SnappingTag = editor_plugin.config.snapping_tags[index]
|
||||
tag._activate(editor_plugin)
|
||||
|
||||
|
||||
|
||||
func _on_bn_snap_toggled(toggled_on):
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_ENABLED, toggled_on)
|
||||
pass # Replace with function body.
|
||||
129
addons/cyclops_level_builder/menu/editor_toolbar.tscn
Normal file
129
addons/cyclops_level_builder/menu/editor_toolbar.tscn
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
[gd_scene load_steps=7 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"]
|
||||
[ext_resource type="Texture2D" uid="uid://bs54uhn80ykrr" path="res://addons/cyclops_level_builder/art/icons/xray_normal.svg" id="3_ldp0l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dloyvoq8piwx0" path="res://addons/cyclops_level_builder/art/icons/snap.svg" id="4_begwr"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_o7kxq"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_0hxey"]
|
||||
PanelContainer/styles/panel = SubResource("StyleBoxEmpty_o7kxq")
|
||||
|
||||
[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="ToolButtonContainer" type="HBoxContainer" parent="HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MenuBar" type="MenuBar" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
prefer_global_menu = false
|
||||
|
||||
[node name="Menu" type="PopupMenu" parent="HBoxContainer/MenuBar"]
|
||||
unique_name_in_owner = true
|
||||
item_count = 27
|
||||
item_0/text = "Duplicate Selected Blocks"
|
||||
item_0/id = 1000
|
||||
item_1/text = "Merge Selected Blocks"
|
||||
item_1/id = 1001
|
||||
item_2/text = "Subtract Block"
|
||||
item_2/id = 1002
|
||||
item_3/text = "Intersect Blocks"
|
||||
item_3/id = 1003
|
||||
item_4/text = "Delete Selected Blocks"
|
||||
item_4/id = 1004
|
||||
item_5/text = "Snap to grid"
|
||||
item_5/id = 1005
|
||||
item_6/text = "Merge Vertices Center"
|
||||
item_6/id = 1006
|
||||
item_7/text = ""
|
||||
item_7/id = -1
|
||||
item_7/separator = true
|
||||
item_8/text = "Convert To Godot Mesh"
|
||||
item_8/id = 1007
|
||||
item_9/text = "Export As Gltf..."
|
||||
item_9/id = 1008
|
||||
item_10/text = "Export As Godot Scene..."
|
||||
item_10/id = 1009
|
||||
item_11/text = "Export As Cyclops File..."
|
||||
item_11/id = 1010
|
||||
item_12/text = ""
|
||||
item_12/id = -1
|
||||
item_12/separator = true
|
||||
item_13/text = "Rotate 90 Ccw X"
|
||||
item_13/id = 1011
|
||||
item_14/text = "Rotate 90 Cw X"
|
||||
item_14/id = 1012
|
||||
item_15/text = "Rotate 180 X"
|
||||
item_15/id = 1013
|
||||
item_16/text = "Mirror Selection X"
|
||||
item_16/id = 1014
|
||||
item_17/text = ""
|
||||
item_17/id = -1
|
||||
item_17/separator = true
|
||||
item_18/text = "Rotate 90 Ccw Y"
|
||||
item_18/id = 1015
|
||||
item_19/text = "Rotate 90 Cw Y"
|
||||
item_19/id = 1016
|
||||
item_20/text = "Rotate 180 Y"
|
||||
item_20/id = 1017
|
||||
item_21/text = "Mirror Selection Y"
|
||||
item_21/id = 1018
|
||||
item_22/text = ""
|
||||
item_22/id = -1
|
||||
item_22/separator = true
|
||||
item_23/text = "Rotate 90 Ccw Z"
|
||||
item_23/id = 1019
|
||||
item_24/text = "Rotate 90 Cw Z"
|
||||
item_24/id = 1020
|
||||
item_25/text = "Rotate 180 Z"
|
||||
item_25/id = 1021
|
||||
item_26/text = "Mirror Selection Z"
|
||||
item_26/id = 1022
|
||||
script = ExtResource("2_ni0c8")
|
||||
|
||||
[node name="bn_snap" type="Button" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Snapping on/off"
|
||||
toggle_mode = true
|
||||
button_pressed = true
|
||||
icon = ExtResource("4_begwr")
|
||||
|
||||
[node name="snap_options" type="OptionButton" parent="HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Snapping system"
|
||||
|
||||
[node name="display_mode" type="OptionButton" parent="HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "How the mesh is shown in the viewport."
|
||||
item_count = 3
|
||||
selected = 1
|
||||
popup/item_0/text = "Wireframe"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "Mesh"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "Materials"
|
||||
popup/item_2/id = 2
|
||||
|
||||
[node name="bn_xray" type="Button" parent="HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Xray"
|
||||
toggle_mode = true
|
||||
icon = ExtResource("3_ldp0l")
|
||||
|
||||
[connection signal="toggled" from="HBoxContainer/bn_snap" to="." method="_on_bn_snap_toggled"]
|
||||
[connection signal="item_selected" from="HBoxContainer/snap_options" to="." method="_on_snap_options_item_selected"]
|
||||
[connection signal="item_selected" from="HBoxContainer/display_mode" to="." method="_on_display_mode_item_selected"]
|
||||
[connection signal="toggled" from="HBoxContainer/bn_xray" to="." method="_on_bn_xray_toggled"]
|
||||
39
addons/cyclops_level_builder/menu/main_toolbar.gd
Normal file
39
addons/cyclops_level_builder/menu/main_toolbar.gd
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# 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 MainToolbar
|
||||
|
||||
var editor_plugin:CyclopsLevelBuilder
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
%Cyclops.clear()
|
||||
%Cyclops.add_action_item(ActionImportMeshInstance.new(editor_plugin))
|
||||
%Cyclops.add_action_item(ActionImportCyclopsFile.new(editor_plugin))
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
19
addons/cyclops_level_builder/menu/main_toolbar.tscn
Normal file
19
addons/cyclops_level_builder/menu/main_toolbar.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bm17ky7j4lwqc"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/main_toolbar.gd" id="1_7i5xc"]
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/action_popup_menu.gd" id="2_8w58b"]
|
||||
|
||||
[node name="MainToolbar" type="PanelContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_7i5xc")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MenuBar" type="MenuBar" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Cyclops" type="PopupMenu" parent="HBoxContainer/MenuBar"]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_8w58b")
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
# 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 UpgradeCyclopsBlocksToolbar
|
||||
|
||||
var editor_plugin:CyclopsLevelBuilder
|
||||
|
||||
var activated:bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_bn_upgrade_pressed():
|
||||
var ed_iface:EditorInterface = editor_plugin.get_editor_interface()
|
||||
var nodes:Array = ed_iface.get_selection().get_selected_nodes()
|
||||
|
||||
if nodes.is_empty():
|
||||
return
|
||||
|
||||
if !(nodes[0] is CyclopsBlocks):
|
||||
return
|
||||
|
||||
|
||||
var root:CyclopsBlocks = nodes[0]
|
||||
var parent:Node = root.get_parent()
|
||||
var index:int = root.get_index()
|
||||
|
||||
var new_root:Node3D = Node3D.new()
|
||||
root.add_sibling(new_root)
|
||||
new_root.name = root.name + "_upgraded"
|
||||
new_root.owner = ed_iface.get_edited_scene_root()
|
||||
|
||||
root.visible = false
|
||||
|
||||
#var grid_step_size:float = pow(2, editor_plugin.get_global_scene().grid_size)
|
||||
|
||||
for child in root.get_children():
|
||||
if child is CyclopsConvexBlock:
|
||||
var old_block:CyclopsConvexBlock = child
|
||||
|
||||
var vol:ConvexVolume = ConvexVolume.new()
|
||||
vol.init_from_mesh_vector_data(old_block.mesh_vector_data)
|
||||
var centroid:Vector3 = vol.get_centroid()
|
||||
#centroid = MathUtil.snap_to_grid(centroid, grid_step_size)
|
||||
vol.translate(-centroid)
|
||||
|
||||
var new_block:CyclopsBlock = CyclopsBlock.new()
|
||||
new_root.add_child(new_block)
|
||||
new_block.owner = ed_iface.get_edited_scene_root()
|
||||
|
||||
new_block.name = old_block.name
|
||||
new_block.materials = old_block.materials
|
||||
new_block.mesh_vector_data = vol.to_mesh_vector_data()
|
||||
new_block.global_transform = Transform3D.IDENTITY.translated(centroid)
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://u52a8gflbktl"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/menu/upgrade_cyclops_blocks_toolbar.gd" id="1_pbwhi"]
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_pbwhi")
|
||||
|
||||
[node name="bn_upgrade" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Upgrade CyclopsBlocks"
|
||||
|
||||
[connection signal="pressed" from="bn_upgrade" to="." method="_on_bn_upgrade_pressed"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue