diff --git a/assets/graphics/cursor_icons/text_cursor.png b/assets/graphics/cursor_icons/text_cursor.png new file mode 100644 index 0000000..1f27a31 Binary files /dev/null and b/assets/graphics/cursor_icons/text_cursor.png differ diff --git a/assets/graphics/cursor_icons/text_cursor.png.import b/assets/graphics/cursor_icons/text_cursor.png.import new file mode 100644 index 0000000..e32dd03 --- /dev/null +++ b/assets/graphics/cursor_icons/text_cursor.png.import @@ -0,0 +1,13 @@ +[remap] + +importer="image" +type="Image" +path="res://.import/text_cursor.png-46628cf6392befd7350cadc065719d3b.image" + +[deps] + +source_file="res://assets/graphics/cursor_icons/text_cursor.png" +dest_files=[ "res://.import/text_cursor.png-46628cf6392befd7350cadc065719d3b.image" ] + +[params] + diff --git a/assets/graphics/dark_themes/tools/text.png b/assets/graphics/dark_themes/tools/text.png new file mode 100644 index 0000000..1f27a31 Binary files /dev/null and b/assets/graphics/dark_themes/tools/text.png differ diff --git a/assets/graphics/dark_themes/tools/text.png.import b/assets/graphics/dark_themes/tools/text.png.import new file mode 100644 index 0000000..325777e --- /dev/null +++ b/assets/graphics/dark_themes/tools/text.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/text.png-970021a1171658bd56d4ae0c23768972.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/dark_themes/tools/text.png" +dest_files=[ "res://.import/text.png-970021a1171658bd56d4ae0c23768972.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/graphics/dark_themes/tools/text_l.png b/assets/graphics/dark_themes/tools/text_l.png new file mode 100644 index 0000000..5ae28a5 Binary files /dev/null and b/assets/graphics/dark_themes/tools/text_l.png differ diff --git a/assets/graphics/dark_themes/tools/text_l.png.import b/assets/graphics/dark_themes/tools/text_l.png.import new file mode 100644 index 0000000..a252769 --- /dev/null +++ b/assets/graphics/dark_themes/tools/text_l.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/text_l.png-7ef3f46f1090dd60537250c857fc87b7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/dark_themes/tools/text_l.png" +dest_files=[ "res://.import/text_l.png-7ef3f46f1090dd60537250c857fc87b7.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/graphics/dark_themes/tools/text_l_r.png b/assets/graphics/dark_themes/tools/text_l_r.png new file mode 100644 index 0000000..69d5c55 Binary files /dev/null and b/assets/graphics/dark_themes/tools/text_l_r.png differ diff --git a/assets/graphics/dark_themes/tools/text_l_r.png.import b/assets/graphics/dark_themes/tools/text_l_r.png.import new file mode 100644 index 0000000..a0586b4 --- /dev/null +++ b/assets/graphics/dark_themes/tools/text_l_r.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/text_l_r.png-68b397a3f5253ccd0fd06a2dbe44f205.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/dark_themes/tools/text_l_r.png" +dest_files=[ "res://.import/text_l_r.png-68b397a3f5253ccd0fd06a2dbe44f205.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/graphics/dark_themes/tools/text_r.png b/assets/graphics/dark_themes/tools/text_r.png new file mode 100644 index 0000000..0e982fb Binary files /dev/null and b/assets/graphics/dark_themes/tools/text_r.png differ diff --git a/assets/graphics/dark_themes/tools/text_r.png.import b/assets/graphics/dark_themes/tools/text_r.png.import new file mode 100644 index 0000000..0797b2c --- /dev/null +++ b/assets/graphics/dark_themes/tools/text_r.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/text_r.png-9157efcaa46ca548897e2f232969466a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/dark_themes/tools/text_r.png" +dest_files=[ "res://.import/text_r.png-9157efcaa46ca548897e2f232969466a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 0f9edcc..0e4a657 100644 --- a/project.godot +++ b/project.godot @@ -414,6 +414,16 @@ open_docs={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777255,"unicode":0,"echo":false,"script":null) ] } +left_text_tool={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) + ] +} +right_text_tool={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) + ] +} [locale] diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 9e7f379..638ac63 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -46,6 +46,7 @@ var _tools = { "Eraser" : "res://src/Tools/Eraser.tscn", "Bucket" : "res://src/Tools/Bucket.tscn", "LightenDarken" : "res://src/Tools/LightenDarken.tscn", + "Text" : "res://src/Tools/Text.tscn", } var _slots = {} var _panels = {} diff --git a/src/Tools/Text.gd b/src/Tools/Text.gd new file mode 100644 index 0000000..8cb9c67 --- /dev/null +++ b/src/Tools/Text.gd @@ -0,0 +1,76 @@ +extends "res://src/Tools/Base.gd" + + +var text_edit : TextEdit +var text_edit_pos := Vector2.ZERO + + +func _input(event : InputEvent) -> void: + if event.is_action_pressed("ui_accept"): + text_to_pixels() + + +func draw_start(position : Vector2) -> void: + if text_edit: + return + text_edit = TextEdit.new() + text_edit.text = "" + text_edit.rect_position = get_viewport().get_mouse_position() + text_edit_pos = position + text_edit.rect_min_size = Vector2(100, 60) + Global.control.add_child(text_edit) + + +func draw_move(_position : Vector2) -> void: + pass + + +func draw_end(_position : Vector2) -> void: + pass + + +func text_to_pixels() -> void: + if !text_edit: + return + var project : Project = Global.current_project + var size : Vector2 = project.size + var current_cel = project.frames[project.current_frame].cels[project.current_layer].image + var viewport_texture := Image.new() + + var vp = VisualServer.viewport_create() + var canvas = VisualServer.canvas_create() + VisualServer.viewport_attach_canvas(vp, canvas) + VisualServer.viewport_set_size(vp, size.x, size.y) + VisualServer.viewport_set_disable_3d(vp, true) + VisualServer.viewport_set_usage(vp, VisualServer.VIEWPORT_USAGE_2D) + VisualServer.viewport_set_hdr(vp, true) + VisualServer.viewport_set_active(vp, true) + VisualServer.viewport_set_transparent_background(vp, true) + + var ci_rid = VisualServer.canvas_item_create() + VisualServer.viewport_set_canvas_transform(vp, canvas, Transform()) + VisualServer.canvas_item_set_parent(ci_rid, canvas) + var texture = ImageTexture.new() + texture.create_from_image(current_cel) + VisualServer.canvas_item_add_texture_rect(ci_rid, Rect2(Vector2(0, 0), size), texture) + var font : Font = load("res://assets/fonts/Roboto-Regular.tres") + font.draw(ci_rid, text_edit_pos, text_edit.text, tool_slot.color) + + VisualServer.viewport_set_update_mode(vp, VisualServer.VIEWPORT_UPDATE_ONCE) + VisualServer.viewport_set_vflip(vp, true) + VisualServer.force_draw(false) + viewport_texture = VisualServer.texture_get_data(VisualServer.viewport_get_texture(vp)) + VisualServer.free_rid(vp) + VisualServer.free_rid(canvas) + VisualServer.free_rid(ci_rid) + viewport_texture.convert(Image.FORMAT_RGBA8) + print(viewport_texture.get_size()) + if !viewport_texture.is_empty(): + Global.canvas.handle_undo("Draw") + current_cel.unlock() + current_cel.copy_from(viewport_texture) + current_cel.lock() + Global.canvas.handle_redo("Draw") + + text_edit.queue_free() + text_edit = null diff --git a/src/Tools/Text.tscn b/src/Tools/Text.tscn new file mode 100644 index 0000000..d795519 --- /dev/null +++ b/src/Tools/Text.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Tools/Text.gd" type="Script" id=2] + + +[node name="ToolOptions" instance=ExtResource( 1 )] +script = ExtResource( 2 ) + +[node name="PixelPerfect" parent="." index="1"] +visible = false + +[node name="EmptySpacer" parent="." index="2"] +visible = false +margin_top = 18.0 +margin_bottom = 30.0 + +[node name="Mirror" parent="." index="3"] +visible = false +margin_top = 18.0 +margin_bottom = 35.0 diff --git a/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn b/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn index 73ffd6d..ea13e03 100644 --- a/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn +++ b/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn @@ -70,8 +70,8 @@ resizable = true mode = 0 access = 2 filters = PoolStringArray( "*shader" ) -current_dir = "/Users/manos/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" -current_path = "/Users/manos/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" +current_dir = "/Users/Overloaded/Documents/#Orama Stuff/Pixelorama/#Main Repos/Pixelorama" +current_path = "/Users/Overloaded/Documents/#Orama Stuff/Pixelorama/#Main Repos/Pixelorama/" [connection signal="about_to_show" from="." to="." method="_on_ShaderEffect_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_ShaderEffect_confirmed"] [connection signal="popup_hide" from="." to="." method="_on_ShaderEffect_popup_hide"] diff --git a/src/UI/ToolButtons.gd b/src/UI/ToolButtons.gd index d840f98..4e70753 100644 --- a/src/UI/ToolButtons.gd +++ b/src/UI/ToolButtons.gd @@ -10,6 +10,7 @@ onready var tools := [ [$Eraser, "eraser"], [$Bucket, "fill"], [$LightenDarken, "lightdark"], + [$Text, "text"], ] diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index 3705fd5..e1feea8 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=24 format=2] [ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1] [ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=2] @@ -8,6 +8,7 @@ [ext_resource path="res://src/UI/Canvas/Rulers/HorizontalRuler.gd" type="Script" id=6] [ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=7] [ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8] +[ext_resource path="res://assets/graphics/dark_themes/tools/text.png" type="Texture" id=9] [ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10] [ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11] [ext_resource path="res://assets/graphics/dark_themes/tools/rectselect.png" type="Texture" id=12] @@ -58,7 +59,7 @@ __meta__ = { margin_left = 7.0 margin_top = 7.0 margin_right = 39.0 -margin_bottom = 255.0 +margin_bottom = 291.0 script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false @@ -189,6 +190,24 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Text" type="Button" parent="ToolPanel/PanelContainer/ToolButtons" groups=[ +"UIButtons", +]] +margin_top = 252.0 +margin_right = 32.0 +margin_bottom = 284.0 +rect_min_size = Vector2( 32, 32 ) +mouse_default_cursor_shape = 2 +button_mask = 3 + +[node name="TextureRect" type="TextureRect" parent="ToolPanel/PanelContainer/ToolButtons/Text"] +margin_right = 32.0 +margin_bottom = 32.0 +texture = ExtResource( 9 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="CanvasAndTimeline" type="VSplitContainer" parent="."] margin_left = 48.0 margin_right = 950.0