Advertisement
polectron

Untitled

Dec 28th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.21 KB | None | 0 0
  1. class Game_Temp
  2. attr_writer :message_window_showing
  3. attr_writer :player_transferring
  4. attr_writer :transition_processing
  5.  
  6. def message_window_showing
  7. @message_window_showing=false if !@message_window_showing
  8. return @message_window_showing
  9. end
  10.  
  11. def player_transferring
  12. @player_transferring=false if !@player_transferring
  13. return @player_transferring
  14. end
  15.  
  16. def transition_processing
  17. @transition_processing=false if !@transition_processing
  18. return @transition_processing
  19. end
  20. end
  21.  
  22.  
  23.  
  24. class Game_Message
  25. attr_writer :background, :visible
  26. def visible; return @visible ? @visible : false; end
  27. def background; return @background ? @background : 0; end
  28. end
  29.  
  30.  
  31.  
  32. class Game_System
  33. attr_writer :message_position
  34.  
  35. def message_position
  36. @message_position=2 if !@message_position
  37. return @message_position
  38. end
  39. end
  40.  
  41.  
  42.  
  43. #########
  44.  
  45. class Scene_Map
  46. def updatemini
  47. oldmws=$game_temp.message_window_showing
  48. oldvis=$game_message ? $game_message.visible : false
  49. $game_temp.message_window_showing=true
  50. $game_message.visible=true if $game_message
  51. loop do
  52. $game_map.update
  53. $game_player.update
  54. $game_system.update
  55. if $game_screen
  56. $game_screen.update
  57. else
  58. $game_map.screen.update
  59. end
  60. unless $game_temp.player_transferring
  61. break
  62. end
  63. transfer_player
  64. if $game_temp.transition_processing
  65. break
  66. end
  67. end
  68. $game_temp.message_window_showing=oldmws
  69. $game_message.visible=oldvis if $game_message
  70. @spriteset.update if @spriteset
  71. @message_window.update if @message_window
  72. end
  73. end
  74.  
  75.  
  76.  
  77. class Scene_Battle
  78. def updatemini
  79. if self.respond_to?("update_basic")
  80. update_basic(true)
  81. update_info_viewport # Update information viewport
  82. if $game_message && $game_message.visible
  83. @info_viewport.visible = false
  84. @message_window.visible = true
  85. end
  86. else
  87. oldmws=$game_temp.message_window_showing
  88. $game_temp.message_window_showing=true
  89. # Update system (timer) and screen
  90. $game_system.update
  91. if $game_screen
  92. $game_screen.update
  93. else
  94. $game_map.screen.update
  95. end
  96. # If timer has reached 0
  97. if $game_system.timer_working and $game_system.timer == 0
  98. # Abort battle
  99. $game_temp.battle_abort = true
  100. end
  101. # Update windows
  102. @help_window.update if @help_window
  103. @party_command_window.update if @party_command_window
  104. @actor_command_window.update if @actor_command_window
  105. @status_window.update if @status_window
  106. $game_temp.message_window_showing=oldmws
  107. @message_window.update if @message_window
  108. # Update sprite set
  109. @spriteset.update if @spriteset
  110. end
  111. end
  112. end
  113.  
  114.  
  115.  
  116. def pbMapInterpreterRunning?
  117. interp=pbMapInterpreter
  118. return interp && interp.running?
  119. end
  120.  
  121. def pbMapInterpreter
  122. if $game_map && $game_map.respond_to?("interpreter")
  123. return $game_map.interpreter
  124. elsif $game_system
  125. return $game_system.map_interpreter
  126. end
  127. return nil
  128. end
  129.  
  130. def pbRefreshSceneMap
  131. if $scene && $scene.is_a?(Scene_Map)
  132. if $scene.respond_to?("miniupdate")
  133. $scene.miniupdate
  134. else
  135. $scene.updatemini
  136. end
  137. elsif $scene && $scene.is_a?(Scene_Battle)
  138. $scene.updatemini
  139. end
  140. end
  141.  
  142. def pbUpdateSceneMap
  143. if $scene && $scene.is_a?(Scene_Map) && !pbIsFaded?
  144. if $scene.respond_to?("miniupdate")
  145. $scene.miniupdate
  146. else
  147. $scene.updatemini
  148. end
  149. elsif $scene && $scene.is_a?(Scene_Battle)
  150. $scene.updatemini
  151. end
  152. end
  153. #########
  154.  
  155. def pbCsvField!(str)
  156. ret=""
  157. str.sub!(/\A\s*/,"")
  158. if str[0,1]=="\""
  159. str[0,1]=""
  160. escaped=false
  161. fieldbytes=0
  162. str.scan(/./) do |s|
  163. fieldbytes+=s.length
  164. break if s=="\"" && !escaped
  165. if s=="\\" && !escaped
  166. escaped=true
  167. else
  168. ret+=s
  169. escaped=false
  170. end
  171. end
  172. str[0,fieldbytes]=""
  173. if !str[/\A\s*,/] && !str[/\A\s*$/]
  174. raise _INTL("Invalid quoted field (in: {1})",ret)
  175. end
  176. str[0,str.length]=$~.post_match
  177. else
  178. if str[/,/]
  179. str[0,str.length]=$~.post_match
  180. ret=$~.pre_match
  181. else
  182. ret=str.clone
  183. str[0,str.length]=""
  184. end
  185. ret.gsub!(/\s+$/,"")
  186. end
  187. return ret
  188. end
  189.  
  190. def pbCsvPosInt!(str)
  191. ret=pbCsvField!(str)
  192. if !ret[/\A\d+$/]
  193. raise _INTL("Field {1} is not a positive integer",ret)
  194. end
  195. return ret.to_i
  196. end
  197.  
  198. def pbEventCommentInput(*args)
  199. parameters = []
  200. list = *args[0].list # Event or event page
  201. elements = *args[1] # Number of elements
  202. trigger = *args[2] # Trigger
  203. return nil if list == nil
  204. return nil unless list.is_a?(Array)
  205. for item in list
  206. next unless item.code == 108 || item.code == 408
  207. if item.parameters[0] == trigger
  208. start = list.index(item) + 1
  209. finish = start + elements
  210. for id in start...finish
  211. next if !list[id]
  212. parameters.push(list[id].parameters[0])
  213. end
  214. return parameters
  215. end
  216. end
  217. return nil
  218. end
  219.  
  220. def pbCurrentEventCommentInput(elements,trigger)
  221. return nil if !pbMapInterpreterRunning?
  222. event=pbMapInterpreter.get_character(0)
  223. return nil if !event
  224. return pbEventCommentInput(event,elements,trigger)
  225. end
  226.  
  227.  
  228.  
  229. module InterpreterMixin
  230. def pbGlobalLock # Freezes all events on the map (for use at the beginning of common events)
  231. for event in $game_map.events.values
  232. event.minilock
  233. end
  234. end
  235.  
  236. def pbGlobalUnlock # Unfreezes all events on the map (for use at the end of common events)
  237. for event in $game_map.events.values
  238. event.unlock
  239. end
  240. end
  241.  
  242. def pbRepeatAbove(index)
  243. index=@list[index].indent
  244. loop do
  245. index-=1
  246. if @list[index].indent==indent
  247. return index+1
  248. end
  249. end
  250. end
  251.  
  252. def pbBreakLoop(index)
  253. indent = @list[index].indent
  254. temp_index=index
  255. # Copy index to temporary variables
  256. loop do
  257. # Advance index
  258. temp_index += 1
  259. # If a fitting loop was not found
  260. if temp_index >= @list.size-1
  261. return index+1
  262. end
  263. if @list[temp_index].code == 413 and @list[temp_index].indent < indent
  264. return temp_index+1
  265. end
  266. end
  267. end
  268.  
  269. def pbJumpToLabel(index,label_name)
  270. temp_index = 0
  271. loop do
  272. if temp_index >= @list.size-1
  273. return index+1
  274. end
  275. if @list[temp_index].code == 118 and
  276. @list[temp_index].parameters[0] == label_name
  277. return temp_index+1
  278. end
  279. temp_index += 1
  280. end
  281. end
  282.  
  283. # Gets the next index in the interpreter, ignoring
  284. # certain events between messages
  285. def pbNextIndex(index)
  286. return -1 if !@list || @list.length==0
  287. i=index+1
  288. loop do
  289. if i>=@list.length-1
  290. return i
  291. end
  292. code=@list[i].code
  293. case code
  294. when 118, 108, 408 # Label, Comment
  295. i+=1
  296. when 413 # Repeat Above
  297. i=pbRepeatAbove(i)
  298. when 113 # Break Loop
  299. i=pbBreakLoop(i)
  300. when 119 # Jump to Label
  301. newI=pbJumpToLabel(i,@list[i].parameters[0])
  302. if newI>i
  303. i=newI
  304. else
  305. i+=1
  306. end
  307. else
  308. return i
  309. end
  310. end
  311. end
  312.  
  313. # Helper function that shows a picture in a script. To be used in
  314. # a script event command.
  315. def pbShowPicture(number,name,origin,x,y,zoomX=100,zoomY=100,opacity=255,blendType=0)
  316. number = number + ($game_temp.in_battle ? 50 : 0)
  317. $game_screen.pictures[number].show(name,origin,
  318. x, y, zoomX,zoomY,opacity,blendType)
  319. end
  320.  
  321. # Erases an event and adds it to the list of erased events so that
  322. # it can stay erased when the game is saved then loaded again. To be used in
  323. # a script event command.
  324. def pbEraseThisEvent
  325. if $game_map.events[@event_id]
  326. $game_map.events[@event_id].erase
  327. $PokemonMap.addErasedEvent(@event_id) if $PokemonMap
  328. end
  329. @index+=1
  330. return true
  331. end
  332.  
  333. # Runs a common event. To be used in a script event command.
  334. def pbCommonEvent(id)
  335. if $game_temp.in_battle
  336. $game_temp.common_event_id = id
  337. else
  338. commonEvent = $data_common_events[id]
  339. $game_system.battle_interpreter.setup(commonEvent.list, 0)
  340. end
  341. end
  342.  
  343. # Sets another event's self switch (eg. pbSetSelfSwitch(20,"A",true) ).
  344. # To be used in a script event command.
  345. def pbSetSelfSwitch(event,swtch,value)
  346. $game_self_switches[[@map_id,event,swtch]]=value
  347. $game_map.need_refresh = true
  348. end
  349.  
  350. # Must use this approach to share the methods because the methods already
  351. # defined in a class override those defined in an included module
  352. CustomEventCommands=<<_END_
  353.  
  354. def command_242
  355. pbBGMFade(pbParams[0])
  356. return true
  357. end
  358.  
  359. def command_246
  360. pbBGSFade(pbParams[0])
  361. return true
  362. end
  363.  
  364. def command_251
  365. pbSEStop()
  366. return true
  367. end
  368.  
  369. def command_241
  370. pbBGMPlay(pbParams[0])
  371. return true
  372. end
  373.  
  374. def command_245
  375. pbBGSPlay(pbParams[0])
  376. return true
  377. end
  378.  
  379. def command_249
  380. pbMEPlay(pbParams[0])
  381. return true
  382. end
  383.  
  384. def command_250
  385. pbSEPlay(pbParams[0])
  386. return true
  387. end
  388. _END_
  389. end
  390.  
  391.  
  392.  
  393. def pbButtonInputProcessing(variableNumber=0,timeoutFrames=0)
  394. ret=0
  395. loop do
  396. Graphics.update
  397. Input.update
  398. pbUpdateSceneMap
  399. for i in 1..18
  400. if Input.trigger?(i)
  401. ret=i
  402. end
  403. end
  404. break if ret!=0
  405. if timeoutFrames && timeoutFrames>0
  406. i+=1
  407. break if i>=timeoutFrames
  408. end
  409. end
  410. Input.update
  411. if variableNumber && variableNumber>0
  412. $game_variables[variableNumber]=ret
  413. $game_map.need_refresh = true if $game_map
  414. end
  415. return ret
  416. end
  417.  
  418.  
  419.  
  420. class Game_Temp
  421. attr_accessor :background
  422. end
  423.  
  424.  
  425.  
  426. class Game_Interpreter # Used by RMVX
  427. include InterpreterMixin
  428. eval(InterpreterMixin::CustomEventCommands)
  429. @@immediateDisplayAfterWait=false
  430. @buttonInput=false
  431.  
  432. def pbParams
  433. return @params
  434. end
  435.  
  436. def command_105
  437. return false if @buttonInput
  438. @buttonInput=true
  439. pbButtonInputProcessing(@list[@index].parameters[0])
  440. @buttonInput=false
  441. @index+=1
  442. return true
  443. end
  444.  
  445. def command_101
  446. if $game_temp.message_window_showing
  447. return false
  448. end
  449. $game_message=Game_Message.new if !$game_message
  450. message=""
  451. commands=nil
  452. numInputVar=nil
  453. numInputDigitsMax=nil
  454. text=""
  455. facename=@list[@index].parameters[0]
  456. faceindex=@list[@index].parameters[1]
  457. if facename && facename!=""
  458. text+="\\ff[#{facename},#{faceindex}]"
  459. end
  460. if $game_message
  461. $game_message.background=@list[@index].parameters[2]
  462. end
  463. $game_system.message_position=@list[@index].parameters[3]
  464. message+=text
  465. messageend=""
  466. loop do
  467. nextIndex=pbNextIndex(@index)
  468. code=@list[nextIndex].code
  469. if code == 401
  470. text=@list[nextIndex].parameters[0]
  471. text+=" " if text!="" && text[text.length-1,1]!=" "
  472. message+=text
  473. @index=nextIndex
  474. else
  475. if code == 102
  476. commands=@list[nextIndex].parameters
  477. @index=nextIndex
  478. elsif code == 106 && @@immediateDisplayAfterWait
  479. params=@list[nextIndex].parameters
  480. if params[0]<=10
  481. nextcode=@list[nextIndex+1].code
  482. if nextcode==101||nextcode==102||nextcode==103
  483. @index=nextIndex
  484. else
  485. break
  486. end
  487. else
  488. break
  489. end
  490. elsif code == 103
  491. numInputVar=@list[nextIndex].parameters[0]
  492. numInputDigitsMax=@list[nextIndex].parameters[1]
  493. @index=nextIndex
  494. elsif code == 101
  495. messageend="\1"
  496. end
  497. break
  498. end
  499. end
  500. message=_MAPINTL($game_map.map_id,message)
  501. @message_waiting=true
  502. if commands
  503. cmdlist=[]
  504. for cmd in commands[0]
  505. cmdlist.push(_MAPINTL($game_map.map_id,cmd))
  506. end
  507. command=Kernel.pbMessage(message+messageend,cmdlist,commands[1])
  508. @branch[@list[@index].indent] = command
  509. elsif numInputVar
  510. params=ChooseNumberParams.new
  511. params.setMaxDigits(numInputDigitsMax)
  512. params.setDefaultValue($game_variables[numInputVar])
  513. $game_variables[numInputVar]=Kernel.pbMessageChooseNumber(message+messageend,params)
  514. $game_map.need_refresh = true if $game_map
  515. else
  516. Kernel.pbMessage(message+messageend)
  517. end
  518. @message_waiting=false
  519. return true
  520. end
  521.  
  522. def command_102
  523. @message_waiting=true
  524. command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1])
  525. @message_waiting=false
  526. @branch[@list[@index].indent] = command
  527. Input.update # Must call Input.update again to avoid extra triggers
  528. return true
  529. end
  530.  
  531. def command_103
  532. varnumber=@list[@index].parameters[0]
  533. @message_waiting=true
  534. params=ChooseNumberParams.new
  535. params.setMaxDigits(@list[@index].parameters[1])
  536. params.setDefaultValue($game_variables[varnumber])
  537. $game_variables[varnumber]=Kernel.pbChooseNumber(nil,params)
  538. $game_map.need_refresh = true if $game_map
  539. @message_waiting=false
  540. return true
  541. end
  542. end
  543.  
  544.  
  545.  
  546. class Interpreter # Used by RMXP
  547. include InterpreterMixin
  548. eval(InterpreterMixin::CustomEventCommands)
  549. @@immediateDisplayAfterWait=false
  550. @buttonInput=false
  551.  
  552. def pbParams
  553. return @parameters
  554. end
  555.  
  556. def command_105
  557. return false if @buttonInput
  558. @buttonInput=true
  559. pbButtonInputProcessing(@list[@index].parameters[0])
  560. @buttonInput=false
  561. @index+=1
  562. return true
  563. end
  564.  
  565. def command_101
  566. if $game_temp.message_window_showing
  567. return false
  568. end
  569. message=""
  570. commands=nil
  571. numInputVar=nil
  572. numInputDigitsMax=nil
  573. text=""
  574. firstText=nil
  575. if @list[@index].parameters.length==1
  576. text+=@list[@index].parameters[0]
  577. firstText=@list[@index].parameters[0]
  578. text+=" " if text[text.length-1,1]!=" "
  579. message+=text
  580. else
  581. facename=@list[@index].parameters[0]
  582. faceindex=@list[@index].parameters[1]
  583. if facename && facename!=""
  584. text+="\\ff[#{facename},#{faceindex}]"
  585. message+=text
  586. end
  587. end
  588. messageend=""
  589. loop do
  590. nextIndex=pbNextIndex(@index)
  591. code=@list[nextIndex].code
  592. if code == 401
  593. text=@list[nextIndex].parameters[0]
  594. text+=" " if text[text.length-1,1]!=" "
  595. message+=text
  596. @index=nextIndex
  597. else
  598. if code == 102
  599. commands=@list[nextIndex].parameters
  600. @index=nextIndex
  601. elsif code == 106 && @@immediateDisplayAfterWait
  602. params=@list[nextIndex].parameters
  603. if params[0]<=10
  604. nextcode=@list[nextIndex+1].code
  605. if nextcode==101||nextcode==102||nextcode==103
  606. @index=nextIndex
  607. else
  608. break
  609. end
  610. else
  611. break
  612. end
  613. elsif code == 103
  614. numInputVar=@list[nextIndex].parameters[0]
  615. numInputDigitsMax=@list[nextIndex].parameters[1]
  616. @index=nextIndex
  617. elsif code == 101
  618. if @list[@index].parameters.length==1
  619. text=@list[@index].parameters[0]
  620. if text[/\A\\ignr/] && text==firstText
  621. text+=" " if text[text.length-1,1]!=" "
  622. message+=text
  623. @index=nextIndex
  624. continue
  625. end
  626. end
  627. messageend="\1"
  628. end
  629. break
  630. end
  631. end
  632. @message_waiting=true # needed to allow parallel process events to work while
  633. # a message is displayed
  634. message=_MAPINTL($game_map.map_id,message)
  635. if commands
  636. cmdlist=[]
  637. for cmd in commands[0]
  638. cmdlist.push(_MAPINTL($game_map.map_id,cmd))
  639. end
  640. command=Kernel.pbMessage(message+messageend,cmdlist,commands[1])
  641. @branch[@list[@index].indent] = command
  642. elsif numInputVar
  643. params=ChooseNumberParams.new
  644. params.setMaxDigits(numInputDigitsMax)
  645. params.setDefaultValue($game_variables[numInputVar])
  646. $game_variables[numInputVar]=Kernel.pbMessageChooseNumber(message+messageend,params)
  647. $game_map.need_refresh = true if $game_map
  648. else
  649. Kernel.pbMessage(message+messageend,nil)
  650. end
  651. @message_waiting=false
  652. return true
  653. end
  654.  
  655. def command_102
  656. @message_waiting=true
  657. command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1])
  658. @message_waiting=false
  659. @branch[@list[@index].indent] = command
  660. Input.update # Must call Input.update again to avoid extra triggers
  661. return true
  662. end
  663.  
  664. def command_103
  665. varnumber=@list[@index].parameters[0]
  666. @message_waiting=true
  667. params=ChooseNumberParams.new
  668. params.setMaxDigits(@list[@index].parameters[1])
  669. params.setDefaultValue($game_variables[varnumber])
  670. $game_variables[varnumber]=Kernel.pbChooseNumber(nil,params)
  671. $game_map.need_refresh = true if $game_map
  672. @message_waiting=false
  673. return true
  674. end
  675. end
  676.  
  677.  
  678.  
  679. class ChooseNumberParams
  680. def initialize
  681. @maxDigits=0
  682. @minNumber=0
  683. @maxNumber=0
  684. @skin=nil
  685. @messageSkin=nil
  686. @negativesAllowed=false
  687. @initialNumber=0
  688. @cancelNumber=nil
  689. end
  690.  
  691. def setMessageSkin(value)
  692. @messageSkin=value
  693. end
  694.  
  695. def messageSkin # Set the full path for the message's window skin
  696. @messageSkin
  697. end
  698.  
  699. def setSkin(value)
  700. @skin=value
  701. end
  702.  
  703. def skin
  704. @skin
  705. end
  706.  
  707. def setNegativesAllowed(value)
  708. @negativeAllowed=value
  709. end
  710.  
  711. def negativesAllowed
  712. @negativeAllowed ? true : false
  713. end
  714.  
  715. def setRange(minNumber,maxNumber)
  716. maxNumber=minNumber if minNumber>maxNumber
  717. @maxDigits=0
  718. @minNumber=minNumber
  719. @maxNumber=maxNumber
  720. end
  721.  
  722. def setDefaultValue(number)
  723. @initialNumber=number
  724. @cancelNumber=nil
  725. end
  726.  
  727. def setInitialValue(number)
  728. @initialNumber=number
  729. end
  730.  
  731. def setCancelValue(number)
  732. @cancelNumber=number
  733. end
  734.  
  735. def initialNumber
  736. return clamp(@initialNumber,self.minNumber,self.maxNumber)
  737. end
  738.  
  739. def cancelNumber
  740. return @cancelNumber ? @cancelNumber : self.initialNumber
  741. end
  742.  
  743. def minNumber
  744. ret=0
  745. if @maxDigits>0
  746. ret=-((10**@maxDigits)-1)
  747. elsif
  748. ret=@minNumber
  749. end
  750. ret=0 if !@negativeAllowed && ret<0
  751. return ret
  752. end
  753.  
  754. def maxNumber
  755. ret=0
  756. if @maxDigits>0
  757. ret=((10**@maxDigits)-1)
  758. elsif
  759. ret=@maxNumber
  760. end
  761. ret=0 if !@negativeAllowed && ret<0
  762. return ret
  763. end
  764.  
  765. def setMaxDigits(value)
  766. @maxDigits=[1,value].max
  767. end
  768.  
  769. def maxDigits
  770. if @maxDigits>0
  771. return @maxDigits
  772. else
  773. return [numDigits(self.minNumber),numDigits(self.maxNumber)].max
  774. end
  775. end
  776.  
  777. private
  778.  
  779. def clamp(v,mn,mx)
  780. return v<mn ? mn : (v>mx ? mx : v)
  781. end
  782.  
  783. def numDigits(number)
  784. ans = 1
  785. number=number.abs
  786. while number >= 10
  787. ans+=1
  788. number/=10
  789. end
  790. return ans
  791. end
  792. end
  793.  
  794.  
  795.  
  796. def pbChooseNumber(msgwindow,params)
  797. return 0 if !params
  798. ret=0
  799. maximum=params.maxNumber
  800. minimum=params.minNumber
  801. defaultNumber=params.initialNumber
  802. cancelNumber=params.cancelNumber
  803. cmdwindow=Window_InputNumberPokemon.new(params.maxDigits)
  804. cmdwindow.z=99999
  805. cmdwindow.visible=true
  806. cmdwindow.setSkin(params.skin) if params.skin
  807. cmdwindow.sign=params.negativesAllowed # must be set before number
  808. cmdwindow.number=defaultNumber
  809. curnumber=defaultNumber
  810. pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
  811. command=0
  812. loop do
  813. Graphics.update
  814. Input.update
  815. pbUpdateSceneMap
  816. cmdwindow.update
  817. msgwindow.update if msgwindow
  818. yield if block_given?
  819. if Input.trigger?(Input::C)
  820. ret=cmdwindow.number
  821. if ret>maximum
  822. pbPlayBuzzerSE()
  823. elsif ret<minimum
  824. pbPlayBuzzerSE()
  825. else
  826. pbPlayDecisionSE()
  827. break
  828. end
  829. elsif Input.trigger?(Input::B)
  830. pbPlayCancelSE()
  831. ret=cancelNumber
  832. break
  833. end
  834. end
  835. cmdwindow.dispose
  836. Input.update
  837. return ret
  838. end
  839.  
  840. def Kernel.pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel=0,defaultCmd=0)
  841. msgwin=msgwindow
  842. if !msgwindow
  843. msgwin=Kernel.pbCreateMessageWindow(nil)
  844. end
  845. oldlbl=msgwin.letterbyletter
  846. msgwin.letterbyletter=false
  847. if commands
  848. cmdwindow=Window_CommandPokemonEx.new(commands)
  849. cmdwindow.z=99999
  850. cmdwindow.visible=true
  851. cmdwindow.resizeToFit(cmdwindow.commands)
  852. cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y
  853. cmdwindow.index=defaultCmd
  854. command=0
  855. msgwin.text=help[cmdwindow.index]
  856. msgwin.width=msgwin.width # Necessary evil to make it use the proper margins.
  857. loop do
  858. Graphics.update
  859. Input.update
  860. oldindex=cmdwindow.index
  861. cmdwindow.update
  862. if oldindex!=cmdwindow.index
  863. msgwin.text=help[cmdwindow.index]
  864. end
  865. msgwin.update
  866. yield if block_given?
  867. if Input.trigger?(Input::B)
  868. if cmdIfCancel>0
  869. command=cmdIfCancel-1
  870. break
  871. elsif cmdIfCancel<0
  872. command=cmdIfCancel
  873. break
  874. end
  875. end
  876. if Input.trigger?(Input::C)
  877. command=cmdwindow.index
  878. break
  879. end
  880. pbUpdateSceneMap
  881. end
  882. ret=command
  883. cmdwindow.dispose
  884. Input.update
  885. end
  886. msgwin.letterbyletter=oldlbl
  887. if !msgwindow
  888. msgwin.dispose
  889. end
  890. return ret
  891. end
  892.  
  893. def Kernel.pbShowCommands(msgwindow,commands=nil,cmdIfCancel=0,defaultCmd=0)
  894. ret=0
  895. if commands
  896. cmdwindow=Window_CommandPokemonEx.new(commands)
  897. cmdwindow.z=99999
  898. cmdwindow.visible=true
  899. cmdwindow.resizeToFit(cmdwindow.commands)
  900. pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
  901. cmdwindow.index=defaultCmd
  902. command=0
  903. loop do
  904. Graphics.update
  905. Input.update
  906. cmdwindow.update
  907. msgwindow.update if msgwindow
  908. yield if block_given?
  909. if Input.trigger?(Input::B)
  910. if cmdIfCancel>0
  911. command=cmdIfCancel-1
  912. break
  913. elsif cmdIfCancel<0
  914. command=cmdIfCancel
  915. break
  916. end
  917. end
  918. if Input.trigger?(Input::C)
  919. command=cmdwindow.index
  920. break
  921. end
  922. pbUpdateSceneMap
  923. end
  924. ret=command
  925. cmdwindow.dispose
  926. Input.update
  927. end
  928. return ret
  929. end
  930.  
  931. def pbPositionFaceWindow(facewindow,msgwindow)
  932. return if !facewindow
  933. if msgwindow
  934. if facewindow.height<=msgwindow.height
  935. facewindow.y=msgwindow.y
  936. else
  937. facewindow.y=msgwindow.y+msgwindow.height-facewindow.height
  938. end
  939. facewindow.x=Graphics.width-facewindow.width
  940. msgwindow.x=0
  941. msgwindow.width=Graphics.width-facewindow.width
  942. else
  943. facewindow.height=Graphics.height if facewindow.height>Graphics.height
  944. facewindow.x=0
  945. facewindow.y=0
  946. end
  947. end
  948.  
  949. def pbPositionNearMsgWindow(cmdwindow,msgwindow,side)
  950. return if !cmdwindow
  951. if msgwindow
  952. height=[cmdwindow.height,Graphics.height-msgwindow.height].min
  953. if cmdwindow.height!=height
  954. cmdwindow.height=height
  955. end
  956. cmdwindow.y=msgwindow.y-cmdwindow.height
  957. if cmdwindow.y<0
  958. cmdwindow.y=msgwindow.y+msgwindow.height
  959. if cmdwindow.y+cmdwindow.height>Graphics.height
  960. cmdwindow.y=msgwindow.y-cmdwindow.height
  961. end
  962. end
  963. case side
  964. when :left
  965. cmdwindow.x=msgwindow.x
  966. when :right
  967. cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
  968. else
  969. cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
  970. end
  971. else
  972. cmdwindow.height=Graphics.height if cmdwindow.height>Graphics.height
  973. cmdwindow.x=0
  974. cmdwindow.y=0
  975. end
  976. end
  977.  
  978. def pbGetBasicMapNameFromId(id)
  979. begin
  980. map = pbLoadRxData("Data/MapInfos")
  981. return "" if !map
  982. return map[id].name
  983. rescue
  984. return ""
  985. end
  986. end
  987.  
  988. def pbGetMapNameFromId(id)
  989. map=pbGetBasicMapNameFromId(id)
  990. if $Trainer
  991. map.gsub!(/\\PN/,$Trainer.name)
  992. end
  993. return map
  994. end
  995.  
  996. def Kernel.pbMessage(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block)
  997. ret=0
  998. msgwindow=Kernel.pbCreateMessageWindow(nil,skin)
  999. if commands
  1000. ret=Kernel.pbMessageDisplay(msgwindow,message,true,
  1001. proc {|msgwindow|
  1002. next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
  1003. },&block)
  1004. else
  1005. Kernel.pbMessageDisplay(msgwindow,message,&block)
  1006. end
  1007. Kernel.pbDisposeMessageWindow(msgwindow)
  1008. Input.update
  1009. return ret
  1010. end
  1011.  
  1012. def Kernel.pbMessageChooseNumber(message,params,&block)
  1013. msgwindow=Kernel.pbCreateMessageWindow(nil,params.messageSkin)
  1014. ret=Kernel.pbMessageDisplay(msgwindow,message,true,
  1015. proc {|msgwindow|
  1016. next Kernel.pbChooseNumber(msgwindow,params,&block)
  1017. },&block)
  1018. Kernel.pbDisposeMessageWindow(msgwindow)
  1019. return ret
  1020. end
  1021.  
  1022. def Kernel.pbConfirmMessage(message,&block)
  1023. return (Kernel.pbMessage(message,[_INTL("Yes"),_INTL("No")],2,&block)==0)
  1024. end
  1025.  
  1026. def Kernel.pbConfirmMessageSerious(message,&block)
  1027. return (Kernel.pbMessage(message,[_INTL("No"),_INTL("Yes")],1,&block)==1)
  1028. end
  1029.  
  1030. def Kernel.pbCreateStatusWindow(viewport=nil)
  1031. msgwindow=Window_AdvancedTextPokemon.new("")
  1032. if !viewport
  1033. msgwindow.z=99999
  1034. else
  1035. msgwindow.viewport=viewport
  1036. end
  1037. msgwindow.visible=false
  1038. msgwindow.letterbyletter=false
  1039. pbBottomLeftLines(msgwindow,2)
  1040. skinfile=MessageConfig.pbGetSpeechFrame()
  1041. msgwindow.setSkin(skinfile)
  1042. return msgwindow
  1043. end
  1044.  
  1045. def Kernel.pbCreateMessageWindow(viewport=nil,skin=nil)
  1046. msgwindow=Window_AdvancedTextPokemon.new("")
  1047. if !viewport
  1048. msgwindow.z=99999
  1049. else
  1050. msgwindow.viewport=viewport
  1051. end
  1052. msgwindow.visible=true
  1053. msgwindow.letterbyletter=true
  1054. msgwindow.back_opacity=MessageConfig::WindowOpacity
  1055. pbBottomLeftLines(msgwindow,2)
  1056. $game_temp.message_window_showing=true if $game_temp
  1057. $game_message.visible=true if $game_message
  1058. skin=MessageConfig.pbGetSpeechFrame() if !skin
  1059. msgwindow.setSkin(skin)
  1060. return msgwindow
  1061. end
  1062.  
  1063. def Kernel.pbDisposeMessageWindow(msgwindow)
  1064. $game_temp.message_window_showing=false if $game_temp
  1065. $game_message.visible=false if $game_message
  1066. msgwindow.dispose
  1067. end
  1068.  
  1069.  
  1070.  
  1071. class FaceWindowVX < SpriteWindow_Base
  1072. def initialize(face)
  1073. super(0,0,128,128)
  1074. faceinfo=face.split(",")
  1075. facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0])
  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(96,96)
  1081. @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
  1082. (@faceIndex % 4) * 96,
  1083. (@faceIndex / 4) * 96, 96, 96
  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) * 96,
  1094. (@faceIndex / 4) * 96, 96, 96
  1095. ))
  1096. end
  1097. end
  1098.  
  1099. def dispose
  1100. @facebitmaptmp.dispose
  1101. @facebitmap.dispose if @facebitmap
  1102. super
  1103. end
  1104. end
  1105.  
  1106.  
  1107.  
  1108. def itemIconTag(item)
  1109. return "" if !item
  1110. if item.respond_to?("icon_name")
  1111. return sprintf("<icon=%s>",item.icon_name)
  1112. else
  1113. ix=item.icon_index % 16 * 24
  1114. iy=item.icon_index / 16 * 24
  1115. return sprintf("<img=Graphics/System/Iconset|%d|%d|24|24>",ix,iy)
  1116. end
  1117. end
  1118.  
  1119. def getSkinColor(windowskin,color,isDarkSkin)
  1120. if !windowskin || windowskin.disposed? ||
  1121. windowskin.width!=128 || windowskin.height!=128
  1122. textcolors=[
  1123. isDarkSkin ? shadowc3tag(MessageConfig::LIGHTTEXTBASE, MessageConfig::LIGHTTEXTSHADOW) :
  1124. shadowc3tag(MessageConfig::DARKTEXTBASE, MessageConfig::DARKTEXTSHADOW),
  1125. "<c2=7E105D08>", # Red
  1126. "<c2=421F2117>", # Blue
  1127. "<c2=43F022E8>", # Green
  1128. "<c2=7FF05EE8>", # Yellow
  1129. "<c2=7E1F5D17>", # Magenta
  1130. "<c2=43FF22F7>", # Cyan
  1131. "<c2=63184210>", # Grey
  1132. "<c2=7FFF5EF7>" # White
  1133. ]
  1134. color=0 if color>textcolors.length
  1135. return textcolors[color]
  1136. else # VX windowskin
  1137. color=0 if color>=32
  1138. x = 64 + (color % 8) * 8
  1139. y = 96 + (color / 8) * 8
  1140. pixel=windowskin.get_pixel(x, y)
  1141. return shadowctagFromColor(pixel)
  1142. end
  1143. end
  1144.  
  1145. # internal function
  1146. def pbRepositionMessageWindow(msgwindow, linecount=2)
  1147. msgwindow.height=32*linecount+msgwindow.borderY
  1148. msgwindow.y=(Graphics.height)-(msgwindow.height)
  1149. if $game_temp && $game_temp.in_battle && !$scene.respond_to?("update_basic")
  1150. msgwindow.y=0
  1151. elsif $game_system && $game_system.respond_to?("message_position")
  1152. case $game_system.message_position
  1153. when 0 # up
  1154. msgwindow.y=0
  1155. when 1 # middle
  1156. msgwindow.y=(Graphics.height/2)-(msgwindow.height/2)
  1157. when 2
  1158. msgwindow.y=(Graphics.height)-(msgwindow.height)
  1159. end
  1160. end
  1161. if $game_system && $game_system.respond_to?("message_frame")
  1162. if $game_system.message_frame != 0
  1163. msgwindow.opacity = 0
  1164. end
  1165. end
  1166. if $game_message
  1167. case $game_message.background
  1168. when 1 # dim
  1169. msgwindow.opacity=0
  1170. when 2 # transparent
  1171. msgwindow.opacity=0
  1172. end
  1173. end
  1174. end
  1175.  
  1176. # internal function
  1177. def pbUpdateMsgWindowPos(msgwindow,event,eventChanged=false)
  1178. if event
  1179. if eventChanged
  1180. msgwindow.resizeToFit2(msgwindow.text,Graphics.width*2/3,msgwindow.height)
  1181. end
  1182. msgwindow.y=event.screen_y-48-msgwindow.height
  1183. if msgwindow.y<0
  1184. msgwindow.y=event.screen_y+24
  1185. end
  1186. msgwindow.x=event.screen_x-(msgwindow.width/2)
  1187. msgwindow.x=0 if msgwindow.x<0
  1188. if msgwindow.x>Graphics.width-msgwindow.width
  1189. msgwindow.x=Graphics.width-msgwindow.width
  1190. end
  1191. else
  1192. curwidth=msgwindow.width
  1193. if curwidth!=Graphics.width
  1194. msgwindow.width=Graphics.width
  1195. msgwindow.width=Graphics.width
  1196. end
  1197. end
  1198. end
  1199.  
  1200. # internal function
  1201.  
  1202. def pbGetGoldString
  1203. moneyString=""
  1204. if $Trainer
  1205. moneyString=_INTL("${1}",$Trainer.money)
  1206. else
  1207. if $data_system.respond_to?("words")
  1208. moneyString=_INTL("{1} {2}",$game_party.gold,$data_system.words.gold)
  1209. else
  1210. moneyString=_INTL("{1} {2}",$game_party.gold,Vocab.gold)
  1211. end
  1212. end
  1213. return moneyString
  1214. end
  1215.  
  1216. def pbDisplayGoldWindow(msgwindow)
  1217. moneyString=pbGetGoldString()
  1218. goldwindow=Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>",moneyString))
  1219. goldwindow.setSkin("Graphics/Windowskins/goldskin")
  1220. goldwindow.resizeToFit(goldwindow.text,Graphics.width)
  1221. goldwindow.width=160 if goldwindow.width<=160
  1222. if msgwindow.y==0
  1223. goldwindow.y=Graphics.height-goldwindow.height
  1224. else
  1225. goldwindow.y=0
  1226. end
  1227. goldwindow.viewport=msgwindow.viewport
  1228. goldwindow.z=msgwindow.z
  1229. return goldwindow
  1230. end
  1231.  
  1232. #polectron
  1233. def pbDisplayNametagWindow(msgwindow, facewindow, name)
  1234. namewindow=Window_AdvancedTextPokemon.new(_INTL("{1}",name))
  1235. namewindow.setSkin("Graphics/Windowskins/nameskin")
  1236. namewindow.resizeToFit(namewindow.text,Graphics.width)
  1237. namewindow.width=160 if namewindow.width<=160
  1238. if msgwindow.y==0
  1239. namewindow.y=Graphics.height-namewindow.height
  1240. else
  1241. namewindow.y=0
  1242. end
  1243.  
  1244. namewindow.y=msgwindow.y-namewindow.height
  1245. namewindow.x=msgwindow.x+6
  1246. if facewindow
  1247. namewindow.x=facewindow.x+6
  1248. end
  1249.  
  1250. namewindow.viewport=msgwindow.viewport
  1251. namewindow.z=msgwindow.z
  1252. return namewindow
  1253. end
  1254. def pbDisplayCoinsWindow(msgwindow,goldwindow)
  1255. coinString=($PokemonGlobal) ? $PokemonGlobal.coins : "0"
  1256. coinwindow=Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>",coinString))
  1257. coinwindow.setSkin("Graphics/Windowskins/goldskin")
  1258. coinwindow.resizeToFit(coinwindow.text,Graphics.width)
  1259. coinwindow.width=160 if coinwindow.width<=160
  1260. if msgwindow.y==0
  1261. coinwindow.y=(goldwindow) ? goldwindow.y-coinwindow.height : Graphics.height-coinwindow.height
  1262. else
  1263. coinwindow.y=(goldwindow) ? goldwindow.height : 0
  1264. end
  1265. coinwindow.viewport=msgwindow.viewport
  1266. coinwindow.z=msgwindow.z
  1267. return coinwindow
  1268. end
  1269.  
  1270. def pbMessageWaitForInput(msgwindow,frames,showPause=false)
  1271. return if !frames || frames<=0
  1272. if msgwindow && showPause
  1273. msgwindow.startPause
  1274. end
  1275. frames.times do
  1276. Graphics.update
  1277. Input.update
  1278. msgwindow.update if msgwindow
  1279. pbUpdateSceneMap
  1280. if Input.trigger?(Input::C) || Input.trigger?(Input::B)
  1281. break
  1282. end
  1283. yield if block_given?
  1284. end
  1285. if msgwindow && showPause
  1286. msgwindow.stopPause
  1287. end
  1288. end
  1289.  
  1290. def Kernel.pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
  1291. return if !msgwindow
  1292. oldletterbyletter=msgwindow.letterbyletter
  1293. msgwindow.letterbyletter=(letterbyletter ? true : false)
  1294. ret=nil
  1295. count=0
  1296. commands=nil
  1297. facewindow=nil
  1298. goldwindow=nil
  1299. coinwindow=nil
  1300. namewindow=nil
  1301. cmdvariable=0
  1302. cmdIfCancel=0
  1303. msgwindow.waitcount=0
  1304. autoresume=false
  1305. text=message.clone
  1306. msgback=nil
  1307. linecount=(Graphics.height>400) ? 3 : 2
  1308. ### Text replacement
  1309. text.gsub!(/\\\\/,"\5")
  1310. if $game_actors
  1311. text.gsub!(/\\[Nn]\[([1-8])\]/){
  1312. m=$1.to_i
  1313. next $game_actors[m].name
  1314. }
  1315. end
  1316. text.gsub!(/\\[Ss][Ii][Gg][Nn]\[([^\]]*)\]/){
  1317. next "\\op\\cl\\ts[]\\w["+$1+"]"
  1318. }
  1319. text.gsub!(/\\[Pp][Nn]/,$Trainer.name) if $Trainer
  1320. text.gsub!(/\\[Pp][Mm]/,_INTL("${1}",$Trainer.money)) if $Trainer
  1321. text.gsub!(/\\[Nn]/,"\n")
  1322. text.gsub!(/\\\[([0-9A-Fa-f]{8,8})\]/){ "<c2="+$1+">" }
  1323. text.gsub!(/\\[Pp][Gg]/,"\\b") if $Trainer && $Trainer.isMale?
  1324. text.gsub!(/\\[Pp][Gg]/,"\\r") if $Trainer && $Trainer.isFemale?
  1325. text.gsub!(/\\[Pp][Oo][Gg]/,"\\r") if $Trainer && $Trainer.isMale?
  1326. text.gsub!(/\\[Pp][Oo][Gg]/,"\\b") if $Trainer && $Trainer.isFemale?
  1327. text.gsub!(/\\[Pp][Gg]/,"")
  1328. text.gsub!(/\\[Pp][Oo][Gg]/,"")
  1329. text.gsub!(/\\[Bb]/,"<c2=6546675A>")
  1330. text.gsub!(/\\[Rr]/,"<c2=043C675A>")
  1331. text.gsub!(/\\1/,"\1")
  1332. colortag=""
  1333. isDarkSkin=isDarkWindowskin(msgwindow.windowskin)
  1334. if ($game_message && $game_message.background>0) ||
  1335. ($game_system && $game_system.respond_to?("message_frame") &&
  1336. $game_system.message_frame != 0)
  1337. colortag=getSkinColor(msgwindow.windowskin,0,true)
  1338. else
  1339. colortag=getSkinColor(msgwindow.windowskin,0,isDarkSkin)
  1340. end
  1341. text.gsub!(/\\[Cc]\[([0-9]+)\]/){
  1342. m=$1.to_i
  1343. next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
  1344. }
  1345. begin
  1346. last_text = text.clone
  1347. text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  1348. end until text == last_text
  1349. begin
  1350. last_text = text.clone
  1351. text.gsub!(/\\[Ll]\[([0-9]+)\]/) {
  1352. linecount=[1,$1.to_i].max;
  1353. next ""
  1354. }
  1355. end until text == last_text
  1356. text=colortag+text
  1357. ### Controls
  1358. textchunks=[]
  1359. controls=[]
  1360. while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Tt][Gg]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i]
  1361. textchunks.push($~.pre_match)
  1362. if $~[1]
  1363. controls.push([$~[1].downcase,$~[2],-1])
  1364. else
  1365. controls.push([$~[3].downcase,"",-1])
  1366. end
  1367. text=$~.post_match
  1368. end
  1369. textchunks.push(text)
  1370. for chunk in textchunks
  1371. chunk.gsub!(/\005/,"\\")
  1372. end
  1373. textlen=0
  1374. for i in 0...controls.length
  1375. control=controls[i][0]
  1376. if control=="wt" || control=="wtnp" || control=="." || control=="|"
  1377. textchunks[i]+="\2"
  1378. elsif control=="!"
  1379. textchunks[i]+="\1"
  1380. end
  1381. textlen+=toUnformattedText(textchunks[i]).scan(/./m).length
  1382. controls[i][2]=textlen
  1383. end
  1384. text=textchunks.join("")
  1385. unformattedText=toUnformattedText(text)
  1386. signWaitCount=0
  1387. haveSpecialClose=false
  1388. specialCloseSE=""
  1389. for i in 0...controls.length
  1390. control=controls[i][0]
  1391. param=controls[i][1]
  1392. if control=="f"
  1393. facewindow.dispose if facewindow
  1394. facewindow=PictureWindow.new("Graphics/Pictures/#{param}")
  1395. elsif control=="op"
  1396. signWaitCount=21
  1397. elsif control=="cl"
  1398. text=text.sub(/\001\z/,"") # fix: '$' can match end of line as well
  1399. haveSpecialClose=true
  1400. specialCloseSE=param
  1401. elsif control=="se" && controls[i][2]==0
  1402. startSE=param
  1403. controls[i]=nil
  1404. elsif control=="ff"
  1405. facewindow.dispose if facewindow
  1406. facewindow=FaceWindowVX.new(param)
  1407. elsif control=="ch"
  1408. cmds=param.clone
  1409. cmdvariable=pbCsvPosInt!(cmds)
  1410. cmdIfCancel=pbCsvField!(cmds).to_i
  1411. commands=[]
  1412. while cmds.length>0
  1413. commands.push(pbCsvField!(cmds))
  1414. end
  1415. elsif control=="wtnp" || control=="^"
  1416. text=text.sub(/\001\z/,"") # fix: '$' can match end of line as well
  1417. end
  1418. end
  1419. if startSE!=nil
  1420. pbSEPlay(pbStringToAudioFile(startSE))
  1421. elsif signWaitCount==0 && letterbyletter
  1422. pbPlayDecisionSE()
  1423. end
  1424. ########## Position message window ##############
  1425. pbRepositionMessageWindow(msgwindow,linecount)
  1426. if $game_message && $game_message.background==1
  1427. msgback=IconSprite.new(0,msgwindow.y,msgwindow.viewport)
  1428. msgback.z=msgwindow.z-1
  1429. msgback.setBitmap("Graphics/System/MessageBack")
  1430. end
  1431. if facewindow
  1432. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1433. facewindow.viewport=msgwindow.viewport
  1434. facewindow.z=msgwindow.z
  1435. end
  1436. atTop=(msgwindow.y==0)
  1437. ########## Show text #############################
  1438. msgwindow.text=text
  1439. Graphics.frame_reset if Graphics.frame_rate>40
  1440. begin
  1441. if signWaitCount>0
  1442. signWaitCount-=1
  1443. if atTop
  1444. msgwindow.y=-(msgwindow.height*(signWaitCount)/20)
  1445. else
  1446. msgwindow.y=Graphics.height-(msgwindow.height*(20-signWaitCount)/20)
  1447. end
  1448. end
  1449. for i in 0...controls.length
  1450. if controls[i] && controls[i][2]<=msgwindow.position && msgwindow.waitcount==0
  1451. control=controls[i][0]
  1452. param=controls[i][1]
  1453. case control
  1454. when "f"
  1455. facewindow.dispose if facewindow
  1456. facewindow=PictureWindow.new("Graphics/Pictures/#{param}")
  1457. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1458. facewindow.viewport=msgwindow.viewport
  1459. facewindow.z=msgwindow.z
  1460. when "ts"
  1461. if param==""
  1462. msgwindow.textspeed=-999
  1463. else
  1464. msgwindow.textspeed=param.to_i
  1465. end
  1466. when "ff"
  1467. facewindow.dispose if facewindow
  1468. facewindow=FaceWindowVX.new(param)
  1469. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1470. facewindow.viewport=msgwindow.viewport
  1471. facewindow.z=msgwindow.z
  1472. when "g" # Display gold window
  1473. goldwindow.dispose if goldwindow
  1474. goldwindow=pbDisplayGoldWindow(msgwindow)
  1475. when "tg" #display nametag by polectron
  1476. namewindow.dispose if namewindow
  1477. namewindow=pbDisplayNametagWindow(msgwindow, facewindow, param)
  1478. when "cn" # Display coins window
  1479. coinwindow.dispose if coinwindow
  1480. coinwindow=pbDisplayCoinsWindow(msgwindow,goldwindow)
  1481. when "wu"
  1482. msgwindow.y=0
  1483. atTop=true
  1484. msgback.y=msgwindow.y if msgback
  1485. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1486. msgwindow.y=-(msgwindow.height*(signWaitCount)/20)
  1487. when "wm"
  1488. atTop=false
  1489. msgwindow.y=(Graphics.height/2)-(msgwindow.height/2)
  1490. msgback.y=msgwindow.y if msgback
  1491. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1492. when "wd"
  1493. atTop=false
  1494. msgwindow.y=(Graphics.height)-(msgwindow.height)
  1495. msgback.y=msgwindow.y if msgback
  1496. pbPositionNearMsgWindow(facewindow,msgwindow,:left)
  1497. msgwindow.y=Graphics.height-(msgwindow.height*(20-signWaitCount)/20)
  1498. when "."
  1499. msgwindow.waitcount+=Graphics.frame_rate/4
  1500. when "|"
  1501. msgwindow.waitcount+=Graphics.frame_rate
  1502. when "wt" # Wait
  1503. param=param.sub(/\A\s+/,"").sub(/\s+\z/,"")
  1504. msgwindow.waitcount+=param.to_i*2
  1505. when "w" # Windowskin
  1506. if param==""
  1507. msgwindow.windowskin=nil
  1508. else
  1509. msgwindow.setSkin("Graphics/Windowskins/#{param}")
  1510. end
  1511. msgwindow.width=msgwindow.width # Necessary evil
  1512. when "^" # Wait, no pause
  1513. autoresume=true
  1514. when "wtnp" # Wait, no pause
  1515. param=param.sub(/\A\s+/,"").sub(/\s+\z/,"")
  1516. msgwindow.waitcount=param.to_i*2
  1517. autoresume=true
  1518. when "se" # Play SE
  1519. pbSEPlay(pbStringToAudioFile(param))
  1520. when "me" # Play ME
  1521. pbMEPlay(pbStringToAudioFile(param))
  1522. end
  1523. controls[i]=nil
  1524. end
  1525. end
  1526. break if !letterbyletter
  1527. Graphics.update
  1528. Input.update
  1529. facewindow.update if facewindow
  1530. if $DEBUG && Input.trigger?(Input::F6)
  1531. pbRecord(unformattedText)
  1532. end
  1533. if autoresume && msgwindow.waitcount==0
  1534. msgwindow.resume if msgwindow.busy?
  1535. break if !msgwindow.busy?
  1536. end
  1537. if (Input.trigger?(Input::C) || Input.trigger?(Input::B))
  1538. if msgwindow.busy?
  1539. pbPlayDecisionSE() if msgwindow.pausing?
  1540. msgwindow.resume
  1541. else
  1542. break if signWaitCount==0
  1543. end
  1544. end
  1545. pbUpdateSceneMap
  1546. msgwindow.update
  1547. yield if block_given?
  1548. end until (!letterbyletter || commandProc || commands) && !msgwindow.busy?
  1549. Input.update # Must call Input.update again to avoid extra triggers
  1550. msgwindow.letterbyletter=oldletterbyletter
  1551. if commands
  1552. $game_variables[cmdvariable]=Kernel.pbShowCommands(
  1553. msgwindow,commands,cmdIfCancel)
  1554. $game_map.need_refresh = true if $game_map
  1555. end
  1556. if commandProc
  1557. ret=commandProc.call(msgwindow)
  1558. end
  1559. msgback.dispose if msgback
  1560. goldwindow.dispose if goldwindow
  1561. coinwindow.dispose if coinwindow
  1562. facewindow.dispose if facewindow
  1563. namewindow.dispose if namewindow
  1564. if haveSpecialClose
  1565. pbSEPlay(pbStringToAudioFile(specialCloseSE))
  1566. atTop=(msgwindow.y==0)
  1567. for i in 0..20
  1568. if atTop
  1569. msgwindow.y=-(msgwindow.height*(i)/20)
  1570. else
  1571. msgwindow.y=Graphics.height-(msgwindow.height*(20-i)/20)
  1572. end
  1573. Graphics.update
  1574. Input.update
  1575. pbUpdateSceneMap
  1576. msgwindow.update
  1577. end
  1578. end
  1579. return ret
  1580. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement