Advertisement
TechSkylander1518

Speech Bubble v19

Nov 4th, 2021 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.75 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Carmaniac's Speech Bubbles for v18
  3. # Updated by Avery
  4. #-------------------------------------------------------------------------------
  5. # To use, call pbCallBub(type, eventID)
  6. #
  7. # Where type is either 1 or 2:
  8. # 1 - floating bubble
  9. # 2 - speech bubble with arrow
  10. #-------------------------------------------------------------------------------
  11.  
  12. #PluginManager.register({
  13. #  :name => "Speech Bubbles",
  14. #  :version => "1.3",
  15. #  :credits => ["Carmaniac","Avery","Boonzeet","Golisopod User"],
  16. #  :link => "https://reliccastle.com/resources/461/"
  17. #})
  18.  
  19. #-------------------------------------------------------------------------------
  20. # Class modifiers
  21. #-------------------------------------------------------------------------------
  22.  
  23. class PokemonTemp
  24.   attr_accessor :speechbubble_bubble
  25.   attr_accessor :speechbubble_vp
  26.   attr_accessor :speechbubble_arrow
  27.   attr_accessor :speechbubble_outofrange
  28.   attr_accessor :speechbubble_talking
  29. end
  30.  
  31. module MessageConfig
  32.   if defined?($PokemonTemp.speechbubble_bubble) && $PokemonTemp.speechbubble_bubble > 0
  33.     type = $PokemonTemp.speechbubble_bubble
  34.     if type == 1 || type == 3
  35.       LIGHT_TEXT_MAIN_COLOR    = Color.new(80, 80, 88)
  36.       LIGHT_TEXT_SHADOW_COLOR  = Color.new(160, 160, 168)
  37.       DARK_TEXT_MAIN_COLOR    = Color.new(80, 80, 88)
  38.       DARK_TEXT_SHADOW_COLOR  = Color.new(160, 160, 168)
  39.     end
  40.   end
  41. end
  42.  
  43. #-------------------------------------------------------------------------------
  44. # Function modifiers
  45. #-------------------------------------------------------------------------------
  46.  
  47. class Window_AdvancedTextPokemon
  48.   def text=(value)
  49.     if value != nil && value != "" && $PokemonTemp.speechbubble_bubble && $PokemonTemp.speechbubble_bubble > 0
  50.       type = $PokemonTemp.speechbubble_bubble
  51.       if type == 1 || type == 3
  52.         $PokemonTemp.speechbubble_bubble = 0
  53.         self.height = 100
  54.         self.width  = 480
  55.         if type == 1
  56.           @x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x
  57.           @y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y - (32 + @height)
  58.         else
  59.           @x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x - (@width/2)
  60.           @y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y - 50 - @height
  61.         end
  62.         if @y>(Graphics.height-@height-2)
  63.           @y = (Graphics.height-@height)
  64.         end
  65.         if @y<2
  66.           if type == 1
  67.             @y=2
  68.           else
  69.             @y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y + 16
  70.           end
  71.         end
  72.         if @x = Graphics.width - @width - 2 #@x>(Graphics.width-@width-2)
  73.           @x = ($game_map.events[$PokemonTemp.speechbubble_talking].screen_x-(@width/2))
  74.         end
  75.         if @x<2
  76.           @x=2
  77.         end
  78.       else
  79.         $PokemonTemp.speechbubble_bubble = 0
  80.       end
  81.     end
  82.     setText(value)
  83.   end
  84. end
  85.  
  86. def pbRepositionMessageWindow(msgwindow, linecount=2)
  87.   msgwindow.height=32*linecount+msgwindow.borderY
  88.   msgwindow.y=(Graphics.height)-(msgwindow.height)
  89.   if $game_temp && $game_temp.in_battle && !$scene.respond_to?("update_basic")
  90.     msgwindow.y=0
  91.   elsif $game_system && $game_system.respond_to?("message_position")
  92.     case $game_system.message_position
  93.     when 0  # up
  94.       msgwindow.y=0
  95.     when 1  # middle
  96.       msgwindow.y=(Graphics.height/2)-(msgwindow.height/2)
  97.     when 2
  98.       if $PokemonTemp.speechbubble_bubble && $PokemonTemp.speechbubble_bubble > 0
  99.         msgwindow.setSkin("Graphics/Windowskins/frlgtextskin")
  100.         msgwindow.baseColor      = MessageConfig::DARK_TEXT_MAIN_COLOR
  101.         msgwindow.shadowColor    = MessageConfig::DARK_TEXT_SHADOW_COLOR
  102.       end
  103.       case $PokemonTemp.speechbubble_bubble
  104.       when 1
  105.        msgwindow.height = 100
  106.        msgwindow.width = 400
  107.       when 2
  108.        msgwindow.height = 102
  109.        msgwindow.width = Graphics.width
  110.        if $game_player.direction==8
  111.          $PokemonTemp.speechbubble_vp = Viewport.new(0, 0, Graphics.width, 280)
  112.          msgwindow.y = 6
  113.        else
  114.          $PokemonTemp.speechbubble_vp = Viewport.new(0, 6 + msgwindow.height, Graphics.width, 280)
  115.          msgwindow.y = (Graphics.height - msgwindow.height) - 6
  116.          if $PokemonTemp.speechbubble_outofrange==true
  117.            msgwindow.y = 6
  118.          end
  119.        end
  120.       when 3
  121.         msgwindow.height = 300
  122.         msgwindow.width = 600
  123.       else
  124.         msgwindow.height = 102
  125.         msgwindow.y = Graphics.height - msgwindow.height - 6
  126.       end
  127.     end
  128.   end
  129.   if $game_system && $game_system.respond_to?("message_frame")
  130.     if $game_system.message_frame != 0
  131.       msgwindow.opacity = 0
  132.     end
  133.   end
  134.   if $game_message
  135.     case $game_message.background
  136.       when 1,2  # dim, transparent
  137.         msgwindow.opacity=0
  138.     end
  139.   end
  140. end
  141.  
  142. def pbCreateMessageWindow(viewport=nil,skin=nil)
  143.   #@directory = "Graphics/Pictures/"
  144.   arrow = nil
  145.   if $PokemonTemp.speechbubble_bubble==2 && $game_map.events[$PokemonTemp.speechbubble_talking] != nil # Message window set to floating bubble.
  146.     if $game_player.direction==8 # Player facing up, message window top.
  147.       $PokemonTemp.speechbubble_vp = Viewport.new(0, 100, Graphics.width, 300)  #104, 280
  148.       $PokemonTemp.speechbubble_vp.z = 999999
  149.       arrow = Sprite.new($PokemonTemp.speechbubble_vp)
  150.       arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x - Graphics.width
  151.       arrow.y = ($game_map.events[$PokemonTemp.speechbubble_talking].screen_y - Graphics.height) - 216
  152.       arrow.z = 999999
  153.       arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow4")
  154.       arrow.zoom_x = 2
  155.       arrow.zoom_y = 2
  156.       if arrow.x<-230
  157.         arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x
  158.         arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow3")
  159.       end
  160.     else # Player facing left, down, right, message window bottom.
  161.       $PokemonTemp.speechbubble_vp = Viewport.new(0, 0, Graphics.width, 284)
  162.       $PokemonTemp.speechbubble_vp.z = 999999
  163.       arrow = Sprite.new($PokemonTemp.speechbubble_vp)
  164.       arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x
  165.       arrow.y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y - 8
  166.       arrow.z = 999999
  167.       arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow1")
  168.       if arrow.y>=Graphics.height-120 # Change arrow direction.
  169.         $PokemonTemp.speechbubble_outofrange=true
  170.         $PokemonTemp.speechbubble_vp.rect.y+=104
  171.         arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x - Graphics.width
  172.         arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow4")
  173.         arrow.y = ($game_map.events[$PokemonTemp.speechbubble_talking].screen_y - Graphics.height) - 136
  174.         if arrow.x<-250
  175.           arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x
  176.           arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow3")
  177.         end
  178.         if arrow.x>=256
  179.           arrow.x -= 15 # $game_map.events[$PokemonTemp.speechbubble_talking].screen_x-Graphics.width
  180.           arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow3")
  181.         end
  182.       else
  183.         $PokemonTemp.speechbubble_outofrange=false
  184.       end
  185.       arrow.zoom_x = 2
  186.       arrow.zoom_y = 2
  187.     end
  188.   elsif $PokemonTemp.speechbubble_bubble==3 && $game_map.events[$PokemonTemp.speechbubble_talking] != nil # Message window set to floating bubble.
  189.     $PokemonTemp.speechbubble_vp = Viewport.new(0, 0, Graphics.width, Graphics.height)
  190.     $PokemonTemp.speechbubble_vp.z = 999999
  191.     if Graphics.height/3>$game_map.events[$PokemonTemp.speechbubble_talking].screen_y-32
  192.       arrow = Sprite.new($PokemonTemp.speechbubble_vp)
  193.       arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x-16#arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x - Graphics.width
  194.       arrow.y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y+4#arrow.y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y - Graphics.height
  195.       arrow.z = 999999
  196.       arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow6")
  197.     else
  198.       arrow = Sprite.new($PokemonTemp.speechbubble_vp)
  199.       arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x#arrow.x = $game_map.events[$PokemonTemp.speechbubble_talking].screen_x - Graphics.width
  200.       arrow.y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y-60#arrow.y = $game_map.events[$PokemonTemp.speechbubble_talking].screen_y - Graphics.height
  201.       arrow.z = 999999
  202.       arrow.y-=1 if ($PokemonSystem.screensize==2)
  203.       arrow.bitmap = Bitmap.new("Graphics/Pictures/Arrow5")
  204.     end
  205.   end
  206.   $PokemonTemp.speechbubble_arrow = arrow
  207.   $game_temp.message_window = Window_AdvancedTextPokemon.new("")
  208.   msgwindow=$game_temp.message_window
  209.   if !viewport
  210.     msgwindow.z=99999
  211.   else
  212.     msgwindow.viewport=viewport
  213.   end
  214.   msgwindow.visible=true
  215.   msgwindow.letterbyletter=true
  216.   msgwindow.back_opacity=MessageConfig::WINDOW_OPACITY
  217.   pbBottomLeftLines(msgwindow,2)
  218.   $game_temp.message_window_showing=true if $game_temp
  219.   $game_message.visible=true if $game_message
  220.   skin=MessageConfig.pbGetSpeechFrame() if !skin
  221.   msgwindow.setSkin(skin)
  222.   return msgwindow
  223. end
  224.  
  225. def pbDisposeMessageWindow(msgwindow)
  226.   $game_temp.message_window_showing=false if $game_temp
  227.   $game_message.visible=false if $game_message
  228.   $game_temp.message_window.dispose if $game_temp.message_window
  229.   msgwindow.dispose
  230.   $PokemonTemp.speechbubble_arrow.dispose if $PokemonTemp.speechbubble_arrow
  231.   $PokemonTemp.speechbubble_vp.dispose if $PokemonTemp.speechbubble_vp
  232. end
  233.  
  234. def pbCallBub(status=0,value=0)
  235.   $PokemonTemp.speechbubble_talking=get_character(value).id
  236.   $PokemonTemp.speechbubble_bubble=status
  237. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement