Guest

Pokemon UI

Aug 14th, 2026
15
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 151.35 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.  
  33. if releasing?
  34. time_now = System.uptime
  35. self.zoom_x = lerp(1.0, 0.0, 1.5, @release_timer_start, System.uptime)
  36. self.zoom_y = self.zoom_x
  37. self.opacity = lerp(255, 0, 1.5, @release_timer_start, System.uptime)
  38. if self.opacity == 0
  39. @release_timer_start = nil
  40. dispose
  41. end
  42. end
  43. end
  44. end
  45.  
  46. #===============================================================================
  47. # Pokémon sprite
  48. #===============================================================================
  49. class MosaicPokemonSprite < PokemonSprite
  50. attr_reader :mosaic
  51.  
  52. def initialize(*args)
  53. super(*args)
  54. @mosaic = 0
  55. @inrefresh = false
  56. @mosaicbitmap = nil
  57. @mosaicbitmap2 = nil
  58. @oldbitmap = self.bitmap
  59. end
  60.  
  61. def dispose
  62. super
  63. @mosaicbitmap&.dispose
  64. @mosaicbitmap = nil
  65. @mosaicbitmap2&.dispose
  66. @mosaicbitmap2 = nil
  67. end
  68.  
  69. def bitmap=(value)
  70. super
  71. mosaicRefresh(value)
  72. end
  73.  
  74. def mosaic=(value)
  75. @mosaic = value
  76. @mosaic = 0 if @mosaic < 0
  77. mosaicRefresh(@oldbitmap)
  78. end
  79.  
  80. def mosaicRefresh(bitmap)
  81. return if @inrefresh
  82. @inrefresh = true
  83. @oldbitmap = bitmap
  84. if @mosaic <= 0 || !@oldbitmap
  85. @mosaicbitmap&.dispose
  86. @mosaicbitmap = nil
  87. @mosaicbitmap2&.dispose
  88. @mosaicbitmap2 = nil
  89. self.bitmap = @oldbitmap
  90. else
  91. newWidth = [(@oldbitmap.width / @mosaic), 1].max
  92. newHeight = [(@oldbitmap.height / @mosaic), 1].max
  93. @mosaicbitmap2&.dispose
  94. @mosaicbitmap = pbDoEnsureBitmap(@mosaicbitmap, newWidth, newHeight)
  95. @mosaicbitmap.clear
  96. @mosaicbitmap2 = pbDoEnsureBitmap(@mosaicbitmap2, @oldbitmap.width, @oldbitmap.height)
  97. @mosaicbitmap2.clear
  98. @mosaicbitmap.stretch_blt(Rect.new(0, 0, newWidth, newHeight), @oldbitmap, @oldbitmap.rect)
  99. @mosaicbitmap2.stretch_blt(
  100. Rect.new((-@mosaic / 2) + 1, (-@mosaic / 2) + 1, @mosaicbitmap2.width, @mosaicbitmap2.height),
  101. @mosaicbitmap, Rect.new(0, 0, newWidth, newHeight)
  102. )
  103. self.bitmap = @mosaicbitmap2
  104. end
  105. @inrefresh = false
  106. end
  107. end
  108.  
  109. #===============================================================================
  110. #
  111. #===============================================================================
  112. class AutoMosaicPokemonSprite < MosaicPokemonSprite
  113. INITIAL_MOSAIC = 10 # Pixellation factor
  114.  
  115. def mosaic=(value)
  116. @mosaic = value
  117. @mosaic = 0 if @mosaic < 0
  118. @start_mosaic = @mosaic if !@start_mosaic
  119. end
  120.  
  121. def mosaic_duration=(val)
  122. @mosaic_duration = val
  123. @mosaic_duration = 0 if @mosaic_duration < 0
  124. @mosaic_timer_start = System.uptime if @mosaic_duration > 0
  125. end
  126.  
  127. def update
  128. super
  129. if @mosaic_timer_start
  130. @start_mosaic = INITIAL_MOSAIC if !@start_mosaic || @start_mosaic == 0
  131. new_mosaic = lerp(@start_mosaic, 0, @mosaic_duration, @mosaic_timer_start, System.uptime).to_i
  132. self.mosaic = new_mosaic
  133. mosaicRefresh(@oldbitmap)
  134. if new_mosaic == 0
  135. @mosaic_timer_start = nil
  136. @start_mosaic = nil
  137. end
  138. end
  139. end
  140. end
  141.  
  142. #===============================================================================
  143. # Cursor
  144. #===============================================================================
  145. class PokemonBoxArrow < Sprite
  146. attr_accessor :quickswap
  147.  
  148. # Time in seconds for the cursor to move down and back up to grab/drop a
  149. # Pokémon.
  150. GRAB_TIME = 0.4
  151.  
  152. def initialize(viewport = nil)
  153. super(viewport)
  154. @holding = false
  155. @updating = false
  156. @quickswap = false
  157. @heldpkmn = nil
  158. @handsprite = ChangelingSprite.new(0, 0, viewport)
  159. @handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
  160. @handsprite.addBitmap("point2", "Graphics/UI/Storage/cursor_point_2")
  161. @handsprite.addBitmap("grab", "Graphics/UI/Storage/cursor_grab")
  162. @handsprite.addBitmap("fist", "Graphics/UI/Storage/cursor_fist")
  163. @handsprite.addBitmap("point1q", "Graphics/UI/Storage/cursor_point_1_q")
  164. @handsprite.addBitmap("point2q", "Graphics/UI/Storage/cursor_point_2_q")
  165. @handsprite.addBitmap("grabq", "Graphics/UI/Storage/cursor_grab_q")
  166. @handsprite.addBitmap("fistq", "Graphics/UI/Storage/cursor_fist_q")
  167. @handsprite.changeBitmap("fist")
  168. @spriteX = self.x
  169. @spriteY = self.y
  170. end
  171.  
  172. def dispose
  173. @handsprite.dispose
  174. @heldpkmn&.dispose
  175. super
  176. end
  177.  
  178. def x=(value)
  179. super
  180. @handsprite.x = self.x
  181. @spriteX = x if !@updating
  182. heldPokemon.x = self.x if holding?
  183. end
  184.  
  185. def y=(value)
  186. super
  187. @handsprite.y = self.y
  188. @spriteY = y if !@updating
  189. heldPokemon.y = self.y + 16 if holding?
  190. end
  191.  
  192. def z=(value)
  193. super
  194. @handsprite.z = value
  195. end
  196.  
  197. def visible=(value)
  198. super
  199. @handsprite.visible = value
  200. sprite = heldPokemon
  201. sprite.visible = value if sprite
  202. end
  203.  
  204. def color=(value)
  205. super
  206. @handsprite.color = value
  207. sprite = heldPokemon
  208. sprite.color = value if sprite
  209. end
  210.  
  211. def heldPokemon
  212. @heldpkmn = nil if @heldpkmn&.disposed?
  213. @holding = false if !@heldpkmn
  214. return @heldpkmn
  215. end
  216.  
  217. def holding?
  218. return self.heldPokemon && @holding
  219. end
  220.  
  221. def grabbing?
  222. return !@grabbing_timer_start.nil?
  223. end
  224.  
  225. def placing?
  226. return !@placing_timer_start.nil?
  227. end
  228.  
  229. def setSprite(sprite)
  230. if holding?
  231. @heldpkmn = sprite
  232. @heldpkmn.viewport = self.viewport if @heldpkmn
  233. @heldpkmn.z = 1 if @heldpkmn
  234. @holding = false if !@heldpkmn
  235. self.z = 2
  236. end
  237. end
  238.  
  239. def deleteSprite
  240. @holding = false
  241. if @heldpkmn
  242. @heldpkmn.dispose
  243. @heldpkmn = nil
  244. end
  245. end
  246.  
  247. def grab(sprite)
  248. @grabbing_timer_start = System.uptime
  249. @heldpkmn = sprite
  250. @heldpkmn.viewport = self.viewport
  251. @heldpkmn.z = 1
  252. self.z = 2
  253. end
  254.  
  255. def place
  256. @placing_timer_start = System.uptime
  257. end
  258.  
  259. def release
  260. @heldpkmn&.release
  261. end
  262.  
  263. def update
  264. @updating = true
  265. super
  266. heldpkmn = heldPokemon
  267. heldpkmn&.update
  268. @handsprite.update
  269. @holding = false if !heldpkmn
  270. if @grabbing_timer_start
  271. if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2
  272. @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
  273. self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime)
  274. else
  275. @holding = true
  276. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  277. delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime)
  278. self.y = @spriteY + delta_y
  279. @grabbing_timer_start = nil if delta_y == 0
  280. end
  281. elsif @placing_timer_start
  282. if System.uptime - @placing_timer_start <= GRAB_TIME / 2
  283. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  284. self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime)
  285. else
  286. @holding = false
  287. @heldpkmn = nil
  288. @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab")
  289. delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime)
  290. self.y = @spriteY + delta_y
  291. @placing_timer_start = nil if delta_y == 0
  292. end
  293. elsif holding?
  294. @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
  295. else # Idling
  296. self.x = @spriteX
  297. self.y = @spriteY
  298. if (System.uptime / 0.5).to_i.even? # Changes every 0.5 seconds
  299. @handsprite.changeBitmap((@quickswap) ? "point1q" : "point1")
  300. else
  301. @handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
  302. end
  303. end
  304. @updating = false
  305. end
  306. end
  307.  
  308. #===============================================================================
  309. # Box
  310. #===============================================================================
  311. class PokemonBoxSprite < Sprite
  312. attr_accessor :refreshBox
  313. attr_accessor :refreshSprites
  314.  
  315. def initialize(storage, boxnumber, viewport = nil)
  316. super(viewport)
  317. @storage = storage
  318. @boxnumber = boxnumber
  319. @refreshBox = true
  320. @refreshSprites = true
  321. @pokemonsprites = []
  322. PokemonBox::BOX_SIZE.times do |i|
  323. @pokemonsprites[i] = nil
  324. pokemon = @storage[boxnumber, i]
  325. @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) if pokemon
  326. end
  327. @contents = Bitmap.new(650, 390)
  328. self.bitmap = @contents
  329. self.x = 184
  330. self.y = 18
  331. refresh
  332. end
  333.  
  334. def dispose
  335. if !disposed?
  336. @pokemonsprites.each do |sprite|
  337. sprite&.dispose
  338. end
  339. @pokemonsprites.clear
  340. @boxbitmap.dispose
  341. @contents.dispose
  342. super
  343. end
  344. end
  345.  
  346. def x=(value)
  347. super
  348. end
  349.  
  350. def y=(value)
  351. super
  352. end
  353.  
  354. def color=(value)
  355. super
  356. if @refreshSprites
  357. @pokemonsprites.each do |sprite|
  358. sprite.color = value if sprite && !sprite.disposed?
  359. end
  360. end
  361. refresh
  362. end
  363.  
  364. def visible=(value)
  365. super
  366. @pokemonsprites.each do |sprite|
  367. sprite.visible = value if sprite && !sprite.disposed?
  368. end
  369. refresh
  370. end
  371.  
  372. def getBoxBitmap
  373. if !@bg || @bg != @storage[@boxnumber].background
  374. curbg = @storage[@boxnumber].background
  375. if !curbg || (curbg.is_a?(String) && curbg.length == 0)
  376. @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY
  377. else
  378. if curbg.is_a?(String) && curbg[/^box(\d+)$/]
  379. curbg = $~[1].to_i
  380. @storage[@boxnumber].background = curbg
  381. end
  382. @bg = curbg
  383. end
  384. @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY
  385. @storage[@boxnumber].background = @bg
  386. end
  387. @boxbitmap&.dispose
  388. @boxbitmap = AnimatedBitmap.new("Graphics/UI/Storage/box_#{@bg}")
  389. end
  390. end
  391.  
  392. def getPokemon(index)
  393. return @pokemonsprites[index]
  394. end
  395.  
  396. def setPokemon(index, sprite)
  397. @pokemonsprites[index] = sprite
  398. @pokemonsprites[index].refresh
  399.  
  400. row = index / PokemonBox::BOX_WIDTH
  401. column = index % PokemonBox::BOX_WIDTH
  402.  
  403. sprite.viewport = self.viewport
  404. sprite.x = self.x + 10 + (column * 48)
  405. sprite.y = self.y + 30 + (row * 48)
  406. sprite.z = 1
  407. end
  408.  
  409. def grabPokemon(index, arrow)
  410. sprite = @pokemonsprites[index]
  411. if sprite
  412. arrow.grab(sprite)
  413. @pokemonsprites[index] = nil
  414. end
  415. end
  416.  
  417. def deletePokemon(index)
  418. @pokemonsprites[index]&.dispose
  419. @pokemonsprites[index] = nil
  420. end
  421.  
  422. def refresh
  423. if @refreshBox
  424. boxname = @storage[@boxnumber].name
  425. getBoxBitmap
  426. @contents.stretch_blt(
  427. Rect.new(0, 0, 650, 390),
  428. @boxbitmap.bitmap,
  429. Rect.new(0, 0, 324, 296)
  430. )
  431. pbSetSystemFont(@contents)
  432. widthval = @contents.text_size(boxname).width
  433. xval = 162 - (widthval / 2)
  434. pbDrawShadowText(@contents, xval, 14, widthval, 32,
  435. boxname, Color.new(248, 248, 248), Color.new(40, 48, 48))
  436. @refreshBox = false
  437. end
  438. yval = self.y + 30
  439. PokemonBox::BOX_HEIGHT.times do |j|
  440. xval = self.x + 10
  441. PokemonBox::BOX_WIDTH.times do |k|
  442. sprite = @pokemonsprites[(j * PokemonBox::BOX_WIDTH) + k]
  443. if sprite && !sprite.disposed?
  444. sprite.viewport = self.viewport
  445. sprite.x = xval
  446. sprite.y = yval
  447. sprite.z = 1
  448. end
  449. xval += 48
  450. end
  451. yval += 48
  452. end
  453. end
  454.  
  455. def update
  456. super
  457. @frame_limiter = 0 if !@frame_limiter
  458. @frame_limiter = (@frame_limiter + 1) % 4
  459.  
  460. @pokemonsprites.each_with_index do |sprite, index|
  461. next if !sprite || sprite.disposed?
  462. if index % 4 == @frame_limiter || (sprite.respond_to?(:releasing?) && sprite.releasing?)
  463. sprite.update
  464. end
  465. end
  466. end
  467. end
  468.  
  469. #===============================================================================
  470. # Party pop-up panel
  471. #===============================================================================
  472. class PokemonBoxPartySprite < Sprite
  473. def initialize(party, viewport = nil)
  474. super(viewport)
  475. @party = party
  476. @boxbitmap = AnimatedBitmap.new("Graphics/UI/Storage/overlay_party")
  477. @pokemonsprites = []
  478. Settings::MAX_PARTY_SIZE.times do |i|
  479. @pokemonsprites[i] = nil
  480. pokemon = @party[i]
  481. @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) if pokemon
  482. end
  483. @contents = Bitmap.new(172, 352)
  484. self.bitmap = @contents
  485. self.x = 182
  486. self.y = Graphics.height - 352
  487. pbSetSystemFont(self.bitmap)
  488. refresh
  489. end
  490.  
  491. def dispose
  492. Settings::MAX_PARTY_SIZE.times do |i|
  493. @pokemonsprites[i]&.dispose
  494. end
  495. @boxbitmap.dispose
  496. @contents.dispose
  497. super
  498. end
  499.  
  500. def x=(value)
  501. super
  502. end
  503.  
  504. def y=(value)
  505. super
  506. end
  507.  
  508. def color=(value)
  509. super
  510. Settings::MAX_PARTY_SIZE.times do |i|
  511. if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
  512. @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color, value)
  513. end
  514. end
  515. end
  516.  
  517. def visible=(value)
  518. super
  519. @pokemonsprites.each do |sprite|
  520. sprite.visible = value if sprite && !sprite.disposed?
  521. end
  522. refresh
  523. end
  524.  
  525. def getPokemon(index)
  526. return @pokemonsprites[index]
  527. end
  528.  
  529. def setPokemon(index, sprite)
  530. @pokemonsprites[index] = sprite
  531. @pokemonsprites.compact!
  532. refresh
  533. end
  534.  
  535. def grabPokemon(index, arrow)
  536. sprite = @pokemonsprites[index]
  537. if sprite
  538. arrow.grab(sprite)
  539. @pokemonsprites[index] = nil
  540. end
  541. end
  542.  
  543. def deletePokemon(index)
  544. @pokemonsprites[index].dispose
  545. @pokemonsprites[index] = nil
  546. @pokemonsprites.compact!
  547. refresh
  548. end
  549.  
  550. def refresh
  551. @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, 324, 296))
  552. pbDrawTextPositions(
  553. self.bitmap,
  554. [[_INTL("Back"), 86, 248, :center, Color.new(248, 248, 248), Color.new(80, 80, 80), :outline]]
  555. )
  556. xvalues = [] # [18, 90, 18, 90, 18, 90]
  557. yvalues = [] # [2, 18, 66, 82, 130, 146]
  558. Settings::MAX_PARTY_SIZE.times do |i|
  559. xvalues.push(18 + (72 * (i % 2)))
  560. yvalues.push(2 + (16 * (i % 2)) + (64 * (i / 2)))
  561. end
  562. @pokemonsprites.delete_if { |sprite| sprite&.disposed? }
  563. @pokemonsprites.each { |sprite| sprite&.refresh }
  564. Settings::MAX_PARTY_SIZE.times do |j|
  565. sprite = @pokemonsprites[j]
  566. next if sprite.nil? || sprite.disposed?
  567. sprite.viewport = self.viewport
  568. sprite.x = self.x + xvalues[j]
  569. sprite.y = self.y + yvalues[j]
  570. sprite.z = 1
  571. end
  572. end
  573.  
  574. def update
  575. super
  576. Settings::MAX_PARTY_SIZE.times do |i|
  577. @pokemonsprites[i].update if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
  578. end
  579. end
  580. end
  581.  
  582. #===============================================================================
  583. # Pokémon storage visuals
  584. #===============================================================================
  585. class PokemonStorageScene
  586. attr_reader :quickswap
  587.  
  588. MARK_WIDTH = 16
  589. MARK_HEIGHT = 16
  590.  
  591. def initialize
  592. @command = 1
  593. end
  594.  
  595. def pbStartBox(screen, command)
  596. @screen = screen
  597. @storage = screen.storage
  598. @bgviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  599. @bgviewport.z = 99999
  600. @boxviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  601. @boxviewport.z = 99999
  602. @boxsidesviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  603. @boxsidesviewport.z = 99999
  604. @arrowviewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  605. @arrowviewport.z = 99999
  606. @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  607. @viewport.z = 99999
  608. @selection = 0
  609. @quickswap = false
  610. @sprites = {}
  611. @choseFromParty = false
  612. @command = command
  613. addBackgroundPlane(@sprites, "background", "Storage/bg", @bgviewport)
  614. @sprites["box"] = PokemonBoxSprite.new(@storage, @storage.currentBox, @boxviewport)
  615. @sprites["boxsides"] = IconSprite.new(0, 0, @boxsidesviewport)
  616. @sprites["boxsides"].setBitmap("Graphics/UI/Storage/overlay_main")
  617. @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport)
  618. pbSetSystemFont(@sprites["overlay"].bitmap)
  619. @sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport)
  620. @sprites["pokemon"].setOffset(PictureOrigin::CENTER)
  621. @sprites["pokemon"].x = 90
  622. @sprites["pokemon"].y = 134
  623. @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party, @boxsidesviewport)
  624. if command != 2 # Drop down tab only on Deposit
  625. @sprites["boxparty"].x = 182
  626. @sprites["boxparty"].y = Graphics.height
  627. end
  628. @markingbitmap = AnimatedBitmap.new("Graphics/UI/Storage/markings")
  629. @sprites["markingbg"] = IconSprite.new(292, 68, @boxsidesviewport)
  630. @sprites["markingbg"].setBitmap("Graphics/UI/Storage/overlay_marking")
  631. @sprites["markingbg"].z = 10
  632. @sprites["markingbg"].visible = false
  633. @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport)
  634. @sprites["markingoverlay"].z = 11
  635. @sprites["markingoverlay"].visible = false
  636. pbSetSystemFont(@sprites["markingoverlay"].bitmap)
  637. @sprites["arrow"] = PokemonBoxArrow.new(@arrowviewport)
  638. @sprites["arrow"].z += 1
  639. if command == 2
  640. pbPartySetArrow(@sprites["arrow"], @selection)
  641. pbUpdateOverlay(@selection, @storage.party)
  642. else
  643. pbSetArrow(@sprites["arrow"], @selection)
  644. pbUpdateOverlay(@selection)
  645. end
  646. pbSetMosaic(@selection)
  647. pbSEPlay("PC access")
  648. pbFadeInAndShow(@sprites)
  649. end
  650.  
  651. def pbCloseBox
  652. pbFadeOutAndHide(@sprites)
  653. pbDisposeSpriteHash(@sprites)
  654. @markingbitmap&.dispose
  655. @boxviewport.dispose
  656. @boxsidesviewport.dispose
  657. @arrowviewport.dispose
  658. end
  659.  
  660. def pbDisplay(message)
  661. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  662. msgwindow.viewport = @viewport
  663. msgwindow.visible = true
  664. msgwindow.letterbyletter = false
  665. msgwindow.resizeHeightToFit(message, Graphics.width - 180)
  666. msgwindow.text = message
  667. pbBottomRight(msgwindow)
  668. loop do
  669. Graphics.update
  670. Input.update
  671. if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
  672. break
  673. end
  674. msgwindow.update
  675. self.update
  676. end
  677. msgwindow.dispose
  678. Input.update
  679. end
  680.  
  681. def pbShowCommands(message, commands, index = 0)
  682. ret = -1
  683. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  684. msgwindow.viewport = @viewport
  685. msgwindow.visible = true
  686. msgwindow.letterbyletter = false
  687. msgwindow.text = message
  688. msgwindow.resizeHeightToFit(message, Graphics.width - 180)
  689. pbBottomRight(msgwindow)
  690. cmdwindow = Window_CommandPokemon.new(commands)
  691. cmdwindow.viewport = @viewport
  692. cmdwindow.visible = true
  693. cmdwindow.resizeToFit(cmdwindow.commands)
  694. cmdwindow.height = Graphics.height - msgwindow.height if cmdwindow.height > Graphics.height - msgwindow.height
  695. pbBottomRight(cmdwindow)
  696. cmdwindow.y -= msgwindow.height
  697. cmdwindow.index = index
  698. loop do
  699. Graphics.update
  700. Input.update
  701. msgwindow.update
  702. cmdwindow.update
  703. if Input.trigger?(Input::BACK)
  704. ret = -1
  705. break
  706. elsif Input.trigger?(Input::USE)
  707. ret = cmdwindow.index
  708. break
  709. end
  710. self.update
  711. end
  712. msgwindow.dispose
  713. cmdwindow.dispose
  714. Input.update
  715. return ret
  716. end
  717.  
  718. def pbSetArrow(arrow, selection)
  719. case selection
  720. when -1, -4, -5
  721. arrow.x = 488
  722. arrow.y = -24
  723. when -2
  724. arrow.x = 280
  725. arrow.y = 450
  726. when -3
  727. arrow.x = 600
  728. arrow.y = 450
  729. else
  730. arrow.x = (97 + (24 * (selection % PokemonBox::BOX_WIDTH))) * 2
  731. arrow.y = (8 + (24 * (selection / PokemonBox::BOX_WIDTH))) * 2
  732. end
  733. end
  734.  
  735. def pbChangeSelection(key, selection)
  736. case key
  737. when Input::UP
  738. case selection
  739. when -1
  740. selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH
  741. when -2, -3
  742. selection = 0
  743. else
  744. new_selection = selection - PokemonBox::BOX_WIDTH
  745. if new_selection < 0
  746. selection = -1 # Box name
  747. else
  748. selection = new_selection
  749. end
  750. end
  751. when Input::DOWN
  752. case selection
  753. when -1
  754. selection = 0
  755. when -2
  756. selection = 0
  757. when -3
  758. selection = 0
  759. else
  760. new_selection = selection + PokemonBox::BOX_WIDTH
  761. if new_selection >= PokemonBox::BOX_SIZE
  762. if (selection % PokemonBox::BOX_WIDTH) < (PokemonBox::BOX_WIDTH / 2)
  763. selection = -2 # Party
  764. else
  765. selection = -3 # Exit
  766. end
  767. else
  768. selection = new_selection
  769. end
  770. end
  771. when Input::LEFT
  772. if selection >= 0
  773. if (selection % PokemonBox::BOX_WIDTH) == 0
  774. selection += PokemonBox::BOX_WIDTH - 1
  775. else
  776. selection -= 1
  777. end
  778. elsif selection == -1
  779. selection = -4
  780. elsif selection == -2
  781. selection = -3
  782. elsif selection == -3
  783. selection = -2
  784. end
  785. when Input::RIGHT
  786. if selection >= 0
  787. if (selection % PokemonBox::BOX_WIDTH) == PokemonBox::BOX_WIDTH - 1
  788. selection -= PokemonBox::BOX_WIDTH - 1
  789. else
  790. selection += 1
  791. end
  792. elsif selection == -1
  793. selection = -5
  794. elsif selection == -2
  795. selection = -3
  796. elsif selection == -3
  797. selection = -2
  798. end
  799. end
  800. return selection
  801. end
  802.  
  803. def pbPartySetArrow(arrow, selection)
  804. return if selection < 0
  805. xvalues = [] # [200, 272, 200, 272, 200, 272, 236]
  806. yvalues = [] # [2, 18, 66, 82, 130, 146, 220]
  807. Settings::MAX_PARTY_SIZE.times do |i|
  808. xvalues.push(200 + (72 * (i % 2)))
  809. yvalues.push(190 + (16 * (i % 2)) + (64 * (i / 2)))
  810. end
  811. xvalues.push(268)
  812. yvalues.push(Graphics.height - 104)
  813. arrow.angle = 0
  814. arrow.mirror = false
  815. arrow.ox = 0
  816. arrow.oy = 0
  817. arrow.x = xvalues[selection]
  818. arrow.y = yvalues[selection]
  819. end
  820.  
  821. def pbPartyChangeSelection(key, selection)
  822. case key
  823. when Input::LEFT
  824. if selection == 1 || selection == 3 || selection == 5
  825. selection -= 1
  826. elsif selection == 6
  827. selection = 5
  828. end
  829.  
  830. when Input::RIGHT
  831. if selection == 0 || selection == 2 || selection == 4
  832. selection += 1
  833. elsif selection == 6
  834. selection = 0
  835. end
  836.  
  837. when Input::UP
  838. if selection == 6
  839. selection = 4
  840. elsif selection >= 2
  841. selection -= 2
  842. end
  843.  
  844. when Input::DOWN
  845. if selection < 4
  846. selection += 2
  847. elsif selection == 4 || selection == 5
  848. selection = 6
  849. elsif selection == 6
  850. selection = 0
  851. end
  852. end
  853.  
  854. return selection
  855. end
  856.  
  857. def pbSelectBoxInternal(_party)
  858. selection = @selection
  859. pbSetArrow(@sprites["arrow"], selection)
  860. pbUpdateOverlay(selection)
  861. pbSetMosaic(selection)
  862. loop do
  863. Graphics.update
  864. Input.update
  865. key = -1
  866. key = Input::DOWN if Input.repeat?(Input::DOWN)
  867. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  868. key = Input::LEFT if Input.repeat?(Input::LEFT)
  869. key = Input::UP if Input.repeat?(Input::UP)
  870. if key >= 0
  871. pbPlayCursorSE
  872. selection = pbChangeSelection(key, selection)
  873. pbSetArrow(@sprites["arrow"], selection)
  874. case selection
  875. when -4
  876. nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes
  877. pbSwitchBoxToLeft(nextbox)
  878. @storage.currentBox = nextbox
  879. when -5
  880. nextbox = (@storage.currentBox + 1) % @storage.maxBoxes
  881. pbSwitchBoxToRight(nextbox)
  882. @storage.currentBox = nextbox
  883. end
  884. selection = -1 if [-4, -5].include?(selection)
  885. pbUpdateOverlay(selection)
  886. pbSetMosaic(selection)
  887. end
  888. self.update
  889. if Input.trigger?(Input::JUMPUP)
  890. pbPlayCursorSE
  891. nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes
  892. pbSwitchBoxToLeft(nextbox)
  893. @storage.currentBox = nextbox
  894. pbUpdateOverlay(selection)
  895. pbSetMosaic(selection)
  896. elsif Input.trigger?(Input::JUMPDOWN)
  897. pbPlayCursorSE
  898. nextbox = (@storage.currentBox + 1) % @storage.maxBoxes
  899. pbSwitchBoxToRight(nextbox)
  900. @storage.currentBox = nextbox
  901. pbUpdateOverlay(selection)
  902. pbSetMosaic(selection)
  903. elsif Input.trigger?(Input::SPECIAL) # Jump to box name
  904. if selection != -1
  905. pbPlayCursorSE
  906. selection = -1
  907. pbSetArrow(@sprites["arrow"], selection)
  908. pbUpdateOverlay(selection)
  909. pbSetMosaic(selection)
  910. end
  911. elsif Input.trigger?(Input::ACTION) && @command == 0 # Organize only
  912. pbPlayDecisionSE
  913. pbSetQuickSwap(!@quickswap)
  914. elsif Input.trigger?(Input::BACK)
  915. @selection = selection
  916. return nil
  917. elsif Input.trigger?(Input::USE)
  918. @selection = selection
  919. if selection >= 0
  920. return [@storage.currentBox, selection]
  921. elsif selection == -1 # Box name
  922. return [-4, -1]
  923. elsif selection == -2 # Party Pokémon
  924. return [-2, -1]
  925. elsif selection == -3 # Close Box
  926. return [-3, -1]
  927. end
  928. end
  929. end
  930. end
  931.  
  932. def pbSelectBox(party)
  933. return pbSelectBoxInternal(party) if @command == 1 # Withdraw
  934. ret = nil
  935. loop do
  936. ret = pbSelectBoxInternal(party) if !@choseFromParty
  937. if @choseFromParty || (ret && ret[0] == -2) # Party Pokémon
  938. if !@choseFromParty
  939. pbShowPartyTab
  940. @selection = 0
  941. end
  942. ret = pbSelectPartyInternal(party, false)
  943. if ret < 0
  944. pbHidePartyTab
  945. @selection = -2
  946. @choseFromParty = false
  947. else
  948. @choseFromParty = true
  949. return [-1, ret]
  950. end
  951. else
  952. @choseFromParty = false
  953. return ret
  954. end
  955. end
  956. end
  957.  
  958. def pbSelectPartyInternal(party, depositing)
  959. selection = @selection
  960. pbPartySetArrow(@sprites["arrow"], selection)
  961. pbUpdateOverlay(selection, party)
  962. pbSetMosaic(selection)
  963. lastsel = 1
  964. loop do
  965. Graphics.update
  966. Input.update
  967. key = -1
  968. key = Input::DOWN if Input.repeat?(Input::DOWN)
  969. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  970. key = Input::LEFT if Input.repeat?(Input::LEFT)
  971. key = Input::UP if Input.repeat?(Input::UP)
  972. if key >= 0
  973. pbPlayCursorSE
  974. newselection = pbPartyChangeSelection(key, selection)
  975. case newselection
  976. when -1
  977. return -1 if !depositing
  978. when -2
  979. selection = lastsel
  980. else
  981. selection = newselection
  982. end
  983. pbPartySetArrow(@sprites["arrow"], selection)
  984. lastsel = selection if selection > 0
  985. pbUpdateOverlay(selection, party)
  986. pbSetMosaic(selection)
  987. end
  988. self.update
  989. if Input.trigger?(Input::ACTION) && @command == 0 # Organize only
  990. pbPlayDecisionSE
  991. pbSetQuickSwap(!@quickswap)
  992. elsif Input.trigger?(Input::BACK)
  993. @selection = selection
  994. return -1
  995. elsif Input.trigger?(Input::USE)
  996. if selection >= 0 && selection < Settings::MAX_PARTY_SIZE
  997. @selection = selection
  998. return selection
  999. elsif selection == Settings::MAX_PARTY_SIZE # Back
  1000. @selection = selection
  1001. return -1
  1002. end
  1003. end
  1004. end
  1005. end
  1006.  
  1007. def pbSelectParty(party)
  1008. return pbSelectPartyInternal(party, true)
  1009. end
  1010.  
  1011. def pbChangeBackground(wp)
  1012. duration = 0.2 # Time in seconds to fade out or fade in
  1013. @sprites["box"].refreshSprites = false
  1014. Graphics.update
  1015. self.update
  1016. # Fade old background to white
  1017. timer_start = System.uptime
  1018. loop do
  1019. alpha = lerp(0, 255, duration, timer_start, System.uptime)
  1020. @sprites["box"].color = Color.new(248, 248, 248, alpha)
  1021. Graphics.update
  1022. self.update
  1023. break if alpha >= 255
  1024. end
  1025. # Fade in new background from white
  1026. @sprites["box"].refreshBox = true
  1027. @storage[@storage.currentBox].background = wp
  1028. timer_start = System.uptime
  1029. loop do
  1030. alpha = lerp(255, 0, duration, timer_start, System.uptime)
  1031. @sprites["box"].color = Color.new(248, 248, 248, alpha)
  1032. Graphics.update
  1033. self.update
  1034. break if alpha <= 0
  1035. end
  1036. @sprites["box"].refreshSprites = true
  1037. Input.update
  1038. end
  1039.  
  1040. def pbSwitchBoxToRight(new_box_number)
  1041. start_x = @sprites["box"].x
  1042. newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
  1043. newbox.x = start_x + 336
  1044. timer_start = System.uptime
  1045. loop do
  1046. @sprites["box"].x = lerp(start_x, start_x - 336, 0.25, timer_start, System.uptime)
  1047. newbox.x = @sprites["box"].x + 336
  1048. self.update
  1049. Graphics.update
  1050. break if newbox.x == start_x
  1051. end
  1052. @sprites["box"].dispose
  1053. @sprites["box"] = newbox
  1054. Input.update
  1055. end
  1056.  
  1057. def pbSwitchBoxToLeft(new_box_number)
  1058. start_x = @sprites["box"].x
  1059. newbox = PokemonBoxSprite.new(@storage, new_box_number, @boxviewport)
  1060. newbox.x = start_x - 336
  1061. timer_start = System.uptime
  1062. loop do
  1063. @sprites["box"].x = lerp(start_x, start_x + 336, 0.25, timer_start, System.uptime)
  1064. newbox.x = @sprites["box"].x - 336
  1065. self.update
  1066. Graphics.update
  1067. break if newbox.x == start_x
  1068. end
  1069. @sprites["box"].dispose
  1070. @sprites["box"] = newbox
  1071. Input.update
  1072. end
  1073.  
  1074. def pbJumpToBox(newbox)
  1075. return if @storage.currentBox == newbox
  1076. if newbox > @storage.currentBox
  1077. pbSwitchBoxToRight(newbox)
  1078. else
  1079. pbSwitchBoxToLeft(newbox)
  1080. end
  1081. @storage.currentBox = newbox
  1082. end
  1083.  
  1084. def pbSetMosaic(selection)
  1085. return if @screen.pbHeldPokemon
  1086. return if @boxForMosaic == @storage.currentBox && @selectionForMosaic == selection
  1087. @sprites["pokemon"].mosaic_duration = 0.25 # In seconds
  1088. @boxForMosaic = @storage.currentBox
  1089. @selectionForMosaic = selection
  1090. end
  1091.  
  1092. def pbSetQuickSwap(value)
  1093. @quickswap = value
  1094. @sprites["arrow"].quickswap = value
  1095. end
  1096.  
  1097. def pbShowPartyTab
  1098. @sprites["arrow"].visible = false
  1099. pbUpdateOverlay(-1)
  1100. pbSetMosaic(-1)
  1101. end
  1102. pbSEPlay("GUI storage show party panel")
  1103. start_y = @sprites["boxparty"].y # Graphics.height
  1104. timer_start = System.uptime
  1105. loop do
  1106. @sprites["boxparty"].y = lerp(start_y, start_y - @sprites["boxparty"].height,
  1107. 0.4, timer_start, System.uptime)
  1108. self.update
  1109. Graphics.update
  1110. break if @sprites["boxparty"].y == start_y - @sprites["boxparty"].height
  1111. end
  1112. Input.update
  1113. @sprites["arrow"].visible = true
  1114. end
  1115.  
  1116. def pbHidePartyTab
  1117. @sprites["arrow"].visible = false
  1118. pbUpdateOverlay(-1)
  1119. pbSetMosaic(-1)
  1120. end
  1121. pbSEPlay("GUI storage hide party panel")
  1122. start_y = @sprites["boxparty"].y # Graphics.height - @sprites["boxparty"].height
  1123. timer_start = System.uptime
  1124. loop do
  1125. @sprites["boxparty"].y = lerp(start_y, start_y + @sprites["boxparty"].height,
  1126. 0.4, timer_start, System.uptime)
  1127. self.update
  1128. Graphics.update
  1129. break if @sprites["boxparty"].y == start_y + @sprites["boxparty"].height
  1130. end
  1131. Input.update
  1132. @sprites["arrow"].visible = true
  1133. end
  1134.  
  1135. def pbHold(selected)
  1136. pbSEPlay("GUI storage pick up")
  1137. if selected[0] == -1
  1138. @sprites["boxparty"].grabPokemon(selected[1], @sprites["arrow"])
  1139. else
  1140. @sprites["box"].grabPokemon(selected[1], @sprites["arrow"])
  1141. end
  1142. while @sprites["arrow"].grabbing?
  1143. Graphics.update
  1144. Input.update
  1145. self.update
  1146. end
  1147. end
  1148.  
  1149. def pbSwap(selected, _heldpoke)
  1150. pbSEPlay("GUI storage pick up")
  1151. heldpokesprite = @sprites["arrow"].heldPokemon
  1152. boxpokesprite = nil
  1153. if selected[0] == -1
  1154. boxpokesprite = @sprites["boxparty"].getPokemon(selected[1])
  1155. else
  1156. boxpokesprite = @sprites["box"].getPokemon(selected[1])
  1157. end
  1158. if selected[0] == -1
  1159. @sprites["boxparty"].setPokemon(selected[1], heldpokesprite)
  1160. else
  1161. @sprites["box"].setPokemon(selected[1], heldpokesprite)
  1162. end
  1163. @sprites["arrow"].setSprite(boxpokesprite)
  1164. @sprites["pokemon"].mosaic_duration = 0.25 # In seconds
  1165. @boxForMosaic = @storage.currentBox
  1166. @selectionForMosaic = selected[1]
  1167. end
  1168.  
  1169. def pbPlace(selected, _heldpoke)
  1170. pbSEPlay("GUI storage put down")
  1171. heldpokesprite = @sprites["arrow"].heldPokemon
  1172. @sprites["arrow"].place
  1173. while @sprites["arrow"].placing?
  1174. Graphics.update
  1175. Input.update
  1176. self.update
  1177. end
  1178. if selected[0] == -1
  1179. @sprites["boxparty"].setPokemon(selected[1], heldpokesprite)
  1180. else
  1181. @sprites["box"].setPokemon(selected[1], heldpokesprite)
  1182. end
  1183. @boxForMosaic = @storage.currentBox
  1184. @selectionForMosaic = selected[1]
  1185. end
  1186.  
  1187. def pbWithdraw(selected, heldpoke, partyindex)
  1188. pbHold(selected) if !heldpoke
  1189. pbShowPartyTab
  1190. pbPartySetArrow(@sprites["arrow"], partyindex)
  1191. pbPlace([-1, partyindex], heldpoke)
  1192. pbHidePartyTab
  1193. end
  1194.  
  1195. def pbStore(selected, heldpoke, destbox, firstfree)
  1196. if heldpoke
  1197. if destbox == @storage.currentBox
  1198. heldpokesprite = @sprites["arrow"].heldPokemon
  1199. @sprites["box"].setPokemon(firstfree, heldpokesprite)
  1200. @sprites["arrow"].setSprite(nil)
  1201. else
  1202. @sprites["arrow"].deleteSprite
  1203. end
  1204. else
  1205. sprite = @sprites["boxparty"].getPokemon(selected[1])
  1206. if destbox == @storage.currentBox
  1207. @sprites["box"].setPokemon(firstfree, sprite)
  1208. @sprites["boxparty"].setPokemon(selected[1], nil)
  1209. else
  1210. @sprites["boxparty"].deletePokemon(selected[1])
  1211. end
  1212. end
  1213. end
  1214.  
  1215. def pbRelease(selected, heldpoke)
  1216. box = selected[0]
  1217. index = selected[1]
  1218. if heldpoke
  1219. sprite = @sprites["arrow"].heldPokemon
  1220. elsif box == -1
  1221. sprite = @sprites["boxparty"].getPokemon(index)
  1222. else
  1223. sprite = @sprites["box"].getPokemon(index)
  1224. end
  1225. if sprite
  1226. sprite.release
  1227. while sprite.releasing?
  1228. Graphics.update
  1229. sprite.update
  1230. self.update
  1231. end
  1232. end
  1233. end
  1234.  
  1235. def pbChooseBox(msg)
  1236. commands = []
  1237. @storage.maxBoxes.times do |i|
  1238. box = @storage[i]
  1239. if box
  1240. commands.push(_INTL("{1} ({2}/{3})", box.name, box.nitems, box.length))
  1241. end
  1242. end
  1243. return pbShowCommands(msg, commands, @storage.currentBox)
  1244. end
  1245.  
  1246. def pbBoxName(helptext, minchars, maxchars)
  1247. oldsprites = pbFadeOutAndHide(@sprites)
  1248. ret = pbEnterBoxName(helptext, minchars, maxchars)
  1249. @storage[@storage.currentBox].name = ret if ret.length > 0
  1250. @sprites["box"].refreshBox = true
  1251. pbRefresh
  1252. pbFadeInAndShow(@sprites, oldsprites)
  1253. end
  1254.  
  1255. def pbChooseItem(bag)
  1256. ret = nil
  1257. pbFadeOutIn do
  1258. scene = PokemonBag_Scene.new
  1259. screen = PokemonBagScreen.new(scene, bag)
  1260. ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? })
  1261. end
  1262. return ret
  1263. end
  1264.  
  1265. def pbSummary(selected, heldpoke)
  1266. oldsprites = pbFadeOutAndHide(@sprites)
  1267. scene = PokemonSummary_Scene.new
  1268. screen = PokemonSummaryScreen.new(scene)
  1269. if heldpoke
  1270. screen.pbStartScreen([heldpoke], 0)
  1271. elsif selected[0] == -1
  1272. @selection = screen.pbStartScreen(@storage.party, selected[1])
  1273. pbPartySetArrow(@sprites["arrow"], @selection)
  1274. pbUpdateOverlay(@selection, @storage.party)
  1275. else
  1276. @selection = screen.pbStartScreen(@storage.boxes[selected[0]], selected[1])
  1277. pbSetArrow(@sprites["arrow"], @selection)
  1278. pbUpdateOverlay(@selection)
  1279. end
  1280. pbFadeInAndShow(@sprites, oldsprites)
  1281. end
  1282.  
  1283. def pbMarkingSetArrow(arrow, selection)
  1284. if selection >= 0
  1285. xvalues = [162, 191, 220, 162, 191, 220, 184, 184]
  1286. yvalues = [24, 24, 24, 49, 49, 49, 77, 109]
  1287. arrow.angle = 0
  1288. arrow.mirror = false
  1289. arrow.ox = 0
  1290. arrow.oy = 0
  1291. arrow.x = xvalues[selection] * 2
  1292. arrow.y = yvalues[selection] * 2
  1293. end
  1294. end
  1295.  
  1296. def pbMarkingChangeSelection(key, selection)
  1297. case key
  1298. when Input::LEFT
  1299. if selection < 6
  1300. selection -= 1
  1301. selection += 3 if selection % 3 == 2
  1302. end
  1303. when Input::RIGHT
  1304. if selection < 6
  1305. selection += 1
  1306. selection -= 3 if selection % 3 == 0
  1307. end
  1308. when Input::UP
  1309. if selection == 7
  1310. selection = 6
  1311. elsif selection == 6
  1312. selection = 4
  1313. elsif selection < 3
  1314. selection = 7
  1315. else
  1316. selection -= 3
  1317. end
  1318. when Input::DOWN
  1319. if selection == 7
  1320. selection = 1
  1321. elsif selection == 6
  1322. selection = 7
  1323. elsif selection >= 3
  1324. selection = 6
  1325. else
  1326. selection += 3
  1327. end
  1328. end
  1329. return selection
  1330. end
  1331.  
  1332. def pbMark(selected, heldpoke)
  1333. @sprites["markingbg"].visible = true
  1334. @sprites["markingoverlay"].visible = true
  1335. msg = _INTL("Mark your Pokémon.")
  1336. msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32)
  1337. msgwindow.viewport = @viewport
  1338. msgwindow.visible = true
  1339. msgwindow.letterbyletter = false
  1340. msgwindow.text = msg
  1341. msgwindow.resizeHeightToFit(msg, Graphics.width - 180)
  1342. pbBottomRight(msgwindow)
  1343. base = Color.new(248, 248, 248)
  1344. shadow = Color.new(80, 80, 80)
  1345. pokemon = heldpoke
  1346. if heldpoke
  1347. pokemon = heldpoke
  1348. elsif selected[0] == -1
  1349. pokemon = @storage.party[selected[1]]
  1350. else
  1351. pokemon = @storage.boxes[selected[0]][selected[1]]
  1352. end
  1353. markings = pokemon.markings.clone
  1354. mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT
  1355. index = 0
  1356. redraw = true
  1357. markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT)
  1358. loop do
  1359. # Redraw the markings and text
  1360. if redraw
  1361. @sprites["markingoverlay"].bitmap.clear
  1362. (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
  1363. markrect.x = i * MARK_WIDTH
  1364. markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
  1365. @sprites["markingoverlay"].bitmap.blt(336 + (58 * (i % 3)), 106 + (50 * (i / 3)),
  1366. @markingbitmap.bitmap, markrect)
  1367. end
  1368. textpos = [
  1369. [_INTL("OK"), 402, 216, :center, base, shadow, :outline],
  1370. [_INTL("Cancel"), 402, 280, :center, base, shadow, :outline]
  1371. ]
  1372. pbDrawTextPositions(@sprites["markingoverlay"].bitmap, textpos)
  1373. pbMarkingSetArrow(@sprites["arrow"], index)
  1374. redraw = false
  1375. end
  1376. Graphics.update
  1377. Input.update
  1378. key = -1
  1379. key = Input::DOWN if Input.repeat?(Input::DOWN)
  1380. key = Input::RIGHT if Input.repeat?(Input::RIGHT)
  1381. key = Input::LEFT if Input.repeat?(Input::LEFT)
  1382. key = Input::UP if Input.repeat?(Input::UP)
  1383. if key >= 0
  1384. oldindex = index
  1385. index = pbMarkingChangeSelection(key, index)
  1386. pbPlayCursorSE if index != oldindex
  1387. pbMarkingSetArrow(@sprites["arrow"], index)
  1388. end
  1389. self.update
  1390. if Input.trigger?(Input::BACK)
  1391. pbPlayCancelSE
  1392. break
  1393. elsif Input.trigger?(Input::USE)
  1394. pbPlayDecisionSE
  1395. case index
  1396. when 6 # OK
  1397. pokemon.markings = markings
  1398. break
  1399. when 7 # Cancel
  1400. break
  1401. else
  1402. markings[index] = ((markings[index] || 0) + 1) % mark_variants
  1403. redraw = true
  1404. end
  1405. end
  1406. end
  1407. @sprites["markingbg"].visible = false
  1408. @sprites["markingoverlay"].visible = false
  1409. msgwindow.dispose
  1410. end
  1411.  
  1412. def pbRefresh
  1413. @sprites["box"].refresh
  1414. @sprites["boxparty"].refresh
  1415. end
  1416.  
  1417. def pbHardRefresh
  1418. @sprites["box"].refresh
  1419. @sprites["boxparty"].refresh
  1420. end
  1421.  
  1422. def drawMarkings(bitmap, x, y, _width, _height, markings)
  1423. mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT
  1424. markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT)
  1425. (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i|
  1426. markrect.x = i * MARK_WIDTH
  1427. markrect.y = [(markings[i] || 0), mark_variants - 1].min * MARK_HEIGHT
  1428. bitmap.blt(x + (i * MARK_WIDTH), y, @markingbitmap.bitmap, markrect)
  1429. end
  1430. end
  1431.  
  1432. def pbUpdateOverlay(selection, party = nil)
  1433. overlay = @sprites["overlay"].bitmap
  1434. overlay.clear
  1435. buttonbase = Color.new(248, 248, 248)
  1436. buttonshadow = Color.new(80, 80, 80)
  1437. pbDrawTextPositions(
  1438. overlay,
  1439. [[_INTL("Party: {1}", (@storage.party.length rescue 0)), 280, 470, :center, buttonbase, buttonshadow, :outline],
  1440. [_INTL("Exit"), 600, 470, :center, buttonbase, buttonshadow, :outline]]
  1441. )
  1442. pokemon = nil
  1443. if @screen.pbHeldPokemon
  1444. pokemon = @screen.pbHeldPokemon
  1445. elsif selection >= 0
  1446. pokemon = (party) ? party[selection] : @storage[@storage.currentBox, selection]
  1447. end
  1448. if !pokemon
  1449. @sprites["pokemon"].visible = false
  1450. return
  1451. end
  1452. @sprites["pokemon"].visible = true
  1453. base = Color.new(88, 88, 80)
  1454. shadow = Color.new(168, 184, 184)
  1455. nonbase = Color.new(208, 208, 208)
  1456. nonshadow = Color.new(224, 224, 224)
  1457. pokename = pokemon.name
  1458. textstrings = [
  1459. [pokename, 10, 14, :left, base, shadow]
  1460. ]
  1461. if !pokemon.egg?
  1462. imagepos = []
  1463. if pokemon.male?
  1464. textstrings.push([_INTL("♂"), 148, 14, :left, Color.new(24, 112, 216), Color.new(136, 168, 208)])
  1465. elsif pokemon.female?
  1466. textstrings.push([_INTL("♀"), 148, 14, :left, Color.new(248, 56, 32), Color.new(224, 152, 144)])
  1467. end
  1468. imagepos.push([_INTL("Graphics/UI/Storage/overlay_lv"), 6, 246])
  1469. textstrings.push([pokemon.level.to_s, 28, 240, :left, base, shadow])
  1470. if pokemon.ability
  1471. textstrings.push([pokemon.ability.name, 86, 312, :center, base, shadow])
  1472. else
  1473. textstrings.push([_INTL("No ability"), 86, 312, :center, nonbase, nonshadow])
  1474. end
  1475. if pokemon.item
  1476. textstrings.push([pokemon.item.name, 86, 348, :center, base, shadow])
  1477. else
  1478. textstrings.push([_INTL("No item"), 86, 348, :center, nonbase, nonshadow])
  1479. end
  1480. imagepos.push(["Graphics/UI/shiny", 156, 198]) if pokemon.shiny?
  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