Skip to content

Commit

Permalink
Merge branch 'develop_β'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhiel committed Sep 10, 2022
2 parents 88b2390 + 3c45a91 commit 60385f0
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 40 deletions.
4 changes: 3 additions & 1 deletion MHRiseModManager/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
xmlns:local="clr-namespace:MHRiseModManager"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
StartupUri="Views/MainWindow.xaml"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Startup="Application_Startup"
Exit="Application_Exit">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
24 changes: 24 additions & 0 deletions MHRiseModManager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Threading;

namespace MHRiseModManager
{
Expand All @@ -13,5 +14,28 @@ namespace MHRiseModManager
/// </summary>
public partial class App : Application
{
private Mutex _mutex = new Mutex(false, "MHRiseModManager");

private void Application_Startup(object sender, StartupEventArgs e)
{
if(_mutex.WaitOne(0, false))
{
return;
}

MessageBox.Show("二重起動できません", "情報", MessageBoxButton.OK, MessageBoxImage.Information);
_mutex.Close();
_mutex = null;
Shutdown();
}

private void Application_Exit(object sender, ExitEventArgs e)
{
if(_mutex != null)
{
_mutex.ReleaseMutex();
_mutex.Close();
}
}
}
}
10 changes: 3 additions & 7 deletions MHRiseModManager/Models/Category.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace MHRiseModManager.Models
{
public enum Category : int
{
REFramework = 0,
Lua = 1,
その他 = 2
Pak = 2,
その他 = 3
}
}
31 changes: 27 additions & 4 deletions MHRiseModManager/Models/ModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public string ExtractArchivePath
File.WriteAllBytes(archiveFile, ModFileBinary);
}

if(archiveFile.EndsWith("pak"))
{
return archiveFile;
}

var targetDir = Path.Combine(Path.GetDirectoryName(archiveFile), Path.GetFileNameWithoutExtension(archiveFile));

if (!Directory.Exists(targetDir))
Expand Down Expand Up @@ -154,6 +159,11 @@ public Category GetNewCategory()
category = Category.REFramework;
break;
}
if (item.Name.EndsWith("pak"))
{
category = Category.Pak;
break;
}
}

return category;
Expand Down Expand Up @@ -240,15 +250,28 @@ private IEnumerable<ModFileTree> GetElements(ModFileTree node)

private List<ModFileTree> Search(string path)
{
var chiled = new List<ModFileTree>();
var child = new List<ModFileTree>();

if(path.EndsWith("pak"))
{
FileInfo f = new FileInfo(path);
ModFileTree tree = new ModFileTree();
tree.Name = f.Name;
tree.Path = f.Name;
tree.IsFile = true;
child.Add(tree);
return child;
}


var di = new DirectoryInfo(path);
foreach (var f in di.GetFiles())
{
ModFileTree tree = new ModFileTree();
tree.Name = f.Name;
tree.Path = f.FullName.Substring(ExtractArchivePath.Length + 1);
tree.IsFile = true;
chiled.Add(tree);
child.Add(tree);
}

foreach (var d in di.GetDirectories())
Expand All @@ -258,10 +281,10 @@ private List<ModFileTree> Search(string path)
tree.Path = d.FullName.Substring(ExtractArchivePath.Length + 1);
tree.Child = Search(d.FullName);
tree.IsFile = false;
chiled.Add(tree);
child.Add(tree);
}

return chiled;
return child;
}


Expand Down
27 changes: 27 additions & 0 deletions MHRiseModManager/Models/ModListManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,32 @@ public ModInfo UpdateLatestVersion(int id, string latestversion)

return SelectAll().Where(x => x.Id == id).First();
}
public void UpdateArchivePath(int id, string archivefilepath)
{
// コネクションを開いてテーブル作成して閉じる
using (var con = new SQLiteConnection($"Data Source={Settings.Default.DataBaseFileName}"))
{
con.Open();
string sql = $"update modinfo set archivefilepath = '{archivefilepath}' where id = {id}";
var com = new SQLiteCommand(sql, con);
com.ExecuteNonQuery();

con.Close();
}

}

public void UpdateDetailPath(int id, string path)
{
using (var con = new SQLiteConnection($"Data Source={Settings.Default.DataBaseFileName}"))
{
con.Open();
string sql = $"update modinfodetail set path = '{path}' where id = {id}";
var com = new SQLiteCommand(sql, con);
com.ExecuteNonQuery();

con.Close();
}
}
}
}
16 changes: 15 additions & 1 deletion MHRiseModManager/ViewModels/InstallDialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,27 @@ namespace MHRiseModManager.ViewModels
public class InstallDialogViewModel
{
public ReactiveCommand CloseWindow { get; } = new ReactiveCommand();
public ReactiveCommand CloseWindowCancel { get; } = new ReactiveCommand();
public ReactiveProperty<string> Name { get; } = new ReactiveProperty<string>();
public ReactiveProperty<string> URL { get; } = new ReactiveProperty<string>();
public ReactiveProperty<string> Version { get; } = new ReactiveProperty<string>();
public ReactiveProperty<string> Memo { get; } = new ReactiveProperty<string>();
public ReactiveProperty<bool> PakMode { get; } = new ReactiveProperty<bool>(false);
public ReactiveProperty<string> PakFileName { get; } = new ReactiveProperty<string>();
public bool Result { get; set; }

public InstallDialogViewModel()
{
CloseWindow.Subscribe(x => ((System.Windows.Window)x).Close());
CloseWindow.Subscribe(x =>
{
Result = true;
((System.Windows.Window)x).Close();
});
CloseWindowCancel.Subscribe(x =>
{
Result = false;
((System.Windows.Window)x).Close();
});
}
}
}
Loading

0 comments on commit 60385f0

Please sign in to comment.