Advertisement
Vlue

Message UI

Jun 1st, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.96 KB | None | 0 0
  1. #Usage:
  2. # $game_message.set("bust name", position, "name")
  3. # Bust name is name of bust image in the pictures folder
  4. # Position is 0 for left and not 0 for right
  5. # Name is the name for the text box
  6.  
  7. #Using a custom message skin to achieve borderless look without messing with
  8. # other windows. Delete line 42 to remove effect.
  9.  
  10. #Ignoring tone setting in database to achieve grey look without messing with
  11. # other windows. Delete lines 47-49 to remove effect.
  12.  
  13. class Game_Message
  14.   attr_accessor  :bust_name
  15.   attr_accessor  :bust_position
  16.   attr_accessor  :name
  17.   alias message_clear clear
  18.   def clear
  19.     message_clear
  20.     @bust_name = nil
  21.     @bust_position = nil
  22.     @name = nil
  23.   end
  24.   def set(bustname, pos, name)
  25.     @bust_name = bustname
  26.     @bust_position = pos
  27.     @name = name
  28.   end
  29. end
  30.  
  31. #56,13,144+24,28+24
  32. class Window_Message
  33.   alias message_init initialize
  34.   def initialize
  35.     message_init
  36.     self.width += 12
  37.     self.x -= 6
  38.     @uiname_window = Window_Base.new(0,0,168,52)
  39.     @uiname_window.opacity = 0
  40.     @border_sprite = Sprite_Base.new
  41.     @border_sprite.z = self.z + 1
  42.     #@border_sprite.opacity = 0
  43.     @bust_sprite = Sprite_Base.new
  44.     #@bust_sprite.opacity = 0
  45.     self.windowskin = Cache.system("Messageskin")
  46.   end
  47.   def update_tone
  48.     self.tone = Tone.new(0,0,0,255)
  49.   end
  50.   def update_placement
  51.     @position = $game_message.position
  52.     self.y = @position * (Graphics.height - height) / 2 + 6
  53.     @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
  54.   end
  55.   alias ui_open open_and_wait
  56.   def open_and_wait
  57.     if $game_message.bust_name
  58.       @bust_sprite.bitmap = Cache.picture($game_message.bust_name)
  59.       if $game_message.bust_position == 0
  60.         @bust_sprite.mirror = false
  61.         @bust_sprite.x = 0
  62.       else
  63.         @bust_sprite.mirror = true
  64.         @bust_sprite.x = Graphics.width - @bust_sprite.width
  65.       end
  66.       @bust_sprite.y = self.y + 3 - @bust_sprite.height
  67.     end
  68.     if $game_message.name
  69.       if $game_message.bust_position == 0
  70.         @uiname_window.x = Graphics.width - 168 - 24
  71.       else
  72.         @uiname_window.x = 56 - 16
  73.       end
  74.       @uiname_window.y = self.y - @uiname_window.height + 12
  75.       @uiname_window.contents.clear
  76.       @uiname_window.contents.fill_rect(0,0,144,28,Color.new(75,75,75,175))
  77.       @uiname_window.draw_text(4,0,144,28,$game_message.name)
  78.     end
  79.     if $game_message.bust_position == 0
  80.       @border_sprite.bitmap = Cache.system("UI text right")
  81.     else
  82.       @border_sprite.bitmap = Cache.system("UI text left")
  83.     end
  84.     @border_sprite.y = self.y + 12 - @border_sprite.height
  85.     ui_open
  86.   end
  87.   alias ui_close close_and_wait
  88.   def close_and_wait
  89.     @uiname_window.contents.clear
  90.     if @bust_sprite.bitmap
  91.       @bust_sprite.bitmap.dispose
  92.       @bust_sprite.bitmap = nil
  93.     end
  94.     if @border_sprite.bitmap
  95.       @border_sprite.bitmap.dispose
  96.       @border_sprite.bitmap = nil
  97.     end
  98.     ui_close
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement