TheoAllen

Msg Balloon V2

Dec 25th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 25.22 KB | None | 0 0
  1. #==============================================================================
  2. # TheoAllen - Message Balloon
  3. # Version : 2.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. #==============================================================================
  7. ($imported ||= {})[:Theo_MessageBalloonV2] = true
  8. #==============================================================================
  9. # Change Logs :
  10. #------------------------------------------------------------------------------
  11. # 2014.12.26 - Rewrite for version 2.0
  12. #            - Get rid gradient background. Bring back windowskin
  13. #            - Added opening animation
  14. #            - Added <bm:x> tag for subject
  15. #            - Compatibility with Namebox window
  16. # 2013.09.05 - Finished script
  17. #==============================================================================
  18. =begin
  19.  
  20.   ==================
  21.   *) Perkenalan :
  22.   ------------------
  23.   Script ini ngebikin kamu nampilin dialog dalam balloon diatas karakter
  24.  
  25.   =======================
  26.   *) Cara penggunaan :
  27.   -----------------------
  28.   Pasang dibawah material namun diatas main.
  29.   Masukkan gambar untuk ballon pointer di Graphics/system. Dan jangan lupa
  30.   dinamain "ballonpointer".
  31.  
  32.   Edit konfigurasinya dan ikuti aturan script call berikut
  33.  
  34.   =======================
  35.   *) Script Calls :
  36.   -----------------------
  37.   - message.balloon
  38.   Panggil script call seperti ini untuk membuat text ditampilkan dalam model
  39.   balloon
  40.  
  41.   - message.normal
  42.   Panggil script call seperti ini untuk mengembalikan message seperti biasa
  43.  
  44.   - message.subject = angka
  45.   Panggil script call seperti ini untuk menentukan subject yang berbicara.
  46.   Angka disana adalah event ID. Jika kamu memasukkan 0, maka yang akan
  47.   berbicara adalah player. Jika event ID tidak ada, maka message akan
  48.   berubah seperti biasa
  49.  
  50.   Atau jika kalian kerepotan untuk membuat script call, kalian bisa memakai tag
  51.   <bm:x> pada kotak dimana x adalah event ID tersebut. Contoh
  52.  
  53.   <bm:1>Hai, apa kabar?
  54.  
  55.   =======================
  56.   *) Terms of use :
  57.   -----------------------
  58.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  59.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  60.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  61.  
  62. =end
  63. #==============================================================================
  64. # Konfigurasi :
  65. #==============================================================================
  66. module Theo
  67.   module Msg
  68.  
  69.   # Jarak keatas message balloon (default: 32)
  70.     Buffer_Y     = 44
  71.  
  72.   # Ukuran font dalam balloon  
  73.     FontSize     = 22
  74.  
  75.   # Batas minimum lebar window
  76.     MinimumWidth = 0
  77.    
  78.   # Gunakan animasi opening untuk mode balloon? (Butuh: Theo Basic Module)
  79.     UseOpening   = true
  80.    
  81.   # Kecepatan opening
  82.     OpeningSpeed = 25
  83.    
  84.   # Warna popup opening (red, green, blue)
  85.     OpeningColor = Color.new(255,255,255)
  86.    
  87.   # Opening SE. Tuliskan dengan RPG::SE.new('nama', volume, pitch)
  88.   # Isi dengan nil jika tidak digunakan
  89.     OpeningSE = RPG::SE.new('Open1', 80, 150)
  90.    
  91.   # Closing SE. Tuliskan dengan RPG::SE.new('nama', volume, pitch)
  92.   # Isi dengan nil jika tidak digunakan
  93.     ClosingSE = nil
  94.    
  95.   end
  96. end
  97. #==============================================================================
  98. # Akhir dari konfigurasi
  99. #==============================================================================
  100.  
  101. #==============================================================================
  102. # ** Game_Interpreter
  103. #==============================================================================
  104.  
  105. class Game_Interpreter
  106.    
  107.   # Shortcut
  108.   def message
  109.     $game_message
  110.   end
  111.  
  112. end
  113.  
  114. #==============================================================================
  115. # ** Global window, taken from Sprite Extension
  116. #==============================================================================
  117.  
  118. module Theo
  119.   #--------------------------------------------------------------------------
  120.   # * Get Global Window
  121.   #--------------------------------------------------------------------------
  122.   def self.window
  123.     if @window.nil? || @window.disposed?
  124.       @window = Window_Base.new(0,0,1,1)
  125.       @window.visible = false
  126.       @window.gobj_exempt if @window.respond_to?(:gobj_exempt)
  127.       # Compatibility with mithran's
  128.     end
  129.     return @window
  130.   end
  131.  
  132. end
  133.  
  134. #==============================================================================
  135. # ** Bitmap
  136. #==============================================================================
  137.  
  138. class Bitmap
  139.   #--------------------------------------------------------------------------
  140.   # * Border fill
  141.   #--------------------------------------------------------------------------
  142.   def border_fill(color)
  143.     fill_rect(0,0,width,1,color)
  144.     fill_rect(0,0,1,height,color)
  145.     fill_rect(width-1,0,1,height,color)
  146.     fill_rect(0,height-1,width,1,color)
  147.   end
  148.  
  149. end
  150.  
  151. #==============================================================================
  152. # ** Point. To store x and y
  153. #==============================================================================
  154.  
  155. class Point
  156.   #--------------------------------------------------------------------------
  157.   # * Public attributes
  158.   #--------------------------------------------------------------------------
  159.   attr_accessor :x
  160.   attr_accessor :y
  161.   #--------------------------------------------------------------------------
  162.   # * Initialize
  163.   #--------------------------------------------------------------------------
  164.   def initialize(x,y)
  165.     @x, @y = x, y
  166.   end
  167.  
  168. end
  169.  
  170. #==============================================================================
  171. # ** Game_Message
  172. #==============================================================================
  173.  
  174. class Game_Message
  175.   #--------------------------------------------------------------------------
  176.   # * Escape char junk
  177.   #--------------------------------------------------------------------------
  178.   Junk_EscapeChar = [
  179.   /\eNBL\['.*'\]/i,
  180.   /\eNBR\['.*'\]/i,
  181.   /\eNBL\[\d+\]/i,
  182.   /\eNBR\[\d+\]/i,
  183.   /\e\^/,
  184.   /\e\./,
  185.   /\e\|/,
  186.   /\e\$/,
  187.   /\e\>/,
  188.   /\e\</,
  189.   /\e\!/,
  190.   ]
  191.  
  192.   #--------------------------------------------------------------------------
  193.   # * Public attributes
  194.   #--------------------------------------------------------------------------
  195.   attr_accessor :balloon_refresh
  196.   attr_accessor :subject
  197.   attr_reader :type
  198.  
  199.   #--------------------------------------------------------------------------
  200.   # * Alias : Initialize
  201.   #--------------------------------------------------------------------------
  202.   alias theo_msgballoon_init initialize
  203.   def initialize
  204.     theo_msgballoon_init
  205.     @subject = 0
  206.     normal
  207.   end
  208.  
  209.   #--------------------------------------------------------------------------
  210.   # * Switch to balloon
  211.   #--------------------------------------------------------------------------
  212.   def balloon
  213.     @type = :balloon
  214.     @balloon_refresh = true
  215.   end
  216.  
  217.   #--------------------------------------------------------------------------
  218.   # * Switch to normal
  219.   #--------------------------------------------------------------------------
  220.   def normal
  221.     @type = :normal
  222.     @balloon_refresh = true
  223.   end
  224.  
  225.   #--------------------------------------------------------------------------
  226.   # * Balloon mode is on?
  227.   #--------------------------------------------------------------------------
  228.   def balloon?
  229.     return false unless SceneManager.scene_is?(Scene_Map)
  230.     @type == :balloon && @subject > -1 && !get_char.nil?
  231.   end
  232.  
  233.   #--------------------------------------------------------------------------
  234.   # * Convert escape char for width calculation
  235.   #--------------------------------------------------------------------------
  236.   def convert_escape_characters(text)
  237.     result = Theo.window.convert_escape_characters(text)
  238.     result.gsub!(/\eC\[\d+\]/i) { "" }        # Destroy change color code
  239.     result.gsub!(/\eI\[\d+\]/i) { "      " }  # Destroy draw icon
  240.     result.gsub!(/<bm:\s*(\d+)>/i) do
  241.       @subject = $1.to_i
  242.       ""
  243.     end
  244.     Junk_EscapeChar.each do |esc|  
  245.       result.gsub!(esc) { "" }
  246.     end
  247.     return result
  248.   end
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # * Get longest text
  252.   #--------------------------------------------------------------------------
  253.   def longest_text
  254.     test = Theo.window.contents
  255.     test.font.size = Theo::Msg::FontSize
  256.     txts = []
  257.     @texts.each do |txt|
  258.       txts.push(convert_escape_characters(txt))
  259.     end
  260.     longest = txts.sort do |a,b|
  261.       test.text_size(b).width <=> test.text_size(a).width
  262.     end[0]
  263.     result = test.text_size(longest).width
  264.     return [result, Theo::Msg::MinimumWidth].max
  265.   end
  266.  
  267.   #--------------------------------------------------------------------------
  268.   # * Get character
  269.   #--------------------------------------------------------------------------
  270.   def get_char
  271.     if @subject == 0
  272.       player = $game_player
  273.       return Point.new(player.screen_x, player.screen_y)
  274.     else
  275.       event = $game_map.events[@subject]
  276.       return nil unless event
  277.       return Point.new(event.screen_x, event.screen_y)
  278.     end
  279.   end
  280.  
  281.   #--------------------------------------------------------------------------
  282.   # * Total text
  283.   #--------------------------------------------------------------------------
  284.   def total_text
  285.     @texts.size
  286.   end
  287.  
  288. end
  289.  
  290. #==============================================================================
  291. # ** BalloonPointer
  292. #==============================================================================
  293.  
  294. class BalloonPointer < Sprite
  295.   #--------------------------------------------------------------------------
  296.   # * Public Attributes
  297.   #--------------------------------------------------------------------------
  298.   attr_reader :window
  299.   attr_reader :pos
  300.  
  301.   #--------------------------------------------------------------------------
  302.   # *
  303.   #--------------------------------------------------------------------------
  304.   def initialize(viewport,window)
  305.     super(viewport)
  306.     @window = window
  307.     @pos = :upper
  308.     self.bitmap = Cache.system("ballonpointer")
  309.     to_center
  310.     update
  311.   end
  312.  
  313.   #--------------------------------------------------------------------------
  314.   # * Position
  315.   #--------------------------------------------------------------------------
  316.   def pos=(pos)
  317.     @pos = pos
  318.     update_placement
  319.   end
  320.  
  321.   #--------------------------------------------------------------------------
  322.   # * To center
  323.   #--------------------------------------------------------------------------
  324.   def to_center
  325.     self.ox = width/2
  326.     self.oy = height
  327.   end
  328.  
  329.   #--------------------------------------------------------------------------
  330.   # * Update
  331.   #--------------------------------------------------------------------------
  332.   def update
  333.     super
  334.     if window.balloon?
  335.       self.visible = window.open?
  336.       update_placement
  337.     else
  338.       self.visible = false
  339.     end
  340.     self.mirror = mirror_case
  341.   end
  342.  
  343.   #--------------------------------------------------------------------------
  344.   # * Update Placement
  345.   #--------------------------------------------------------------------------
  346.   def update_placement
  347.     self.x = window.char.x
  348.     if pos == :upper
  349.       self.y = window.char.y - 32
  350.       self.angle = 0
  351.     else
  352.       self.angle = 180
  353.       self.y = window.char.y
  354.     end
  355.   end
  356.  
  357.   def mirror_case
  358.     pos = x - window.x
  359.     pos < window.width/2
  360.   end
  361.  
  362. end
  363.  
  364. #==============================================================================
  365. # ** Sprite_OpenAnimation
  366. #==============================================================================
  367.  
  368. class Sprite_OpenAnimation < Sprite
  369.   #--------------------------------------------------------------------------
  370.   # * Initialize
  371.   #--------------------------------------------------------------------------
  372.   def initialize(vport, msg_window)
  373.     super(vport)
  374.     @msg = msg_window
  375.     w = 12*5
  376.     h = 12
  377.     self.bitmap = Bitmap.new(w,h)
  378.     bitmap.border_fill(Theo::Msg::OpeningColor)
  379.     self.ox = width/2
  380.     self.oy = height/2
  381.     update
  382.   end
  383.  
  384.   #--------------------------------------------------------------------------
  385.   # * Update
  386.   #--------------------------------------------------------------------------
  387.   def update
  388.     super
  389.     if Theo::Msg::UseOpening && @msg.balloon?
  390.       @ratio = @msg.openness / 255.0
  391.       self.opacity = @msg.openness
  392.       self.zoom_x = zoom_ratio_x
  393.       self.zoom_y = zoom_ratio_y
  394.       self.visible = false if @msg.open?
  395.     else
  396.       self.visible = false
  397.     end
  398.   end
  399.  
  400.   #--------------------------------------------------------------------------
  401.   # * Zoom ratio X
  402.   #--------------------------------------------------------------------------
  403.   def zoom_ratio_x
  404.     (@msg.width / width.to_f)* @ratio
  405.   end
  406.  
  407.   #--------------------------------------------------------------------------
  408.   # * Zoom ratio Y
  409.   #--------------------------------------------------------------------------
  410.   def zoom_ratio_y
  411.     (@msg.height / height.to_f) * @ratio
  412.   end
  413.  
  414.   #--------------------------------------------------------------------------
  415.   # * Start pop
  416.   #--------------------------------------------------------------------------
  417.   def start_pop(char)
  418.     Theo::Msg::OpeningSE.play if Theo::Msg::OpeningSE
  419.     self.x = char.x
  420.     self.y = char.y - 16
  421.     targ_x = @msg.x + @msg.width/2
  422.     targ_y = @msg.y + @msg.height/2
  423.     dur = 255/Theo::Msg::OpeningSpeed
  424.     goto(targ_x, targ_y, dur)
  425.   end
  426.  
  427. end
  428.  
  429. #==============================================================================
  430. # ** Window_Message
  431. #==============================================================================
  432.  
  433. class Window_Message < Window_Base
  434.   #--------------------------------------------------------------------------
  435.   # * Alias : Initialize
  436.   #--------------------------------------------------------------------------
  437.   alias theo_msgballoon_init initialize
  438.   def initialize
  439.     theo_msgballoon_init
  440.     @animation = Sprite_OpenAnimation.new(viewport, self)
  441.     @animation.visible = false
  442.     @pointer_viewport = Viewport.new
  443.     @pointer_viewport.z = 999
  444.     @pointer = BalloonPointer.new(@pointer_viewport,self)
  445.   end
  446.  
  447.   #--------------------------------------------------------------------------
  448.   # * Alias clear instance variables
  449.   #--------------------------------------------------------------------------
  450.   alias theo_msgballoon_clear_instances clear_instance_variables
  451.   def clear_instance_variables
  452.     theo_msgballoon_clear_instances
  453.     @balloon = false
  454.     @subject = -1
  455.   end
  456.  
  457.   #--------------------------------------------------------------------------
  458.   # * Alias : Setting changed
  459.   #--------------------------------------------------------------------------
  460.   alias theo_msgballoon_settings_changed? settings_changed?
  461.   def settings_changed?
  462.     theo_msgballoon_settings_changed? || balloon_setting_changed?
  463.   end
  464.  
  465.   #--------------------------------------------------------------------------
  466.   # * Ballon setting changed
  467.   #--------------------------------------------------------------------------
  468.   def balloon_setting_changed?
  469.     @balloon != balloon? || @subject != $game_message.subject
  470.   end
  471.  
  472.   #--------------------------------------------------------------------------
  473.   # * Setup Window
  474.   #--------------------------------------------------------------------------
  475.   def setup_window
  476.     balloon? ? setup_balloon : setup_normal
  477.   end
  478.  
  479.   #--------------------------------------------------------------------------
  480.   # * Setup normal
  481.   #--------------------------------------------------------------------------
  482.   def setup_normal
  483.     h = fitting_height(visible_line_number)
  484.     w = Graphics.width
  485.     self.width = w
  486.     self.height = h
  487.     create_contents
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # * Setup Balloon
  492.   #--------------------------------------------------------------------------
  493.   def setup_balloon
  494.     h = fitting_height($game_message.total_text) + 2
  495.     w = $game_message.longest_text + 10 + (standard_padding * 2)
  496.     self.width = w
  497.     self.height = h
  498.     create_contents
  499.     self.opacity = 255
  500.   end
  501.  
  502.   #--------------------------------------------------------------------------
  503.   # * Balloon mode?
  504.   #--------------------------------------------------------------------------
  505.   def balloon?
  506.     $game_message.balloon?
  507.   end
  508.  
  509.   #--------------------------------------------------------------------------
  510.   # * Update background
  511.   #--------------------------------------------------------------------------
  512.   alias theo_msgballoon_update_bg update_background
  513.   def update_background
  514.     recreate_choice if @balloon != balloon?
  515.     @balloon = balloon?
  516.     @subject = $game_message.subject
  517.     theo_msgballoon_update_bg
  518.   end
  519.  
  520.   #--------------------------------------------------------------------------
  521.   # * Update placement
  522.   #--------------------------------------------------------------------------
  523.   alias theo_msgballoon_normal_placement update_placement
  524.   def update_placement
  525.     setup_window
  526.     theo_msgballoon_normal_placement
  527.     if balloon?
  528.       update_balloon_placement
  529.     else
  530.       self.x = 0
  531.     end
  532.   end
  533.  
  534.   #--------------------------------------------------------------------------
  535.   # * Get character
  536.   #--------------------------------------------------------------------------
  537.   def char
  538.     $game_message.get_char
  539.   end
  540.  
  541.   #--------------------------------------------------------------------------
  542.   # * Update balloon placement
  543.   #--------------------------------------------------------------------------
  544.   def update_balloon_placement
  545.     xpos = [[char.x - width/2,0].max, Graphics.width - width].min
  546.     ypos = char.y - height - Theo::Msg::Buffer_Y
  547.     @pointer.pos = :upper
  548.     if ypos < 0
  549.       ypos = char.y + 11
  550.       @pointer.pos = :lower
  551.     end
  552.     self.x = xpos
  553.     self.y = ypos
  554.   end
  555.  
  556.   #--------------------------------------------------------------------------
  557.   # * Alias : New page
  558.   #--------------------------------------------------------------------------
  559.   alias theo_msgballoon_new_page new_page
  560.   def new_page(text, pos)
  561.     balloon? ? balloon_new_page(text, pos) : theo_msgballoon_new_page(text, pos)
  562.   end
  563.  
  564.   #--------------------------------------------------------------------------
  565.   # * Balloon new page
  566.   #--------------------------------------------------------------------------
  567.   def balloon_new_page(text, pos)
  568.     setup_balloon
  569.     update_balloon_placement
  570.     contents.clear
  571.     reset_font_settings
  572.     pos[:x] = new_line_x
  573.     pos[:y] = 0
  574.     pos[:new_x] = new_line_x
  575.     pos[:height] = calc_line_height(text)
  576.     clear_flags
  577.   end
  578.  
  579.   #--------------------------------------------------------------------------
  580.   # * Alias : New line X
  581.   #--------------------------------------------------------------------------
  582.   alias theo_balloon_new_line_x new_line_x
  583.   def new_line_x
  584.     balloon? ? 4 : theo_balloon_new_line_x
  585.   end
  586.  
  587.   #--------------------------------------------------------------------------
  588.   # * Alias : Update
  589.   #--------------------------------------------------------------------------
  590.   alias theo_msgballoon_update update
  591.   def update
  592.     theo_msgballoon_update
  593.     @pointer.update
  594.     @animation.update
  595.     if balloon?
  596.       self.visible = open? if Theo::Msg::UseOpening
  597.       update_balloon_placement if !@opening && !@closing
  598.     else
  599.       self.visible = true
  600.     end
  601.     recreate_choice if $game_message.balloon_refresh
  602.   end
  603.  
  604.   #--------------------------------------------------------------------------
  605.   # * Recreate choice
  606.   #--------------------------------------------------------------------------
  607.   def recreate_choice
  608.     @choice_window.dispose
  609.     @choice_window = Window_ChoiceList.new(self)
  610.     $game_message.balloon_refresh = false
  611.   end
  612.  
  613.   #--------------------------------------------------------------------------
  614.   # * Alias : Line height
  615.   #--------------------------------------------------------------------------
  616.   alias theo_msgballoon_line_height line_height
  617.   def line_height
  618.     balloon? ? Theo::Msg::FontSize : theo_msgballoon_line_height
  619.   end
  620.  
  621.   #--------------------------------------------------------------------------
  622.   # * Reset font settings
  623.   #--------------------------------------------------------------------------
  624.   alias theo_msgballoon_reset_font reset_font_settings
  625.   def reset_font_settings
  626.     theo_msgballoon_reset_font
  627.     contents.font.size = Theo::Msg::FontSize if balloon?
  628.   end
  629.  
  630. #~   #--------------------------------------------------------------------------
  631. #~   # * Overwrite : Input pause
  632. #~   #--------------------------------------------------------------------------
  633. #~   def input_pause
  634. #~     self.pause = true unless balloon?
  635. #~     wait(10)
  636. #~     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
  637. #~     Input.update
  638. #~     self.pause = false unless balloon?
  639. #~   end
  640.  
  641.   #--------------------------------------------------------------------------
  642.   # * Alias : Open and wait
  643.   #--------------------------------------------------------------------------
  644.   alias theo_msgballoon_open_wait open_and_wait
  645.   def open_and_wait
  646.     if balloon? && Theo::Msg::UseOpening
  647.       @animation.visible = true
  648.       @animation.start_pop(char)
  649.     end
  650.     theo_msgballoon_open_wait
  651.   end
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # * Alias : Close and wait
  655.   #--------------------------------------------------------------------------
  656.   alias theo_msgballoon_close_wait close_and_wait
  657.   def close_and_wait
  658.     Theo::Msg::ClosingSE.play if Theo::Msg::UseOpening && Theo::Msg::ClosingSE
  659.     @animation.visible = false
  660.     theo_msgballoon_close_wait
  661.   end
  662.  
  663.   #--------------------------------------------------------------------------
  664.   # * Overwrite : Update Open Processing
  665.   #--------------------------------------------------------------------------
  666.   def update_open
  667.     speed = balloon? ? Theo::Msg::OpeningSpeed : 48
  668.     self.openness += speed
  669.     @opening = false if open?
  670.   end
  671.  
  672.   #--------------------------------------------------------------------------
  673.   # * Overwrite : Update Close Processing
  674.   #--------------------------------------------------------------------------
  675.   def update_close
  676.     speed = balloon? ? Theo::Msg::OpeningSpeed : 48
  677.     self.openness -= speed
  678.     @closing = false if close?
  679.   end
  680.  
  681.   #--------------------------------------------------------------------------
  682.   # * Alias : Convert escape character
  683.   #--------------------------------------------------------------------------
  684.   alias theo_msgballoon_convert_char convert_escape_characters
  685.   def convert_escape_characters(text)
  686.     result = theo_msgballoon_convert_char(text)
  687.     result = result.gsub(/<bm:\s*(\d+)>/i) { "" }
  688.     result
  689.   end
  690.  
  691.   #---------------------------------------------------------------------------
  692.   # * Alias : Dispose
  693.   #---------------------------------------------------------------------------
  694.   alias theo_msgballoon_dispose dispose
  695.   def dispose
  696.     theo_msgballoon_dispose
  697.     @animation.dispose
  698.     @pointer.dispose
  699.   end
  700.  
  701. end
  702.  
  703. #==============================================================================
  704. # ** Window_ChoiceList
  705. #==============================================================================
  706.  
  707. class Window_ChoiceList < Window_Command
  708.   #--------------------------------------------------------------------------
  709.   # * Reset font settings
  710.   #--------------------------------------------------------------------------
  711.   alias theo_msgballoon_reset_font reset_font_settings
  712.   def reset_font_settings
  713.     theo_msgballoon_reset_font
  714.     contents.font.size = Theo::Msg::FontSize if @message_window.balloon?
  715.   end
  716.  
  717.   #--------------------------------------------------------------------------
  718.   # * Alias : Update placement
  719.   #--------------------------------------------------------------------------
  720.   alias theo_msgballoon_update_placement update_placement
  721.   def update_placement
  722.     theo_msgballoon_update_placement
  723.     if @message_window.balloon?
  724.       update_balloon_placement
  725.     end
  726.   end
  727.  
  728.   #--------------------------------------------------------------------------
  729.   # * Update balloon placement
  730.   #--------------------------------------------------------------------------
  731.   def update_balloon_placement
  732.     msg = @message_window
  733.     self.y = msg.y
  734.     self.x = msg.x + msg.width
  735.     if (x + width) > Graphics.width
  736.       self.x = msg.x - width
  737.     end
  738.     if x < 0
  739.       self.x = msg.x + msg.width - self.width
  740.       self.y = msg.y + msg.height
  741.     end
  742.     if (y + height) > Graphics.height
  743.       self.y = msg.y - self.height
  744.     end
  745.   end
  746.  
  747.   #--------------------------------------------------------------------------
  748.   # * Alias : Line height
  749.   #--------------------------------------------------------------------------
  750.   alias theo_msgballoon_line_height line_height
  751.   def line_height
  752.     @message_window.balloon? ? Theo::Msg::FontSize : theo_msgballoon_line_height
  753.   end
  754.  
  755. end
Advertisement
Add Comment
Please, Sign In to add comment