From 3f7a632432e5cafb07217eb7c69e300c5b348390 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 12:03:17 -0300 Subject: [PATCH 1/6] 1/3 --- Figures/Figures.gd | 1 - GUI/Display/Display.gd | 2 ++ GUI/Menus/MenuBar/MenuBarButton/MenuBarButton.gd | 13 ++++++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Figures/Figures.gd b/Figures/Figures.gd index 47d32bc..47254fa 100644 --- a/Figures/Figures.gd +++ b/Figures/Figures.gd @@ -47,7 +47,6 @@ func select_figure(): is_select = true SM.set_position() Insp.reload_atributes = true - print(is_select) func get_id(): diff --git a/GUI/Display/Display.gd b/GUI/Display/Display.gd index 6cb884a..86eed0e 100644 --- a/GUI/Display/Display.gd +++ b/GUI/Display/Display.gd @@ -86,7 +86,9 @@ func _input(event): ) if figures[figures.size() - 1]._is_ready == true: if ids_avaiable.size() > 0: + ids_avaiable.sort() figures[figures.size() - 1].init(ids_avaiable[0]) + ids_avaiable.remove(0) else: figures[figures.size() - 1].init(figures.size() - 1) figures[figures.size() - 1].select_figure() diff --git a/GUI/Menus/MenuBar/MenuBarButton/MenuBarButton.gd b/GUI/Menus/MenuBar/MenuBarButton/MenuBarButton.gd index 1bf8561..de00077 100644 --- a/GUI/Menus/MenuBar/MenuBarButton/MenuBarButton.gd +++ b/GUI/Menus/MenuBar/MenuBarButton/MenuBarButton.gd @@ -4,17 +4,18 @@ onready var PN = get_node("/root/PanelInfo") var _title var _id: int -func init(id, title,tamanho, sub_title, scuts): + +func init(id, title, tamanho, sub_title, scuts): _id = id _title = title text = title - + for i in range(tamanho): get_popup().add_item(String(sub_title[i])) for j in range(scuts.size()): get_popup().set_item_shortcut(j, set_shortcut(scuts[j]), true) - + get_popup().connect("id_pressed", self, "_on_MenuBarButton_pressed") @@ -25,12 +26,10 @@ func set_shortcut(key): inputeventkey.control = true shortcut.set_shortcut(inputeventkey) return shortcut - func _on_MenuBarButton_pressed(id): - var item_name = get_popup().get_item_text(id) - # print("btton clicked parent in menuBarButton >> ", get_parent().button_clicked) + var item_name = get_popup().get_item_text(id) if item_name == "About": var popup = load("res://GUI/PopUp/About/About.tscn").instance() get_tree().get_root().get_node("Main/Layout").add_child(popup) @@ -42,4 +41,4 @@ func _on_MenuBarButton_pressed(id): elif item_name == "Square": PN.set_button_selected(item_name) elif item_name == "Hexagon": - PN.set_button_selected(item_name) \ No newline at end of file + PN.set_button_selected(item_name) From f4d1dbe0e96ed7e19b70c41e64cec79396154739 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 12:24:34 -0300 Subject: [PATCH 2/6] 2/3 --- Figures/Irregular.gd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Figures/Irregular.gd b/Figures/Irregular.gd index 750f911..b8779b9 100644 --- a/Figures/Irregular.gd +++ b/Figures/Irregular.gd @@ -5,6 +5,7 @@ var _is_ready = false var geometry = Geometry var new_line: PoolVector2Array var can_create_vertex = true +var last_position func init(id): @@ -29,11 +30,13 @@ func set_ready(): func create_next_vertex(pos): if vertex.size() == 0: + last_position = pos vertex.append(Vector2(0, 0)) inital_pos = pos translate = inital_pos else: if can_create_vertex: + last_position = pos vertex.append(pos - inital_pos) if inital_pos.distance_to(pos) <= 0.2 and vertex.size() > 2: set_ready() @@ -113,12 +116,21 @@ func pre_render(vertex_mod): draw_circle(new_line[1], 4, Color(0, 0, 0, 1)) +func min_dist(): + var next_position = CP.mouse_position_to_cartesian(get_global_mouse_position()) + if last_position.distance_to(next_position) < 0.02: + return false + else: + return true + + func can_create_new_vertex(): var next_position = CP.mouse_position_to_cartesian(get_global_mouse_position()) - inital_pos + min_dist() if vertex.size() > 1: if ( valid_angle(PoolVector2Array([vertex[vertex.size() - 1], next_position])) - and valid_position(new_line) + and valid_position(new_line) and min_dist() ): can_create_vertex = true else: From 3955e731843d8da5171a4655e1e6597c6adf0aa7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 12:42:16 -0300 Subject: [PATCH 3/6] 3/3 --- GUI/Display/Display.gd | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/GUI/Display/Display.gd b/GUI/Display/Display.gd index 86eed0e..92ecb54 100644 --- a/GUI/Display/Display.gd +++ b/GUI/Display/Display.gd @@ -27,6 +27,10 @@ func _process(_delta): set_margin(MARGIN_BOTTOM, Res.get_display_res().size.y) if is_clicking and is_in_display(clicked_position) and clicked_position != null: create_object() + if creating and PN.get_button_selected() != "Vertex": + figures[figures.size() - 1].queue_free() + figures.remove(figures.size() - 1) + creating = false func is_in_display(Position): @@ -59,6 +63,19 @@ func create_object(): ) ) +func delete_object(): + var position_list = SM.get_position() + ids_avaiable.append(figures[position_list].get_id()) + figures[position_list].delete() + figures[figures.size() - 1].set_is_selected(false) + figures[position_list].queue_free() + figures.remove(position_list) + if figures.size() != 0: + figures[figures.size() - 1].select_figure() + else: + Insp.clear() + Insp.reload_atributes = true + func _input(event): if PN.get_button_selected() != "": @@ -97,7 +114,6 @@ func _input(event): Insp.reload_atributes = true creating = false - if PN.get_button_selected() != "Vertex": add_child(new_figure) figures.append(new_figure) @@ -126,14 +142,4 @@ func _input(event): Insp.reload_atributes = true if event.is_action_pressed("delete_figure") and figures.size() > 0: - var position_list = SM.get_position() - ids_avaiable.append(figures[position_list].get_id()) - figures[position_list].delete() - figures[figures.size() - 1].set_is_selected(false) - figures[position_list].queue_free() - figures.remove(position_list) - if figures.size() != 0: - figures[figures.size() - 1].select_figure() - else: - Insp.clear() - Insp.reload_atributes = true + delete_object() From a94245a0058dd6964d7f7ce63deedeb56f8df946 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 13:41:04 -0300 Subject: [PATCH 4/6] cancelar e letras maiusculas --- Figures/Figures.gd | 4 ++-- Figures/Hexagon/Hexagon.gd | 2 +- Figures/Square/Square.gd | 2 +- Figures/Triangle/Triangle.gd | 2 +- GUI/Display/Display.gd | 5 +++++ project.godot | 5 +++++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Figures/Figures.gd b/Figures/Figures.gd index 47254fa..da80025 100644 --- a/Figures/Figures.gd +++ b/Figures/Figures.gd @@ -88,9 +88,9 @@ func delete(): func create_dic_to_properties(): info = [ - {"id": "rotation", "label": "rotation", "value": rotation}, + {"id": "rotation", "label": "Rotation", "value": rotation}, {"type": "checkbox", "id": "flip", "label": "Flip", "value": {"X": flip_x, "Y": flip_y}}, - {"id": "line_width", "label": "line width", "value": line_width}, + {"id": "line_width", "label": "Line Width", "value": line_width}, { "listLabel": "Translate", "type": "list", diff --git a/Figures/Hexagon/Hexagon.gd b/Figures/Hexagon/Hexagon.gd index 9f71cd6..25d6573 100644 --- a/Figures/Hexagon/Hexagon.gd +++ b/Figures/Hexagon/Hexagon.gd @@ -6,7 +6,7 @@ func init(id): _figure_name = "hexagon (" + String(_id) + ")" selection_button.init(_figure_name, self) create_dic_to_properties() - info.insert(0, {"id": "edge", "label": "edge", "value": edge}) + info.insert(0, {"id": "edge", "label": "Edge", "value": edge}) set_properties_in_inspector() diff --git a/Figures/Square/Square.gd b/Figures/Square/Square.gd index f619417..e672134 100644 --- a/Figures/Square/Square.gd +++ b/Figures/Square/Square.gd @@ -8,7 +8,7 @@ func init(id): _figure_name = "square (" + String(_id) + ")" selection_button.init(_figure_name, self) create_dic_to_properties() - info.insert(0, {"id": "edge", "label": "edge", "value": edge}) + info.insert(0, {"id": "edge", "label": "Edge", "value": edge}) # var list_of_vertices_insp = {"listLabel": "vertex", "type": "list", "infos": []} # for i in range(vertex.size()): # list_of_vertices_insp["infos"].insert( diff --git a/Figures/Triangle/Triangle.gd b/Figures/Triangle/Triangle.gd index aadca73..e735162 100644 --- a/Figures/Triangle/Triangle.gd +++ b/Figures/Triangle/Triangle.gd @@ -6,7 +6,7 @@ func init(id): _figure_name = "triangle (" + String(_id) + ")" selection_button.init(_figure_name, self) create_dic_to_properties() - info.insert(0, {"id": "edge", "label": "edge", "value": edge}) + info.insert(0, {"id": "edge", "label": "Edge", "value": edge}) set_properties_in_inspector() diff --git a/GUI/Display/Display.gd b/GUI/Display/Display.gd index 92ecb54..9f9d377 100644 --- a/GUI/Display/Display.gd +++ b/GUI/Display/Display.gd @@ -143,3 +143,8 @@ func _input(event): if event.is_action_pressed("delete_figure") and figures.size() > 0: delete_object() + + if event.is_action_pressed("cancel") and creating: + figures[figures.size() - 1].queue_free() + figures.remove(figures.size() - 1) + creating = false diff --git a/project.godot b/project.godot index c42c83b..e904a19 100644 --- a/project.godot +++ b/project.godot @@ -54,6 +54,11 @@ delete_figure={ "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":16777224,"unicode":0,"echo":false,"script":null) ] } +cancel={ +"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":16777217,"unicode":0,"echo":false,"script":null) + ] +} [rendering] From 596d42c8d10e48a2c720f34391c964a8f03f9ab7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 14:41:44 -0300 Subject: [PATCH 5/6] =?UTF-8?q?irregular=20com=20cor=20de=20sele=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Figures/Irregular.gd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Figures/Irregular.gd b/Figures/Irregular.gd index b8779b9..a3d220f 100644 --- a/Figures/Irregular.gd +++ b/Figures/Irregular.gd @@ -6,6 +6,7 @@ var geometry = Geometry var new_line: PoolVector2Array var can_create_vertex = true var last_position +var vertex_color = ColorN("black") func init(id): @@ -45,8 +46,10 @@ func create_next_vertex(pos): func _physics_process(_delta): if is_select: selection_button.pressed = true + vertex_color = ColorN("green") update_values() else: + vertex_color = ColorN("black") selection_button.pressed = false can_create_new_vertex() #transformations @@ -145,4 +148,4 @@ func custom_draw_polygon(): for i in range(vertex_mod.size() - 1): draw_line(vertex_mod[i], vertex_mod[i + 1], color, line_width) for i in range(vertex_mod.size()): - draw_circle(vertex_mod[i], 4, Color(0, 0, 0, 1)) + draw_circle(vertex_mod[i], 4, vertex_color) From 7a2b675203d6f28c31c34f0faee8859338ac9f86 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mariotti Paiva Date: Wed, 21 Jul 2021 14:57:26 -0300 Subject: [PATCH 6/6] Bugfix --- Figures/Regular.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Figures/Regular.gd b/Figures/Regular.gd index 889230d..29493f2 100644 --- a/Figures/Regular.gd +++ b/Figures/Regular.gd @@ -13,7 +13,8 @@ func set_edge(value): func update_local_values(): - edge = float(Insp.get_properties_by_id("edge")) + if Insp.get_properties_by_id("edge"): + edge = float(Insp.get_properties_by_id("edge")) func _physics_process(_delta):