mirror of
https://github.com/mr0xb/godot-flashcards.git
synced 2026-08-27 20:44:56 -04:00
initial commit
This commit is contained in:
commit
94847a50a2
42 changed files with 2063 additions and 0 deletions
48
scenes/ui/quiz_mode/flashcard_display.gd
Normal file
48
scenes/ui/quiz_mode/flashcard_display.gd
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
extends PanelContainer
|
||||
|
||||
signal answer_submitted(is_correct: bool)
|
||||
|
||||
@onready var question_label = $MarginContainer/VBoxContainer/QuestionPanel/MarginContainer/QuestionLabel
|
||||
@onready var answer_panel = $MarginContainer/VBoxContainer/AnswerPanel
|
||||
@onready var answer_label = $MarginContainer/VBoxContainer/AnswerPanel/MarginContainer/AnswerLabel
|
||||
@onready var show_answer_btn = $MarginContainer/VBoxContainer/Controls/ShowAnswerButton
|
||||
@onready var rating_buttons = $MarginContainer/VBoxContainer/Controls/RatingButtons
|
||||
@onready var incorrect_btn = $MarginContainer/VBoxContainer/Controls/RatingButtons/IncorrectButton
|
||||
@onready var correct_btn = $MarginContainer/VBoxContainer/Controls/RatingButtons/CorrectButton
|
||||
|
||||
var current_card: Flashcard
|
||||
var answer_revealed: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
show_answer_btn.pressed.connect(_on_show_answer_pressed)
|
||||
incorrect_btn.pressed.connect(_on_incorrect_pressed)
|
||||
correct_btn.pressed.connect(_on_correct_pressed)
|
||||
|
||||
answer_panel.hide()
|
||||
rating_buttons.hide()
|
||||
|
||||
func set_card(card: Flashcard) -> void:
|
||||
current_card = card
|
||||
answer_revealed = false
|
||||
|
||||
question_label.text = card.question_text
|
||||
question_label.modulate = card.question_color
|
||||
|
||||
answer_label.text = card.answer_text
|
||||
answer_label.modulate = card.answer_color
|
||||
|
||||
answer_panel.hide()
|
||||
rating_buttons.hide()
|
||||
show_answer_btn.show()
|
||||
|
||||
func _on_show_answer_pressed() -> void:
|
||||
answer_revealed = true
|
||||
answer_panel.show()
|
||||
show_answer_btn.hide()
|
||||
rating_buttons.show()
|
||||
|
||||
func _on_incorrect_pressed() -> void:
|
||||
answer_submitted.emit(false)
|
||||
|
||||
func _on_correct_pressed() -> void:
|
||||
answer_submitted.emit(true)
|
||||
Loading…
Reference in a new issue