-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Library): add interface and menus to select install location
- Loading branch information
1 parent
50e9401
commit eba232a
Showing
10 changed files
with
782 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
extends Control | ||
class_name InstallLocationCard | ||
|
||
signal pressed | ||
signal button_up | ||
signal button_down | ||
|
||
@onready var icon := $%IconTextureRect as TextureRect | ||
@onready var name_label := $%DriveName as Label | ||
@onready var desc_label := $%Description as Label | ||
@onready var drive_size_label := $%DriveSize as Label | ||
@onready var drive_used_bar := $%SpaceUsedProgressBar as ProgressBar | ||
|
||
var location: Library.InstallLocation | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready() -> void: | ||
if not location: | ||
return | ||
if location.icon: | ||
icon.texture = location.icon | ||
|
||
name_label.text = location.name | ||
|
||
desc_label.visible = not location.description.is_empty() | ||
desc_label.text = location.description | ||
|
||
drive_size_label.visible = location.total_space_mb != 0 | ||
drive_size_label.text = str(location.total_space_mb) + " Mb" | ||
|
||
drive_used_bar.visible = location.total_space_mb != 0 | ||
var percent_free := (float(location.free_space_mb) / float(location.total_space_mb)) * 100.0 | ||
drive_used_bar.value = 100.0 - percent_free | ||
|
||
|
||
## Creates an [InstallLocationCard] instance for the given install location | ||
static func from_location(location: Library.InstallLocation) -> InstallLocationCard: | ||
var card_scene := load("res://core/ui/components/install_location_card.tscn") as PackedScene | ||
var card := card_scene.instantiate() as InstallLocationCard | ||
card.location = location | ||
|
||
return card | ||
|
||
|
||
func _gui_input(event: InputEvent) -> void: | ||
var dbus_path := event.get_meta("dbus_path", "") as String | ||
if event is InputEventMouseButton: | ||
if event.is_pressed(): | ||
button_down.emit() | ||
pressed.emit() | ||
else: | ||
button_up.emit() | ||
if not event.is_action("ui_accept"): | ||
return | ||
if event.is_pressed(): | ||
button_down.emit() | ||
pressed.emit() | ||
else: | ||
button_up.emit() |
Oops, something went wrong.