|
5 | 5 | using System.Linq;
|
6 | 6 | using Foundation;
|
7 | 7 | using AppKit;
|
| 8 | +using Bluegrams.Application; |
8 | 9 | using LibHac;
|
9 | 10 | using FsTitle = LibHac.Title;
|
10 | 11 | using Title = NX_Game_Info.Common.Title;
|
@@ -69,9 +70,10 @@ public override void WindowDidLoad()
|
69 | 70 |
|
70 | 71 | PortableSettingsProvider.SettingsFileName = Common.USER_SETTINGS;
|
71 | 72 | PortableSettingsProviderBase.SettingsDirectory = Process.path_prefix;
|
72 |
| - PortableSettingsProvider.ApplyProvider(Common.Settings.Default); |
| 73 | + PortableSettingsProvider.ApplyProvider(Common.Settings.Default, Common.History.Default); |
73 | 74 |
|
74 | 75 | Common.Settings.Default.Upgrade();
|
| 76 | + Common.History.Default.Upgrade(); |
75 | 77 |
|
76 | 78 | NSMenuItem debugLog = Window.Menu?.ItemWithTitle("File")?.Submenu.ItemWithTitle("Debug Log");
|
77 | 79 | if (debugLog != null)
|
@@ -104,6 +106,12 @@ public override void WindowDidLoad()
|
104 | 106 | backgroundWorker.DoWork += BackgroundWorker_DoWork;
|
105 | 107 | backgroundWorker.ProgressChanged += BackgroundWorker_ProgressChanged;
|
106 | 108 | backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;
|
| 109 | + |
| 110 | + titles = Process.processHistory(); |
| 111 | + |
| 112 | + tableViewDataSource.Titles.AddRange(titles); |
| 113 | + |
| 114 | + tableView.ReloadData(); |
107 | 115 | }
|
108 | 116 |
|
109 | 117 | [Export("openDocument:")]
|
@@ -268,30 +276,6 @@ public void OpenSDCard(NSMenuItem menuItem)
|
268 | 276 | });
|
269 | 277 | }
|
270 | 278 |
|
271 |
| - [Export("debugLog:")] |
272 |
| - public void DebugLog(NSMenuItem menuItem) |
273 |
| - { |
274 |
| - menuItem.State = menuItem.State == NSCellStateValue.On ? NSCellStateValue.Off : NSCellStateValue.On; |
275 |
| - |
276 |
| - Common.Settings.Default.DebugLog = menuItem.State == NSCellStateValue.On; |
277 |
| - Common.Settings.Default.Save(); |
278 |
| - |
279 |
| - if (Common.Settings.Default.DebugLog) |
280 |
| - { |
281 |
| - try |
282 |
| - { |
283 |
| - Process.log = File.AppendText(Process.path_prefix + Common.LOG_FILE); |
284 |
| - Process.log.AutoFlush = true; |
285 |
| - } |
286 |
| - catch { } |
287 |
| - } |
288 |
| - else |
289 |
| - { |
290 |
| - Process.log?.Close(); |
291 |
| - Process.log = null; |
292 |
| - } |
293 |
| - } |
294 |
| - |
295 | 279 | [Export("export:")]
|
296 | 280 | public void Export(NSMenuItem menuItem)
|
297 | 281 | {
|
@@ -351,11 +335,109 @@ public void Export(NSMenuItem menuItem)
|
351 | 335 | Process.log?.WriteLine("\n{0} of {1} titles exported", index, titles.Count);
|
352 | 336 |
|
353 | 337 | Window.EndSheet(sheet);
|
| 338 | + |
| 339 | + var alert = new NSAlert() |
| 340 | + { |
| 341 | + InformativeText = String.Format("{0} of {1} titles exported", index, titles.Count), |
| 342 | + MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), |
| 343 | + }; |
| 344 | + alert.RunModal(); |
354 | 345 | }
|
355 | 346 | }
|
356 | 347 | });
|
357 | 348 | }
|
358 | 349 |
|
| 350 | + [Export("updateVersionList:")] |
| 351 | + public void UpdateVersionList(NSMenuItem menuItem) |
| 352 | + { |
| 353 | + Window.BeginSheet(sheet, ProgressComplete); |
| 354 | + |
| 355 | + message.StringValue = String.Format("Downloading from {0}", Common.TAGAYA_VERSIONLIST); |
| 356 | + progress.DoubleValue = 0; |
| 357 | + |
| 358 | + if (Process.updateVersionList()) |
| 359 | + { |
| 360 | + uint count = 0; |
| 361 | + |
| 362 | + foreach (var title in titles) |
| 363 | + { |
| 364 | + if (title.type == TitleType.Application || title.type == TitleType.Patch) |
| 365 | + { |
| 366 | + if (Process.versionList.TryGetValue(title.titleIDApplication, out uint version)) |
| 367 | + { |
| 368 | + if (title.latestVersion == unchecked((uint)-1) || version > title.latestVersion) |
| 369 | + { |
| 370 | + title.latestVersion = version; |
| 371 | + count++; |
| 372 | + } |
| 373 | + } |
| 374 | + } |
| 375 | + } |
| 376 | + |
| 377 | + if (count != 0) |
| 378 | + { |
| 379 | + tableView.ReloadData(); |
| 380 | + |
| 381 | + List<List<Title>> history = new List<List<Title>>(); |
| 382 | + history.AddRange(Common.History.Default.Titles); |
| 383 | + history.Add(titles.ToList()); |
| 384 | + |
| 385 | + Common.History.Default.Titles = new List<List<Title>>(history); |
| 386 | + if (Common.History.Default.Titles.Count > Common.HISTORY_SIZE) |
| 387 | + { |
| 388 | + Common.History.Default.Titles.RemoveRange(0, Common.History.Default.Titles.Count - Common.HISTORY_SIZE); |
| 389 | + } |
| 390 | + Common.History.Default.Save(); |
| 391 | + } |
| 392 | + |
| 393 | + Process.log?.WriteLine("\n{0} titles have updated version", count); |
| 394 | + |
| 395 | + Window.EndSheet(sheet); |
| 396 | + |
| 397 | + var alert = new NSAlert() |
| 398 | + { |
| 399 | + InformativeText = String.Format("{0} titles have updated version", count), |
| 400 | + MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), |
| 401 | + }; |
| 402 | + alert.RunModal(); |
| 403 | + } |
| 404 | + else |
| 405 | + { |
| 406 | + Window.EndSheet(sheet); |
| 407 | + |
| 408 | + var alert = new NSAlert() |
| 409 | + { |
| 410 | + InformativeText = "Failed to download version list", |
| 411 | + MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), |
| 412 | + }; |
| 413 | + alert.RunModal(); |
| 414 | + } |
| 415 | + } |
| 416 | + |
| 417 | + [Export("debugLog:")] |
| 418 | + public void DebugLog(NSMenuItem menuItem) |
| 419 | + { |
| 420 | + menuItem.State = menuItem.State == NSCellStateValue.On ? NSCellStateValue.Off : NSCellStateValue.On; |
| 421 | + |
| 422 | + Common.Settings.Default.DebugLog = menuItem.State == NSCellStateValue.On; |
| 423 | + Common.Settings.Default.Save(); |
| 424 | + |
| 425 | + if (Common.Settings.Default.DebugLog) |
| 426 | + { |
| 427 | + try |
| 428 | + { |
| 429 | + Process.log = File.AppendText(Process.path_prefix + Common.LOG_FILE); |
| 430 | + Process.log.AutoFlush = true; |
| 431 | + } |
| 432 | + catch { } |
| 433 | + } |
| 434 | + else |
| 435 | + { |
| 436 | + Process.log?.Close(); |
| 437 | + Process.log = null; |
| 438 | + } |
| 439 | + } |
| 440 | + |
359 | 441 | void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
|
360 | 442 | {
|
361 | 443 | BackgroundWorker worker = sender as BackgroundWorker;
|
@@ -494,6 +576,17 @@ void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventA
|
494 | 576 |
|
495 | 577 | tableView.ReloadData();
|
496 | 578 |
|
| 579 | + List<List<Title>> history = new List<List<Title>>(); |
| 580 | + history.AddRange(Common.History.Default.Titles); |
| 581 | + history.Add(titles.ToList()); |
| 582 | + |
| 583 | + Common.History.Default.Titles = new List<List<Title>>(history); |
| 584 | + if (Common.History.Default.Titles.Count > Common.HISTORY_SIZE) |
| 585 | + { |
| 586 | + Common.History.Default.Titles.RemoveRange(0, Common.History.Default.Titles.Count - Common.HISTORY_SIZE); |
| 587 | + } |
| 588 | + Common.History.Default.Save(); |
| 589 | + |
497 | 590 | Window.EndSheet(sheet);
|
498 | 591 | }
|
499 | 592 | else if (e.Result is string error)
|
|
0 commit comments