Skip to content

Commit

Permalink
Closes #60; Added fullscreen option which fixes display bug on SteamD…
Browse files Browse the repository at this point in the history
…eck. Also added support for a bunch more games.
  • Loading branch information
ZachAR3 committed Jul 1, 2023
1 parent f07bb77 commit 0df4bef
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 85 deletions.
21 changes: 12 additions & 9 deletions Scenes/Home.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ size_flags_horizontal = 4
size_flags_vertical = 4
theme = ExtResource("1_c22a4")
script = ExtResource("1_p51ic")
_appVersion = 3.2
_appVersion = 3.4
_darkBg = NodePath("DarkBG")
_lightBg = NodePath("LightBG")
_downloadWindowApp = NodePath("Pages/Installer/DownloadWindow/Window")
Expand Down Expand Up @@ -146,18 +146,16 @@ vertical_alignment = 1

[node name="Option" type="HBoxContainer" parent="Header"]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = -396.0
offset_top = -20.9444
offset_bottom = 21.0556
anchors_preset = -1
anchor_left = 0.715625
anchor_top = 0.325
anchor_right = 0.989062
anchor_bottom = 0.675001
grow_horizontal = 0
grow_vertical = 2
theme_override_constants/separation = 29
alignment = 1
metadata/_edit_use_anchors_ = true

[node name="LightMode" type="CheckButton" parent="Header/Option"]
layout_mode = 2
Expand All @@ -176,6 +174,10 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tufja")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tufja")
text = "Music"

[node name="QuitButton" type="Button" parent="Header/Option"]
layout_mode = 2
text = "Quit"

[node name="OpenConsole" type="Button" parent="Header"]
layout_mode = 1
anchors_preset = -1
Expand Down Expand Up @@ -256,6 +258,7 @@ script = ExtResource("15_p1cux")

[connection signal="toggled" from="Header/Option/LightMode" to="." method="SetTheme"]
[connection signal="toggled" from="Header/Option/MuteButton" to="." method="ToggledMusicButton"]
[connection signal="pressed" from="Header/Option/QuitButton" to="." method="ExitButtonPressed"]
[connection signal="pressed" from="Header/OpenConsole" to="Tools" method="ToggleConsole"]
[connection signal="pressed" from="ErrorConsole/ErrorConsole/CloseButton" to="Tools" method="ToggleConsole"]

Expand Down
6 changes: 3 additions & 3 deletions Scenes/ModManagerPage.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ text = "Load more"
layout_mode = 1
anchors_preset = -1
anchor_left = 0.0130208
anchor_top = 0.175
anchor_top = 0.186111
anchor_right = 0.793229
anchor_bottom = 0.211111
anchor_bottom = 0.223148
placeholder_text = "Search"
metadata/_edit_use_anchors_ = true

Expand All @@ -278,7 +278,7 @@ clip_contents = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.0125
anchor_top = 0.226852
anchor_top = 0.24
anchor_right = 0.792708
anchor_bottom = 0.933333
grow_horizontal = 2
Expand Down
23 changes: 20 additions & 3 deletions Scenes/SettingsPage.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="Script" path="res://Scripts/SettingsPage.cs" id="1_angmk"]

[node name="Settings" type="Control" node_paths=PackedStringArray("_githubTokenLineEdit", "_getCompatibleVersionsButton") groups=["Initiate"]]
[node name="Settings" type="Control" node_paths=PackedStringArray("_githubTokenLineEdit", "_getCompatibleVersionsButton", "_displayModeButton") groups=["Initiate"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -12,12 +12,15 @@ grow_vertical = 2
script = ExtResource("1_angmk")
_githubTokenLineEdit = NodePath("SettingsContainer/GithubTokenLineEdit")
_getCompatibleVersionsButton = NodePath("SettingsContainer/GetCompatibleVersions")
_displayModeButton = NodePath("SettingsContainer/DisplayModeButton")
metadata/_edit_use_anchors_ = true

[node name="SettingsContainer" type="GridContainer" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.252922
anchor_right = 0.747078
anchor_left = 0.253125
anchor_top = 0.037963
anchor_right = 0.747396
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
Expand Down Expand Up @@ -59,7 +62,21 @@ WARNING:WILL LIKELY CAUSE ANANONYMOUS USERS TO EXCEED API LIMIT"
flat = true
text_overrun_behavior = 4

[node name="DisplayModeLabel" type="Label" parent="SettingsContainer"]
layout_mode = 2
text = "Display mode:"

[node name="DisplayModeButton" type="OptionButton" parent="SettingsContainer"]
layout_mode = 2
alignment = 1
item_count = 2
popup/item_0/text = "Windowed"
popup/item_0/id = 0
popup/item_1/text = "Fullscreen"
popup/item_1/id = 3

[connection signal="pressed" from="SettingsContainer/ResetSettings" to="." method="ResetSettingsPressed"]
[connection signal="pressed" from="SettingsContainer/ResetInstalledMods" to="." method="ResetInstalledModsPressed"]
[connection signal="text_submitted" from="SettingsContainer/GithubTokenLineEdit" to="." method="GithubTokenEntered"]
[connection signal="toggled" from="SettingsContainer/GetCompatibleVersions" to="." method="GetCompatibleToggled"]
[connection signal="item_selected" from="SettingsContainer/DisplayModeButton" to="." method="SetDisplayMode"]
2 changes: 1 addition & 1 deletion Scripts/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class Globals : Node
public override void _Ready()
{
Instance = this;
SaveManager.Version = 2.2f;
SaveManager.Version = 2.3f;
Settings = SaveManager.GetSettings();
SetDefaultPaths();
if (!string.IsNullOrEmpty(Settings.GithubApiToken))
Expand Down
14 changes: 11 additions & 3 deletions Scripts/Home.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Godot;
using Godot.Collections;

Expand Down Expand Up @@ -32,8 +33,9 @@ public partial class Home : Control
// Godot functions
private void Initiate()
{
// Sets minimum window size to prevent text clipping and UI breaking at smaller scales.
// Sets minimum window size and display mode.
DisplayServer.WindowSetMinSize(new Vector2I(1024, 576));
DisplayServer.WindowSetMode((DisplayServer.WindowMode)Globals.Instance.Settings.DisplayMode);

// Set the theme
SetTheme(Globals.Instance.Settings.LightModeEnabled);
Expand Down Expand Up @@ -84,6 +86,12 @@ private void ToggledMusicButton(bool musicEnabled)
{
AudioServer.SetBusMute(AudioServer.GetBusIndex("Master"), !musicEnabled);
}




private void ExitButtonPressed()
{
GetTree().Quit();
}

}

7 changes: 7 additions & 0 deletions Scripts/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ private void GetTitles(long result, long responseCode, string[] headers, byte[]

// TODO remove this once games are added to list (#59)
_titles["01001F5010DFA000"] = "Pokémon Legends: Arceus";
_titles["0100000011D90000"] = "Pokémon Brilliant Diamond";
_titles["010018E011D92000"] = "Pokémon Shining Pearl";
_titles["01003D200BAA2000"] = "Pokémon Mystery Dungeon: Rescue Team DX";
_titles["01004D300C5AE000"] = "Kirby and the Forgotten Land";
_titles["01006BB00C6F0000"] = "The Legend of Zelda: Link's Awakening";
_titles["010093801237C000"] = "Metroid Dread";
_titles["0100A3D008C5C000"] = "Pokémon Scarlet and Violet";
}


Expand Down
112 changes: 62 additions & 50 deletions Scripts/SettingsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,66 @@

public partial class SettingsPage : Node
{
[Export()] private ModManager _modManager;
[Export()] private LineEdit _githubTokenLineEdit;

[Export()] private CheckBox _getCompatibleVersionsButton;


private void Initiate()
{
_getCompatibleVersionsButton.ButtonPressed = Globals.Instance.Settings.GetCompatibleVersions;
}


// Signal functions
private async void ResetSettingsPressed()
{
var confirm = await Tools.Instance.ConfirmationPopup();
if (confirm != true)
{
return;
}
Globals.Instance.Settings = new SettingsResource();
Globals.Instance.SetDefaultPaths();
}


private async void ResetInstalledModsPressed()
{
var confirm = await Tools.Instance.ConfirmationPopup();
if (confirm != true)
{
return;
}
_modManager.ResetInstalled();
}


private void GithubTokenEntered(string token)
{
Globals.Instance.Settings.GithubApiToken = token;
Globals.Instance.SaveManager.WriteSave();
Globals.Instance.AuthenticateGithubClient();
_githubTokenLineEdit.Text = "Success!";
}


private void GetCompatibleToggled(bool getCompatible)
{
Globals.Instance.Settings.GetCompatibleVersions = getCompatible;
Globals.Instance.SaveManager.WriteSave();
}
[Export()] private ModManager _modManager;
[Export()] private LineEdit _githubTokenLineEdit;

[Export()] private CheckBox _getCompatibleVersionsButton;
[Export()] private OptionButton _displayModeButton;


private void Initiate()
{
_getCompatibleVersionsButton.ButtonPressed = Globals.Instance.Settings.GetCompatibleVersions;
_displayModeButton.Selected = _displayModeButton.GetItemIndex(Globals.Instance.Settings.DisplayMode);
}


// Signal functions
private async void ResetSettingsPressed()
{
var confirm = await Tools.Instance.ConfirmationPopup();
if (confirm != true)
{
return;
}
Globals.Instance.Settings = new SettingsResource();
Globals.Instance.SetDefaultPaths();
}


private async void ResetInstalledModsPressed()
{
var confirm = await Tools.Instance.ConfirmationPopup();
if (confirm != true)
{
return;
}
_modManager.ResetInstalled();
}


private void GithubTokenEntered(string token)
{
Globals.Instance.Settings.GithubApiToken = token;
Globals.Instance.SaveManager.WriteSave();
Globals.Instance.AuthenticateGithubClient();
_githubTokenLineEdit.Text = "Success!";
}


private void GetCompatibleToggled(bool getCompatible)
{
Globals.Instance.Settings.GetCompatibleVersions = getCompatible;
Globals.Instance.SaveManager.WriteSave();
}


private void SetDisplayMode(int modeSelected)
{
var displayMode = _displayModeButton.GetItemId(modeSelected);
DisplayServer.WindowSetMode((DisplayServer.WindowMode)displayMode);
Globals.Instance.Settings.DisplayMode = displayMode;
Globals.Instance.SaveManager.WriteSave();
}
}

1 change: 1 addition & 0 deletions Scripts/SettingsResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public partial class SettingsResource : Resource
[Export()] public string AppDataPath;
[Export()] public string GithubApiToken;
[Export()] public bool GetCompatibleVersions;
[Export()] public int DisplayMode;
}
Loading

0 comments on commit 0df4bef

Please sign in to comment.