Advertisement
LiTTleDRAgo

[RGSS/2/3] Colorful Description

Feb 18th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.45 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_Help
  3. #------------------------------------------------------------------------------
  4. #  This window shows skill and item explanations along with actor status.
  5. #==============================================================================
  6. class Window_Help < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # * Set Text
  9.   #--------------------------------------------------------------------------
  10.   def set_text(t='', a = 0)
  11.     draw_colored_text(t,a) if t != @text || a != @align
  12.     self.visible = true
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # * Draw Colored Text
  16.   #--------------------------------------------------------------------------
  17.   def draw_colored_text(t='',a=0)
  18.     self.contents.clear
  19.     self.contents.font.color = normal_color
  20.     @text, @align, @actor, x = t.clone, a, nil, 0
  21.     if a != 0
  22.       t.gsub!(/\\[Cc]\[([0-9]+)\]/) { '' }
  23.       return self.contents.draw_text(4,0,self.width-40,32,t,a)
  24.     end
  25.     t.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  26.     while ((c = t.slice!(/./m)) != nil)
  27.       if c == "\001"
  28.         t.sub!(/\[([0-9]+)\]/, "")
  29.         self.contents.font.color = text_color($1.to_i)
  30.         next
  31.       end
  32.       self.contents.draw_text(4 + x, 32 * 0, 40, 32, c)
  33.       x += self.contents.text_size(c).width
  34.    end
  35.   end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement