2023-03-26 23:23:07 +08:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace MHFQuestToMH2Dos
|
2023-03-23 18:32:30 +08:00
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
static string loc = Path.GetDirectoryName(AppContext.BaseDirectory) + "\\";
|
|
|
|
|
|
|
|
|
|
const string InDir = "Input";
|
|
|
|
|
const string OutDir = "Out";
|
2023-03-27 11:10:13 +08:00
|
|
|
|
const string Ver = "0.2.1";
|
2023-03-23 18:32:30 +08:00
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2023-03-27 11:10:13 +08:00
|
|
|
|
string title = $"MHFQuestToMH2Dos Ver.{Ver} By 皓月云 axibug.com";
|
|
|
|
|
Console.Title = title;
|
|
|
|
|
Console.WriteLine(title);
|
|
|
|
|
|
2023-03-23 18:32:30 +08:00
|
|
|
|
if (!Directory.Exists(loc + InDir))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Input文件不存在");
|
|
|
|
|
Console.ReadLine();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(loc + OutDir))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Out文件不存在");
|
|
|
|
|
Console.ReadLine();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-26 23:23:07 +08:00
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
|
|
|
|
|
|
|
|
2023-03-23 18:32:30 +08:00
|
|
|
|
string[] files = FileHelper.GetDirFile(loc + InDir);
|
2023-03-27 11:10:13 +08:00
|
|
|
|
Console.WriteLine($"共{files.Length}个文件,是否处理? (y/n)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string yn = Console.ReadLine();
|
|
|
|
|
if (yn.ToLower() != "y")
|
|
|
|
|
return;
|
2023-03-23 18:32:30 +08:00
|
|
|
|
|
|
|
|
|
int index= 0;
|
2023-03-23 22:10:57 +08:00
|
|
|
|
int errcount = 0;
|
2023-03-23 18:32:30 +08:00
|
|
|
|
for(int i = 0;i < files.Length;i++)
|
|
|
|
|
{
|
2023-03-23 22:10:57 +08:00
|
|
|
|
string FileName = files[i].Substring(files[i].LastIndexOf("\\"));
|
2023-03-26 23:23:07 +08:00
|
|
|
|
|
2023-03-23 18:32:30 +08:00
|
|
|
|
if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin"))
|
|
|
|
|
{
|
2023-03-24 09:13:59 +08:00
|
|
|
|
continue;
|
2023-03-23 18:32:30 +08:00
|
|
|
|
}
|
|
|
|
|
index++;
|
2023-03-27 11:10:13 +08:00
|
|
|
|
|
|
|
|
|
Console.WriteLine($">>>>>>>>>>>>>>开始处理 第{index}个文件 {FileName}<<<<<<<<<<<<<<<<<<<");
|
2023-03-23 18:32:30 +08:00
|
|
|
|
FileHelper.LoadFile(files[i], out byte[] data);
|
2023-03-24 18:21:24 +08:00
|
|
|
|
if (ModifyQuest.ModifyQuset(data, out byte[] targetdata))
|
2023-03-23 22:10:57 +08:00
|
|
|
|
{
|
2023-03-24 09:13:59 +08:00
|
|
|
|
string newfileName = FileName + "_fix";
|
2023-03-23 22:10:57 +08:00
|
|
|
|
string outstring = loc + OutDir + "\\" + newfileName;
|
|
|
|
|
FileHelper.SaveFile(outstring, targetdata);
|
2023-03-27 11:10:13 +08:00
|
|
|
|
Console.WriteLine($">>>>>>>>>>>>>>成功处理 第{index}个:{outstring}");
|
2023-03-23 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
errcount++;
|
2023-03-27 11:10:13 +08:00
|
|
|
|
Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个: 输出到{files[i]}");
|
2023-03-23 22:10:57 +08:00
|
|
|
|
}
|
2023-03-23 18:32:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-26 23:23:07 +08:00
|
|
|
|
Console.WriteLine($"已处理{files.Length}个文件,其中{errcount}个失败");
|
2023-03-23 18:32:30 +08:00
|
|
|
|
Console.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|