Guest

Pokemon UI

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