1 hour ago
My endeavor to more SDK the old RPGMaker SDK and 'slicing' it into smaller modules continues...
AND THIS ... is now the size of my refresh method in Window_Message
And the ORANGE part IN that method that draws the actual message is this!
Doesn't that look sexy?
Yes, the YELLOW highlighted area does show I added a \sw[#] message code to let you get switches (true/false) just the same as using \v[#] to get the value of variables
But more than that, the PINK areas go to these two new methods...
And what does this mean?
These two methods are open to adding MORE WINDOW COMMAND CODES. I already added \b for Boldfaced text and \i to make text italicized. And yep, I have the feature that changes the color of text within its 'own' individual method if anyone wants to adapt it to use HEX codes or whatever.
ITS THAT MODULAR AND SEXY!
I could add more options like changing the font or font size... But no. And if I wanted to add \u for underline, \o for outline or \s for Strikethru, I would need to include a font script to add those features as they are not engine native.
But yeah, adding command codes is a tad easier now.
AND THIS ... is now the size of my refresh method in Window_Message
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
@x = @y = 0
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
@x = 8
end
# If waiting for a message to be displayed
if $game_temp.message_text != nil
@text = $game_temp.message_text
refresh_text
end
refresh_choices
refresh_number_input
end
* I highlighted methods I created to make it modular...# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
@x = @y = 0
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
@x = 8
end
# If waiting for a message to be displayed
if $game_temp.message_text != nil
@text = $game_temp.message_text
refresh_text
end
refresh_choices
refresh_number_input
end
And the ORANGE part IN that method that draws the actual message is this!
#--------------------------------------------------------------------------
# * Refresh Message Text
#--------------------------------------------------------------------------
def refresh_text
# Control text processing
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
@text.gsub!(/\\[Ss][Ww]\[([0-9]+)\]/) { $game_switches[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# Change "\\\\" to "\000" for convenience
@text.gsub!(/\\\\/) { "\000" }
# Change any other message code to special command code
text_substitute
# Get 1 text character in c (loop until unable to get text)
while ((c = @text.slice!(/./m)) != nil)
# Return to original text if \\
c = "\\" if c == "\000"
# Skip if text actively replaced with special codes
next if text_replace?(c)
# Draw text
self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
# Add x to drawn text width
@x += self.contents.text_size(c).width
end
end
# * Refresh Message Text
#--------------------------------------------------------------------------
def refresh_text
# Control text processing
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
@text.gsub!(/\\[Ss][Ww]\[([0-9]+)\]/) { $game_switches[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# Change "\\\\" to "\000" for convenience
@text.gsub!(/\\\\/) { "\000" }
# Change any other message code to special command code
text_substitute
# Get 1 text character in c (loop until unable to get text)
while ((c = @text.slice!(/./m)) != nil)
# Return to original text if \\
c = "\\" if c == "\000"
# Skip if text actively replaced with special codes
next if text_replace?(c)
# Draw text
self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
# Add x to drawn text width
@x += self.contents.text_size(c).width
end
end
Doesn't that look sexy?
Yes, the YELLOW highlighted area does show I added a \sw[#] message code to let you get switches (true/false) just the same as using \v[#] to get the value of variables
But more than that, the PINK areas go to these two new methods...
#--------------------------------------------------------------------------
# * Convert message code into a command code (eg \g into \002)
#--------------------------------------------------------------------------
def text_substitute
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Gg]/) { "\002" }
@text.gsub!(/\\[Bb]/) { "\010" }
@text.gsub!(/\\[Ii]/) { "\011" }
end
-and-# * Convert message code into a command code (eg \g into \002)
#--------------------------------------------------------------------------
def text_substitute
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Gg]/) { "\002" }
@text.gsub!(/\\[Bb]/) { "\010" }
@text.gsub!(/\\[Ii]/) { "\011" }
end
#--------------------------------------------------------------------------
# * Determine if actively replaced codes in text
#--------------------------------------------------------------------------
def text_replace?(c)
return true if text_replace_bold(c)
return true if text_replace_italic(c)
return true if text_replace_color(c)
return true if text_replace_gold(c)
return true if text_replace_newline(c)
return false
end
# * Determine if actively replaced codes in text
#--------------------------------------------------------------------------
def text_replace?(c)
return true if text_replace_bold(c)
return true if text_replace_italic(c)
return true if text_replace_color(c)
return true if text_replace_gold(c)
return true if text_replace_newline(c)
return false
end
And what does this mean?
These two methods are open to adding MORE WINDOW COMMAND CODES. I already added \b for Boldfaced text and \i to make text italicized. And yep, I have the feature that changes the color of text within its 'own' individual method if anyone wants to adapt it to use HEX codes or whatever.
ITS THAT MODULAR AND SEXY!
I could add more options like changing the font or font size... But no. And if I wanted to add \u for underline, \o for outline or \s for Strikethru, I would need to include a font script to add those features as they are not engine native.
But yeah, adding command codes is a tad easier now.


![[Image: QrnbKlx.jpg]](https://i.imgur.com/QrnbKlx.jpg)
![[Image: sGz1ErF.png]](https://i.imgur.com/sGz1ErF.png)
![[Image: liM4ikn.png]](https://i.imgur.com/liM4ikn.png)
![[Image: fdzKgZA.png]](https://i.imgur.com/fdzKgZA.png)
![[Image: sj0H81z.png]](https://i.imgur.com/sj0H81z.png)
![[Image: QL7oRau.png]](https://i.imgur.com/QL7oRau.png)
![[Image: uSqjY09.png]](https://i.imgur.com/uSqjY09.png)
![[Image: GAA3qE9.png]](https://i.imgur.com/GAA3qE9.png)
![[Image: 2Hmnx1G.png]](https://i.imgur.com/2Hmnx1G.png)
![[Image: BwtNdKw.png%5B]](https://i.imgur.com/BwtNdKw.png%5B)