forked from Sin365/MHFQuestToMH2Dos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
143 lines (113 loc) · 5 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System.Text;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace MHFQuestToMH2Dos
{
internal class Program
{
static string loc = Path.GetDirectoryName(AppContext.BaseDirectory) + "\\";
const string InDir = "Input";
const string OutDir = "Out";
const string PosFile2DosDir = "PosFile2Dos";
const string Ver = "0.3.2";
static void Main(string[] args)
{
string title = $"MHFQuestToMH2Dos Ver.{Ver} By 皓月云 axibug.com";
Console.Title = title;
Console.WriteLine(title);
if (!Directory.Exists(loc + InDir))
{
Console.WriteLine("Input文件不存在");
Console.ReadLine();
return;
}
if (!Directory.Exists(loc + OutDir))
{
Console.WriteLine("Out文件不存在");
Console.ReadLine();
return;
}
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++;
//Console.WriteLine($">>>>>>>>>>>>>>读取 第{index_temp}个模板文件 {FileName}<<<<<<<<<<<<<<<<<<<");
FileHelper.LoadFile(tempfiles[i], out byte[] data);
if (LoadToSaveTemplate.LoadMapTemplateAreaData(data, FileName, tempfiles[i]))
{
//Console.WriteLine($">>>>>>>>>>>>>>成功读取 第{index_temp}个,"+ FileName);
}
else
{
errcount_temp++;
//Console.WriteLine($">>>>>>>>>>>>>>成功失败 第{index_temp}个");
}
//LoadToSaveTemplate.LoadMaxGuti(data);
}
//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);
//}
Console.WriteLine($"-----------原数据读取完毕-----------");
string[] files = FileHelper.GetDirFile(loc + InDir);
Console.WriteLine($"共{files.Length}个文件,是否处理? (y/n)");
string yn = Console.ReadLine();
if (yn.ToLower() != "y")
return;
int index= 0;
int errcount = 0;
for(int i = 0;i < files.Length;i++)
{
string FileName = files[i].Substring(files[i].LastIndexOf("\\"));
if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin"))
{
continue;
}
index++;
Console.WriteLine($">>>>>>>>>>>>>>开始处理 第{index}个文件 {FileName}<<<<<<<<<<<<<<<<<<<");
FileHelper.LoadFile(files[i], out byte[] data);
if (ModifyQuest.ModifyQuset(data, out byte[] targetdata, out int targetQuestID))
{
string newfileName = FileName + "_fix_toid_"+ targetQuestID;
string outstring = loc + OutDir + "\\" + newfileName;
//LoadToSaveTemplate.GetModeType(targetdata, FileName);
FileHelper.SaveFile(outstring, targetdata);
Console.WriteLine($">>>>>>>>>>>>>>成功处理 第{index}个:{outstring}");
}
else
{
errcount++;
Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个");
}
}
Console.WriteLine($"已处理{files.Length}个文件,其中{errcount}个失败");
string[] tempkeys = LoadToSaveTemplate.DictTimeTypeCount.Keys.OrderBy(w => w).ToArray();
foreach (var r in tempkeys)
{
Console.WriteLine(r + ":" + LoadToSaveTemplate.DictTimeTypeCount[r]);
}
Console.ReadLine();
}
}
}