Improve popup and add lobby list command
This commit is contained in:
parent
a94d9d7699
commit
c292f4e4a8
3 changed files with 59 additions and 19 deletions
|
@ -96,6 +96,7 @@ namespace GamecraftRPC
|
||||||
Discord.LobbyManager lm = Plugin.DiscordRPC.GetLobbyManager();
|
Discord.LobbyManager lm = Plugin.DiscordRPC.GetLobbyManager();
|
||||||
Discord.LobbyTransaction lt = lm.GetLobbyCreateTransaction();
|
Discord.LobbyTransaction lt = lm.GetLobbyCreateTransaction();
|
||||||
lt.SetMetadata("steamid", PresenceUtility.SteamId.ToString());
|
lt.SetMetadata("steamid", PresenceUtility.SteamId.ToString());
|
||||||
|
lt.SetMetadata("name", Steamworks.SteamClient.Name);
|
||||||
lt.SetType(Discord.LobbyType.Public);
|
lt.SetType(Discord.LobbyType.Public);
|
||||||
lt.SetCapacity(2);
|
lt.SetCapacity(2);
|
||||||
lm.CreateLobby(lt, SyncActivityLobby);
|
lm.CreateLobby(lt, SyncActivityLobby);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.1.0</Version>
|
||||||
<Authors>Me</Authors>
|
<Authors>Me</Authors>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://git.exmods.org/???/???</PackageProjectUrl>
|
<PackageProjectUrl>https://git.exmods.org/???/???</PackageProjectUrl>
|
||||||
|
@ -72,10 +72,6 @@
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
<HintPath>..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ClusterToWireConversion.Mock">
|
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
|
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="CommandLine">
|
<Reference Include="CommandLine">
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
<HintPath>..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
//using Microsoft.Win32;
|
//using Microsoft.Win32;
|
||||||
|
|
||||||
using IllusionPlugin;
|
using IllusionPlugin;
|
||||||
|
@ -94,6 +96,8 @@ namespace GamecraftRPC
|
||||||
Client.EnterMenu += CallbackUtility.MenuEnter;
|
Client.EnterMenu += CallbackUtility.MenuEnter;
|
||||||
|
|
||||||
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine());
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Engines.PlayerCountEngine());
|
||||||
|
|
||||||
|
Client client = new Client();
|
||||||
|
|
||||||
CommandBuilder.Builder()
|
CommandBuilder.Builder()
|
||||||
.Name("JoinDiscord")
|
.Name("JoinDiscord")
|
||||||
|
@ -136,7 +140,6 @@ namespace GamecraftRPC
|
||||||
if (DiscordRPC != null)
|
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{PluginInfo()}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}");
|
GamecraftModdingAPI.Utility.Logging.CommandLog($"Gamecraft {client.Version}\nUnity {client.UnityVersion}\n{PluginInfo()}\nSDK {DiscordRPC.ToString()}\nGame {game.Name}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -174,25 +177,65 @@ namespace GamecraftRPC
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.Build();
|
.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) =>
|
Client.EnterMenu += (_, args) =>
|
||||||
{
|
{
|
||||||
if (alreadyWarned) return;
|
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;
|
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
|
#endif
|
||||||
|
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.LogDebug($"{Name} has started up");
|
GamecraftModdingAPI.Utility.Logging.MetaLog($"{Name} has started up");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnFixedUpdate() { } // called once per physics update
|
public void OnFixedUpdate() { } // called once per physics update
|
||||||
|
|
Loading…
Add table
Reference in a new issue