|
|
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>CsfStudio - Red Alert 2 String Table Editor</title>
- <style>
- body {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
- line-height: 1.6;
- color: #24292e;
- max-width: 800px;
- margin: 0 auto;
- padding: 20px;
- background-color: #ffffff;
- }
- h1, h2, h3 {
- border-bottom: 1px solid #eaecef;
- padding-bottom: 0.3em;
- margin-top: 24px;
- margin-bottom: 16px;
- font-weight: 600;
- }
- code {
- padding: 0.2em 0.4em;
- margin: 0;
- font-size: 85%;
- background-color: rgba(27,31,35,0.05);
- border-radius: 3px;
- font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
- }
- pre {
- padding: 16px;
- overflow: auto;
- font-size: 85%;
- line-height: 1.45;
- background-color: #f6f8fa;
- border-radius: 6px;
- white-space: pre-wrap;
- }
- pre code {
- background-color: transparent;
- padding: 0;
- font-size: 100%;
- }
- table {
- border-spacing: 0;
- border-collapse: collapse;
- width: 100%;
- margin-top: 0;
- margin-bottom: 16px;
- }
- table th, table td {
- padding: 6px 13px;
- border: 1px solid #dfe2e5;
- }
- table tr {
- background-color: #fff;
- border-top: 1px solid #c6cbd1;
- }
- table tr:nth-child(2n) {
- background-color: #f6f8fa;
- }
- .badge {
- margin-right: 5px;
- }
- .footer {
- margin-top: 40px;
- font-size: 0.9em;
- color: #6a737d;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <h1>CsfStudio - Red Alert 2 String Table Editor</h1>
- <p>
- <img src="https://img.shields.io/badge/.NET%20Framework-4.0-blue.svg" alt=".NET Framework" class="badge">
- <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" class="badge">
- </p>
- <p>CsfStudio 是一个强大的命令行工具,专为处理《红色警戒 2》(Red Alert 2)的字符串表文件(.csf)而设计。它支持多种格式之间的转换、字符串表合并以及差分(减法)操作。</p>
- <h2>功能特性</h2>
- <ul>
- <li>🔄 <strong>双向转换</strong>:支持在 CSF、INI、JSON、YAML 和 LLF 格式之间进行互转</li>
- <li>🧩 <strong>合并操作</strong>:将多个字符串表文件合并为一个</li>
- <li>✂️ <strong>差分操作</strong>:移除在其他文件中已存在的标签(Labels)</li>
- <li>🔠 <strong>编码修复</strong>:修正现有文件中的文本编码问题</li>
- <li>📊 <strong>元数据保留</strong>:保持版本号和语言信息不变</li>
- <li>✅ <strong>验证</strong>:严格的标签名称和格式验证</li>
- <li>⚡ 基于 .NET Framework 4.0 的快速处理</li>
- </ul>
- <h2>支持的格式</h2>
- <h3>CSF 格式 (Command & Conquer String File)</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.csf</code></li>
- <li><strong>类型</strong>:二进制游戏格式</li>
- <li><strong>结构</strong>:</li>
- </ul>
- <pre><code>偏移量 类型 描述
- 0x00 char[4] 头部 " FSC"
- 0x04 int32 版本 (通常为 3)
- 0x08 int32 标签计数
- 0x0C int32 字符串计数
- 0x10 int32 未使用
- 0x14 int32 语言 ID
- ... ... 标签条目:
- char[4] " LBL" 头部
- int32 值计数
- int32 标签名称长度
- char[] 标签名称 (ASCII)
- char[4] " RTS" 或 "WRTS"
- int32 值长度
- byte[] 值 (UTF-16 非编码)</code></pre>
- <h3>INI 格式</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.ini</code></li>
- <li><strong>类型</strong>:基于文本的配置</li>
- <li><strong>结构</strong>:</li>
- </ul>
- <pre><code>[SadPencil.Ra2CsfFile.Ini]
- IniVersion = 2
- CsfVersion = 3
- CsfLang = 0
- [LABEL_NAME]
- Value = 单行值
- ValueLine2 = 附加行</code></pre>
- <h3>JSON 格式</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.json</code></li>
- <li><strong>类型</strong>:标准数据交换格式</li>
- </ul>
- <pre><code>{
- "version": 3,
- "language": 0,
- "labels": {
- "LABEL1": "值 1",
- "LABEL2": "多行\n值"
- }
- }</code></pre>
- <h3>YAML 格式</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.yaml</code> 或 <code>.yml</code></li>
- <li><strong>类型</strong>:人类可读的数据序列化格式</li>
- </ul>
- <pre><code>version: 3
- language: 0
- version_yaml: 1.2
- labels:
- LABEL1: 值 1
- LABEL2: |
- 多行
- 值</code></pre>
- <h3>LLF 格式 (标签语言文件 / Label Language File)</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.llf</code></li>
- <li><strong>类型</strong>:人类可读的编辑格式</li>
- </ul>
- <pre><code># filename
- # version: 3
- # language: 0
- # csf count: 42
- # build time: 2025-08-01 14:30:00
- KEY_SIMPLE: 简单值
- KEY_MULTILINE: >-
- 多行
- 值</code></pre>
- <h3>TXT 格式</h3>
- <ul>
- <li><strong>扩展名</strong>:<code>.txt</code></li>
- <li><strong>类型</strong>:简单文本格式(兼容 CSFTool)</li>
- </ul>
- <pre><code>KEY_SIMPLE|简单值
- KEY_MULTILINE|多行\n值</code></pre>
- <h2>编码修复功能</h2>
- <p>使用 <code>--fix-encoding</code> 修复解释错误的文本编码:</p>
- <pre><code>CsfStudio.exe -i input.csf -o fixed.csf --fix-encoding windows-1251</code></pre>
- <p><strong>支持的编码</strong>:</p>
- <ul>
- <li><code>gb18030</code> (中文)</li>
- <li><code>gb2312</code> (中文)</li>
- <li><code>windows-1251</code> (西里尔文/俄文)</li>
- <li><code>windows-1252</code> (西欧语言)</li>
- <li><code>iso-8859-1</code> (Latin-1)</li>
- <li><code>utf-8</code></li>
- <li><code>unicode</code> (UTF-16)</li>
- </ul>
- <h2>命令行用法</h2>
- <h3>基本语法</h3>
- <pre><code>CsfStudio.exe -i input.ext -o output.ext --to-format
- CsfStudio.exe -i file1.ext,file2.ext -o result.ext --operation</code></pre>
- <h3>操作指令</h3>
- <table>
- <thead>
- <tr>
- <th>命令</th>
- <th>描述</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>-i</code>, <code>--input</code></td>
- <td>输入文件路径(支持多个)</td>
- </tr>
- <tr>
- <td><code>-o</code>, <code>--output</code></td>
- <td>输出文件路径</td>
- </tr>
- <tr>
- <td><code>--to-ini</code></td>
- <td>转换为 INI 格式</td>
- </tr>
- <tr>
- <td><code>--to-csf</code></td>
- <td>转换为 CSF 格式</td>
- </tr>
- <tr>
- <td><code>--to-json</code></td>
- <td>转换为 JSON 格式</td>
- </tr>
- <tr>
- <td><code>--to-yaml</code></td>
- <td>转换为 YAML 格式</td>
- </tr>
- <tr>
- <td><code>--to-llf</code></td>
- <td>转换为 LLF 格式</td>
- </tr>
- <tr>
- <td><code>--to-txt</code></td>
- <td>转换为 TXT 格式</td>
- </tr>
- <tr>
- <td><code>--merge</code></td>
- <td>合并多个文件</td>
- </tr>
- <tr>
- <td><code>--subtract</code></td>
- <td>减去(移除)来自其他文件的标签</td>
- </tr>
- <tr>
- <td><code>--fix-encoding</code></td>
- <td>修复文本编码</td>
- </tr>
- <tr>
- <td><code>-h</code>, <code>--help</code></td>
- <td>显示帮助信息</td>
- </tr>
- </tbody>
- </table>
- <h3>示例</h3>
- <pre><code># 将 CSF 转换为 LLF
- CsfStudio.exe -i stringtable01.csf -o stringtable01.llf --to-llf
- # 将 LLF 转换为 INI
- CsfStudio.exe -i stringtable01.llf -o stringtable01.ini --to-ini
- # 合并两个文件
- CsfStudio.exe -i stringtable01.json,stringtable02.json -o stringtable03.json --merge
- # 差分操作(移除标签)
- CsfStudio.exe -i stringtable01.llf,stringtable02.llf -o stringtable03.llf --subtract
- # 修复编码
- CsfStudio.exe -i stringtable01.csf -o stringtable02.csf --fix-encoding windows-1251</code></pre>
- <p><strong>注意:</strong> <code>--merge</code>(合并)、<code>--subtract</code>(差分)和 <code>--fix-encoding</code>(编码修复)操作仅适用于<strong>相同格式</strong>的文件(即扩展名 <code>.ext</code> 必须一致)!</p>
- <h2>格式对比矩阵</h2>
- <table>
- <thead>
- <tr>
- <th>特性</th>
- <th>CSF</th>
- <th>INI</th>
- <th>JSON</th>
- <th>YAML</th>
- <th>LLF</th>
- <th>TXT</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><strong>人类可读</strong></td>
- <td>❌</td>
- <td>✅</td>
- <td>🟡</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- </tr>
- <tr>
- <td><strong>元数据支持</strong></td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>🟡</td>
- </tr>
- <tr>
- <td><strong>多行值支持</strong></td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- </tr>
- <tr>
- <td><strong>语言支持</strong></td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>🟡</td>
- </tr>
- <tr>
- <td><strong>版本支持</strong></td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>✅</td>
- <td>🟡</td>
- </tr>
- <tr>
- <td><strong>编辑复杂度</strong></td>
- <td>高</td>
- <td>中</td>
- <td>低</td>
- <td>低</td>
- <td>低</td>
- <td>低</td>
- </tr>
- <tr>
- <td><strong>文件大小</strong></td>
- <td>小</td>
- <td>中</td>
- <td>大</td>
- <td>中</td>
- <td>中</td>
- <td>中</td>
- </tr>
- <tr>
- <td><strong>最佳用例</strong></td>
- <td>游戏</td>
- <td>工具</td>
- <td>API</td>
- <td>配置</td>
- <td>编辑</td>
- <td>工具</td>
- </tr>
- </tbody>
- </table>
- <h2>技术规格</h2>
- <ol>
- <li><strong>字符编码</strong>:
- <ul>
- <li>CSF:UTF-16 配合按位取反(bitwise NOT)编码</li>
- <li>文本格式:UTF-8</li>
- <li>特殊处理:Windows-1252 字符 (128-159)</li>
- </ul>
- </li>
- <li><strong>标签规则</strong>:
- <ul>
- <li>仅限 ASCII 字符 32-126</li>
- <li>不区分大小写(存储为小写)</li>
- <li>无明确长度限制</li>
- </ul>
- </li>
- <li><strong>多行处理</strong>:
- <ul>
- <li>所有格式均支持多行值</li>
- <li>换行符统一标准化为 LF (<code>\n</code>)</li>
- <li>LLF 和 YAML 提供最自然的表现形式</li>
- </ul>
- </li>
- <li><strong>元数据保留</strong>:
- <ul>
- <li>在所有转换中保留版本(默认为 3)和语言</li>
- <li>合并操作中使用第一个文件的元数据</li>
- <li>语言 ID:0=英语(美), 1=英语(英), ..., 9=中文, -1=未知</li>
- </ul>
- </li>
- </ol>
- <h2>从源码构建</h2>
- <h3>先决条件</h3>
- <ul>
- <li>.NET Framework 4.0</li>
- <li>Visual Studio 2019 或更高版本</li>
- </ul>
- <h3>步骤</h3>
- <ol>
- <li>克лон仓库:<br><code>git clone https://github.com/YoVVassup/Ra2CsfFile.git</code></li>
- <li>在 Visual Studio 或 Rider (JetBrains) 中打开 <code>SadPencil.Ra2CsfFile.sln</code></li>
- <li>还原 NuGet 包</li>
- <li>构建解决方案</li>
- </ol>
- <h2>许可证</h2>
- <p>MIT License - 详情请参阅 <a href="https://github.com/YoVVassup/Ra2CsfFile/blob/cli/LICENSE">LICENSE</a> 文件</p>
- <h2>致谢</h2>
- <ul>
- <li>Westwood Studios:创造了《命令与征服:红色警戒 2》</li>
- <li>Modding 社区:提供了 CSF 格式的文档</li>
- <li>本项目中使用的开源库的贡献者们</li>
- </ul>
- <h2>备注</h2>
- <p>参考资料:https://modenc.renegadeprojects.com/CSF_File_Format<br>
- 获取 .Net Target Framework SDK 的简便方法:运行 <a href="https://github.com/YoVVassup/Ra2CsfFile/blob/main/Get_.NET_Target_Framework.ps1">Get_.NET_Target_Framework.ps1</a><br>
- 来自 <a href="https://github.com/Starkku/CSFTool">CSFTool</a> 的 TXT 文件格式遵循 <a href="https://github.com/Starkku/CSFTool/blob/master/LICENSE.txt">GPL Version 3</a> 许可。</p>
- <h2>版本历史 SadPencil.Ra2CsfFile (DLL)</h2>
- <pre><code>v2.2.2: 增加了 TXT 序列化支持
- v2.2.1: 增加了 LLF 序列化支持
- v2.2.0: 增加了 JSON 和 YAML 序列化支持
- v2.1.3: 降级以兼容 .NET Framework 4.0
- v2.1.2: 默认禁用 Encoding1252WriteWorkaround;为 SadPencil.Ra2CsfFile 命名空间添加 CLSCompliant 属性
- v2.1.1: 修复了部分标签名无法从 .ini 文件成功加载的问题
- v2.1.0: API 重大变更:更改了 Csf.AddLabel() 的行为,采用“添加并替换”逻辑,以便能加载原始 ra2.csf 文件
- v2.0.2: 移除了 ini 文件中 "=" 符号周围的空格,以修复处理包含 " = " 模式的值时的错误
- v2.0.1: 修复了包含 non-lowercase 标签名的 CSF 文件无法加载的错误
- v2.0.0: 迁移至 .NET Standard 2.0;使用 ini-parser-netstandard 替换了 MadMilkman.Ini 依赖项;添加了 Csf.RemoveLabel() 方法。
- v1.3.1: API 重大变更:Labels.Add 将被 AddLabel 取代;为原始 RA2 字体添加了编码 1252 变通选项;为 CsfFile 添加了克隆构造函数。
- v1.2.2: 现在容忍标签中的空格,库不再会对 RA2 中的字符串表文件报错。
- v1.2.1: 修复了 ini 文件中部分标签未被加载的错误。
- v1.2.0: API 重大变更:CsfFile.Labels 现在每个标签仅存储一个值,因为游戏不使用其余值(如果有);API 变更:废弃 CsfFile.GetCsfLang(),改用 CsfLangHelper.GetCsfLang();废弃 CsfFile.LoadFromIniFile(),改用 CsfFileIniHelper.LoadFromIniFile();废弃 CsfFile.WriteIniFile(),改用 CsfFileIniHelper.WriteIniFile()。
- v1.1.1: 添加了 XML 文档;使用 Release 配置重新发布了库。
- v1.1.0: 修复了多行文本会被错误修剪的错误;现在会检查标签名中的无效字符。</code></pre>
- <h2>发布和源代码</h2>
- <p>
- https://github.com/YoVVassup/Ra2CsfFile/tree/cli
- https://github.com/YoVVassup/Ra2CsfFile/releases/tag/CLI_v.1.0.3
- </p>
- <div class="footer">
- <strong>CsfStudio</strong> - 您处理红色警戒 2 字符串表的强力工具!
- </div>
- </body>
- </html>
复制代码 |
|