Skip to content

Commit

Permalink
Hot Fix 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiNtD committed Jan 5, 2021
1 parent 2f64e7e commit 5d8b725
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
4 changes: 4 additions & 0 deletions SVRichPresence/IRichPresenceAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public interface IRichPresenceAPI {
bool SetTag(Mod mod, string key, string value);
bool SetTag(Mod mod, string key, NetString value);
bool SetTag(Mod mod, string key, int value);
bool SetTag(Mod mod, string key, float value);
bool SetTag(Mod mod, string key, decimal value, int roundDigits = -1);
bool SetTag(Mod mod, string key, double value, int roundDigits = -1);

Expand All @@ -28,6 +29,7 @@ public interface IRichPresenceAPI {
bool SetTag(Mod mod, string key, Func<string> resolver, bool onlyWhenWorldReady = false);
bool SetTag(Mod mod, string key, Func<NetString> resolver, bool onlyWhenWorldReady = false);
bool SetTag(Mod mod, string key, Func<int> resolver, bool onlyWhenWorldReady = false);
bool SetTag(Mod mod, string key, Func<float> resolver, bool onlyWhenWorldReady = false);
bool SetTag(Mod mod, string key, Func<decimal> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false);
bool SetTag(Mod mod, string key, Func<double> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false);

Expand Down Expand Up @@ -113,6 +115,7 @@ public interface ITagRegister {
bool SetTag(string key, string value);
bool SetTag(string key, NetString value);
bool SetTag(string key, int value);
bool SetTag(string key, float value);
bool SetTag(string key, decimal value, int roundDigits = -1);
bool SetTag(string key, double value, int roundDigits = -1);

Expand All @@ -126,6 +129,7 @@ public interface ITagRegister {
bool SetTag(string key, Func<string> resolver, bool onlyWhenWorldReady = false);
bool SetTag(string key, Func<NetString> resolver, bool onlyWhenWorldReady = false);
bool SetTag(string key, Func<int> resolver, bool onlyWhenWorldReady = false);
bool SetTag(string key, Func<float> resolver, bool onlyWhenWorldReady = false);
bool SetTag(string key, Func<decimal> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false);
bool SetTag(string key, Func<double> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false);

Expand Down
1 change: 0 additions & 1 deletion SVRichPresence/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ internal class GamePresence : MenuPresence {
public bool ShowFarmType = true;
public bool ShowWeather = true;
public bool ShowPlayTime = true;
public bool AllowAskToJoin = true;

public GamePresence() {
Details = "{{ FarmName }} | {{ Money }}";
Expand Down
6 changes: 3 additions & 3 deletions SVRichPresence/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Stardew Valley Rich Presence")]
[assembly: AssemblyCopyright("Copyright © Fayne Aldan 2019")]
[assembly: AssemblyCopyright("Copyright © Fayne Aldan 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("09756636-fa49-4706-8951-4aeb7ccca411")]

[assembly: AssemblyVersion("2.3.1.0")]
[assembly: AssemblyFileVersion("2.3.1.0")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]

8 changes: 8 additions & 0 deletions SVRichPresence/RichPresenceAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public bool SetTag(Mod mod, string key, NetString value) =>
SetTag(mod, key, () => value);
public bool SetTag(Mod mod, string key, int value) =>
SetTag(mod, key, () => value);
public bool SetTag(Mod mod, string key, float value) =>
SetTag(mod, key, () => value);
public bool SetTag(Mod mod, string key, decimal value, int roundDigits = -1) =>
SetTag(mod, key, () => value, roundDigits);
public bool SetTag(Mod mod, string key, double value, int roundDigits = -1) =>
Expand All @@ -43,6 +45,8 @@ public bool SetTag(Mod mod, string key, Func<NetString> resolver, bool onlyWhenW
SetTag(mod, key, () => resolver.Invoke().ToString(), onlyWhenWorldReady);
public bool SetTag(Mod mod, string key, Func<int> resolver, bool onlyWhenWorldReady = false) =>
SetTag(mod, key, () => resolver.Invoke().ToString(), onlyWhenWorldReady);
public bool SetTag(Mod mod, string key, Func<float> resolver, bool onlyWhenWorldReady = false) =>
SetTag(mod, key, () => resolver.Invoke().ToString(), onlyWhenWorldReady);
public bool SetTag(Mod mod, string key, Func<decimal> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false) =>
SetTag(mod, key, () => {
decimal val = resolver.Invoke();
Expand Down Expand Up @@ -144,6 +148,8 @@ public bool SetTag(string key, NetString value) =>
api.SetTag(mod, key, value);
public bool SetTag(string key, int value) =>
api.SetTag(mod, key, value);
public bool SetTag(string key, float value) =>
api.SetTag(mod, key, value);
public bool SetTag(string key, decimal value, int roundDigits = -1) =>
api.SetTag(mod, key, value, roundDigits);
public bool SetTag(string key, double value, int roundDigits = -1) =>
Expand All @@ -155,6 +161,8 @@ public bool SetTag(string key, Func<NetString> resolver, bool onlyWhenWorldReady
api.SetTag(mod, key, resolver, onlyWhenWorldReady);
public bool SetTag(string key, Func<int> resolver, bool onlyWhenWorldReady = false) =>
api.SetTag(mod, key, resolver, onlyWhenWorldReady);
public bool SetTag(string key, Func<float> resolver, bool onlyWhenWorldReady = false) =>
api.SetTag(mod, key, resolver, onlyWhenWorldReady);
public bool SetTag(string key, Func<decimal> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false) =>
api.SetTag(mod, key, resolver, roundDigits, onlyWhenWorldReady);
public bool SetTag(string key, Func<double> resolver, int roundDigits = -1, bool onlyWhenWorldReady = false) =>
Expand Down
35 changes: 1 addition & 34 deletions SVRichPresence/RichPresenceMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,7 @@ public override void Entry(IModHelper helper) {
client.OnReady += (sender, e) => {
Monitor.Log("Connected to Discord: " + e.User.ToString(), LogLevel.Info);
};
client.OnJoin += (sender, args) => {
Monitor.Log("Attempting to join game: " + args.Secret, LogLevel.Info);
JoinGame(args.Secret);
};
client.OnJoinRequested += (sender, msg) => {
string name = msg.User.Username;
string tag = msg.User.ToString();
ushort id = (ushort)rand.Next(ushort.MinValue, ushort.MaxValue);
requests[id] = msg;
lastRequestID = id;
string hex = id.ToString("X");
Monitor.Log(tag + " wants to join your game via Discord.", LogLevel.Alert);
Monitor.Log("To respond type \"discord " + hex + " yes/no\" or just \"discord yes/no\"", LogLevel.Info);
Game1.chatBox.addMessage(name + " wants to join your game via Discord.\nTo respond check the console or use Discord or its overlay.", blurple);
};
client.Initialize();
client.SetSubscription(EventType.Join | EventType.JoinRequest);

#region Console Commands
Helper.ConsoleCommands.Add("discord",
Expand Down Expand Up @@ -118,12 +102,6 @@ public override void Entry(IModHelper helper) {
}
}
);
Helper.ConsoleCommands.Add("DiscordRP_Join",
"Join a co-op game via invite code.",
(string command, string[] args) => {
JoinGame(string.Join(" ", args));
}
);
Helper.ConsoleCommands.Add("DiscordRP_Reload",
"Reloads the config for Discord Rich Presence.",
(string command, string[] args) => {
Expand Down Expand Up @@ -268,14 +246,6 @@ private void Respond(ushort id, Boolean response) {
requests[id] = null;
}

private void JoinGame(string inviteCode) {
Game1.ExitToTitle(() => {
object lobby = Program.sdk.Networking.GetLobbyFromInviteCode(inviteCode);
if (lobby == null) return;
TitleMenu.subMenu = new FarmhandMenu(Program.sdk.Networking.CreateClient(lobby));
});
}

public override object GetApi() => api;

private void HandleButton(object sender, ButtonReleasedEventArgs e) {
Expand Down Expand Up @@ -329,16 +299,13 @@ private RichPresence GetPresence() {
assets.SmallImageKey = "weather_" + WeatherKey();
if (conf.ShowPlayTime)
presence.Timestamps = timestampFarm;
if (Context.IsMultiplayer && conf.AllowAskToJoin)
if (Context.IsMultiplayer)
try {
presence.Party = new Party {
ID = Game1.MasterPlayer.UniqueMultiplayerID.ToString(),
Size = Game1.numberOfPlayers(),
Max = Game1.getFarm().getNumberBuildingsConstructed("Cabin") + 1
};
presence.Secrets = new Secrets {
JoinSecret = Game1.server.getInviteCode()
};
} catch { }
}

Expand Down
13 changes: 9 additions & 4 deletions SVRichPresence/SVRichPresence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="DiscordRPC, Version=1.0.121.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DiscordRichPresence.1.0.121\lib\net35\DiscordRPC.dll</HintPath>
<Reference Include="DiscordRPC, Version=1.0.169.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DiscordRichPresence.1.0.169\lib\net35\DiscordRPC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -67,11 +72,11 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion SVRichPresence/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Rich Presence",
"Author": "Fayne Aldan",
"Version": "2.3.1",
"Version": "2.4.0",
"Description": "Shows your in-game state on your Discord profile.",
"UniqueID": "FayneAldan.RichPresence",
"EntryDll": "SVRichPresence.dll",
Expand Down
4 changes: 2 additions & 2 deletions SVRichPresence/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DiscordRichPresence" version="1.0.121" targetFramework="net452" />
<package id="DiscordRichPresence" version="1.0.169" targetFramework="net452" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="3.0.0" targetFramework="net452" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="3.2.2" targetFramework="net452" />
</packages>

0 comments on commit 5d8b725

Please sign in to comment.