From 20bb1575db315957cdbe7dc6811893234fe3edd2 Mon Sep 17 00:00:00 2001 From: VladimirKhil Date: Wed, 6 Mar 2024 09:24:36 +0100 Subject: [PATCH] Support mandatory releases --- Directory.Build.props | 2 +- src/Common/SIUI.ViewModel/TableInfoViewModel.cs | 2 +- src/Common/SIUI/Behaviors/MediaController.cs | 6 +++--- src/SICore/SICore/Clients/IConnector.cs | 7 ++++++- src/SICore/SICore/Clients/Viewer/Viewer.cs | 1 + src/SICore/SICore/Messages.cs | 5 +++++ .../SIGame.ViewModel/Settings/UserSettings.cs | 2 +- .../SIGame.ViewModel/ViewModel/GameViewModel.cs | 4 +++- .../SIGame.ViewModel/ViewModel/ReconnectManager.cs | 4 ++++ .../SIGame.ViewModel/ViewModel/SIOnlineViewModel.cs | 1 + src/SIGame/SIGame/App.xaml.cs | 13 ++++++++++--- src/SIGame/SIGame/SIGame.csproj | 2 +- test/Common/Notions.Tests/Notions.Tests.csproj | 2 +- .../SIEngine.Core.Tests/SIEngine.Core.Tests.csproj | 2 +- test/Common/SIEngine.Tests/SIEngine.Tests.csproj | 2 +- .../Common/SIPackages.Tests/SIPackages.Tests.csproj | 2 +- 16 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ff71f1ba..062ae00b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ Vladimir Khil Khil-soft - 7.11.10 + 7.11.11 6.0.2 2.15.0 diff --git a/src/Common/SIUI.ViewModel/TableInfoViewModel.cs b/src/Common/SIUI.ViewModel/TableInfoViewModel.cs index e3dd7c65..bc05a9f6 100644 --- a/src/Common/SIUI.ViewModel/TableInfoViewModel.cs +++ b/src/Common/SIUI.ViewModel/TableInfoViewModel.cs @@ -373,7 +373,7 @@ public double Volume get => _volume; set { - if (_volume != value) + if (_volume != value && _volume >= 0.0 && _volume <= 1.0) { var oldValue = _volume; _volume = value; diff --git a/src/Common/SIUI/Behaviors/MediaController.cs b/src/Common/SIUI/Behaviors/MediaController.cs index bf8dbad8..ae6505d4 100644 --- a/src/Common/SIUI/Behaviors/MediaController.cs +++ b/src/Common/SIUI/Behaviors/MediaController.cs @@ -24,7 +24,7 @@ static MediaController() public static void UpdateVolume(double factor) { - Volume *= factor; + Volume = Math.Min(1.0, Math.Max(0.0, Volume * factor)); _ = waveOutSetVolume(IntPtr.Zero, (uint)(0xFFFF * 2 * Volume)); } @@ -125,9 +125,9 @@ void resumeHandler() mediaElement.Dispatcher.BeginInvoke(mediaElement.Play); } - void volumeChangedHandler(double volume) + void volumeChangedHandler(double factor) { - mediaElement.Volume *= volume; + mediaElement.Volume = Math.Min(1.0, Math.Max(0.0, mediaElement.Volume * factor)); } tableInfo.MediaSeek += seekHandler; diff --git a/src/SICore/SICore/Clients/IConnector.cs b/src/SICore/SICore/Clients/IConnector.cs index 6d5bc664..5f0fba25 100644 --- a/src/SICore/SICore/Clients/IConnector.cs +++ b/src/SICore/SICore/Clients/IConnector.cs @@ -1,4 +1,5 @@ -namespace SICore; + +namespace SICore; public interface IConnector { @@ -12,6 +13,8 @@ public interface IConnector int GameId { get; } + Uri? HostUri { get; } + Task ReconnectToServer(); Task RejoinGame(); @@ -19,4 +22,6 @@ public interface IConnector void SetHost(IViewerClient newHost); void SetGameID(int gameID); + + void SetHostUri(Uri? hostUri); } diff --git a/src/SICore/SICore/Clients/Viewer/Viewer.cs b/src/SICore/SICore/Clients/Viewer/Viewer.cs index a9db27cd..d41f40a0 100644 --- a/src/SICore/SICore/Clients/Viewer/Viewer.cs +++ b/src/SICore/SICore/Clients/Viewer/Viewer.cs @@ -2127,6 +2127,7 @@ await _client.Node.ConnectionsLock.WithLockAsync(() => UpdateDeleteTableCommand(); SendPicture(); + _viewerActions.SendMessage(Messages.Moveable); } private void UpdateDeleteTableCommand() diff --git a/src/SICore/SICore/Messages.cs b/src/SICore/SICore/Messages.cs index ee81305d..33bff4d3 100644 --- a/src/SICore/SICore/Messages.cs +++ b/src/SICore/SICore/Messages.cs @@ -273,6 +273,11 @@ public static class Messages /// public const string Move = "MOVE"; + /// + /// Denotes that the person could be moved during the game. + /// + public const string Moveable = "MOVEABLE"; + /// /// Выбрать следующего игрока /// diff --git a/src/SIGame/SIGame.ViewModel/Settings/UserSettings.cs b/src/SIGame/SIGame.ViewModel/Settings/UserSettings.cs index afb7e73d..e6db95fb 100644 --- a/src/SIGame/SIGame.ViewModel/Settings/UserSettings.cs +++ b/src/SIGame/SIGame.ViewModel/Settings/UserSettings.cs @@ -67,7 +67,7 @@ public bool MainMenuSound private double _volume = 25; /// - /// Громкость звука + /// Sound volume level. /// public double Volume { diff --git a/src/SIGame/SIGame.ViewModel/ViewModel/GameViewModel.cs b/src/SIGame/SIGame.ViewModel/ViewModel/GameViewModel.cs index f7c124b3..7221baa2 100644 --- a/src/SIGame/SIGame.ViewModel/ViewModel/GameViewModel.cs +++ b/src/SIGame/SIGame.ViewModel/ViewModel/GameViewModel.cs @@ -365,7 +365,9 @@ private async void PrintOnlineInformation() try { - Host.AddLog($"{Resources.OnlineGameAddress}: {CommonSettings.NewOnlineGameUrl}{Host.Connector?.GameId}&invite=true"); + var hostUri = Host.Connector?.HostUri; + var hostInfo = hostUri != null ? "&host=" + Uri.EscapeDataString(hostUri.ToString()) : ""; + Host.AddLog($"{Resources.OnlineGameAddress}: {CommonSettings.NewOnlineGameUrl}{Host.Connector?.GameId}{hostInfo}&invite=true"); } catch (Exception exc) { diff --git a/src/SIGame/SIGame.ViewModel/ViewModel/ReconnectManager.cs b/src/SIGame/SIGame.ViewModel/ViewModel/ReconnectManager.cs index f0091245..9d2594b6 100644 --- a/src/SIGame/SIGame.ViewModel/ViewModel/ReconnectManager.cs +++ b/src/SIGame/SIGame.ViewModel/ViewModel/ReconnectManager.cs @@ -30,6 +30,8 @@ internal sealed class ReconnectManager : IConnector public int GameId { get; set; } = -1; + public Uri? HostUri { get; set; } + public ReconnectManager( SecondaryNode server, Client client, @@ -147,4 +149,6 @@ private async Task JoinGameAsync() } public void SetHost(IViewerClient newHost) => _host = newHost; + + public void SetHostUri(Uri? hostUri) => HostUri = hostUri; } diff --git a/src/SIGame/SIGame.ViewModel/ViewModel/SIOnlineViewModel.cs b/src/SIGame/SIGame.ViewModel/ViewModel/SIOnlineViewModel.cs index a5f56044..d9a12c82 100644 --- a/src/SIGame/SIGame.ViewModel/ViewModel/SIOnlineViewModel.cs +++ b/src/SIGame/SIGame.ViewModel/ViewModel/SIOnlineViewModel.cs @@ -1174,6 +1174,7 @@ public override async Task JoinGameCoreAsync( } _host.Connector.SetGameID(gameInfo.GameID); + _host.Connector.SetHostUri(gameInfo.HostUri); } catch (TaskCanceledException exc) { diff --git a/src/SIGame/SIGame/App.xaml.cs b/src/SIGame/SIGame/App.xaml.cs index b91ae234..e28eb677 100644 --- a/src/SIGame/SIGame/App.xaml.cs +++ b/src/SIGame/SIGame/App.xaml.cs @@ -291,10 +291,17 @@ private void SearchForUpdatesFinished(AppInstallerReleaseInfoResponse updateInfo { var updateUri = updateInfo.Installer?.Uri!; - var mainViewModel = (MainViewModel)MainWindow.DataContext; + if (updateInfo.Release != null && updateInfo.Release.IsMandatory) + { + Update_Executed(updateUri); + } + else + { + var mainViewModel = (MainViewModel)MainWindow.DataContext; - mainViewModel.StartMenu.UpdateVersion = updateInfo.Release?.Version!; - mainViewModel.StartMenu.Update = new CustomCommand(obj => Update_Executed(updateUri)); + mainViewModel.StartMenu.UpdateVersion = updateInfo.Release?.Version!; + mainViewModel.StartMenu.Update = new CustomCommand(obj => Update_Executed(updateUri)); + } } private bool _isUpdating = false; diff --git a/src/SIGame/SIGame/SIGame.csproj b/src/SIGame/SIGame/SIGame.csproj index 56203fbc..61690ce4 100644 --- a/src/SIGame/SIGame/SIGame.csproj +++ b/src/SIGame/SIGame/SIGame.csproj @@ -42,7 +42,7 @@ - + diff --git a/test/Common/Notions.Tests/Notions.Tests.csproj b/test/Common/Notions.Tests/Notions.Tests.csproj index 7babb7d6..f2d5b805 100644 --- a/test/Common/Notions.Tests/Notions.Tests.csproj +++ b/test/Common/Notions.Tests/Notions.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Common/SIEngine.Core.Tests/SIEngine.Core.Tests.csproj b/test/Common/SIEngine.Core.Tests/SIEngine.Core.Tests.csproj index d0380738..0ee6e571 100644 --- a/test/Common/SIEngine.Core.Tests/SIEngine.Core.Tests.csproj +++ b/test/Common/SIEngine.Core.Tests/SIEngine.Core.Tests.csproj @@ -16,7 +16,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Common/SIEngine.Tests/SIEngine.Tests.csproj b/test/Common/SIEngine.Tests/SIEngine.Tests.csproj index bae48014..9ad343c9 100644 --- a/test/Common/SIEngine.Tests/SIEngine.Tests.csproj +++ b/test/Common/SIEngine.Tests/SIEngine.Tests.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Common/SIPackages.Tests/SIPackages.Tests.csproj b/test/Common/SIPackages.Tests/SIPackages.Tests.csproj index 067e27ab..690b453a 100644 --- a/test/Common/SIPackages.Tests/SIPackages.Tests.csproj +++ b/test/Common/SIPackages.Tests/SIPackages.Tests.csproj @@ -16,7 +16,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive