sebbesthusbando

Pokemon UI

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