default volume persists restarts

This commit is contained in:
Master Kwoth 2016-06-29 03:12:38 +02:00
parent a6d35aa6c2
commit 112cf972ac
3 changed files with 17 additions and 7 deletions

View File

@ -66,6 +66,7 @@ namespace NadekoBot.Classes
get { return voicePlusTextEnabled; } get { return voicePlusTextEnabled; }
set { set {
voicePlusTextEnabled = value; voicePlusTextEnabled = value;
if (!SpecificConfigurations.Instantiated) return;
OnPropertyChanged(); OnPropertyChanged();
} }
} }
@ -76,6 +77,7 @@ namespace NadekoBot.Classes
get { return sendPrivateMessageOnMention; } get { return sendPrivateMessageOnMention; }
set { set {
sendPrivateMessageOnMention = value; sendPrivateMessageOnMention = value;
if (!SpecificConfigurations.Instantiated) return;
OnPropertyChanged(); OnPropertyChanged();
} }
} }
@ -133,6 +135,17 @@ namespace NadekoBot.Classes
} }
} }
[JsonIgnore]
private float defaultMusicVolume = 1f;
public float DefaultMusicVolume {
get { return defaultMusicVolume; }
set {
defaultMusicVolume = value;
if (!SpecificConfigurations.Instantiated) return;
OnPropertyChanged();
}
}
public ServerSpecificConfig() public ServerSpecificConfig()
{ {
ListOfSelfAssignableRoles = new ObservableCollection<ulong>(); ListOfSelfAssignableRoles = new ObservableCollection<ulong>();

View File

@ -19,7 +19,6 @@ namespace NadekoBot.Modules.Music
{ {
public static ConcurrentDictionary<Server, MusicPlayer> MusicPlayers = new ConcurrentDictionary<Server, MusicPlayer>(); public static ConcurrentDictionary<Server, MusicPlayer> MusicPlayers = new ConcurrentDictionary<Server, MusicPlayer>();
public static ConcurrentDictionary<ulong, float> DefaultMusicVolumes = new ConcurrentDictionary<ulong, float>();
public MusicModule() public MusicModule()
{ {
@ -200,7 +199,8 @@ namespace NadekoBot.Modules.Music
await e.Channel.SendMessage("Volume number invalid.").ConfigureAwait(false); await e.Channel.SendMessage("Volume number invalid.").ConfigureAwait(false);
return; return;
} }
DefaultMusicVolumes.AddOrUpdate(e.Server.Id, volume / 100, (key, newval) => volume / 100); var conf = SpecificConfigurations.Default.Of(e.Server.Id);
conf.DefaultMusicVolume = volume / 100;
await e.Channel.SendMessage($"🎵 `Default volume set to {volume}%`").ConfigureAwait(false); await e.Channel.SendMessage($"🎵 `Default volume set to {volume}%`").ConfigureAwait(false);
}); });
@ -709,10 +709,7 @@ namespace NadekoBot.Modules.Music
var musicPlayer = MusicPlayers.GetOrAdd(textCh.Server, server => var musicPlayer = MusicPlayers.GetOrAdd(textCh.Server, server =>
{ {
float? vol = null; float vol = SpecificConfigurations.Default.Of(server.Id).DefaultMusicVolume;
float throwAway;
if (DefaultMusicVolumes.TryGetValue(server.Id, out throwAway))
vol = throwAway;
var mp = new MusicPlayer(voiceCh, vol); var mp = new MusicPlayer(voiceCh, vol);

View File

@ -136,7 +136,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Modules\Administration\Commands\AutoAssignRole.cs" /> <Compile Include="Modules\Administration\Commands\AutoAssignRole.cs" />
<Compile Include="Modules\Administration\Commands\CustomReactionsCommands.cs" /> <Compile Include="Modules\Administration\Commands\CustomReactionsCommands.cs" />
<Compile Include="Modules\Administration\Commands\SelfAssignedRolesCommand - Copy.cs" /> <Compile Include="Modules\Administration\Commands\SelfAssignedRolesCommand.cs" />
<Compile Include="Modules\Administration\Commands\SelfCommands.cs" /> <Compile Include="Modules\Administration\Commands\SelfCommands.cs" />
<Compile Include="Modules\ClashOfClans\ClashOfClans.cs" /> <Compile Include="Modules\ClashOfClans\ClashOfClans.cs" />
<Compile Include="Classes\DBHandler.cs" /> <Compile Include="Classes\DBHandler.cs" />