From f801f3a61e7251de2b7a7d0e9cf1546f40ecb52d Mon Sep 17 00:00:00 2001 From: Yann Kervran Date: Thu, 28 Nov 2024 11:13:57 +0100 Subject: [PATCH] Adding checkboxes to pin psyline --- main.gd | 36 ++++++++++++--------- main.tscn | 93 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 97 insertions(+), 32 deletions(-) diff --git a/main.gd b/main.gd index 9f07500..f4a99b7 100644 --- a/main.gd +++ b/main.gd @@ -10,14 +10,18 @@ extends Control @onready var sound: Node2D = $Sounds @onready var roll_dice: TextureButton = $Roll/Roll_dice @onready var psyline_other: Control = $Psy_line_other +@onready var pin_other: CheckBox = $Others_panel/Pin @onready var psyline_self: Control = $Psy_line_self +@onready var pin_self: CheckBox = $Self_panel/Pin @onready var psyline_true: Control = $Psy_line_true +@onready var pin_true: CheckBox = $True_panel/Pin @onready var traits: Control = $Traits @onready var keep_psy: CheckBox = $Roll/Keep_psy @onready var keep_traits: CheckBox = $Roll/Keep_traits @onready var language_choice: MenuButton = $Language @onready var soundplayer: EAEventBankMounter = $SoundPlayer + # Called when the node enters the scene tree for the first time. func _ready() -> void: lets_roll(seed, 0) @@ -50,31 +54,33 @@ func lets_roll(chosen_seed: int, noise: bool = 1) -> void: # Randomize psychology if not keep_psy.button_pressed: - random.randomize() - var result_other: int = random.randi_range(0, possible_psy - 1) - psyline_other.choice.select(result_other) - psyline_other.on_item_selected(result_other) - - random.randomize() - var result_self: int = random.randi_range(0, possible_psy - 1) - psyline_self.choice.select(result_self) - psyline_self.on_item_selected(result_self) - - random.randomize() - var result_true: int = random.randi_range(0, possible_psy - 1) - psyline_true.choice.select(result_true) - psyline_true.on_item_selected(result_true) + if not pin_other.button_pressed: + random.randomize() + var result_other: int = random.randi_range(0, possible_psy - 1) + psyline_other.choice.select(result_other) + psyline_other.on_item_selected(result_other) + if not pin_self.button_pressed: + random.randomize() + var result_self: int = random.randi_range(0, possible_psy - 1) + psyline_self.choice.select(result_self) + psyline_self.on_item_selected(result_self) + if not pin_true.button_pressed: + random.randomize() + var result_true: int = random.randi_range(0, possible_psy - 1) + psyline_true.choice.select(result_true) + psyline_true.on_item_selected(result_true) # Randomize trait if not keep_traits.button_pressed: traits.populate() func update_language(new_language: String) -> void: + # Change the localisation on Translation Server TranslationServer.set_locale(new_language) emit_signal("language_changed", new_language) -# Fonction appelée lorsque l'utilisateur sélectionne une option func _on_menu_language_selected(id: int) -> void: + # To call proper locale when button signal is emitted match id: 0: TranslationServer.set_locale("fr") diff --git a/main.tscn b/main.tscn index b67b4ac..893a430 100644 --- a/main.tscn +++ b/main.tscn @@ -17,57 +17,90 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_gqole") +[node name="SoundPlayer" type="Node" parent="."] +script = ExtResource("6_im5e0") +_audio_bank_resource = ExtResource("7_6knbw") + +[node name="Sounds" type="Node2D" parent="."] + [node name="Others_panel" type="ColorRect" parent="."] layout_mode = 0 -offset_left = 40.0 +offset_left = 16.0 offset_top = 64.0 offset_right = 1136.0 offset_bottom = 168.0 color = Color(0, 1, 0.203922, 0.478431) +[node name="Pin" type="CheckBox" parent="Others_panel"] +layout_mode = 0 +offset_left = 8.0 +offset_top = 64.0 +offset_right = 32.0 +offset_bottom = 88.0 +tooltip_text = "PIN" + [node name="Self_panel" type="ColorRect" parent="."] layout_mode = 0 -offset_left = 40.0 +offset_left = 16.0 offset_top = 184.0 offset_right = 1136.0 offset_bottom = 288.0 color = Color(1, 0.815852, 0, 0.478431) +[node name="Pin" type="CheckBox" parent="Self_panel"] +layout_mode = 0 +offset_left = 8.0 +offset_top = 64.0 +offset_right = 32.0 +offset_bottom = 88.0 +tooltip_text = "PIN" + [node name="True_panel" type="ColorRect" parent="."] layout_mode = 0 -offset_left = 40.0 +offset_left = 16.0 offset_top = 304.0 offset_right = 1136.0 offset_bottom = 408.0 color = Color(0.159107, 0.480726, 1, 0.478431) +[node name="Pin" type="CheckBox" parent="True_panel"] +layout_mode = 0 +offset_left = 8.0 +offset_top = 64.0 +offset_right = 32.0 +offset_bottom = 88.0 +tooltip_text = "PIN" + [node name="People think" type="Label" parent="."] layout_mode = 0 offset_left = 64.0 -offset_top = 88.0 -offset_right = 209.0 -offset_bottom = 104.0 +offset_top = 80.0 +offset_right = 232.0 +offset_bottom = 112.0 theme = ExtResource("2_vc4v2") text = "Who people think character is" +autowrap_mode = 3 [node name="Character think" type="Label" parent="."] layout_mode = 0 offset_left = 64.0 -offset_top = 208.0 -offset_right = 209.0 -offset_bottom = 224.0 +offset_top = 200.0 +offset_right = 232.0 +offset_bottom = 232.0 theme = ExtResource("2_vc4v2") text = "Who character think he is" +autowrap_mode = 3 [node name="Character is actually" type="Label" parent="."] layout_mode = 0 offset_left = 64.0 -offset_top = 336.0 -offset_right = 209.0 +offset_top = 320.0 +offset_right = 232.0 offset_bottom = 352.0 theme = ExtResource("2_vc4v2") text = "Character is actually " +autowrap_mode = 3 [node name="Slogan_label" type="Label" parent="."] layout_mode = 0 @@ -79,6 +112,14 @@ theme = ExtResource("2_vc4v2") text = "Slogan" horizontal_alignment = 1 +[node name="ColorRect" type="ColorRect" parent="Slogan_label"] +layout_mode = 0 +offset_left = -26.0 +offset_top = -8.0 +offset_right = 98.0 +offset_bottom = 372.0 +color = Color(1, 1, 1, 0.266667) + [node name="Motivation_label" type="Label" parent="."] layout_mode = 0 offset_left = 384.0 @@ -99,6 +140,14 @@ theme = ExtResource("2_vc4v2") text = "Goal" horizontal_alignment = 1 +[node name="ColorRect2" type="ColorRect" parent="Goal_label"] +layout_mode = 0 +offset_left = -18.0 +offset_top = -8.0 +offset_right = 106.0 +offset_bottom = 372.0 +color = Color(1, 1, 1, 0.266667) + [node name="Fear_label" type="Label" parent="."] layout_mode = 0 offset_left = 640.0 @@ -119,6 +168,14 @@ theme = ExtResource("2_vc4v2") text = "Strategy" horizontal_alignment = 1 +[node name="ColorRect3" type="ColorRect" parent="Strategy_label"] +layout_mode = 0 +offset_left = -18.0 +offset_top = -8.0 +offset_right = 106.0 +offset_bottom = 372.0 +color = Color(1, 1, 1, 0.266667) + [node name="Weakness_label" type="Label" parent="."] layout_mode = 0 offset_left = 896.0 @@ -139,6 +196,14 @@ theme = ExtResource("2_vc4v2") text = "Problem handling" horizontal_alignment = 1 +[node name="ColorRect4" type="ColorRect" parent="Problem_handling_label"] +layout_mode = 0 +offset_left = -10.0 +offset_top = -8.0 +offset_right = 114.0 +offset_bottom = 372.0 +color = Color(1, 1, 1, 0.266667) + [node name="Psy_line_other" parent="." instance=ExtResource("1_03r8p")] layout_mode = 1 anchor_top = 0.086 @@ -241,9 +306,3 @@ item_count = 2 popup/item_0/text = "FRENCH" popup/item_1/text = "ENGLISH" popup/item_1/id = 1 - -[node name="SoundPlayer" type="Node" parent="."] -script = ExtResource("6_im5e0") -_audio_bank_resource = ExtResource("7_6knbw") - -[node name="Sounds" type="Node2D" parent="."]