|
|
@@ -1,5 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.IO; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
//using Microsoft.Win32; |
|
|
|
|
|
|
|
using IllusionPlugin; |
|
|
@@ -94,6 +96,8 @@ namespace GamecraftRPC |
|
|
|
Client.EnterMenu += CallbackUtility.MenuEnter; |
|
|
|
|
|
|
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine()); |
|
|
|
|
|
|
|
Client client = new Client(); |
|
|
|
|
|
|
|
CommandBuilder.Builder() |
|
|
|
.Name("JoinDiscord") |
|
|
@@ -136,7 +140,6 @@ namespace GamecraftRPC |
|
|
|
if (DiscordRPC != null) |
|
|
|
{ |
|
|
|
Game game = Game.CurrentGame(); |
|
|
|
Client client = new Client(); |
|
|
|
GamecraftModdingAPI.Utility.Logging.CommandLog($"Gamecraft {client.Version}\nUnity {client.UnityVersion}\n{PluginInfo()}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}"); |
|
|
|
} |
|
|
|
else |
|
|
@@ -174,25 +177,65 @@ namespace GamecraftRPC |
|
|
|
} |
|
|
|
}) |
|
|
|
.Build(); |
|
|
|
#if !RELEASE |
|
|
|
bool alreadyWarned = false; |
|
|
|
|
|
|
|
CommandBuilder.Builder() |
|
|
|
.Name("ListDiscordLobbies") |
|
|
|
.Description($"View a list of public multiplayer lobbies available through {Name}") |
|
|
|
.Action(() => |
|
|
|
{ |
|
|
|
LobbySearchQuery query = lm.GetSearchQuery(); |
|
|
|
query.Sort("slots", LobbySearchCast.Number, "999"); |
|
|
|
query.Limit(100); |
|
|
|
lm.Search(query, result => |
|
|
|
{ |
|
|
|
if (result == Result.Ok) |
|
|
|
{ |
|
|
|
StringBuilder sb = new StringBuilder("~ Lobby List [ID | Username (players/max)] ~\n"); |
|
|
|
int lobbyCount = lm.LobbyCount(); |
|
|
|
for (int i = 0; i < lobbyCount; i++) |
|
|
|
{ |
|
|
|
long id = lm.GetLobbyId(i); |
|
|
|
Lobby lobby = lm.GetLobby(id); |
|
|
|
sb.AppendFormat("{3} | {0} ({1}/{2})\n", lm.GetLobbyMetadataValue(id, "name"), |
|
|
|
lm.MemberCount(id), lobby.Capacity.ToString(), lm.GetLobbyMetadataValue(id, "steamid")); |
|
|
|
} |
|
|
|
GamecraftModdingAPI.Utility.Logging.CommandLog(sb.ToString().TrimEnd()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
.Build(); |
|
|
|
|
|
|
|
string popupFileName = "." + Name + "_startuppopup"; |
|
|
|
bool alreadyWarned = File.Exists(popupFileName); |
|
|
|
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; |
|
|
|
}; |
|
|
|
client.PromptUser(new DualChoicePrompt( |
|
|
|
#if !RELEASE |
|
|
|
$"Version {Version} of {Name} is a pre-release. If you encounter a bug or other issue, please report it on the Exmods Discord.", |
|
|
|
#else |
|
|
|
$"Congrats, you've installed the {Name} mod! If you encounter a bug or other issue, please report it on the Exmods Discord.", |
|
|
|
#endif |
|
|
|
|
|
|
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up"); |
|
|
|
Name, |
|
|
|
"Discord", |
|
|
|
() => |
|
|
|
{ |
|
|
|
if (DiscordRPC == null) |
|
|
|
{ |
|
|
|
UnityEngine.Application.OpenURL("https://discord.exmods.org"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DiscordRPC.GetOverlayManager().OpenGuildInvite("2CtWzZT", result => { GamecraftModdingAPI.Utility.Logging.MetaLog($"Open Discord server invite through GameSDK {result}"); }); |
|
|
|
} |
|
|
|
File.WriteAllText(popupFileName, Version); |
|
|
|
}, |
|
|
|
"Ok", |
|
|
|
() => { File.WriteAllText(popupFileName, Version); })); |
|
|
|
}; |
|
|
|
|
|
|
|
GamecraftModdingAPI.Utility.Logging.MetaLog($"{Name} has started up"); |
|
|
|
} |
|
|
|
|
|
|
|
public void OnFixedUpdate() { } // called once per physics update |
|
|
|