Skip to content

Commit

Permalink
Settings screen better
Browse files Browse the repository at this point in the history
ini change
Platform now instance rather than need to make a node
  • Loading branch information
SlejmUr committed Dec 27, 2024
1 parent d57ada0 commit 4b2dca0
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ PublishProfiles
*.user

logs.txt
EIV_Platform.*
EIV_Platform.*
Mods/
5 changes: 2 additions & 3 deletions csharp/Client/MasterServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ public static string Authenticate()
if (!CanConnect)
return string.Empty;

IPlatform platform = GameManager.Instance.Platform_Manager.Platform;
IUser user = platform.GetUser();
IUser user = PlatformManager.Platform.GetUser();
if (user == null)
return string.Empty;

HttpClient httpClient = new();
UserInfoJson userInfoJSON = new()
{
Platform = platform.PlatformType,
Platform = PlatformManager.Platform.PlatformType,
UserId = user.GetUserId(),
Name = user.GetUserName(),
Version = BuildDefined.Version.ToString(),
Expand Down
10 changes: 8 additions & 2 deletions csharp/Managers/BuildDefined.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EIV_JsonLib;
using Godot;
using System;
using System.IO;

Expand Down Expand Up @@ -40,7 +39,14 @@ public static ReleaseType Release
}


public static string INI = Path.Combine(Path.GetDirectoryName(OS.GetExecutablePath()),
public static string INI = Path.Combine(
#if TOOLS
Directory.GetCurrentDirectory(),
"resources",
"ini",
#else
Path.GetDirectoryName(Godot.OS.GetExecutablePath()),
#endif
#if GAME
"Game.ini"
#elif SERVER
Expand Down
15 changes: 8 additions & 7 deletions csharp/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ public partial class GameManager : Node
public Client.UIManager UIManager { get; set; }
#endif

public PlatformManager Platform_Manager { get; set; }

Array<Node> Nodes = new();

public override void _Ready()
{
this.Name = "GameManager";
MainLog.CreateNew();
Log.Information(csharp.Properties.Resource.BuildDate.Replace("\n", ""));
Log.Information(csharp.Properties.Resource.BuildDate.Replace("\n", "_"));
Log.Information(BuildDefined.FullVersion);
Instance = this;
Log.Verbose("Preload JsonLib! " + (CoreConverters.Converters.Count == 1));
ModManagerInstance = new();
ModManagerInstance = new()
{
Name = "ModManager"
};
Nodes.Add(ModManagerInstance);
#if CLIENT || GAME
UIManager = new();
#endif
Platform_Manager = new();
foreach (var item in Nodes)
{
this.CallDeferred("add_sibling", item);
Expand All @@ -42,8 +43,8 @@ public override void _Ready()

private void ModManagerInstance_AllModsLoaded()
{
Platform_Manager.Init();
if (Platform_Manager.Platform.PlatformType == EIV_Common.Platform.PlatformType.Unknown)
PlatformManager.Init();
if (PlatformManager.Platform.PlatformType == EIV_Common.Platform.PlatformType.Unknown)
{
Log.Error("The Platform set to unknown. We dont know what Platform you using. Please use EIV_Platform.Free solution!");
Quit();
Expand Down
33 changes: 21 additions & 12 deletions csharp/Managers/PlatformManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,35 @@ namespace ExtractIntoVoid.Managers;

public class PlatformManager
{
protected List<string> PlatformNames = ["EIV_Platform.Free.dll", "EIV_Platform.Steam.dll", "EIV_Platform.Epic.dll"];

public IPlatform Platform;
protected static List<string> PlatformNames = ["EIV_Platform.Free.dll", "EIV_Platform.Steam.dll", "EIV_Platform.Epic.dll"];
protected static IPlatform internal_platform;
public static IPlatform Platform
{
get
{
if (internal_platform == null)
GetPlatform();
internal_platform.Init();
return internal_platform;
}
}

public void Init()
public static void Init()
{
if (Platform == null)
if (internal_platform == null)
GetPlatform();
Platform.Init();
internal_platform.Init();
}

public void GetPlatform()
public static void GetPlatform()
{
CreatePlatformEvent createPlatformEvent = new()
{
Platform = null
};
ModAPI.V2.V2Manager.TriggerEvent(createPlatformEvent);
Platform = createPlatformEvent.Platform;
if (Platform == null)
internal_platform = createPlatformEvent.Platform;
if (internal_platform == null)
{
string thisLocation = typeof(PlatformManager).Assembly.Location.GetBaseDir();
// this fixing if we "playing" in-editor.
Expand All @@ -52,13 +61,13 @@ public void GetPlatform()
IPlatform platform = (IPlatform)Activator.CreateInstance(iType);
if (platform == null)
continue;
Platform = platform;
internal_platform = platform;
}
}
}
if (Platform == null)
if (internal_platform == null)
{
Platform = new UnknownPlatform();
internal_platform = new UnknownPlatform();
}
}
}
1 change: 1 addition & 0 deletions csharp/Menus/ConnectionScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void Refresh()
{
ServerList.RemoveChild(item);
}
GD.Print(BuildDefined.INI);
var lobbyList = ConfigINI.Read(BuildDefined.INI, "Lobby", "OfflineLobbyList");
if (lobbyList.Contains("{EXE}"))
{
Expand Down
16 changes: 15 additions & 1 deletion csharp/Menus/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void Apply()
public void Back()
{
this.Hide();
GetTree().Root.GetNode<MainMenu>("/MainMenu").Show();
GetTree().Root.GetNode<MainMenu>("MainMenu").Show();
this.QueueFree();
}

Expand Down Expand Up @@ -201,6 +201,20 @@ private void ScreenSpaceAAButton_IdPressed(long id)
ScreenSpaceAA_LastIndex = (int)id;
}

public void AdvancedVideoSettings_Toggle(bool toggle)
{
if (toggle)
{
VideoSettings.GetNode<Control>("Borderless").Show();
VideoSettings.GetNode<Control>("Exclusive").Show();
}
else
{
VideoSettings.GetNode<Control>("Borderless").Hide();
VideoSettings.GetNode<Control>("Exclusive").Hide();
}
}

public void GameButton_Pressed()
{
GameSettingsContainer.Show();
Expand Down
4 changes: 2 additions & 2 deletions csharp/Properties/BuildDate.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
update-deps
2024-12-26T19:58:54
0c89531
2024-12-28 00:11
d57ada0
5 changes: 1 addition & 4 deletions resources/ini/Client.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
;
; Welcome to Client related configs
; 1 = Enabled | True
; 0 = Disabled | False
; Empty = ""
;


; Master server related configuration
[MasterServer]
; Connect or not to the master server.
ConnectToMasterServer = 0
ConnectToMasterServer = false
; This for testing master server, only works on Debug build.
MasterServerURL = 26.48.71.165:7777

Expand Down
5 changes: 1 addition & 4 deletions resources/ini/Game.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
;
; Welcome to Game related configs
; 1 = Enabled | True
; 0 = Disabled | False
; Empty = ""
;


; Master server related configuration
[MasterServer]
; Connect or not to the master server.
ConnectToMasterServer = 0
ConnectToMasterServer = false
; This for testing master server, only works on Debug build.
MasterServerURL = 26.48.71.165:7777

Expand Down
3 changes: 0 additions & 3 deletions resources/ini/Server.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
;
; Welcome to Server related configs
; 1 = Enabled | True
; 0 = Disabled | False
; Empty = ""
;


Expand Down
80 changes: 66 additions & 14 deletions scenes/Menu/Settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,40 @@ layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -324.0
offset_right = 324.0
offset_bottom = 65.0
offset_left = -325.0
offset_top = 30.0
offset_right = 323.0
offset_bottom = 95.0
grow_horizontal = 2

[node name="Separator" type="HBoxContainer" parent="TopElements"]
layout_mode = 0
theme_override_constants/separation = 60
alignment = 1

[node name="Game" type="Button" parent="TopElements/Separator"]
layout_mode = 2
theme_override_font_sizes/font_size = 27
text = "Game"
flat = true

[node name="Video" type="Button" parent="TopElements/Separator"]
layout_mode = 2
theme_override_font_sizes/font_size = 27
text = "Video"
flat = true

[node name="Controls" type="Button" parent="TopElements/Separator"]
layout_mode = 2
theme_override_font_sizes/font_size = 27
text = "Controls"
flat = true

[node name="Audio" type="Button" parent="TopElements/Separator"]
layout_mode = 2
theme_override_font_sizes/font_size = 27
text = "Audio"
flat = true

[node name="Panel" type="Control" parent="."]
layout_mode = 1
Expand All @@ -69,7 +75,6 @@ grow_horizontal = 2
grow_vertical = 2

[node name="Game Settings" type="VBoxContainer" parent="Panel"]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand Down Expand Up @@ -111,8 +116,10 @@ offset_bottom = 15.5
grow_horizontal = 0
grow_vertical = 2
text = "BUTTON"
flat = true

[node name="Video Settings" type="VBoxContainer" parent="Panel"]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -127,7 +134,36 @@ size_flags_horizontal = 0
theme_override_font_sizes/font_size = 20
text = "Video Settings"

[node name="Enable Advanced" type="Control" parent="Panel/Video Settings"]
layout_mode = 2

[node name="Label" type="Label" parent="Panel/Video Settings/Enable Advanced"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -11.5
offset_right = 233.0
offset_bottom = 11.5
grow_vertical = 2
text = "Enable Advanced"

[node name="CheckBox" type="CheckBox" parent="Panel/Video Settings/Enable Advanced"]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = -81.0
offset_top = -15.5
offset_bottom = 15.5
grow_horizontal = 0
grow_vertical = 2
text = "Enable"

[node name="Borderless" type="Control" parent="Panel/Video Settings"]
visible = false
layout_mode = 2

[node name="Label" type="Label" parent="Panel/Video Settings/Borderless"]
Expand Down Expand Up @@ -156,6 +192,7 @@ grow_vertical = 2
text = "Enable"

[node name="Exclusive" type="Control" parent="Panel/Video Settings"]
visible = false
layout_mode = 2

[node name="Label" type="Label" parent="Panel/Video Settings/Exclusive"]
Expand Down Expand Up @@ -606,21 +643,36 @@ grow_vertical = 0
text = "Apply"

[node name="CancelButton" type="Button" parent="."]
layout_mode = 0
offset_left = 480.0
offset_top = 650.0
offset_right = 540.0
offset_bottom = 685.0
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -140.0
offset_top = -70.0
offset_right = -80.0
offset_bottom = -35.0
grow_horizontal = 2
grow_vertical = 0
text = "Cancel"

[node name="BackButton" type="Button" parent="."]
layout_mode = 0
offset_left = 750.0
offset_top = 650.0
offset_right = 810.0
offset_bottom = 685.0
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = 80.0
offset_top = -70.0
offset_right = 140.0
offset_bottom = -35.0
grow_horizontal = 2
grow_vertical = 0
text = "Back"

[connection signal="pressed" from="TopElements/Separator/Game" to="." method="GameButton_Pressed"]
[connection signal="pressed" from="TopElements/Separator/Video" to="." method="VideoButton_Pressed"]
[connection signal="pressed" from="TopElements/Separator/Controls" to="." method="ControlsButton_Pressed"]
[connection signal="pressed" from="TopElements/Separator/Audio" to="." method="AudioButton_Pressed"]
Expand Down

0 comments on commit 4b2dca0

Please sign in to comment.