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
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ DiskCache="*res://src/engine/caching/DiskCache.cs"
ProceduralDataCache="*res://src/engine/ProceduralDataCache.cs"
PhotoStudio="*res://src/engine/PhotoStudio.tscn"
PauseManager="*res://src/engine/PauseManager.cs"
PauseMenu="*res://src/general/PauseMenu.tscn"
GUIFocusSetter="*res://src/engine/GUIFocusSetter.cs"
UnHandledErrorsGUI="*res://src/engine/UnHandledErrorsGUI.tscn"
DebugDrawer="*res://src/engine/DebugDrawer.tscn"
Expand Down
3 changes: 3 additions & 0 deletions src/engine/LogInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public override void _LogError(string function, string file, int line, string co
if (code.Contains("with non-equal opposite anchors"))
return;

// We might want to ignore this somewhat intermittent error: Parent node is busy adding
// that sometimes happens on scene switch but doesn't seem to cause any problems

// Avoid recursion
if (code.Contains("Unhandled Exception Log"))
return;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/UnHandledErrorsGUI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("1_ca0xl")
errorCount = NodePath("CanvasLayer/MarginContainer/VBoxContainer/ErrorCountLabel")
errorPopup = NodePath("ErrorDialog")
Expand All @@ -31,11 +32,13 @@ anchor_right = 1.0
offset_left = -40.0
offset_bottom = 40.0
grow_horizontal = 0
mouse_filter = 2
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 10

[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/MarginContainer"]
layout_mode = 2
mouse_filter = 2

[node name="ErrorCountLabel" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer"]
visible = false
Expand Down
43 changes: 37 additions & 6 deletions src/general/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public partial class MainMenu : NodeWithInput
private NewGameSettings newGameSettings = null!;
private AnimationPlayer guiAnimations = null!;
private SaveManagerGUI saves = null!;
private Thriveopedia thriveopedia = null!;

private Thriveopedia? thriveopedia;

[Export]
private ModManager modManager = null!;
Expand Down Expand Up @@ -139,6 +140,9 @@ public partial class MainMenu : NodeWithInput

[Export]
private CenterContainer menus = null!;

[Export]
private PackedScene thriveopediaScene = null!;
#pragma warning restore CA2213

private Array<Node>? menuArray;
Expand Down Expand Up @@ -189,6 +193,8 @@ public override void _Ready()
// Unpause the game as the MainMenu should never be paused.
PauseManager.Instance.ForceClear();
MouseCaptureManager.ForceDisableCapture();
PauseMenu.Instance.ReportStageTransition();
PauseMenu.Instance.ForgetCurrentlyOpenPage();

RunMenuSetup();

Expand Down Expand Up @@ -386,7 +392,7 @@ public bool OnEscapePressed()
}

/// <summary>
/// Setup the main menu.
/// Set up the main menu.
/// </summary>
private void RunMenuSetup()
{
Expand All @@ -406,7 +412,6 @@ private void RunMenuSetup()
options = GetNode<OptionsMenu>("OptionsMenu");
newGameSettings = GetNode<NewGameSettings>("NewGameSettings");
saves = GetNode<SaveManagerGUI>("SaveManagerGUI");
thriveopedia = GetNode<Thriveopedia>("Thriveopedia");

// Set initial menu
SwitchMenu();
Expand Down Expand Up @@ -932,7 +937,9 @@ private void OnRedirectedToOptionsMenuFromNewGameSettings()

private void OnReturnFromThriveopedia()
{
thriveopedia.Visible = false;
if (thriveopedia != null)
thriveopedia.Visible = false;

SetCurrentMenu(0, false);
}

Expand Down Expand Up @@ -989,6 +996,21 @@ private void ThriveopediaPressed()
// Hide all the other menus
SetCurrentMenu(uint.MaxValue, false);

// Create the Thriveopedia if it doesn't exist yet
if (thriveopedia == null)
{
thriveopedia = thriveopediaScene.Instantiate<Thriveopedia>();

// Thriveopedia needs to start off hidden to work correctly
thriveopedia.Visible = false;

// Hook up the necessary signals
thriveopedia.Connect(Thriveopedia.SignalName.OnThriveopediaClosed,
new Callable(this, nameof(OnReturnFromThriveopedia)));

AddChild(thriveopedia);
}

// Show the Thriveopedia
thriveopedia.OpenFromMainMenu();
}
Expand Down Expand Up @@ -1116,8 +1138,17 @@ private void OnNewGameIntroVideoStarted()

private void OnThriveopediaOpened(string pageName)
{
thriveopedia.OpenFromMainMenu();
thriveopedia.ChangePage(pageName);
// Make sure Thriveopedia is created if missing
if (thriveopedia == null)
{
GD.Print("Creating Thriveopedia due to page open request");
ThriveopediaPressed();
}

thriveopedia!.OpenFromMainMenu();

// TODO: does something already play a sound or not in this case?
thriveopedia.ChangePage(pageName, false);
}

private void ResetPerformanceTracking()
Expand Down
6 changes: 1 addition & 5 deletions src/general/MainMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ modsInstalledButNotEnabledWarning = NodePath("ModsInstalledButNothingEnabledWarn
lowPerformanceWarning = NodePath("LowPerformanceDialog")
thanksDialog = NodePath("ThanksForBuyingDialog")
menus = NodePath("MenuContainers/Menus")
thriveopediaScene = ExtResource("49")

[node name="Background" type="TextureRect" parent="."]
layout_mode = 1
Expand Down Expand Up @@ -846,10 +847,6 @@ grow_vertical = 2
visible = false
layout_mode = 1

[node name="Thriveopedia" parent="." instance=ExtResource("49")]
visible = false
layout_mode = 1

[node name="LicensesDisplay" parent="." instance=ExtResource("12")]
layout_mode = 1

Expand Down Expand Up @@ -1029,7 +1026,6 @@ ShowCloseButton = false
[connection signal="OnNewGameSettingsClosed" from="NewGameSettings" to="." method="OnReturnFromNewGameSettings"]
[connection signal="OnNewGameVideoStarted" from="NewGameSettings" to="." method="OnNewGameIntroVideoStarted"]
[connection signal="OnWantToSwitchToOptionsMenu" from="NewGameSettings" to="." method="OnRedirectedToOptionsMenuFromNewGameSettings"]
[connection signal="OnThriveopediaClosed" from="Thriveopedia" to="." method="OnReturnFromThriveopedia"]
[connection signal="hidden" from="LicensesDisplay" to="." method="OnReturnFromLicenses"]
[connection signal="hidden" from="GalleryViewer" to="." method="OnReturnFromArtGallery"]
[connection signal="OnFinishedSignal" from="CreditsView/CreditsScroll" to="." method="OnReturnFromCredits"]
Expand Down
Loading