@@ -10,9 +10,6 @@ BOOL GetFileVersion()
1010 DWORD dwVerSize;
1111 DWORD dwHandle;
1212 TCHAR szFullPath[MAX_PATH];
13- // DWORD dwVerInfoSize = 0;
14- // DWORD dwVerHnd;
15- // VS_FIXEDFILEINFO * pFileInfo;
1613
1714 GetModuleFileName (NULL , szFullPath, MAX_PATH);
1815 // printf("信息:");
@@ -39,41 +36,108 @@ BOOL GetFileVersion()
3936 return FALSE ;
4037}
4138
42- // CharAdd CharADD;
4339SEL WCharAdd;
44- // char Ver[] = "[SpaceEngine 汉化生成器 1.0.0.4]";
40+ HANDLE hHandle;
41+ void Color (WORD C) {
42+ SetConsoleTextAttribute (hHandle,C);
43+ }
44+ class GetOff {
45+
46+ public:
47+ GetOff (std::string Path, std::string O, std::string F) {
48+ std::ifstream IF (Path);
49+ std::string L;
50+ char Line[256 ],*str=new char [1024 ];
51+ int T = 0 ;
52+ std::ofstream OF (O);
53+ if (F.find (" %s" )!=std::string::npos)T=1 ;
54+ else if (F.find (" %d" ) != std::string::npos|| F.find (" %X" ) != std::string::npos)T = 2 ;
55+ while (IF.getline (Line, 256 )) {
56+ L = Line;
57+ char *P = 0 ,*P2=0 ;
58+ if ((P = strstr (Line, " <Address>" )) != 0 ) {
59+ P += 9 ;
60+ if ((P2 = strstr (Line, " </Address>" )) != 0 )*P2 = 0 ;
61+
62+
63+ if (T == 2 ) {
64+ if ((P = strstr (Line, " +" )) != 0 ) { P += 1 ;
65+ snprintf (str, 1024 , F.c_str (), strtol (P,0 ,16 ));
66+ printf (" %s\n " , str);
67+ OF << str << std::endl;
68+ }
69+
70+ }
71+ else {
72+ snprintf (str, 1024 , F.c_str (), P);
73+ printf (" %s\n " , str);
74+ OF << str << std::endl;
75+ }
76+
77+
78+ }
79+
80+ }
81+ delete[] str;
82+ };
83+
84+ };
4585int main (int argc, char *argv[])
4686{
47- HANDLE hHandle = GetStdHandle (STD_OUTPUT_HANDLE);
48- SetConsoleTextAttribute (hHandle, 0xB );
49- printf (" \n [SpaceEngine 汉化生成器 1.0.0.4]\n\n " );
50- SetConsoleTextAttribute (hHandle, 0x7 );
51- if (argc != 3 ) {
52- SetConsoleTextAttribute (hHandle, 0xA );
53- printf (" \n 用法: %s [输入文件] [输出文件]\n " , argv[0 ]);
54- SetConsoleTextAttribute (hHandle, 0xC );
55- printf (" \n 输入文件必须使用Unicode字符集,现在存在FontConfig\\ FontTexture字符的行会被忽略.\n " );
56- SetConsoleTextAttribute (hHandle, 0x7 );
57- printf (" \n 程序目录下需要Config.ini字符配置文件 若不存在则自动创建\n 翻译一行一个\n 要复制的话最好用UE的[用户剪切板(ctrl+数字)]去复制,系统剪切板会破坏内容\n 即便如此,有时一些内容仍然会被破坏,请自行检查.重点检查换行是否正常(一般是被插入0A)\n 错误的字节用16进制编辑删除.\n \n 示例" );
58- SetConsoleTextAttribute (hHandle, 0xB );
59- printf (" \n 命令: %s gui.txt chs-gui.cfg\n " , argv[0 ]);
60- SetConsoleTextAttribute (hHandle, 0xE );
61- printf (" 文件内容: \" SYSTEM\" \" 系统\" \n " );
62- SetConsoleTextAttribute (hHandle, 0x7 );
63- }
64- else {
87+ hHandle = GetStdHandle (STD_OUTPUT_HANDLE);
88+ Color (0xB );
89+ printf (" \n [SpaceEngine 汉化生成器 1.0.0.7]\n\n " );
90+ Color (0x7 );
91+ if (argc == 3 ) {
6592 WCharAdd.WMainInit ();
6693 TEST (argv[1 ], argv[2 ]);
94+ }
95+ else if (argc==5 ) {
96+ ReadAdd RA (argv[1 ], argv[2 ], argv[3 ],atoi (argv[4 ]));
97+
98+
99+ }
100+ else if (argc==4 ) {
101+ GetOff GF (argv[1 ], argv[2 ], argv[3 ]);
67102
103+ }
104+ else {
105+
106+ Color (0XA );
107+ printf (" \n 用法: %s [输入文件] [输出文件]\n 读取SE内存: %s [偏移列表文件] [输出文件] [输出格式] [PID] \n CE XML格式地址析出 %s [输入文件] [输出文件] [输出格式]" , argv[0 ], argv[0 ], argv[0 ]);
108+ Color (0xC );
109+ printf (" \n [翻译模式] 输入文件必须使用Unicode编码,现在存在FontConfig\\ FontTexture字符的行会被忽略.\n " );
110+ Color (0x7 );
111+ printf (" \n 程序目录下需要Config.ini字符配置文件 若不存在则自动创建\n 翻译一行一个\n 要复制的话最好用UE的[用户剪切板(ctrl+数字)]去复制,系统剪切板会破坏内容\n 即便如此,有时一些内容仍然会被破坏,请自行检查.重点检查换行是否正常(一般是被插入0A)\n 错误的字节用16进制编辑删除.\n \n 示例" );
112+ Color (0xB );
113+ printf (" \n 命令: %s gui.txt chs-gui.cfg\n " , argv[0 ]);
114+ Color (0xE );
115+ printf (" 输入文件内容: \" SYSTEM\" \" 系统\" \n " );
116+ Color (0x7 );
117+ printf (" \n [读取内存模式] 根据文件内偏移读取内存并输出到文件 格式化需要两个格式化参数 %%X或%%d 和%%s 详参printf函数输出格式" );
118+ Color (0xC );
119+ printf (" \n 若仍不了解请使用示例格式 0x00 %%X = %%s\n 输入文件内必须是偏移值而不是内存地址 错误的偏移值可能会导致程序爆炸 " );
120+ Color (0x7 );
121+ printf (" \n 用CE搜个绿色基址然后点开看到后面的XXX.exe + ABCD... 的 + XXX部分就是偏移了\n PID是进程ID 打开任务管理器看" );
122+ Color (0xB );
123+ printf (" \n 命令: %s offset.txt out.txt 0x00%%X=%%s \n " , argv[0 ]);
124+ Color (0xE );
125+ printf (" 输入文件内容: 0x0012345 \n " );
126+ Color (0x7 );
127+ printf (" \n [CE XML地址析出] 从CE内复制的地址是XML格式的 无法直接进行读取,故添加此功能 用于配合[读取内存模式]\n 输出格式同上 %%s输出 程序+偏移 %%d或%%X 只输出偏移" );
128+ Color (0xB );
129+ printf (" \n 命令: %s ce.txt ceout.txt %%s\n %s ce.txt ceout.txt %%d\n %s ce.txt ceout.txt %%X\n " , argv[0 ], argv[0 ], argv[0 ]);
130+ Color (0x7 );
131+
68132 }
69133 setlocale (LC_CTYPE, " .936" );
70134
71135 std::vector<STA> A = WCharAdd.No ;
72136 DWORD Err = 0 ;
73137 if (!A.empty ()) {
74- SetConsoleTextAttribute (hHandle, 0xE );
138+ Color ( 0xE );
75139 printf (" 以下字符未配置 " );
76- SetConsoleTextAttribute (hHandle, 0x7 );
140+ Color ( 0x7 );
77141 printf (" 输出格式 [字符:频度]\n " );
78142 for (unsigned int i = 0 ;i < A.size ();i++) {
79143 printf (" %s:%d " , A[i].str , WCharAdd.Wstr [A[i].ID [0 ]].Size );
@@ -82,17 +146,17 @@ int main(int argc, char *argv[])
82146 else if ((Err = GetLastError ()) != 0 ) {
83147 char MsgBuf[256 ];
84148 FormatMessageA ( FORMAT_MESSAGE_FROM_SYSTEM , NULL , Err, 0 ,MsgBuf,256 , NULL );
85- SetConsoleTextAttribute (hHandle, 0xC );
149+ Color ( 0xC );
86150 printf (" 错误:%d" , Err);
87- SetConsoleTextAttribute (hHandle, 0x7 );
151+ Color ( 0x7 );
88152 printf (" 描述:%s\n " , MsgBuf);
89153
90154 }
91155
92156 else {
93- SetConsoleTextAttribute (hHandle, 0xA );
157+ Color ( 0xA );
94158 printf (" \n 完成" );
95- SetConsoleTextAttribute (hHandle, 0x7 );
159+ Color ( 0x7 );
96160 };
97161
98162 printf (" \n " );
@@ -103,7 +167,8 @@ int main(int argc, char *argv[])
103167
104168 }
105169
106- SetConsoleTextAttribute (hHandle, 0x7 );
170+ Color (0x7 );
171+ CloseHandle (hHandle);
107172 return 0 ;
108173}
109174
0 commit comments