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>2017-03-18 22:18:15 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-03-18 22:18:38 +0300
commitcbe2e9d21d3f16b2f9068d4ebfa4b8a8fb8c966b (patch)
tree1c4c9220e1c6455c8ae90b1281c5e05fca116abc
parent84503d3af44292d12e80942b22c9f5d6babd85e6 (diff)
More drag&drop
-rw-r--r--MainForm.cs41
-rw-r--r--Properties/AssemblyInfo.cs4
-rw-r--r--SelectModsForm.cs11
3 files changed, 49 insertions, 7 deletions
diff --git a/MainForm.cs b/MainForm.cs
index f8f1e6fd..2b6ed97f 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -1,6 +1,7 @@
using com.clusterrr.clovershell;
using com.clusterrr.Famicom;
using com.clusterrr.hakchi_gui.Properties;
+using SevenZip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -1051,7 +1052,10 @@ namespace com.clusterrr.hakchi_gui
private void checkedListBoxGames_DragDrop(object sender, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
- if (files.Length == 1) // Maybe it's cover art drag&dropped?
+
+ // Need to determine type of files
+ // Maybe it's cover art?
+ if (files.Length == 1)
{
var ext = Path.GetExtension(files[0]).ToLower();
if (ext == ".jpg" || ext == ".png")
@@ -1060,6 +1064,34 @@ namespace com.clusterrr.hakchi_gui
return;
}
}
+
+ // Maybe it's some mods?
+ bool mods = false;
+ foreach (var file in files)
+ if (Path.GetExtension(file).ToLower() == ".hmod")
+ mods = true;
+ // Maybe it's some mods in single archive?
+ if (files.Length == 1)
+ {
+ var ext = Path.GetExtension(files[0]).ToLower();
+ if (ext == ".7z" || ext == ".zip" || ext == ".rar")
+ {
+ SevenZipExtractor.SetLibraryPath(Path.Combine(BaseDirectory, IntPtr.Size == 8 ? @"tools\7z64.dll" : @"tools\7z.dll"));
+ using (var szExtractor = new SevenZipExtractor(files[0]))
+ {
+ foreach (var f in szExtractor.ArchiveFileNames)
+ if (Path.GetExtension(f).ToLower() == ".hmod")
+ mods = true;
+ }
+ }
+ }
+ if (mods)
+ {
+ installModules(files);
+ return;
+ }
+
+ // All other cases - games or apps
var allFilesToAdd = new List<string>();
foreach (var file in files)
if (Directory.Exists(file))
@@ -1170,7 +1202,12 @@ namespace com.clusterrr.hakchi_gui
MessageBox.Show(Resources.NoKernelYouNeed, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
- var form = new SelectModsForm(false, true);
+ installModules();
+ }
+
+ private void installModules(string[] add = null)
+ {
+ var form = new SelectModsForm(false, true, add);
form.Text = Resources.SelectModsInstall;
if (form.ShowDialog() == DialogResult.OK)
{
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 2bcad38c..1483dc6e 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 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.14.4")]
-[assembly: AssemblyFileVersion("2.0.14.4")]
+[assembly: AssemblyVersion("2.0.14.5")]
+[assembly: AssemblyFileVersion("2.0.14.5")]
diff --git a/SelectModsForm.cs b/SelectModsForm.cs
index 5b12955e..06c45478 100644
--- a/SelectModsForm.cs
+++ b/SelectModsForm.cs
@@ -15,7 +15,7 @@ namespace com.clusterrr.hakchi_gui
private readonly string usermodsDirectory;
private readonly string[] readmeFiles;
- public SelectModsForm(bool loadInstalledMods, bool allowDropMods)
+ public SelectModsForm(bool loadInstalledMods, bool allowDropMods, string[] filesToAdd = null)
{
InitializeComponent();
baseDirectory = MainForm.BaseDirectory;
@@ -52,10 +52,10 @@ namespace com.clusterrr.hakchi_gui
readmeFiles = new string[] { "readme.txt", "readme.md", "readme" };
checkedListBoxMods.Items.Clear();
checkedListBoxMods.Items.AddRange(modsList.ToArray());
+ if (filesToAdd != null) AddMods(filesToAdd);
this.AllowDrop = allowDropMods;
}
-
private void buttonOk_Click(object sender, EventArgs e)
{
if (checkedListBoxMods.CheckedItems.Count > 0)
@@ -148,7 +148,12 @@ namespace com.clusterrr.hakchi_gui
private void SelectModsForm_DragDrop(object sender, DragEventArgs e)
{
- var files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ var files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ AddMods(files);
+ }
+
+ private void AddMods(string[] files)
+ {
var listAddedMods = new List<string>();
foreach (var file in files)
{