2023-03-26 23:23:07 +08:00
|
|
|
|
using System.Text;
|
2023-04-10 16:13:55 +08:00
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
2023-03-26 23:23:07 +08:00
|
|
|
|
|
|
|
|
|
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-04-03 15:55:27 +08:00
|
|
|
|
const string PosFile2DosDir = "PosFile2Dos";
|
|
|
|
|
const string Ver = "0.3.0";
|
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-04-06 08:55:15 +08:00
|
|
|
|
|
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-04-03 15:55:27 +08:00
|
|
|
|
if (!Directory.Exists(loc + PosFile2DosDir))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Templete文件不存在");
|
|
|
|
|
Console.ReadLine();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
|
|
|
|
|
|
|
string[] tempfiles = FileHelper.GetDirFile(loc + PosFile2DosDir);
|
|
|
|
|
int index_temp = 0;
|
|
|
|
|
int errcount_temp = 0;
|
|
|
|
|
for (int i = 0; i < tempfiles.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string FileName = tempfiles[i].Substring(tempfiles[i].LastIndexOf("\\"));
|
|
|
|
|
|
|
|
|
|
if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
index_temp++;
|
|
|
|
|
|
2023-04-06 08:55:15 +08:00
|
|
|
|
//Console.WriteLine($">>>>>>>>>>>>>>读取 第{index_temp}个模板文件 {FileName}<<<<<<<<<<<<<<<<<<<");
|
2023-04-03 15:55:27 +08:00
|
|
|
|
FileHelper.LoadFile(tempfiles[i], out byte[] data);
|
|
|
|
|
if (LoadToSaveTemplate.LoadMapTemplateAreaData(data, FileName, tempfiles[i]))
|
|
|
|
|
{
|
2023-04-06 08:55:15 +08:00
|
|
|
|
//Console.WriteLine($">>>>>>>>>>>>>>成功读取 第{index_temp}个,"+ FileName);
|
2023-04-03 15:55:27 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
errcount_temp++;
|
2023-04-06 08:55:15 +08:00
|
|
|
|
//Console.WriteLine($">>>>>>>>>>>>>>成功失败 第{index_temp}个");
|
2023-04-03 15:55:27 +08:00
|
|
|
|
}
|
2023-04-10 16:13:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//LoadToSaveTemplate.LoadMaxGuti(data);
|
|
|
|
|
|
2023-04-03 15:55:27 +08:00
|
|
|
|
}
|
2023-03-26 23:23:07 +08:00
|
|
|
|
|
2023-04-10 16:13:55 +08:00
|
|
|
|
//int[] gutikeys = LoadToSaveTemplate.DictGutiName.Keys.ToArray();
|
|
|
|
|
//gutikeys = gutikeys.OrderBy(w => w).ToArray();
|
|
|
|
|
//foreach (var k in gutikeys)
|
|
|
|
|
//{
|
|
|
|
|
// Log.HexInfo(k, "任务" + LoadToSaveTemplate.DictGutiName[k] + ",固体值{0}", k);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//int[] gutikeys = LoadToSaveTemplate.DictStarName.Keys.ToArray();
|
|
|
|
|
//gutikeys = gutikeys.OrderBy(w => w).ToArray();
|
|
|
|
|
//foreach (var k in gutikeys)
|
|
|
|
|
//{
|
|
|
|
|
// Log.HexInfo(k, "任务" + LoadToSaveTemplate.DictStarName[k] + ",星{0}", k);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
2023-04-04 18:28:24 +08:00
|
|
|
|
Console.WriteLine($"-----------原数据读取完毕-----------");
|
2023-03-26 23:23:07 +08:00
|
|
|
|
|
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;
|
2023-04-06 08:55:15 +08:00
|
|
|
|
|
|
|
|
|
//LoadToSaveTemplate.GetModeType(targetdata, FileName);
|
|
|
|
|
|
2023-03-23 22:10:57 +08:00
|
|
|
|
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-04-10 16:13:55 +08:00
|
|
|
|
Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个");
|
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-04-06 08:55:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] tempkeys = LoadToSaveTemplate.DictTimeTypeCount.Keys.OrderBy(w => w).ToArray();
|
|
|
|
|
|
|
|
|
|
foreach (var r in tempkeys)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(r + ":" + LoadToSaveTemplate.DictTimeTypeCount[r]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 18:32:30 +08:00
|
|
|
|
Console.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|