Skip to content

Commit

Permalink
Merge pull request #84 from dan0v/master
Browse files Browse the repository at this point in the history
Version 2.10.0
  • Loading branch information
dan0v authored Jul 21, 2024
2 parents ce864bb + 6f1520b commit ed57394
Show file tree
Hide file tree
Showing 49 changed files with 1,252 additions and 482 deletions.
14 changes: 8 additions & 6 deletions AmplitudeSoundboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<RootNamespace>Amplitude</RootNamespace>
<NeutralLanguage>en</NeutralLanguage>
<Platforms>AnyCPU;x64</Platforms>
<Version>2.9.2</Version>
<Version>2.10.0</Version>
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode>
Expand All @@ -34,15 +34,17 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="Avalonia" Version="11.0.11" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.0.11"/>
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.11"/>
<PackageReference Include="ManagedBass" Version="3.1.1" />
<PackageReference Include="ManagedBass.Flac" Version="3.1.1" />
<PackageReference Include="ManagedBass.Mix" Version="3.1.1" />
<PackageReference Include="ManagedBass.Opus" Version="3.1.1" />
<PackageReference Include="SharpHook" Version="5.3.2" />
<PackageReference Include="SharpHook" Version="5.3.7" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
<Application.Styles>
<FluentTheme>
<FluentTheme.Palettes>
<ColorPaletteResources x:Key="Light" Accent="#ff9821af" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" AltMediumLow="#e4e7e9" BaseHigh="Black" BaseLow="#fff0813a" BaseMedium="#ffad4617" BaseMediumHigh="#ff811e00" BaseMediumLow="#ff97320c" ChromeAltLow="#ff811e00" ChromeBlackHigh="Black" ChromeBlackLow="#fff0813a" ChromeBlackMedium="#ff811e00" ChromeBlackMediumLow="#ffad4617" ChromeDisabledHigh="#fff0813a" ChromeDisabledLow="#ffad4617" ChromeGray="#ff97320c" ChromeHigh="#fff0813a" ChromeLow="#ffffceac" ChromeMedium="#fffcbf95" ChromeMediumLow="#ffffceac" ChromeWhite="White" ListLow="#fffcbf95" ListMedium="#fff0813a" RegionColor="#ffbfbfc1" />
<ColorPaletteResources x:Key="Dark" Accent="#ff9821af" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" AltMediumLow="#1f2329" BaseHigh="White" BaseLow="#fff0813a" BaseMedium="#fffcbf95" BaseMediumHigh="#ffffceac" BaseMediumLow="#fff6a068" ChromeAltLow="#ffffceac" ChromeBlackHigh="Black" ChromeBlackLow="#ffffceac" ChromeBlackMedium="Black" ChromeBlackMediumLow="Black" ChromeDisabledHigh="#fff0813a" ChromeDisabledLow="#fffcbf95" ChromeGray="#fff9af7e" ChromeHigh="#fff9af7e" ChromeLow="#ff97320c" ChromeMedium="#ffad4617" ChromeMediumLow="#ffda6d2e" ChromeWhite="White" ListLow="#ffad4617" ListMedium="#fff0813a" RegionColor="#ff171a21" />
<ColorPaletteResources x:Key="Light" Accent="{Binding ThemeManager.Theme.AccentColor}" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" BaseHigh="Black" ChromeBlackHigh="Black" ChromeBlackLow="#fff0813a" ChromeBlackMediumLow="#ffad4617" ChromeWhite="White"/>
<ColorPaletteResources x:Key="Dark" Accent="{Binding ThemeManager.Theme.AccentColor}" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" BaseHigh="White" ChromeBlackHigh="Black" ChromeBlackLow="#ffffceac" ChromeBlackMediumLow="Black" ChromeWhite="White"/>
</FluentTheme.Palettes>
</FluentTheme>
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
</Application.Styles>
</Application>
5 changes: 2 additions & 3 deletions App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
*/

using Amplitude.Helpers;
using Amplitude.Models;
using Amplitude.ViewModels;
using Amplitude.Views;
using Avalonia;
Expand Down Expand Up @@ -57,7 +56,7 @@ public static string APP_STORAGE
public static SoundClipManager SoundClipManager => SoundClipManager.Instance;
public static OutputProfileManager OutputProfileManager => OutputProfileManager.Instance;
public static HotkeysManager HotkeysManager => HotkeysManager.Instance;
public static ThemeHandler ThemeHandler => ThemeHandler.Instance;
public static ThemeManager ThemeManager => ThemeManager.Instance;
public static WindowManager WindowManager => WindowManager.Instance;
public static ConfigManager ConfigManager => ConfigManager.Instance;
public static ISoundEngine SoundEngine => MSoundEngine.Instance;
Expand Down Expand Up @@ -112,7 +111,7 @@ public override void OnFrameworkInitializationCompleted()
var p = OutputProfileManager;
var s = SoundClipManager;
var h = HotkeysManager;
var t = ThemeHandler;
var t = ThemeManager;
var w = WindowManager;
w.ReadWindowSizesAndPositions();
w.SetMainWindow((MainWindow)desktop.MainWindow);
Expand Down
Binary file added Assets/img/Dark/Reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/img/Light/Reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 5 additions & 10 deletions Models/ConfigManager.cs → Helpers/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Helpers;
using Amplitude.Localization;
using Amplitude.Models;
using Amplitude.ViewModels;
using AmplitudeSoundboard;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Config))]
public partial class ConfigManagerContext : JsonSerializerContext { }
Expand Down Expand Up @@ -99,10 +98,6 @@ public void SaveAndOverwriteConfig(Config config)
{
Localizer.Instance.ChangeLanguage(config.Language);
}
if (_config.ThemeId != config.ThemeId)
{
App.ThemeHandler.SelectTheme(config.ThemeId);
}

var json = App.JsonIoManager.ConvertObjectsToJSON(config);
App.JsonIoManager.SaveJSONToFile(CONFIG_FILE_LOCATION, json);
Expand All @@ -121,7 +116,7 @@ public void SaveAndOverwriteConfig(Config config)
try
{
string json = App.JsonIoManager.RetrieveJSONFromFile(CONFIG_FILE_LOCATION);
if (!string.IsNullOrEmpty(json))
if (!string.IsNullOrEmpty(json))
{
return App.JsonIoManager.ConvertObjectsFromJSON<Config>(json);
}
Expand Down Expand Up @@ -154,7 +149,7 @@ public List<GridItemRow> GetGridLayout()
rowItem.List.Add(new SoundBoardGridItemViewModel(Config.GridSoundClipIds[row][col], row, col));
}
}

list.Add(rowItem);
}
return list;
Expand All @@ -164,7 +159,7 @@ public void ComputeGridTileSizes()
{
var rows = Config.GridRows;
Config.ActualTileHeight = (int)(((App.WindowManager.MainWindow?.GridSize.height - (8 * rows) - 15) / rows) ?? Config.GridTileHeight ?? 100);

var cols = Config.GridColumns;
Config.ActualTileWidth = (int)(((App.WindowManager.MainWindow?.GridSize.width - (10 * cols) - 10) / cols) ?? Config.GridTileWidth ?? 100);
}
Expand Down
10 changes: 10 additions & 0 deletions Helpers/FeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ private static OSPlatform GetPlatform()
{ OSPlatform.OSX, true },
{ OSPlatform.Linux, false },
}
},
{
Feature.BACKGROUND_OPACTIY,
new()
{
{ OSPlatform.Windows, true },
{ OSPlatform.OSX, true },
{ OSPlatform.Linux, false },
}
}
};

public enum Feature
{
HOTKEYS,
CUSTOM_TITLEBAR,
BACKGROUND_OPACTIY
}
}
}
4 changes: 2 additions & 2 deletions Helpers/JsonIoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Models;
using AmplitudeSoundboard;
using System;
using System.IO;
Expand All @@ -42,6 +41,7 @@ public class JsonIoManager
SoundClipManagerContext.Default,
OutputProfileManagerContext.Default,
ConfigManagerContext.Default,
ThemeManagerContext.Default,
WindowManagerContext.Default
)
};
Expand All @@ -56,7 +56,7 @@ public class JsonIoManager
try
{
var obj = JsonSerializer.Deserialize<T>(json, jsonSerializerOptions);
return obj == null ? default : (T?) obj;
return obj == null ? default : (T?)obj;
}
catch (Exception e)
{
Expand Down
24 changes: 12 additions & 12 deletions Helpers/MSoundEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ class MSoundEngine : ISoundEngine

private void RefreshPlaybackProgressAndCheckQueue(object? sender, ElapsedEventArgs e)
{
lock(currentlyPlayingLock)
lock (currentlyPlayingLock)
{
List<PlayingClip> toRemove = [];
foreach(var track in CurrentlyPlaying)
foreach (var track in CurrentlyPlaying)
{
track.CurrentPos += TIMER_MS * 0.001d;
if (track.ProgressPct == 1)
{
toRemove.Add(track);
}
}
foreach(var track in toRemove)

foreach (var track in toRemove)
{
if (track.LoopClip)
{
Expand Down Expand Up @@ -156,7 +156,7 @@ private MSoundEngine()

public void AddToQueue(SoundClip source)
{
lock(queueLock)
lock (queueLock)
{
Queued.Add(source.ShallowCopy());
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public void Play(SoundClip source, bool fromQueue = false)
}
}

private void Play(string fileName, int volume, int volumeMultiplier, string playerDeviceName, bool loopClip, string soundClipId, string ? name = null)
private void Play(string fileName, int volume, int volumeMultiplier, string playerDeviceName, bool loopClip, string soundClipId, string? name = null)
{
double vol = (volume / 100.0) * (volumeMultiplier / 100.0);

Expand Down Expand Up @@ -257,15 +257,15 @@ private void Play(string fileName, int volume, int volumeMultiplier, string play
{
var len = Bass.ChannelGetLength(stream, PositionFlags.Bytes);
double length = Bass.ChannelBytes2Seconds(stream, len);
PlayingClip track = new (string.IsNullOrEmpty(name) ? Path.GetFileNameWithoutExtension(fileName) ?? "" : name, soundClipId, playerDeviceName, stream, length, loopClip);
PlayingClip track = new(string.IsNullOrEmpty(name) ? Path.GetFileNameWithoutExtension(fileName) ?? "" : name, soundClipId, playerDeviceName, stream, length, loopClip);

lock(currentlyPlayingLock)
lock (currentlyPlayingLock)
{
CurrentlyPlaying.Add(track);
}
Bass.ChannelPlay(stream, false);
}
catch(Exception)
catch (Exception)
{
App.WindowManager.ShowErrorString(string.Format(Localization.Localizer.Instance["FileBadFormatString"], fileName));
}
Expand Down Expand Up @@ -306,11 +306,11 @@ public void CheckDeviceExistsAndGenerateErrors(OutputProfile profile)

public void Reset()
{
lock(queueLock)
lock (queueLock)
{
Queued.Clear();
}
lock(currentlyPlayingLock)
lock (currentlyPlayingLock)
{
foreach (var stream in CurrentlyPlaying)
{
Expand All @@ -336,7 +336,7 @@ public void StopPlaying(int bassId)

public void RemoveFromQueue(SoundClip clip)
{
lock(queueLock)
lock (queueLock)
{
Queued.Remove(clip);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Helpers;
using Amplitude.Models;
using AmplitudeSoundboard;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -28,19 +28,19 @@ You should have received a copy of the GNU General Public License
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Dictionary<string, OutputProfile>))]
public partial class OutputProfileManagerContext : JsonSerializerContext { }

public class OutputProfileManager : INotifyPropertyChanged
{
private static OutputProfileManager? _instance;
public static OutputProfileManager Instance => _instance ??= new OutputProfileManager();

private const string MIGRATED_PROFILES_NAME_BASE = "Migrated_Profile";
private int migratedProfileCounter = 1;

private const string OUTPUTPROFILES_FILE = "profiles.json";
public const string DEFAULT_OUTPUTPROFILE = "DEFAULT";

Expand Down
1 change: 0 additions & 1 deletion Helpers/SharpKeyboardHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ You should have received a copy of the GNU General Public License
using SharpHook.Native;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Amplitude.Helpers
{
Expand Down
7 changes: 4 additions & 3 deletions Models/SoundClipManager.cs → Helpers/SoundClipManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Models;
using AmplitudeSoundboard;
using System;
using System.Collections.Generic;
Expand All @@ -30,12 +31,12 @@ You should have received a copy of the GNU General Public License
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Dictionary<string, SoundClip>))]
public partial class SoundClipManagerContext : JsonSerializerContext { }

public class SoundClipManager: INotifyPropertyChanged
public class SoundClipManager : INotifyPropertyChanged
{
private static SoundClipManager? _instance;
public static SoundClipManager Instance => _instance ??= new SoundClipManager();
Expand Down Expand Up @@ -149,7 +150,7 @@ private void ValidateSoundClip(SoundClip clip)
{
App.WindowManager.ShowErrorSoundClip(clip, ViewModels.ErrorListViewModel.SoundClipErrorType.MISSING_IMAGE_FILE);
}

var profile = App.OutputProfileManager.GetOutputProfile(clip.OutputProfileId);
if (profile == null)
{
Expand Down
Loading

0 comments on commit ed57394

Please sign in to comment.