more discord rpc

This commit is contained in:
iAmAsval
2021-06-07 17:12:09 +02:00
parent 3ce2fb1430
commit 60e23373f3
7 changed files with 21 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ namespace FModel.Services
Assets = _staticAssets,
Timestamps = _timestamps,
Buttons = _buttons,
State = $"{game.GetDescription()} - Idling"
Details = $"{game.GetDescription()} - Idling"
};
_client.OnReady += (_, args) => Log.Information("{Username}#{Discriminator} ({UserId}) is now ready", args.User.Username, args.User.Discriminator, args.User.ID);
@@ -60,7 +60,7 @@ namespace FModel.Services
_client.Invoke();
}
public void UpdateButDontSavePresence(string details, string state)
public void UpdateButDontSavePresence(string details = null, string state = null)
{
if (!_client.IsInitialized) return;
_client.SetPresence(new RichPresence
@@ -68,8 +68,8 @@ namespace FModel.Services
Assets = _staticAssets,
Timestamps = _timestamps,
Buttons = _buttons,
Details = details,
State = state
Details = details ?? _currentPresence.Details,
State = state ?? _currentPresence.State
});
_client.Invoke();
}

View File

@@ -15,6 +15,7 @@ using System.Windows.Data;
using CSCore.CoreAudioAPI;
using FModel.Extensions;
using FModel.Framework;
using FModel.Services;
using FModel.Settings;
using FModel.ViewModels.Commands;
using FModel.Views.Resources.Controls;
@@ -154,6 +155,7 @@ namespace FModel.ViewModels
public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
{
private DiscordHandler _discordHandler => DiscordService.DiscordHandler;
private static IWaveSource _waveSource;
private static ISoundOut _soundOut;
private Timer _sourceTimer;
@@ -385,6 +387,7 @@ namespace FModel.ViewModels
public void Play()
{
if (_soundOut == null || IsPlaying) return;
_discordHandler.UpdateButDontSavePresence(null, $"Audio Player: {PlayedFile.FileName} ({PlayedFile.Duration:g})");
_soundOut.Play();
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using CUE4Parse.UE4.Assets.Exports;
@@ -34,6 +35,7 @@ namespace FModel.ViewModels
public class MapViewerViewModel : ViewModel
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
private DiscordHandler _discordHandler => DiscordService.DiscordHandler;
#region BINDINGS
@@ -267,13 +269,17 @@ namespace FModel.ViewModels
private void TriggerChange()
{
var layerCount = _bitmaps[_mapIndex].Count(x => x.Value.IsEnabled);
var layerString = $"{layerCount} Layer{(layerCount > 1 ? "s" : "")}";
switch (_mapIndex)
{
case 0:
_discordHandler.UpdateButDontSavePresence(null, $"Map Viewer: Battle Royale ({layerString})");
_mapImage = _brMiniMapImage;
_layerImage = _brLayerImage;
break;
case 1:
_discordHandler.UpdateButDontSavePresence(null, $"Map Viewer: Party Royale ({layerString})");
_mapImage = _prMiniMapImage;
_layerImage = _prLayerImage;
break;
@@ -569,6 +575,7 @@ namespace FModel.ViewModels
}
else if (uObject.TryGetValue(out bool endsTrial, "EndsTrial") && endsTrial)
{
path.LineTo(vector.X, vector.Y);
c.DrawPath(path, _pathPaint);
path = new SKPath();
}

View File

@@ -30,6 +30,7 @@ namespace FModel.Views
{
_applicationView.AudioPlayer.Stop();
_applicationView.AudioPlayer.Dispose();
DiscordService.DiscordHandler.UpdateToSavedPresence();
}
private void OnDeviceSwap(object sender, SelectionChangedEventArgs e)

View File

@@ -6,7 +6,7 @@
xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI"
WindowStartupLocation="CenterScreen" IconVisibility="Collapsed" SizeToContent="Width" ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen" IconVisibility="Collapsed" SizeToContent="Width" ResizeMode="CanMinimize" Closing="OnClosing"
Height="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.75'}"
MinWidth="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.50'}">
<adonisControls:AdonisWindow.Style>

View File

@@ -1,4 +1,5 @@
using System.IO;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
@@ -24,6 +25,8 @@ namespace FModel.Views
InitializeComponent();
}
private void OnClosing(object sender, CancelEventArgs e) => DiscordService.DiscordHandler.UpdateToSavedPresence();
private void OnClick(object sender, RoutedEventArgs e)
{
if (_applicationView.MapViewer.MapImage == null) return;