Guest

Pokemon UI

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