Skip to content

Commit e7dc06a

Browse files
authored
Merge pull request #153 from Project-Funk-Engine/SteamFixes
Steam fixes
2 parents 0ab882e + 8a6037b commit e7dc06a

File tree

13 files changed

+76
-14
lines changed

13 files changed

+76
-14
lines changed

Globals/StageProducer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,16 @@ private BattleConfig MakeBattleConfig(Stages nextRoom, int nextRoomIdx)
212212
CurRoom = nextRoomIdx;
213213
return result;
214214
}
215+
216+
//Putting this here in an autoload.
217+
public override void _Input(InputEvent @event)
218+
{
219+
//Consume controller input, if window out of focus.
220+
//This handles ui_input, other scenes need to consume their own.
221+
if (!GetWindow().HasFocus())
222+
{
223+
GetViewport().SetInputAsHandled();
224+
return;
225+
}
226+
}
215227
}

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private void OnBattleLost()
257257
Audio.StreamPaused = true;
258258
SaveSystem.ClearSave();
259259
AddChild(GD.Load<PackedScene>(EndScreen.LoadPath).Instantiate());
260-
GetTree().Paused = true;
260+
ProcessMode = ProcessModeEnum.Disabled;
261261
}
262262

263263
private void ShowRewardSelection(int amount)

Scenes/Maps/Scripts/Cartographer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ private void WinStage()
144144
EndScreen es = GD.Load<PackedScene>(EndScreen.LoadPath).Instantiate<EndScreen>();
145145
AddChild(es);
146146
es.TopLabel.Text = Tr("BATTLE_ROOM_WIN");
147-
GetTree().Paused = true;
147+
ProcessMode = ProcessModeEnum.Disabled;
148148
}
149149
}

Scenes/UI/EndScreen.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="4_1vt77"]
77

88
[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("_buttons", "TopLabel")]
9-
process_mode = 2
9+
process_mode = 3
1010
script = ExtResource("1_37m3y")
1111
_buttons = [NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer/Restart"), NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer2/Title"), NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer3/Quit")]
1212
TopLabel = NodePath("MarginContainer2/MarginContainer/VBoxContainer/TopLabel")

Scenes/UI/Options/Scripts/HowToPlay.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public void ReturnToPrev()
4141

4242
public override void _Input(InputEvent @event)
4343
{
44+
if (!GetWindow().HasFocus())
45+
{
46+
GetViewport().SetInputAsHandled();
47+
return;
48+
}
4449
if (@event.IsActionPressed("ui_cancel"))
4550
{
4651
ReturnToPrev();

Scenes/UI/Options/Scripts/OptionsMenu.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public override void _Ready()
5050

5151
public override void _Input(InputEvent @event)
5252
{
53+
if (!GetWindow().HasFocus())
54+
{
55+
GetViewport().SetInputAsHandled();
56+
return;
57+
}
5358
if (@event.IsActionPressed("ui_cancel"))
5459
{
5560
ReturnToPrev();

Scenes/UI/Remapping/ControlSettings.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,19 @@ private void GetCurrentSelection()
131131
OnControllerButtonPressed();
132132
GetNode<Button>("Panel/ControllerButton").GrabFocus();
133133
break;
134+
default:
135+
_closeButton.GrabFocus();
136+
break;
134137
}
135138
}
136139

137140
public override void _Input(InputEvent @event)
138141
{
142+
if (!GetWindow().HasFocus())
143+
{
144+
GetViewport().SetInputAsHandled();
145+
return;
146+
}
139147
if (@event.IsActionPressed("ui_cancel"))
140148
{
141149
ReturnToPrev();
@@ -179,7 +187,7 @@ private void ControllerConnectionChanged(long id, bool connected)
179187
_controllerButton.Visible = Input.GetConnectedJoypads().Count > 0;
180188
if (
181189
(string)SaveSystem.GetConfigValue(SaveSystem.ConfigSettings.InputKey) == "CONTROLLER"
182-
&& !_closeButton.Visible
190+
&& !_controllerButton.Visible
183191
)
184192
{
185193
OnArrowButtonPressed();

Scenes/UI/RewardSelectionUI.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[ext_resource type="Texture2D" uid="uid://burj10os057fx" path="res://Scenes/UI/Assets/UI_CrystalFrameInset.png" id="4_gufce"]
88

99
[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("ButtonContainer", "_description", "_acceptButton", "_skipButton")]
10-
process_mode = 2
10+
process_mode = 3
1111
script = ExtResource("1_1m6an")
1212
ButtonContainer = NodePath("MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer/HBoxContainer")
1313
_description = NodePath("MarginContainer/PanelContainer/VBoxContainer/DescBox/DescMargin/Description")

Scenes/UI/Scripts/Inventory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ private void AddDisplayButtons(IDisplayable[] displayables, Node parentNode)
4545

4646
public override void _Input(InputEvent @event)
4747
{
48+
if (!GetWindow().HasFocus())
49+
{
50+
GetViewport().SetInputAsHandled();
51+
return;
52+
}
4853
if (_tabs.CurrentTab == 0) //Godot 4.4 changed neighbor behaviour
4954
{
5055
if (_notes.GetChildCount() > 0)

Scenes/UI/Scripts/MenuModule.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ public partial class MenuModule : CanvasLayer, IFocusableMenu
1111

1212
private Control _lastFocused { get; set; }
1313

14+
public override void _Ready()
15+
{
16+
Input.JoyConnectionChanged += (device, connected) =>
17+
{
18+
if (!connected)
19+
OpenPauseMenu(); //Pause on disconnection
20+
};
21+
GetTree().GetRoot().FocusExited += OpenPauseMenu;
22+
}
23+
1424
public void ResumeFocus()
1525
{
1626
CurSceneNode.ProcessMode = ProcessModeEnum.Inherit;
@@ -37,11 +47,14 @@ public void ReturnToPrev()
3747

3848
public override void _Input(InputEvent @event)
3949
{
50+
if (!GetWindow().HasFocus())
51+
{
52+
GetViewport().SetInputAsHandled();
53+
return;
54+
}
4055
if (@event.IsActionPressed("Pause"))
4156
{
42-
var pauseMenu = GD.Load<PackedScene>(PauseMenu.LoadPath).Instantiate<PauseMenu>();
43-
AddChild(pauseMenu);
44-
pauseMenu.OpenMenu(this);
57+
OpenPauseMenu();
4558
}
4659
if (@event.IsActionPressed("Inventory"))
4760
{
@@ -50,4 +63,13 @@ public override void _Input(InputEvent @event)
5063
invenMenu.OpenMenu(this);
5164
}
5265
}
66+
67+
private void OpenPauseMenu()
68+
{
69+
if (CurSceneNode.ProcessMode == ProcessModeEnum.Disabled)
70+
return;
71+
var pauseMenu = GD.Load<PackedScene>(PauseMenu.LoadPath).Instantiate<PauseMenu>();
72+
AddChild(pauseMenu);
73+
pauseMenu.OpenMenu(this);
74+
}
5375
}

0 commit comments

Comments
 (0)