Advertisement
Guest User

EliteBattle_UI

a guest
Aug 1st, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.14 KB | None | 0 0
  1. #===============================================================================
  2. # Elite Battle Interface
  3. # created by Luka S.J.
  4. #
  5. # a brand new interface for Pokemon Essentials, to be used with the dynamic
  6. # battle system. Command and Fight windows are not based upon the previous
  7. # versions. Keep that in mind if you did (or plan to do) any alterations to the
  8. # interfaces.
  9. #===============================================================================
  10. module PokeBattle_SceneConstants
  11. if USENEWUI
  12. MESSAGEBASECOLOR = Color.new(80,80,88)
  13. MESSAGESHADOWCOLOR = Color.new(160,160,168)
  14. MENUBASECOLOR = MESSAGEBASECOLOR
  15. MENUSHADOWCOLOR = MESSAGESHADOWCOLOR
  16. BOXTEXTBASECOLOR = MESSAGEBASECOLOR
  17. BOXTEXTSHADOWCOLOR = MESSAGESHADOWCOLOR
  18. HPGAUGESIZE = 96
  19. EXPGAUGESIZE = 192
  20. end
  21. end
  22.  
  23. def menuButtonAnim(sprite,updateall=true)
  24. 6.times do
  25. pbGraphicsUpdate if updateall
  26. animateBattleSprites(true) if updateall
  27. # pbMoveCamera if updateall
  28. sprite.tone.red+=26
  29. sprite.tone.blue+=26
  30. sprite.tone.green+=26
  31. end
  32. 6.times do
  33. pbGraphicsUpdate if updateall
  34. animateBattleSprites(true) if updateall
  35. # pbMoveCamera if updateall
  36. sprite.tone.red-=26
  37. sprite.tone.blue-=26
  38. sprite.tone.green-=26
  39. end
  40. end
  41.  
  42. class BattleSelectorArrow
  43. def initialize(x,y,w,h,viewport=nil)
  44. @frame=0
  45. @arrows={}
  46. @savepos={}
  47. @visible=false
  48. @bitmap=BitmapCache.load_bitmap("Graphics/Pictures/BattleUI/battleselector")
  49. for i in 0...4
  50. bwidth=(i%2==0) ? 0 : @bitmap.width/2
  51. bheight=(i/2<1) ? 0 : @bitmap.height/2
  52. xpos=(i%2==0) ? x : x+w-@bitmap.width/2
  53. ypos=(i/2<1) ? y : h+y-@bitmap.height/2
  54.  
  55. if viewport!=nil
  56. @arrows["#{i}"]=Sprite.new(viewport)
  57. else
  58. @arrows["#{i}"]=Sprite.new
  59. end
  60. @arrows["#{i}"].bitmap=@bitmap.clone
  61. @arrows["#{i}"].src_rect.set(bwidth,bheight,@bitmap.width/2,@bitmap.height/2)
  62. @arrows["#{i}"].pos(xpos,ypos)
  63. @arrows["#{i}"].z=9999998
  64. @arrows["#{i}"].opacity=0
  65. @savepos[i]=[xpos,ypos]
  66. end
  67. firstshow
  68. end
  69.  
  70. def checkMouse
  71. if Input.triggerex?(Input::Mouse_Left) &&
  72. $mouse.y>=400
  73. return true
  74. end
  75. return false
  76. end
  77.  
  78. def opacity=(value)
  79. for i in 0...4
  80. @arrows["#{i}"].opacity=value
  81. end
  82. end
  83.  
  84. def opacity
  85. return @arrows["0"].opacity
  86. end
  87.  
  88. def disposed?
  89. return @arrows["0"].disposed?
  90. end
  91.  
  92. def color=(value)
  93. for i in 0...4
  94. @arrows["#{i}"].color=color
  95. end
  96. end
  97.  
  98. def color
  99. return @arrows["0"].color
  100. end
  101.  
  102. def visible=(value)
  103. for i in 0...4
  104. @arrows["#{i}"].visible=value
  105. end
  106. end
  107.  
  108. def visible
  109. return @arrows["0"].visible
  110. end
  111.  
  112. def checkTrigger
  113. if Input.trigger?(Input::C)
  114. return true
  115. elsif Input.trigger?(Input::UP)
  116. return true
  117. elsif Input.trigger?(Input::DOWN)
  118. return true
  119. elsif Input.trigger?(Input::LEFT)
  120. return true
  121. elsif Input.trigger?(Input::RIGHT)
  122. return true
  123. end
  124. return false
  125. end
  126.  
  127. def update
  128.  
  129. if checkTrigger
  130. if !visible?
  131. show
  132. $USINGMANUAL=true
  133. pbSEPlay("SE_Select1")
  134. pbWait(1) { update }
  135. end
  136. elsif checkMouse
  137. if visible?
  138. $USINGMANUAL=false
  139. hide
  140. end
  141. end
  142.  
  143. @frame+=1
  144. if @frame==15
  145. for i in 0...4
  146. xplus=(i%2==0) ? -4 : 4
  147. yplus=(i/2<1) ? -4 : 4
  148. @arrows["#{i}"].x=@savepos[i][0]+xplus
  149. @arrows["#{i}"].y=@savepos[i][1]+yplus
  150. end
  151. elsif @frame==30
  152. for i in 0...4
  153. xplus=(i%2==0) ? -2 : 2
  154. yplus=(i/2<1) ? -2 : 2
  155. @arrows["#{i}"].x=@savepos[i][0]+xplus
  156. @arrows["#{i}"].y=@savepos[i][1]+yplus
  157. end
  158. elsif @frame==45
  159. for i in 0...4
  160. xplus=(i%2==0) ? 0 : 0
  161. yplus=(i/2<1) ? 0 : 0
  162. @arrows["#{i}"].x=@savepos[i][0]+xplus
  163. @arrows["#{i}"].y=@savepos[i][1]+yplus
  164. end
  165. end
  166. @frame=0 if @frame==45
  167. end
  168.  
  169. def show
  170. @frame=0
  171. for i in 0...4
  172. @arrows["#{i}"].opacity=255
  173. end
  174. @visible=true
  175. end
  176.  
  177. def firstshow
  178. if $USINGMANUAL
  179. for i in 0...4
  180. @arrows["#{i}"].opacity=255
  181. end
  182. @visible=true
  183. end
  184. end
  185.  
  186. def visible?
  187. return @visible
  188. end
  189.  
  190. def hide
  191. @frame=0
  192. for i in 0...4
  193. @arrows["#{i}"].opacity=0
  194. end
  195. @visible=false
  196. end
  197.  
  198. def recolocate(x,y,w,h)
  199. for i in 0...4
  200. bwidth=(i%2==0) ? 0 : @bitmap.width/2
  201. bheight=(i/2<1) ? 0 : @bitmap.height/2
  202. xpos=(i%2==0) ? x : x+w-@bitmap.width/2
  203. ypos=(i/2<1) ? y : h+y-@bitmap.height/2
  204.  
  205. @arrows["#{i}"].pos(xpos,ypos)
  206. @arrows["#{i}"].z=9999998
  207. @savepos[i]=[xpos,ypos]
  208. end
  209. end
  210.  
  211. def dispose
  212. $USINGMANUAL=visible?
  213. for i in 0...4
  214. @arrows["#{i}"].dispose
  215. end
  216. end
  217. end
  218. #===============================================================================
  219. # Pokemon data battle boxes
  220. # UI overhaul
  221. #===============================================================================
  222. class PokemonNewDataBox < SpriteWrapper
  223. attr_reader :battler
  224. attr_accessor :selected
  225. attr_accessor :appearing
  226. attr_reader :animatingHP
  227. attr_reader :animatingEXP
  228.  
  229. def initialize(battler,doublebattle,viewport=nil,player=nil)
  230. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  231. view.z = viewport.z + 1
  232. viewport = view
  233. super(viewport)
  234. @explevel=0
  235. @player=player
  236. @battler=battler
  237. @doublebattle=doublebattle
  238. @selected=0
  239. @frame=0
  240. @showhp=false
  241. @showexp=false
  242. @appearing=false
  243. @animatingHP=false
  244. @starthp=0
  245. @currenthp=0
  246. @endhp=0
  247. @expflash=0
  248. if (@battler.index&1)==0 # if player's Pokémon
  249. @spritebaseX=34
  250. else
  251. @spritebaseX=16
  252. end
  253. if doublebattle
  254. case @battler.index
  255. when 0
  256. @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
  257. @spriteX=PokeBattle_SceneConstants::PLAYERBOXD1_X
  258. @spriteY=PokeBattle_SceneConstants::PLAYERBOXD1_Y
  259. when 1
  260. @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
  261. @spriteX=PokeBattle_SceneConstants::FOEBOXD1_X
  262. @spriteY=PokeBattle_SceneConstants::FOEBOXD1_Y
  263. when 2
  264. @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
  265. @spriteX=PokeBattle_SceneConstants::PLAYERBOXD2_X
  266. @spriteY=PokeBattle_SceneConstants::PLAYERBOXD2_Y
  267. when 3
  268. @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
  269. @spriteX=PokeBattle_SceneConstants::FOEBOXD2_X
  270. @spriteY=PokeBattle_SceneConstants::FOEBOXD2_Y
  271. end
  272. else
  273. case @battler.index
  274. when 0
  275. @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxS")
  276. @spriteX=PokeBattle_SceneConstants::PLAYERBOX_X
  277. @spriteY=PokeBattle_SceneConstants::PLAYERBOX_Y
  278. @showhp=true
  279. @showexp=true
  280. when 1
  281. @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxS")
  282. @spriteX=PokeBattle_SceneConstants::FOEBOX_X
  283. @spriteY=PokeBattle_SceneConstants::FOEBOX_Y
  284. end
  285. end
  286. @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleStatuses"))
  287. @contents=BitmapWrapper.new(@databox.width,@databox.height)
  288. self.bitmap=@contents
  289. self.visible=false
  290. self.z=50
  291. refreshExpLevel
  292. refresh
  293. end
  294.  
  295. def dispose
  296. @statuses.dispose
  297. @contents.dispose
  298. super
  299. end
  300.  
  301. def refreshExpLevel
  302. if !@battler.pokemon
  303. @explevel=0
  304. else
  305. growthrate=@battler.pokemon.growthrate
  306. startexp=PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
  307. endexp=PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
  308. if startexp==endexp
  309. @explevel=0
  310. else
  311. @explevel=(@battler.pokemon.exp-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/(endexp-startexp)
  312. end
  313. end
  314. end
  315.  
  316. def exp
  317. return @animatingEXP ? @currentexp : @explevel
  318. end
  319.  
  320. def hp
  321. return @animatingHP ? @currenthp : @battler.hp
  322. end
  323.  
  324. def animateHP(oldhp,newhp)
  325. @starthp=oldhp
  326. @currenthp=oldhp
  327. @endhp=newhp
  328. @animatingHP=true
  329. end
  330.  
  331. def animateEXP(oldexp,newexp)
  332. @currentexp=oldexp
  333. @endexp=newexp
  334. @animatingEXP=true
  335. end
  336.  
  337. def appear
  338. refreshExpLevel
  339. refresh
  340. self.visible=true
  341. self.opacity=255
  342. end
  343.  
  344. def getBattler(battler)
  345. return battler.effects[PBEffects::Illusion] if PBEffects.const_defined?(:Illusion) && battler.respond_to?('effects') && !battler.effects[PBEffects::Illusion].nil?
  346. return battler
  347. end
  348.  
  349. def refresh
  350. self.bitmap.clear
  351. return if !@battler.pokemon
  352. self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  353. base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
  354. shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
  355. pokename=@battler.name
  356. pbSetSystemFont(self.bitmap)
  357. textpos=[
  358. [pokename,@spritebaseX+8,6,false,base,shadow]
  359. ]
  360. genderX=self.bitmap.text_size(pokename).width
  361. genderX+=@spritebaseX+14
  362. if @battler.gender==0 # Male
  363. textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
  364. elsif @battler.gender==1 # Female
  365. textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
  366. end
  367. pbDrawTextPositions(self.bitmap,textpos)
  368. pbSetSmallFont(self.bitmap)
  369. textpos=[
  370. [_INTL("Lv{1}",@battler.level),@spritebaseX+202,8,true,base,shadow]
  371. ]
  372. if @showhp
  373. hpstring=_ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
  374. textpos.push([hpstring,@spritebaseX+188,48,true,base,shadow])
  375. end
  376. pbDrawTextPositions(self.bitmap,textpos)
  377. imagepos=[]
  378. if @battler.pokemon.isShiny?
  379. shinyX=206
  380. shinyX=-6 if (@battler.index&1)==0 # If player's Pokémon
  381. imagepos.push(["Graphics/Pictures/shiny.png",@spritebaseX+shinyX,36,0,0,-1,-1])
  382. end
  383. if @battler.isMega?
  384. imagepos.push(["Graphics/Pictures/battleMegaEvoBox.png",@spritebaseX+8,34,0,0,-1,-1])
  385. end
  386. if @battler.owned && (@battler.index&1)==1
  387. imagepos.push(["Graphics/Pictures/battleBoxOwned.png",@spritebaseX+8,36,0,0,-1,-1])
  388. end
  389. pbDrawImagePositions(self.bitmap,imagepos)
  390. if @battler.status>0
  391. self.bitmap.blt(@spritebaseX+24,36,@statuses.bitmap,
  392. Rect.new(0,(@battler.status-1)*16,44,16))
  393. end
  394. hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
  395. hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
  396. hpgauge=2 if hpgauge==0 && self.hp>0
  397. hpzone=0
  398. hpzone=1 if self.hp<=(@battler.totalhp/2).floor
  399. hpzone=2 if self.hp<=(@battler.totalhp/4).floor
  400. hpcolors=[
  401. PokeBattle_SceneConstants::HPCOLORGREENDARK,
  402. PokeBattle_SceneConstants::HPCOLORGREEN,
  403. PokeBattle_SceneConstants::HPCOLORYELLOWDARK,
  404. PokeBattle_SceneConstants::HPCOLORYELLOW,
  405. PokeBattle_SceneConstants::HPCOLORREDDARK,
  406. PokeBattle_SceneConstants::HPCOLORRED
  407. ]
  408. # fill with black (shows what the HP used to be)
  409. hpGaugeX=PokeBattle_SceneConstants::HPGAUGE_X
  410. hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
  411. if @animatingHP && self.hp>0
  412. self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,
  413. @starthp*hpGaugeSize/@battler.totalhp,6,Color.new(0,0,0))
  414. end
  415. # fill with HP color
  416. self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,hpgauge,2,hpcolors[hpzone*2])
  417. self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY+2,hpgauge,4,hpcolors[hpzone*2+1])
  418. if @showexp
  419. # fill with EXP color
  420. expGaugeX=PokeBattle_SceneConstants::EXPGAUGE_X
  421. expGaugeY=PokeBattle_SceneConstants::EXPGAUGE_Y
  422. self.bitmap.fill_rect(@spritebaseX+expGaugeX,expGaugeY,self.exp,2,
  423. PokeBattle_SceneConstants::EXPCOLORSHADOW)
  424. self.bitmap.fill_rect(@spritebaseX+expGaugeX,expGaugeY+2,self.exp,2,
  425. PokeBattle_SceneConstants::EXPCOLORBASE)
  426. end
  427. end
  428.  
  429. def update
  430. super
  431. @frame+=1
  432. if @animatingHP
  433. if @currenthp < @endhp
  434. @currenthp+=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor*4].max
  435. @currenthp=@endhp if @currenthp > @endhp
  436. elsif @currenthp > @endhp
  437. @currenthp-=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor*4].max
  438. @currenthp=@endhp if @currenthp < @endhp
  439. end
  440. refresh
  441. @animatingHP=false if @currenthp==@endhp
  442. end
  443. if @animatingEXP
  444. if !@showexp
  445. @currentexp=@endexp
  446. elsif @currentexp < @endexp # Gaining Exp
  447. if @endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE ||
  448. @endexp-@currentexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
  449. @currentexp+=4
  450. else
  451. @currentexp+=2
  452. end
  453. @currentexp=@endexp if @currentexp > @endexp
  454. elsif @currentexp > @endexp # Losing Exp
  455. if @endexp==0 ||
  456. @currentexp-@endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
  457. @currentexp-=4
  458. elsif @currentexp > @endexp
  459. @currentexp-=2
  460. end
  461. @currentexp=@endexp if @currentexp < @endexp
  462. end
  463. refresh
  464. if @currentexp==@endexp
  465. if @currentexp==PokeBattle_SceneConstants::EXPGAUGESIZE
  466. if @expflash==0
  467. pbSEPlay("expfull")
  468. self.flash(Color.new(64,200,248),8)
  469. @expflash=8
  470. else
  471. @expflash-=1
  472. if @expflash==0
  473. @animatingEXP=false
  474. refreshExpLevel
  475. end
  476. end
  477. else
  478. @animatingEXP=false
  479. end
  480. end
  481. end
  482. end
  483. end
  484.  
  485. class NewSafariDataBox < SpriteWrapper
  486. attr_accessor :selected
  487. attr_reader :appearing
  488.  
  489. def initialize(battle,viewport=nil)
  490. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  491. view.z = viewport.z + 1
  492. viewport = view
  493. super(viewport)
  494. @selected=0
  495. @battle=battle
  496. @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerSafari")
  497. @spriteX=PokeBattle_SceneConstants::SAFARIBOX_X
  498. @spriteY=PokeBattle_SceneConstants::SAFARIBOX_Y
  499. @appearing=false
  500. @contents=BitmapWrapper.new(@databox.width,@databox.height)
  501. self.bitmap=@contents
  502. self.visible=false
  503. self.z=50
  504. refresh
  505. end
  506.  
  507. def appear
  508. refresh
  509. self.visible=true
  510. self.opacity=255
  511. end
  512.  
  513. def refresh
  514. self.bitmap.clear
  515. self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  516. pbSetSystemFont(self.bitmap)
  517. textpos=[]
  518. base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
  519. shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
  520. textpos.push([_INTL("Safari Balls"),30,8,false,base,shadow])
  521. textpos.push([_INTL("Left: {1}",@battle.ballcount),30,38,false,base,shadow])
  522. pbDrawTextPositions(self.bitmap,textpos)
  523. end
  524.  
  525. def update
  526. end
  527. end
  528. #===============================================================================
  529. # Command Menu
  530. # UI ovarhaul
  531. #===============================================================================
  532. class NewCommandWindow
  533. attr_accessor :index
  534.  
  535. def initialize(viewport=nil,battle=nil,safari=false)
  536. if !viewport.nil?
  537. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  538. view.z = viewport.z
  539. view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  540. view2.z = viewport.z + 2
  541. viewport = view
  542. end
  543. @battle=battle
  544. @safaribattle=safari
  545. @viewport=viewport
  546. @viewport2=(viewport.nil?) ? viewport : view2
  547. @index=0
  548. @over=false
  549.  
  550. @buttonBitmap=pbBitmap("Graphics/Pictures/battlecommands_new")
  551.  
  552. @texts=[
  553. ["Fight","Bag","Pokemon","Run"],
  554. ["Ball","Bait","Rock","Call"]
  555. ]
  556.  
  557. @helpText=Sprite.new(@viewport)
  558. @helpText.bitmap=Bitmap.new(Graphics.width,36)
  559. @helpText.y=384-84
  560. @helpText.x=512
  561. @helpText.z=100
  562. pbSetSystemFont(@helpText.bitmap)
  563.  
  564.  
  565. @bgText=Sprite.new(@viewport)
  566. @bgText.bitmap=Bitmap.new(512,98)
  567. @bgText.y=384-68
  568. @bgText.z=110
  569. pbSetSystemFont(@bgText.bitmap)
  570. text=[]
  571.  
  572. @selHand=Sprite.new(@viewport2)
  573. @selHand.bitmap=pbBitmap("Graphics/Pictures/selHand")
  574. @selHand.oy=@selHand.bitmap.height
  575. @selHand.ox=@selHand.bitmap.width/2
  576. @selHand.z=150
  577. @selHand.visible=false
  578. @animdata=[0.1,0]
  579.  
  580. @button={}
  581. for i in 0...4
  582. @button["#{i}"]=Sprite.new(@viewport)
  583. @button["#{i}"].bitmap=@buttonBitmap
  584. @button["#{i}"].visible=false
  585. row=(@safaribattle) ? 1 : 0
  586. row=0 if i==3
  587. @button["#{i}"].z=120
  588. if i==0
  589. @button["#{i}"].src_rect.set(0,0,416,176)
  590. @button["#{i}"].x=48#+(i*122)
  591. @button["#{i}"].y=480
  592. end
  593. if i==1
  594. @button["#{i}"].src_rect.set(0,268,156,92)
  595. @button["#{i}"].x=2#+(i*122)
  596. @button["#{i}"].y=690
  597. end
  598. if i==2
  599. @button["#{i}"].src_rect.set(0,176,156,92)
  600. @button["#{i}"].x=354#+(i*122)
  601. @button["#{i}"].y=690
  602. end
  603. if i==3
  604. @button["#{i}"].src_rect.set(0,360,156,92)
  605. @button["#{i}"].x=178#+(i*122)
  606. @button["#{i}"].y=706
  607. end
  608. text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
  609. end
  610. #pbDrawTextPositions(@bgText.bitmap,text)
  611. # @bgText.x=@button["#{@index}"].x
  612. #@bgText.src_rect.set((@index*122)+16,0,116,98)
  613. end
  614.  
  615. def refreshCommands(index)
  616. poke=@battle.battlers[index]
  617. for i in 0...4
  618. @button["#{i}"].dispose if @button["#{i}"] && !@button["#{i}"].disposed?
  619. end
  620. @bgText.bitmap.clear
  621. text=[]
  622. for i in 0...4
  623. @button["#{i}"]=Sprite.new(@viewport)
  624. @button["#{i}"].bitmap=@buttonBitmap
  625. row=(@safaribattle) ? 1 : 0
  626. if i==3
  627. if poke.isShadow? && poke.inHyperMode?
  628. row=1
  629. else
  630. row=0
  631. end
  632. end
  633. @button["#{i}"].z=120
  634. if i==0
  635. @button["#{i}"].src_rect.set(0,0,416,176)
  636. @button["#{i}"].x=48#+(i*122)
  637. @button["#{i}"].y=480
  638. end
  639. if i==1
  640. @button["#{i}"].src_rect.set(0,268,156,92)
  641. @button["#{i}"].x=2#+(i*122)
  642. @button["#{i}"].y=690
  643. end
  644. if i==2
  645. @button["#{i}"].src_rect.set(0,176,156,92)
  646. @button["#{i}"].x=354#+(i*122)
  647. @button["#{i}"].y=690
  648. end
  649. if i==3
  650. @button["#{i}"].src_rect.set(0,360,156,92)
  651. @button["#{i}"].x=178#+(i*122)
  652. @button["#{i}"].y=706
  653. end
  654. # text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
  655. end
  656. # pbDrawTextPositions(@bgText.bitmap,text)
  657. end
  658.  
  659. def visible; end; def visible=(val); end
  660. def disposed?; end; def dispose; end
  661. def color; end; def color=(val); end
  662.  
  663. def text=(msg)
  664. bitmap=pbBitmap("Graphics/Pictures/newBattleMessageSmall")
  665. balls=pbBitmap("Graphics/Pictures/ballnormal")
  666. @helpText.bitmap.clear
  667. @helpText.bitmap.blt(0,0,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
  668. text=[["#{msg}",bitmap.width/2,2,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,PokeBattle_SceneConstants::MESSAGESHADOWCOLOR]]
  669. for i in 0...6
  670. next if @safaribattle
  671. o=3
  672. if i < @battle.party1.length && @battle.party1[i]
  673. if @battle.party1[i].hp <=0 || @battle.party1[i].isEgg?
  674. o=2
  675. elsif @battle.party1[i].status > 0
  676. o=1
  677. else
  678. o=0
  679. end
  680. end
  681. @helpText.bitmap.blt(404+(i*30),30,balls,Rect.new(o*30,0,30,30))
  682. next if !@battle.opponent
  683. enemyindex=i
  684. if @battle.doublebattle && i >=3
  685. enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
  686. end
  687. o=3
  688. if enemyindex < @battle.party2.length && @battle.party2[enemyindex]
  689. if @battle.party2[enemyindex].hp <=0 || @battle.party2[enemyindex].isEgg?
  690. o=2
  691. elsif @battle.party2[enemyindex].status > 0
  692. o=1
  693. else
  694. o=0
  695. end
  696. end
  697. @helpText.bitmap.blt(i*30,0,balls,Rect.new(o*30,0,30,30))
  698. end
  699. pbDrawTextPositions(@helpText.bitmap,text)
  700. end
  701.  
  702. def showText
  703. # @helpText.opacity=255
  704. # @helpText.x-=52
  705. @helpText.x-=51.2
  706. end
  707.  
  708.  
  709. def show
  710. @selHand.visible=false
  711. # @helpText.opacity+=25.5
  712. # @helpText.x-=52
  713. for i in 0...4
  714. @button["#{i}"].visible=true
  715. if i==0
  716. @button["#{i}"].y=480
  717. end
  718. if i==1
  719. @button["#{i}"].y=690
  720. end
  721. if i==2
  722. @button["#{i}"].y=690
  723. end
  724. if i==3
  725. @button["#{i}"].y=706
  726. end
  727. end
  728. end
  729.  
  730. def hide
  731. @selHand.visible=false
  732. for i in 0...4
  733. @button["#{i}"].visible=false
  734. end
  735. #@helpText.opacity-=25.5
  736. @helpText.x+=51.2
  737. @helpText.x=Graphics.width+8 if @helpText.opacity <=0
  738. end
  739.  
  740. def update
  741.  
  742. @selHand.x=@button["#{@index}"].x+58
  743. @selHand.y=@button["#{@index}"].y
  744. @selHand.zoom_y-=@animdata[0]
  745. @selHand.visible=true
  746. @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
  747. if @selHand.zoom_y >=1
  748. @animdata[0]=0
  749. @animdata[1]+=1
  750. if @animdata[1] > 14
  751. @animdata[0]=0.1
  752. @animdata[1]=0
  753. end
  754. end
  755. @over=false
  756. for i in 0...4
  757. if USEMOUSE
  758. if $mouse.over?(@button["#{i}"])
  759. @over=true
  760. @index = i
  761. end
  762. end
  763. if @index==i
  764. # @button["#{i}"].y-=1 if @button["#{i}"].y > @background.y+2
  765. else
  766. # @button["#{i}"].y+=1 if @button["#{i}"].y < @background.y+12
  767. end
  768. end
  769. end
  770.  
  771. def mouseOver?
  772. return false if !USEMOUSE
  773. return @over
  774. end
  775.  
  776. end
  777.  
  778. class PokeBattle_Scene
  779.  
  780. alias pbCommandMenu_old pbCommandMenu
  781. def pbCommandMenu(index)
  782. @orgPos=[@vector.x,@vector.y,@vector.angle,@vector.scale,@vector.zoom1] if @orgPos.nil?
  783. @idleTimer=0 if @idleTimer < 0
  784. pbCommandMenu_old(index)
  785. end
  786.  
  787. alias pbCommandMenuEx_old pbCommandMenuEx
  788. def pbCommandMenuEx(index,texts,mode=0)
  789. if !USENEWUI
  790. return pbCommandMenuEx_old(index,texts,mode)
  791. end
  792. @ret=0
  793. clearMessageWindow
  794. cw=@commandWindow
  795. cw.refreshCommands(index)
  796. name=(@safaribattle) ? $Trainer.name : @battle.battlers[index].name
  797. cw.text=_INTL("What will {1} do?",name)
  798. pbSEPlay("SE_Zoom2",50)
  799. 10.times do
  800. cw.showText
  801. animateBattleSprites(true)
  802. pbGraphicsUpdate
  803. end
  804. pbSEPlay("SE_Zoom4",50)
  805. 10.times do
  806. cw.show
  807. animateBattleSprites(true)
  808. pbGraphicsUpdate
  809. end
  810. pbRefresh
  811. loop do
  812. pbGraphicsUpdate
  813. pbInputUpdate
  814. animateBattleSprites(true)
  815. cw.update
  816. # Update selected command
  817. if Input.trigger?(Input::LEFT)
  818. if cw.index > 0
  819. pbSEPlay("SE_Select1")
  820. cw.index-=1
  821. elsif cw.index <=0
  822. pbSEPlay("SE_Select1")
  823. cw.index=3
  824. end
  825. end
  826. if Input.trigger?(Input::RIGHT)
  827. if cw.index < 3
  828. pbSEPlay("SE_Select1")
  829. cw.index+=1
  830. elsif cw.index >=3
  831. pbSEPlay("SE_Select1")
  832. cw.index=0
  833. end
  834. end
  835. if Input.trigger?(Input::UP)
  836. if cw.index==1
  837. pbSEPlay("SE_Select1")
  838. cw.index-=1
  839. elsif cw.index >=3
  840. pbSEPlay("SE_Select1")
  841. cw.index=0
  842. end
  843. end
  844. if Input.trigger?(Input::DOWN)
  845. if cw.index==0
  846. pbSEPlay("SE_Select1")
  847. cw.index+=1
  848. elsif cw.index >=3
  849. pbSEPlay("SE_Select1")
  850. cw.index=0
  851. end
  852. end
  853. if Input.trigger?(Input::C) || (USEMOUSE && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
  854. pbSEPlay("SE_Select2")
  855. @ret=cw.index
  856. @lastcmd[index]=@ret
  857. break
  858. elsif (Input.trigger?(Input::B) || (USEMOUSE && $mouse.leftClick?)) && index==2 && @lastcmd[0]!=2 # Cancel
  859. pbSEPlay("SE_Select2")
  860. @ret=-1
  861. break
  862. end
  863. end
  864. 10.times do
  865. cw.hide
  866. animateBattleSprites(true)
  867. pbGraphicsUpdate
  868. end
  869. if @ret > 0
  870. @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
  871. @vector.inc=0.2
  872. end
  873. return @ret
  874. end
  875.  
  876. end
  877. #===============================================================================
  878. # Fight Menu
  879. # UI ovarhaul
  880. #===============================================================================
  881. class NewFightWindow
  882. attr_accessor :index
  883. attr_accessor :battler
  884. attr_accessor :refreshpos
  885. attr_reader :nummoves
  886.  
  887. def initialize(viewport=nil)
  888. if !viewport.nil?
  889. view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  890. view.z = viewport.z
  891. view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
  892. view2.z = viewport.z + 2
  893. viewport = view
  894. end
  895. @viewport=viewport
  896. @viewport2=(viewport.nil?) ? viewport : view2
  897. @index=0
  898. @over=false
  899. @refreshpos=false
  900. @battler=nil
  901. @nummoves=0
  902.  
  903. @buttonBitmap=pbBitmap("Graphics/Pictures/battleFightButtons")
  904. @categoryBitmap=pbBitmap("Graphics/Pictures/category")
  905. @typeBitmap=pbBitmap("Graphics/Pictures/types")
  906.  
  907. @background=Sprite.new(@viewport)
  908. @background.bitmap=pbBitmap("Graphics/Pictures/battleFight")
  909. @background.y=400
  910. @background.z=100
  911. @background.visible=false
  912.  
  913. @selHand=Sprite.new(@viewport2)
  914. @selHand.bitmap=pbBitmap("Graphics/Pictures/selHand")
  915. @selHand.oy=@selHand.bitmap.height
  916. @selHand.ox=@selHand.bitmap.width/2
  917. @selHand.z=150
  918. @selHand.visible=false
  919. @animdata=[0.1,0]
  920.  
  921.  
  922. @megaButton=Sprite.new(@viewport)
  923. @megaButton.bitmap=pbBitmap("Graphics/Pictures/battleMegaEvo")
  924. @megaButton.y=252
  925. @megaButton.x=-16
  926. @megaButton.z=145
  927. @megaButton.src_rect.set(0,0,116,48)
  928.  
  929. @button={}
  930. @moved=false
  931. @showMega=false
  932. @position=[]
  933. @alternate=[0,0]
  934.  
  935. end
  936.  
  937. def generateButtons
  938. @moves=@battler.moves
  939. @nummoves=0
  940. @position.clear
  941. for i in 0...4
  942. @button["#{i}"].dispose if @button["#{i}"]
  943. @button["#{i}_2"].dispose if @button["#{i}_2"]
  944. @nummoves+=1 if @moves[i] && @moves[i].id > 0
  945. end
  946. if @index==3
  947. for j in 0...@position.length
  948. @position[j]+=220
  949. end
  950. end
  951. for i in 0...@nummoves
  952. movedata=PBMoveData.new(@moves[i].id)
  953. @button["#{i}"]=Sprite.new(@viewport)
  954. @button["#{i}"].bitmap=Bitmap.new(248,108)
  955. pbSetSystemFont(@button["#{i}"].bitmap)
  956. @button["#{i}"].z=120
  957. @button["#{i}"].x=4+256*(i%2)
  958. @button["#{i}"].y=450+128*(i/2)
  959. baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR#@buttonBitmap.get_pixel(0,32+(@moves[i].type*108))
  960. shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR#@buttonBitmap.get_pixel(20,4+(@moves[i].type*108))
  961. @button["#{i}"].bitmap.blt(0,0,@buttonBitmap,Rect.new(0,@moves[i].type*108,248,108))
  962. text=[
  963. ["#{@moves[i].name}",103,10,2,baseColor,shadowColor],
  964. ["PP: #{@moves[i].pp}/#{@moves[i].totalpp}",103-18,38,2,baseColor,shadowColor]
  965. ]
  966. pbDrawTextPositions(@button["#{i}"].bitmap,text)
  967.  
  968. @button["#{i}_2"]=Sprite.new(@viewport)
  969. @button["#{i}_2"].bitmap=Bitmap.new(214,88)
  970. @button["#{i}_2"].z=120
  971. @button["#{i}_2"].x=4+256*(i%2)
  972. @button["#{i}_2"].y=450+128*(i/2)
  973. @button["#{i}_2"].visible=false
  974. @button["#{i}_2"].visible=true if @index==i
  975. @button["#{i}_2"].bitmap.blt(148,62,@categoryBitmap,Rect.new(0,movedata.category*28,64,28))
  976.  
  977. @button["#{i}_3"]=Sprite.new(@viewport)
  978. @button["#{i}_3"].bitmap=Bitmap.new(214,88)
  979. @button["#{i}_3"].z=120
  980. @button["#{i}_3"].x=4+256*(i%2)
  981. @button["#{i}_3"].y=450+128*(i/2)
  982. # @button["#{i}_3"].visible=false
  983. @button["#{i}_3"].visible=true #if @index==i
  984. @button["#{i}_3"].bitmap.blt(148,62,@typeBitmap,Rect.new(0,@moves[i].type*28,64,28))
  985. end
  986. end
  987.  
  988. def show
  989. @selHand.visible=false
  990. @background.visible=true
  991. end
  992.  
  993. def hide
  994. @selHand.visible=false
  995. @background.visible=false
  996. @megaButton.x-=10
  997. @showMega=false
  998. for i in 0...@nummoves
  999. @button["#{i}"].visible=false
  1000. @button["#{i}_2"].visible=false
  1001. @button["#{i}_3"].visible=false
  1002. end
  1003. end
  1004.  
  1005. def megaButton
  1006. @showMega=true
  1007. end
  1008.  
  1009. def megaButtonTrigger
  1010. @megaButton.src_rect.y+=48
  1011. @megaButton.src_rect.y=0 if @megaButton.src_rect.y >=96
  1012. end
  1013.  
  1014. def update
  1015. for i in 0...@position.length
  1016. @position[i]=30+(i*220)-(@index*220) if @index < 3 or @refreshpos
  1017. end
  1018. @refreshpos=false
  1019. for i in 0...@nummoves
  1020. @button["#{i}_2"].visible=false
  1021. @button["#{i}_2"].visible=true if @index==i
  1022. @button["#{i}_3"].visible=true
  1023. @button["#{i}_3"].visible=false if @index==i
  1024. end
  1025. if @showMega
  1026. @megaButton.x+=10 if @megaButton.x < -16
  1027. end
  1028. @selHand.x=@button["#{@index}"].x+103
  1029. @selHand.y=@button["#{@index}"].y
  1030. @selHand.zoom_y-=@animdata[0]
  1031. @selHand.visible=true
  1032. @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
  1033. if @selHand.zoom_y >=1
  1034. @animdata[0]=0
  1035. @animdata[1]+=1
  1036. if @animdata[1] > 14
  1037. @animdata[0]=0.1
  1038. @animdata[1]=0
  1039. end
  1040. end
  1041. if USEMOUSE
  1042. @over = false
  1043. for i in 0...@nummoves
  1044. if $mouse.over?(@button["#{i}"])
  1045. @over = true
  1046. @index = i
  1047. end
  1048. end
  1049. end
  1050.  
  1051. end
  1052.  
  1053. def overMega?
  1054. return false if !USEMOUSE
  1055. return $mouse.over?(@megaButton)
  1056. end
  1057.  
  1058. def mouseOver?
  1059. return false if !USEMOUSE
  1060. return @over
  1061. end
  1062. end
  1063.  
  1064. class PokeBattle_Scene
  1065.  
  1066. alias pbFightMenu_old pbFightMenu
  1067. def pbFightMenu(index)
  1068. if !USENEWUI
  1069. return pbFightMenu_old(index)
  1070. end
  1071. clearMessageWindow
  1072. cw = @fightWindow
  1073. mega = false
  1074. battler=@battle.battlers[index]
  1075. cw.megaButton if @battle.pbCanMegaEvolve?(index)
  1076. cw.battler=battler
  1077. lastIndex=@lastmove[index]
  1078. if battler.moves[lastIndex].id!=0
  1079. cw.index=lastIndex
  1080. else
  1081. cw.index=0
  1082. end
  1083. cw.generateButtons
  1084. pbSelectBattler(index)
  1085. pbSEPlay("SE_Zoom4",50)
  1086. #10.times do
  1087. # cw.show
  1088. # moveEntireScene(8,-6)
  1089. # animateBattleSprites(true)
  1090. # pbGraphicsUpdate
  1091. #end
  1092. moveUpperRight(cw)
  1093. pbRefresh
  1094. loop do
  1095. pbGraphicsUpdate
  1096. pbInputUpdate
  1097. animateBattleSprites(true)
  1098. cw.update
  1099. # Update selected command
  1100. if Input.trigger?(Input::LEFT)
  1101. if cw.index > 0
  1102. pbSEPlay("SE_Select1")
  1103. cw.index-=1
  1104. else
  1105. pbSEPlay("SE_Select1")
  1106. cw.index=cw.nummoves-1
  1107. cw.refreshpos=true
  1108. end
  1109. elsif Input.trigger?(Input::RIGHT)
  1110. if cw.index < (cw.nummoves-1)
  1111. pbSEPlay("SE_Select1")
  1112. cw.index+=1
  1113. else
  1114. pbSEPlay("SE_Select1")
  1115. cw.index=0
  1116. end
  1117. end
  1118. if Input.trigger?(Input::UP) && (cw.index&2)==2
  1119. pbSEPlay("SE_Select1")
  1120. cw.index-=2
  1121. elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
  1122. pbSEPlay("SE_Select1")
  1123. cw.index+=2
  1124. end
  1125. if Input.trigger?(Input::C) || (USEMOUSE && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
  1126. @ret=cw.index
  1127. @battle.pbRegisterMegaEvolution(index) if mega
  1128. pbSEPlay("SE_Select2")
  1129. @lastmove[index]=@ret
  1130. @idleTimer=-1
  1131. break
  1132. elsif Input.trigger?(Input::A) || (USEMOUSE && cw.overMega? && $mouse.leftClick?) # Use Mega Evolution
  1133. if @battle.pbCanMegaEvolve?(index)
  1134. if mega
  1135. mega = false
  1136. else
  1137. mega = true
  1138. end
  1139. cw.megaButtonTrigger
  1140. pbSEPlay("SE_Select3")
  1141. end
  1142. elsif Input.trigger?(Input::B) || (USEMOUSE && $mouse.leftClick?) # Cancel fight menu
  1143. @lastmove[index]=cw.index
  1144. pbPlayCancelSE()
  1145. @ret=-1
  1146. break
  1147. end
  1148. end
  1149. if @ret > -1
  1150. @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
  1151. @orgPos=nil
  1152. @vector.inc=0.2
  1153. @vector.lock
  1154. 10.times do
  1155. cw.hide
  1156. wait(1,true)
  1157. end
  1158. else
  1159. moveLowerLeft(cw)
  1160. end
  1161. return @ret
  1162. end
  1163.  
  1164. alias pbChooseTarget_old pbChooseTarget
  1165. def pbChooseTarget(index)
  1166. if !USENEWUI
  1167. return pbChooseTarget_old(index)
  1168. end
  1169. curwindow=pbFirstTarget(index)
  1170. if curwindow==-1
  1171. raise RuntimeError.new(_INTL("No targets somehow..."))
  1172. end
  1173. loop do
  1174. pbGraphicsUpdate
  1175. pbInputUpdate
  1176. pbUpdateSelected(curwindow)
  1177. if Input.trigger?(Input::C)
  1178. pbUpdateSelected(-1)
  1179. @ret=curwindow
  1180. break
  1181. end
  1182. if Input.trigger?(Input::B)
  1183. pbUpdateSelected(-1)
  1184. @ret=-1
  1185. break
  1186. end
  1187. if Input.trigger?(Input::RIGHT) && !(curwindow==3 or curwindow==2)
  1188. pbPlayCursorSE()
  1189. newcurwindow=3 if curwindow==1
  1190. newcurwindow=2 if curwindow==0
  1191. curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
  1192. elsif Input.trigger?(Input::DOWN) && !(curwindow==0 or curwindow==2)
  1193. pbPlayCursorSE()
  1194. newcurwindow=0 if curwindow==1
  1195. newcurwindow=2 if curwindow==3
  1196. curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
  1197. elsif Input.trigger?(Input::LEFT) && !(curwindow==1 or curwindow==0)
  1198. pbPlayCursorSE()
  1199. newcurwindow=1 if curwindow==3
  1200. newcurwindow=0 if curwindow==2
  1201. curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
  1202. elsif Input.trigger?(Input::UP) && !(curwindow==3 or curwindow==1)
  1203. pbPlayCursorSE()
  1204. newcurwindow=3 if curwindow==2
  1205. newcurwindow=1 if curwindow==0
  1206. curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
  1207. end
  1208. #
  1209. @sprites["shades"].opacity+=15 if @sprites["shades"].opacity < 150
  1210. for i in 0...4
  1211. if @sprites["pokemon#{i}"]
  1212. if index==i or curwindow==i
  1213. increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"].tone.red > 0
  1214. else
  1215. increaseTone(@sprites["pokemon#{i}"],10) if @sprites["pokemon#{i}"].tone.red < 80
  1216. end
  1217. end
  1218. end
  1219. #
  1220. end
  1221. 10.times do
  1222. @sprites["shades"].opacity-=15 if @sprites["shades"].opacity > 0
  1223. for i in 0...4
  1224. increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"] && @sprites["pokemon#{i}"].tone.red > 0
  1225. end
  1226. animateBattleSprites(true)
  1227. pbGraphicsUpdate
  1228. end
  1229. return @ret
  1230. end
  1231.  
  1232. end
  1233.  
  1234. def increaseTone(sprite,amount)
  1235. sprite.tone.red+=amount
  1236. sprite.tone.green+=amount
  1237. sprite.tone.blue+=amount
  1238. end
  1239. #===============================================================================
  1240. # Command Choices
  1241. # UI ovarhaul
  1242. #===============================================================================
  1243. class NewChoiceSel
  1244. attr_accessor :index
  1245. attr_reader :over
  1246.  
  1247. def initialize(viewport,commands)
  1248. @commands=commands
  1249. @index=0
  1250. @over=false
  1251. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  1252. @viewport.z=viewport.z+5
  1253. @sprites={}
  1254. @sprites["back"]=Sprite.new(@viewport)
  1255. @sprites["back"].bitmap=pbBitmap("Graphics/Pictures/shadeRest")
  1256. @sprites["back"].opacity=0
  1257. bitmap=pbBitmap("Graphics/Pictures/draw_choice")
  1258. baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  1259. shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  1260. @sprites["sel"]=Sprite.new(@viewport)
  1261. @sprites["sel"].bitmap=bitmap
  1262. @sprites["sel"].src_rect.set(0,84,500,84)
  1263. @sprites["sel"].y=480
  1264. @sprites["sel"].x=6
  1265. @sprites["sel"].z=+1
  1266. for i in 0...@commands.length
  1267. @sprites["choice#{i}"]=Sprite.new(@viewport)
  1268. @sprites["choice#{i}"].x=6
  1269. @sprites["choice#{i}"].y=480+96*i
  1270. @sprites["choice#{i}"].bitmap=Bitmap.new(500,84)
  1271. choice=@sprites["choice#{i}"].bitmap
  1272. pbSetSystemFont(choice)
  1273. choice.blt(0,0,bitmap,Rect.new(0,0,500,84))
  1274. pbDrawOutlineText(choice,0,0,500,84,@commands[i],baseColor,shadowColor,1)
  1275. end
  1276. end
  1277.  
  1278. def dispose(scene)
  1279. 5.times do
  1280. @sprites["back"].opacity-=51
  1281. @sprites["sel"].opacity-=51
  1282. for i in 0...@commands.length
  1283. @sprites["choice#{i}"].opacity-=51
  1284. end
  1285. @sprites["choice#{@index}"].y+=2
  1286. scene.animateBattleSprites(true)
  1287. scene.pbGraphicsUpdate
  1288. end
  1289. pbDisposeSpriteHash(@sprites)
  1290. @viewport.dispose
  1291. end
  1292.  
  1293. def update
  1294. @sprites["sel"].x=@sprites["choice#{@index}"].x
  1295. @sprites["sel"].y=@sprites["choice#{@index}"].y
  1296. @sprites["back"].opacity+=25.5 if @sprites["back"].opacity < 255
  1297. if Input.trigger?(Input::UP)
  1298. pbSEPlay("SE_Select1")
  1299. @index-=1
  1300. @index=@commands.length-1 if @index < 0
  1301. @sprites["sel"].y=@sprites["choice#{@index}"].y
  1302. end
  1303. if Input.trigger?(Input::DOWN)
  1304. pbSEPlay("SE_Select1")
  1305. @index+=1
  1306. @index=0 if @index >=@commands.length
  1307. @sprites["sel"].y=@sprites["choice#{@index}"].y
  1308. end
  1309. @over=false
  1310. if USEMOUSE
  1311. for i in 0...2
  1312. if $mouse.over?(@sprites["choice#{i}"])
  1313. @index = i
  1314. @over=true
  1315. end
  1316. end
  1317. end
  1318. for i in 0...@commands.length
  1319. # @sprites["choice#{i}"].src_rect.y-=1 if @sprites["choice#{i}"].src_rect.y > 0
  1320. # @sprites["choice#{i}"].y-=(@sprites["choice#{i}"].y-220)*0.4
  1321. end
  1322. end
  1323.  
  1324. end
  1325. #===============================================================================
  1326. # Battle Bag interface
  1327. # UI ovarhaul
  1328. #===============================================================================
  1329. class NewBattleBag
  1330. attr_reader :index
  1331. attr_reader :ret
  1332.  
  1333. def pbDisplayMessage(msg)
  1334. @scene.changeMessageViewport(@viewport)
  1335. @scene.pbDisplayMessage(msg)
  1336. @scene.clearMessageWindow
  1337. @scene.changeMessageViewport
  1338. end
  1339.  
  1340. def initialize(scene,viewport)
  1341. @scene=scene
  1342. $lastUsed=0 if $lastUsed.nil?
  1343. @background=Viewport.new(0,0,Graphics.width,Graphics.height)
  1344. @background.z=viewport.z+5
  1345. @viewport=Viewport.new(0,400,Graphics.width,Graphics.height)
  1346. @viewport.z=viewport.z+5
  1347. @lastUsed=$lastUsed
  1348. @index=0
  1349. @item=0
  1350. @page=-1
  1351. @selPocket=0
  1352. @ret=nil
  1353. @over=false
  1354. @baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
  1355. @shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
  1356.  
  1357.  
  1358. @sprites={}
  1359. @items={}
  1360. @bitmaps=[pbBitmap("Graphics/Pictures/BattleBag/menus"),
  1361. pbBitmap("Graphics/Pictures/BattleBag/lastitem"),
  1362. pbBitmap("Graphics/Pictures/BattleBag/menuitem"),
  1363. #pbBitmap("Graphics/Pictures/BattleBag/lastitem"),
  1364. pbBitmap("Graphics/Pictures/BattleBag/back")]
  1365. @sprites["back"]=Sprite.new(@background)
  1366. @sprites["back"].bitmap=pbBitmap("Graphics/Pictures/shadeFull")
  1367. @sprites["back"].opacity=0
  1368. @sprites["sel"]=Sprite.new(@viewport)
  1369. @sprites["sel"].x=-216
  1370. @sprites["sel"].y=34
  1371. @sprites["name"]=Sprite.new(@viewport)
  1372. @sprites["name"].bitmap=Bitmap.new(412,78)
  1373. pbSetSystemFont(@sprites["name"].bitmap)
  1374. @sprites["name"].x=-380
  1375. @sprites["name"].y=328
  1376. @sprites["name"].visible=false
  1377. for i in 0...4
  1378. @sprites["pocket#{i}"]=Sprite.new(@viewport)
  1379. @sprites["pocket#{i}"].bitmap=@bitmaps[0]
  1380. @sprites["pocket#{i}"].src_rect.set(0,140*i,252,140)
  1381. @sprites["pocket#{i}"].x=2+(i%2)*256#+((i%2==0) ? -260 : 260)
  1382. @sprites["pocket#{i}"].y=18+(i/2)*144#+(i%2)*42
  1383. @sprites["pocket#{i}"].visible=false
  1384.  
  1385. end
  1386. @sprites["pocket4"]=Sprite.new(@viewport)
  1387. @sprites["pocket4"].bitmap=Bitmap.new(412,78)
  1388. pbSetSystemFont(@sprites["pocket4"].bitmap)
  1389. @sprites["pocket4"].x=2
  1390. @sprites["pocket4"].y=306
  1391. @sprites["pocket4"].visible=false
  1392. self.refresh
  1393. @sprites["pocket5"]=Sprite.new(@viewport)
  1394. @sprites["pocket5"].bitmap=@bitmaps[3]
  1395. @sprites["pocket5"].src_rect.set(0,0,120,52)
  1396. @sprites["pocket5"].x=434
  1397. @sprites["pocket5"].y=306
  1398. @sprites["pocket5"].z=5
  1399. @sprites["pocket5"].visible=false
  1400. @sprites["confirm"]=Sprite.new(@viewport)
  1401. @sprites["confirm"].bitmap=Bitmap.new(466,156)
  1402. pbSetSmallFont(@sprites["confirm"].bitmap)
  1403. @sprites["confirm"].x=26-520
  1404. @sprites["confirm"].y=80
  1405. @sprites["cancel"]=Sprite.new(@viewport)
  1406. @sprites["cancel"].bitmap=pbBitmap("Graphics/Pictures/BattleBag/back")
  1407. # @sprites["cancel"].src_rect.set(466,0,466,72)
  1408. @sprites["cancel"].x=434
  1409. @sprites["cancel"].y=306
  1410. @sprites["cancel"].visible=false
  1411.  
  1412. end
  1413.  
  1414. def drawPocket(pocket)
  1415. @pocket=[]
  1416. @pgtrigger=false
  1417. tp=$PokemonBag.pockets[pocket]
  1418. tp=tp+$PokemonBag.pockets[1] if pocket==7
  1419. tp=tp+$PokemonBag.pockets[8] if pocket==7
  1420. for i in 0...tp.length
  1421. item=tp[i]
  1422. @pocket.push([item[0],item[1]]) if ItemHandlers.hasUseInBattle(item[0]) || ItemHandlers.hasBattleUseOnPokemon(item[0]) || ItemHandlers.hasBattleUseOnBattler(item[0])
  1423. end
  1424. if @pocket.length < 1
  1425. pbDisplayMessage("You have no usable items in this pocket.")
  1426. return
  1427. end
  1428. @xpos=[]
  1429. @pages=@pocket.length/6
  1430. @pages+=1 if @pocket.length%6 > 0
  1431. @page=0
  1432. @item=0
  1433. @back=false
  1434. @selPocket=pocket
  1435. pbDisposeSpriteHash(@items)
  1436. @pname=pbPocketNames[pocket]
  1437. x=0
  1438. y=0
  1439. for j in 0...@pocket.length
  1440. i=j
  1441. @items["#{j}"]=Sprite.new(@viewport)
  1442. @items["#{j}"].bitmap=Bitmap.new(252,92)
  1443. pbSetSystemFont(@items["#{j}"].bitmap)
  1444. @items["#{j}"].bitmap.blt(0,0,@bitmaps[2],Rect.new(0,0,252,92))
  1445. @items["#{j}"].bitmap.blt(156,32,pbBitmap(sprintf("Graphics/Icons/item%03d",@pocket[i][0])),Rect.new(0,0,48,48))
  1446. pbDrawOutlineText(@items["#{j}"].bitmap,8,8,200,38,"#{PBItems.getName(@pocket[i][0])}",@baseColor,@shadowColor,1)
  1447. pbDrawOutlineText(@items["#{j}"].bitmap,8,46,200,38,"x#{@pocket[i][1]}",@baseColor,@shadowColor,1)
  1448.  
  1449. @items["#{j}"].x=2+x*256+(i/6)*512+512
  1450. @xpos.push(@items["#{j}"].x-512)
  1451. @items["#{j}"].y=28+y*90
  1452. @items["#{j}"].opacity=255
  1453. x+=1
  1454. y+=1 if x > 1
  1455. x=0 if x > 1
  1456. y=0 if y > 2
  1457. end
  1458. end
  1459.  
  1460. def name
  1461. bitmap=@sprites["name"].bitmap
  1462. bitmap.clear
  1463. bitmap.blt(0,0,pbBitmap("Graphics/Pictures/battleLastItem"),Rect.new(0,0,412,78))
  1464. pbDrawOutlineText(bitmap,0,0,320,36,@pname,@baseColor,@shadowColor,1)
  1465. pbDrawOutlineText(bitmap,300,0,80,36,"#{@page+1}/#{@pages}",@baseColor,@shadowColor,1)
  1466. @sprites["name"].x+=38 if @sprites["name"].x < 0
  1467. @sprites["name"].visible=true
  1468. end
  1469.  
  1470. def updatePocket
  1471. @page=@item/6
  1472. # self.name
  1473. @sprites["name"].visible=false
  1474. for i in 0...@pocket.length
  1475. @items["#{i}"].x-=(@items["#{i}"].x-(@xpos[i]-@page*512))*0.2
  1476. @items["#{i}"].src_rect.y-=1 if @items["#{i}"].src_rect.y > 0
  1477. end
  1478. if @back
  1479. @sprites["sel"].bitmap=@bitmaps[2]
  1480. @sprites["sel"].src_rect.set(120*2,0,120,52)
  1481. @sprites["sel"].x=@sprites["pocket5"].x
  1482. @sprites["sel"].y=@sprites["pocket5"].y
  1483. else
  1484. @sprites["sel"].bitmap=@bitmaps[0]
  1485. @sprites["sel"].src_rect.set(216*4,0,216,92)
  1486. @sprites["sel"].x=@items["#{@item}"].x
  1487. @sprites["sel"].y=@items["#{@item}"].y
  1488. end
  1489. # @sprites["pocket5"].src_rect.y-=1 if @sprites["pocket5"].src_rect.y > 0
  1490. if Input.trigger?(Input::LEFT) && !@back
  1491. pbSEPlay("SE_Select1")
  1492. if ![0,2,4].include?(@item)
  1493. if @item%2==0
  1494. @item-=5
  1495. else
  1496. @item-=1
  1497. end
  1498. else
  1499. @item-=1 if @item < 0
  1500. end
  1501. @item=0 if @item < 0
  1502. @items["#{@item}"].src_rect.y+=6
  1503. end
  1504. if Input.trigger?(Input::RIGHT) && !@back
  1505. pbSEPlay("SE_Select1")
  1506. if @page < (@pocket.length)/6
  1507. if @item%2==1
  1508. @item+=5
  1509. else
  1510. @item+=1
  1511. end
  1512. else
  1513. @item+=1 if @item < @pocket.length-1
  1514. end
  1515. @item=@pocket.length-1 if @item > @pocket.length-1
  1516. @items["#{@item}"].src_rect.y+=6
  1517. end
  1518. if Input.trigger?(Input::UP)
  1519. pbSEPlay("SE_Select1")
  1520. if @back
  1521. @item+=4 if (@item%6) < 2
  1522. @back=false
  1523. else
  1524. @item-=2
  1525. if (@item%6) > 3
  1526. @item+=6
  1527. @back=true
  1528. end
  1529. end
  1530. @item=0 if @item < 0
  1531. @item=@pocket.length-1 if @item > @pocket.length-1
  1532. @items["#{@item}"].src_rect.y+=6 if !@back
  1533. @sprites["pocket5"].src_rect.y+=6 if @back
  1534. end
  1535. if Input.trigger?(Input::DOWN)
  1536. pbSEPlay("SE_Select1")
  1537. if @back
  1538. @item-=4 if (@item%6) > 3
  1539. @back=false
  1540. else
  1541. @item+=2
  1542. if (@item%6) < 2
  1543. @item-=6
  1544. @back=true
  1545. end
  1546. @back=true if @item > @pocket.length-1
  1547. end
  1548. @item=@pocket.length-1 if @item > @pocket.length-1
  1549. @item=0 if @item < 0
  1550. @items["#{@item}"].src_rect.y+=6 if !@back
  1551. @sprites["pocket5"].src_rect.y+=6 if @back
  1552. end
  1553. @over=false
  1554. if USEMOUSE
  1555. for i in 0...@pocket.length
  1556. if $mouse.over?(@items["#{i}"])
  1557. @item = i
  1558. @back=false
  1559. @over=true
  1560. end
  1561. end
  1562. if $mouse.inArea?(Graphics.width-32,0,32,Graphics.height) && @page < (@pocket.length)/6
  1563. if !@pgtrigger
  1564. @item+=5 if !(@item+5 > @pocket.length-1)
  1565. @item=@pocket.length-1 if @item > @pocket.length-1
  1566. end
  1567. @pgtrigger=true
  1568. end
  1569. if $mouse.inArea?(0,0,32,Graphics.height) && @page > 0
  1570. if !@pgtrigger
  1571. @item-=5 if !(@item-5 < 0)
  1572. @item=0 if @item < 0
  1573. end
  1574. @pgtrigger=true
  1575. end
  1576. @pgtrigger=false if !$mouse.inArea?(Graphics.width-32,0,32,Graphics.height) && !$mouse.inArea?(0,0,32,Graphics.height)
  1577. if $mouse.over?(@sprites["pocket5"])
  1578. @back=true
  1579. @over=true
  1580. end
  1581. end
  1582. if (@back && (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?))) || Input.trigger?(Input::B)
  1583. pbSEPlay("SE_Select3")
  1584. @selPocket=0
  1585. @page=-1
  1586. @back=false
  1587. @doubleback=true
  1588. end
  1589. end
  1590.  
  1591. def closeCurrent
  1592. @selPocket=0
  1593. @page=-1
  1594. @back=false
  1595. @ret=nil
  1596. self.refresh
  1597. end
  1598.  
  1599. def show
  1600. @ret=nil
  1601. self.refresh
  1602. for i in 0...6
  1603. @sprites["pocket#{i}"].opacity=255
  1604. end
  1605. # @sprites["pocket4"].y=316+80
  1606. # @sprites["pocket5"].y=320+80
  1607. @sprites["pocket4"].visible=true
  1608. @sprites["pocket5"].visible=true
  1609. pbSEPlay("SE_Zoom4",60)
  1610. 10.times do
  1611. for i in 0...4
  1612. @sprites["pocket#{i}"].visible=true
  1613. end
  1614. for i in 4...6
  1615. # @sprites["pocket#{i}"].y-=8
  1616. end
  1617. @sprites["back"].opacity+=25.5
  1618. @scene.animateBattleSprites(true)
  1619. @scene.pbGraphicsUpdate
  1620. end
  1621. end
  1622.  
  1623. def hide
  1624. @sprites["sel"].x=Graphics.width
  1625. @sprites["pocket4"].visible=false
  1626. @sprites["pocket5"].visible=false
  1627. 10.times do
  1628. for i in 0...4
  1629. @sprites["pocket#{i}"].visible=false
  1630. end
  1631. for i in 4...6
  1632. # @sprites["pocket#{i}"].y+=8
  1633. end
  1634. if @pocket
  1635. for i in 0...@pocket.length
  1636. @items["#{i}"].opacity-=25.5
  1637. end
  1638. end
  1639. #@sprites["name"].x-=38
  1640. @sprites["back"].opacity-=25.5
  1641. @scene.animateBattleSprites(true)
  1642. @scene.pbGraphicsUpdate
  1643. end
  1644. end
  1645.  
  1646. def useItem?
  1647. Input.update
  1648. bitmap=@sprites["confirm"].bitmap
  1649. bitmap.clear
  1650. bitmap.blt(0,0,pbBitmap("Graphics/Pictures/BattleBag/iteminfo"),Rect.new(0,0,466,156))
  1651. bitmap.blt(20,30,pbBitmap(sprintf("Graphics/Icons/item%03d",@ret)),Rect.new(0,0,48,48))
  1652. drawTextEx(bitmap,80,12,364,3,pbGetMessage(MessageTypes::ItemDescriptions,@ret),@shadowColor,Color.new(200,200,200))
  1653. @sprites["sel"].bitmap=pbBitmap("Graphics/Pictures/battleItemConfirm")
  1654. @sprites["sel"].x=Graphics.width
  1655. @sprites["sel"].src_rect.width=466
  1656. 10.times do
  1657. @sprites["confirm"].x+=52
  1658. @sprites["cancel"].x+=52
  1659. if @pocket
  1660. for i in 0...@pocket.length
  1661. @items["#{i}"].opacity-=25.5
  1662. end
  1663. end
  1664. for i in 0...4
  1665. @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
  1666. end
  1667. # @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
  1668. # @sprites["pocket5"].y+=8 if @sprites["pocket5"].y < 400
  1669. #@sprites["name"].x-=38
  1670. @scene.animateBattleSprites
  1671. @scene.pbGraphicsUpdate
  1672. end
  1673. # @sprites["name"].x=-380
  1674. index=0
  1675. choice=(index==0) ? "confirm" : "cancel"
  1676. loop do
  1677. @sprites["sel"].x=@sprites["#{choice}"].x
  1678. @sprites["sel"].y=@sprites["#{choice}"].y
  1679. @sprites["sel"].src_rect.x=(466*(index+2))
  1680. @sprites["#{choice}"].src_rect.y-=1 if @sprites["#{choice}"].src_rect.y > 0
  1681. if Input.trigger?(Input::UP)
  1682. pbSEPlay("SE_Select1")
  1683. index-=1
  1684. index=1 if index < 0
  1685. choice=(index==0) ? "confirm" : "cancel"
  1686. @sprites["#{choice}"].src_rect.y+=6
  1687. end
  1688. if Input.trigger?(Input::DOWN)
  1689. pbSEPlay("SE_Select1")
  1690. index+=1
  1691. index=0 if index > 1
  1692. choice=(index==0) ? "confirm" : "cancel"
  1693. @sprites["#{choice}"].src_rect.y+=6
  1694. end
  1695. @over=false
  1696. for i in 0...2
  1697. if USEMOUSE
  1698. c=(i==0) ? "confirm" : "cancel"
  1699. if $mouse.over?(@sprites["#{c}"])
  1700. choice=(i==0) ? "confirm" : "cancel"
  1701. index = i
  1702. @over=true
  1703. end
  1704. end
  1705. end
  1706. if Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)
  1707. pbSEPlay("SE_Select2")
  1708. break
  1709. end
  1710. Input.update
  1711. @scene.animateBattleSprites
  1712. @scene.pbGraphicsUpdate
  1713. end
  1714. @sprites["sel"].x=Graphics.width
  1715. self.refresh
  1716. 10.times do
  1717. # @sprites["confirm"].x-=52
  1718. # @sprites["cancel"].x-=52
  1719. # @sprites["pocket5"].y-=8 if index > 0
  1720. @scene.animateBattleSprites
  1721. @scene.pbGraphicsUpdate
  1722. end
  1723. if index > 0
  1724. @ret=nil
  1725. return false
  1726. else
  1727. @index=0 if @index==4 && @lastUsed==0
  1728. return true
  1729. end
  1730. end
  1731.  
  1732. def finish
  1733. if (Input.trigger?(Input::B) || ((Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && @index==5)) && @selPocket==0 && !@doubleback
  1734. pbSEPlay("SE_Select3")
  1735. return true
  1736. end
  1737. @doubleback=false
  1738. return false
  1739. end
  1740.  
  1741. def refresh
  1742. bitmap=@sprites["pocket4"].bitmap
  1743. bitmap.clear
  1744. i=(@lastUsed > 0 ? 1 : 0)
  1745. text=["","#{PBItems.getName(@lastUsed)}"]
  1746. bitmap.blt(0,0,@bitmaps[1],Rect.new(0,0,412,78))
  1747. bitmap.blt(28,6,pbBitmap(sprintf("Graphics/Icons/item%03d",@lastUsed)),Rect.new(0,0,48,48)) if @lastUsed>0
  1748. pbDrawOutlineText(bitmap,0,0,356,60,text[i],@baseColor,@shadowColor,1)
  1749. end
  1750.  
  1751. def update
  1752. if @selPocket==0
  1753. updateMain
  1754. for i in 0...4
  1755. @sprites["pocket#{i}"].opacity+=51 if @sprites["pocket#{i}"].opacity < 255
  1756. end
  1757. # @sprites["pocket4"].y-=8 if @sprites["pocket4"].y > 316
  1758. if @pocket
  1759. for i in 0...@pocket.length
  1760. @items["#{i}"].opacity-=51 if @items["#{i}"] && @items["#{i}"].opacity > 0
  1761. end
  1762. end
  1763. @sprites["name"].x-=38 if @sprites["name"].x > -380
  1764. else
  1765. if (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && !@back
  1766. pbSEPlay("SE_Select2")
  1767. @selPocket=0
  1768. @page=-1
  1769. @lastUsed=0
  1770. @lastUsed=@pocket[@item][0] if @pocket[@item][1] > 1
  1771. $lastUsed=@lastUsed
  1772. @ret=@pocket[@item][0]
  1773. end
  1774. updatePocket
  1775. for i in 0...4
  1776. @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
  1777. end
  1778. # @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
  1779. for i in 0...@pocket.length
  1780. @items["#{i}"].opacity+=51 if @items["#{i}"] && @items["#{i}"].opacity < 255
  1781. end
  1782. end
  1783. end
  1784.  
  1785. def updateMain
  1786. if @index < 4
  1787. @sprites["sel"].bitmap=@bitmaps[0]
  1788. @sprites["sel"].src_rect.set(216*4,0,216,92)
  1789. elsif @index==4
  1790. @sprites["sel"].bitmap=@bitmaps[1]
  1791. @sprites["sel"].src_rect.set(356*2,0,356,60)
  1792. else
  1793. @sprites["sel"].bitmap=@bitmaps[2]
  1794. @sprites["sel"].src_rect.set(120*2,0,120,52)
  1795. end
  1796. @sprites["sel"].x=@sprites["pocket#{@index}"].x
  1797. @sprites["sel"].y=@sprites["pocket#{@index}"].y
  1798. if Input.trigger?(Input::LEFT)
  1799. pbSEPlay("SE_Select1")
  1800. @index-=1
  1801. @index+=2 if @index%2==1
  1802. @index=3 if @index==4 && !(@lastUsed > 0)
  1803. @sprites["pocket#{@index}"].src_rect.y+=6
  1804. end
  1805. if Input.trigger?(Input::RIGHT)
  1806. pbSEPlay("SE_Select1")
  1807. @index+=1
  1808. @index-=2 if @index%2==0
  1809. @index=2 if @index==4 && !(@lastUsed > 0)
  1810. @sprites["pocket#{@index}"].src_rect.y+=6
  1811. end
  1812. if Input.trigger?(Input::UP)
  1813. pbSEPlay("SE_Select1")
  1814. @index-=2
  1815. @index+=6 if @index < 0
  1816. @index=5 if @index==4 && !(@lastUsed > 0)
  1817. @sprites["pocket#{@index}"].src_rect.y+=6
  1818. end
  1819. if Input.trigger?(Input::DOWN)
  1820. pbSEPlay("SE_Select1")
  1821. @index+=2
  1822. @index-=6 if @index > 5
  1823. @index=5 if @index==4 && !(@lastUsed > 0)
  1824. @sprites["pocket#{@index}"].src_rect.y+=6
  1825. end
  1826. @over = false
  1827. for i in 0...6
  1828. if USEMOUSE
  1829. if $mouse.over?(@sprites["pocket#{i}"])
  1830. @index = i if i!=4 || (i==4 && @lastUsed > 0)
  1831. @over = true
  1832. end
  1833. end
  1834. # @sprites["pocket#{i}"].src_rect.y-=1 if @sprites["pocket#{i}"].src_rect.y > 0
  1835. end
  1836. if (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && !@doubleback && @index < 5
  1837. pbSEPlay("SE_Select2")
  1838. if @index < 4
  1839. cmd=[2,3,5,7]
  1840. self.drawPocket(cmd[@index])
  1841. else
  1842. @selPocket=0
  1843. @page=-1
  1844. @ret=@lastUsed
  1845. @lastUsed=0 if !($PokemonBag.pbQuantity(@lastUsed) > 1)
  1846. end
  1847. end
  1848. end
  1849.  
  1850. end
  1851.  
  1852. class PokeBattle_Scene
  1853. alias pbItemMenu_old pbItemMenu
  1854. def pbItemMenu(index)
  1855. @idleTimer=-1
  1856. @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
  1857. @vector.inc=0.2
  1858. Input.update
  1859. return pbItemMenu_old(index) if !USENEWUI
  1860. ret=0
  1861. retindex=-1
  1862. pkmnid=-1
  1863. @bagWindow.show
  1864. loop do
  1865. break if @bagWindow.finish
  1866. Input.update
  1867. @bagWindow.update
  1868. if !@bagWindow.ret.nil? && @bagWindow.useItem?
  1869. item=@bagWindow.ret
  1870. usetype=$ItemData[item][ITEMBATTLEUSE]
  1871. if usetype==1 || usetype==3
  1872. modparty=[]
  1873. for i in 0...6
  1874. modparty.push(@battle.party1[@battle.partyorder[i]])
  1875. end
  1876. pkmnlist=PokemonScreen_Scene.new
  1877. pkmnlist.addPriority=true
  1878. pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
  1879. pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
  1880. activecmd=pkmnscreen.pbChoosePokemon
  1881. pkmnid=@battle.partyorder[activecmd]
  1882. if activecmd>=0 && pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
  1883. pkmnlist.pbEndScene
  1884. ret=item
  1885. retindex=pkmnid
  1886. break
  1887. end
  1888. pkmnlist.pbEndScene
  1889. @bagWindow.closeCurrent
  1890. #itemscene.pbStartScene($PokemonBag)
  1891. elsif usetype==2 || usetype==4
  1892. if ItemHandlers.hasBattleUseOnBattler(item)
  1893. ret=item
  1894. retindex=index
  1895. break
  1896. end
  1897. end
  1898. end
  1899. animateBattleSprites
  1900. pbGraphicsUpdate
  1901. end
  1902. @bagWindow.hide
  1903. pbConsumeItemInBattle($PokemonBag,ret) if ret > 0
  1904. return [ret,retindex]
  1905. end
  1906. end
  1907. =begin
  1908. class PokemonScreen_Scene
  1909. attr_accessor :addPriority
  1910. def pbStartScene(party,starthelptext,annotations=nil,multiselect=false)
  1911. @sprites={}
  1912. @party=party
  1913. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  1914. @viewport.z=99999
  1915. @viewport.z+=6 if @addPriority
  1916. @multiselect=multiselect
  1917. addBackgroundPlane(@sprites,"partybg","partybg",@viewport)
  1918. @sprites["messagebox"]=Window_AdvancedTextPokemon.new("")
  1919. @sprites["helpwindow"]=Window_UnformattedTextPokemon.new(starthelptext)
  1920. @sprites["messagebox"].viewport=@viewport
  1921. @sprites["messagebox"].visible=false
  1922. @sprites["messagebox"].letterbyletter=true
  1923. @sprites["helpwindow"].viewport=@viewport
  1924. @sprites["helpwindow"].visible=true
  1925. pbBottomLeftLines(@sprites["messagebox"],2)
  1926. pbBottomLeftLines(@sprites["helpwindow"],1)
  1927. pbSetHelpText(starthelptext)
  1928. # Add party Pokémon sprites
  1929. for i in 0...6
  1930. if @party[i]
  1931. @sprites["pokemon#{i}"]=PokeSelectionSprite.new(
  1932. @party[i],i,@viewport)
  1933. else
  1934. @sprites["pokemon#{i}"]=PokeSelectionPlaceholderSprite.new(
  1935. @party[i],i,@viewport)
  1936. end
  1937. if annotations
  1938. @sprites["pokemon#{i}"].text=annotations[i]
  1939. end
  1940. end
  1941. if @multiselect
  1942. @sprites["pokemon6"]=PokeSelectionConfirmSprite.new(@viewport)
  1943. @sprites["pokemon7"]=PokeSelectionCancelSprite2.new(@viewport)
  1944. else
  1945. @sprites["pokemon6"]=PokeSelectionCancelSprite.new(@viewport)
  1946. end
  1947. # Select first Pokémon
  1948. @activecmd=0
  1949. @sprites["pokemon0"].selected=true
  1950. pbFadeInAndShow(@sprites) { update }
  1951. end
  1952. end
  1953. =end
  1954.  
  1955. def clearFakeText
  1956. @sprites["faketext"].bitmap.clear
  1957. end
  1958.  
  1959. def setFakeText(msg)
  1960. @sprites["faketext"].bitmap.clear
  1961. text=[["#{msg}",8,10,false,MESSAGEBASECOLOR,MESSAGESHADOWCOLOR]]
  1962. pbDrawTextPositions(@sprites["faketext"].bitmap,text)
  1963. end
  1964.  
  1965. def increaseTone(sprite,amount)
  1966. sprite.tone.red+=amount
  1967. sprite.tone.green+=amount
  1968. sprite.tone.blue+=amount
  1969. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement