Skip to content

Commit

Permalink
chore(Various): minor fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Aug 25, 2024
1 parent 82f57ca commit 417871b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 48 deletions.
17 changes: 6 additions & 11 deletions core/global/launch_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ var _apps_by_name: Dictionary = {}
var _data_dir: String = ProjectSettings.get_setting("OpenGamepadUI/data/directory")
var _persist_path: String = "/".join([_data_dir, "launcher.json"])
var _persist_data: Dictionary = {"version": 1}
var _ogui_window_id: int
var _ogui_window_id := gamescope.get_window_id(PID, gamescope.XWAYLAND.OGUI)
var should_manage_overlay := true
var logger := Log.get_logger("LaunchManager", Log.LEVEL.INFO)


# Connect to Gamescope signals
func _init() -> void:
# Grab the window ID of OpenGamepadUI
_ogui_window_id = gamescope.get_window_id(PID, gamescope.XWAYLAND.OGUI)

# When window focus changes, update the current app and gamepad profile
var on_focus_changed := func(from: int, to: int):
logger.info("Window focus changed from " + str(from) + " to: " + str(to))
Expand Down Expand Up @@ -109,9 +106,8 @@ func _init() -> void:
if not should_manage_overlay:
return

var ogui_window_id = gamescope.get_window_id(PID, gamescope.XWAYLAND.OGUI)
logger.debug("Disabling STEAM_OVERLAY atom")
gamescope.set_overlay(ogui_window_id, 1)
gamescope.set_overlay(_ogui_window_id, 1)

in_game_state.state_entered.connect(on_game_state_entered)
in_game_state.state_exited.connect(on_game_state_exited)
Expand Down Expand Up @@ -301,7 +297,6 @@ func set_app_gamepad_profile(app: RunningApp) -> void:

## Sets the gamepad profile for the running app with the given profile
func set_gamepad_profile(path: String, target_gamepad: String = "") -> void:
logger.warn("Set gamepad profile to:", path, "With target_gamepad:", target_gamepad)
# Discover the currently set gamepad to properly add additional capabilities based on that gamepad
var profile_modifier := target_gamepad
if target_gamepad.is_empty():
Expand All @@ -313,7 +308,7 @@ func set_gamepad_profile(path: String, target_gamepad: String = "") -> void:
var profile_path := settings_manager.get_value("input", "gamepad_profile", InputPlumber.DEFAULT_GLOBAL_PROFILE) as String
if not profile_path.ends_with(".json") or not FileAccess.file_exists(profile_path):
profile_path = InputPlumber.DEFAULT_GLOBAL_PROFILE
logger.debug("Loading global gamepad profile: " + profile_path)
logger.info("Loading global gamepad profile: " + profile_path)

for gamepad in input_plumber.composite_devices:
gamepad.target_modify_profile(profile_path, profile_modifier)
Expand All @@ -326,12 +321,12 @@ func set_gamepad_profile(path: String, target_gamepad: String = "") -> void:
target_devices.append("touchpad")
_:
logger.debug(target_gamepad, "needs no additional target devices.")
logger.debug("Setting target devices to: ", target_devices)
logger.info("Setting target devices to: ", target_devices)
gamepad.set_target_devices(target_devices)

return

logger.debug("Loading gamepad profile: " + path)
logger.info("Loading gamepad profile: " + path)
if not FileAccess.file_exists(path):
logger.warn("Gamepad profile not found: " + path)
return
Expand All @@ -354,7 +349,7 @@ func set_gamepad_profile(path: String, target_gamepad: String = "") -> void:
target_devices.append("touchpad")
_:
logger.debug(target_gamepad, "needs no additional target devices.")
logger.debug("Setting target devices to: ", target_devices)
logger.info("Setting target devices to: ", target_devices)
gamepad.set_target_devices(target_devices)

var notify := Notification.new("Using gamepad profile: " + profile.name)
Expand Down
2 changes: 2 additions & 0 deletions core/systems/input/focus_group.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class_name FocusGroup
@export_category("Focus Control")
## The current focus of the focus group
@export var current_focus: Control
## DEPRECATED: Use [InputWatcher] nodes with [FocusSetter] to handle back input.
## Menus with multiple levels of focus groups can be part of a chain of focus
@export var focus_stack: FocusStack
## The InputEvent that will trigger focusing a parent focus group
Expand Down Expand Up @@ -423,6 +424,7 @@ func _vbox_set_focus_tree(control_children: Array[Control]) -> void:
child.focus_next = control_children[i + 1].get_path()
child.focus_neighbor_bottom = control_children[i + 1].get_path()
else:
# If wrap focus is enabled, then link focus of the last node to the first node.
if wrap_focus:
child.focus_next = control_children[0].get_path()
child.focus_neighbor_bottom = control_children[0].get_path()
Expand Down
12 changes: 6 additions & 6 deletions core/systems/input/input_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ func _guide_input(event: InputEvent) -> void:
# Only act on release events
if event.is_pressed():
logger.warn("Guide pressed. Waiting for additional events.")
# Set the gamepad profile to the global default so we can capture button events
# Set the gamepad profile to the global default so we can capture button events.
# This ensures that we use the global profile and not the game's input profile for
# processing guide button combos and navigating the menu.
launch_manager.set_gamepad_profile("")
return

Expand All @@ -201,14 +203,13 @@ func _main_menu_input(event: InputEvent) -> void:

# Open the main menu
var state := popup_state_machine.current_state()
var menu_state := main_menu_state

if state == menu_state:
if state == main_menu_state:
popup_state_machine.pop_state()
elif state in [quick_bar_state, osk_state]:
popup_state_machine.replace_state(menu_state)
popup_state_machine.replace_state(main_menu_state)
else:
popup_state_machine.push_state(menu_state)
popup_state_machine.push_state(main_menu_state)


## Handle quick bar menu events to open the quick bar menu
Expand All @@ -234,7 +235,6 @@ func _osk_input(event: InputEvent) -> void:

var state := popup_state_machine.current_state()
if state == osk_state:
logger.error("POP POP MUTHAFUCKA")
osk.close()
popup_state_machine.pop_state()
return
Expand Down
4 changes: 3 additions & 1 deletion core/systems/input/overlay_mode_input_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ func _guide_input(event: InputEvent) -> void:
# Only act on release events
if event.is_pressed():
logger.debug("Guide pressed. Waiting for additional events.")
# Set the gamepad profile to the global default so we can capture button events
# Set the gamepad profile to the global default so we can capture button events.
# This ensures that we use the global profile and not the game's input profile for
# processing guide button combos and navigating the menu.
launch_manager.set_gamepad_profile("")
return

Expand Down
2 changes: 1 addition & 1 deletion core/ui/card_ui/gamepad/gamepad_settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func _save_profile() -> void:
if running_app:
if running_app.launch_item.name != library_item.name:
pass
logger.warn("Reloading gamepad profile for running game")
logger.debug("Reloading gamepad profile for running game")
launch_manager.set_gamepad_profile(path)


Expand Down
12 changes: 6 additions & 6 deletions core/ui/card_ui/home/cardui_home.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ var recent_apps: Array
var tween: Tween
var logger := Log.get_logger("HomeMenu", Log.LEVEL.INFO)

@onready var container: HBoxContainer = $%CardContainer
@onready var banner: TextureRect = $%BannerTexture
@onready var container := $%CardContainer as HBoxContainer
@onready var banner := $%BannerTexture as TextureRect
@onready var library_banner := $%LibraryBanner as Control
@onready var player: AnimationPlayer = $%AnimationPlayer
@onready var scroll_container: ScrollContainer = $%ScrollContainer
@onready var library_deck: LibraryDeck = $%LibraryDeck
@onready var end_spacer := $%EndSpacer
@onready var player := $%AnimationPlayer as AnimationPlayer
@onready var scroll_container := $%ScrollContainer as ScrollContainer
@onready var library_deck := $%LibraryDeck as LibraryDeck
@onready var end_spacer := $%EndSpacer as Control


# Called when the node enters the scene tree for the first time.
Expand Down
6 changes: 3 additions & 3 deletions core/ui/card_ui/navigation/running_game_card.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[ext_resource type="Resource" uid="uid://cr544el0cqjlm" path="res://assets/state/state_machines/global_state_machine.tres" id="15_p4kr0"]
[ext_resource type="Resource" uid="uid://cv3vduo0ojk1u" path="res://assets/state/states/menu.tres" id="16_vmedb"]

[sub_resource type="Image" id="Image_w47dc"]
[sub_resource type="Image" id="Image_2yqt6"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
Expand All @@ -27,7 +27,7 @@ data = {
}

[sub_resource type="ImageTexture" id="ImageTexture_osglk"]
image = SubResource("Image_w47dc")
image = SubResource("Image_2yqt6")

[node name="RunningGameCard" type="PanelContainer"]
anchors_preset = 10
Expand Down Expand Up @@ -152,7 +152,7 @@ layout_mode = 2
[node name="ResumeButton" parent="MarginContainer/VBoxContainer/ContentContainer" instance=ExtResource("8_ixs6g")]
unique_name_in_owner = true
layout_mode = 2
text = "Resume"
text = "Return"

[node name="PauseButton" parent="MarginContainer/VBoxContainer/ContentContainer" instance=ExtResource("8_ixs6g")]
unique_name_in_owner = true
Expand Down
4 changes: 2 additions & 2 deletions core/ui/card_ui/settings/plugin_settings_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[ext_resource type="PackedScene" uid="uid://o0equu1tyr4s" path="res://core/ui/components/expandable_card.tscn" id="8_veuxu"]
[ext_resource type="PackedScene" uid="uid://b0cyl6fdqxevn" path="res://core/systems/input/scroller_joystick.tscn" id="10_nbqrj"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l6jww"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xcwv0"]
resource_local_to_scene = true
bg_color = Color(0.105882, 0.109804, 0.141176, 1)
border_blend = true
Expand Down Expand Up @@ -72,6 +72,6 @@ horizontal_alignment = 1

[node name="ExpandableCard" parent="MarginContainer/ContentContainer" instance=ExtResource("8_veuxu")]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_l6jww")
theme_override_styles/panel = SubResource("StyleBoxFlat_xcwv0")

[node name="ScrollerJoystick" parent="." instance=ExtResource("10_nbqrj")]
2 changes: 1 addition & 1 deletion core/ui/components/drive_card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func _srm_format_drive() -> void:
var dialog := get_tree().get_first_node_in_group("dialog") as Dialog
var msg := "WARNING: All data on " + device_path + " device will be wiped. " + \
"This action cannot be undone. Do you wish to continue?"
dialog.open(self, msg, "Cancel", "Continue Format")
dialog.open(format_button, msg, "Cancel", "Continue Format")
var cancel := await dialog.choice_selected as bool
if cancel:
return
Expand Down
17 changes: 0 additions & 17 deletions core/ui/components/plugin_store_card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,3 @@ func _gui_input(event: InputEvent) -> void:
pressed.emit()
else:
button_up.emit()

#
#func _input(event: InputEvent) -> void:
# if not event.is_action("ogui_east"):
# return
# if not event.is_released():
# return
#
# # Only process input if a child node has focus
# var focus_owner := get_viewport().gui_get_focus_owner()
# if not self.is_ancestor_of(focus_owner):
# return
#
# # Stop the event from propagating
# #logger.debug("Consuming input event '{action}' for node {n}".format({"action": action, "n": str(self)}))
# get_viewport().set_input_as_handled()
#

0 comments on commit 417871b

Please sign in to comment.