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
45
scenes/ui/deck_manager/deck_list_item.gd
Normal file
45
scenes/ui/deck_manager/deck_list_item.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
extends PanelContainer
|
||||
|
||||
signal study_requested(deck: Deck)
|
||||
signal edit_requested(deck: Deck)
|
||||
signal delete_requested(deck: Deck)
|
||||
|
||||
var deck: Deck
|
||||
|
||||
@onready var deck_name_label = $MarginContainer/HBoxContainer/VBoxContainer/DeckName
|
||||
@onready var deck_info_label = $MarginContainer/HBoxContainer/VBoxContainer/DeckInfo
|
||||
@onready var color_indicator = $MarginContainer/HBoxContainer/ColorIndicator
|
||||
@onready var study_btn = $MarginContainer/HBoxContainer/Actions/StudyButton
|
||||
@onready var edit_btn = $MarginContainer/HBoxContainer/Actions/EditButton
|
||||
@onready var delete_btn = $MarginContainer/HBoxContainer/Actions/DeleteButton
|
||||
|
||||
func _ready() -> void:
|
||||
study_btn.pressed.connect(_on_study_pressed)
|
||||
edit_btn.pressed.connect(_on_edit_pressed)
|
||||
delete_btn.pressed.connect(_on_delete_pressed)
|
||||
|
||||
func set_deck(p_deck: Deck) -> void:
|
||||
deck = p_deck
|
||||
|
||||
if deck:
|
||||
deck_name_label.text = deck.name
|
||||
deck_info_label.text = "%d cards" % deck.get_card_count()
|
||||
color_indicator.color = deck.color_theme
|
||||
|
||||
var progress = DataManager.get_progress(deck.id)
|
||||
if progress:
|
||||
deck_info_label.text += " • %.1f%% accuracy" % progress.get_accuracy()
|
||||
|
||||
func _on_study_pressed() -> void:
|
||||
if deck and deck.get_card_count() > 0:
|
||||
study_requested.emit(deck)
|
||||
else:
|
||||
push_warning("Cannot study empty deck")
|
||||
|
||||
func _on_edit_pressed() -> void:
|
||||
if deck:
|
||||
edit_requested.emit(deck)
|
||||
|
||||
func _on_delete_pressed() -> void:
|
||||
if deck:
|
||||
delete_requested.emit(deck)
|
||||
Loading…
Reference in a new issue