1. #===============================================================================
  2. # Pokémon icons
  3. #===============================================================================
  4. class PokemonBoxIcon < IconSprite
  5. def initialize(pokemon, viewport = nil)
  6. super(0, 0, viewport)
  7. @pokemon = pokemon
  8. @release_timer_start = nil
  9. refresh
  10. end
  11.  
  12. def releasing?
  13. return !@release_timer_start.nil?
  14. end
  15.  
  16. def release
  17. self.ox = self.src_rect.width / 2 # 32
  18. self.oy = self.src_rect.height / 2 # 32
  19. self.x += self.src_rect.width / 2 # 32
  20. self.y += self.src_rect.height / 2 # 32
  21. @release_timer_start = System.uptime
  22. end
  23.  
  24. def refresh
  25. return if !@pokemon
  26. self.setBitmap(GameData::Species.icon_filename_from_pokemon(@pokemon))
  27. self.src_rect = Rect.new(0, 0, self.bitmap.height, self.bitmap.height)
  28. end
  29.  
  30. def update
  31. super
  32.  
  33. if releasing?
  34. time_now = System.uptime
  35. self.zoom_x = lerp(1.0, 0.0, 1.5, @release_timer_start, System.uptime)
  36. self.zoom_y = self.zoom_x
  37. self.opacity = lerp(255, 0, 1.5, @release_timer_start, System.uptime)
  38. if self.opacity == 0
  39. @release_timer_start = nil
  40. dispose
  41. end
  42. end
  43. end
  44. end
  45.  
  46. #===============================================================================
  47. # Pokémon sprite
  48. #===============================================================================
  49. class MosaicPokemonSprite < PokemonSprite
  50. attr_reader :mosaic
  51.  
  52. def initialize(*args)
  53. super(*args)
  54. @mosaic = 0
  55. @inrefresh = false
  56. @mosaicbitmap = nil
  57. @mosaicbitmap2 = nil
  58. @oldbitmap = self.bitmap
  59. end
  60.  
  61. def dispose
  62. super
  63. @mosaicbitmap&.dispose
  64. @mosaicbitmap = nil
  65. @mosaicbitmap2&.dispose
  66. @mosaicbitmap2 = nil
  67. end
  68.  
  69. def bitmap=(value)
  70. super
  71. mosaicRefresh(value)
  72. end
  73.  
  74. def mosaic=(value)
  75. @mosaic = value
  76. @mosaic = 0 if @mosaic < 0
  77. mosaicRefresh(@oldbitmap)
  78. end
  79.  
  80. def mosaicRefresh(bitmap)
  81. return if @inrefresh
  82. @inrefresh = true
  83. @oldbitmap = bitmap
  84. if @mosaic <= 0 || !@oldbitmap
  85. @mosaicbitmap&.dispose
  86. @mosaicbitmap = nil
  87. @mosaicbitmap2&.dispose
  88. @mosaicbitmap2 = nil
  89. self.bitmap = @oldbitmap
  90. else
  91. newWidth = [(@oldbitmap.width / @mosaic), 1].max
  92. newHeight = [(@oldbitmap.height / @mosaic), 1].max
  93. @mosaicbitmap2&.dispose
  94. @mosaicbitmap = pbDoEnsureBitmap(@mosaicbitmap, newWidth, newHeight)
  95. @mosaicbitmap.clear
  96. @mosaicbitmap2 = pbDoEnsureBitmap(@mosaicbitmap2, @oldbitmap.width, @oldbitmap.height)
  97. @mosaicbitmap2.clear
  98. @mosaicbitmap.stretch_blt(Rect.new(0, 0, newWidth, newHeight), @oldbitmap, @oldbitmap.rect)
  99. @mosaicbitmap2.stretch_blt(
  100. Rect.new((-@mosaic / 2) + 1, (-@mosaic / 2) + 1, @mosaicbitmap2.width, @mosaicbitmap2.height),
  101. @mosaicbitmap, Rect.new(0, 0, newWidth, newHeight)
  102. )
  103. self.bitmap = @mosaicbitmap2
  104. end
  105. @inrefresh = false
  106. end
  107. end
  108.  
  109. #===============================================================================
  110. #
  111. #===============================================================================
  112. class AutoMosaicPokemonSprite < MosaicPokemonSprite
  113. INITIAL_MOSAIC = 10 # Pixellation factor
  114.  
  115. def mosaic=(value)
  116. @mosaic = value
  117. @mosaic = 0 if @mosaic < 0
  118. @start_mosaic = @mosaic if !@start_mosaic
  119. end
  120.  
  121. def mosaic_duration=(val)
  122. @mosaic_duration = val
  123. @mosaic_duration = 0 if @mosaic_duration < 0
  124. @mosaic_timer_start = System.uptime if @mosaic_duration > 0
  125. end
  126.  
  127. def update
  128. super
  129. if @mosaic_timer_start
  130. @start_mosaic = INITIAL_MOSAIC if !@start_mosaic || @start_mosaic == 0
  131. new_mosaic = lerp(@start_mosaic, 0, @mosaic_duration, @mosaic_timer_start, System.uptime).to_i
  132. self.mosaic = new_mosaic
  133. mosaicRefresh(@oldbitmap)
  134. if new_mosaic == 0
  135. @mosaic_timer_start = nil
  136. @start_mosaic = nil
  137. end
  138. end
  139. end
  140. end
  141.  
  142. #===============================================================================
  143. # Cursor
  144. #===============================================================================
  145. class PokemonBoxArrow < Sprite
  146. attr_accessor :quickswap
  147.  
  148. # Time in seconds for the cursor to move down and back up to grab/drop a
  149. # Pokémon.
  150. GRAB_TIME = 0.4
  151.  
  152. def initialize(viewport = nil)
  153. super(viewport)
  154. @holding = false
  155. @updating = false
  156. @quickswap = false
  157. @heldpkmn = nil
  158. @handsprite = ChangelingSprite.new(0, 0, viewport)
  159. @handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
  160. @handsprite.addBitmap("point2", "Graphics/UI/Storage/cursor_point_2")
  161. @handsprite.addBitmap("grab", "Graphics/UI/Storage/cursor_grab")
  162. @handsprite.addBitmap("fist", "Graphics/UI/Storage/cursor_fist")
  163. @handsprite.addBitmap("point1q", "Graphics/UI/Storage/cursor_point_1_q")
  164. @handsprite.addBitmap("point2q", "Graphics/UI/Storage/cursor_point_2_q")
  165. @handsprite.addBitmap("grabq", "Graphics/UI/Storage/cursor_grab_q")
  166. @handsprite.addBitmap("fistq", "Graphics/UI/Storage/cursor_fist_q")
  167. @handsprite.changeBitmap("fist")
  168. @spriteX = self.x
  169. @spriteY = self.y
  170. end
  171.  
  172. def dispose
  173. @handsprite.dispose
  174. @heldpkmn&.dispose
  175. super
  176. end
  177.  
  178. def x=(value)
  179. super
  180. @handsprite.x = self.x
  181. @spriteX = x if !@updating
  182. heldPokemon.x = self.x if holding?
  183. end
  184.  
  185. def y=(value)
  186. super
  187. @handsprite.y = self.y
  188. @spriteY = y if !@updating
  189. heldPokemon.y = self.y + 16 if holding?
  190. end
  191.  
  192. def z=(value)
  193. super
  194. @handsprite.z = value
  195. end
  196.  
  197. def visible=(value)
  198. super
  199. @handsprite.visible = value
  200. sprite = heldPokemon
  201. sprite.visible = value if sprite
  202. end
  203.  
  204. def color=(value)
  205. super
  206. @handsprite.color = value
  207. sprite = heldPokemon
  208. sprite.color = value if sprite
  209. end
  210.  
  211. def heldPokemon
  212. @heldpkmn = nil if @heldpkmn&.disposed?
  213. @holding = false if !@heldpkmn
  214. return @heldpkmn
  215. end
  216.  
  217. def holding?
  218. return self.heldPokemon && @holding
  219. end
  220.  
  221. def grabbing?
  222. return !@grabbing_timer_start.nil?
  223. end
  224.  
  225. def placing?
  226. return !@placing_timer_start.nil?
  227. end
  228.  
  229. def setSprite(sprite)
  230. if holding?
  231. @heldpkmn = sprite
  232. @heldpkmn.viewport = self.viewport if @heldpkmn
  233. @heldpkmn.z = 1 if @heldpkmn
  234. @holding = false if !@heldpkmn
  235. self.z = 2
  236. end
  237. end
  238.  
  239. def deleteSprite
  240. @holding = false
  241. if @heldpkmn
  242. @heldpkmn.dispose
  243. @heldpkmn = nil
  244. end
  245. end
  246.  
  247. def grab(sprite)
  248. @grabbing_timer_start = System.uptime
  249. @heldpkmn = sprite
  250. @heldpkmn.viewport = self.viewport
  251. @heldpkmn.z = 1
  252. self.z = 2
  253. end
  254.  
  255. def place
  256. @placing_timer_start = System.uptime
  257. end
  258.  
  259. def release
  260. @heldpkmn&.release
  261. end
  262.  
  263. def update
  264. @updating = true
  265. super
  266. heldpkmn = heldPokemon
  267. heldpkmn&.update
  268. @handsprite.update
  269. @holding = false if !heldpkmn
  270. if @grabbing_timer_start
  271. if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2
  272. @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
  273. self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime)
  274. else
  275. @holding = true
  276. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  277. delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime)
  278. self.y = @spriteY + delta_y
  279. @grabbing_timer_start = nil if delta_y == 0
  280. end
  281. elsif @placing_timer_start
  282. if System.uptime - @placing_timer_start <= GRAB_TIME / 2
  283. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  284. self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime)
  285. else
  286. @holding = false
  287. @heldpkmn = nil
  288. @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
  289. delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime)
  290. self.y = @spriteY + delta_y
  291. @placing_timer_start = nil if delta_y == 0
  292. end
  293. elsif holding?
  294. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  295. else # Idling
  296. self.x = @spriteX
  297. self.y = @spriteY
  298. if (System.uptime / 0.5).to_i.even? # Changes every 0.5 seconds
  299. @handsprite.changeBitmap((@quickswap) ? "point1q" : "point1")
  300. else
  301. @handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
  302. end
  303. end
  304. @updating = false
  305. end
  306. end
  307.  
  308. #===============================================================================
  309. # Box
  310. #===============================================================================
  311. class PokemonBoxSprite < Sprite
  312. attr_accessor :refreshBox
  313. attr_accessor :refreshSprites
  314.  
  315. def initialize(storage, boxnumber, viewport = nil)
  316. super(viewport)
  317. @storage = storage
  318. @boxnumber = boxnumber
  319. @refreshBox = true
  320. @refreshSprites = true
  321. @pokemonsprites = []
  322. PokemonBox::BOX_SIZE.times do |i|
  323. @pokemonsprites[i] = nil
  324. pokemon = @storage[boxnumber, i]
  325. @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) if pokemon
  326.  
  327. Graphics.update if (i + 1) % 15 == 0
  328. end
  329. @contents = Bitmap.new(650, 390)
  330. self.bitmap = @contents
  331. self.x = 184
  332. self.y = 18
  333. refresh
  334. end
  335.  
  336. def dispose
  337. if !disposed?
  338. @pokemonsprites.each do |sprite|
  339. sprite&.dispose
  340. end
  341. @pokemonsprites.clear
  342. @boxbitmap.dispose
  343. @contents.dispose
  344. super
  345. end
  346. end
  347.  
  348. def x=(value)
  349. super
  350. end
  351.  
  352. def y=(value)
  353. super
  354. end
  355.  
  356. def color=(value)
  357. super
  358. if @refreshSprites
  359. @pokemonsprites.each do |sprite|
  360. sprite.color = value if sprite && !sprite.disposed?
  361. end
  362. end
  363. refresh
  364. end
  365.  
  366. def visible=(value)
  367. super
  368. @pokemonsprites.each do |sprite|
  369. sprite.visible = value if sprite && !sprite.disposed?
  370. end
  371. refresh
  372. end
  373.  
  374. def getBoxBitmap
  375. if !@bg || @bg != @storage[@boxnumber].background
  376. curbg = @storage[@boxnumber].background
  377. if !curbg || (curbg.is_a?(String) && curbg.length == 0)
  378. @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY
  379. else
  380. if curbg.is_a?(String) && curbg[/^box(\d+)$/]
  381. curbg = $~[1].to_i
  382. @storage[@boxnumber].background = curbg
  383. end
  384. @bg = curbg
  385. end
  386. @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY
  387. @storage[@boxnumber].background = @bg
  388. end
  389. @boxbitmap&.dispose
  390. @boxbitmap = AnimatedBitmap.new("Graphics/UI/Storage/box_#{@bg}")
  391. end
  392. end
  393.  
  394. def getPokemon(index)
  395. return @pokemonsprites[index]
  396. end
  397.  
  398. def setPokemon(index, sprite)
  399. @pokemonsprites[index] = sprite
  400. @pokemonsprites[index].refresh
  401.  
  402. row = index / PokemonBox::BOX_WIDTH
  403. column = index % PokemonBox::BOX_WIDTH
  404.  
  405. sprite.viewport = self.viewport
  406. sprite.x = self.x + 10 + (column * 48)
  407. sprite.y = self.y + 30 + (row * 48)
  408. sprite.z = 1
  409. end
  410.  
  411. def grabPokemon(index, arrow)
  412. sprite = @pokemonsprites[index]
  413. if sprite
  414. arrow.grab(sprite)
  415. @pokemonsprites[index] = nil
  416. end
  417. end
  418.  
  419. def deletePokemon(index)
  420. @pokemonsprites[index]&.dispose
  421. @pokemonsprites[index] = nil
  422. end
  423.  
  424. def refresh
  425. if @refreshBox
  426. boxname = @storage[@boxnumber].name
  427. getBoxBitmap
  428. @contents.stretch_blt(
  429. Rect.new(0, 0, 650, 390),
  430. @boxbitmap.bitmap,
  431. Rect.new(0, 0, 324, 296)
  432. )
  433. pbSetSystemFont(@contents)
  434. widthval = @contents.text_size(boxname).width
  435. xval = 162 - (widthval / 2)
  436. pbDrawShadowText(@contents, xval, 14, widthval, 32,
  437. boxname, Color.new(248, 248, 248), Color.new(40, 48, 48))
  438. @refreshBox = false
  439. end
  440. yval = self.y + 30
  441. PokemonBox::BOX_HEIGHT.times do |j|
  442. xval = self.x + 10
  443. PokemonBox::BOX_WIDTH.times do |k|
  444. sprite = @pokemonsprites[(j * PokemonBox::BOX_WIDTH) + k]
  445. if sprite && !sprite.disposed?
  446. sprite.viewport = self.viewport
  447. sprite.x = xval
  448. sprite.y = yval
  449. sprite.z = 1
  450. end
  451. xval += 48
  452. end
  453. yval += 48
  454. end
  455. end
  456.  
  457. def update
  458. super
  459. @frame_limiter = 0 if !@frame_limiter
  460. @frame_limiter = (@frame_limiter + 1) % 4
  461.  
  462. @pokemonsprites.each_with_index do |sprite, index|
  463. next if !sprite || sprite.disposed?
  464. if index % 4 == @frame_limiter || (sprite.respond_to?(:releasing?) && sprite.releasing?)
  465. sprite.update
  466. end
  467. end
  468. end
  469. end
  470.  
  471. #===============================================================================
  472. # Party pop-up panel
  473. #===============================================================================
  474. class PokemonBoxPartySprite < Sprite
  475. def initialize(party, viewport = nil)
  476. super(viewport)
  477. @party = party
  478. @boxbitmap = AnimatedBitmap.new("Graphics/UI/Storage/overlay_party")
  479. @pokemonsprites = []
  480. Settings::MAX_PARTY_SIZE.times do |i|
  481. @pokemonsprites[i] = nil
  482. pokemon = @party[i]
  483. @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) if pokemon
  484. end
  485. @contents = Bitmap.new(172, 352)
  486. self.bitmap = @contents
  487. self.x = 182
  488. self.y = Graphics.height - 352
  489. pbSetSystemFont(self.bitmap)
  490. refresh
  491. end
  492.  
  493. def dispose
  494. Settings::MAX_PARTY_SIZE.times do |i|
  495. @pokemonsprites[i]&.dispose
  496. end
  497. @boxbitmap.dispose
  498. @contents.dispose
  499. super
  500. end
  501.  
  502. def x=(value)
  503. super
  504. end
  505.  
  506. def y=(value)
  507. super
  508. end
  509.  
  510. def color=(value)
  511. super
  512. Settings::MAX_PARTY_SIZE.times do |i|
  513. if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
  514. @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color, value)
  515. end
  516. end
  517. end
  518.  
  519. def visible=(value)
  520. super
  521. @pokemonsprites.each do |sprite|
  522. sprite.visible = value if sprite && !sprite.disposed?
  523. end
  524. refresh
  525. end
  526.  
  527. def getPokemon(index)
  528. return @pokemonsprites[index]
  529. end
  530.  
  531. def setPokemon(index, sprite)
  532. @pokemonsprites[index] = sprite
  533. end
  534.  
  535. def grabPokemon(index, arrow)
  536. sprite = @pokemonsprites[index]
  537. if sprite
  538. arrow.grab(sprite)
  539. @pokemonsprites[index] = nil
  540. end
  541. end
  542.  
  543. def deletePokemon(index)
  544. @pokemonsprites[index]&.dispose
  545. @pokemonsprites[index] = nil
  546. end
  547.  
  548. def refresh
  549. @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, 324, 296))
  550. pbDrawTextPositions(
  551. self.bitmap,
  552. [[_INTL("Back"), 86, 248, :center, Color.new(248, 248, 248), Color.new(80, 80, 80), :outline]]
  553. )
  554. xvalues = [] # [18, 90, 18, 90, 18, 90]
  555. yvalues = [] # [2, 18, 66, 82, 130, 146]
  556. Settings::MAX_PARTY_SIZE.times do |i|
  557. xvalues.push(18 + (72 * (i % 2)))
  558. yvalues.push(2 + (16 * (i % 2)) + (64 * (i / 2)))
  559. end
  560. @pokemonsprites.delete_if { |sprite| sprite&.disposed? }
  561.  
  562. Settings::MAX_PARTY_SIZE.times do |j|
  563. sprite = @pokemonsprites[j]
  564. next if sprite.nil? || sprite.disposed?
  565.  
  566. sprite.viewport = self.viewport
  567. sprite.x = self.x + xvalues[j]
  568. sprite.y = self.y + yvalues[j]
  569. sprite.z = 1
  570. end
  571. end
  572.  
  573. def update
  574. super
  575. Settings::MAX_PARTY_SIZE.times do |i|
  576. @pokemonsprites[i].update if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
  577. end
  578. end
  579. end
  580.  
  581. #===============================================================================
  582. # Pokémon storage visuals
  583. #===============================================================================
  584. class PokemonStorageScene
  585. attr_reader :quickswap
  586.  
  587. MARK_WIDTH = 16
  588. MARK_HEIGHT = 16
  589.  
  590. def initialize
  591. @command = 1
  592. end
  593.  
  594. def pbStartBox(screen, command)
  595. @screen = screen
  596. @storage = screen.storage
  597. @bgviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  598. @bgviewport.z = 99999
  599. @boxviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  600. @boxviewport.z = 99999
  601. @boxsidesviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  602. @boxsidesviewport.z = 99999
  603. @arrowviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  604. @arrowviewport.z = 99999
  605. @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  606. @viewport.z = 99999
  607. @selection = 0
  608. @quickswap = false
  609. @sprites = {}
  610. @choseFromParty = false
  611. @command = command
  612. addBackgroundPlane(@sprites, "background", "Storage/bg", @bgviewport)
  613. @sprites["box"] = PokemonBoxSprite.new(@storage, @storage.currentBox, @boxviewport)
  614. @sprites["boxsides"] = IconSprite.new(0, 0, @boxsidesviewport)
  615. @sprites["boxsides"].setBitmap("Graphics/UI/Storage/overlay_main")
  616. @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport)
  617. pbSetSystemFont(@sprites["overlay"].bitmap)
  618. @sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport)
  619. @sprites["pokemon"].setOffset(PictureOrigin::CENTER)
  620. @sprites["pokemon"].x = 90
  621. @sprites["pokemon"].y = 134
  622. @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party, @boxsidesviewport)
  623. if command != 2 # Drop down tab only on Deposit
  624. @sprites["boxparty"].x = 182
  625. @sprites["boxparty"].y = Graphics.height
  626. end
  627. @markingbitmap = AnimatedBitmap.new("Graphics/UI/Storage/markings")
  628. @sprites["markingbg"] = IconSprite.new(292, 68, @boxsidesviewport)
  629. @sprites["markingbg"].setBitmap("Graphics/UI/Storage/overlay_marking")
  630. @sprites["markingbg"].z = 10
  631. @sprites["markingbg"].visible = false
  632. @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport)
  633. @sprites["markingoverlay"].z = 11
  634. @sprites["markingoverlay"].visible = false
  635. pbSetSystemFont(@sprites["markingoverlay"].bitmap)
  636. @sprites["arrow"] = PokemonBoxArrow.new(@arrowviewport)
  637. @sprites["arrow"].z += 1
  638. if command == 2
  639. pbPartySetArrow(@sprites["arrow"], @selection)
  640. pbUpdateOverlay(@selection, @storage.party)
  641. else
  642. pbSetArrow(@sprites["arrow"], @selection)
  643. pbUpdateOverlay(@selection)
  644. end
  645. pbSetMosaic(@selection)
  646. pbSEPlay("PC access")
  647. pbFadeInAndShow(@sprites)
  648. end
  649.  
  650. def pbCloseBox
  651. pbFadeOutAndHide(@sprites)
  652. pbDisposeSpriteHash(@sprites)
  653. @markingbitmap&.dispose
  654. @boxviewport.dispose
  655. @boxsidesviewport.dispose
  656. @arrowviewport.dispose
  657. end
  658.  
  659. def pbDisplay(message)
  660. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  661. msgwindow.viewport = @viewport
  662. msgwindow.visible = true
  663. msgwindow.letterbyletter = false
  664. msgwindow.resizeHeightToFit(message, Graphics.width - 180)
  665. msgwindow.text = message
  666. pbBottomRight(msgwindow)
  667. loop do
  668. Graphics.update
  669. Input.update
  670. if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
  671. break
  672. end
  673. msgwindow.update
  674. self.update
  675. end
  676. msgwindow.dispose
  677. Input.update
  678. end
  679.  
  680. def pbShowCommands(message, commands, index = 0)
  681. ret = -1
  682. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  683. msgwindow.viewport = @viewport
  684. msgwindow.visible = true
  685. msgwindow.letterbyletter = false
  686. msgwindow.text = message
  687. msgwindow.resizeHeightToFit(message, Graphics.width - 180)
  688. pbBottomRight(msgwindow)
  689. cmdwindow = Window_CommandPokemon.new(commands)
  690. cmdwindow.viewport = @viewport
  691. cmdwindow.visible = true
  692. cmdwindow.resizeToFit(cmdwindow.commands)
  693. cmdwindow.height = Graphics.height - msgwindow.height if cmdwindow.height > Graphics.height - msgwindow.height
  694. pbBottomRight(cmdwindow)
  695. cmdwindow.y -= msgwindow.height
  696. cmdwindow.index = index
  697. loop do
  698. Graphics.update
  699. Input.update
  700. msgwindow.update
  701. cmdwindow.update
  702. if Input.trigger?(Input::BACK)
  703. ret = -1
  704. break
  705. elsif Input.trigger?(Input::USE)
  706. ret = cmdwindow.index
  707. break
  708. end
  709. self.update
  710. end
  711. msgwindow.dispose
  712. cmdwindow.dispose
  713. Input.update
  714. return ret
  715. end
  716.  
  717. def pbSetArrow(arrow, selection)
  718. case selection
  719. when -1, -4, -5
  720. arrow.x = 488
  721. arrow.y = -24
  722. when -2
  723. arrow.x = 280
  724. arrow.y = 450
  725. when -3
  726. arrow.x = 600
  727. arrow.y = 450
  728. else
  729. arrow.x = (97 + (24 * (selection % PokemonBox::BOX_WIDTH))) * 2
  730. arrow.y = (8 + (24 * (selection / PokemonBox::BOX_WIDTH))) * 2
  731. end
  732. end
  733.  
  734. def pbChangeSelection(key, selection)
  735. case key
  736. when Input::UP
  737. case selection
  738. when -1
  739. selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH
  740. when -2, -3
  741. selection = 0
  742. else
  743. new_selection = selection - PokemonBox::BOX_WIDTH
  744. if new_selection < 0
  745. selection = -1 # Box name
  746. else
  747. selection = new_selection
  748. end
  749. end
  750. when Input::DOWN
  751. case selection
  752. when -1
  753. selection = 0
  754. when -2
  755. selection = 0
  756. when -3
  757. selection = 0
  758. else
  759. new_selection = selection + PokemonBox::BOX_WIDTH
  760. if new_selection >= PokemonBox::BOX_SIZE
  761. if (selection % PokemonBox::BOX_WIDTH) < (PokemonBox::BOX_WIDTH / 2)
  762. selection = -2 # Party
  763. else
  764. selection = -3 # Exit
  765. end
  766. else
  767. selection = new_selection
  768. end
  769. end
  770. when Input::LEFT
  771. if selection >= 0
  772. if (selection % PokemonBox::BOX_WIDTH) == 0
  773. selection += PokemonBox::BOX_WIDTH - 1
  774. else
  775. selection -= 1
  776. end
  777. elsif selection == -1
  778. selection = -4
  779. elsif selection == -2
  780. selection = -3
  781. elsif selection == -3
  782. selection = -2
  783. end
  784. when Input::RIGHT
  785. if selection >= 0
  786. if (selection % PokemonBox::BOX_WIDTH) == PokemonBox::BOX_WIDTH - 1
  787. selection -= PokemonBox::BOX_WIDTH - 1
  788. else
  789. selection += 1
  790. end
  791. elsif selection == -1
  792. selection = -5
  793. elsif selection == -2
  794. selection = -3
  795. elsif selection == -3
  796. selection = -2
  797. end
  798. end
  799. return selection
  800. end
  801.  
  802. def pbPartySetArrow(arrow, selection)
  803. return if selection < 0
  804. xvalues = [] # [200, 272, 200, 272, 200, 272, 236]
  805. yvalues = [] # [2, 18, 66, 82, 130, 146, 220]
  806. Settings::MAX_PARTY_SIZE.times do |i|
  807. xvalues.push(200 + (72 * (i % 2)))
  808. yvalues.push(190 + (16 * (i % 2)) + (64 * (i / 2)))
  809. end
  810. xvalues.push(268)
  811. yvalues.push(Graphics.height - 104)
  812. arrow.angle = 0
  813. arrow.mirror = false
  814. arrow.ox = 0
  815. arrow.oy = 0
  816. arrow.x = xvalues[selection]
  817. arrow.y = yvalues[selection]
  818. end
  819.  
  820. def pbPartyChangeSelection(key, selection)
  821. case key
  822. when Input::LEFT
  823. if selection == 1 || selection == 3 || selection == 5
  824. selection -= 1
  825. elsif selection == 6
  826. selection = 5
  827. end
  828.  
  829. when Input::RIGHT
  830. if selection == 0 || selection == 2 || selection == 4
  831. selection += 1
  832. elsif selection == 6
  833. selection = 0
  834. end
  835.  
  836. when Input::UP
  837. if selection == 6
  838. selection = 4
  839. elsif selection >= 2
  840. selection -= 2
  841. end
  842.  
  843. when Input::DOWN
  844. if selection < 4
  845. selection += 2
  846. elsif selection == 4 || selection == 5
  847. selection = 6
  848. elsif selection == 6
  849. selection = 0
  850. end
  851. end
  852.  
  853. return selection
  854. end
  855.  
  856. def pbSelectBoxInternal(_party)
  857. selection = @selection
  858. pbSetArrow(@sprites["arrow"], selection)
  859. pbUpdateOverlay(selection)
  860. pbSetMosaic(selection)
  861. loop do
  862. Graphics.update
  863. Input.update
  864. key = -1
  865. key = Input::DOWN if Input.repeat?(Input::DOWN)
  866. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  867. key = Input::LEFT if Input.repeat?(Input::LEFT)
  868. key = Input::UP if Input.repeat?(Input::UP)
  869. if key >= 0
  870. pbPlayCursorSE
  871. selection = pbChangeSelection(key, selection)
  872. pbSetArrow(@sprites["arrow"], selection)
  873. case selection
  874. when -4
  875. nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes
  876. pbSwitchBoxToLeft(nextbox)
  877. @storage.currentBox = nextbox
  878. when -5
  879. nextbox = (@storage.currentBox + 1) % @storage.maxBoxes
  880. pbSwitchBoxToRight(nextbox)
  881. @storage.currentBox = nextbox
  882. end
  883. selection = -1 if [-4, -5].include?(selection)
  884. pbUpdateOverlay(selection)
  885. pbSetMosaic(selection)
  886. end
  887. self.update
  888. if Input.trigger?(Input::JUMPUP)
  889. pbPlayCursorSE
  890. nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes
  891. pbSwitchBoxToLeft(nextbox)
  892. @storage.currentBox = nextbox
  893. pbUpdateOverlay(selection)
  894. pbSetMosaic(selection)
  895. elsif Input.trigger?(Input::JUMPDOWN)
  896. pbPlayCursorSE
  897. nextbox = (@storage.currentBox + 1) % @storage.maxBoxes
  898. pbSwitchBoxToRight(nextbox)
  899. @storage.currentBox = nextbox
  900. pbUpdateOverlay(selection)
  901. pbSetMosaic(selection)
  902. elsif Input.trigger?(Input::SPECIAL) # Jump to box name
  903. if selection != -1
  904. pbPlayCursorSE
  905. selection = -1
  906. pbSetArrow(@sprites["arrow"], selection)
  907. pbUpdateOverlay(selection)
  908. pbSetMosaic(selection)
  909. end
  910. elsif Input.trigger?(Input::ACTION) && @command == 0 # Organize only
  911. pbPlayDecisionSE
  912. pbSetQuickSwap(!@quickswap)
  913. elsif Input.trigger?(Input::BACK)
  914. @selection = selection
  915. return nil
  916. elsif Input.trigger?(Input::USE)
  917. @selection = selection
  918. if selection >= 0
  919. return [@storage.currentBox, selection]
  920. elsif selection == -1 # Box name
  921. return [-4, -1]
  922. elsif selection == -2 # Party Pokémon
  923. return [-2, -1]
  924. elsif selection == -3 # Close Box
  925. return [-3, -1]
  926. end
  927. end
  928. end
  929. end
  930.  
  931. def pbSelectBox(party)
  932. return pbSelectBoxInternal(party) if @command == 1 # Withdraw
  933. ret = nil
  934. loop do
  935. ret = pbSelectBoxInternal(party) if !@choseFromParty
  936. if @choseFromParty || (ret && ret[0] == -2) # Party Pokémon
  937. if !@choseFromParty
  938. pbShowPartyTab
  939. @selection = 0
  940. end
  941. ret = pbSelectPartyInternal(party, false)
  942. if ret < 0
  943. pbHidePartyTab
  944. @selection = -2
  945. @choseFromParty = false
  946. else
  947. @choseFromParty = true
  948. return [-1, ret]
  949. end
  950. else
  951. @choseFromParty = false
  952. return ret
  953. end
  954. end
  955. end
  956.  
  957. def pbSelectPartyInternal(party, depositing)
  958. selection = @selection
  959. pbPartySetArrow(@sprites["arrow"], selection)
  960. pbUpdateOverlay(selection, party)
  961. pbSetMosaic(selection)
  962. lastsel = 1
  963. loop do
  964. Graphics.update
  965. Input.update
  966. key = -1
  967. key = Input::DOWN if Input.repeat?(Input::DOWN)
  968. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  969. key = Input::LEFT if Input.repeat?(Input::LEFT)
  970. key = Input::UP if Input.repeat?(Input::UP)
  971. if key >= 0
  972. pbPlayCursorSE
  973. newselection = pbPartyChangeSelection(key, selection)
  974. case newselection
  975. when -1
  976. return -1 if !depositing
  977. when -2
  978. selection = lastsel
  979. else
  980. selection = newselection
  981. end
  982. pbPartySetArrow(@sprites["arrow"], selection)
  983. lastsel = selection if selection > 0
  984. pbUpdateOverlay(selection, party)
  985. pbSetMosaic(selection)
  986. end
  987. self.update
  988. if Input.trigger?(Input::ACTION) && @command == 0 # Organize only
  989. pbPlayDecisionSE
  990. pbSetQuickSwap(!@quickswap)
  991. elsif Input.trigger?(Input::BACK)
  992. @selection = selection
  993. return -1
  994. elsif Input.trigger?(Input::USE)
  995. if selection >= 0 && selection < Settings::MAX_PARTY_SIZE
  996. @selection = selection
  997. return selection
  998. elsif selection == Settings::MAX_PARTY_SIZE # Back
  999. @selection = selection
  1000. return -1
  1001. end
  1002. end
  1003. end
  1004. end
  1005.  
  1006. def pbSelectParty(party)
  1007. return pbSelectPartyInternal(party, true)
  1008. end
  1009.  
  1010. def pbChangeBackground(wp)
  1011. duration = 0.2 # Time in seconds to fade out or fade in
  1012. @sprites["box"].refreshSprites = false
  1013. Graphics.update
  1014. self.update
  1015. # Fade old background to white
  1016. timer_start = System.uptime
  1017. loop do
  1018. alpha = lerp(0, 255, duration, timer_start, System.uptime)
  1019. @sprites["box"].color = Color.new(248, 248, 248, alpha)
  1020. Graphics.update
  1021. self.update
  1022. break if alpha >= 255
  1023. end
  1024. # Fade in new background from white
  1025. @sprites["box"].refreshBox = true
  1026. @storage[@storage.currentBox].background = wp
  1027. timer_start = System.uptime
  1028. loop do
  1029. alpha = lerp(255, 0, duration, timer_start, System.uptime)
  1030. @sprites["box"].color = Color.new(248, 248, 248, alpha)
  1031. Graphics.update
  1032. self.update
  1033. break if alpha <= 0
  1034. end
  1035. @sprites["box"].refreshSprites = true
  1036. Input.update
  1037. end
  1038.  
  1039. def pbSwitchBoxToRight(new_box_number)
  1040. start_x = @sprites["box"].x
  1041. newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
  1042. newbox.x = start_x + 336
  1043. timer_start = System.uptime
  1044. loop do
  1045. @sprites["box"].x = lerp(start_x, start_x - 336, 0.25, timer_start, System.uptime)
  1046. newbox.x = @sprites["box"].x + 336
  1047. self.update
  1048. Graphics.update
  1049. break if newbox.x == start_x
  1050. end
  1051. @sprites["box"].dispose
  1052. @sprites["box"] = newbox
  1053. Input.update
  1054. end
  1055.  
  1056. def pbSwitchBoxToLeft(new_box_number)
  1057. start_x = @sprites["box"].x
  1058. newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
  1059. newbox.x = start_x - 336
  1060. timer_start = System.uptime
  1061. loop do
  1062. @sprites["box"].x = lerp(start_x, start_x + 336, 0.25, timer_start, System.uptime)
  1063. newbox.x = @sprites["box"].x - 336
  1064. self.update
  1065. Graphics.update
  1066. break if newbox.x == start_x
  1067. end
  1068. @sprites["box"].dispose
  1069. @sprites["box"] = newbox
  1070. Input.update
  1071. end
  1072.  
  1073. def pbJumpToBox(newbox)
  1074. return if @storage.currentBox == newbox
  1075. if newbox > @storage.currentBox
  1076. pbSwitchBoxToRight(newbox)
  1077. else
  1078. pbSwitchBoxToLeft(newbox)
  1079. end
  1080. @storage.currentBox = newbox
  1081. end
  1082.  
  1083. def pbSetMosaic(selection)
  1084. return if @screen.pbHeldPokemon
  1085. return if @boxForMosaic == @storage.currentBox && @selectionForMosaic == selection
  1086. @sprites["pokemon"].mosaic_duration = 0.25 # In seconds
  1087. @boxForMosaic = @storage.currentBox
  1088. @selectionForMosaic = selection
  1089. end
  1090.  
  1091. def pbSetQuickSwap(value)
  1092. @quickswap = value
  1093. @sprites["arrow"].quickswap = value
  1094. end
  1095.  
  1096. def pbShowPartyTab
  1097. @sprites["arrow"].visible = false
  1098. pbUpdateOverlay(-1)
  1099. pbSetMosaic(-1)
  1100. end
  1101. pbSEPlay("GUI storage show party panel")
  1102. start_y = @sprites["boxparty"].y # Graphics.height
  1103. timer_start = System.uptime
  1104. loop do
  1105. @sprites["boxparty"].y = lerp(start_y, start_y - @sprites["boxparty"].height,
  1106. 0.4, timer_start, System.uptime)
  1107. self.update
  1108. Graphics.update
  1109. break if @sprites["boxparty"].y == start_y - @sprites["boxparty"].height
  1110. end
  1111. Input.update
  1112. @sprites["arrow"].visible = true
  1113. end
  1114.  
  1115. def pbHidePartyTab
  1116. @sprites["arrow"].visible = false
  1117. pbUpdateOverlay(-1)
  1118. pbSetMosaic(-1)
  1119. end
  1120. pbSEPlay("GUI storage hide party panel")
  1121. start_y = @sprites["boxparty"].y # Graphics.height - @sprites["boxparty"].height
  1122. timer_start = System.uptime
  1123. loop do
  1124. @sprites["boxparty"].y = lerp(start_y, start_y + @sprites["boxparty"].height,
  1125. 0.4, timer_start, System.uptime)
  1126. self.update
  1127. Graphics.update
  1128. break if @sprites["boxparty"].y == start_y + @sprites["boxparty"].height
  1129. end
  1130. Input.update
  1131. @sprites["arrow"].visible = true
  1132. end
  1133.  
  1134. def pbHold(selected)
  1135. pbSEPlay("GUI storage pick up")
  1136. if selected[0] == -1
  1137. @sprites["boxparty"].grabPokemon(selected[1], @sprites["arrow"])
  1138. else
  1139. @sprites["box"].grabPokemon(selected[1], @sprites["arrow"])
  1140. end
  1141. while @sprites["arrow"].grabbing?
  1142. Graphics.update
  1143. Input.update
  1144. self.update
  1145. end
  1146. end
  1147.  
  1148. def pbSwap(selected, _heldpoke)
  1149. pbSEPlay("GUI storage pick up")
  1150. heldpokesprite = @sprites["arrow"].heldPokemon
  1151. boxpokesprite = nil
  1152. if selected[0] == -1
  1153. boxpokesprite = @sprites["boxparty"].getPokemon(selected[1])
  1154. else
  1155. boxpokesprite = @sprites["box"].getPokemon(selected[1])
  1156. end
  1157. if selected[0] == -1
  1158. @sprites["boxparty"].setPokemon(selected[1], heldpokesprite)
  1159. else
  1160. @sprites["box"].setPokemon(selected[1], heldpokesprite)
  1161. end
  1162. @sprites["arrow"].setSprite(boxpokesprite)
  1163. @sprites["pokemon"].mosaic_duration = 0.25 # In seconds
  1164. @boxForMosaic = @storage.currentBox
  1165. @selectionForMosaic = selected[1]
  1166. end
  1167.  
  1168. def pbPlace(selected, _heldpoke)
  1169. pbSEPlay("GUI storage put down")
  1170. heldpokesprite = @sprites["arrow"].heldPokemon
  1171. @sprites["arrow"].place
  1172. while @sprites["arrow"].placing?
  1173. Graphics.update
  1174. Input.update
  1175. self.update
  1176. end
  1177. if selected[0] == -1
  1178. @sprites["boxparty"].setPokemon(selected[1], heldpokesprite)
  1179. else
  1180. @sprites["box"].setPokemon(selected[1], heldpokesprite)
  1181. end
  1182. @boxForMosaic = @storage.currentBox
  1183. @selectionForMosaic = selected[1]
  1184. end
  1185.  
  1186. def pbWithdraw(selected, heldpoke, partyindex)
  1187. pbHold(selected) if !heldpoke
  1188. pbShowPartyTab
  1189. pbPartySetArrow(@sprites["arrow"], partyindex)
  1190. pbPlace([-1, partyindex], heldpoke)
  1191. pbHidePartyTab
  1192. end
  1193.  
  1194. def pbStore(selected, heldpoke, destbox, firstfree)
  1195. if heldpoke
  1196. if destbox == @storage.currentBox
  1197. heldpokesprite = @sprites["arrow"].heldPokemon
  1198. @sprites["box"].setPokemon(firstfree, heldpokesprite)
  1199. @sprites["arrow"].setSprite(nil)
  1200. else
  1201. @sprites["arrow"].deleteSprite
  1202. end
  1203. else
  1204. sprite = @sprites["boxparty"].getPokemon(selected[1])
  1205. if destbox == @storage.currentBox
  1206. @sprites["box"].setPokemon(firstfree, sprite)
  1207. @sprites["boxparty"].setPokemon(selected[1], nil)
  1208. else
  1209. @sprites["boxparty"].deletePokemon(selected[1])
  1210. end
  1211. end
  1212. end
  1213.  
  1214. def pbRelease(selected, heldpoke)
  1215. box = selected[0]
  1216. index = selected[1]
  1217. if heldpoke
  1218. sprite = @sprites["arrow"].heldPokemon
  1219. elsif box == -1
  1220. sprite = @sprites["boxparty"].getPokemon(index)
  1221. else
  1222. sprite = @sprites["box"].getPokemon(index)
  1223. end
  1224. if sprite
  1225. sprite.release
  1226. while sprite.releasing?
  1227. Graphics.update
  1228. sprite.update
  1229. self.update
  1230. end
  1231. end
  1232. end
  1233.  
  1234. def pbChooseBox(msg)
  1235. commands = []
  1236. @storage.maxBoxes.times do |i|
  1237. box = @storage[i]
  1238. if box
  1239. commands.push(_INTL("{1} ({2}/{3})", box.name, box.nitems, box.length))
  1240. end
  1241. end
  1242. return pbShowCommands(msg, commands, @storage.currentBox)
  1243. end
  1244.  
  1245. def pbBoxName(helptext, minchars, maxchars)
  1246. oldsprites = pbFadeOutAndHide(@sprites)
  1247. ret = pbEnterBoxName(helptext, minchars, maxchars)
  1248. @storage[@storage.currentBox].name = ret if ret.length > 0
  1249. @sprites["box"].refreshBox = true
  1250. pbRefresh
  1251. pbFadeInAndShow(@sprites, oldsprites)
  1252. end
  1253.  
  1254. def pbChooseItem(bag)
  1255. ret = nil
  1256. pbFadeOutIn do
  1257. scene = PokemonBag_Scene.new
  1258. screen = PokemonBagScreen.new(scene, bag)
  1259. ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? })
  1260. end
  1261. return ret
  1262. end
  1263.  
  1264. def pbSummary(selected, heldpoke)
  1265. oldsprites = pbFadeOutAndHide(@sprites)
  1266. scene = PokemonSummary_Scene.new
  1267. screen = PokemonSummaryScreen.new(scene)
  1268. if heldpoke
  1269. screen.pbStartScreen([heldpoke], 0)
  1270. elsif selected[0] == -1
  1271. @selection = screen.pbStartScreen(@storage.party, selected[1])
  1272. pbPartySetArrow(@sprites["arrow"], @selection)
  1273. pbUpdateOverlay(@selection, @storage.party)
  1274. else
  1275. @selection = screen.pbStartScreen(@storage.boxes[selected[0]], selected[1])
  1276. pbSetArrow(@sprites["arrow"], @selection)
  1277. pbUpdateOverlay(@selection)
  1278. end
  1279. pbFadeInAndShow(@sprites, oldsprites)
  1280. end
  1281.  
  1282. def pbMarkingSetArrow(arrow, selection)
  1283. if selection >= 0
  1284. xvalues = [162, 191, 220, 162, 191, 220, 184, 184]
  1285. yvalues = [24, 24, 24, 49, 49, 49, 77, 109]
  1286. arrow.angle = 0
  1287. arrow.mirror = false
  1288. arrow.ox = 0
  1289. arrow.oy = 0
  1290. arrow.x = xvalues[selection] * 2
  1291. arrow.y = yvalues[selection] * 2
  1292. end
  1293. end
  1294.  
  1295. def pbMarkingChangeSelection(key, selection)
  1296. case key
  1297. when Input::LEFT
  1298. if selection < 6
  1299. selection -= 1
  1300. selection += 3 if selection % 3 == 2
  1301. end
  1302. when Input::RIGHT
  1303. if selection < 6
  1304. selection += 1
  1305. selection -= 3 if selection % 3 == 0
  1306. end
  1307. when Input::UP
  1308. if selection == 7
  1309. selection = 6
  1310. elsif selection == 6
  1311. selection = 4
  1312. elsif selection < 3
  1313. selection = 7
  1314. else
  1315. selection -= 3
  1316. end
  1317. when Input::DOWN
  1318. if selection == 7
  1319. selection = 1
  1320. elsif selection == 6
  1321. selection = 7
  1322. elsif selection >= 3
  1323. selection = 6
  1324. else
  1325. selection += 3
  1326. end
  1327. end
  1328. return selection
  1329. end
  1330.  
  1331. def pbMark(selected, heldpoke)
  1332. @sprites["markingbg"].visible = true
  1333. @sprites["markingoverlay"].visible = true
  1334. msg = _INTL("Mark your Pokémon.")
  1335. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  1336. msgwindow.viewport = @viewport
  1337. msgwindow.visible = true
  1338. msgwindow.letterbyletter = false
  1339. msgwindow.text = msg
  1340. msgwindow.resizeHeightToFit(msg, Graphics.width - 180)
  1341. pbBottomRight(msgwindow)
  1342. base = Color.new(248, 248, 248)
  1343. shadow = Color.new(80, 80, 80)
  1344. pokemon = heldpoke
  1345. if heldpoke
  1346. pokemon = heldpoke
  1347. elsif selected[0] == -1
  1348. pokemon = @storage.party[selected[1]]
  1349. else
  1350. pokemon = @storage.boxes[selected[0]][selected[1]]
  1351. end
  1352. markings = pokemon.markings.clone
  1353. mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT
  1354. index = 0
  1355. redraw = true
  1356. markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT)
  1357. loop do
  1358. # Redraw the markings and text
  1359. if redraw
  1360. @sprites["markingoverlay"].bitmap.clear
  1361. (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
  1362. markrect.x = i * MARK_WIDTH
  1363. markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
  1364. @sprites["markingoverlay"].bitmap.blt(336 + (58 * (i % 3)), 106 + (50 * (i / 3)),
  1365. @markingbitmap.bitmap, markrect)
  1366. end
  1367. textpos = [
  1368. [_INTL("OK"), 402, 216, :center, base, shadow, :outline],
  1369. [_INTL("Cancel"), 402, 280, :center, base, shadow, :outline]
  1370. ]
  1371. pbDrawTextPositions(@sprites["markingoverlay"].bitmap, textpos)
  1372. pbMarkingSetArrow(@sprites["arrow"], index)
  1373. redraw = false
  1374. end
  1375. Graphics.update
  1376. Input.update
  1377. key = -1
  1378. key = Input::DOWN if Input.repeat?(Input::DOWN)
  1379. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  1380. key = Input::LEFT if Input.repeat?(Input::LEFT)
  1381. key = Input::UP if Input.repeat?(Input::UP)
  1382. if key >= 0
  1383. oldindex = index
  1384. index = pbMarkingChangeSelection(key, index)
  1385. pbPlayCursorSE if index != oldindex
  1386. pbMarkingSetArrow(@sprites["arrow"], index)
  1387. end
  1388. self.update
  1389. if Input.trigger?(Input::BACK)
  1390. pbPlayCancelSE
  1391. break
  1392. elsif Input.trigger?(Input::USE)
  1393. pbPlayDecisionSE
  1394. case index
  1395. when 6 # OK
  1396. pokemon.markings = markings
  1397. break
  1398. when 7 # Cancel
  1399. break
  1400. else
  1401. markings[index] = ((markings[index] || 0) + 1) % mark_variants
  1402. redraw = true
  1403. end
  1404. end
  1405. end
  1406. @sprites["markingbg"].visible = false
  1407. @sprites["markingoverlay"].visible = false
  1408. msgwindow.dispose
  1409. end
  1410.  
  1411. def pbRefresh
  1412. @sprites["box"].refresh
  1413. @sprites["boxparty"].refresh
  1414. end
  1415.  
  1416. def pbHardRefresh
  1417. @sprites["box"].refresh
  1418. @sprites["boxparty"].refresh
  1419. end
  1420.  
  1421. def drawMarkings(bitmap, x, y, _width, _height, markings)
  1422. mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT
  1423. markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT)
  1424. (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
  1425. markrect.x = i * MARK_WIDTH
  1426. markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
  1427. bitmap.blt(x + (i * MARK_WIDTH), y, @markingbitmap.bitmap, markrect)
  1428. end
  1429. end
  1430.  
  1431. def pbUpdateOverlay(selection, party = nil)
  1432. overlay = @sprites["overlay"].bitmap
  1433. overlay.clear
  1434. buttonbase = Color.new(248, 248, 248)
  1435. buttonshadow = Color.new(80, 80, 80)
  1436. pbDrawTextPositions(
  1437. overlay,
  1438. [[_INTL("Party: {1}", (@storage.party.length rescue 0)), 280, 470, :center, buttonbase, buttonshadow, :outline],
  1439. [_INTL("Exit"), 600, 470, :center, buttonbase, buttonshadow, :outline]]
  1440. )
  1441. pokemon = nil
  1442. if @screen.pbHeldPokemon
  1443. pokemon = @screen.pbHeldPokemon
  1444. elsif selection >= 0
  1445. pokemon = (party) ? party[selection] : @storage[@storage.currentBox, selection]
  1446. end
  1447. if !pokemon
  1448. @sprites["pokemon"].visible = false
  1449. return
  1450. end
  1451. @sprites["pokemon"].visible = true
  1452. base = Color.new(88, 88, 80)
  1453. shadow = Color.new(168, 184, 184)
  1454. nonbase = Color.new(208, 208, 208)
  1455. nonshadow = Color.new(224, 224, 224)
  1456. pokename = pokemon.name
  1457. textstrings = [
  1458. [pokename, 10, 14, :left, base, shadow]
  1459. ]
  1460. if !pokemon.egg?
  1461. imagepos = []
  1462. if pokemon.male?
  1463. textstrings.push([_INTL("♂"), 148, 14, :left, Color.new(24, 112, 216), Color.new(136, 168, 208)])
  1464. elsif pokemon.female?
  1465. textstrings.push([_INTL("♀"), 148, 14, :left, Color.new(248, 56, 32), Color.new(224, 152, 144)])
  1466. end
  1467. imagepos.push([_INTL("Graphics/UI/Storage/overlay_lv"), 6, 246])
  1468. textstrings.push([pokemon.level.to_s, 28, 240, :left, base, shadow])
  1469. if pokemon.ability
  1470. textstrings.push([pokemon.ability.name, 86, 312, :center, base, shadow])
  1471. else
  1472. textstrings.push([_INTL("No ability"), 86, 312, :center, nonbase, nonshadow])
  1473. end
  1474. if pokemon.item
  1475. textstrings.push([pokemon.item.name, 86, 348, :center, base, shadow])
  1476. else
  1477. textstrings.push([_INTL("No item"), 86, 348, :center, nonbase, nonshadow])
  1478. end
  1479. imagepos.push(["Graphics/UI/shiny", 156, 198]) if pokemon.shiny?
  1480. typebitmap = AnimatedBitmap.new(_INTL("Graphics/UI/types"))
  1481.  
  1482. pokemon.types.each_with_index do |type, i|
  1483. type_number = GameData::Type.get(type).icon_position
  1484. type_rect = Rect.new(0, type_number * 28, 64, 28)
  1485. type_x = (pokemon.types.length == 1) ? 52 : 18 + (70 * i)
  1486. overlay.blt(type_x, 272, typebitmap.bitmap, type_rect)
  1487. end
  1488.  
  1489. typebitmap.dispose
  1490. drawMarkings(overlay, 70, 240, 128, 20, pokemon.markings)
  1491. pbDrawImagePositions(overlay, imagepos)
  1492. end
  1493. pbDrawTextPositions(overlay, textstrings)
  1494. @sprites["pokemon"].setPokemonBitmap(pokemon)
  1495. end
  1496.  
  1497. def update
  1498. pbUpdateSpriteHash(@sprites)
  1499. end
  1500. end
  1501.  
  1502. #===============================================================================
  1503. # Pokémon storage mechanics
  1504. #===============================================================================
  1505. class PokemonStorageScreen
  1506. attr_reader :scene
  1507. attr_reader :storage
  1508. attr_accessor :heldpkmn
  1509.  
  1510. def initialize(scene, storage)
  1511. @scene = scene
  1512. @storage = storage
  1513. @pbHeldPokemon = nil
  1514. end
  1515.  
  1516. def pbStartScreen(command)
  1517. $game_temp.in_storage = true
  1518. @heldpkmn = nil
  1519. case command
  1520. when 0 # Organise
  1521. @scene.pbStartBox(self, command)
  1522. loop do
  1523. selected = @scene.pbSelectBox(@storage.party)
  1524. if selected.nil?
  1525. if pbHeldPokemon
  1526. pbDisplay(_INTL("You're holding a Pokémon!"))
  1527. next
  1528. end
  1529. next if pbConfirm(_INTL("Continue Box operations?"))
  1530. break
  1531. elsif selected[0] == -3 # Close box
  1532. if pbHeldPokemon
  1533. pbDisplay(_INTL("You're holding a Pokémon!"))
  1534. next
  1535. end
  1536. if pbConfirm(_INTL("Exit from the Box?"))
  1537. pbSEPlay("PC close")
  1538. break
  1539. end
  1540. next
  1541. elsif selected[0] == -4 # Box name
  1542. pbBoxCommands
  1543. else
  1544. pokemon = @storage[selected[0], selected[1]]
  1545. heldpoke = pbHeldPokemon
  1546. next if !pokemon && !heldpoke
  1547. if @scene.quickswap
  1548. if @heldpkmn
  1549. (pokemon) ? pbSwap(selected) : pbPlace(selected)
  1550. else
  1551. pbHold(selected)
  1552. end
  1553. else
  1554. commands = []
  1555. cmdMove = -1
  1556. cmdSummary = -1
  1557. cmdWithdraw = -1
  1558. cmdItem = -1
  1559. cmdMark = -1
  1560. cmdRelease = -1
  1561. cmdDebug = -1
  1562. if heldpoke
  1563. helptext = _INTL("{1} is selected.", heldpoke.name)
  1564. commands[cmdMove = commands.length] = (pokemon) ? _INTL("Shift") : _INTL("Place")
  1565. elsif pokemon
  1566. helptext = _INTL("{1} is selected.", pokemon.name)
  1567. commands[cmdMove = commands.length] = _INTL("Move")
  1568. end
  1569. commands[cmdSummary = commands.length] = _INTL("Summary")
  1570. commands[cmdWithdraw = commands.length] = (selected[0] == -1) ? _INTL("Store") : _INTL("Withdraw")
  1571. commands[cmdItem = commands.length] = _INTL("Item")
  1572. commands[cmdMark = commands.length] = _INTL("Mark")
  1573. commands[cmdRelease = commands.length] = _INTL("Release")
  1574. commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
  1575. commands[commands.length] = _INTL("Cancel")
  1576. command = pbShowCommands(helptext, commands)
  1577. if cmdMove >= 0 && command == cmdMove # Move/Shift/Place
  1578. if @heldpkmn
  1579. (pokemon) ? pbSwap(selected) : pbPlace(selected)
  1580. else
  1581. pbHold(selected)
  1582. end
  1583. elsif cmdSummary >= 0 && command == cmdSummary # Summary
  1584. pbSummary(selected, @heldpkmn)
  1585. elsif cmdWithdraw >= 0 && command == cmdWithdraw # Store/Withdraw
  1586. (selected[0] == -1) ? pbStore(selected, @heldpkmn) : pbWithdraw(selected, @heldpkmn)
  1587. elsif cmdItem >= 0 && command == cmdItem # Item
  1588. pbItem(selected, @heldpkmn)
  1589. elsif cmdMark >= 0 && command == cmdMark # Mark
  1590. pbMark(selected, @heldpkmn)
  1591. elsif cmdRelease >= 0 && command == cmdRelease # Release
  1592. pbRelease(selected, @heldpkmn)
  1593. elsif cmdDebug >= 0 && command == cmdDebug # Debug
  1594. pbPokemonDebug((@heldpkmn) ? @heldpkmn : pokemon, selected, heldpoke)
  1595. end
  1596. end
  1597. end
  1598. end
  1599. @scene.pbCloseBox
  1600. when 1 # Withdraw
  1601. @scene.pbStartBox(self, command)
  1602. loop do
  1603. selected = @scene.pbSelectBox(@storage.party)
  1604. if selected.nil?
  1605. next if pbConfirm(_INTL("Continue Box operations?"))
  1606. break
  1607. else
  1608. case selected[0]
  1609. when -2 # Party Pokémon
  1610. pbDisplay(_INTL("Which one will you take?"))
  1611. next
  1612. when -3 # Close box
  1613. if pbConfirm(_INTL("Exit from the Box?"))
  1614. pbSEPlay("PC close")
  1615. break
  1616. end
  1617. next
  1618. when -4 # Box name
  1619. pbBoxCommands
  1620. next
  1621. end
  1622. pokemon = @storage[selected[0], selected[1]]
  1623. next if !pokemon
  1624. command = pbShowCommands(_INTL("{1} is selected.", pokemon.name),
  1625. [_INTL("Withdraw"),
  1626. _INTL("Summary"),
  1627. _INTL("Mark"),
  1628. _INTL("Release"),
  1629. _INTL("Cancel")])
  1630. case command
  1631. when 0 then pbWithdraw(selected, nil)
  1632. when 1 then pbSummary(selected, nil)
  1633. when 2 then pbMark(selected, nil)
  1634. when 3 then pbRelease(selected, nil)
  1635. end
  1636. end
  1637. end
  1638. @scene.pbCloseBox
  1639. when 2 # Deposit
  1640. @scene.pbStartBox(self, command)
  1641. loop do
  1642. selected = @scene.pbSelectParty(@storage.party)
  1643. if selected == -3 # Close box
  1644. if pbConfirm(_INTL("Exit from the Box?"))
  1645. pbSEPlay("PC close")
  1646. break
  1647. end
  1648. next
  1649. elsif selected < 0
  1650. next if pbConfirm(_INTL("Continue Box operations?"))
  1651. break
  1652. else
  1653. pokemon = @storage[-1, selected]
  1654. next if !pokemon
  1655. command = pbShowCommands(_INTL("{1} is selected.", pokemon.name),
  1656. [_INTL("Store"),
  1657. _INTL("Summary"),
  1658. _INTL("Mark"),
  1659. _INTL("Release"),
  1660. _INTL("Cancel")])
  1661. case command
  1662. when 0 then pbStore([-1, selected], nil)
  1663. when 1 then pbSummary([-1, selected], nil)
  1664. when 2 then pbMark([-1, selected], nil)
  1665. when 3 then pbRelease([-1, selected], nil)
  1666. end
  1667. end
  1668. end
  1669. @scene.pbCloseBox
  1670. when 3
  1671. @scene.pbStartBox(self, command)
  1672. @scene.pbCloseBox
  1673. end
  1674. $game_temp.in_storage = false
  1675. end
  1676.  
  1677. # For debug purposes.
  1678. def pbUpdate
  1679. @scene.update
  1680. end
  1681.  
  1682. # For debug purposes.
  1683. def pbHardRefresh
  1684. @scene.pbHardRefresh
  1685. end
  1686.  
  1687. # For debug purposes.
  1688. def pbRefreshSingle(i)
  1689. @scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil)
  1690. @scene.pbHardRefresh
  1691. end
  1692.  
  1693. def pbDisplay(message)
  1694. @scene.pbDisplay(message)
  1695. end
  1696.  
  1697. def pbConfirm(str)
  1698. return pbShowCommands(str, [_INTL("Yes"), _INTL("No")]) == 0
  1699. end
  1700.  
  1701. def pbShowCommands(msg, commands, index = 0)
  1702. return @scene.pbShowCommands(msg, commands, index)
  1703. end
  1704.  
  1705. def pbAble?(pokemon)
  1706. pokemon && !pokemon.egg? && pokemon.hp > 0
  1707. end
  1708.  
  1709. def pbAbleCount
  1710. count = 0
  1711. @storage.party.each do |p|
  1712. count += 1 if pbAble?(p)
  1713. end
  1714. return count
  1715. end
  1716.  
  1717. def pbHeldPokemon
  1718. return @heldpkmn
  1719. end
  1720.  
  1721. def pbWithdraw(selected, heldpoke)
  1722. box = selected[0]
  1723. index = selected[1]
  1724. raise _INTL("Can't withdraw from party...") if box == -1
  1725. if @storage.party_full?
  1726. pbDisplay(_INTL("Your party's full!"))
  1727. return false
  1728. end
  1729. @scene.pbWithdraw(selected, heldpoke, @storage.party.length)
  1730. if heldpoke
  1731. @storage.pbMoveCaughtToParty(heldpoke)
  1732. @heldpkmn = nil
  1733. else
  1734. @storage.pbMove(-1, -1, box, index)
  1735. end
  1736. @scene.pbRefresh
  1737. return true
  1738. end
  1739.  
  1740. def pbStore(selected, heldpoke)
  1741. box = selected[0]
  1742. index = selected[1]
  1743. raise _INTL("Can't deposit from box...") if box != -1
  1744. if pbAbleCount <= 1 && pbAble?(@storage[box, index]) && !heldpoke
  1745. pbPlayBuzzerSE
  1746. pbDisplay(_INTL("That's your last Pokémon!"))
  1747. elsif heldpoke&.mail
  1748. pbDisplay(_INTL("Please remove the Mail."))
  1749. elsif !heldpoke && @storage[box, index].mail
  1750. pbDisplay(_INTL("Please remove the Mail."))
  1751. elsif heldpoke&.cannot_store
  1752. pbDisplay(_INTL("{1} refuses to go into storage!", heldpoke.name))
  1753. elsif !heldpoke && @storage[box, index].cannot_store
  1754. pbDisplay(_INTL("{1} refuses to go into storage!", @storage[box, index].name))
  1755. else
  1756. loop do
  1757. destbox = @scene.pbChooseBox(_INTL("Deposit in which Box?"))
  1758. if destbox >= 0
  1759. firstfree = @storage.pbFirstFreePos(destbox)
  1760. if firstfree < 0
  1761. pbDisplay(_INTL("The Box is full."))
  1762. next
  1763. end
  1764. if heldpoke || selected[0] == -1
  1765. p = (heldpoke) ? heldpoke : @storage[-1, index]
  1766. if Settings::HEAL_STORED_POKEMON
  1767. old_ready_evo = p.ready_to_evolve
  1768. p.heal
  1769. p.ready_to_evolve = old_ready_evo
  1770. end
  1771. end
  1772. @scene.pbStore(selected, heldpoke, destbox, firstfree)
  1773. if heldpoke
  1774. @storage.pbMoveCaughtToBox(heldpoke, destbox)
  1775. @heldpkmn = nil
  1776. else
  1777. @storage.pbMove(destbox, -1, -1, index)
  1778. end
  1779. end
  1780. break
  1781. end
  1782. @scene.pbRefresh
  1783. end
  1784. end
  1785.  
  1786. def pbHold(selected)
  1787. box = selected[0]
  1788. index = selected[1]
  1789. if box == -1 && pbAble?(@storage[box, index]) && pbAbleCount <= 1
  1790. pbPlayBuzzerSE
  1791. pbDisplay(_INTL("That's your last Pokémon!"))
  1792. return
  1793. end
  1794. @scene.pbHold(selected)
  1795. @heldpkmn = @storage[box, index]
  1796. @storage.pbDelete(box, index)
  1797. @scene.pbRefresh
  1798. end
  1799.  
  1800. def pbPlace(selected)
  1801. box = selected[0]
  1802. index = selected[1]
  1803. if @storage[box, index]
  1804. raise _INTL("Position {1},{2} is not empty...", box, index)
  1805. elsif box != -1
  1806. if index >= @storage.maxPokemon(box)
  1807. pbDisplay("Can't place that there.")
  1808. return
  1809. elsif @heldpkmn.mail
  1810. pbDisplay("Please remove the mail.")
  1811. return
  1812. elsif @heldpkmn.cannot_store
  1813. pbDisplay(_INTL("{1} refuses to go into storage!", @heldpkmn.name))
  1814. return
  1815. end
  1816. end
  1817. if Settings::HEAL_STORED_POKEMON && box >= 0
  1818. old_ready_evo = @heldpkmn.ready_to_evolve
  1819. @heldpkmn.heal
  1820. @heldpkmn.ready_to_evolve = old_ready_evo
  1821. end
  1822. @scene.pbPlace(selected, @heldpkmn)
  1823. @storage[box, index] = @heldpkmn
  1824. @storage.party.compact! if box == -1
  1825. @scene.pbRefresh
  1826. @heldpkmn = nil
  1827. end
  1828.  
  1829. def pbSwap(selected)
  1830. box = selected[0]
  1831. index = selected[1]
  1832. if !@storage[box, index]
  1833. raise _INTL("Position {1},{2} is empty...", box, index)
  1834. end
  1835. if @heldpkmn.cannot_store && box != -1
  1836. pbPlayBuzzerSE
  1837. pbDisplay(_INTL("{1} refuses to go into storage!", @heldpkmn.name))
  1838. return false
  1839. elsif box == -1 && pbAble?(@storage[box, index]) && pbAbleCount <= 1 && !pbAble?(@heldpkmn)
  1840. pbPlayBuzzerSE
  1841. pbDisplay(_INTL("That's your last Pokémon!"))
  1842. return false
  1843. end
  1844. if box != -1 && @heldpkmn.mail
  1845. pbDisplay("Please remove the mail.")
  1846. return false
  1847. end
  1848. if Settings::HEAL_STORED_POKEMON && box >= 0
  1849. old_ready_evo = @heldpkmn.ready_to_evolve
  1850. @heldpkmn.heal
  1851. @heldpkmn.ready_to_evolve = old_ready_evo
  1852. end
  1853. @scene.pbSwap(selected, @heldpkmn)
  1854. tmp = @storage[box, index]
  1855. @storage[box, index] = @heldpkmn
  1856. @heldpkmn = tmp
  1857. @scene.pbRefresh
  1858. return true
  1859. end
  1860.  
  1861. def pbRelease(selected, heldpoke)
  1862. box = selected[0]
  1863. index = selected[1]
  1864. pokemon = (heldpoke) ? heldpoke : @storage[box, index]
  1865. return if !pokemon
  1866. if pokemon.egg?
  1867. pbDisplay(_INTL("You can't release an Egg."))
  1868. return false
  1869. elsif pokemon.mail
  1870. pbDisplay(_INTL("Please remove the mail."))
  1871. return false
  1872. elsif pokemon.cannot_release
  1873. pbDisplay(_INTL("{1} refuses to leave you!", pokemon.name))
  1874. return false
  1875. end
  1876. if box == -1 && pbAbleCount <= 1 && pbAble?(pokemon) && !heldpoke
  1877. pbPlayBuzzerSE
  1878. pbDisplay(_INTL("That's your last Pokémon!"))
  1879. return
  1880. end
  1881. command = pbShowCommands(_INTL("Release this Pokémon?"), [_INTL("No"), _INTL("Yes")])
  1882. if command == 1
  1883. pkmnname = pokemon.name
  1884. @scene.pbRelease(selected, heldpoke)
  1885. if heldpoke
  1886. @heldpkmn = nil
  1887. else
  1888. @storage.pbDelete(box, index)
  1889. end
  1890. @scene.pbRefresh
  1891. pbDisplay(_INTL("{1} was released.", pkmnname))
  1892. pbDisplay(_INTL("Bye-bye, {1}!", pkmnname))
  1893. @scene.pbRefresh
  1894. end
  1895. return
  1896. end
  1897.  
  1898. def pbChooseMove(pkmn, helptext, index = 0)
  1899. movenames = []
  1900. pkmn.moves.each do |i|
  1901. if i.total_pp <= 0
  1902. movenames.push(_INTL("{1} (PP: ---)", i.name))
  1903. else
  1904. movenames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp))
  1905. end
  1906. end
  1907. return @scene.pbShowCommands(helptext, movenames, index)
  1908. end
  1909.  
  1910. def pbSummary(selected, heldpoke)
  1911. @scene.pbSummary(selected, heldpoke)
  1912. end
  1913.  
  1914. def pbMark(selected, heldpoke)
  1915. @scene.pbMark(selected, heldpoke)
  1916. end
  1917.  
  1918. def pbItem(selected, heldpoke)
  1919. box = selected[0]
  1920. index = selected[1]
  1921. pokemon = (heldpoke) ? heldpoke : @storage[box, index]
  1922. if pokemon.egg?
  1923. pbDisplay(_INTL("Eggs can't hold items."))
  1924. return
  1925. elsif pokemon.mail
  1926. pbDisplay(_INTL("Please remove the mail."))
  1927. return
  1928. end
  1929. if pokemon.item
  1930. itemname = pokemon.item.portion_name
  1931. if pbConfirm(_INTL("Take the {1}?", itemname))
  1932. if $bag.add(pokemon.item)
  1933. pbDisplay(_INTL("Took the {1}.", itemname))
  1934. pokemon.item = nil
  1935. @scene.pbHardRefresh
  1936. else
  1937. pbDisplay(_INTL("Can't store the {1}.", itemname))
  1938. end
  1939. end
  1940. else
  1941. item = scene.pbChooseItem($bag)
  1942. if item
  1943. itemname = GameData::Item.get(item).name
  1944. pokemon.item = item
  1945. $bag.remove(item)
  1946. pbDisplay(_INTL("{1} is now being held.", itemname))
  1947. @scene.pbHardRefresh
  1948. end
  1949. end
  1950. end
  1951.  
  1952. def pbBoxCommands
  1953. commands = [
  1954. _INTL("Jump"),
  1955. _INTL("Wallpaper"),
  1956. _INTL("Name"),
  1957. _INTL("Cancel")
  1958. ]
  1959. command = pbShowCommands(_INTL("What do you want to do?"), commands)
  1960. case command
  1961. when 0
  1962. destbox = @scene.pbChooseBox(_INTL("Jump to which Box?"))
  1963. @scene.pbJumpToBox(destbox) if destbox >= 0
  1964. when 1
  1965. papers = @storage.availableWallpapers
  1966. index = 0
  1967. papers[1].length.times do |i|
  1968. if papers[1][i] == @storage[@storage.currentBox].background
  1969. index = i
  1970. break
  1971. end
  1972. end
  1973. wpaper = pbShowCommands(_INTL("Pick the wallpaper."), papers[0], index)
  1974. @scene.pbChangeBackground(papers[1][wpaper]) if wpaper >= 0
  1975. when 2
  1976. @scene.pbBoxName(_INTL("Box name?"), 0, 12)
  1977. end
  1978. end
  1979.  
  1980. def pbChoosePokemon(_party = nil)
  1981. $game_temp.in_storage = true
  1982. @heldpkmn = nil
  1983. @scene.pbStartBox(self, 1)
  1984. retval = nil
  1985. loop do
  1986. selected = @scene.pbSelectBox(@storage.party)
  1987. if selected && selected[0] == -3 # Close box
  1988. if pbConfirm(_INTL("Exit from the Box?"))
  1989. pbSEPlay("PC close")
  1990. break
  1991. end
  1992. next
  1993. end
  1994. if selected.nil?
  1995. next if pbConfirm(_INTL("Continue Box operations?"))
  1996. break
  1997. elsif selected[0] == -4 # Box name
  1998. pbBoxCommands
  1999. else
  2000. pokemon = @storage[selected[0], selected[1]]
  2001. next if !pokemon
  2002. commands = [
  2003. _INTL("Select"),
  2004. _INTL("Summary"),
  2005. _INTL("Withdraw"),
  2006. _INTL("Item"),
  2007. _INTL("Mark")
  2008. ]
  2009. commands.push(_INTL("Cancel"))
  2010. commands[2] = _INTL("Store") if selected[0] == -1
  2011. helptext = _INTL("{1} is selected.", pokemon.name)
  2012. command = pbShowCommands(helptext, commands)
  2013. case command
  2014. when 0 # Select
  2015. if pokemon
  2016. retval = selected
  2017. break
  2018. end
  2019. when 1
  2020. pbSummary(selected, nil)
  2021. when 2 # Store/Withdraw
  2022. if selected[0] == -1
  2023. pbStore(selected, nil)
  2024. else
  2025. pbWithdraw(selected, nil)
  2026. end
  2027. when 3
  2028. pbItem(selected, nil)
  2029. when 4
  2030. pbMark(selected, nil)
  2031. end
  2032. end
  2033. end
  2034. @scene.pbCloseBox
  2035. $game_temp.in_storage = false
  2036. return retval
  2037. end
  2038. end