Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,16 @@ private BattleConfig MakeBattleConfig(Stages nextRoom, int nextRoomIdx)
CurRoom = nextRoomIdx;
return result;
}

//Putting this here in an autoload.
public override void _Input(InputEvent @event)
{
//Consume controller input, if window out of focus.
//This handles ui_input, other scenes need to consume their own.
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
}
}
2 changes: 1 addition & 1 deletion Scenes/BattleDirector/Scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void OnBattleLost()
Audio.StreamPaused = true;
SaveSystem.ClearSave();
AddChild(GD.Load<PackedScene>(EndScreen.LoadPath).Instantiate());
GetTree().Paused = true;
ProcessMode = ProcessModeEnum.Disabled;
}

private void ShowRewardSelection(int amount)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Maps/Scripts/Cartographer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ private void WinStage()
EndScreen es = GD.Load<PackedScene>(EndScreen.LoadPath).Instantiate<EndScreen>();
AddChild(es);
es.TopLabel.Text = Tr("BATTLE_ROOM_WIN");
GetTree().Paused = true;
ProcessMode = ProcessModeEnum.Disabled;
}
}
2 changes: 1 addition & 1 deletion Scenes/UI/EndScreen.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="4_1vt77"]

[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("_buttons", "TopLabel")]
process_mode = 2
process_mode = 3
script = ExtResource("1_37m3y")
_buttons = [NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer/Restart"), NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer2/Title"), NodePath("MarginContainer2/MarginContainer/VBoxContainer/MarginContainer3/Quit")]
TopLabel = NodePath("MarginContainer2/MarginContainer/VBoxContainer/TopLabel")
Expand Down
5 changes: 5 additions & 0 deletions Scenes/UI/Options/Scripts/HowToPlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public void ReturnToPrev()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (@event.IsActionPressed("ui_cancel"))
{
ReturnToPrev();
Expand Down
5 changes: 5 additions & 0 deletions Scenes/UI/Options/Scripts/OptionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public override void _Ready()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (@event.IsActionPressed("ui_cancel"))
{
ReturnToPrev();
Expand Down
10 changes: 9 additions & 1 deletion Scenes/UI/Remapping/ControlSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ private void GetCurrentSelection()
OnControllerButtonPressed();
GetNode<Button>("Panel/ControllerButton").GrabFocus();
break;
default:
_closeButton.GrabFocus();
break;
}
}

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (@event.IsActionPressed("ui_cancel"))
{
ReturnToPrev();
Expand Down Expand Up @@ -179,7 +187,7 @@ private void ControllerConnectionChanged(long id, bool connected)
_controllerButton.Visible = Input.GetConnectedJoypads().Count > 0;
if (
(string)SaveSystem.GetConfigValue(SaveSystem.ConfigSettings.InputKey) == "CONTROLLER"
&& !_closeButton.Visible
&& !_controllerButton.Visible
)
{
OnArrowButtonPressed();
Expand Down
2 changes: 1 addition & 1 deletion Scenes/UI/RewardSelectionUI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="Texture2D" uid="uid://burj10os057fx" path="res://Scenes/UI/Assets/UI_CrystalFrameInset.png" id="4_gufce"]

[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("ButtonContainer", "_description", "_acceptButton", "_skipButton")]
process_mode = 2
process_mode = 3
script = ExtResource("1_1m6an")
ButtonContainer = NodePath("MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer/HBoxContainer")
_description = NodePath("MarginContainer/PanelContainer/VBoxContainer/DescBox/DescMargin/Description")
Expand Down
5 changes: 5 additions & 0 deletions Scenes/UI/Scripts/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ private void AddDisplayButtons(IDisplayable[] displayables, Node parentNode)

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (_tabs.CurrentTab == 0) //Godot 4.4 changed neighbor behaviour
{
if (_notes.GetChildCount() > 0)
Expand Down
28 changes: 25 additions & 3 deletions Scenes/UI/Scripts/MenuModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ public partial class MenuModule : CanvasLayer, IFocusableMenu

private Control _lastFocused { get; set; }

public override void _Ready()
{
Input.JoyConnectionChanged += (device, connected) =>
{
if (!connected)
OpenPauseMenu(); //Pause on disconnection
};
GetTree().GetRoot().FocusExited += OpenPauseMenu;
}

public void ResumeFocus()
{
CurSceneNode.ProcessMode = ProcessModeEnum.Inherit;
Expand All @@ -37,11 +47,14 @@ public void ReturnToPrev()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (@event.IsActionPressed("Pause"))
{
var pauseMenu = GD.Load<PackedScene>(PauseMenu.LoadPath).Instantiate<PauseMenu>();
AddChild(pauseMenu);
pauseMenu.OpenMenu(this);
OpenPauseMenu();
}
if (@event.IsActionPressed("Inventory"))
{
Expand All @@ -50,4 +63,13 @@ public override void _Input(InputEvent @event)
invenMenu.OpenMenu(this);
}
}

private void OpenPauseMenu()
{
if (CurSceneNode.ProcessMode == ProcessModeEnum.Disabled)
return;
var pauseMenu = GD.Load<PackedScene>(PauseMenu.LoadPath).Instantiate<PauseMenu>();
AddChild(pauseMenu);
pauseMenu.OpenMenu(this);
}
}
5 changes: 5 additions & 0 deletions Scenes/UI/Scripts/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ private void OpenOptions()

public override void _Input(InputEvent @event)
{
if (!GetWindow().HasFocus())
{
GetViewport().SetInputAsHandled();
return;
}
if (@event.IsActionPressed("ui_cancel"))
{
ReturnToPrev();
Expand Down
2 changes: 1 addition & 1 deletion Scenes/UI/Scripts/RewardSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Stages type
var rewardUI = GD.Load<PackedScene>(LoadPath).Instantiate<RewardSelect>();
parent.AddChild(rewardUI);
rewardUI.Initialize(playerStats, amount, type);
parent.GetTree().Paused = true;
parent.ProcessMode = ProcessModeEnum.Disabled;

return rewardUI;
}
Expand Down
10 changes: 5 additions & 5 deletions Scenes/UI/TitleScreen/Scripts/TitleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public partial class TitleScreen : Control, IFocusableMenu
private Control _focused;
public IFocusableMenu Prev { get; set; }

public override void _EnterTree()
{
BgAudioPlayer.LiveInstance.PlayLevelMusic();
}

public override void _Ready()
{
TweenLight();
Expand Down Expand Up @@ -59,9 +64,4 @@ private void TweenLight()
tween.SetLoops(-1);
tween.Play();
}

public override void _EnterTree()
{
BgAudioPlayer.LiveInstance.PlayLevelMusic();
}
}