Guest

pokemon ui

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