From a8dbbfd7884886c43f6fd1800120952485ac131f Mon Sep 17 00:00:00 2001 From: HITIKM Date: Mon, 22 Jun 2020 00:54:10 +0800 Subject: [PATCH] 1.42 beta --- AssFile.c | 44 +++++++++++++++++++++++--------------------- Define/CLIDef.h | 2 +- README.md | 32 ++++++++++++-------------------- XmlFile.c | 3 ++- 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/AssFile.c b/AssFile.c index 60f785b..b2fae74 100644 --- a/AssFile.c +++ b/AssFile.c @@ -1236,7 +1236,8 @@ int writeAssDanmakuPart(FILE *opF, DANMAKU *now = NULL; int cnt; - char EscapedText[MAX_TEXT_LENGTH]; + char escapedText[MAX_TEXT_LENGTH]; + char tempText[MAX_TEXT_LENGTH]; DANMAKU *signPtr = head, *scanPtr = head; @@ -1383,11 +1384,19 @@ int writeAssDanmakuPart(FILE *opF, textLen = getStrLen((unsigned char *)(now -> text), fontSize, now -> fontSize, fontName); textHei = getStrHei((unsigned char *)(now -> text), fontSize, now -> fontSize, fontName); - /*特殊字符替换 特殊弹幕单独处理*/ - if (abs(now -> type) != 5) + /*特殊字符替换*/ + if (*(now->text) == ' ') { - strrpl(now -> text, EscapedText, " ", "\\h", MAX_TEXT_LENGTH); + strcpy(escapedText, "\\h"); + strcat_s(escapedText, MAX_TEXT_LENGTH, now->text); } + else + { + strSafeCopy(escapedText, now->text, MAX_TEXT_LENGTH); + } + + strrpl(escapedText, tempText, "\n ", "\\N\\h", MAX_TEXT_LENGTH); + strrpl(tempText, escapedText, "\n", "\\N", MAX_TEXT_LENGTH); if(now -> type == 1 || now -> type == -1)/*右左弹幕*/ { @@ -1440,7 +1449,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "R2L,,0000,0000,0000,,{\\move(%d,%d,%d,%d)\\q2", resX + textLen/2, PositionY, -1 * textLen / 2, PositionY); - if(now -> fontSize != 25) + if(textHei != 25) { fprintf(opF, "\\fs%d", textHei); } @@ -1451,7 +1460,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "\\c&H%s", toHexColor(now->color, hexColor)); } - fprintf(opF, "}%s", EscapedText); + fprintf(opF, "}%s", escapedText); } else if(now -> type == 2 || now -> type == -2)/*左右弹幕*/ { @@ -1505,7 +1514,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "L2R,,0000,0000,0000,,{\\move(%d,%d,%d,%d)\\q2", -1 * textLen / 2, PositionY, resX + textLen/2, PositionY); - if(now -> fontSize != 25) + if(textHei != 25) { fprintf(opF, "\\fs%d", textHei); } @@ -1516,7 +1525,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "\\c&H%s", toHexColor(now->color, hexColor)); } - fprintf(opF, "}%s", EscapedText); + fprintf(opF, "}%s", escapedText); } else if(now -> type == 3 || now -> type == -3)/*顶端弹幕*/ { @@ -1565,7 +1574,7 @@ int writeAssDanmakuPart(FILE *opF, printTime(opF, now->time + holdTime, ","); fprintf(opF, "TOP,,0000,0000,0000,,{\\pos(%d,%d)\\q2", resX / 2, PositionY); - if(now -> fontSize != 25) + if(textHei != 25) { fprintf(opF, "\\fs%d", textHei); } @@ -1576,7 +1585,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "\\c&H%s", toHexColor(now->color, hexColor)); } - fprintf(opF, "}%s", EscapedText); + fprintf(opF, "}%s", escapedText); } else if(now -> type == 4 || now -> type == -4)/*底端弹幕*/ { @@ -1630,7 +1639,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "BTM,,0000,0000,0000,,{\\pos(%d,%d)\\q2", resX / 2, PositionY - textHei + 2); - if(now -> fontSize != 25) + if(textHei != 25) { fprintf(opF, "\\fs%d", textHei); } @@ -1641,7 +1650,7 @@ int writeAssDanmakuPart(FILE *opF, fprintf(opF, "\\c&H%s", toHexColor(now->color, hexColor)); } - fprintf(opF, "}%s", EscapedText); + fprintf(opF, "}%s", escapedText); } else if(now -> type == 5 || now -> type == -5)/*特殊弹幕*/ { @@ -1714,7 +1723,7 @@ int writeAssDanmakuPart(FILE *opF, if(now -> fontSize != 25) {/*字号*/ - fprintf(opF, "\\fs%d", fontSize + (now -> fontSize - 25)); + fprintf(opF, "\\fs%d", now -> fontSize); } if(now -> color != 0xFFFFFF) @@ -1746,15 +1755,8 @@ int writeAssDanmakuPart(FILE *opF, {/*字体*/ fprintf(opF, "\\fn%s", now -> special -> fontName); } - - /*特殊字符替换*/ - { - char tempText[MAX_TEXT_LENGTH]; - strrpl(now -> text, tempText, " ", "\\h", MAX_TEXT_LENGTH); - strrpl(tempText, EscapedText, "\n", "\\N", MAX_TEXT_LENGTH); - } - fprintf(opF, "}%s", EscapedText); + fprintf(opF, "}%s", escapedText); } else if(now -> type == 8)/*代码弹幕*/ { diff --git a/Define/CLIDef.h b/Define/CLIDef.h index b6da6d4..479a3cc 100644 --- a/Define/CLIDef.h +++ b/Define/CLIDef.h @@ -17,7 +17,7 @@ limitations under the License. #ifndef __CLIDEF_H__ #define __CLIDEF_H__ -#define VERSION "1.41 CLI Release" +#define VERSION "1.42 CLI Beta" #define CONFIG_FILE_NAME "DanmakuFactoryConfig.json" #define FILENAME_LEN 512 #define FORMAT_LEN 16 diff --git a/README.md b/README.md index 5ede0ab..58246fd 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ DanmakuFactory是一款弹幕文件转换工具,支持特殊弹幕,支持ass ##### Windows -[DanmakuFactory_1.41_CLI Beta(蓝奏云)](https://hihkm.lanzous.com/i9pU4dsdl7c) +[DanmakuFactory_1.42_CLI Beta(蓝奏云)](https://hihkm.lanzous.com/i9pU4dsdl7c) -[DanmakuFactory_1.41_CLI Beta(GITHUB)](https://github.com/hihkm/DanmakuFactory/releases) +[DanmakuFactory_1.42_CLI Beta(GITHUB)](https://github.com/hihkm/DanmakuFactory/releases) [DanmakuFactory_GUI(~~在做了在做了~~)]() -[1.31 Release](Compiled/release/DanmakuFactory_1.31_release.zip) +[1.31 Release(有指引的控制台应用)](Compiled/release/DanmakuFactory_1.31_release.zip) @@ -174,35 +174,19 @@ DanmakuFactory -o [输出文件格式] 输出文件名 -i [输入文件1格式] ##### 1.40 - 增加了ass弹幕读入功能,并兼容第三方软件生成的ass弹幕文件 - - 增加了xml弹幕写出功能 - - 增加了json弹幕读入功能(实验) - - 增加了json弹幕写出功能(实验) - - 增加了写出ass文件时屏蔽弹幕以注释方式保留 - - 增加了xml弹幕转义符解析 - - 增加了多文件弹幕合并 - - - - 修复了特殊弹幕不换行的问题 - - 修复了特殊弹幕解析有概率崩溃的问题 - - 修复了普通弹幕过长可能导致的崩溃问题 - - - 优化了部分模块,执行效率有所提高 - - 改用json文件存储配置信息,便于修改查看 - - - 去除了原本不稳定的编码转换模块(后续可能会使用第三方库) ##### 1.41 @@ -210,4 +194,12 @@ DanmakuFactory -o [输出文件格式] 输出文件名 -i [输入文件1格式] - 适配linux - 修复了部分xml特殊弹幕无法正常解析的问题 - 修复了ass输出后空格失效的问题 -- 优化排序,对于原本正序的输入无需重新排序 \ No newline at end of file +- 优化排序,对于原本正序的输入无需重新排序 + +**1.42** + +- 修复了部分xml特殊弹幕无法正常解析的问题 + +- 修复了部分xml特殊弹幕回车或空格显示错误问题 + +- 取消了特殊弹幕等比缩放 \ No newline at end of file diff --git a/XmlFile.c b/XmlFile.c index ed6ca17..b0c03e7 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -266,7 +266,8 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl /*文本部分*/ strGetLeftPart(NULL, &textPtr, '\"', MAX_TEXT_LENGTH); - strGetLeftPart(textPart, &textPtr, '\"', MAX_TEXT_LENGTH); + strGetLeftPart(tempText, &textPtr, '\"', MAX_TEXT_LENGTH); + strrpl(tempText, textPart, "/n", "\n", MAX_TEXT_LENGTH);//远古弹幕转义换行符 strGetLeftPart(NULL, &textPtr, ',', MAX_TEXT_LENGTH); now->special->frZ = atoi(deQuotMarks(strGetLeftPart(tempText, &textPtr, ',', MAX_TEXT_LENGTH)));