Skip to content

Commit

Permalink
Hotfix 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiNtD committed Jan 5, 2021
1 parent 4a6d107 commit 6164053
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 60 deletions.
23 changes: 18 additions & 5 deletions SVRichPresence/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## Unreleased

## [2.4.1] - 2021-01-05
### Removed
- `discord` command used for Ask to Join (removed in last update)
- Code that went unused from removal of Ask to Join
- `{ PercentComplete }` tag due to lag issues

### Changed
- Commands changed from starting with `DiscordRP_` to just `Discord`
- `DiscordRP_Reload` -> `DiscordReload`
- `DiscordRP_Format` -> `DiscordFormat`
- `DiscordRP_Tags` -> `DiscordTags`

## [2.4.0] - 2021-01-05
### Added
Expand All @@ -13,13 +25,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Migrated to "new" project format

### Fixed
- Supports Stardew Valley 1.5

### Removed
- Ask to Join support (Networking SDK no longer accessible)
- `AllowAskToJoin` from config

### Fixed
- Supports Stardew Valley 1.5

## [2.3.1] - 2019-12-05
### Added
- `discord` console command to respond to Ask to Join requests via console.
Expand Down Expand Up @@ -135,7 +147,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Removed Discord event handlers due to them not triggering.

[Unreleased]: https://github.com/FayneAldan/SVRichPresence/compare/v2.4.0...HEAD
[Unreleased]: https://github.com/FayneAldan/SVRichPresence/compare/v2.4.1...HEAD
[2.4.1]: https://github.com/FayneAldan/SVRichPresence/compare/v2.4.0...v2.4.1
[2.4.0]: https://github.com/FayneAldan/SVRichPresence/compare/v2.3.1...v2.4.0
[2.3.1]: https://github.com/FayneAldan/SVRichPresence/compare/v2.3.0...v2.3.1
[2.3.0]: https://github.com/FayneAldan/SVRichPresence/compare/2.3.0-beta1...v2.3.0
Expand Down
57 changes: 4 additions & 53 deletions SVRichPresence/RichPresenceMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@

namespace SVRichPresence {
public class RichPresenceMod : Mod {
private static readonly Color blurple = new Color(114, 137, 218);
private static readonly string clientId = "444517509148966923";
private static readonly string steamId = "413150";
private readonly Random rand = new Random();
private ModConfig config = new ModConfig();
private IRichPresenceAPI api;
private DiscordRpcClient client;
private readonly JoinRequestMessage[] requests = new JoinRequestMessage[ushort.MaxValue + 1];
private ushort lastRequestID = 0;

public override void Entry(IModHelper helper) {
#if DEBUG
Expand Down Expand Up @@ -66,57 +62,21 @@ public override void Entry(IModHelper helper) {
client.Initialize();

#region Console Commands
Helper.ConsoleCommands.Add("discord",
"Respond to a Discord join request.",
(command, args) => {
// Yes, I know this code is a mess.
switch (args[0].ToLower()) {
case "yes":
case "y":
Respond(lastRequestID, true);
break;
case "no":
case "n":
Respond(lastRequestID, false);
break;
default:
try {
var id = ushort.Parse(args[0], System.Globalization.NumberStyles.HexNumber);
switch (args[1].ToLower()) {
case "yes":
case "y":
Respond(id, true);
break;
case "no":
case "n":
Respond(id, false);
break;
default:
Monitor.Log("Invalid response.", LogLevel.Error);
break;
}
} catch (Exception) {
Monitor.Log("Invalid request ID.", LogLevel.Error);
}
break;
}
}
);
Helper.ConsoleCommands.Add("DiscordRP_Reload",
Helper.ConsoleCommands.Add("DiscordReload",
"Reloads the config for Discord Rich Presence.",
(string command, string[] args) => {
LoadConfig();
Monitor.Log("Config reloaded.", LogLevel.Info);
}
);
Helper.ConsoleCommands.Add("DiscordRP_Format",
Helper.ConsoleCommands.Add("DiscordFormat",
"Formats and prints a provided configuration string.",
(string command, string[] args) => {
string text = api.FormatText(string.Join(" ", args));
Monitor.Log("Result: " + text, LogLevel.Info);
}
);
Helper.ConsoleCommands.Add("DiscordRP_Tags",
Helper.ConsoleCommands.Add("DiscordTags",
"Lists tags usable for configuration strings.",
(string command, string[] args) => {
IDictionary<string, string> tags =
Expand Down Expand Up @@ -196,7 +156,6 @@ public override void Entry(IModHelper helper) {
tagReg.SetTag("PetName", () => Game1.player.hasPet() ? Game1.player.getPetDisplayName() : api.None, true);
tagReg.SetTag("Location", () => Game1.currentLocation.Name, true);
tagReg.SetTag("RomanticInterest", () => Utility.getTopRomanticInterest(Game1.player)?.getName() ?? api.None, true);
tagReg.SetTag("PercentComplete", () => Utility.percentGameComplete(), true);

tagReg.SetTag("Money", () => {
// Copied from LoadGameMenu
Expand Down Expand Up @@ -237,15 +196,6 @@ public override void Entry(IModHelper helper) {
#endregion
}

private void Respond(ushort id, Boolean response) {
var request = requests[id];
if (request == null)
Monitor.Log("Request ID doesn't exist.", LogLevel.Error);
client.Respond(request, response);
Monitor.Log("Responding to join request. This may fail if 30 seconds have passed.", LogLevel.Info);
requests[id] = null;
}

public override object GetApi() => api;

private void HandleButton(object sender, ButtonReleasedEventArgs e) {
Expand All @@ -262,6 +212,7 @@ private void HandleButton(object sender, ButtonReleasedEventArgs e) {

private void LoadConfig() => config = Helper.ReadConfig<ModConfig>();

[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members")]
private void SaveConfig() => Helper.WriteConfig(config);

private Timestamps timestampSession;
Expand Down
2 changes: 1 addition & 1 deletion SVRichPresence/SVRichPresence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>SVRichPresence</AssemblyName>
<RootNamespace>SVRichPresence</RootNamespace>
<Version>2.4.0</Version>
<Version>2.4.1</Version>
<TargetFramework>net452</TargetFramework>
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
Expand Down
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.4.0",
"Version": "2.4.1",
"Description": "Shows your in-game state on your Discord profile.",
"UniqueID": "FayneAldan.RichPresence",
"EntryDll": "SVRichPresence.dll",
Expand Down

0 comments on commit 6164053

Please sign in to comment.