MHFQuestToMH2Dos/Program.cs

65 lines
2.2 KiB
C#
Raw Normal View History

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";
static void Main(string[] args)
{
Console.Title = "MHFQuestToMH2Dos By 皓月云 axibug.com";
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;
}
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
2023-03-23 18:32:30 +08:00
string[] files = FileHelper.GetDirFile(loc + InDir);
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("\\"));
Console.WriteLine($">>>>>>>>>>>>>>开始处理{FileName}<<<<<<<<<<<<<<<<<<<");
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++;
FileHelper.LoadFile(files[i], out byte[] data);
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);
Console.WriteLine($">>>>>>>>>>>>>>成功已处理 第{index}个:{outstring}");
2023-03-23 22:10:57 +08:00
}
else
{
errcount++;
Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个:{files[i]}");
2023-03-23 22:10:57 +08:00
}
2023-03-23 18:32:30 +08:00
}
Console.WriteLine($"已处理{files.Length}个文件,其中{errcount}个失败");
2023-03-23 18:32:30 +08:00
Console.ReadLine();
}
}
}