Skip to content

Commit

Permalink
Merge pull request #19 from Loxtir/playable_game
Browse files Browse the repository at this point in the history
  • Loading branch information
MrEliptik authored Sep 4, 2024
2 parents e766c2c + 32a849c commit 398529c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion games/config_template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ arguments = "--fullscreen"
[SETTINGS]
order = 1
visible = true
pinned = false
pinned = false
playable = true
8 changes: 8 additions & 0 deletions scenes/app/app.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ text = "Game name"
horizontal_alignment = 1
vertical_alignment = 1

[node name="NotPlayable" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer/Description"]
layout_mode = 2
size_flags_vertical = 1
theme_override_colors/font_color = Color(1, 0, 0.216667, 1)
theme_override_font_sizes/font_size = 26
text = "NOT PLAYBLE"
vertical_alignment = 1

[node name="Description" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer/Description"]
layout_mode = 2
size_flags_vertical = 1
Expand Down
9 changes: 8 additions & 1 deletion scenes/app/scripts/app.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var curr_game_btn: Button = null
@onready var games_container: Control = $Games
@onready var no_game_found = $NoGameFound
@onready var title: Label = $PanelContainer/MarginContainer/HBoxContainer/Description/Title
@onready var not_playable: Label = $PanelContainer/MarginContainer/HBoxContainer/Description/NotPlayable
@onready var description: Label = $PanelContainer/MarginContainer/HBoxContainer/Description/Description
@onready var version_btn = $VersionBtn
@onready var qr_container: VBoxContainer = $PanelContainer/MarginContainer/HBoxContainer/QRContainer
Expand Down Expand Up @@ -197,6 +198,7 @@ func parse_config(path: String, dir: String, dict: Dictionary):
dict["order"] = config.get_value("SETTINGS", "order")
dict["visible"] = config.get_value("SETTINGS", "visible")
dict["pinned"] = config.get_value("SETTINGS", "pinned")
dict["playable"] = config.get_value("SETTINGS", "playable", true)

func launch_game(game_name: String) -> void:
if not games[game_name].has("executable"): return
Expand Down Expand Up @@ -230,7 +232,12 @@ func on_game_btn_focused(who: Button) -> void:
if not who.properties.has("description"):
description.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
else:
description.text = who.properties["description"]
# clear previous description to allow string concat
description.text = ""
# disable non playable games
var playable: bool = who.properties.get("playable") if who.properties.get("playable") else false
not_playable.visible = not playable
description.text += who.properties["description"]

# Also works in .ini has no "qr_url" property
var qr_url: String = who.properties.get("qr_url") if who.properties.get("qr_url") else ""
Expand Down
5 changes: 5 additions & 0 deletions scenes/carousel/scripts/carousel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func create_game_buttons(game_button: PackedScene, to_create: Dictionary) -> Arr
instance.properties = to_create[key]
game_buttons.append(instance)

# disable non playable games
var playable: bool = instance.properties.get("playable") if instance.properties.get("playable") else false
instance.disabled = not playable

# Sort using order values
game_buttons.sort_custom(sort_btns_ascending)

Expand All @@ -40,6 +44,7 @@ func create_game_buttons(game_button: PackedScene, to_create: Dictionary) -> Arr
btn.position -= btn.size / 2.0
btn.position.x += (btn.size.x + button_offset.x) * count
count += 1


if get_child_count() > 0:
# Call deferred to make sure the app has time to connect focus signal and react accordingly
Expand Down

0 comments on commit 398529c

Please sign in to comment.