simple composable grid context and grid controller, fiend sprite, godotxel addon
This commit is contained in:
73
addons/Godoxel/components/AnimationButton.gd
Normal file
73
addons/Godoxel/components/AnimationButton.gd
Normal file
@ -0,0 +1,73 @@
|
||||
extends Button
|
||||
tool
|
||||
|
||||
signal on_animation_button_pressed()
|
||||
|
||||
onready var line_edit = $LineEdit
|
||||
onready var label = $Label
|
||||
|
||||
var press_pos
|
||||
var release_pos
|
||||
var moved = false
|
||||
|
||||
|
||||
func _ready():
|
||||
line_edit.hide()
|
||||
set_process_input(false)
|
||||
|
||||
|
||||
func _input(event: InputEvent):
|
||||
if event is InputEventKey:
|
||||
if event.pressed and event.scancode == KEY_ESCAPE:
|
||||
line_edit.hide()
|
||||
line_edit.text = label.text
|
||||
elif event is InputEventMouseButton:
|
||||
if line_edit.visible and event.pressed and event.button_index == BUTTON_LEFT:
|
||||
line_edit.hide()
|
||||
line_edit.text = label.text
|
||||
|
||||
|
||||
func _on_TextButton_gui_input(event: InputEvent):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
if not event.pressed:
|
||||
if !moved:
|
||||
if not line_edit.visible:
|
||||
line_edit.show()
|
||||
line_edit.grab_focus()
|
||||
line_edit.grab_click_focus()
|
||||
line_edit.caret_position = line_edit.text.length() - 1
|
||||
else:
|
||||
line_edit.hide()
|
||||
elif line_edit.visible:
|
||||
line_edit.hide()
|
||||
else:
|
||||
moved = false
|
||||
elif event is InputEventMouseMotion:
|
||||
moved = true
|
||||
|
||||
|
||||
func _on_LineEdit_focus_exited():
|
||||
label.text = line_edit.text
|
||||
if not Rect2(rect_global_position, rect_size).has_point(get_global_mouse_position()):
|
||||
line_edit.hide()
|
||||
|
||||
|
||||
func _on_LineEdit_text_entered(new_text: String):
|
||||
label.text = new_text
|
||||
line_edit.hide()
|
||||
|
||||
|
||||
func _on_AnimationButton_pressed():
|
||||
line_edit.hide()
|
||||
emit_signal("on_animation_button_pressed")
|
||||
# if line_edit.visible:
|
||||
# line_edit.hide()
|
||||
# else:
|
||||
# line_edit.show()
|
||||
# line_edit.grab_focus()
|
||||
# line_edit.grab_click_focus()
|
||||
|
||||
|
||||
func _on_LineEdit_visibility_changed():
|
||||
set_process_input(line_edit.visible)
|
64
addons/Godoxel/components/AnimationButton.tscn
Normal file
64
addons/Godoxel/components/AnimationButton.tscn
Normal file
@ -0,0 +1,64 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/AnimationButton.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0.12549 )
|
||||
|
||||
[node name="AnimationButton" type="Button"]
|
||||
margin_right = 250.0
|
||||
margin_bottom = 42.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextButton" type="Button" parent="."]
|
||||
anchor_left = 0.14
|
||||
anchor_top = 0.261905
|
||||
anchor_right = 0.86
|
||||
anchor_bottom = 0.738095
|
||||
margin_top = -9.53674e-07
|
||||
custom_styles/hover = SubResource( 1 )
|
||||
custom_styles/pressed = SubResource( 1 )
|
||||
custom_styles/focus = SubResource( 1 )
|
||||
custom_styles/disabled = SubResource( 1 )
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
text = "Animation"
|
||||
align = 1
|
||||
valign = 1
|
||||
clip_text = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="."]
|
||||
visible = false
|
||||
anchor_left = 0.108
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.892
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -0.0559998
|
||||
margin_top = -12.0
|
||||
margin_right = 0.0559998
|
||||
margin_bottom = 12.0
|
||||
mouse_filter = 2
|
||||
text = "Animation"
|
||||
caret_blink = true
|
||||
caret_blink_speed = 0.5
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="." to="." method="_on_AnimationButton_pressed"]
|
||||
[connection signal="gui_input" from="TextButton" to="." method="_on_TextButton_gui_input"]
|
||||
[connection signal="focus_exited" from="LineEdit" to="." method="_on_LineEdit_focus_exited"]
|
||||
[connection signal="text_entered" from="LineEdit" to="." method="_on_LineEdit_text_entered"]
|
||||
[connection signal="visibility_changed" from="LineEdit" to="." method="_on_LineEdit_visibility_changed"]
|
157
addons/Godoxel/components/AnimationPanel.gd
Normal file
157
addons/Godoxel/components/AnimationPanel.gd
Normal file
@ -0,0 +1,157 @@
|
||||
extends Panel
|
||||
tool
|
||||
|
||||
signal on_add_animation()
|
||||
signal on_frame_pressed(anim, frame_button)
|
||||
signal on_add_frame_pressed(anim, frame_button)
|
||||
signal on_animation_pressed(anim)
|
||||
|
||||
signal on_play_pause_pressed()
|
||||
signal on_animation_frame_rate_changed(new_frame_rate)
|
||||
signal on_animation_loop_toggled()
|
||||
|
||||
signal on_animation_move(from, to)
|
||||
signal on_animation_duplicated(anim)
|
||||
|
||||
signal on_animation_selected(anim)
|
||||
signal on_animation_deleted(anim)
|
||||
|
||||
|
||||
const AnimationStripe = preload("res://addons/Godoxel/components/AnimationStripe.tscn")
|
||||
|
||||
onready var anim_button_container = find_node("AnimationButtons")
|
||||
onready var play_pause_button = find_node("PlayPause")
|
||||
onready var add_animation_button = find_node("AddAnimation") # for dragging
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func _on_moved(from, to):
|
||||
if from > to:
|
||||
_move_animation_up(from, to)
|
||||
elif from != to:
|
||||
_move_animation_up(from, to)
|
||||
anim_button_container.queue_sort()
|
||||
|
||||
|
||||
func _move_animation_up(anim_idx, pos):
|
||||
anim_button_container.move_child(anim_button_container.get_child(anim_idx), pos)
|
||||
emit_signal("on_animation_move", anim_idx, pos)
|
||||
|
||||
|
||||
func move_animation_up(anim_idx):
|
||||
var pos = max(anim_idx - 1, 0)
|
||||
anim_button_container.move_child(anim_button_container.get_child(anim_idx), pos)
|
||||
emit_signal("on_animation_move", anim_idx, pos)
|
||||
|
||||
|
||||
func move_animation_down(anim_idx):
|
||||
var pos = min(anim_idx + 1, anim_button_container.get_child_count() - 1)
|
||||
anim_button_container.move_child(anim_button_container.get_child(anim_idx), pos)
|
||||
emit_signal("on_animation_move", anim_idx, pos)
|
||||
|
||||
|
||||
func clear_all():
|
||||
for anim_button in anim_button_container.get_children():
|
||||
anim_button_container.remove_child(anim_button)
|
||||
anim_button.queue_free()
|
||||
|
||||
|
||||
func update_all_frame_button_previews():
|
||||
for anim_stripe in anim_button_container.get_children():
|
||||
for frame_button in anim_stripe.frame_button_container.get_children():
|
||||
for layer in frame_button.frame.layers:
|
||||
layer.update_texture()
|
||||
frame_button.update_preview()
|
||||
|
||||
|
||||
func set_frame_preview(anim_idx, frame_idx, frame):
|
||||
if anim_button_container.get_child(anim_idx).get_frame_button(frame_idx):
|
||||
anim_button_container.get_child(anim_idx).get_frame_button(frame_idx).set_frame(frame)
|
||||
|
||||
|
||||
func get_frame_button(anim_idx, frame_idx):
|
||||
return anim_button_container.get_child(anim_idx).get_frame_button(frame_idx)
|
||||
|
||||
|
||||
func get_animation_stripe(anim_idx):
|
||||
return anim_button_container.get_child(anim_idx)
|
||||
|
||||
|
||||
func get_last_animation_stripe():
|
||||
return get_animation_stripe(anim_button_container.get_child_count()-1)
|
||||
|
||||
|
||||
func _on_AddAnimation_pressed():
|
||||
emit_signal("on_add_animation")
|
||||
|
||||
|
||||
func add_animation_stripe():
|
||||
var anim_stripe = AnimationStripe.instance()
|
||||
anim_button_container.add_child(anim_stripe)
|
||||
anim_stripe.connect("on_frame_pressed", self, "_on_frame_pressed")
|
||||
anim_stripe.connect("on_add_frame_pressed", self, "_on_add_frame_pressed")
|
||||
anim_stripe.connect("on_animation_pressed", self, "_on_animation_pressed")
|
||||
anim_stripe.connect("on_move_down_pressed", self, "move_animation_down")
|
||||
anim_stripe.connect("on_move_up_pressed", self, "move_animation_up")
|
||||
anim_stripe.connect("on_moved", self, "_on_moved")
|
||||
anim_stripe.connect("on_animation_duplicated", self, "_on_animation_duplicated")
|
||||
anim_stripe.connect("on_animation_selected", self, "_on_animation_selected")
|
||||
anim_stripe.connect("on_deleted", self, "_on_deleted")
|
||||
|
||||
anim_stripe.add_new_frame_button()
|
||||
|
||||
return anim_stripe
|
||||
|
||||
|
||||
func _on_animation_pressed(anim_idx):
|
||||
emit_signal("on_animation_pressed", anim_idx)
|
||||
|
||||
|
||||
func _on_add_frame_pressed(anim, frame_button):
|
||||
emit_signal("on_add_frame_pressed", anim, frame_button)
|
||||
|
||||
|
||||
func _on_frame_pressed(anim, frame_button):
|
||||
emit_signal("on_frame_pressed", anim, frame_button)
|
||||
|
||||
|
||||
func get_animation_container():
|
||||
return anim_button_container
|
||||
|
||||
|
||||
func set_play_pause_button(playing: bool):
|
||||
if playing:
|
||||
play_pause_button.text = "Pause"
|
||||
else:
|
||||
play_pause_button.text = "Play"
|
||||
|
||||
|
||||
func _on_PlayPause_pressed():
|
||||
if play_pause_button.text == "Play":
|
||||
play_pause_button.text = "Pause"
|
||||
else:
|
||||
play_pause_button.text = "Play"
|
||||
emit_signal("on_play_pause_pressed")
|
||||
|
||||
|
||||
func _on_FrameRate_value_changed(value):
|
||||
emit_signal("on_animation_frame_rate_changed", value)
|
||||
|
||||
|
||||
func _on_ToggleAnimationLoop_pressed():
|
||||
emit_signal("on_animation_loop_toggled")
|
||||
|
||||
|
||||
func _on_animation_duplicated(anim):
|
||||
emit_signal("on_animation_duplicated", anim)
|
||||
|
||||
|
||||
func _on_animation_selected(anim):
|
||||
emit_signal("on_animation_selected", anim)
|
||||
|
||||
|
||||
func _on_deleted(anim):
|
||||
emit_signal("on_animation_deleted", anim)
|
109
addons/Godoxel/components/AnimationPanel.tscn
Normal file
109
addons/Godoxel/components/AnimationPanel.tscn
Normal file
@ -0,0 +1,109 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/AnimationPanel.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.2, 0.227451, 0.309804, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.12549, 0.141176, 0.192157, 1 )
|
||||
|
||||
[node name="AnimationPanel" type="Panel"]
|
||||
margin_right = 653.0
|
||||
margin_bottom = 120.0
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="VBoxContainer"]
|
||||
margin_right = 653.0
|
||||
margin_bottom = 40.0
|
||||
rect_min_size = Vector2( 0, 40 )
|
||||
custom_styles/panel = SubResource( 2 )
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_constants/separation = 20
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PlayPause" type="Button" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
margin_top = 5.0
|
||||
margin_right = 60.0
|
||||
margin_bottom = 35.0
|
||||
rect_min_size = Vector2( 60, 30 )
|
||||
size_flags_vertical = 4
|
||||
text = "Play"
|
||||
|
||||
[node name="FrameRate" type="SpinBox" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
margin_left = 80.0
|
||||
margin_top = 4.0
|
||||
margin_right = 154.0
|
||||
margin_bottom = 36.0
|
||||
rect_min_size = Vector2( 0, 32 )
|
||||
size_flags_vertical = 4
|
||||
min_value = 0.001
|
||||
max_value = 200.0
|
||||
step = 0.1
|
||||
value = 5.0
|
||||
align = 1
|
||||
suffix = "fps"
|
||||
|
||||
[node name="ToggleAnimationLoop" type="CheckButton" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
margin_left = 174.0
|
||||
margin_right = 285.0
|
||||
margin_bottom = 40.0
|
||||
pressed = true
|
||||
text = "Loop"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
margin_top = 44.0
|
||||
margin_right = 653.0
|
||||
margin_bottom = 120.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer2" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
margin_right = 653.0
|
||||
margin_bottom = 76.0
|
||||
rect_min_size = Vector2( 450, 0 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="AnimationButtons" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/HBoxContainer2"]
|
||||
margin_right = 653.0
|
||||
size_flags_horizontal = 3
|
||||
custom_constants/separation = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/HBoxContainer2"]
|
||||
margin_top = 4.0
|
||||
margin_right = 120.0
|
||||
margin_bottom = 34.0
|
||||
size_flags_horizontal = 0
|
||||
|
||||
[node name="AddAnimation" type="Button" parent="VBoxContainer/ScrollContainer/HBoxContainer2/VBoxContainer"]
|
||||
margin_right = 120.0
|
||||
margin_bottom = 30.0
|
||||
rect_min_size = Vector2( 120, 30 )
|
||||
text = "+"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/Panel/HBoxContainer/PlayPause" to="." method="_on_PlayPause_pressed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/Panel/HBoxContainer/FrameRate" to="." method="_on_FrameRate_value_changed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Panel/HBoxContainer/ToggleAnimationLoop" to="." method="_on_ToggleAnimationLoop_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/ScrollContainer/HBoxContainer2/VBoxContainer/AddAnimation" to="." method="_on_AddAnimation_pressed"]
|
141
addons/Godoxel/components/AnimationStripe.gd
Normal file
141
addons/Godoxel/components/AnimationStripe.gd
Normal file
@ -0,0 +1,141 @@
|
||||
extends Panel
|
||||
tool
|
||||
|
||||
signal on_frame_pressed(anim, btn)
|
||||
signal on_add_frame_pressed(anim, btn)
|
||||
signal on_animation_pressed(anim)
|
||||
|
||||
signal on_move_up_pressed(index)
|
||||
signal on_move_down_pressed(index)
|
||||
signal on_moved(form, to)
|
||||
|
||||
signal on_animation_duplicated(anim)
|
||||
signal on_animation_selected(anim)
|
||||
|
||||
signal on_deleted(anim)
|
||||
|
||||
const FrameButton = preload("res://addons/Godoxel/components/FrameButton.tscn")
|
||||
|
||||
const StyleNormal = preload("res://addons/Godoxel/themes/AnimationStripe_Panel_normal.tres")
|
||||
const StyleDragging = preload("res://addons/Godoxel/themes/AnimationStripe_Panel_dragging.tres")
|
||||
const StyleDraggable = preload("res://addons/Godoxel/themes/AnimationStripe_Panel_draggable.tres")
|
||||
|
||||
onready var frame_button_container = find_node("FrameContainer")
|
||||
onready var anim_button = find_node("AnimationButton")
|
||||
var frames = []
|
||||
var animation: GEAnimation
|
||||
|
||||
|
||||
func _ready():
|
||||
set("custom_styles/panel", StyleNormal)
|
||||
|
||||
|
||||
var previous_index = -1
|
||||
var current_index = -1
|
||||
var dragging = false
|
||||
var mouse_offset = Vector2.ZERO
|
||||
func _input(event):
|
||||
if not dragging:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and event.pressed:
|
||||
if not dragging and get_global_rect().has_point(get_global_mouse_position()):
|
||||
dragging = true
|
||||
set("custom_styles/panel", StyleDragging)
|
||||
var mp = get_global_mouse_position()
|
||||
mouse_offset = mp - rect_global_position
|
||||
emit_signal("on_animation_selected", get_index())
|
||||
if event is InputEventMouseMotion:
|
||||
if get_global_rect().has_point(get_global_mouse_position()):
|
||||
set("custom_styles/panel", StyleDraggable)
|
||||
else:
|
||||
set("custom_styles/panel", StyleNormal)
|
||||
return
|
||||
|
||||
if dragging and event is InputEventMouseButton:
|
||||
if not event.pressed and event.button_index == BUTTON_LEFT:
|
||||
dragging = false
|
||||
current_index = -1
|
||||
current_index = -1
|
||||
mouse_offset = Vector2.ZERO
|
||||
get_parent().update()
|
||||
return
|
||||
|
||||
previous_index = current_index
|
||||
|
||||
var mp = get_global_mouse_position().y - get_parent().rect_global_position.y
|
||||
var y_index = mp / (rect_size.y + get_parent().get("custom_constants/separation"))
|
||||
y_index = clamp(int(y_index), 0, get_parent().get_child_count()-1)
|
||||
current_index = y_index
|
||||
|
||||
if previous_index != current_index and previous_index != -1:
|
||||
emit_signal("on_moved", previous_index, current_index)
|
||||
|
||||
|
||||
func set_animation(animation):
|
||||
self.animation = animation
|
||||
|
||||
|
||||
func get_animation_name() -> String:
|
||||
return anim_button.label.text
|
||||
|
||||
|
||||
func set_animation_name(anim_name: String):
|
||||
anim_button.label.text = anim_name
|
||||
anim_button.line_edit.text = anim_name
|
||||
|
||||
|
||||
func get_frame_button(idx):
|
||||
return frame_button_container.get_child(idx)
|
||||
|
||||
|
||||
func add_new_frame_button():
|
||||
var frame_button = FrameButton.instance()
|
||||
frame_button_container.add_child(frame_button)
|
||||
frame_button.connect("on_frame_pressed", self, "_on_frame_pressed")
|
||||
return frame_button
|
||||
|
||||
|
||||
func add_frame(frame):
|
||||
var frame_button = add_new_frame_button()
|
||||
frame_button.set_frame(frame)
|
||||
return frame_button
|
||||
|
||||
|
||||
func remove_frame(idx):
|
||||
var child = frame_button_container.get_child(idx)
|
||||
frame_button_container.remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
|
||||
func _on_frame_pressed(frame_btn_index):
|
||||
emit_signal("on_frame_pressed", get_index(), frame_btn_index)
|
||||
|
||||
|
||||
func _on_AddFrame_pressed():
|
||||
var frame_button = add_new_frame_button()
|
||||
emit_signal("on_add_frame_pressed", get_index(), frame_button.get_index())
|
||||
|
||||
|
||||
func _on_AnimationButton_on_animation_button_pressed():
|
||||
emit_signal("on_animation_pressed", get_index())
|
||||
|
||||
|
||||
func _on_AnimationButton_pressed():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_Up_pressed():
|
||||
emit_signal("on_move_up_pressed", get_index())
|
||||
|
||||
|
||||
func _on_Down_pressed():
|
||||
emit_signal("on_move_down_pressed", get_index())
|
||||
|
||||
|
||||
func _on_Duplicate_pressed():
|
||||
emit_signal("on_animation_duplicated", get_index())
|
||||
|
||||
|
||||
func _on_Delete_pressed():
|
||||
emit_signal("on_deleted", get_index())
|
||||
|
132
addons/Godoxel/components/AnimationStripe.tscn
Normal file
132
addons/Godoxel/components/AnimationStripe.tscn
Normal file
@ -0,0 +1,132 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/AnimationButton.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/Godoxel/components/AnimationStripe.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/Godoxel/themes/AnimationStripe_Panel_normal.tres" type="StyleBox" id=3]
|
||||
[ext_resource path="res://addons/Godoxel/assets/bitstream_vera_sans_font_6016/Vera.ttf" type="DynamicFontData" id=4]
|
||||
[ext_resource path="res://addons/Godoxel/assets/animation_arrow_up.png" type="Texture" id=5]
|
||||
[ext_resource path="res://addons/Godoxel/assets/animation_arrow_down.png" type="Texture" id=6]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 12
|
||||
use_filter = true
|
||||
font_data = ExtResource( 4 )
|
||||
|
||||
[node name="AnimationStripe" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -813.0
|
||||
margin_bottom = -666.0
|
||||
rect_min_size = Vector2( 0, 54 )
|
||||
size_flags_horizontal = 3
|
||||
custom_styles/panel = ExtResource( 3 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_right = -4.0
|
||||
rect_pivot_offset = Vector2( -149, -134 )
|
||||
size_flags_horizontal = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AnimationButton" parent="HBoxContainer" instance=ExtResource( 1 )]
|
||||
margin_top = 7.0
|
||||
margin_right = 120.0
|
||||
margin_bottom = 47.0
|
||||
rect_min_size = Vector2( 120, 40 )
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
|
||||
margin_left = 124.0
|
||||
margin_right = 152.0
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
custom_constants/separation = 5
|
||||
alignment = 1
|
||||
|
||||
[node name="Up" type="TextureButton" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_top = 6.0
|
||||
margin_right = 28.0
|
||||
margin_bottom = 18.0
|
||||
rect_min_size = Vector2( 28, 12 )
|
||||
size_flags_vertical = 6
|
||||
texture_normal = ExtResource( 5 )
|
||||
expand = true
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Down" type="TextureButton" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_top = 35.0
|
||||
margin_right = 28.0
|
||||
margin_bottom = 47.0
|
||||
rect_min_size = Vector2( 28, 12 )
|
||||
size_flags_vertical = 6
|
||||
texture_normal = ExtResource( 6 )
|
||||
expand = true
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
||||
margin_left = 156.0
|
||||
margin_right = 333.0
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 80, 0 )
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
scroll_vertical_enabled = false
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/ScrollContainer"]
|
||||
margin_right = 54.0
|
||||
margin_bottom = 54.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="FrameContainer" type="HBoxContainer" parent="HBoxContainer/ScrollContainer/HBoxContainer"]
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 0, 38 )
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/ScrollContainer/HBoxContainer"]
|
||||
margin_left = 4.0
|
||||
margin_right = 54.0
|
||||
margin_bottom = 54.0
|
||||
size_flags_vertical = 5
|
||||
|
||||
[node name="AddFrame" type="Button" parent="HBoxContainer/ScrollContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_right = 50.0
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 50, 0 )
|
||||
text = "+"
|
||||
|
||||
[node name="Duplicate" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 337.0
|
||||
margin_top = 9.0
|
||||
margin_right = 406.0
|
||||
margin_bottom = 44.0
|
||||
rect_min_size = Vector2( 0, 35 )
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Duplicate"
|
||||
|
||||
[node name="Delete" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 410.0
|
||||
margin_top = 9.0
|
||||
margin_right = 459.0
|
||||
margin_bottom = 44.0
|
||||
rect_min_size = Vector2( 0, 35 )
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "delete"
|
||||
|
||||
[connection signal="on_animation_button_pressed" from="HBoxContainer/AnimationButton" to="." method="_on_AnimationButton_on_animation_button_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/AnimationButton" to="." method="_on_AnimationButton_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/VBoxContainer/Up" to="." method="_on_Up_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/VBoxContainer/Down" to="." method="_on_Down_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/ScrollContainer/HBoxContainer/HBoxContainer/AddFrame" to="." method="_on_AddFrame_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Duplicate" to="." method="_on_Duplicate_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Delete" to="." method="_on_Delete_pressed"]
|
55
addons/Godoxel/components/FrameButton.gd
Normal file
55
addons/Godoxel/components/FrameButton.gd
Normal file
@ -0,0 +1,55 @@
|
||||
extends Button
|
||||
tool
|
||||
|
||||
signal on_frame_pressed(btn)
|
||||
|
||||
onready var frame_preview := find_node("TextureRect")
|
||||
|
||||
var frame: GEFrame
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func set_frame(frame: GEFrame):
|
||||
self.frame = frame
|
||||
update_preview()
|
||||
|
||||
|
||||
func set_layer_visibility(layer_idx: int, visibility: bool):
|
||||
frame.layers[layer_idx].visible = visibility
|
||||
|
||||
|
||||
func update_preview():
|
||||
for child in get_children():
|
||||
remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
for layer in frame.layers:
|
||||
if not layer.visible:
|
||||
continue
|
||||
var texture_rect = TextureRect.new()
|
||||
add_child(texture_rect)
|
||||
texture_rect.expand = true
|
||||
texture_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
texture_rect.anchor_bottom = 1
|
||||
texture_rect.anchor_right = 1
|
||||
texture_rect.margin_left = 3
|
||||
texture_rect.margin_top = 3
|
||||
texture_rect.margin_right = -3
|
||||
texture_rect.margin_bottom = -3
|
||||
|
||||
texture_rect.texture = layer.texture
|
||||
|
||||
|
||||
func move_layer_forward():
|
||||
pass
|
||||
|
||||
|
||||
func move_layer_back():
|
||||
pass
|
||||
|
||||
|
||||
func _on_FrameButton_pressed():
|
||||
emit_signal("on_frame_pressed", get_index())
|
50
addons/Godoxel/components/FrameButton.tscn
Normal file
50
addons/Godoxel/components/FrameButton.tscn
Normal file
@ -0,0 +1,50 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/FrameButton.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.933333, 0.933333, 0.933333, 1 )
|
||||
border_color = Color( 0.266667, 0.266667, 0.266667, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.933333, 0.933333, 0.933333, 1 )
|
||||
border_width_left = 3
|
||||
border_width_top = 3
|
||||
border_width_right = 3
|
||||
border_width_bottom = 3
|
||||
border_color = Color( 0.662745, 0.662745, 0.662745, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.721569, 0.721569, 0.721569, 1 )
|
||||
border_width_left = 3
|
||||
border_width_top = 3
|
||||
border_width_right = 3
|
||||
border_width_bottom = 3
|
||||
border_color = Color( 0.45098, 0.45098, 0.45098, 1 )
|
||||
|
||||
[node name="FrameButton" type="Button"]
|
||||
margin_right = 50.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 50, 50 )
|
||||
custom_styles/hover = SubResource( 3 )
|
||||
custom_styles/focus = SubResource( 2 )
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = -3.0
|
||||
margin_bottom = -3.0
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="." to="." method="_on_FrameButton_pressed"]
|
29
addons/Godoxel/components/ShortcutPanel.gd
Normal file
29
addons/Godoxel/components/ShortcutPanel.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends Panel
|
||||
tool
|
||||
|
||||
onready var name_label = find_node("Name")
|
||||
onready var shortcut_label = find_node("Shortcut")
|
||||
|
||||
const select_theme = preload("res://addons/Godoxel/themes/ShortcutPanel_selected.tres")
|
||||
const deselect_theme = preload("res://addons/Godoxel/themes/ShortcutPanel_deselected.tres")
|
||||
|
||||
|
||||
func _ready():
|
||||
set("custom_styles/panel", deselect_theme)
|
||||
|
||||
|
||||
func set_tool(tool_name, tool_shortcut):
|
||||
name_label.text = tool_name
|
||||
shortcut_label.text = tool_shortcut
|
||||
|
||||
|
||||
func select():
|
||||
set("custom_styles/panel", select_theme)
|
||||
|
||||
|
||||
func deselect():
|
||||
set("custom_styles/panel", deselect_theme)
|
||||
|
||||
|
||||
func get_shortcut():
|
||||
return shortcut_label.text
|
39
addons/Godoxel/components/ShortcutPanel.tscn
Normal file
39
addons/Godoxel/components/ShortcutPanel.tscn
Normal file
@ -0,0 +1,39 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/ShortcutPanel.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/Godoxel/themes/ShortcutPanel_deselected.tres" type="StyleBox" id=2]
|
||||
|
||||
[node name="ShortcutPanel" type="Panel"]
|
||||
margin_right = 85.0
|
||||
margin_bottom = 75.0
|
||||
rect_min_size = Vector2( 85, 75 )
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
custom_styles/panel = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Name" type="Label" parent="VBoxContainer"]
|
||||
margin_right = 85.0
|
||||
margin_bottom = 35.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
align = 1
|
||||
valign = 2
|
||||
|
||||
[node name="Shortcut" type="Label" parent="VBoxContainer"]
|
||||
margin_top = 39.0
|
||||
margin_right = 85.0
|
||||
margin_bottom = 75.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
align = 1
|
59
addons/Godoxel/components/ShortcutWindow.gd
Normal file
59
addons/Godoxel/components/ShortcutWindow.gd
Normal file
@ -0,0 +1,59 @@
|
||||
extends Panel
|
||||
tool
|
||||
|
||||
onready var shortcut_container = find_node("ShortcutContainer")
|
||||
|
||||
var shortcuts = {}
|
||||
var shift_pressed = false
|
||||
var panels = []
|
||||
|
||||
|
||||
func _ready():
|
||||
hide()
|
||||
panels.clear()
|
||||
for child in get_child(0).get_children():
|
||||
for panel in child.get_children():
|
||||
if panel is Panel:
|
||||
panels.append(panel)
|
||||
|
||||
|
||||
func setup(shortcuts: Dictionary):
|
||||
self.shortcuts = shortcuts
|
||||
var idx = 0
|
||||
for panel in panels:
|
||||
var tool_name = ""
|
||||
if typeof(shortcuts.values()[idx]) == TYPE_STRING:
|
||||
tool_name = str(shortcuts.values()[idx])
|
||||
else:
|
||||
tool_name = str(owner.Tools.keys()[shortcuts.values()[idx]])
|
||||
tool_name = tool_name.to_lower().capitalize()
|
||||
|
||||
var shortcut = OS.get_scancode_string(shortcuts.keys()[idx])
|
||||
panel.set_tool(tool_name, shortcut)
|
||||
idx += 1
|
||||
|
||||
|
||||
func check_input_for_shorcut(event: InputEvent, shift_pressed: bool):
|
||||
if not event is InputEventKey:
|
||||
return
|
||||
|
||||
if event.pressed:
|
||||
if event.scancode in shortcuts.keys():
|
||||
for panel in panels:
|
||||
panel.deselect()
|
||||
get_panel(event.as_text()).select()
|
||||
return true
|
||||
else:
|
||||
for panel in panels:
|
||||
panel.deselect()
|
||||
return false
|
||||
|
||||
|
||||
func get_panel(scancode: String):
|
||||
var character = scancode.substr(scancode.length() - 1, 1)
|
||||
for panel in panels:
|
||||
if panel.get_shortcut() == character:
|
||||
return panel
|
||||
return null
|
||||
|
||||
|
114
addons/Godoxel/components/ShortcutWindow.tscn
Normal file
114
addons/Godoxel/components/ShortcutWindow.tscn
Normal file
@ -0,0 +1,114 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/Godoxel/components/ShortcutWindow.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/Godoxel/components/ShortcutPanel.tscn" type="PackedScene" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.247059, 0.239216, 0.239216, 0.819608 )
|
||||
border_color = Color( 1, 1, 1, 1 )
|
||||
border_blend = true
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 80
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 80
|
||||
|
||||
[node name="ShortcutWindow" type="Panel"]
|
||||
visible = false
|
||||
margin_right = 390.0
|
||||
margin_bottom = 328.0
|
||||
rect_pivot_offset = Vector2( -497, -187 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ShortcutContainer" type="VBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -189.0
|
||||
margin_top = -124.0
|
||||
margin_right = 158.0
|
||||
margin_bottom = 158.0
|
||||
custom_constants/separation = 15
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="ShortcutContainer"]
|
||||
margin_right = 355.0
|
||||
margin_bottom = 75.0
|
||||
size_flags_vertical = 0
|
||||
custom_constants/separation = 15
|
||||
alignment = 1
|
||||
|
||||
[node name="PAINT" parent="ShortcutContainer/HBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_left = 35.0
|
||||
margin_right = 120.0
|
||||
|
||||
[node name="BUCKET" parent="ShortcutContainer/HBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_left = 135.0
|
||||
margin_right = 220.0
|
||||
|
||||
[node name="RAINBOW" parent="ShortcutContainer/HBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_left = 235.0
|
||||
margin_right = 320.0
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="ShortcutContainer"]
|
||||
margin_top = 90.0
|
||||
margin_right = 355.0
|
||||
margin_bottom = 165.0
|
||||
size_flags_vertical = 0
|
||||
custom_constants/separation = 15
|
||||
alignment = 1
|
||||
|
||||
[node name="Control" type="Control" parent="ShortcutContainer/HBoxContainer2"]
|
||||
margin_left = 17.0
|
||||
margin_right = 37.0
|
||||
margin_bottom = 75.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
|
||||
[node name="LINE" parent="ShortcutContainer/HBoxContainer2" instance=ExtResource( 2 )]
|
||||
margin_left = 52.0
|
||||
margin_right = 137.0
|
||||
|
||||
[node name="RECT" parent="ShortcutContainer/HBoxContainer2" instance=ExtResource( 2 )]
|
||||
margin_left = 152.0
|
||||
margin_right = 237.0
|
||||
|
||||
[node name="COLORPICKER" parent="ShortcutContainer/HBoxContainer2" instance=ExtResource( 2 )]
|
||||
margin_left = 252.0
|
||||
margin_right = 337.0
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="ShortcutContainer"]
|
||||
margin_top = 180.0
|
||||
margin_right = 355.0
|
||||
margin_bottom = 255.0
|
||||
size_flags_vertical = 0
|
||||
custom_constants/separation = 15
|
||||
alignment = 1
|
||||
|
||||
[node name="Control" type="Control" parent="ShortcutContainer/HBoxContainer3"]
|
||||
margin_right = 20.0
|
||||
margin_bottom = 75.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
|
||||
[node name="Control2" type="Control" parent="ShortcutContainer/HBoxContainer3"]
|
||||
margin_left = 35.0
|
||||
margin_right = 55.0
|
||||
margin_bottom = 75.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
|
||||
[node name="BRIGHTEN" parent="ShortcutContainer/HBoxContainer3" instance=ExtResource( 2 )]
|
||||
margin_left = 70.0
|
||||
margin_right = 155.0
|
||||
|
||||
[node name="DARKEN" parent="ShortcutContainer/HBoxContainer3" instance=ExtResource( 2 )]
|
||||
margin_left = 170.0
|
||||
margin_right = 255.0
|
||||
|
||||
[node name="CUT" parent="ShortcutContainer/HBoxContainer3" instance=ExtResource( 2 )]
|
||||
margin_left = 270.0
|
||||
margin_right = 355.0
|
Reference in New Issue
Block a user