2024-11-25 17:16:38 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
@export var seed: int = 0
|
|
|
|
|
|
|
|
@onready var otherview: int = 0
|
|
|
|
@onready var selfview: int = 0
|
|
|
|
@onready var trueview: int = 0
|
|
|
|
|
|
|
|
# variables for nodes
|
2024-11-28 09:46:27 +00:00
|
|
|
@onready var sound: Node2D = $Sounds
|
2024-11-25 17:16:38 +00:00
|
|
|
@onready var roll_dice: TextureButton = $Roll/Roll_dice
|
|
|
|
@onready var psyline_other: Control = $Psy_line_other
|
|
|
|
@onready var psyline_self: Control = $Psy_line_self
|
|
|
|
@onready var psyline_true: Control = $Psy_line_true
|
|
|
|
@onready var traits: Control = $Traits
|
|
|
|
@onready var keep_psy: CheckBox = $Roll/Keep_psy
|
|
|
|
@onready var keep_traits: CheckBox = $Roll/Keep_traits
|
2024-11-27 15:41:24 +00:00
|
|
|
@onready var language_choice: MenuButton = $Language
|
2024-11-28 09:46:27 +00:00
|
|
|
@onready var soundplayer: EAEventBankMounter = $SoundPlayer
|
2024-11-25 17:16:38 +00:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
2024-11-28 09:46:27 +00:00
|
|
|
lets_roll(seed, 0)
|
2024-11-25 17:16:38 +00:00
|
|
|
roll_dice.pressed.connect(_on_roll_dice_pressed)
|
|
|
|
|
2024-11-27 15:41:24 +00:00
|
|
|
language_choice.get_popup().connect("id_pressed", _on_menu_language_selected)
|
|
|
|
|
2024-11-25 17:16:38 +00:00
|
|
|
func _process(delta: float) -> void:
|
|
|
|
# Roll new result"
|
|
|
|
if Input.is_action_just_pressed("roll"):
|
|
|
|
lets_roll(seed)
|
|
|
|
|
|
|
|
# Exit the app
|
|
|
|
if Input.is_action_just_pressed("ui_cancel"):
|
|
|
|
get_tree().quit()
|
|
|
|
|
|
|
|
func _on_roll_dice_pressed() -> void:
|
|
|
|
lets_roll(seed)
|
|
|
|
|
2024-11-28 09:46:27 +00:00
|
|
|
func lets_roll(chosen_seed: int, noise: bool = 1) -> void:
|
2024-11-25 17:16:38 +00:00
|
|
|
# Random psy profiles
|
|
|
|
var possible_psy: int = $Psy_line_other.resources.size()
|
|
|
|
|
|
|
|
var random = RandomNumberGenerator.new()
|
|
|
|
random.seed = chosen_seed
|
|
|
|
|
2024-11-28 09:46:27 +00:00
|
|
|
# Play sound if wanted
|
|
|
|
if noise:
|
|
|
|
EventAudio.play_2d("DICEROLL", sound)
|
|
|
|
|
2024-11-25 17:16:38 +00:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
# Randomize trait
|
|
|
|
if not keep_traits.button_pressed:
|
|
|
|
traits.populate()
|
2024-11-27 14:20:30 +00:00
|
|
|
|
|
|
|
func update_language(new_language: String) -> void:
|
|
|
|
TranslationServer.set_locale(new_language)
|
|
|
|
emit_signal("language_changed", new_language)
|
2024-11-27 15:41:24 +00:00
|
|
|
|
|
|
|
# Fonction appelée lorsque l'utilisateur sélectionne une option
|
|
|
|
func _on_menu_language_selected(id: int) -> void:
|
|
|
|
match id:
|
|
|
|
0:
|
|
|
|
TranslationServer.set_locale("fr")
|
|
|
|
1:
|
|
|
|
TranslationServer.set_locale("en")
|