Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 01:11:32 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 01:11:32 +0300
commit20d8e10dcd6d4136e10976cb3c8b81ffb512f635 (patch)
treedce85066c5a339f2defe1c8f935ffbc9bb8461c9
parentad2caa99e09a20cd3b09b6f319d0abde6d589343 (diff)
Progressbar while loading games
-rw-r--r--MainForm.Designer.cs2
-rw-r--r--MainForm.cs61
-rw-r--r--Properties/AssemblyInfo.cs4
-rw-r--r--WorkerForm.cs66
4 files changed, 82 insertions, 51 deletions
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 7401aa38..36f696d6 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -1113,6 +1113,7 @@
this.Activated += new System.EventHandler(this.MainForm_Activated);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
+ this.Load += new System.EventHandler(this.MainForm_Load);
this.Shown += new System.EventHandler(this.MainForm_Shown);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.dragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.dragEnter);
@@ -1129,6 +1130,7 @@
this.groupBoxDefaultGames.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
+
}
#endregion
diff --git a/MainForm.cs b/MainForm.cs
index 130677e4..48b74a12 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -158,7 +158,6 @@ namespace com.clusterrr.hakchi_gui
public MainForm()
{
InitializeComponent();
- FormInitialize();
Clovershell = new ClovershellConnection() { AutoReconnect = true, Enabled = true };
Clovershell.OnConnected += Clovershell_OnConnected;
@@ -173,8 +172,11 @@ namespace com.clusterrr.hakchi_gui
FTPToolStripMenuItem_Click(null, null);
if (ConfigIni.TelnetServer)
Clovershell.ShellEnabled = shellToolStripMenuItem.Checked = true;
- alwaysWriteGamesToUSBDriveToolStripMenuItem.Checked = ConfigIni.AlwaysWriteToUSB;
- buttonStart.Text = (Control.ModifierKeys == Keys.Shift) || ConfigIni.AlwaysWriteToUSB ? Resources.SyncronizeUSB : Resources.Syncronize;
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ FormInitialize();
}
void FormInitialize()
@@ -217,6 +219,8 @@ namespace com.clusterrr.hakchi_gui
openFTPInExplorerToolStripMenuItem.Enabled = FTPToolStripMenuItem.Checked = ConfigIni.FtpServer;
openTelnetToolStripMenuItem.Enabled = shellToolStripMenuItem.Checked = ConfigIni.TelnetServer;
+ alwaysWriteGamesToUSBDriveToolStripMenuItem.Checked = ConfigIni.AlwaysWriteToUSB;
+ buttonStart.Text = (Control.ModifierKeys == Keys.Shift) || ConfigIni.AlwaysWriteToUSB ? Resources.SyncronizeUSB : Resources.Syncronize;
}
catch (Exception ex)
{
@@ -276,50 +280,14 @@ namespace com.clusterrr.hakchi_gui
public void LoadGames()
{
- Debug.WriteLine("Loading games");
- var selected = ConfigIni.SelectedGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- Directory.CreateDirectory(NesMiniApplication.GamesDirectory);
- var gameDirs = Directory.GetDirectories(NesMiniApplication.GamesDirectory);
- var games = new List<NesMiniApplication>();
- foreach (var gameDir in gameDirs)
- {
- try
- {
- // Removing empty directories without errors
- try
- {
- var game = NesMiniApplication.FromDirectory(gameDir);
- games.Add(game);
- }
- catch (FileNotFoundException ex) // Remove bad directories if any
- {
- Debug.WriteLine(ex.Message + ex.StackTrace);
- Directory.Delete(gameDir, true);
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message + ex.StackTrace);
- MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
- continue;
- }
- }
-
- var gamesSorted = games.OrderBy(o => o.Name);
- listViewGames.Items.Clear();
- var listViewItem = new ListViewItem(Resources.Default30games);
- listViewItem.Tag = "default";
- listViewItem.Checked = selected.Contains("default");
- listViewGames.Items.Add(listViewItem);
- foreach (var game in gamesSorted)
- {
- listViewItem = new ListViewItem(game.Name);
- listViewItem.Tag = game;
- listViewItem.Checked = selected.Contains(game.Code);
- listViewGames.Items.Add(listViewItem);
- }
+ var workerForm = new WorkerForm(this);
+ workerForm.Text = Resources.LoadingGames;
+ workerForm.Task = WorkerForm.Tasks.LoadGames;
+ workerForm.Start();
RecalculateSelectedGames();
ShowSelected();
+ if (workerForm.DialogResult != DialogResult.OK)
+ Close();
}
public void ShowSelected()
@@ -1242,7 +1210,7 @@ namespace com.clusterrr.hakchi_gui
{
ConfigIni.FcStart = upABStartOnSecondControllerToolStripMenuItem.Checked;
}
-
+
private void enableUSBHostToolStripMenuItem_Click(object sender, EventArgs e)
{
ConfigIni.UsbHost = enableUSBHostToolStripMenuItem.Checked;
@@ -1578,6 +1546,7 @@ namespace com.clusterrr.hakchi_gui
private void timerConnectionCheck_Tick(object sender, EventArgs e)
{
+ if (Clovershell == null) return;
toolStripStatusConnectionIcon.Image = Clovershell.IsOnline ? Resources.green : Resources.red;
toolStripStatusConnectionIcon.ToolTipText = Clovershell.IsOnline ? "Online" : "Offline";
}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index b6ee6612..67a2a29e 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -33,6 +33,6 @@ using System.Resources;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.30.2")]
-[assembly: AssemblyFileVersion("2.0.30.2")]
+[assembly: AssemblyVersion("2.0.30.3")]
+[assembly: AssemblyFileVersion("2.0.30.3")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/WorkerForm.cs b/WorkerForm.cs
index c05e364e..7c796037 100644
--- a/WorkerForm.cs
+++ b/WorkerForm.cs
@@ -18,7 +18,7 @@ namespace com.clusterrr.hakchi_gui
{
public partial class WorkerForm : Form
{
- public enum Tasks { DumpKernel, FlashKernel, DumpNand, FlashNand, DumpNandB, DumpNandC, FlashNandC, Memboot, UploadGames, DownloadCovers, AddGames, CompressGames, DecompressGames, DeleteGames };
+ public enum Tasks { DumpKernel, FlashKernel, DumpNand, FlashNand, DumpNandB, DumpNandC, FlashNandC, Memboot, UploadGames, DownloadCovers, AddGames, LoadGames, CompressGames, DecompressGames, DeleteGames };
public Tasks Task;
//public string UBootDump;
public static string KernelDumpPath
@@ -77,8 +77,6 @@ namespace com.clusterrr.hakchi_gui
readonly string argumentsFilePath;
readonly string transferDirectory;
string tempGamesDirectory;
- //string originalGamesConfigDirectory;
- //string hiddenPath;
Dictionary<MainForm.ConsoleType, string[]> correctKernels = new Dictionary<MainForm.ConsoleType, string[]>();
Dictionary<MainForm.ConsoleType, string[]> correctKeys = new Dictionary<MainForm.ConsoleType, string[]>();
const long maxCompressedsRamfsSize = 30 * 1024 * 1024;
@@ -307,6 +305,9 @@ namespace com.clusterrr.hakchi_gui
case Tasks.AddGames:
AddGames(GamesToAdd);
break;
+ case Tasks.LoadGames:
+ LoadGames();
+ break;
case Tasks.DownloadCovers:
DownloadCovers();
break;
@@ -1643,6 +1644,65 @@ namespace com.clusterrr.hakchi_gui
return apps; // Added games/apps
}
+ void LoadGames()
+ {
+ SetStatus(Resources.PleaseWait);
+ var selected = ConfigIni.SelectedGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+
+ MainForm.Invoke(new Action(delegate ()
+ {
+ MainForm.listViewGames.Items.Clear();
+ }));
+ var games = new List<ListViewItem>();
+ var listViewItem = new ListViewItem(Resources.Default30games);
+ listViewItem.Tag = "default";
+ listViewItem.Checked = selected.Contains("default");
+ games.Add(listViewItem);
+
+ Directory.CreateDirectory(NesMiniApplication.GamesDirectory);
+ var gameDirs = Directory.GetDirectories(NesMiniApplication.GamesDirectory);
+ int progress = 0;
+ var maxProgress = gameDirs.Length;
+ foreach (var gameDir in gameDirs)
+ {
+ try
+ {
+ // Removing empty directories without errors
+ try
+ {
+ var game = NesMiniApplication.FromDirectory(gameDir);
+ listViewItem = new ListViewItem(game.Name);
+ listViewItem.Tag = game;
+ listViewItem.Checked = selected.Contains(game.Code);
+ games.Add(listViewItem);
+ }
+ catch (FileNotFoundException ex) // Remove bad directories if any
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ Directory.Delete(gameDir, true);
+ }
+ }
+ catch (ThreadAbortException) { }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ MainForm.Invoke(new Action(delegate ()
+ {
+ MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }));
+ continue;
+ }
+ progress++;
+ if (progress % 30 == 0)
+ SetProgress(progress, maxProgress);
+ }
+ SetProgress(maxProgress, maxProgress);
+ MainForm.Invoke(new Action(delegate ()
+ {
+ MainForm.listViewGames.Items.AddRange(games.ToArray());
+ }));
+ }
+
void DownloadCovers()
{
if (Games == null) return;