|
3 | 3 | using CollapseLauncher.Helper.Metadata; |
4 | 4 | using CollapseLauncher.Statics; |
5 | 5 | using Hi3Helper; |
| 6 | +using Hi3Helper.Shared.ClassStruct; |
6 | 7 | using Microsoft.UI.Xaml; |
7 | 8 | using System; |
8 | 9 | using System.Collections.Generic; |
| 10 | +using System.Text; |
| 11 | +using System.Threading.Tasks; |
9 | 12 | using static Hi3Helper.Shared.Region.LauncherConfig; |
10 | 13 | // ReSharper disable StringLiteralTypo |
11 | 14 | // ReSharper disable IdentifierTypo |
@@ -223,7 +226,7 @@ internal bool IsPlaytimeSyncDb |
223 | 226 | CurrentGameProperty.GameSettings.SettingsCollapseMisc.IsSyncPlaytimeToDatabase = value; |
224 | 227 | CurrentGameProperty?.GameSettings?.SaveBaseSettings(); |
225 | 228 | SyncDbPlaytimeBtn.IsEnabled = value; |
226 | | - |
| 229 | + |
227 | 230 | // Run DbSync if toggle is changed to enable |
228 | 231 | if (value) CurrentGameProperty?.GamePlaytime?.CheckDb(); |
229 | 232 | } |
@@ -295,5 +298,90 @@ internal VerticalAlignment CurrentBannerIconVerticalAlign |
295 | 298 | WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignVertical : |
296 | 299 | WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignVerticalHYP; |
297 | 300 | } |
| 301 | + |
| 302 | + internal string? StartTooltipText |
| 303 | + { |
| 304 | + get |
| 305 | + { |
| 306 | + if (CurrentGameProperty.GameVersion == null) |
| 307 | + return null; |
| 308 | + |
| 309 | + var installed = CurrentGameProperty.GameVersion.GetGameExistingVersion(); |
| 310 | + if (installed is null) |
| 311 | + return null; |
| 312 | + return string.Format(Locale.Lang._HomePage.StartGameTooltip, installed); |
| 313 | + } |
| 314 | + } |
| 315 | + |
| 316 | + internal string? InstallUpdateTooltipText |
| 317 | + { |
| 318 | + get |
| 319 | + { |
| 320 | + if (CurrentGameProperty.GameVersion == null) |
| 321 | + return null; |
| 322 | + |
| 323 | + var state = Task.Run(async () => await CurrentGameProperty.GameVersion.GetGameState()).GetAwaiter().GetResult(); |
| 324 | + switch (state) |
| 325 | + { |
| 326 | + case GameInstallStateEnum.NotInstalled: |
| 327 | + { |
| 328 | + var remote = CurrentGameProperty.GameVersion.GetGameVersionApi(); |
| 329 | + return string.Format(Locale.Lang._HomePage.InstallGameTooltip, remote); |
| 330 | + } |
| 331 | + case GameInstallStateEnum.NeedsUpdate: |
| 332 | + { |
| 333 | + var installed = CurrentGameProperty.GameVersion.GetGameExistingVersion(); |
| 334 | + var remote = CurrentGameProperty.GameVersion.GetGameVersionApi(); |
| 335 | + if (remote is null || installed == remote) |
| 336 | + return null; |
| 337 | + |
| 338 | + if (installed is null) |
| 339 | + return string.Format(Locale.Lang._HomePage.InstallGameTooltip, remote); |
| 340 | + |
| 341 | + return string.Format(Locale.Lang._HomePage.UpdateGameTooltip, installed, remote); |
| 342 | + } |
| 343 | + case GameInstallStateEnum.InstalledHavePlugin: |
| 344 | + { |
| 345 | + var tooltip = new StringBuilder(); |
| 346 | + |
| 347 | + // SDK |
| 348 | + { |
| 349 | + var installed = CurrentGameProperty.GameVersion.GetSdkVersionInstalled(); |
| 350 | + var remote = CurrentGameProperty.GameVersion.GetSdkVersionApi(); |
| 351 | + if (remote is not null && installed != remote) |
| 352 | + { |
| 353 | + if (installed is null) |
| 354 | + tooltip.Append(string.Format(Locale.Lang._HomePage.InstallSdkTooltip, remote)); |
| 355 | + else |
| 356 | + tooltip.Append(string.Format(Locale.Lang._HomePage.UpdateSdkTooltip, installed, remote)); |
| 357 | + } |
| 358 | + } |
| 359 | + |
| 360 | + // Plugin |
| 361 | + { |
| 362 | + var installedDict = CurrentGameProperty.GameVersion.GetPluginVersionsInstalled(); |
| 363 | + var mismatchList = CurrentGameProperty.GameVersion.GetMismatchPlugin(); |
| 364 | + foreach (var mismatch in mismatchList) |
| 365 | + { |
| 366 | + if (tooltip.Length != 0) |
| 367 | + tooltip.Append('\n'); |
| 368 | + |
| 369 | + var remote = mismatch.Version; |
| 370 | + if (!installedDict.TryGetValue(mismatch.PluginId!, out var installed)) |
| 371 | + tooltip.Append(string.Format(Locale.Lang._HomePage.InstallPluginTooltip, mismatch.PluginId, remote)); |
| 372 | + else |
| 373 | + tooltip.Append(string.Format(Locale.Lang._HomePage.UpdatePluginTooltip, mismatch.PluginId, installed, remote)); |
| 374 | + } |
| 375 | + } |
| 376 | + |
| 377 | + if (tooltip.Length == 0) |
| 378 | + return null; |
| 379 | + return tooltip.ToString(); |
| 380 | + } |
| 381 | + default: |
| 382 | + return null; |
| 383 | + } |
| 384 | + } |
| 385 | + } |
298 | 386 | } |
299 | 387 | } |
0 commit comments