|
|
@@ -36,31 +36,31 @@ namespace GamecraftRPC |
|
|
|
|
|
|
|
internal static Discord.Discord DiscordRPC; |
|
|
|
|
|
|
|
// called when Gamecraft shuts down |
|
|
|
// called when Gamecraft shuts down |
|
|
|
public void OnApplicationQuit() |
|
|
|
{ |
|
|
|
// Shutdown this mod |
|
|
|
if (DiscordRPC != null) |
|
|
|
{ |
|
|
|
// Shutdown this mod |
|
|
|
if (DiscordRPC != null) |
|
|
|
{ |
|
|
|
DiscordRPC.GetActivityManager().ClearActivity((result) => { GamecraftModdingAPI.Utility.Logging.LogDebug($"Cleared status: {result}"); DiscordRPC.Dispose(); }); |
|
|
|
} |
|
|
|
} |
|
|
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown"); |
|
|
|
|
|
|
|
// Shutdown the Gamecraft modding API last |
|
|
|
// Shutdown the Gamecraft modding API last |
|
|
|
GamecraftModdingAPI.Main.Shutdown(); |
|
|
|
} |
|
|
|
|
|
|
|
// called when Gamecraft starts up |
|
|
|
// called when Gamecraft starts up |
|
|
|
public void OnApplicationStart() |
|
|
|
{ |
|
|
|
// Initialize the Gamecraft modding API first |
|
|
|
// Initialize the Gamecraft modding API first |
|
|
|
GamecraftModdingAPI.Main.Init(); |
|
|
|
|
|
|
|
// detect Wine (maybe?) |
|
|
|
bool isWineDetected = false; |
|
|
|
foreach (var key in Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").GetSubKeyNames()) |
|
|
|
{ |
|
|
|
if (key == "Wine") |
|
|
|
if (key == "Wine") |
|
|
|
{ |
|
|
|
isWineDetected = true; |
|
|
|
break; |
|
|
@@ -72,7 +72,7 @@ namespace GamecraftRPC |
|
|
|
GamecraftModdingAPI.Utility.Logging.MetaLog("\n--------------------------------\n\nIt looks like you may be using Wine/Proton, cool!\nPlease install https://github.com/0e4ef622/wine-discord-ipc-bridge to get this to work.\n\n--------------------------------"); |
|
|
|
} |
|
|
|
|
|
|
|
// Initialize this mod |
|
|
|
// Initialize this mod |
|
|
|
DiscordRPC = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.NoRequireDiscord); |
|
|
|
DiscordRPC.SetLogHook(LOG_LEVEL, (_, msg) => { GamecraftModdingAPI.Utility.Logging.MetaLog(msg); }); |
|
|
|
//DiscordRPC.GetActivityManager().RegisterSteam(1078000); |
|
|
@@ -92,7 +92,7 @@ namespace GamecraftRPC |
|
|
|
Game.Simulate += CallbackUtility.SimulationEnter; |
|
|
|
Client.EnterMenu += CallbackUtility.MenuEnter; |
|
|
|
|
|
|
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine()); |
|
|
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine()); |
|
|
|
|
|
|
|
CommandBuilder.Builder() |
|
|
|
.Name("JoinDiscord") |
|
|
@@ -133,18 +133,35 @@ namespace GamecraftRPC |
|
|
|
.Action(() => |
|
|
|
{ |
|
|
|
if (DiscordRPC != null) |
|
|
|
{ |
|
|
|
Game game = Game.CurrentGame(); |
|
|
|
{ |
|
|
|
Game game = Game.CurrentGame(); |
|
|
|
Client client = new Client(); |
|
|
|
GamecraftModdingAPI.Utility.Logging.CommandLog($"Gamecraft {client.Version}\nUnity {client.UnityVersion}\n{Name} {Version}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GamecraftModdingAPI.Utility.Logging.CommandLogError("Discord GameSDK functionality is unavailable. Please make sure Discord is open when launching Gamecraft."); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GamecraftModdingAPI.Utility.Logging.CommandLogError("Discord GameSDK functionality is unavailable. Please make sure Discord is open when launching Gamecraft."); |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
.Build(); |
|
|
|
#if !RELEASE |
|
|
|
bool alreadyWarned = false; |
|
|
|
Client.EnterMenu += (_, args) => |
|
|
|
{ |
|
|
|
if (alreadyWarned) return; |
|
|
|
//GamecraftModdingAPI.Utility.Logging.LogDebug($"Displaying {Name} {Version} DEBUG warning"); |
|
|
|
/* |
|
|
|
RobocraftX.Services.ErrorBuilder.DisplayCustomError( |
|
|
|
$"THIS IS NOT ACTUALLY AN ERROR! {Name} v{Version} is a pre-release. If you encounter a bug or other issue, please report it to NGnius or Exmods on Discord.", |
|
|
|
"Discord", () => { UnityEngine.Application.OpenURL("https://discord.exmods.org"); }, |
|
|
|
"Ok!", () => { GamecraftModdingAPI.Utility.Logging.LogDebug($"Dismissed {Name} {Version} DEBUG warning"); } |
|
|
|
); |
|
|
|
*/ |
|
|
|
RobocraftX.Services.ErrorBuilder.DisplayWarning($"{Name} v{Version} is a pre-release. If you encounter a bug or other issue, please report it to NGnius or Exmods on Discord."); |
|
|
|
alreadyWarned = true; |
|
|
|
}; |
|
|
|
#endif |
|
|
|
|
|
|
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up"); |
|
|
|
} |
|
|
|