Add additional development info
This commit is contained in:
parent
8e99ee0b72
commit
8d81295f43
3 changed files with 40 additions and 19 deletions
|
@ -50,6 +50,7 @@ namespace GamecraftRPC
|
||||||
|
|
||||||
public static void MenuEnter(object sender, MenuEventArgs data)
|
public static void MenuEnter(object sender, MenuEventArgs data)
|
||||||
{
|
{
|
||||||
|
if (PresenceUtility.IsConnecting) return;
|
||||||
PresenceUtility.LastGameStart = 0;
|
PresenceUtility.LastGameStart = 0;
|
||||||
PresenceUtility.Activity.Timestamps.Start = 0;
|
PresenceUtility.Activity.Timestamps.Start = 0;
|
||||||
PresenceUtility.Activity.Timestamps.End = 0;
|
PresenceUtility.Activity.Timestamps.End = 0;
|
||||||
|
|
|
@ -36,31 +36,31 @@ namespace GamecraftRPC
|
||||||
|
|
||||||
internal static Discord.Discord DiscordRPC;
|
internal static Discord.Discord DiscordRPC;
|
||||||
|
|
||||||
// called when Gamecraft shuts down
|
// called when Gamecraft shuts down
|
||||||
public void OnApplicationQuit()
|
public void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
// Shutdown this mod
|
// Shutdown this mod
|
||||||
if (DiscordRPC != null)
|
if (DiscordRPC != null)
|
||||||
{
|
{
|
||||||
DiscordRPC.GetActivityManager().ClearActivity((result) => { GamecraftModdingAPI.Utility.Logging.LogDebug($"Cleared status: {result}"); DiscordRPC.Dispose(); });
|
DiscordRPC.GetActivityManager().ClearActivity((result) => { GamecraftModdingAPI.Utility.Logging.LogDebug($"Cleared status: {result}"); DiscordRPC.Dispose(); });
|
||||||
}
|
}
|
||||||
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
|
||||||
|
|
||||||
// Shutdown the Gamecraft modding API last
|
// Shutdown the Gamecraft modding API last
|
||||||
GamecraftModdingAPI.Main.Shutdown();
|
GamecraftModdingAPI.Main.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when Gamecraft starts up
|
// called when Gamecraft starts up
|
||||||
public void OnApplicationStart()
|
public void OnApplicationStart()
|
||||||
{
|
{
|
||||||
// Initialize the Gamecraft modding API first
|
// Initialize the Gamecraft modding API first
|
||||||
GamecraftModdingAPI.Main.Init();
|
GamecraftModdingAPI.Main.Init();
|
||||||
|
|
||||||
// detect Wine (maybe?)
|
// detect Wine (maybe?)
|
||||||
bool isWineDetected = false;
|
bool isWineDetected = false;
|
||||||
foreach (var key in Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").GetSubKeyNames())
|
foreach (var key in Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").GetSubKeyNames())
|
||||||
{
|
{
|
||||||
if (key == "Wine")
|
if (key == "Wine")
|
||||||
{
|
{
|
||||||
isWineDetected = true;
|
isWineDetected = true;
|
||||||
break;
|
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--------------------------------");
|
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 = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.NoRequireDiscord);
|
||||||
DiscordRPC.SetLogHook(LOG_LEVEL, (_, msg) => { GamecraftModdingAPI.Utility.Logging.MetaLog(msg); });
|
DiscordRPC.SetLogHook(LOG_LEVEL, (_, msg) => { GamecraftModdingAPI.Utility.Logging.MetaLog(msg); });
|
||||||
//DiscordRPC.GetActivityManager().RegisterSteam(1078000);
|
//DiscordRPC.GetActivityManager().RegisterSteam(1078000);
|
||||||
|
@ -92,7 +92,7 @@ namespace GamecraftRPC
|
||||||
Game.Simulate += CallbackUtility.SimulationEnter;
|
Game.Simulate += CallbackUtility.SimulationEnter;
|
||||||
Client.EnterMenu += CallbackUtility.MenuEnter;
|
Client.EnterMenu += CallbackUtility.MenuEnter;
|
||||||
|
|
||||||
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine());
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine());
|
||||||
|
|
||||||
CommandBuilder.Builder()
|
CommandBuilder.Builder()
|
||||||
.Name("JoinDiscord")
|
.Name("JoinDiscord")
|
||||||
|
@ -133,18 +133,35 @@ namespace GamecraftRPC
|
||||||
.Action(() =>
|
.Action(() =>
|
||||||
{
|
{
|
||||||
if (DiscordRPC != null)
|
if (DiscordRPC != null)
|
||||||
{
|
{
|
||||||
Game game = Game.CurrentGame();
|
Game game = Game.CurrentGame();
|
||||||
Client client = new Client();
|
Client client = new Client();
|
||||||
GamecraftModdingAPI.Utility.Logging.CommandLog($"Gamecraft {client.Version}\nUnity {client.UnityVersion}\n{Name} {Version}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}");
|
GamecraftModdingAPI.Utility.Logging.CommandLog($"Gamecraft {client.Version}\nUnity {client.UnityVersion}\n{Name} {Version}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GamecraftModdingAPI.Utility.Logging.CommandLogError("Discord GameSDK functionality is unavailable. Please make sure Discord is open when launching Gamecraft.");
|
GamecraftModdingAPI.Utility.Logging.CommandLogError("Discord GameSDK functionality is unavailable. Please make sure Discord is open when launching Gamecraft.");
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.Build();
|
.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");
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# GamecraftRPC
|
# GamecraftRPC
|
||||||
|
|
||||||
Experimental project for Discord Rich Presence in Gamecraft.
|
Experimental project for Discord Rich Presence in Gamecraft.
|
||||||
This currently only works in native environments (eg this does not work with Wine/Proton) although I'm sure someone can find a way to fix that'.
|
This currently only works in native environments (eg this does not work with Wine/Proton) although I'm sure someone can find a way to fix that.
|
||||||
|
|
||||||
## Dev environment Setup
|
## Dev environment Setup
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ For any mod to work, you will have to patch your game with [GCIPA](https://git.e
|
||||||
This project also requires the [GamecraftModdingAPI](https://git.exmods.org/modtainers/GamecraftModdingAPI) library to be installed (in `ref/Plugins/GamecraftModdingAPI.dll`).
|
This project also requires the [GamecraftModdingAPI](https://git.exmods.org/modtainers/GamecraftModdingAPI) library to be installed (in `ref/Plugins/GamecraftModdingAPI.dll`).
|
||||||
[Direct link to install guide](https://www.exmods.org/guides/install.html).
|
[Direct link to install guide](https://www.exmods.org/guides/install.html).
|
||||||
|
|
||||||
|
For rich presence functionality, files in lib/x86_64 of Discord's [GameSDK](https://discord.com/developers/docs/game-sdk/sdk-starter-guide) must be copied to ref/Gamecraft_Data/Plugins.
|
||||||
|
The GameSDK csharp folder is already included in the git repo.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
After you've completed the setup, open the solution file `GamecraftRPC.sln` in your prefered C# .NET/Mono development environment.
|
After you've completed the setup, open the solution file `GamecraftRPC.sln` in your prefered C# .NET/Mono development environment.
|
||||||
|
|
Loading…
Add table
Reference in a new issue