diff -Nru onscripter-20200621/debian/changelog onscripter-20200722/debian/changelog --- onscripter-20200621/debian/changelog 2020-06-30 02:30:35.000000000 +0000 +++ onscripter-20200722/debian/changelog 2020-08-16 07:19:10.000000000 +0000 @@ -1,3 +1,9 @@ +onscripter (20200722-1) unstable; urgency=low + + * New upstream release. + + -- Ying-Chun Liu (PaulLiu) Sun, 16 Aug 2020 15:19:10 +0800 + onscripter (20200621-1) unstable; urgency=low * New upstream release. diff -Nru onscripter-20200621/Encoding.cpp onscripter-20200722/Encoding.cpp --- onscripter-20200621/Encoding.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/Encoding.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -2,7 +2,7 @@ * * Encoding.cpp - Character encoding handler * - * Copyright (c) 2019-2019 Ogapee. All rights reserved. + * Copyright (c) 2019-2020 Ogapee. All rights reserved. * * ogapee@aqua.dti2.ne.jp * @@ -57,6 +57,20 @@ return 1; } +int Encoding::getNum(const unsigned char *buf) +{ + int n = 0; + + while(buf[0] != 0){ + int n2 = getBytes(buf[0]); + n++; + if (n2 > 1) n++; + buf += n2; + } + + return n; +} + char Encoding::getTextMarker() { if (code == CODE_UTF8) diff -Nru onscripter-20200621/Encoding.h onscripter-20200722/Encoding.h --- onscripter-20200621/Encoding.h 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/Encoding.h 2020-07-22 17:06:01.000000000 +0000 @@ -2,7 +2,7 @@ * * Encoding.h - Character encoding handler * - * Copyright (c) 2019-2019 Ogapee. All rights reserved. + * Copyright (c) 2019-2020 Ogapee. All rights reserved. * * ogapee@aqua.dti2.ne.jp * @@ -40,6 +40,8 @@ char getTextMarker(); int getBytes(unsigned char ch, int code = -1); + int getNum(const unsigned char *buf); + unsigned short getUTF16(const char *text, int code = -1); private: diff -Nru onscripter-20200621/FontInfo.cpp onscripter-20200722/FontInfo.cpp --- onscripter-20200621/FontInfo.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/FontInfo.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -2,7 +2,7 @@ * * FontInfo.cpp - Font information storage class of ONScripter * - * Copyright (c) 2001-2019 Ogapee. All rights reserved. + * Copyright (c) 2001-2020 Ogapee. All rights reserved. * * ogapee@aqua.dti2.ne.jp * @@ -77,6 +77,8 @@ is_shadow = true; is_transparent = true; is_newline_accepted = false; + + is_line_space_fixed = false; } void *FontInfo::openFont( char *font_file, int ratio1, int ratio2 ) @@ -168,7 +170,8 @@ int FontInfo::y(bool use_ruby_offset) { int pitch_y = pitch_xy[1]; - if (enc->getEncoding() == Encoding::CODE_UTF8 && ttf_font[0]) + if (!is_line_space_fixed && + enc->getEncoding() == Encoding::CODE_UTF8 && ttf_font[0]) pitch_y += TTF_FontLineSkip((const TTF_Font*)ttf_font[0]) - font_size_xy[1]; int y = xy[1]*pitch_y/2 + top_xy[1] + line_offset_xy[1]; if (use_ruby_offset && rubyon_flag && tateyoko_mode == YOKO_MODE && diff -Nru onscripter-20200621/FontInfo.h onscripter-20200722/FontInfo.h --- onscripter-20200621/FontInfo.h 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/FontInfo.h 2020-07-22 17:06:01.000000000 +0000 @@ -2,7 +2,7 @@ * * FontInfo.h - Font information storage class of ONScripter * - * Copyright (c) 2001-2019 Ogapee. All rights reserved. + * Copyright (c) 2001-2020 Ogapee. All rights reserved. * * ogapee@aqua.dti2.ne.jp * @@ -55,6 +55,7 @@ bool rubyon_flag; int tateyoko_mode; Encoding *enc; // encoding + bool is_line_space_fixed; FontInfo(); void reset(Encoding *enc); diff -Nru onscripter-20200621/ONScripter_rmenu.cpp onscripter-20200722/ONScripter_rmenu.cpp --- onscripter-20200621/ONScripter_rmenu.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/ONScripter_rmenu.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -62,11 +62,7 @@ va_list list; va_start( list, format ); while(*format){ - if (IS_TWO_BYTE(*format)){ - strncat(str, format, 2); - format += 2; - } - else if (format[0] == '%' && format[1] == 's'){ + if (format[0] == '%' && format[1] == 's'){ strcat(str, va_arg(list, char*)); format += 2; } @@ -189,8 +185,7 @@ menu_font.num_xy[1] = rmenu_link_num; menu_font.top_xy[0] = (screen_width * screen_ratio2 / screen_ratio1 - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (screen_height * screen_ratio2 / screen_ratio1 - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; - menu_font.setXY( (menu_font.num_xy[0] - rmenu_link_width) / 2, - (menu_font.num_xy[1] - rmenu_link_num) / 2 ); + menu_font.setXY(0, 0); RMenuLink *link = root_rmenu_link.next; int counter = 1; @@ -293,12 +288,14 @@ current_font = &menu_font; text_info.fill( 0, 0, 0, 0 ); - - menu_font.num_xy[0] = (strlen(save_item_name)+1)/2+2+13; - menu_font.num_xy[1] = num_save_file+2; + + int n = script_h.enc.getNum((unsigned char*)save_item_name); + menu_font.num_xy[0] = (n+1)/2 + 2 + 13; + menu_font.num_xy[1] = num_save_file + 2; menu_font.top_xy[0] = (screen_width * screen_ratio2 / screen_ratio1 - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (screen_height * screen_ratio2 / screen_ratio1 - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; - menu_font.setXY( (menu_font.num_xy[0] - strlen( load_menu_name ) / 2) / 2, 0 ); + int n2 = script_h.enc.getNum((unsigned char*)load_menu_name); + menu_font.setXY((menu_font.num_xy[0]*2 - n2)/4, 0); uchar3 color = {0xff, 0xff, 0xff}; drawString( load_menu_name, color, &menu_font, true, accumulation_surface, NULL, &text_info ); menu_font.newLine(); @@ -307,29 +304,33 @@ flush( refreshMode() ); bool nofile_flag; - char *buffer = new char[ strlen( save_item_name ) + 31 + 1 ]; + char *buffer = new char[menu_font.num_xy[0]*4 + 1]; SaveFileInfo save_file_info; for ( unsigned int i=1 ; i<=num_save_file ; i++ ){ searchSaveFile( save_file_info, i ); - menu_font.setXY( (menu_font.num_xy[0] - (strlen( save_item_name ) / 2 + 15) ) / 2 ); + menu_font.setXY((menu_font.num_xy[0]*2 - (n + 15*2)) / 4); + char *format_str = NULL; if ( save_file_info.valid ){ - sprintf( buffer, MESSAGE_SAVE_EXIST, - save_item_name, - save_file_info.sjis_no, - save_file_info.sjis_month, - save_file_info.sjis_day, - save_file_info.sjis_hour, - save_file_info.sjis_minute ); + setStr(&format_str, MESSAGE_SAVE_EXIST, -1, true); + sprintf(buffer, format_str, + save_item_name, + save_file_info.sjis_no, + save_file_info.sjis_month, + save_file_info.sjis_day, + save_file_info.sjis_hour, + save_file_info.sjis_minute); nofile_flag = false; } else{ - sprintf( buffer, MESSAGE_SAVE_EMPTY, - save_item_name, - save_file_info.sjis_no ); + setStr(&format_str, MESSAGE_SAVE_EMPTY, -1, true); + sprintf(buffer, format_str, + save_item_name, + save_file_info.sjis_no); nofile_flag = true; } + if (format_str) delete[] format_str; ButtonLink *button = getSelectableSentence( buffer, &menu_font, false, nofile_flag ); root_button_link.insert( button ); button->no = i; @@ -402,11 +403,13 @@ text_info.fill( 0, 0, 0, 0 ); - menu_font.num_xy[0] = (strlen(save_item_name)+1)/2+2+13; - menu_font.num_xy[1] = num_save_file+2; + int n = script_h.enc.getNum((unsigned char*)save_item_name); + menu_font.num_xy[0] = (n+1)/2 + 2 + 13; + menu_font.num_xy[1] = num_save_file + 2; menu_font.top_xy[0] = (screen_width * screen_ratio2 / screen_ratio1 - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (screen_height * screen_ratio2 / screen_ratio1 - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; - menu_font.setXY((menu_font.num_xy[0] - strlen( save_menu_name ) / 2 ) / 2, 0); + int n2 = script_h.enc.getNum((unsigned char*)save_menu_name); + menu_font.setXY((menu_font.num_xy[0]*2 - n2)/4, 0); uchar3 color = {0xff, 0xff, 0xff}; drawString( save_menu_name, color, &menu_font, true, accumulation_surface, NULL, &text_info ); menu_font.newLine(); @@ -415,29 +418,33 @@ flush( refreshMode() ); bool nofile_flag; - char *buffer = new char[ strlen( save_item_name ) + 31 + 1 ]; + char *buffer = new char[menu_font.num_xy[0]*4 + 1]; for ( unsigned int i=1 ; i<=num_save_file ; i++ ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, i ); - menu_font.setXY( (menu_font.num_xy[0] - (strlen( save_item_name ) / 2 + 15) ) / 2 ); + menu_font.setXY((menu_font.num_xy[0]*2 - (n + 15*2)) / 4); + char *format_str = NULL; if ( save_file_info.valid ){ - sprintf( buffer, MESSAGE_SAVE_EXIST, - save_item_name, - save_file_info.sjis_no, - save_file_info.sjis_month, - save_file_info.sjis_day, - save_file_info.sjis_hour, - save_file_info.sjis_minute ); + setStr(&format_str, MESSAGE_SAVE_EXIST, -1, true); + sprintf(buffer, format_str, + save_item_name, + save_file_info.sjis_no, + save_file_info.sjis_month, + save_file_info.sjis_day, + save_file_info.sjis_hour, + save_file_info.sjis_minute); nofile_flag = false; } else{ - sprintf( buffer, MESSAGE_SAVE_EMPTY, - save_item_name, - save_file_info.sjis_no ); + setStr(&format_str, MESSAGE_SAVE_EMPTY, -1, true); + sprintf(buffer, format_str, + save_item_name, + save_file_info.sjis_no); nofile_flag = true; } + if (format_str) delete[] format_str; ButtonLink *button = getSelectableSentence( buffer, &menu_font, false, nofile_flag ); root_button_link.insert( button ); button->no = i; @@ -473,28 +480,35 @@ text_info.fill( 0, 0, 0, 0 ); dirty_rect.fill( screen_width, screen_height ); - char name[64] = {'\0'}; + char name[128] = {'\0'}; + char *format_str = NULL; if ( caller == SYSTEM_SAVE ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); - sprintf( name, MESSAGE_SAVE_CONFIRM, - save_item_name, - save_file_info.sjis_no ); + setStr(&format_str, MESSAGE_SAVE_CONFIRM, -1, true); + sprintf(name, format_str, + save_item_name, + save_file_info.sjis_no); } else if ( caller == SYSTEM_LOAD ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); - sprintf( name, MESSAGE_LOAD_CONFIRM, - save_item_name, - save_file_info.sjis_no ); + setStr(&format_str, MESSAGE_LOAD_CONFIRM, -1, true); + sprintf(name, format_str, + save_item_name, + save_file_info.sjis_no); + } + else if ( caller == SYSTEM_RESET ){ + setStr(&format_str, MESSAGE_RESET_CONFIRM, -1, true); + strcpy(name, format_str); + } + else if ( caller == SYSTEM_END ){ + setStr(&format_str, MESSAGE_END_CONFIRM, -1, true); + strcpy(name, format_str); } - else if ( caller == SYSTEM_RESET ) - strcpy( name, MESSAGE_RESET_CONFIRM ); - else if ( caller == SYSTEM_END ) - strcpy( name, MESSAGE_END_CONFIRM ); - - menu_font.num_xy[0] = strlen(name)/2; + int n = script_h.enc.getNum((unsigned char*)name); + menu_font.num_xy[0] = (n+1)/2; menu_font.num_xy[1] = 3; menu_font.top_xy[0] = (screen_width * screen_ratio2 / screen_ratio1 - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (screen_height * screen_ratio2 / screen_ratio1 - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; @@ -504,19 +518,23 @@ flush( refreshMode() ); - int offset1 = strlen(name)/5; - int offset2 = strlen(name)/2 - offset1; - strcpy( name, MESSAGE_YES ); + int offset1 = n/5; + int offset2 = n/2 - offset1; + setStr(&format_str, MESSAGE_YES, -1, true); + strcpy(name, format_str); menu_font.setXY(offset1-2, 2); ButtonLink *button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 1; - strcpy( name, MESSAGE_NO ); + setStr(&format_str, MESSAGE_NO, -1, true); + strcpy(name, format_str); menu_font.setXY(offset2, 2); button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 2; + + if (format_str) delete[] format_str; flush( refreshMode() ); @@ -738,14 +756,14 @@ dialog_info.pos.y = (screen_height - dialog_info.pos.h)/2; // buttons - const char* mes[2]; + char* mes[2] = {NULL}; if (yesno_flag){ - mes[0] = MESSAGE_YES; - mes[1] = MESSAGE_NO; + setStr(&mes[0], MESSAGE_YES, -1, true); + setStr(&mes[1], MESSAGE_NO, -1, true); } else{ - mes[0] = MESSAGE_OK; - mes[1] = MESSAGE_CANCEL; + setStr(&mes[0], MESSAGE_OK, -1, true); + setStr(&mes[1], MESSAGE_CANCEL, -1, true); } for (int i=0 ; i<2 ; i++){ @@ -811,4 +829,7 @@ root_button_link.insert( btn ); } + + delete[] mes[0]; + delete[] mes[1]; } diff -Nru onscripter-20200621/ScriptHandler.cpp onscripter-20200722/ScriptHandler.cpp --- onscripter-20200621/ScriptHandler.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/ScriptHandler.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -1293,21 +1293,19 @@ int ScriptHandler::findLabel( const char *label ) { - int i; - char capital_label[256]; + char buf[256]; - for ( i=0 ; i<(int)strlen( label )+1 ; i++ ){ - capital_label[i] = label[i]; - if ( 'A' <= capital_label[i] && capital_label[i] <= 'Z' ) capital_label[i] += 'a' - 'A'; + for (int i=0; i<(int)strlen(label)+1; i++){ + buf[i] = label[i]; + if ('A' <= buf[i] && buf[i] <= 'Z') buf[i] += 'a' - 'A'; } - for ( i=0 ; i=0; --i){ + if (strcmp(label_info[i].name, buf) == 0) return i; } - char *p = new char[ strlen(label) + 32 ]; - sprintf(p, "Label \"%s\" is not found.", label); - errorAndExit( p ); + sprintf(buf, "Label \"%s\" is not found.", label); + errorAndExit(buf); return -1; // dummy } diff -Nru onscripter-20200621/ScriptParser_command.cpp onscripter-20200722/ScriptParser_command.cpp --- onscripter-20200621/ScriptParser_command.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/ScriptParser_command.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -389,8 +389,9 @@ const char *buf = script_h.readStr(); setStr( &link->next->label, buf ); - if ( rmenu_link_width < strlen( buf )/2 + 1 ) - rmenu_link_width = strlen( buf )/2 + 1; + int n = script_h.enc.getNum((const unsigned char*)buf); + if (rmenu_link_width < n/2 + 1) + rmenu_link_width = n/2 + 1; link->next->system_call_no = getSystemCallNo( script_h.readLabel() ); diff -Nru onscripter-20200621/ScriptParser.cpp onscripter-20200722/ScriptParser.cpp --- onscripter-20200621/ScriptParser.cpp 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/ScriptParser.cpp 2020-07-22 17:06:01.000000000 +0000 @@ -2,7 +2,7 @@ * * ScriptParser.cpp - Define block parser of ONScripter * - * Copyright (c) 2001-2019 Ogapee. All rights reserved. + * Copyright (c) 2001-2020 Ogapee. All rights reserved. * * ogapee@aqua.dti2.ne.jp * @@ -31,7 +31,7 @@ #endif #define VERSION_STR1 "ONScripter" -#define VERSION_STR2 "Copyright (C) 2001-2016 Studio O.G.A. All Rights Reserved." +#define VERSION_STR2 "Copyright (C) 2001-2020 Studio O.G.A. All Rights Reserved." #define DEFAULT_SAVE_MENU_NAME "<セーブ>" #define DEFAULT_LOAD_MENU_NAME "<ロード>" @@ -176,9 +176,9 @@ /* ---------------------------------------- */ /* Save/Load related variables */ - setStr( &save_menu_name, DEFAULT_SAVE_MENU_NAME ); - setStr( &load_menu_name, DEFAULT_LOAD_MENU_NAME ); - setStr( &save_item_name, DEFAULT_SAVE_ITEM_NAME ); + setStr(&save_menu_name, DEFAULT_SAVE_MENU_NAME, -1, true); + setStr(&load_menu_name, DEFAULT_LOAD_MENU_NAME, -1, true); + setStr(&save_item_name, DEFAULT_SAVE_ITEM_NAME, -1, true); num_save_file = 9; /* ---------------------------------------- */ @@ -229,6 +229,7 @@ menu_font.pitch_xy[0] = menu_font.font_size_xy[0]; menu_font.pitch_xy[1] = 2 + menu_font.font_size_xy[1]; menu_font.window_color[0] = menu_font.window_color[1] = menu_font.window_color[2] = 0xcc; + menu_font.is_line_space_fixed = true; deleteRMenuLink(); @@ -620,20 +621,31 @@ last_nest_info = &root_nest_info; } -void ScriptParser::setStr( char **dst, const char *src, int num ) +void ScriptParser::setStr(char **dst, const char *src, int num, bool to_utf8) { - if ( *dst ) delete[] *dst; + if (*dst) delete[] *dst; *dst = NULL; - if ( src ){ + if (src){ if (num >= 0){ - *dst = new char[ num + 1 ]; - memcpy( *dst, src, num ); + *dst = new char[num + 1]; + memcpy(*dst, src, num); (*dst)[num] = '\0'; } else{ - *dst = new char[ strlen( src ) + 1]; - strcpy( *dst, src ); + num = strlen(src); + if (to_utf8 && script_h.enc.getEncoding() == Encoding::CODE_UTF8){ + char *tmp_buf = new char[num*2 + 1]; + DirectReader::convertFromSJISToUTF8(tmp_buf, src); + num = strlen(tmp_buf); + *dst = new char[num + 1]; + strcpy(*dst, tmp_buf); + delete[] tmp_buf; + } + else{ + *dst = new char[num + 1]; + strcpy(*dst, src); + } } } } diff -Nru onscripter-20200621/ScriptParser.h onscripter-20200722/ScriptParser.h --- onscripter-20200621/ScriptParser.h 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/ScriptParser.h 2020-07-22 17:06:01.000000000 +0000 @@ -278,7 +278,7 @@ char *save_dir_envdata; void deleteNestInfo(); - void setStr( char **dst, const char *src, int num=-1 ); + void setStr( char **dst, const char *src, int num = -1, bool to_utf8 = false ); void readToken(); @@ -338,11 +338,11 @@ struct SaveFileInfo{ bool valid; int month, day, hour, minute; - char sjis_no[5]; - char sjis_month[5]; - char sjis_day[5]; - char sjis_hour[5]; - char sjis_minute[5]; + char sjis_no[7]; + char sjis_month[7]; + char sjis_day[7]; + char sjis_hour[7]; + char sjis_minute[7]; }; unsigned int num_save_file; char *save_menu_name; diff -Nru onscripter-20200621/version.h onscripter-20200722/version.h --- onscripter-20200621/version.h 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/version.h 2020-07-22 17:06:01.000000000 +0000 @@ -1,2 +1,2 @@ -#define ONS_VERSION "20200621" +#define ONS_VERSION "20200722" #define NSC_VERSION 296 diff -Nru onscripter-20200621/www/onscripter.html onscripter-20200722/www/onscripter.html --- onscripter-20200621/www/onscripter.html 2020-06-21 21:02:19.000000000 +0000 +++ onscripter-20200722/www/onscripter.html 2020-07-22 17:06:01.000000000 +0000 @@ -20,7 +20,7 @@ Since: Feb. 6, 2002
-Last updated: Jun. 21, 2020 (・ス。シ・ケケケソキ)
+Last updated: Jul. 22, 2020 (・ス。シ・ケケケソキ)
@@ -89,10 +89,10 @@ - + - +
コヌソキネヌonscripter-20200621.tar.gzonscripter-20200722.tar.gz
オネヌonscripter-20200530.tar.gzonscripter-20200721.tar.gz