Skip to content

Commit

Permalink
remove bugs, add confirm popup when deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
nath54 committed Oct 31, 2022
1 parent fb266b8 commit 5578629
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 29 deletions.
2 changes: 1 addition & 1 deletion addons/calendar_button/class/calendar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func get_days_in_month(month : int, year : int) -> int:
func avance_days(i_day: int, i_month: int, i_year: int, nb_days: int):
var nb_days_month = get_days_in_month(i_month, i_year);
i_day += nb_days;
print("NB_DAY : ", nb_days_month, " - ", i_day);
# print("NB_DAY : ", nb_days_month, " - ", i_day);
#
while i_day > nb_days_month:
i_day -= nb_days_month;
Expand Down
9 changes: 9 additions & 0 deletions global/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var original_font_sizes: Dictionary = {};

var already_modif_fonts: Array = [];

var popup_confirm = null;

func resize_aux(node: Node) -> void:
#
if (node is Label) or (node is Button) or (node is LineEdit) or (node is TextEdit):
Expand Down Expand Up @@ -318,3 +320,10 @@ func get_fiche_knowledge_score(fiche: Dictionary) -> float:
score += row[2] - 5; # Compris entre -5 et 5
score /= float(len(fiche["data"]));
return score; # Compris entre -5 et 5

func disconnect_all_signals(node: Node):
var signals = node.get_signal_list();
for cur_signal in signals:
var conns = node.get_signal_connection_list(cur_signal.name);
for cur_conn in conns:
node.disconnect(cur_conn.signal, cur_conn.target, cur_conn.method);
13 changes: 11 additions & 2 deletions pages/events/Create_Event.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ func display_date():
$VBoxContainer/Date/Date.text = String(day)+"/"+String(month)+"/"+String(year);

func _on_Bt_delete_pressed():
#
Global.popup_confirm.visible = true;
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/Texte").text = tr("KEY_VL_SUPPR")+" "+tr("KEY_CET_EVENT")+" ?";
Global.disconnect_all_signals(Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider"));
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").connect("pressed", self, "delete_aux");
#

func delete_aux():
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").disconnect("pressed", self, "delete_aux");
Global.popup_confirm.visible = false;
#
for c in Global.data.calendars:
if evnt in c.events:
c.events.erase(evnt);
Expand Down Expand Up @@ -118,10 +129,8 @@ func _on_CalendarButton_date_selected(date_obj):
year = date_obj.year();
display_date();


func _on_OptionButton_item_selected(index):
cal = index;


func _on_ColorPickerButton_color_changed(cl):
color = cl;
1 change: 1 addition & 0 deletions pages/events/Create_Event.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ text = "KEY_TITRE"
margin_top = 33.0
margin_right = 520.0
margin_bottom = 72.0
max_length = 128
placeholder_text = "Evenement"

[node name="Color" type="HBoxContainer" parent="VBoxContainer"]
Expand Down
2 changes: 1 addition & 1 deletion pages/events/page_events.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func _ready():
if c.active:
for ev in c.events:
# On vérifie que l'évenements n'est pas encore fini
if Global.custom_arrdate_sort(cdar, [[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]]]):
if not Global.custom_arrdate_sort([[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]]], cdar):
# On trie dans l'ordre chronologique
events_list.append([[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]], ev]);
#
Expand Down
5 changes: 4 additions & 1 deletion pages/events/page_events_passés.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func _ready():
if c.active:
for ev in c.events:
# On vérifie que l'évenements n'est pas encore fini
if not Global.custom_arrdate_sort(cdar, [[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]]]):
if Global.custom_arrdate_sort([[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]]], cdar):
# On trie dans l'ordre chronologique
events_list.append([[ev["date"]["year"], ev["date"]["month"], ev["date"]["day"], ev["heure_deb"]], ev]);
#
Expand All @@ -36,6 +36,9 @@ func _ready():
#
Global.resize_all_fonts();

func on_bt_clicked(ev):
Global.active_object = ev;
Global.go_to_page("res://pages/events/Create_Event.tscn", false);


func _on_Bt_retour_pressed():
Expand Down
2 changes: 2 additions & 0 deletions pages/home/settings/page_settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ text = "KEY_SEQ_BEG_LAT"
margin_left = 234.0
margin_right = 328.0
margin_bottom = 39.0
max_length = 10

[node name="EndLat" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 192.0
Expand All @@ -114,6 +115,7 @@ text = "KEY_SEQ_END_LAT"
margin_left = 238.0
margin_right = 332.0
margin_bottom = 39.0
max_length = 10

[node name="MainPageType" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 246.0
Expand Down
7 changes: 7 additions & 0 deletions pages/main_page.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ onready var ctr = $VSplitContainer/Control;
# Called when the node enters the scene tree for the first time.
func _ready():
Global.main_nav = self;
Global.popup_confirm = $C_confirm_popup;
$VSplitContainer/MainNavBar.connect("change_page", self, "change_page");
Global.go_to_page("res://pages/home/page_home.tscn");

Expand All @@ -29,3 +30,9 @@ func really_change_page(path: String, show_bar: bool = true):
$VSplitContainer/MainNavBar.visible = true;
else:
$VSplitContainer/MainNavBar.visible = false;


func _on_Bt_cancel_pressed():
$C_confirm_popup.visible = false;


96 changes: 86 additions & 10 deletions pages/main_page.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=7 format=2]

[ext_resource path="res://pages/main_nav_menu.tscn" type="PackedScene" id=1]
[ext_resource path="res://pages/events/page_events.tscn" type="PackedScene" id=2]
[ext_resource path="res://res/ui/bts1/pressed.tres" type="StyleBox" id=2]
[ext_resource path="res://pages/main_page.gd" type="Script" id=3]
[ext_resource path="res://res/ui/bts1/normal.tres" type="StyleBox" id=4]
[ext_resource path="res://res/ui/bts1/hover.tres" type="StyleBox" id=5]

[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.00392157, 0.0901961, 0.25098, 1 )

[node name="MainPage" type="Control"]
anchor_right = 1.0
Expand All @@ -20,17 +25,88 @@ margin_bottom = 860.0
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="PageEvents" parent="VSplitContainer/Control" instance=ExtResource( 2 )]
visible = false
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 486.0
margin_bottom = 864.0
size_flags_vertical = 3

[node name="MainNavBar" parent="VSplitContainer" instance=ExtResource( 1 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 860.0
margin_right = 540.0
margin_bottom = 960.0

[node name="C_confirm_popup" type="Control" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0

[node name="Control" type="AspectRatioContainer" parent="C_confirm_popup"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 50.0
margin_top = 50.0
margin_right = -50.0
margin_bottom = -50.0

[node name="Panel" type="Panel" parent="C_confirm_popup/Control"]
margin_top = 210.0
margin_right = 440.0
margin_bottom = 650.0
custom_styles/panel = SubResource( 1 )

[node name="VBoxContainer" type="VBoxContainer" parent="C_confirm_popup/Control/Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0

[node name="Titre" type="Label" parent="C_confirm_popup/Control/Panel/VBoxContainer"]
margin_right = 420.0
margin_bottom = 29.0
text = "KEY_ATTENTION"
align = 1
valign = 1

[node name="Texte" type="Label" parent="C_confirm_popup/Control/Panel/VBoxContainer"]
margin_top = 33.0
margin_right = 420.0
margin_bottom = 381.0
size_flags_horizontal = 3
size_flags_vertical = 7
align = 1
valign = 1
autowrap = true

[node name="HBoxContainer" type="HBoxContainer" parent="C_confirm_popup/Control/Panel/VBoxContainer"]
margin_top = 385.0
margin_right = 420.0
margin_bottom = 420.0

[node name="Bt_cancel" type="Button" parent="C_confirm_popup/Control/Panel/VBoxContainer/HBoxContainer"]
margin_left = 13.0
margin_right = 195.0
margin_bottom = 35.0
size_flags_horizontal = 6
size_flags_vertical = 6
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
custom_styles/hover = ExtResource( 5 )
custom_styles/pressed = ExtResource( 2 )
custom_styles/normal = ExtResource( 4 )
text = "KEY_ANNULER"

[node name="Bt_valider" type="Button" parent="C_confirm_popup/Control/Panel/VBoxContainer/HBoxContainer"]
margin_left = 230.0
margin_right = 401.0
margin_bottom = 35.0
size_flags_horizontal = 6
size_flags_vertical = 6
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
custom_styles/hover = ExtResource( 5 )
custom_styles/pressed = ExtResource( 2 )
custom_styles/normal = ExtResource( 4 )
text = "KEY_VALIDER"

[connection signal="pressed" from="C_confirm_popup/Control/Panel/VBoxContainer/HBoxContainer/Bt_cancel" to="." method="_on_Bt_cancel_pressed"]
11 changes: 11 additions & 0 deletions pages/sheets/Feuille_Elt_mode2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ func _on_Bt_retour_pressed():


func _on_Bt_delete_pressed():
#
Global.popup_confirm.visible = true;
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/Texte").text = tr("KEY_VL_SUPPR")+" "+tr("KEY_CET_EVENT")+" ?";
Global.disconnect_all_signals(Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider"));
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").connect("pressed", self, "delete_aux");
#

func delete_aux():
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").disconnect("pressed", self, "delete_aux");
Global.popup_confirm.visible = false;
#
Global.active_object["data"].remove(Global.active_elt);
Global.get_cur_dir_dict()[Global.active_object["id"]] = Global.active_object;
Global.save_data();
Expand Down
11 changes: 11 additions & 0 deletions pages/sheets/create_dossier.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ func _ready():
Global.resize_all_fonts();

func _on_Bt_Delete_pressed():
#
Global.popup_confirm.visible = true;
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/Texte").text = tr("KEY_VL_SUPPR")+" "+tr("KEY_CE_DIR")+" ?";
Global.disconnect_all_signals(Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider"));
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").connect("pressed", self, "delete_aux");
#

func delete_aux():
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").disconnect("pressed", self, "delete_aux");
Global.popup_confirm.visible = false;
#
if len(Global.current_dir) > 0:
var arr = Array(Global.current_dir);
var last_dir = arr[len(arr)-1];
Expand Down
1 change: 1 addition & 0 deletions pages/sheets/create_dossier.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ text = "KEY_NOM"
margin_top = 33.0
margin_right = 520.0
margin_bottom = 72.0
max_length = 128
placeholder_text = "KEY_NOM_DIR"

[node name="HSeparator" type="HSeparator" parent="VBoxContainer/ScrollContainer/Inputs"]
Expand Down
24 changes: 23 additions & 1 deletion pages/sheets/create_sheet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ func on_element_changed(elt, roelt):
Global.save_data();

func delete_row_elt(elt, roelt):
#
Global.popup_confirm.visible = true;
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/Texte").text = tr("KEY_VL_SUPPR")+" "+tr("KEY_CET_ELT")+" ?";
Global.disconnect_all_signals(Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider"));
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").connect("pressed", self, "delete_aux2", [elt, roelt]);
#

func delete_aux2(elt, roelt):
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").disconnect("pressed", self, "delete_aux2");
Global.popup_confirm.visible = false;
#
Global.active_object["data"].erase(elt);
roelt.queue_free();
save_dt();
Expand Down Expand Up @@ -97,6 +108,17 @@ func _on_Bt_edit_titre_pressed():


func _on_Bt_delete_sheet_pressed():
#
Global.popup_confirm.visible = true;
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/Texte").text = tr("KEY_VL_SUPPR")+" "+tr("KEY_CETTE_FICHE")+" ?";
Global.disconnect_all_signals(Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider"));
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").connect("pressed", self, "delete_aux");
#

func delete_aux():
Global.popup_confirm.get_node("Control/Panel/VBoxContainer/HBoxContainer/Bt_valider").disconnect("pressed", self, "delete_aux");
Global.popup_confirm.visible = false;
#
Global.get_cur_dir_dict().erase(Global.active_object["id"]);
Global.save_data();
#
Expand Down Expand Up @@ -146,9 +168,9 @@ func _on_Bt_add_element_pressed():
Global.active_object["data"].append(["", "", -1]);
save_dt();
var roelt:RowSheetElement = preload("res://pages/sheets/Sheet_Element_Row_Ref.tscn").instance();
roelt.set_val("", "");
roelt.connect("delete_pressed", self, "delete_row_elt", [Global.active_object["data"][len(Global.active_object["data"])-1], roelt]);
$VBoxContainer/ScrollContainer/Elements.add_child(roelt);
roelt.set_val("", "");


func _on_Bt_toggle_mode_to_mode_2_pressed():
Expand Down
15 changes: 10 additions & 5 deletions pages/sheets/create_sheet.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ margin_left = 338.0
margin_right = 432.0
margin_bottom = 61.0
size_flags_horizontal = 3
max_length = 128

[node name="Bt_validate_titre" type="Button" parent="VBoxContainer/Titre"]
visible = false
Expand Down Expand Up @@ -206,6 +207,7 @@ margin_left = 426.0
margin_right = 520.0
margin_bottom = 39.0
text = "0.25"
max_length = 6

[node name="HSeparator4" type="HSeparator" parent="VBoxContainer"]
margin_top = 146.0
Expand All @@ -232,9 +234,9 @@ text = "KEY_MULTI_ANS"

[node name="SepChar" type="HBoxContainer" parent="VBoxContainer"]
visible = false
margin_top = 135.0
margin_top = 206.0
margin_right = 520.0
margin_bottom = 174.0
margin_bottom = 245.0

[node name="Label" type="Label" parent="VBoxContainer/SepChar"]
margin_top = 5.0
Expand All @@ -247,6 +249,7 @@ margin_left = 200.0
margin_right = 294.0
margin_bottom = 39.0
text = "||"
max_length = 5

[node name="HSeparator2" type="HSeparator" parent="VBoxContainer"]
margin_top = 206.0
Expand Down Expand Up @@ -297,10 +300,11 @@ valign = 1

[node name="edt_col1" type="LineEdit" parent="VBoxContainer/Cols/Col1"]
visible = false
margin_left = 52.0
margin_right = 146.0
margin_bottom = 41.0
margin_left = 104.0
margin_right = 204.0
margin_bottom = 40.0
size_flags_horizontal = 3
max_length = 20

[node name="Bt_edit_col1" type="Button" parent="VBoxContainer/Cols/Col1"]
modulate = Color( 0.92549, 0.929412, 0.196078, 1 )
Expand Down Expand Up @@ -365,6 +369,7 @@ margin_left = 52.0
margin_right = 146.0
margin_bottom = 41.0
size_flags_horizontal = 3
max_length = 20

[node name="Bt_edit_col2" type="Button" parent="VBoxContainer/Cols/Col2"]
modulate = Color( 0.92549, 0.929412, 0.196078, 1 )
Expand Down
1 change: 1 addition & 0 deletions pages/sheets/quiz/page_prepare_quiz.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ margin_left = 186.0
margin_right = 280.0
margin_bottom = 39.0
text = "10"
max_length = 5
placeholder_text = "-1"

[node name="Mode" type="HBoxContainer" parent="VBoxContainer"]
Expand Down
Loading

0 comments on commit 5578629

Please sign in to comment.