TechSkylander1518

Mr. Gela's Portraits for v19.1

Jul 19th, 2021 (edited)
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.56 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. #===============================================================================
  4. class Scene_Map
  5.   def updatemini
  6.     oldmws=$game_temp.message_window_showing
  7.     $game_temp.message_window_showing=true
  8.     loop do
  9.       $game_map.update
  10.       $game_player.update
  11.       $game_system.update
  12.       if $game_screen
  13.         $game_screen.update
  14.       else
  15.         $game_map.screen.update
  16.       end
  17.       break unless $game_temp.player_transferring
  18.       transfer_player
  19.       break if $game_temp.transition_processing
  20.     end
  21.     $game_temp.message_window_showing=oldmws
  22.     @spriteset.update if @spriteset
  23.     @message_window.update if @message_window
  24.   end
  25. end
  26.  
  27.  
  28.  
  29. class Scene_Battle
  30.   def updatemini
  31.     if self.respond_to?("update_basic")
  32.       update_basic(true)
  33.       update_info_viewport                  # Update information viewport
  34.     else
  35.       oldmws=$game_temp.message_window_showing
  36.       $game_temp.message_window_showing=true
  37.       # Update system (timer) and screen
  38.       $game_system.update
  39.       if $game_screen
  40.         $game_screen.update
  41.       else
  42.         $game_map.screen.update
  43.       end
  44.       # If timer has reached 0
  45.       if $game_system.timer_working && $game_system.timer == 0
  46.         # Abort battle
  47.         $game_temp.battle_abort = true
  48.       end
  49.       # Update windows
  50.       @help_window.update if @help_window
  51.       @party_command_window.update if @party_command_window
  52.       @actor_command_window.update if @actor_command_window
  53.       @status_window.update if @status_window
  54.       $game_temp.message_window_showing=oldmws
  55.       @message_window.update if @message_window
  56.       # Update sprite set
  57.       @spriteset.update if @spriteset
  58.     end
  59.   end
  60. end
  61.  
  62.  
  63.  
  64. def pbMapInterpreter
  65.   if $game_map.respond_to?("interpreter")
  66.     return $game_map.interpreter
  67.   elsif $game_system
  68.     return $game_system.map_interpreter
  69.   end
  70.   return nil
  71. end
  72.  
  73. def pbMapInterpreterRunning?
  74.   interp = pbMapInterpreter
  75.   return interp && interp.running?
  76. end
  77.  
  78. def pbRefreshSceneMap
  79.   if $scene && $scene.is_a?(Scene_Map)
  80.     if $scene.respond_to?("miniupdate")
  81.       $scene.miniupdate
  82.     else
  83.       $scene.updatemini
  84.     end
  85.   elsif $scene && $scene.is_a?(Scene_Battle)
  86.     $scene.updatemini
  87.   end
  88. end
  89.  
  90. def pbUpdateSceneMap
  91.   if $scene && $scene.is_a?(Scene_Map) && !pbIsFaded?
  92.     if $scene.respond_to?("miniupdate")
  93.       $scene.miniupdate
  94.     else
  95.       $scene.updatemini
  96.     end
  97.   elsif $scene && $scene.is_a?(Scene_Battle)
  98.     $scene.updatemini
  99.   end
  100. end
  101.  
  102. #===============================================================================
  103. #
  104. #===============================================================================
  105. def pbEventCommentInput(*args)
  106.   parameters = []
  107.   list = *args[0].list   # Event or event page
  108.   elements = *args[1]    # Number of elements
  109.   trigger = *args[2]     # Trigger
  110.   return nil if list == nil
  111.   return nil unless list.is_a?(Array)
  112.   for item in list
  113.     next unless item.code == 108 || item.code == 408
  114.     if item.parameters[0] == trigger
  115.       start = list.index(item) + 1
  116.       finish = start + elements
  117.       for id in start...finish
  118.         next if !list[id]
  119.         parameters.push(list[id].parameters[0])
  120.       end
  121.       return parameters
  122.     end
  123.   end
  124.   return nil
  125. end
  126.  
  127. def pbCurrentEventCommentInput(elements,trigger)
  128.   return nil if !pbMapInterpreterRunning?
  129.   event = pbMapInterpreter.get_character(0)
  130.   return nil if !event
  131.   return pbEventCommentInput(event,elements,trigger)
  132. end
  133.  
  134.  
  135.  
  136. #===============================================================================
  137. #
  138. #===============================================================================
  139. class ChooseNumberParams
  140.   def initialize
  141.     @maxDigits=0
  142.     @minNumber=0
  143.     @maxNumber=0
  144.     @skin=nil
  145.     @messageSkin=nil
  146.     @negativesAllowed=false
  147.     @initialNumber=0
  148.     @cancelNumber=nil
  149.   end
  150.  
  151.   def setMessageSkin(value)
  152.     @messageSkin=value
  153.   end
  154.  
  155.   def messageSkin   # Set the full path for the message's window skin
  156.     @messageSkin
  157.   end
  158.  
  159.   def setSkin(value)
  160.     @skin=value
  161.   end
  162.  
  163.   def skin
  164.     @skin
  165.   end
  166.  
  167.   def setNegativesAllowed(value)
  168.     @negativeAllowed=value
  169.   end
  170.  
  171.   def negativesAllowed
  172.     @negativeAllowed ? true : false
  173.   end
  174.  
  175.   def setRange(minNumber,maxNumber)
  176.     maxNumber=minNumber if minNumber>maxNumber
  177.     @maxDigits=0
  178.     @minNumber=minNumber
  179.     @maxNumber=maxNumber
  180.   end
  181.  
  182.   def setDefaultValue(number)
  183.     @initialNumber=number
  184.     @cancelNumber=nil
  185.   end
  186.  
  187.   def setInitialValue(number)
  188.     @initialNumber=number
  189.   end
  190.  
  191.   def setCancelValue(number)
  192.     @cancelNumber=number
  193.   end
  194.  
  195.   def initialNumber
  196.     return clamp(@initialNumber,self.minNumber,self.maxNumber)
  197.   end
  198.  
  199.   def cancelNumber
  200.     return @cancelNumber || self.initialNumber
  201.   end
  202.  
  203.   def minNumber
  204.     ret=0
  205.     if @maxDigits>0
  206.       ret=-((10**@maxDigits)-1)
  207.     else
  208.       ret=@minNumber
  209.     end
  210.     ret=0 if !@negativeAllowed && ret<0
  211.     return ret
  212.   end
  213.  
  214.   def maxNumber
  215.     ret=0
  216.     if @maxDigits>0
  217.       ret=((10**@maxDigits)-1)
  218.     else
  219.       ret=@maxNumber
  220.     end
  221.     ret=0 if !@negativeAllowed && ret<0
  222.     return ret
  223.   end
  224.  
  225.   def setMaxDigits(value)
  226.     @maxDigits=[1,value].max
  227.   end
  228.  
  229.   def maxDigits
  230.     if @maxDigits>0
  231.       return @maxDigits
  232.     else
  233.       return [numDigits(self.minNumber),numDigits(self.maxNumber)].max
  234.     end
  235.   end
  236.  
  237.   private
  238.  
  239.   def clamp(v,mn,mx)
  240.     return v<mn ? mn : (v>mx ? mx : v)
  241.   end
  242.  
  243.   def numDigits(number)
  244.     ans = 1
  245.     number=number.abs
  246.     while number >= 10
  247.       ans+=1
  248.       number/=10
  249.     end
  250.     return ans
  251.   end
  252. end
  253.  
  254.  
  255.  
  256. def pbChooseNumber(msgwindow,params)
  257.   return 0 if !params
  258.   ret=0
  259.   maximum=params.maxNumber
  260.   minimum=params.minNumber
  261.   defaultNumber=params.initialNumber
  262.   cancelNumber=params.cancelNumber
  263.   cmdwindow=Window_InputNumberPokemon.new(params.maxDigits)
  264.   cmdwindow.z=99999
  265.   cmdwindow.visible=true
  266.   cmdwindow.setSkin(params.skin) if params.skin
  267.   cmdwindow.sign=params.negativesAllowed # must be set before number
  268.   cmdwindow.number=defaultNumber
  269.   pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
  270.   loop do
  271.     Graphics.update
  272.     Input.update
  273.     pbUpdateSceneMap
  274.     cmdwindow.update
  275.     msgwindow.update if msgwindow
  276.     yield if block_given?
  277.     if Input.trigger?(Input::USE)
  278.       ret=cmdwindow.number
  279.       if ret>maximum
  280.         pbPlayBuzzerSE()
  281.       elsif ret<minimum
  282.         pbPlayBuzzerSE()
  283.       else
  284.         pbPlayDecisionSE()
  285.         break
  286.       end
  287.     elsif Input.trigger?(Input::BACK)
  288.       pbPlayCancelSE()
  289.       ret=cancelNumber
  290.       break
  291.     end
  292.   end
  293.   cmdwindow.dispose
  294.   Input.update
  295.   return ret
  296. end
  297.  
  298.  
  299.  
  300. #===============================================================================
  301. #
  302. #===============================================================================
  303. class FaceWindowVX < SpriteWindow_Base
  304.   def initialize(face)
  305.     super(0,0,128,128)
  306.     faceinfo=face.split(",")
  307.     facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0])
  308.     facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
  309.     self.contents.dispose if self.contents
  310.     @faceIndex=faceinfo[1].to_i
  311.     @facebitmaptmp=AnimatedBitmap.new(facefile)
  312.     @facebitmap=BitmapWrapper.new(96,96)
  313.     @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  314.        (@faceIndex % 4) * 96,
  315.        (@faceIndex / 4) * 96, 96, 96
  316.     ))
  317.     self.contents=@facebitmap
  318.   end
  319.  
  320.   def update
  321.     super
  322.     if @facebitmaptmp.totalFrames>1
  323.       @facebitmaptmp.update
  324.       @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  325.          (@faceIndex % 4) * 96,
  326.          (@faceIndex / 4) * 96, 96, 96
  327.       ))
  328.     end
  329.   end
  330.  
  331.   def dispose
  332.     @facebitmaptmp.dispose
  333.     @facebitmap.dispose if @facebitmap
  334.     super
  335.   end
  336. end
  337.  
  338.  
  339.  
  340. #===============================================================================
  341. #
  342. #===============================================================================
  343. def pbGetBasicMapNameFromId(id)
  344.   begin
  345.     map = pbLoadMapInfos
  346.     return "" if !map
  347.     return map[id].name
  348.   rescue
  349.     return ""
  350.   end
  351. end
  352.  
  353. def pbGetMapNameFromId(id)
  354.   map=pbGetBasicMapNameFromId(id)
  355.   map.gsub!(/\\PN/,$Trainer.name) if $Trainer
  356.   return map
  357. end
  358.  
  359. def pbCsvField!(str)
  360.   ret=""
  361.   str.sub!(/\A\s*/,"")
  362.   if str[0,1]=="\""
  363.     str[0,1]=""
  364.     escaped=false
  365.     fieldbytes=0
  366.     str.scan(/./) do |s|
  367.       fieldbytes+=s.length
  368.       break if s=="\"" && !escaped
  369.       if s=="\\" && !escaped
  370.         escaped=true
  371.       else
  372.         ret+=s
  373.         escaped=false
  374.       end
  375.     end
  376.     str[0,fieldbytes]=""
  377.     if !str[/\A\s*,/] && !str[/\A\s*$/]
  378.       raise _INTL("Invalid quoted field (in: {1})",ret)
  379.     end
  380.     str[0,str.length]=$~.post_match
  381.   else
  382.     if str[/,/]
  383.       str[0,str.length]=$~.post_match
  384.       ret=$~.pre_match
  385.     else
  386.       ret=str.clone
  387.       str[0,str.length]=""
  388.     end
  389.     ret.gsub!(/\s+$/,"")
  390.   end
  391.   return ret
  392. end
  393.  
  394. def pbCsvPosInt!(str)
  395.   ret=pbCsvField!(str)
  396.   if !ret[/\A\d+$/]
  397.     raise _INTL("Field {1} is not a positive integer",ret)
  398.   end
  399.   return ret.to_i
  400. end
  401.  
  402.  
  403.  
  404. #===============================================================================
  405. # Money and coins windows
  406. #===============================================================================
  407. def pbGetGoldString
  408.   moneyString=""
  409.   begin
  410.     moneyString=_INTL("${1}",$Trainer.money.to_s_formatted)
  411.   rescue
  412.     if $data_system.respond_to?("words")
  413.       moneyString=_INTL("{1} {2}",$game_party.gold,$data_system.words.gold)
  414.     else
  415.       moneyString=_INTL("{1} {2}",$game_party.gold,Vocab.gold)
  416.     end
  417.   end
  418.   return moneyString
  419. end
  420.  
  421. def pbDisplayGoldWindow(msgwindow)
  422.   moneyString=pbGetGoldString()
  423.   goldwindow=Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>",moneyString))
  424.   goldwindow.setSkin("Graphics/Windowskins/goldskin")
  425.   goldwindow.resizeToFit(goldwindow.text,Graphics.width)
  426.   goldwindow.width=160 if goldwindow.width<=160
  427.   if msgwindow.y==0
  428.     goldwindow.y=Graphics.height-goldwindow.height
  429.   else
  430.     goldwindow.y=0
  431.   end
  432.   goldwindow.viewport=msgwindow.viewport
  433.   goldwindow.z=msgwindow.z
  434.   return goldwindow
  435. end
  436.  
  437. def pbDisplayCoinsWindow(msgwindow,goldwindow)
  438.   coinString=($Trainer) ? $Trainer.coins.to_s_formatted : "0"
  439.   coinwindow=Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>",coinString))
  440.   coinwindow.setSkin("Graphics/Windowskins/goldskin")
  441.   coinwindow.resizeToFit(coinwindow.text,Graphics.width)
  442.   coinwindow.width=160 if coinwindow.width<=160
  443.   if msgwindow.y==0
  444.     coinwindow.y=(goldwindow) ? goldwindow.y-coinwindow.height : Graphics.height-coinwindow.height
  445.   else
  446.     coinwindow.y=(goldwindow) ? goldwindow.height : 0
  447.   end
  448.   coinwindow.viewport=msgwindow.viewport
  449.   coinwindow.z=msgwindow.z
  450.   return coinwindow
  451. end
  452.  
  453. def pbDisplayBattlePointsWindow(msgwindow)
  454.   pointsString = ($Trainer) ? $Trainer.battle_points.to_s_formatted : "0"
  455.   pointswindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
  456.   pointswindow.setSkin("Graphics/Windowskins/goldskin")
  457.   pointswindow.resizeToFit(pointswindow.text,Graphics.width)
  458.   pointswindow.width=160 if pointswindow.width<=160
  459.   if msgwindow.y==0
  460.     pointswindow.y=Graphics.height-pointswindow.height
  461.   else
  462.     pointswindow.y=0
  463.   end
  464.   pointswindow.viewport=msgwindow.viewport
  465.   pointswindow.z=msgwindow.z
  466.   return pointswindow
  467. end
  468.  
  469.  
  470.  
  471. #===============================================================================
  472. #
  473. #===============================================================================
  474. def pbCreateStatusWindow(viewport=nil)
  475.   msgwindow=Window_AdvancedTextPokemon.new("")
  476.   if !viewport
  477.     msgwindow.z=99999
  478.   else
  479.     msgwindow.viewport=viewport
  480.   end
  481.   msgwindow.visible=false
  482.   msgwindow.letterbyletter=false
  483.   pbBottomLeftLines(msgwindow,2)
  484.   skinfile=MessageConfig.pbGetSpeechFrame()
  485.   msgwindow.setSkin(skinfile)
  486.   return msgwindow
  487. end
  488.  
  489. def pbCreateMessageWindow(viewport=nil,skin=nil)
  490.   msgwindow=Window_AdvancedTextPokemon.new("")
  491.   if !viewport
  492.     msgwindow.z=99999
  493.   else
  494.     msgwindow.viewport=viewport
  495.   end
  496.   msgwindow.visible=true
  497.   msgwindow.letterbyletter=true
  498.   msgwindow.back_opacity=MessageConfig::WINDOW_OPACITY
  499.   pbBottomLeftLines(msgwindow,2)
  500.   $game_temp.message_window_showing=true if $game_temp
  501.   skin=MessageConfig.pbGetSpeechFrame() if !skin
  502.   msgwindow.setSkin(skin)
  503.   return msgwindow
  504. end
  505.  
  506. def pbDisposeMessageWindow(msgwindow)
  507.   $game_temp.message_window_showing=false if $game_temp
  508.   msgwindow.dispose
  509. end
  510.  
  511.  
  512.  
  513. #===============================================================================
  514. # Main message-displaying function
  515. #===============================================================================
  516. def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
  517.   return if !msgwindow
  518.   oldletterbyletter=msgwindow.letterbyletter
  519.   msgwindow.letterbyletter=(letterbyletter) ? true : false
  520.   ret=nil
  521.   commands=nil
  522.   facewindow=nil
  523.   #animport
  524.   facewindowL=nil
  525.   facewindowR=nil
  526.   goldwindow=nil
  527.   coinwindow=nil
  528.   battlepointswindow=nil
  529.   cmdvariable=0
  530.   cmdIfCancel=0
  531.   msgwindow.waitcount=0
  532.   autoresume=false
  533.   text=message.clone
  534.   msgback=nil
  535.   linecount=(Graphics.height>400) ? 3 : 2
  536.   ### Text replacement
  537.   text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
  538.     next "\\op\\cl\\ts[]\\w["+$1+"]"    # \op\cl\ts[]\w[something]
  539.   }
  540.   text.gsub!(/\\\\/,"\5")
  541.   text.gsub!(/\\1/,"\1")
  542.   if $game_actors
  543.     text.gsub!(/\\n\[([1-8])\]/i) {
  544.       m = $1.to_i
  545.       next $game_actors[m].name
  546.     }
  547.   end
  548.   text.gsub!(/\\pn/i,$Trainer.name) if $Trainer
  549.   text.gsub!(/\\pm/i,_INTL("${1}",$Trainer.money.to_s_formatted)) if $Trainer
  550.   text.gsub!(/\\n/i,"\n")
  551.   text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2="+$1+">" }
  552.   text.gsub!(/\\pg/i,"\\b") if $Trainer && $Trainer.male?
  553.   text.gsub!(/\\pg/i,"\\r") if $Trainer && $Trainer.female?
  554.   text.gsub!(/\\pog/i,"\\r") if $Trainer && $Trainer.male?
  555.   text.gsub!(/\\pog/i,"\\b") if $Trainer && $Trainer.female?
  556.   text.gsub!(/\\pg/i,"")
  557.   text.gsub!(/\\pog/i,"")
  558.   text.gsub!(/\\b/i,"<c3=3050C8,D0D0C8>")
  559.   text.gsub!(/\\r/i,"<c3=E00808,D0D0C8>")
  560.   text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
  561.     w = $1.to_s
  562.     if w==""
  563.       msgwindow.windowskin = nil
  564.     else
  565.       msgwindow.setSkin("Graphics/Windowskins/#{w}",false)
  566.     end
  567.     next ""
  568.   }
  569.   isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
  570.   text.gsub!(/\\[Cc]\[([0-9]+)\]/) {
  571.     m = $1.to_i
  572.     next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
  573.   }
  574.   loop do
  575.     last_text = text.clone
  576.     text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
  577.     break if text == last_text
  578.   end
  579.   loop do
  580.     last_text = text.clone
  581.     text.gsub!(/\\l\[([0-9]+)\]/i) {
  582.       linecount = [1,$1.to_i].max
  583.       next ""
  584.     }
  585.     break if text == last_text
  586.   end
  587.   colortag = ""
  588.   if $game_system && $game_system.respond_to?("message_frame") &&
  589.      $game_system.message_frame != 0
  590.     colortag = getSkinColor(msgwindow.windowskin,0,true)
  591.   else
  592.     colortag = getSkinColor(msgwindow.windowskin,0,isDarkSkin)
  593.   end
  594.   text = colortag+text
  595.   ### Controls
  596.   textchunks=[]
  597.   controls=[]
  598.   #animport
  599.   while text[/(?:\\(f|ml|mr|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
  600.     textchunks.push($~.pre_match)
  601.     if $~[1]
  602.       controls.push([$~[1].downcase,$~[2],-1])
  603.     else
  604.       controls.push([$~[3].downcase,"",-1])
  605.     end
  606.     text=$~.post_match
  607.   end
  608.   textchunks.push(text)
  609.   for chunk in textchunks
  610.     chunk.gsub!(/\005/,"\\")
  611.   end
  612.   textlen = 0
  613.   for i in 0...controls.length
  614.     control = controls[i][0]
  615.     case control
  616.     when "wt", "wtnp", ".", "|"
  617.       textchunks[i] += "\2"
  618.     when "!"
  619.       textchunks[i] += "\1"
  620.     end
  621.     textlen += toUnformattedText(textchunks[i]).scan(/./m).length
  622.     controls[i][2] = textlen
  623.   end
  624.   text = textchunks.join("")
  625.   signWaitCount = 0
  626.   signWaitTime = Graphics.frame_rate/2
  627.   haveSpecialClose = false
  628.   specialCloseSE = ""
  629.   for i in 0...controls.length
  630.     control = controls[i][0]
  631.     param = controls[i][1]
  632.     case control
  633.     when "op"
  634.       signWaitCount = signWaitTime+1
  635.     when "cl"
  636.       text = text.sub(/\001\z/,"")   # fix: '$' can match end of line as well
  637.       haveSpecialClose = true
  638.       specialCloseSE = param
  639.     when "f"
  640.       facewindow.dispose if facewindow
  641.       facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
  642.     #animport
  643.     when "ml" # Mug Shot (Left)
  644.       facewindowL.dispose if facewindowL
  645.       facewindowL=FaceWindowVXNew.new(param)
  646.       facewindowL.x=8
  647.       facewindowL.y=146-32
  648.     when "mr" # Mug Shot (Right)
  649.       facewindowR.dispose if facewindowR
  650.       facewindowR=FaceWindowVXNew.new(param)
  651.       facewindowR.x=320
  652.       facewindowR.y=146-32
  653.     when "ff"
  654.       facewindow.dispose if facewindow
  655.       facewindow = FaceWindowVX.new(param)
  656.     when "ch"
  657.       cmds = param.clone
  658.       cmdvariable = pbCsvPosInt!(cmds)
  659.       cmdIfCancel = pbCsvField!(cmds).to_i
  660.       commands = []
  661.       while cmds.length>0
  662.         commands.push(pbCsvField!(cmds))
  663.       end
  664.     when "wtnp", "^"
  665.       text = text.sub(/\001\z/,"")   # fix: '$' can match end of line as well
  666.     when "se"
  667.       if controls[i][2]==0
  668.         startSE = param
  669.         controls[i] = nil
  670.       end
  671.     end
  672.   end
  673.   if startSE!=nil
  674.     pbSEPlay(pbStringToAudioFile(startSE))
  675.   elsif signWaitCount==0 && letterbyletter
  676.     pbPlayDecisionSE()
  677.   end
  678.   ########## Position message window  ##############
  679.   pbRepositionMessageWindow(msgwindow,linecount)
  680.   if facewindow
  681.     pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  682.     facewindow.viewport = msgwindow.viewport
  683.     facewindow.z        = msgwindow.z
  684.   end
  685.   #animport
  686.   if facewindowL
  687.     facewindowL.viewport=msgwindow.viewport
  688.     facewindowL.z=msgwindow.z
  689.   end
  690.   if facewindowR
  691.     facewindowR.viewport=msgwindow.viewport
  692.     facewindowR.z=msgwindow.z
  693.   end
  694.   atTop = (msgwindow.y==0)
  695.   ########## Show text #############################
  696.   msgwindow.text = text
  697.   Graphics.frame_reset if Graphics.frame_rate>40
  698.   loop do
  699.     if signWaitCount>0
  700.       signWaitCount -= 1
  701.       if atTop
  702.         msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
  703.       else
  704.         msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
  705.       end
  706.     end
  707.     for i in 0...controls.length
  708.       next if !controls[i]
  709.       next if controls[i][2]>msgwindow.position || msgwindow.waitcount!=0
  710.       control = controls[i][0]
  711.       param = controls[i][1]
  712.       case control
  713.       when "f"
  714.         facewindow.dispose if facewindow
  715.         facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
  716.         pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  717.         facewindow.viewport = msgwindow.viewport
  718.         facewindow.z        = msgwindow.z
  719. #animport
  720.       when "ml" # Mug Shot (Left)
  721.         facewindowL.dispose if facewindowL
  722.         facewindowL=FaceWindowVXNew.new(param)
  723.         facewindowL.windowskin=nil
  724.         facewindowL.x=8
  725.         facewindowL.y=146-32
  726.         facewindowL.viewport=msgwindow.viewport
  727.         facewindowL.z=msgwindow.z
  728.       when "mr" # Mug Shot (Right)
  729.         facewindowR.dispose if facewindowR
  730.         facewindowR=FaceWindowVXNew.new(param)
  731.         facewindowR.windowskin=nil
  732.         facewindowR.x=320
  733.         facewindowR.y=146-32
  734.         facewindowR.viewport=msgwindow.viewport
  735.         facewindowR.z=msgwindow.z
  736.       when "ff"
  737.         facewindow.dispose if facewindow
  738.         facewindow = FaceWindowVX.new(param)
  739.         pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  740.         facewindow.viewport = msgwindow.viewport
  741.         facewindow.z        = msgwindow.z
  742.       when "g"      # Display gold window
  743.         goldwindow.dispose if goldwindow
  744.         goldwindow = pbDisplayGoldWindow(msgwindow)
  745.       when "cn"     # Display coins window
  746.         coinwindow.dispose if coinwindow
  747.         coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
  748.       when "pt"     # Display battle points window
  749.         battlepointswindow.dispose if battlepointswindow
  750.         battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
  751.       when "wu"
  752.         msgwindow.y = 0
  753.         atTop = true
  754.         msgback.y = msgwindow.y if msgback
  755.         pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  756.         msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
  757.       when "wm"
  758.         atTop = false
  759.         msgwindow.y = (Graphics.height-msgwindow.height)/2
  760.         msgback.y = msgwindow.y if msgback
  761.         pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  762.       when "wd"
  763.         atTop = false
  764.         msgwindow.y = Graphics.height-msgwindow.height
  765.         msgback.y = msgwindow.y if msgback
  766.         pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  767.         msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
  768.       when "ts"     # Change text speed
  769.         msgwindow.textspeed = (param=="") ? -999 : param.to_i
  770.       when "."      # Wait 0.25 seconds
  771.         msgwindow.waitcount += Graphics.frame_rate/4
  772.       when "|"      # Wait 1 second
  773.         msgwindow.waitcount += Graphics.frame_rate
  774.       when "wt"     # Wait X/20 seconds
  775.         param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
  776.         msgwindow.waitcount += param.to_i*Graphics.frame_rate/20
  777.       when "wtnp"   # Wait X/20 seconds, no pause
  778.         param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
  779.         msgwindow.waitcount = param.to_i*Graphics.frame_rate/20
  780.         autoresume = true
  781.       when "^"      # Wait, no pause
  782.         autoresume = true
  783.       when "se"     # Play SE
  784.         pbSEPlay(pbStringToAudioFile(param))
  785.       when "me"     # Play ME
  786.         pbMEPlay(pbStringToAudioFile(param))
  787.       end
  788.       controls[i] = nil
  789.     end
  790.     break if !letterbyletter
  791.     Graphics.update
  792.     Input.update
  793.     facewindow.update if facewindow
  794.     #animport
  795.     facewindowL.update if facewindowL
  796.     facewindowR.update if facewindowR
  797.     if autoresume && msgwindow.waitcount==0
  798.       msgwindow.resume if msgwindow.busy?
  799.       break if !msgwindow.busy?
  800.     end
  801.     if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
  802.       if msgwindow.busy?
  803.         pbPlayDecisionSE if msgwindow.pausing?
  804.         msgwindow.resume
  805.       else
  806.         break if signWaitCount==0
  807.       end
  808.     end
  809.     pbUpdateSceneMap
  810.     msgwindow.update
  811.     yield if block_given?
  812.     break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
  813.   end
  814.   Input.update   # Must call Input.update again to avoid extra triggers
  815.   msgwindow.letterbyletter=oldletterbyletter
  816.   if commands
  817.     $game_variables[cmdvariable]=pbShowCommands(msgwindow,commands,cmdIfCancel)
  818.     $game_map.need_refresh = true if $game_map
  819.   end
  820.   if commandProc
  821.     ret=commandProc.call(msgwindow)
  822.   end
  823.   msgback.dispose if msgback
  824.   goldwindow.dispose if goldwindow
  825.   coinwindow.dispose if coinwindow
  826.   battlepointswindow.dispose if battlepointswindow
  827.   facewindow.dispose if facewindow
  828.   #animport
  829.   facewindowL.dispose if facewindowL
  830.   facewindowR.dispose if facewindowR
  831.   if haveSpecialClose
  832.     pbSEPlay(pbStringToAudioFile(specialCloseSE))
  833.     atTop = (msgwindow.y==0)
  834.     for i in 0..signWaitTime
  835.       if atTop
  836.         msgwindow.y = -msgwindow.height*i/signWaitTime
  837.       else
  838.         msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-i)/signWaitTime
  839.       end
  840.       Graphics.update
  841.       Input.update
  842.       pbUpdateSceneMap
  843.       msgwindow.update
  844.     end
  845.   end
  846.   return ret
  847. end
  848.  
  849.  
  850.  
  851. #===============================================================================
  852. # Message-displaying functions
  853. #===============================================================================
  854. def pbMessage(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block)
  855.   ret = 0
  856.   msgwindow = pbCreateMessageWindow(nil,skin)
  857.   if commands
  858.     ret = pbMessageDisplay(msgwindow,message,true,
  859.        proc { |msgwindow|
  860.          next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
  861.        },&block)
  862.   else
  863.     pbMessageDisplay(msgwindow,message,&block)
  864.   end
  865.   pbDisposeMessageWindow(msgwindow)
  866.   Input.update
  867.   return ret
  868. end
  869.  
  870. def pbConfirmMessage(message,&block)
  871.   return (pbMessage(message,[_INTL("Yes"),_INTL("No")],2,&block)==0)
  872. end
  873.  
  874. def pbConfirmMessageSerious(message,&block)
  875.   return (pbMessage(message,[_INTL("No"),_INTL("Yes")],1,&block)==1)
  876. end
  877.  
  878. def pbMessageChooseNumber(message,params,&block)
  879.   msgwindow = pbCreateMessageWindow(nil,params.messageSkin)
  880.   ret = pbMessageDisplay(msgwindow,message,true,
  881.      proc { |msgwindow|
  882.        next pbChooseNumber(msgwindow,params,&block)
  883.      },&block)
  884.   pbDisposeMessageWindow(msgwindow)
  885.   return ret
  886. end
  887.  
  888. def pbShowCommands(msgwindow,commands=nil,cmdIfCancel=0,defaultCmd=0)
  889.   return 0 if !commands
  890.   cmdwindow=Window_CommandPokemonEx.new(commands)
  891.   cmdwindow.z=99999
  892.   cmdwindow.visible=true
  893.   cmdwindow.resizeToFit(cmdwindow.commands)
  894.   pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
  895.   cmdwindow.index=defaultCmd
  896.   command=0
  897.   loop do
  898.     Graphics.update
  899.     Input.update
  900.     cmdwindow.update
  901.     msgwindow.update if msgwindow
  902.     yield if block_given?
  903.     if Input.trigger?(Input::BACK)
  904.       if cmdIfCancel>0
  905.         command=cmdIfCancel-1
  906.         break
  907.       elsif cmdIfCancel<0
  908.         command=cmdIfCancel
  909.         break
  910.       end
  911.     end
  912.     if Input.trigger?(Input::USE)
  913.       command=cmdwindow.index
  914.       break
  915.     end
  916.     pbUpdateSceneMap
  917.   end
  918.   ret=command
  919.   cmdwindow.dispose
  920.   Input.update
  921.   return ret
  922. end
  923.  
  924. def pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel=0,defaultCmd=0)
  925.   msgwin=msgwindow
  926.   msgwin=pbCreateMessageWindow(nil) if !msgwindow
  927.   oldlbl=msgwin.letterbyletter
  928.   msgwin.letterbyletter=false
  929.   if commands
  930.     cmdwindow=Window_CommandPokemonEx.new(commands)
  931.     cmdwindow.z=99999
  932.     cmdwindow.visible=true
  933.     cmdwindow.resizeToFit(cmdwindow.commands)
  934.     cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y
  935.     cmdwindow.index=defaultCmd
  936.     command=0
  937.     msgwin.text=help[cmdwindow.index]
  938.     msgwin.width=msgwin.width   # Necessary evil to make it use the proper margins
  939.     loop do
  940.       Graphics.update
  941.       Input.update
  942.       oldindex=cmdwindow.index
  943.       cmdwindow.update
  944.       if oldindex!=cmdwindow.index
  945.         msgwin.text=help[cmdwindow.index]
  946.       end
  947.       msgwin.update
  948.       yield if block_given?
  949.       if Input.trigger?(Input::BACK)
  950.         if cmdIfCancel>0
  951.           command=cmdIfCancel-1
  952.           break
  953.         elsif cmdIfCancel<0
  954.           command=cmdIfCancel
  955.           break
  956.         end
  957.       end
  958.       if Input.trigger?(Input::USE)
  959.         command=cmdwindow.index
  960.         break
  961.       end
  962.       pbUpdateSceneMap
  963.     end
  964.     ret=command
  965.     cmdwindow.dispose
  966.     Input.update
  967.   end
  968.   msgwin.letterbyletter=oldlbl
  969.   msgwin.dispose if !msgwindow
  970.   return ret
  971. end
  972.  
  973. # frames is the number of 1/20 seconds to wait for
  974. def pbMessageWaitForInput(msgwindow,frames,showPause=false)
  975.   return if !frames || frames<=0
  976.   msgwindow.startPause if msgwindow && showPause
  977.   frames = frames*Graphics.frame_rate/20
  978.   frames.times do
  979.     Graphics.update
  980.     Input.update
  981.     msgwindow.update if msgwindow
  982.     pbUpdateSceneMap
  983.     if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
  984.       break
  985.     end
  986.     yield if block_given?
  987.   end
  988.   msgwindow.stopPause if msgwindow && showPause
  989. end
  990.  
  991. def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width=240)
  992.   window=Window_TextEntry_Keyboard.new(currenttext,0,0,width,64)
  993.   ret=""
  994.   window.maxlength=maxlength
  995.   window.visible=true
  996.   window.z=99999
  997.   pbPositionNearMsgWindow(window,msgwindow,:right)
  998.   window.text=currenttext
  999.   window.passwordChar="*" if passwordbox
  1000.   Input.text_input = true
  1001.   loop do
  1002.     Graphics.update
  1003.     Input.update
  1004.     if Input.triggerex?(:ESCAPE)
  1005.       ret=currenttext
  1006.       break
  1007.     elsif Input.triggerex?(:RETURN)
  1008.       ret=window.text
  1009.       break
  1010.     end
  1011.     window.update
  1012.     msgwindow.update if msgwindow
  1013.     yield if block_given?
  1014.   end
  1015.   Input.text_input = false
  1016.   window.dispose
  1017.   Input.update
  1018.   return ret
  1019. end
  1020.  
  1021. def pbMessageFreeText(message,currenttext,passwordbox,maxlength,width=240,&block)
  1022.   msgwindow=pbCreateMessageWindow
  1023.   retval=pbMessageDisplay(msgwindow,message,true,
  1024.      proc { |msgwindow|
  1025.        next pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width,&block)
  1026.      },&block)
  1027.   pbDisposeMessageWindow(msgwindow)
  1028.   return retval
  1029. end
  1030.  
  1031. #animport
  1032.  
  1033. class FaceWindowVXNew < SpriteWindow_Base
  1034.   def initialize(face)
  1035.     super(0,0,192,192)
  1036.     self.windowskin=nil
  1037.     faceinfo=face.split(",")
  1038.     facefile=pbResolveBitmap("Graphics/Mugshots/"+faceinfo[0])
  1039.     facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
  1040.     self.contents.dispose if self.contents
  1041.     @faceIndex=faceinfo[1].to_i
  1042.     @facebitmaptmp=AnimatedBitmap.new(facefile)
  1043.     @facebitmap=BitmapWrapper.new(160,160)
  1044.     @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  1045.        (@faceIndex % 4) * 160,
  1046.        (@faceIndex / 4) * 160, 160, 160
  1047.     ))
  1048.     self.contents=@facebitmap
  1049.   end
  1050.  
  1051.   def update
  1052.     super
  1053.     if @facebitmaptmp.totalFrames>1
  1054.       @facebitmaptmp.update
  1055.       @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  1056.          (@faceIndex % 4) * 160,
  1057.          (@faceIndex / 4) * 160, 160, 160
  1058.       ))
  1059.     end
  1060.   end
  1061.  
  1062.   def dispose
  1063.     @facebitmaptmp.dispose
  1064.     @facebitmap.dispose if @facebitmap
  1065.     super
  1066.   end
  1067. end
  1068.  
  1069. class FaceWindowVXNew < SpriteWindow_Base
  1070.   def initialize(face)
  1071.     super(0,0,192,192)
  1072.     self.windowskin=nil
  1073.     faceinfo=face.split(",")
  1074.     facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0]) #Tech added this- not sure why it wasn't in the original?
  1075.     facefile=pbResolveBitmap("Graphics/Mugshots/"+faceinfo[0]) if !facefile
  1076.     facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
  1077.     self.contents.dispose if self.contents
  1078.     @faceIndex=faceinfo[1].to_i
  1079.     @facebitmaptmp=AnimatedBitmap.new(facefile)
  1080.     @facebitmap=BitmapWrapper.new(160,160)
  1081.     @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  1082.        (@faceIndex % 4) * 160,
  1083.        (@faceIndex / 4) * 160, 160, 160
  1084.     ))
  1085.     self.contents=@facebitmap
  1086.   end
  1087.  
  1088.   def update
  1089.     super
  1090.     if @facebitmaptmp.totalFrames>1
  1091.       @facebitmaptmp.update
  1092.       @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  1093.          (@faceIndex % 4) * 160,
  1094.          (@faceIndex / 4) * 160, 160, 160
  1095.       ))
  1096.     end
  1097.   end
  1098.  
  1099.   def dispose
  1100.     @facebitmaptmp.dispose
  1101.     @facebitmap.dispose if @facebitmap
  1102.     super
  1103.   end
  1104. end
Add Comment
Please, Sign In to add comment