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