ccoa's UMS FIT_WINDOW_TO_TEXT Patch
Introduction
ccoa's Universal Message System (UMS) FIT_WINDOW_TO_TEXT mode adds extra space from escape codes and make the window unnecessary longer.
I had Chaucer fix it and I'd like to share the fix with anyone want to remove the gap as well.
Since ccoa does not allow to redistribute the script, so I can only show the parts need changing only.
Script
- Replace line 1195
width = [width, self.contents.text_size(line).width].max 复制代码 with
width = [width, text_width(line)].max 复制代码
- Add these at line 1290 (above reset_window)
Spoiler: text_width method
Ruby: def text_width ( text ) width = 0; text = text.gsub( "\030" ) do "" end text = text.gsub( "\031" ) do "" end text = text.gsub( "\000" ) { "" } text = text.gsub( /\001[.*?]/ ) { "" } text = text.gsub( "\002" ) { "" } text = text.gsub( /\026[.*?]/ ) { "" } text = text.gsub( "\003" ) { "" } text = text.gsub( "\023" ) { "" } text = text.gsub( /\024[.*?]/ ) { "" } text = text.gsub( /\025[.*?]/ ) { "" } text = text.gsub( "\004" ) { "" } text = text.gsub( "\005" ) { "" } text = text.gsub( "\006" ) { "" } text = text.gsub( /\007\[(.*?)\]/ ) { "" } text = text.gsub( /\010\[.*?\]/ ) { "" } text = text.gsub( /\011\[.*?\]/ ) { "" } text = text.gsub( /\013\[[0-9]+\]/ ) { "" } text = text.gsub( /\014\[[0-9]+\]\s\s/ ) { width += 24; "" } text = text.gsub( /\015\[[0-9]+\]\s\s/ ) { width += 24; "" } text = text.gsub( /\016\[[0-9]+\]\s\s/ ) { width += 24; "" } text = text.gsub( /\017\[[0-9]+\]\s\s/ ) { width += 24; "" } text = text.gsub( /\027\[.*?\]/ ) { width += 24; "" } text = text.gsub( "\020" ) { "" } text = text.gsub( "\021" ) { "" } text = text.gsub( "\022" ) { "" } width += self.contents.text_size( text ).width; return width; end 复制代码
Credit and Thanks
- Chaucer
- Credit is optional
本贴来自国际rpgmaker官方论坛作者:callmedan处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/ccoas-ums-fit_window_to_text-patch.159688/