fix(breaking): better handling of the server rotation config

The config path was also changed to `BepInEx/config/GBSU/config.json`

Tracks the -maplist argument
This commit is contained in:
anavoi 2025-07-13 23:32:42 +02:00
commit 8132f69ed2
8 changed files with 69 additions and 14 deletions

View file

@ -11,11 +11,11 @@ namespace GBSU.Addons;
public class GBSUGui : MonoBehaviour
{
private bool menu_shown;
private bool error_shown;
private static bool error_shown;
//private string _currentMap;
public Rect gmenu = new(Screen.width / 2, 0, 385f, 690f);
public Rect error_dialog = new(Screen.width / 2, 0, 520f, 175f);
private string error_msg = "Unknown error!";
private static string error_msg = "Unknown error!";
readonly IInputSystem inputSystem = UnityInput.Current;
private void Update()
@ -46,7 +46,7 @@ public class GBSUGui : MonoBehaviour
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUILayout.Label($@"==Guide==
Set CLI arguments: -ip, -port
Set CLI arguments: -ip, -port (optionally -maplist)
[Hosting]
1. Create a config in Gang Beasts_Data/Config/Rotation/config.json
@ -65,7 +65,7 @@ Set CLI arguments: -ip, -port
{
if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Menu)
{
if (File.Exists(Helper.RotationFolderPath + "config.json"))
if (File.Exists(Helper.GameConfigPath))
{
Helper.hosting = true;
@ -176,7 +176,7 @@ Please refer to the documentation for more information.");
return null;
}
private void PushError(string message)
public static void PushError(string message)
{
Plugin.Log.LogError(message);

View file

@ -34,7 +34,7 @@ public class GBSUServer : MonoBehaviour
public static void StartServer()
{
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig("config.json", true); // load rotation config from Config/Rotation/config.json
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig(null); // the argument doesn't matter as we do stuff in the method
ServerConfig serverConfig = NetConfigLoader.LoadServerConfig(); // load default server config, because it can be overridden by args like -ip and -port
MonoSingleton<Global>.Instance.UNetManager.LaunchServer(serverConfig); // launch the server with the server config
MonoSingleton<Global>.Instance.UNetManager.GetComponent<GameManagerNew>().ChangeRotationConfig(gameConfig, 0); // set server's rotationconfig

View file

@ -6,7 +6,7 @@ using UnityEngine.Analytics;
namespace GBSU.Addons;
public class Helper
{
public static string RotationFolderPath = Application.dataPath + "/Config/Rotation/";
public static string RotationFolderPath = BepInEx.Paths.BepInExRootPath + "/config/GBSU/";
public static string GameConfigPath = RotationFolderPath + "config.json";
public static string serverip = null;
public static int serverport = 5999;
@ -72,4 +72,14 @@ public class Helper
QualitySettings.vSyncCount = 0;
}
}
public static void CheckCustomRotationPath()
{
// Did the host request to use their own rotation config path?
if (CommandLineParser.Instance.KeyExists("-maplist"))
{
GameConfigPath = CommandLineParser.Instance.GetValueForKey("-maplist");
Plugin.Log.LogInfo("Set custom rotation config path at " + GameConfigPath);
}
}
}