Skip to content

Commit

Permalink
2.0.0 things and release
Browse files Browse the repository at this point in the history
  • Loading branch information
MintLily committed Oct 8, 2022
1 parent 69bc9c2 commit c65eff1
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ BuiltProject/
MintyWPF2/bin/
MintyWPF2/obj/
MintyWPF2/Libs/
MintyWPF2/DiscordGameSDK/*.zip
8 changes: 1 addition & 7 deletions MintyRPC.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MintyRPC", "MintyRPC\MintyR
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yggdrasil", "Yggdrasil\Yggdrasil\Yggdrasil.csproj", "{4BB8DF19-7D20-429A-AF5F-5D1232538E08}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MintyWPF", "MintyWPF\MintyWPF.csproj", "{E74C21ED-E3F1-4FE9-8E80-72EB06B28D51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MintyWPF2", "MintyWPF2\MintyWPF2.csproj", "{4FA8187D-BF5B-41C5-B65F-2333F66FCE4F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MintyWPF2", "MintyWPF2\MintyWPF2.csproj", "{4FA8187D-BF5B-41C5-B65F-2333F66FCE4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -25,10 +23,6 @@ Global
{4BB8DF19-7D20-429A-AF5F-5D1232538E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BB8DF19-7D20-429A-AF5F-5D1232538E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BB8DF19-7D20-429A-AF5F-5D1232538E08}.Release|Any CPU.Build.0 = Release|Any CPU
{E74C21ED-E3F1-4FE9-8E80-72EB06B28D51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E74C21ED-E3F1-4FE9-8E80-72EB06B28D51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E74C21ED-E3F1-4FE9-8E80-72EB06B28D51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E74C21ED-E3F1-4FE9-8E80-72EB06B28D51}.Release|Any CPU.Build.0 = Release|Any CPU
{4FA8187D-BF5B-41C5-B65F-2333F66FCE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FA8187D-BF5B-41C5-B65F-2333F66FCE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FA8187D-BF5B-41C5-B65F-2333F66FCE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
4 changes: 2 additions & 2 deletions MintyWPF2/ConfigSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class General {

public class PresenceInfo {
[JsonProperty("PresenceID")]
public ulong PresenceId { get; set; }
public long PresenceId { get; set; }
[JsonProperty("Details")]
public string? Details { get; set; }
[JsonProperty("State")]
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void Setup() {
};

var info = new PresenceInfo {
PresenceId = 702767245385924659,
PresenceId = 999999999999999999,
Details = "Being cute",
State = "And adorable",
LargeImageKey = "mint",
Expand Down
40 changes: 20 additions & 20 deletions MintyWPF2/DiscordActivityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ public class DiscordActivityManager {
public static ActivityManager? _activityManager;
private static ApplicationManager? _applicationManager;
private static string? _randomLobbyId;
public static string clientId;

public static void StartPresence() {
/*public static void StartPresence() {
if (isRunning) return;
if (ConfigSetup.GetPresenceInfo().PresenceId == 0) return;
var pId = ConfigSetup.GetPresenceInfo().PresenceId;
if (pId == "0" || !string.IsNullOrWhiteSpace(pId)) return;
var processes = Process.GetProcesses();
var isDiscordAppRunning = processes.Any(p => p.ProcessName is "Discord" or "DiscordPTB" or "DiscordCanary");
var isDiscordAppRunning = _isDiscordAppRunning(processes);
if (!isDiscordAppRunning) return;
if (!isDiscordAppRunning) throw new Exception();
startTime = DateTime.Now;
_time = Functions.Utils.UpdateTimeSelection();
Expand All @@ -43,8 +45,9 @@ public static void StartPresence() {
}
_randomLobbyId = tempLobbyId;
var clientId = Environment.GetEnvironmentVariable("702767245385924659") ?? "702767245385924659";
DiscordManager = new Discord.Discord(Int64.Parse(clientId), (UInt64)Discord.CreateFlags.Default);
//var clientId = Environment.GetEnvironmentVariable() ?? "702767245385924659";
var _clientId = ConfigSetup.GetPresenceInfo().PresenceId ?? "702767245385924659";
DiscordManager = new Discord.Discord(Int64.Parse(clientId??_clientId), (UInt64)Discord.CreateFlags.Default);
DiscordManager.SetLogHook(Discord.LogLevel.Debug, (level, message) => {
// Log.Status($"Rich Presence has started with code: {message}");
Expand All @@ -54,21 +57,18 @@ public static void StartPresence() {
UpdateActivity();
if (!firstStart)
//if (!firstStart)
_loopThread.Start();

initStart = true;
if (!isRunning && initStart)
if (ConfigSetup.GetGeneralInfo().AutoRestart)
BasicStartDiscord(true);
firstStart = true;
isRunning = true;
}
}*/

public static void BasicStartDiscord(bool callFromRestart = false) {
if (isRunning)
return;
//Log.Info($"{(callFromRestart ? "Res" : "S")}tarting Discord Rich Presence, please wait...");

var pId = ConfigSetup.GetPresenceInfo().PresenceId;
if (pId == 0)
return;

if (!callFromRestart) {
Task.Run(() => {
Expand All @@ -87,7 +87,8 @@ public static void BasicStartDiscord(bool callFromRestart = false) {
Task.Delay(2000);
} else {
//Log.Info("Waited 10 seconds. Failed to start Discord Rich Presence, Discord is not running.");
return;
//return;
throw new Exception();
}
}
}
Expand All @@ -105,18 +106,17 @@ public static void BasicStartDiscord(bool callFromRestart = false) {
}
_randomLobbyId = tempLobbyId;
var clientId = Environment.GetEnvironmentVariable("702767245385924659") ?? "702767245385924659";
DiscordManager = new Discord.Discord(Int64.Parse(clientId), (UInt64)Discord.CreateFlags.Default);
DiscordManager = new Discord.Discord(Int64.Parse(clientId ?? "702767245385924659"), (UInt64)Discord.CreateFlags.Default);
DiscordManager.SetLogHook(Discord.LogLevel.Debug, (level, message) => {
//Log.Status($"Rich Presence has {(callFromRestart ? "re" : "")}started with code: {message}");
// Elly is cute
});
_applicationManager = DiscordManager.GetApplicationManager();
UpdateActivity(callFromRestart);
if (!callFromRestart)
if (!callFromRestart && !firstStart)
_loopThread.Start();
isRunning = true;
});
Expand Down
2 changes: 2 additions & 0 deletions MintyWPF2/Functions/StartTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void OnApplicationStart() {
stream.Close();

File.WriteAllBytes(SdkFilePath, file);

DiscordActivityManager.initStart = true;
}

public static bool IsUpdateAvailable;
Expand Down
8 changes: 5 additions & 3 deletions MintyWPF2/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:local="clr-namespace:MintyWPF" mc:Ignorable="d"
Title="MintyRPC" Height="600" Width="1000" MaxWidth="1000" MaxHeight="650"
ui:WindowHelper.UseModernWindowStyle="True">
ui:WindowHelper.UseModernWindowStyle="True"
Visibility="Visible">

<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskbarItemInfo"
Expand All @@ -22,7 +23,7 @@
<UniformGrid Margin="120 0 0 0">
<UniformGrid>
<Label Content="GitHub ↗️" Margin="50 6 0 0" MouseUp="GitHubLink" />
<Label Content="Version: v2.0.0 Beta Build" Margin="0,6,0,0" />
<Label Content="Version: v2.0.0" Margin="0,6,0,0" />
<Label Content="Creator ↗️" Margin="50 6 0 0" MouseUp="CreatorLink" />
<Label Content="Update Available ↗️" Foreground="Red" Margin="0,6,0,0"
Visibility="Hidden" Name="UpdateLabel" MouseUp="UpdateLink" Initialized="UpdateLabel_OnInitialized" />
Expand All @@ -44,7 +45,8 @@
<UniformGrid Margin="22,0,0,0">
<TextBox Initialized="ClientID_Init" Name="ClientIDBox" Margin="-246,0,150,0" />
<Label Content="Changing the Client ID will require a full restart to take effect." FontSize="8"
Margin="-137,12,0,0" Name="ClientIDExtraText" Visibility="Hidden" />
Margin="-137,12,0,0" Name="ClientIDExtraText" Visibility="Hidden"
DataContextChanged="DoNotAcceptStrings"/>
</UniformGrid>
</UniformGrid>

Expand Down
32 changes: 17 additions & 15 deletions MintyWPF2/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -12,6 +14,7 @@
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
Expand All @@ -21,6 +24,9 @@
using MintyRPC;
using MintyWPF.Functions;
using ModernWpf.Controls;
using ComboBox = System.Windows.Controls.ComboBox;
using Path = System.IO.Path;
using TextBox = System.Windows.Controls.TextBox;

namespace MintyWPF {
/// <summary>
Expand Down Expand Up @@ -56,9 +62,11 @@ public MainWindow() {
InitializeComponent();

LobbyIDBox.ToolTip = ConfigSetup.GetPresenceInfo().LobbyId;

DiscordActivityManager.clientId = ConfigSetup.GetPresenceInfo().PresenceId.ToString();

if (ConfigSetup.GetGeneralInfo().AutoStart)
DiscordActivityManager.StartPresence();
DiscordActivityManager.BasicStartDiscord();
}

private void UpdateLabel_OnInitialized(object? sender, EventArgs e) {
Expand Down Expand Up @@ -197,8 +205,7 @@ private void TimeStampComboBox_OnSelectionChanged(object sender, SelectionChange


private void SaveAndApply_OnClick(object sender, RoutedEventArgs e) {
// TODO: Get all values from text boxes, save to JSON, and restart RPC Activity
ConfigSetup.GetPresenceInfo().PresenceId = ulong.Parse(ClientIDBox.Text);
ConfigSetup.GetPresenceInfo().PresenceId = long.Parse(ClientIDBox.Text);
ConfigSetup.GetPresenceInfo().Details = DetailsBox.Text;
ConfigSetup.GetPresenceInfo().State = StateBox.Text;
ConfigSetup.GetPresenceInfo().LargeImageKey = LargeImgBox.Text;
Expand All @@ -218,31 +225,26 @@ private void SaveAndApply_OnClick(object sender, RoutedEventArgs e) {

private void StartPresenceButton_OnClick(object sender, RoutedEventArgs e) {
ClientIDExtraText.Visibility = Visibility.Visible;
DiscordActivityManager.StartPresence();
try { DiscordActivityManager.BasicStartDiscord(); } catch{ throw new Exception(); }
}

private void StopPresenceButton_OnClick(object sender, RoutedEventArgs e) {
try { DiscordActivityManager.BasicKillDiscord(); } catch { }
}

private void SendToBackground_OnClick(object sender, RoutedEventArgs e) {
/*using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetCallingAssembly()
.GetManifestResourceNames().First(x => x.EndsWith(".ico")));
var file = new byte[stream!.Length];
stream.Read(file, 0, (int)stream.Length);
stream.Close();*/

var iconUri = new Uri("pack://application:,,,/MintyRPCLogo.ico", UriKind.RelativeOrAbsolute);

nIcon.Icon = new Icon(iconUri.AbsolutePath);
var i = System.Drawing.Icon.ExtractAssociatedIcon(
$"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}MintyRPC.exe");

nIcon.Icon = i;
nIcon.Visible = true;
nIcon.Text = "Click to open window.";
WindowState = WindowState.Minimized;
Visibility = Visibility.Hidden;
nIcon.Click += NIconOnClick;
}

private void NIconOnClick(object? sender, EventArgs e) {
WindowState = WindowState.Normal;
Visibility = Visibility.Visible;
nIcon.Visible = false;
}
}
Expand Down
7 changes: 3 additions & 4 deletions MintyWPF2/MintyWPF2.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows8.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
Expand All @@ -11,8 +10,8 @@
<ApplicationIcon>MintyRPCLogo.ico</ApplicationIcon>
<Authors>MintLily</Authors>
<Company>Minty Labs</Company>
<AssemblyVersion>2.0.0.274</AssemblyVersion>
<FileVersion>2.0.0.274</FileVersion>
<AssemblyVersion>2.0.0.361</AssemblyVersion>
<FileVersion>2.0.0.361</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions MintyWPF2/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>C:\Users\dephi\Documents\Visual Studio Projects\MintyRPC\MintyWPF2\bin\publish</PublishDir>
<PublishDir>C:\Users\dephi\Documents\Visual Studio Projects\MintyRPC\BuiltProject</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows8.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-09-30T03:00:50.9510597Z;True|2022-09-29T22:49:42.6524373-04:00;False|2022-09-29T22:49:06.4065762-04:00;</History>
<History>True|2022-10-08T20:41:16.2540517Z;True|2022-10-08T16:27:31.3383695-04:00;True|2022-10-08T16:23:13.2753440-04:00;True|2022-10-08T16:17:05.4061694-04:00;True|2022-10-02T21:51:39.2765070-04:00;True|2022-10-02T21:44:12.9269624-04:00;True|2022-10-02T21:43:57.1716445-04:00;True|2022-10-02T21:42:26.1590634-04:00;True|2022-10-02T21:41:49.8417375-04:00;False|2022-10-02T21:41:38.5840558-04:00;True|2022-10-02T21:41:08.1242720-04:00;True|2022-10-02T21:40:43.4313137-04:00;True|2022-10-02T21:39:23.6046370-04:00;True|2022-10-02T21:34:46.7172906-04:00;True|2022-10-02T21:17:13.1465873-04:00;True|2022-10-02T21:14:08.3577530-04:00;True|2022-10-02T21:04:20.7996296-04:00;True|2022-09-30T16:56:03.2564270-04:00;True|2022-09-30T16:55:37.7796802-04:00;True|2022-09-30T16:37:56.1813491-04:00;True|2022-09-29T23:49:55.4515516-04:00;True|2022-09-29T23:49:15.8667623-04:00;True|2022-09-29T23:12:49.8715563-04:00;True|2022-09-29T23:11:15.0591608-04:00;True|2022-09-29T23:00:50.9510597-04:00;True|2022-09-29T22:49:42.6524373-04:00;False|2022-09-29T22:49:06.4065762-04:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
<h1>MintyRPC</h1>
A basic console application to let you set custom Discord Rich Presences.
What was once solely a basic console application, and now a WPF application, this program lets you display your own Discord Rich Presence. Also, compared to the console application, the WPF version is 3.8% more memory efficient.<br>
<i>Console Application version will no longer be kept up to date.</i>

<h2>TODO:</h2>
<i>Add more documentation; yeah, I'm a bit lazy at the moment.</i>
<h2>TODO</h2>
<ul>
<li><i>Find and fix issues</i></li>
<li>Update DiscordGameSDK to latest</li>
<li>Add support for URL buttons</li>
</ul>

<h2>How to</h2>
<p>
If, for whatever reason, your PC does not have dotNET 6.0+, you can download the latest version below:
.NET Desktop Runtime 6.0.9 - Windows - <a href="https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.9-windows-arm64-installer" target="_blank">Arm64</a> | <a href="https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.9-windows-x64-installer" target="_blank"><b>x64</b></a> | <a href="_blank" target="https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.9-windows-x86-installer">x86</a> - <b>x64</b> will be your best bet.
<br><br>
Create and get your Application ID from <a href="https://discord.com/developers/applications" target="_blank">Discord's Development Portal</a>.<br>
<img src="https://i.mintlily.lgbt/GpUpt8Oszu4N.png" height="300px" /><br><br>
Give it a name of your choosing; this will be the name shown as <code>Playing {your app name}</code> on your Discord Profile<br>
Copy the Application ID and keep it handy, but you will always be able to grab it from here<br>
<img src="https://i.mintlily.lgbt/035RGjJbzAub.png" height="300px" /><br><br>
You can also add your own images for others to see<br>
<img src="https://i.mintlily.lgbt/O1aFLV5TQeV1.png" height="300px" /><br><br>
Place your Application ID in the box labeled Client ID<br>
<img src="https://i.mintlily.lgbt/yBDhLNO1ABka.png" height="300px" /><br><br>
Add your other desired text and any images you uploaded by name (I updated an image with the name of "play")<br>
Once you're ready to go, press "Save and Apply" and then "Start" to turn on the Custom Rich Presence<br>
<img src="https://i.mintlily.lgbt/AsNVcMPfDPgZ.png" width="300px" /><br><br>
<br><br>
Sending the application to the background will put the application in the Notify taskbar section<br>
<img src="https://cdn.discordapp.com/attachments/907498543642722314/1025254249287913492/unknown.png" width="300px" />
</p>

<h2>Credits <small>& other code in the project</small></h2>
<ul>
<li>Discord - <a href="https://discord.com/developers/docs/game-sdk/sdk-starter-guide">DiscordGameSDK</a></li>
<li>exectails - <a href="https://github.com/exectails/Yggdrasil">Yggdrasil</a></li>
<li>Kinnara - <a href="https://github.com/Kinnara/ModernWpf">ModernWpf</a></li>
<li>Discord - <a href="https://discord.com/developers/docs/game-sdk/sdk-starter-guide">DiscordGameSDK</a></li><br>
<li>exectails - <a href="https://github.com/exectails/Yggdrasil">Yggdrasil</a> (for the old console application)</li>
</ul>

0 comments on commit c65eff1

Please sign in to comment.