Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#==============================================================================
# ** Message Thai Vovel and Outline Fix
#------------------------------------------------------------------------------
# By : Admannon
#==============================================================================
#==============================================================================
# ** Window Message
#==============================================================================
class Window_Base < Window
@@THAI_MARKS = "\u0E31\u0E34\u0E35\u0E36\u0E37\u0E48\u0E49\u0E4A\u0E4B\u0E47\u0E4C\u0E38\u0E39\u0E4D\u0E3A"
@@TEXT_SLICE = /.[#{@@THAI_MARKS}]*/m
#--------------------------------------------------------------------------
# * Preconvert Control Characters
#--------------------------------------------------------------------------
alias thai_fix_convert_escape_characters convert_escape_characters unless $@
def convert_escape_characters(text)
result = thai_fix_convert_escape_characters(text).clone
result.gsub!(/([#{@@THAI_MARKS}]+)\u0E33/, "\u0E4D\1\u0E32")
result.gsub!(/\u0E33([#{@@THAI_MARKS}]+)/, "\u0E4D\1\u0E32")
result.gsub!(/\u0E33/ , "\u0E4D\u0E32" )
return result
end
#--------------------------------------------------------------------------
# * Process Normal Character
#--------------------------------------------------------------------------
def process_normal_character(c, pos)
c = " #{c}"
space_width = text_size(" ").width
text_width = text_size( c ).width
draw_text(pos[:x] - space_width, pos[:y], text_width << 1, pos[:height], c)
pos[:x] += text_width - space_width
end
#--------------------------------------------------------------------------
# * Draw Text in Normal Window
#--------------------------------------------------------------------------
def draw_text_ex(x, y, text)
reset_font_settings
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
process_character(text.slice!(@TEXT_SLICE), text, pos) until text.empty?
end
end
#==============================================================================
# ** Window Message
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# * Draw Text in Message Window
#--------------------------------------------------------------------------
def process_all_text
open_and_wait
text = convert_escape_characters($game_message.all_text)
pos = {}
new_page(text, pos)
process_character(text.slice!(@@TEXT_SLICE), text, pos) until text.empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.