Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Elite Battle Interface
- # created by Luka S.J.
- #
- # a brand new interface for Pokemon Essentials, to be used with the dynamic
- # battle system. Command and Fight windows are not based upon the previous
- # versions. Keep that in mind if you did (or plan to do) any alterations to the
- # interfaces.
- #===============================================================================
- module PokeBattle_SceneConstants
- if USENEWUI
- MESSAGEBASECOLOR = Color.new(80,80,88)
- MESSAGESHADOWCOLOR = Color.new(160,160,168)
- MENUBASECOLOR = MESSAGEBASECOLOR
- MENUSHADOWCOLOR = MESSAGESHADOWCOLOR
- BOXTEXTBASECOLOR = MESSAGEBASECOLOR
- BOXTEXTSHADOWCOLOR = MESSAGESHADOWCOLOR
- HPGAUGESIZE = 96
- EXPGAUGESIZE = 192
- end
- end
- def menuButtonAnim(sprite,updateall=true)
- 6.times do
- pbGraphicsUpdate if updateall
- animateBattleSprites(true) if updateall
- # pbMoveCamera if updateall
- sprite.tone.red+=26
- sprite.tone.blue+=26
- sprite.tone.green+=26
- end
- 6.times do
- pbGraphicsUpdate if updateall
- animateBattleSprites(true) if updateall
- # pbMoveCamera if updateall
- sprite.tone.red-=26
- sprite.tone.blue-=26
- sprite.tone.green-=26
- end
- end
- class BattleSelectorArrow
- def initialize(x,y,w,h,viewport=nil)
- @frame=0
- @arrows={}
- @savepos={}
- @visible=false
- @bitmap=BitmapCache.load_bitmap("Graphics/Pictures/BattleUI/battleselector")
- for i in 0...4
- bwidth=(i%2==0) ? 0 : @bitmap.width/2
- bheight=(i/2<1) ? 0 : @bitmap.height/2
- xpos=(i%2==0) ? x : x+w-@bitmap.width/2
- ypos=(i/2<1) ? y : h+y-@bitmap.height/2
- if viewport!=nil
- @arrows["#{i}"]=Sprite.new(viewport)
- else
- @arrows["#{i}"]=Sprite.new
- end
- @arrows["#{i}"].bitmap=@bitmap.clone
- @arrows["#{i}"].src_rect.set(bwidth,bheight,@bitmap.width/2,@bitmap.height/2)
- @arrows["#{i}"].pos(xpos,ypos)
- @arrows["#{i}"].z=9999998
- @arrows["#{i}"].opacity=0
- @savepos[i]=[xpos,ypos]
- end
- firstshow
- end
- def checkMouse
- if Input.triggerex?(Input::Mouse_Left) &&
- $mouse.y>=400
- return true
- end
- return false
- end
- def opacity=(value)
- for i in 0...4
- @arrows["#{i}"].opacity=value
- end
- end
- def opacity
- return @arrows["0"].opacity
- end
- def disposed?
- return @arrows["0"].disposed?
- end
- def color=(value)
- for i in 0...4
- @arrows["#{i}"].color=color
- end
- end
- def color
- return @arrows["0"].color
- end
- def visible=(value)
- for i in 0...4
- @arrows["#{i}"].visible=value
- end
- end
- def visible
- return @arrows["0"].visible
- end
- def checkTrigger
- if Input.trigger?(Input::C)
- return true
- elsif Input.trigger?(Input::UP)
- return true
- elsif Input.trigger?(Input::DOWN)
- return true
- elsif Input.trigger?(Input::LEFT)
- return true
- elsif Input.trigger?(Input::RIGHT)
- return true
- end
- return false
- end
- def update
- if checkTrigger
- if !visible?
- show
- $USINGMANUAL=true
- pbSEPlay("SE_Select1")
- pbWait(1) { update }
- end
- elsif checkMouse
- if visible?
- $USINGMANUAL=false
- hide
- end
- end
- @frame+=1
- if @frame==15
- for i in 0...4
- xplus=(i%2==0) ? -4 : 4
- yplus=(i/2<1) ? -4 : 4
- @arrows["#{i}"].x=@savepos[i][0]+xplus
- @arrows["#{i}"].y=@savepos[i][1]+yplus
- end
- elsif @frame==30
- for i in 0...4
- xplus=(i%2==0) ? -2 : 2
- yplus=(i/2<1) ? -2 : 2
- @arrows["#{i}"].x=@savepos[i][0]+xplus
- @arrows["#{i}"].y=@savepos[i][1]+yplus
- end
- elsif @frame==45
- for i in 0...4
- xplus=(i%2==0) ? 0 : 0
- yplus=(i/2<1) ? 0 : 0
- @arrows["#{i}"].x=@savepos[i][0]+xplus
- @arrows["#{i}"].y=@savepos[i][1]+yplus
- end
- end
- @frame=0 if @frame==45
- end
- def show
- @frame=0
- for i in 0...4
- @arrows["#{i}"].opacity=255
- end
- @visible=true
- end
- def firstshow
- if $USINGMANUAL
- for i in 0...4
- @arrows["#{i}"].opacity=255
- end
- @visible=true
- end
- end
- def visible?
- return @visible
- end
- def hide
- @frame=0
- for i in 0...4
- @arrows["#{i}"].opacity=0
- end
- @visible=false
- end
- def recolocate(x,y,w,h)
- for i in 0...4
- bwidth=(i%2==0) ? 0 : @bitmap.width/2
- bheight=(i/2<1) ? 0 : @bitmap.height/2
- xpos=(i%2==0) ? x : x+w-@bitmap.width/2
- ypos=(i/2<1) ? y : h+y-@bitmap.height/2
- @arrows["#{i}"].pos(xpos,ypos)
- @arrows["#{i}"].z=9999998
- @savepos[i]=[xpos,ypos]
- end
- end
- def dispose
- $USINGMANUAL=visible?
- for i in 0...4
- @arrows["#{i}"].dispose
- end
- end
- end
- #===============================================================================
- # Pokemon data battle boxes
- # UI overhaul
- #===============================================================================
- class PokemonNewDataBox < SpriteWrapper
- attr_reader :battler
- attr_accessor :selected
- attr_accessor :appearing
- attr_reader :animatingHP
- attr_reader :animatingEXP
- def initialize(battler,doublebattle,viewport=nil,player=nil)
- view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view.z = viewport.z + 1
- viewport = view
- super(viewport)
- @explevel=0
- @player=player
- @battler=battler
- @doublebattle=doublebattle
- @selected=0
- @frame=0
- @showhp=false
- @showexp=false
- @appearing=false
- @animatingHP=false
- @starthp=0
- @currenthp=0
- @endhp=0
- @expflash=0
- if (@battler.index&1)==0 # if player's Pokémon
- @spritebaseX=34
- else
- @spritebaseX=16
- end
- if doublebattle
- case @battler.index
- when 0
- @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
- @spriteX=PokeBattle_SceneConstants::PLAYERBOXD1_X
- @spriteY=PokeBattle_SceneConstants::PLAYERBOXD1_Y
- when 1
- @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
- @spriteX=PokeBattle_SceneConstants::FOEBOXD1_X
- @spriteY=PokeBattle_SceneConstants::FOEBOXD1_Y
- when 2
- @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
- @spriteX=PokeBattle_SceneConstants::PLAYERBOXD2_X
- @spriteY=PokeBattle_SceneConstants::PLAYERBOXD2_Y
- when 3
- @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
- @spriteX=PokeBattle_SceneConstants::FOEBOXD2_X
- @spriteY=PokeBattle_SceneConstants::FOEBOXD2_Y
- end
- else
- case @battler.index
- when 0
- @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxS")
- @spriteX=PokeBattle_SceneConstants::PLAYERBOX_X
- @spriteY=PokeBattle_SceneConstants::PLAYERBOX_Y
- @showhp=true
- @showexp=true
- when 1
- @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxS")
- @spriteX=PokeBattle_SceneConstants::FOEBOX_X
- @spriteY=PokeBattle_SceneConstants::FOEBOX_Y
- end
- end
- @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleStatuses"))
- @contents=BitmapWrapper.new(@databox.width,@databox.height)
- self.bitmap=@contents
- self.visible=false
- self.z=50
- refreshExpLevel
- refresh
- end
- def dispose
- @statuses.dispose
- @contents.dispose
- super
- end
- def refreshExpLevel
- if !@battler.pokemon
- @explevel=0
- else
- growthrate=@battler.pokemon.growthrate
- startexp=PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
- endexp=PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
- if startexp==endexp
- @explevel=0
- else
- @explevel=(@battler.pokemon.exp-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/(endexp-startexp)
- end
- end
- end
- def exp
- return @animatingEXP ? @currentexp : @explevel
- end
- def hp
- return @animatingHP ? @currenthp : @battler.hp
- end
- def animateHP(oldhp,newhp)
- @starthp=oldhp
- @currenthp=oldhp
- @endhp=newhp
- @animatingHP=true
- end
- def animateEXP(oldexp,newexp)
- @currentexp=oldexp
- @endexp=newexp
- @animatingEXP=true
- end
- def appear
- refreshExpLevel
- refresh
- self.visible=true
- self.opacity=255
- end
- def getBattler(battler)
- return battler.effects[PBEffects::Illusion] if PBEffects.const_defined?(:Illusion) && battler.respond_to?('effects') && !battler.effects[PBEffects::Illusion].nil?
- return battler
- end
- def refresh
- self.bitmap.clear
- return if !@battler.pokemon
- self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
- base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
- shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
- pokename=@battler.name
- pbSetSystemFont(self.bitmap)
- textpos=[
- [pokename,@spritebaseX+8,6,false,base,shadow]
- ]
- genderX=self.bitmap.text_size(pokename).width
- genderX+=@spritebaseX+14
- if @battler.gender==0 # Male
- textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
- elsif @battler.gender==1 # Female
- textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
- end
- pbDrawTextPositions(self.bitmap,textpos)
- pbSetSmallFont(self.bitmap)
- textpos=[
- [_INTL("Lv{1}",@battler.level),@spritebaseX+202,8,true,base,shadow]
- ]
- if @showhp
- hpstring=_ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
- textpos.push([hpstring,@spritebaseX+188,48,true,base,shadow])
- end
- pbDrawTextPositions(self.bitmap,textpos)
- imagepos=[]
- if @battler.pokemon.isShiny?
- shinyX=206
- shinyX=-6 if (@battler.index&1)==0 # If player's Pokémon
- imagepos.push(["Graphics/Pictures/shiny.png",@spritebaseX+shinyX,36,0,0,-1,-1])
- end
- if @battler.isMega?
- imagepos.push(["Graphics/Pictures/battleMegaEvoBox.png",@spritebaseX+8,34,0,0,-1,-1])
- end
- if @battler.owned && (@battler.index&1)==1
- imagepos.push(["Graphics/Pictures/battleBoxOwned.png",@spritebaseX+8,36,0,0,-1,-1])
- end
- pbDrawImagePositions(self.bitmap,imagepos)
- if @battler.status>0
- self.bitmap.blt(@spritebaseX+24,36,@statuses.bitmap,
- Rect.new(0,(@battler.status-1)*16,44,16))
- end
- hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
- hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
- hpgauge=2 if hpgauge==0 && self.hp>0
- hpzone=0
- hpzone=1 if self.hp<=(@battler.totalhp/2).floor
- hpzone=2 if self.hp<=(@battler.totalhp/4).floor
- hpcolors=[
- PokeBattle_SceneConstants::HPCOLORGREENDARK,
- PokeBattle_SceneConstants::HPCOLORGREEN,
- PokeBattle_SceneConstants::HPCOLORYELLOWDARK,
- PokeBattle_SceneConstants::HPCOLORYELLOW,
- PokeBattle_SceneConstants::HPCOLORREDDARK,
- PokeBattle_SceneConstants::HPCOLORRED
- ]
- # fill with black (shows what the HP used to be)
- hpGaugeX=PokeBattle_SceneConstants::HPGAUGE_X
- hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
- if @animatingHP && self.hp>0
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,
- @starthp*hpGaugeSize/@battler.totalhp,6,Color.new(0,0,0))
- end
- # fill with HP color
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,hpgauge,2,hpcolors[hpzone*2])
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY+2,hpgauge,4,hpcolors[hpzone*2+1])
- if @showexp
- # fill with EXP color
- expGaugeX=PokeBattle_SceneConstants::EXPGAUGE_X
- expGaugeY=PokeBattle_SceneConstants::EXPGAUGE_Y
- self.bitmap.fill_rect(@spritebaseX+expGaugeX,expGaugeY,self.exp,2,
- PokeBattle_SceneConstants::EXPCOLORSHADOW)
- self.bitmap.fill_rect(@spritebaseX+expGaugeX,expGaugeY+2,self.exp,2,
- PokeBattle_SceneConstants::EXPCOLORBASE)
- end
- end
- def update
- super
- @frame+=1
- if @animatingHP
- if @currenthp < @endhp
- @currenthp+=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor*4].max
- @currenthp=@endhp if @currenthp > @endhp
- elsif @currenthp > @endhp
- @currenthp-=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor*4].max
- @currenthp=@endhp if @currenthp < @endhp
- end
- refresh
- @animatingHP=false if @currenthp==@endhp
- end
- if @animatingEXP
- if !@showexp
- @currentexp=@endexp
- elsif @currentexp < @endexp # Gaining Exp
- if @endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE ||
- @endexp-@currentexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
- @currentexp+=4
- else
- @currentexp+=2
- end
- @currentexp=@endexp if @currentexp > @endexp
- elsif @currentexp > @endexp # Losing Exp
- if @endexp==0 ||
- @currentexp-@endexp >=PokeBattle_SceneConstants::EXPGAUGESIZE/4
- @currentexp-=4
- elsif @currentexp > @endexp
- @currentexp-=2
- end
- @currentexp=@endexp if @currentexp < @endexp
- end
- refresh
- if @currentexp==@endexp
- if @currentexp==PokeBattle_SceneConstants::EXPGAUGESIZE
- if @expflash==0
- pbSEPlay("expfull")
- self.flash(Color.new(64,200,248),8)
- @expflash=8
- else
- @expflash-=1
- if @expflash==0
- @animatingEXP=false
- refreshExpLevel
- end
- end
- else
- @animatingEXP=false
- end
- end
- end
- end
- end
- class NewSafariDataBox < SpriteWrapper
- attr_accessor :selected
- attr_reader :appearing
- def initialize(battle,viewport=nil)
- view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view.z = viewport.z + 1
- viewport = view
- super(viewport)
- @selected=0
- @battle=battle
- @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerSafari")
- @spriteX=PokeBattle_SceneConstants::SAFARIBOX_X
- @spriteY=PokeBattle_SceneConstants::SAFARIBOX_Y
- @appearing=false
- @contents=BitmapWrapper.new(@databox.width,@databox.height)
- self.bitmap=@contents
- self.visible=false
- self.z=50
- refresh
- end
- def appear
- refresh
- self.visible=true
- self.opacity=255
- end
- def refresh
- self.bitmap.clear
- self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
- pbSetSystemFont(self.bitmap)
- textpos=[]
- base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
- shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
- textpos.push([_INTL("Safari Balls"),30,8,false,base,shadow])
- textpos.push([_INTL("Left: {1}",@battle.ballcount),30,38,false,base,shadow])
- pbDrawTextPositions(self.bitmap,textpos)
- end
- def update
- end
- end
- #===============================================================================
- # Command Menu
- # UI ovarhaul
- #===============================================================================
- class NewCommandWindow
- attr_accessor :index
- def initialize(viewport=nil,battle=nil,safari=false)
- if !viewport.nil?
- view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view.z = viewport.z
- view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view2.z = viewport.z + 2
- viewport = view
- end
- @battle=battle
- @safaribattle=safari
- @viewport=viewport
- @viewport2=(viewport.nil?) ? viewport : view2
- @index=0
- @over=false
- @buttonBitmap=pbBitmap("Graphics/Pictures/battlecommands_new")
- @texts=[
- ["Fight","Bag","Pokemon","Run"],
- ["Ball","Bait","Rock","Call"]
- ]
- @helpText=Sprite.new(@viewport)
- @helpText.bitmap=Bitmap.new(Graphics.width,36)
- @helpText.y=384-84
- @helpText.x=512
- @helpText.z=100
- pbSetSystemFont(@helpText.bitmap)
- @bgText=Sprite.new(@viewport)
- @bgText.bitmap=Bitmap.new(512,98)
- @bgText.y=384-68
- @bgText.z=110
- pbSetSystemFont(@bgText.bitmap)
- text=[]
- @selHand=Sprite.new(@viewport2)
- @selHand.bitmap=pbBitmap("Graphics/Pictures/selHand")
- @selHand.oy=@selHand.bitmap.height
- @selHand.ox=@selHand.bitmap.width/2
- @selHand.z=150
- @selHand.visible=false
- @animdata=[0.1,0]
- @button={}
- for i in 0...4
- @button["#{i}"]=Sprite.new(@viewport)
- @button["#{i}"].bitmap=@buttonBitmap
- @button["#{i}"].visible=false
- row=(@safaribattle) ? 1 : 0
- row=0 if i==3
- @button["#{i}"].z=120
- if i==0
- @button["#{i}"].src_rect.set(0,0,416,176)
- @button["#{i}"].x=48#+(i*122)
- @button["#{i}"].y=480
- end
- if i==1
- @button["#{i}"].src_rect.set(0,268,156,92)
- @button["#{i}"].x=2#+(i*122)
- @button["#{i}"].y=690
- end
- if i==2
- @button["#{i}"].src_rect.set(0,176,156,92)
- @button["#{i}"].x=354#+(i*122)
- @button["#{i}"].y=690
- end
- if i==3
- @button["#{i}"].src_rect.set(0,360,156,92)
- @button["#{i}"].x=178#+(i*122)
- @button["#{i}"].y=706
- end
- text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
- end
- #pbDrawTextPositions(@bgText.bitmap,text)
- # @bgText.x=@button["#{@index}"].x
- #@bgText.src_rect.set((@index*122)+16,0,116,98)
- end
- def refreshCommands(index)
- poke=@battle.battlers[index]
- for i in 0...4
- @button["#{i}"].dispose if @button["#{i}"] && !@button["#{i}"].disposed?
- end
- @bgText.bitmap.clear
- text=[]
- for i in 0...4
- @button["#{i}"]=Sprite.new(@viewport)
- @button["#{i}"].bitmap=@buttonBitmap
- row=(@safaribattle) ? 1 : 0
- if i==3
- if poke.isShadow? && poke.inHyperMode?
- row=1
- else
- row=0
- end
- end
- @button["#{i}"].z=120
- if i==0
- @button["#{i}"].src_rect.set(0,0,416,176)
- @button["#{i}"].x=48#+(i*122)
- @button["#{i}"].y=480
- end
- if i==1
- @button["#{i}"].src_rect.set(0,268,156,92)
- @button["#{i}"].x=2#+(i*122)
- @button["#{i}"].y=690
- end
- if i==2
- @button["#{i}"].src_rect.set(0,176,156,92)
- @button["#{i}"].x=354#+(i*122)
- @button["#{i}"].y=690
- end
- if i==3
- @button["#{i}"].src_rect.set(0,360,156,92)
- @button["#{i}"].x=178#+(i*122)
- @button["#{i}"].y=706
- end
- # text.push(["#{@texts[row][i]}",78+(i*122),40,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,Color.new(41,71,77)])
- end
- # pbDrawTextPositions(@bgText.bitmap,text)
- end
- def visible; end; def visible=(val); end
- def disposed?; end; def dispose; end
- def color; end; def color=(val); end
- def text=(msg)
- bitmap=pbBitmap("Graphics/Pictures/newBattleMessageSmall")
- balls=pbBitmap("Graphics/Pictures/ballnormal")
- @helpText.bitmap.clear
- @helpText.bitmap.blt(0,0,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
- text=[["#{msg}",bitmap.width/2,2,2,PokeBattle_SceneConstants::MESSAGEBASECOLOR,PokeBattle_SceneConstants::MESSAGESHADOWCOLOR]]
- for i in 0...6
- next if @safaribattle
- o=3
- if i < @battle.party1.length && @battle.party1[i]
- if @battle.party1[i].hp <=0 || @battle.party1[i].isEgg?
- o=2
- elsif @battle.party1[i].status > 0
- o=1
- else
- o=0
- end
- end
- @helpText.bitmap.blt(404+(i*30),30,balls,Rect.new(o*30,0,30,30))
- next if !@battle.opponent
- enemyindex=i
- if @battle.doublebattle && i >=3
- enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
- end
- o=3
- if enemyindex < @battle.party2.length && @battle.party2[enemyindex]
- if @battle.party2[enemyindex].hp <=0 || @battle.party2[enemyindex].isEgg?
- o=2
- elsif @battle.party2[enemyindex].status > 0
- o=1
- else
- o=0
- end
- end
- @helpText.bitmap.blt(i*30,0,balls,Rect.new(o*30,0,30,30))
- end
- pbDrawTextPositions(@helpText.bitmap,text)
- end
- def showText
- # @helpText.opacity=255
- # @helpText.x-=52
- @helpText.x-=51.2
- end
- def show
- @selHand.visible=false
- # @helpText.opacity+=25.5
- # @helpText.x-=52
- for i in 0...4
- @button["#{i}"].visible=true
- if i==0
- @button["#{i}"].y=480
- end
- if i==1
- @button["#{i}"].y=690
- end
- if i==2
- @button["#{i}"].y=690
- end
- if i==3
- @button["#{i}"].y=706
- end
- end
- end
- def hide
- @selHand.visible=false
- for i in 0...4
- @button["#{i}"].visible=false
- end
- #@helpText.opacity-=25.5
- @helpText.x+=51.2
- @helpText.x=Graphics.width+8 if @helpText.opacity <=0
- end
- def update
- @selHand.x=@button["#{@index}"].x+58
- @selHand.y=@button["#{@index}"].y
- @selHand.zoom_y-=@animdata[0]
- @selHand.visible=true
- @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
- if @selHand.zoom_y >=1
- @animdata[0]=0
- @animdata[1]+=1
- if @animdata[1] > 14
- @animdata[0]=0.1
- @animdata[1]=0
- end
- end
- @over=false
- for i in 0...4
- if USEMOUSE
- if $mouse.over?(@button["#{i}"])
- @over=true
- @index = i
- end
- end
- if @index==i
- # @button["#{i}"].y-=1 if @button["#{i}"].y > @background.y+2
- else
- # @button["#{i}"].y+=1 if @button["#{i}"].y < @background.y+12
- end
- end
- end
- def mouseOver?
- return false if !USEMOUSE
- return @over
- end
- end
- class PokeBattle_Scene
- alias pbCommandMenu_old pbCommandMenu
- def pbCommandMenu(index)
- @orgPos=[@vector.x,@vector.y,@vector.angle,@vector.scale,@vector.zoom1] if @orgPos.nil?
- @idleTimer=0 if @idleTimer < 0
- pbCommandMenu_old(index)
- end
- alias pbCommandMenuEx_old pbCommandMenuEx
- def pbCommandMenuEx(index,texts,mode=0)
- if !USENEWUI
- return pbCommandMenuEx_old(index,texts,mode)
- end
- @ret=0
- clearMessageWindow
- cw=@commandWindow
- cw.refreshCommands(index)
- name=(@safaribattle) ? $Trainer.name : @battle.battlers[index].name
- cw.text=_INTL("What will {1} do?",name)
- pbSEPlay("SE_Zoom2",50)
- 10.times do
- cw.showText
- animateBattleSprites(true)
- pbGraphicsUpdate
- end
- pbSEPlay("SE_Zoom4",50)
- 10.times do
- cw.show
- animateBattleSprites(true)
- pbGraphicsUpdate
- end
- pbRefresh
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- animateBattleSprites(true)
- cw.update
- # Update selected command
- if Input.trigger?(Input::LEFT)
- if cw.index > 0
- pbSEPlay("SE_Select1")
- cw.index-=1
- elsif cw.index <=0
- pbSEPlay("SE_Select1")
- cw.index=3
- end
- end
- if Input.trigger?(Input::RIGHT)
- if cw.index < 3
- pbSEPlay("SE_Select1")
- cw.index+=1
- elsif cw.index >=3
- pbSEPlay("SE_Select1")
- cw.index=0
- end
- end
- if Input.trigger?(Input::UP)
- if cw.index==1
- pbSEPlay("SE_Select1")
- cw.index-=1
- elsif cw.index >=3
- pbSEPlay("SE_Select1")
- cw.index=0
- end
- end
- if Input.trigger?(Input::DOWN)
- if cw.index==0
- pbSEPlay("SE_Select1")
- cw.index+=1
- elsif cw.index >=3
- pbSEPlay("SE_Select1")
- cw.index=0
- end
- end
- if Input.trigger?(Input::C) || (USEMOUSE && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
- pbSEPlay("SE_Select2")
- @ret=cw.index
- @lastcmd[index]=@ret
- break
- elsif (Input.trigger?(Input::B) || (USEMOUSE && $mouse.leftClick?)) && index==2 && @lastcmd[0]!=2 # Cancel
- pbSEPlay("SE_Select2")
- @ret=-1
- break
- end
- end
- 10.times do
- cw.hide
- animateBattleSprites(true)
- pbGraphicsUpdate
- end
- if @ret > 0
- @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
- @vector.inc=0.2
- end
- return @ret
- end
- end
- #===============================================================================
- # Fight Menu
- # UI ovarhaul
- #===============================================================================
- class NewFightWindow
- attr_accessor :index
- attr_accessor :battler
- attr_accessor :refreshpos
- attr_reader :nummoves
- def initialize(viewport=nil)
- if !viewport.nil?
- view = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view.z = viewport.z
- view2 = Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width,viewport.rect.height)
- view2.z = viewport.z + 2
- viewport = view
- end
- @viewport=viewport
- @viewport2=(viewport.nil?) ? viewport : view2
- @index=0
- @over=false
- @refreshpos=false
- @battler=nil
- @nummoves=0
- @buttonBitmap=pbBitmap("Graphics/Pictures/battleFightButtons")
- @categoryBitmap=pbBitmap("Graphics/Pictures/category")
- @typeBitmap=pbBitmap("Graphics/Pictures/types")
- @background=Sprite.new(@viewport)
- @background.bitmap=pbBitmap("Graphics/Pictures/battleFight")
- @background.y=400
- @background.z=100
- @background.visible=false
- @selHand=Sprite.new(@viewport2)
- @selHand.bitmap=pbBitmap("Graphics/Pictures/selHand")
- @selHand.oy=@selHand.bitmap.height
- @selHand.ox=@selHand.bitmap.width/2
- @selHand.z=150
- @selHand.visible=false
- @animdata=[0.1,0]
- @megaButton=Sprite.new(@viewport)
- @megaButton.bitmap=pbBitmap("Graphics/Pictures/battleMegaEvo")
- @megaButton.y=252
- @megaButton.x=-16
- @megaButton.z=145
- @megaButton.src_rect.set(0,0,116,48)
- @button={}
- @moved=false
- @showMega=false
- @position=[]
- @alternate=[0,0]
- end
- def generateButtons
- @moves=@battler.moves
- @nummoves=0
- @position.clear
- for i in 0...4
- @button["#{i}"].dispose if @button["#{i}"]
- @button["#{i}_2"].dispose if @button["#{i}_2"]
- @nummoves+=1 if @moves[i] && @moves[i].id > 0
- end
- if @index==3
- for j in 0...@position.length
- @position[j]+=220
- end
- end
- for i in 0...@nummoves
- movedata=PBMoveData.new(@moves[i].id)
- @button["#{i}"]=Sprite.new(@viewport)
- @button["#{i}"].bitmap=Bitmap.new(248,108)
- pbSetSystemFont(@button["#{i}"].bitmap)
- @button["#{i}"].z=120
- @button["#{i}"].x=4+256*(i%2)
- @button["#{i}"].y=450+128*(i/2)
- baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR#@buttonBitmap.get_pixel(0,32+(@moves[i].type*108))
- shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR#@buttonBitmap.get_pixel(20,4+(@moves[i].type*108))
- @button["#{i}"].bitmap.blt(0,0,@buttonBitmap,Rect.new(0,@moves[i].type*108,248,108))
- text=[
- ["#{@moves[i].name}",103,10,2,baseColor,shadowColor],
- ["PP: #{@moves[i].pp}/#{@moves[i].totalpp}",103-18,38,2,baseColor,shadowColor]
- ]
- pbDrawTextPositions(@button["#{i}"].bitmap,text)
- @button["#{i}_2"]=Sprite.new(@viewport)
- @button["#{i}_2"].bitmap=Bitmap.new(214,88)
- @button["#{i}_2"].z=120
- @button["#{i}_2"].x=4+256*(i%2)
- @button["#{i}_2"].y=450+128*(i/2)
- @button["#{i}_2"].visible=false
- @button["#{i}_2"].visible=true if @index==i
- @button["#{i}_2"].bitmap.blt(148,62,@categoryBitmap,Rect.new(0,movedata.category*28,64,28))
- @button["#{i}_3"]=Sprite.new(@viewport)
- @button["#{i}_3"].bitmap=Bitmap.new(214,88)
- @button["#{i}_3"].z=120
- @button["#{i}_3"].x=4+256*(i%2)
- @button["#{i}_3"].y=450+128*(i/2)
- # @button["#{i}_3"].visible=false
- @button["#{i}_3"].visible=true #if @index==i
- @button["#{i}_3"].bitmap.blt(148,62,@typeBitmap,Rect.new(0,@moves[i].type*28,64,28))
- end
- end
- def show
- @selHand.visible=false
- @background.visible=true
- end
- def hide
- @selHand.visible=false
- @background.visible=false
- @megaButton.x-=10
- @showMega=false
- for i in 0...@nummoves
- @button["#{i}"].visible=false
- @button["#{i}_2"].visible=false
- @button["#{i}_3"].visible=false
- end
- end
- def megaButton
- @showMega=true
- end
- def megaButtonTrigger
- @megaButton.src_rect.y+=48
- @megaButton.src_rect.y=0 if @megaButton.src_rect.y >=96
- end
- def update
- for i in 0...@position.length
- @position[i]=30+(i*220)-(@index*220) if @index < 3 or @refreshpos
- end
- @refreshpos=false
- for i in 0...@nummoves
- @button["#{i}_2"].visible=false
- @button["#{i}_2"].visible=true if @index==i
- @button["#{i}_3"].visible=true
- @button["#{i}_3"].visible=false if @index==i
- end
- if @showMega
- @megaButton.x+=10 if @megaButton.x < -16
- end
- @selHand.x=@button["#{@index}"].x+103
- @selHand.y=@button["#{@index}"].y
- @selHand.zoom_y-=@animdata[0]
- @selHand.visible=true
- @animdata[0]=-0.1 if @selHand.zoom_y <=0.5
- if @selHand.zoom_y >=1
- @animdata[0]=0
- @animdata[1]+=1
- if @animdata[1] > 14
- @animdata[0]=0.1
- @animdata[1]=0
- end
- end
- if USEMOUSE
- @over = false
- for i in 0...@nummoves
- if $mouse.over?(@button["#{i}"])
- @over = true
- @index = i
- end
- end
- end
- end
- def overMega?
- return false if !USEMOUSE
- return $mouse.over?(@megaButton)
- end
- def mouseOver?
- return false if !USEMOUSE
- return @over
- end
- end
- class PokeBattle_Scene
- alias pbFightMenu_old pbFightMenu
- def pbFightMenu(index)
- if !USENEWUI
- return pbFightMenu_old(index)
- end
- clearMessageWindow
- cw = @fightWindow
- mega = false
- battler=@battle.battlers[index]
- cw.megaButton if @battle.pbCanMegaEvolve?(index)
- cw.battler=battler
- lastIndex=@lastmove[index]
- if battler.moves[lastIndex].id!=0
- cw.index=lastIndex
- else
- cw.index=0
- end
- cw.generateButtons
- pbSelectBattler(index)
- pbSEPlay("SE_Zoom4",50)
- #10.times do
- # cw.show
- # moveEntireScene(8,-6)
- # animateBattleSprites(true)
- # pbGraphicsUpdate
- #end
- moveUpperRight(cw)
- pbRefresh
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- animateBattleSprites(true)
- cw.update
- # Update selected command
- if Input.trigger?(Input::LEFT)
- if cw.index > 0
- pbSEPlay("SE_Select1")
- cw.index-=1
- else
- pbSEPlay("SE_Select1")
- cw.index=cw.nummoves-1
- cw.refreshpos=true
- end
- elsif Input.trigger?(Input::RIGHT)
- if cw.index < (cw.nummoves-1)
- pbSEPlay("SE_Select1")
- cw.index+=1
- else
- pbSEPlay("SE_Select1")
- cw.index=0
- end
- end
- if Input.trigger?(Input::UP) && (cw.index&2)==2
- pbSEPlay("SE_Select1")
- cw.index-=2
- elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
- pbSEPlay("SE_Select1")
- cw.index+=2
- end
- if Input.trigger?(Input::C) || (USEMOUSE && cw.mouseOver? && $mouse.leftClick?) # Confirm choice
- @ret=cw.index
- @battle.pbRegisterMegaEvolution(index) if mega
- pbSEPlay("SE_Select2")
- @lastmove[index]=@ret
- @idleTimer=-1
- break
- elsif Input.trigger?(Input::A) || (USEMOUSE && cw.overMega? && $mouse.leftClick?) # Use Mega Evolution
- if @battle.pbCanMegaEvolve?(index)
- if mega
- mega = false
- else
- mega = true
- end
- cw.megaButtonTrigger
- pbSEPlay("SE_Select3")
- end
- elsif Input.trigger?(Input::B) || (USEMOUSE && $mouse.leftClick?) # Cancel fight menu
- @lastmove[index]=cw.index
- pbPlayCancelSE()
- @ret=-1
- break
- end
- end
- if @ret > -1
- @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
- @orgPos=nil
- @vector.inc=0.2
- @vector.lock
- 10.times do
- cw.hide
- wait(1,true)
- end
- else
- moveLowerLeft(cw)
- end
- return @ret
- end
- alias pbChooseTarget_old pbChooseTarget
- def pbChooseTarget(index)
- if !USENEWUI
- return pbChooseTarget_old(index)
- end
- curwindow=pbFirstTarget(index)
- if curwindow==-1
- raise RuntimeError.new(_INTL("No targets somehow..."))
- end
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbUpdateSelected(curwindow)
- if Input.trigger?(Input::C)
- pbUpdateSelected(-1)
- @ret=curwindow
- break
- end
- if Input.trigger?(Input::B)
- pbUpdateSelected(-1)
- @ret=-1
- break
- end
- if Input.trigger?(Input::RIGHT) && !(curwindow==3 or curwindow==2)
- pbPlayCursorSE()
- newcurwindow=3 if curwindow==1
- newcurwindow=2 if curwindow==0
- curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
- elsif Input.trigger?(Input::DOWN) && !(curwindow==0 or curwindow==2)
- pbPlayCursorSE()
- newcurwindow=0 if curwindow==1
- newcurwindow=2 if curwindow==3
- curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
- elsif Input.trigger?(Input::LEFT) && !(curwindow==1 or curwindow==0)
- pbPlayCursorSE()
- newcurwindow=1 if curwindow==3
- newcurwindow=0 if curwindow==2
- curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
- elsif Input.trigger?(Input::UP) && !(curwindow==3 or curwindow==1)
- pbPlayCursorSE()
- newcurwindow=3 if curwindow==2
- newcurwindow=1 if curwindow==0
- curwindow=newcurwindow if !(newcurwindow==index) && !@battle.battlers[newcurwindow].isFainted?
- end
- #
- @sprites["shades"].opacity+=15 if @sprites["shades"].opacity < 150
- for i in 0...4
- if @sprites["pokemon#{i}"]
- if index==i or curwindow==i
- increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"].tone.red > 0
- else
- increaseTone(@sprites["pokemon#{i}"],10) if @sprites["pokemon#{i}"].tone.red < 80
- end
- end
- end
- #
- end
- 10.times do
- @sprites["shades"].opacity-=15 if @sprites["shades"].opacity > 0
- for i in 0...4
- increaseTone(@sprites["pokemon#{i}"],-10) if @sprites["pokemon#{i}"] && @sprites["pokemon#{i}"].tone.red > 0
- end
- animateBattleSprites(true)
- pbGraphicsUpdate
- end
- return @ret
- end
- end
- def increaseTone(sprite,amount)
- sprite.tone.red+=amount
- sprite.tone.green+=amount
- sprite.tone.blue+=amount
- end
- #===============================================================================
- # Command Choices
- # UI ovarhaul
- #===============================================================================
- class NewChoiceSel
- attr_accessor :index
- attr_reader :over
- def initialize(viewport,commands)
- @commands=commands
- @index=0
- @over=false
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=viewport.z+5
- @sprites={}
- @sprites["back"]=Sprite.new(@viewport)
- @sprites["back"].bitmap=pbBitmap("Graphics/Pictures/shadeRest")
- @sprites["back"].opacity=0
- bitmap=pbBitmap("Graphics/Pictures/draw_choice")
- baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
- shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
- @sprites["sel"]=Sprite.new(@viewport)
- @sprites["sel"].bitmap=bitmap
- @sprites["sel"].src_rect.set(0,84,500,84)
- @sprites["sel"].y=480
- @sprites["sel"].x=6
- @sprites["sel"].z=+1
- for i in 0...@commands.length
- @sprites["choice#{i}"]=Sprite.new(@viewport)
- @sprites["choice#{i}"].x=6
- @sprites["choice#{i}"].y=480+96*i
- @sprites["choice#{i}"].bitmap=Bitmap.new(500,84)
- choice=@sprites["choice#{i}"].bitmap
- pbSetSystemFont(choice)
- choice.blt(0,0,bitmap,Rect.new(0,0,500,84))
- pbDrawOutlineText(choice,0,0,500,84,@commands[i],baseColor,shadowColor,1)
- end
- end
- def dispose(scene)
- 5.times do
- @sprites["back"].opacity-=51
- @sprites["sel"].opacity-=51
- for i in 0...@commands.length
- @sprites["choice#{i}"].opacity-=51
- end
- @sprites["choice#{@index}"].y+=2
- scene.animateBattleSprites(true)
- scene.pbGraphicsUpdate
- end
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose
- end
- def update
- @sprites["sel"].x=@sprites["choice#{@index}"].x
- @sprites["sel"].y=@sprites["choice#{@index}"].y
- @sprites["back"].opacity+=25.5 if @sprites["back"].opacity < 255
- if Input.trigger?(Input::UP)
- pbSEPlay("SE_Select1")
- @index-=1
- @index=@commands.length-1 if @index < 0
- @sprites["sel"].y=@sprites["choice#{@index}"].y
- end
- if Input.trigger?(Input::DOWN)
- pbSEPlay("SE_Select1")
- @index+=1
- @index=0 if @index >=@commands.length
- @sprites["sel"].y=@sprites["choice#{@index}"].y
- end
- @over=false
- if USEMOUSE
- for i in 0...2
- if $mouse.over?(@sprites["choice#{i}"])
- @index = i
- @over=true
- end
- end
- end
- for i in 0...@commands.length
- # @sprites["choice#{i}"].src_rect.y-=1 if @sprites["choice#{i}"].src_rect.y > 0
- # @sprites["choice#{i}"].y-=(@sprites["choice#{i}"].y-220)*0.4
- end
- end
- end
- #===============================================================================
- # Battle Bag interface
- # UI ovarhaul
- #===============================================================================
- class NewBattleBag
- attr_reader :index
- attr_reader :ret
- def pbDisplayMessage(msg)
- @scene.changeMessageViewport(@viewport)
- @scene.pbDisplayMessage(msg)
- @scene.clearMessageWindow
- @scene.changeMessageViewport
- end
- def initialize(scene,viewport)
- @scene=scene
- $lastUsed=0 if $lastUsed.nil?
- @background=Viewport.new(0,0,Graphics.width,Graphics.height)
- @background.z=viewport.z+5
- @viewport=Viewport.new(0,400,Graphics.width,Graphics.height)
- @viewport.z=viewport.z+5
- @lastUsed=$lastUsed
- @index=0
- @item=0
- @page=-1
- @selPocket=0
- @ret=nil
- @over=false
- @baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
- @shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
- @sprites={}
- @items={}
- @bitmaps=[pbBitmap("Graphics/Pictures/BattleBag/menus"),
- pbBitmap("Graphics/Pictures/BattleBag/lastitem"),
- pbBitmap("Graphics/Pictures/BattleBag/menuitem"),
- #pbBitmap("Graphics/Pictures/BattleBag/lastitem"),
- pbBitmap("Graphics/Pictures/BattleBag/back")]
- @sprites["back"]=Sprite.new(@background)
- @sprites["back"].bitmap=pbBitmap("Graphics/Pictures/shadeFull")
- @sprites["back"].opacity=0
- @sprites["sel"]=Sprite.new(@viewport)
- @sprites["sel"].x=-216
- @sprites["sel"].y=34
- @sprites["name"]=Sprite.new(@viewport)
- @sprites["name"].bitmap=Bitmap.new(412,78)
- pbSetSystemFont(@sprites["name"].bitmap)
- @sprites["name"].x=-380
- @sprites["name"].y=328
- @sprites["name"].visible=false
- for i in 0...4
- @sprites["pocket#{i}"]=Sprite.new(@viewport)
- @sprites["pocket#{i}"].bitmap=@bitmaps[0]
- @sprites["pocket#{i}"].src_rect.set(0,140*i,252,140)
- @sprites["pocket#{i}"].x=2+(i%2)*256#+((i%2==0) ? -260 : 260)
- @sprites["pocket#{i}"].y=18+(i/2)*144#+(i%2)*42
- @sprites["pocket#{i}"].visible=false
- end
- @sprites["pocket4"]=Sprite.new(@viewport)
- @sprites["pocket4"].bitmap=Bitmap.new(412,78)
- pbSetSystemFont(@sprites["pocket4"].bitmap)
- @sprites["pocket4"].x=2
- @sprites["pocket4"].y=306
- @sprites["pocket4"].visible=false
- self.refresh
- @sprites["pocket5"]=Sprite.new(@viewport)
- @sprites["pocket5"].bitmap=@bitmaps[3]
- @sprites["pocket5"].src_rect.set(0,0,120,52)
- @sprites["pocket5"].x=434
- @sprites["pocket5"].y=306
- @sprites["pocket5"].z=5
- @sprites["pocket5"].visible=false
- @sprites["confirm"]=Sprite.new(@viewport)
- @sprites["confirm"].bitmap=Bitmap.new(466,156)
- pbSetSmallFont(@sprites["confirm"].bitmap)
- @sprites["confirm"].x=26-520
- @sprites["confirm"].y=80
- @sprites["cancel"]=Sprite.new(@viewport)
- @sprites["cancel"].bitmap=pbBitmap("Graphics/Pictures/BattleBag/back")
- # @sprites["cancel"].src_rect.set(466,0,466,72)
- @sprites["cancel"].x=434
- @sprites["cancel"].y=306
- @sprites["cancel"].visible=false
- end
- def drawPocket(pocket)
- @pocket=[]
- @pgtrigger=false
- tp=$PokemonBag.pockets[pocket]
- tp=tp+$PokemonBag.pockets[1] if pocket==7
- tp=tp+$PokemonBag.pockets[8] if pocket==7
- for i in 0...tp.length
- item=tp[i]
- @pocket.push([item[0],item[1]]) if ItemHandlers.hasUseInBattle(item[0]) || ItemHandlers.hasBattleUseOnPokemon(item[0]) || ItemHandlers.hasBattleUseOnBattler(item[0])
- end
- if @pocket.length < 1
- pbDisplayMessage("You have no usable items in this pocket.")
- return
- end
- @xpos=[]
- @pages=@pocket.length/6
- @pages+=1 if @pocket.length%6 > 0
- @page=0
- @item=0
- @back=false
- @selPocket=pocket
- pbDisposeSpriteHash(@items)
- @pname=pbPocketNames[pocket]
- x=0
- y=0
- for j in 0...@pocket.length
- i=j
- @items["#{j}"]=Sprite.new(@viewport)
- @items["#{j}"].bitmap=Bitmap.new(252,92)
- pbSetSystemFont(@items["#{j}"].bitmap)
- @items["#{j}"].bitmap.blt(0,0,@bitmaps[2],Rect.new(0,0,252,92))
- @items["#{j}"].bitmap.blt(156,32,pbBitmap(sprintf("Graphics/Icons/item%03d",@pocket[i][0])),Rect.new(0,0,48,48))
- pbDrawOutlineText(@items["#{j}"].bitmap,8,8,200,38,"#{PBItems.getName(@pocket[i][0])}",@baseColor,@shadowColor,1)
- pbDrawOutlineText(@items["#{j}"].bitmap,8,46,200,38,"x#{@pocket[i][1]}",@baseColor,@shadowColor,1)
- @items["#{j}"].x=2+x*256+(i/6)*512+512
- @xpos.push(@items["#{j}"].x-512)
- @items["#{j}"].y=28+y*90
- @items["#{j}"].opacity=255
- x+=1
- y+=1 if x > 1
- x=0 if x > 1
- y=0 if y > 2
- end
- end
- def name
- bitmap=@sprites["name"].bitmap
- bitmap.clear
- bitmap.blt(0,0,pbBitmap("Graphics/Pictures/battleLastItem"),Rect.new(0,0,412,78))
- pbDrawOutlineText(bitmap,0,0,320,36,@pname,@baseColor,@shadowColor,1)
- pbDrawOutlineText(bitmap,300,0,80,36,"#{@page+1}/#{@pages}",@baseColor,@shadowColor,1)
- @sprites["name"].x+=38 if @sprites["name"].x < 0
- @sprites["name"].visible=true
- end
- def updatePocket
- @page=@item/6
- # self.name
- @sprites["name"].visible=false
- for i in 0...@pocket.length
- @items["#{i}"].x-=(@items["#{i}"].x-(@xpos[i]-@page*512))*0.2
- @items["#{i}"].src_rect.y-=1 if @items["#{i}"].src_rect.y > 0
- end
- if @back
- @sprites["sel"].bitmap=@bitmaps[2]
- @sprites["sel"].src_rect.set(120*2,0,120,52)
- @sprites["sel"].x=@sprites["pocket5"].x
- @sprites["sel"].y=@sprites["pocket5"].y
- else
- @sprites["sel"].bitmap=@bitmaps[0]
- @sprites["sel"].src_rect.set(216*4,0,216,92)
- @sprites["sel"].x=@items["#{@item}"].x
- @sprites["sel"].y=@items["#{@item}"].y
- end
- # @sprites["pocket5"].src_rect.y-=1 if @sprites["pocket5"].src_rect.y > 0
- if Input.trigger?(Input::LEFT) && !@back
- pbSEPlay("SE_Select1")
- if ![0,2,4].include?(@item)
- if @item%2==0
- @item-=5
- else
- @item-=1
- end
- else
- @item-=1 if @item < 0
- end
- @item=0 if @item < 0
- @items["#{@item}"].src_rect.y+=6
- end
- if Input.trigger?(Input::RIGHT) && !@back
- pbSEPlay("SE_Select1")
- if @page < (@pocket.length)/6
- if @item%2==1
- @item+=5
- else
- @item+=1
- end
- else
- @item+=1 if @item < @pocket.length-1
- end
- @item=@pocket.length-1 if @item > @pocket.length-1
- @items["#{@item}"].src_rect.y+=6
- end
- if Input.trigger?(Input::UP)
- pbSEPlay("SE_Select1")
- if @back
- @item+=4 if (@item%6) < 2
- @back=false
- else
- @item-=2
- if (@item%6) > 3
- @item+=6
- @back=true
- end
- end
- @item=0 if @item < 0
- @item=@pocket.length-1 if @item > @pocket.length-1
- @items["#{@item}"].src_rect.y+=6 if !@back
- @sprites["pocket5"].src_rect.y+=6 if @back
- end
- if Input.trigger?(Input::DOWN)
- pbSEPlay("SE_Select1")
- if @back
- @item-=4 if (@item%6) > 3
- @back=false
- else
- @item+=2
- if (@item%6) < 2
- @item-=6
- @back=true
- end
- @back=true if @item > @pocket.length-1
- end
- @item=@pocket.length-1 if @item > @pocket.length-1
- @item=0 if @item < 0
- @items["#{@item}"].src_rect.y+=6 if !@back
- @sprites["pocket5"].src_rect.y+=6 if @back
- end
- @over=false
- if USEMOUSE
- for i in 0...@pocket.length
- if $mouse.over?(@items["#{i}"])
- @item = i
- @back=false
- @over=true
- end
- end
- if $mouse.inArea?(Graphics.width-32,0,32,Graphics.height) && @page < (@pocket.length)/6
- if !@pgtrigger
- @item+=5 if !(@item+5 > @pocket.length-1)
- @item=@pocket.length-1 if @item > @pocket.length-1
- end
- @pgtrigger=true
- end
- if $mouse.inArea?(0,0,32,Graphics.height) && @page > 0
- if !@pgtrigger
- @item-=5 if !(@item-5 < 0)
- @item=0 if @item < 0
- end
- @pgtrigger=true
- end
- @pgtrigger=false if !$mouse.inArea?(Graphics.width-32,0,32,Graphics.height) && !$mouse.inArea?(0,0,32,Graphics.height)
- if $mouse.over?(@sprites["pocket5"])
- @back=true
- @over=true
- end
- end
- if (@back && (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?))) || Input.trigger?(Input::B)
- pbSEPlay("SE_Select3")
- @selPocket=0
- @page=-1
- @back=false
- @doubleback=true
- end
- end
- def closeCurrent
- @selPocket=0
- @page=-1
- @back=false
- @ret=nil
- self.refresh
- end
- def show
- @ret=nil
- self.refresh
- for i in 0...6
- @sprites["pocket#{i}"].opacity=255
- end
- # @sprites["pocket4"].y=316+80
- # @sprites["pocket5"].y=320+80
- @sprites["pocket4"].visible=true
- @sprites["pocket5"].visible=true
- pbSEPlay("SE_Zoom4",60)
- 10.times do
- for i in 0...4
- @sprites["pocket#{i}"].visible=true
- end
- for i in 4...6
- # @sprites["pocket#{i}"].y-=8
- end
- @sprites["back"].opacity+=25.5
- @scene.animateBattleSprites(true)
- @scene.pbGraphicsUpdate
- end
- end
- def hide
- @sprites["sel"].x=Graphics.width
- @sprites["pocket4"].visible=false
- @sprites["pocket5"].visible=false
- 10.times do
- for i in 0...4
- @sprites["pocket#{i}"].visible=false
- end
- for i in 4...6
- # @sprites["pocket#{i}"].y+=8
- end
- if @pocket
- for i in 0...@pocket.length
- @items["#{i}"].opacity-=25.5
- end
- end
- #@sprites["name"].x-=38
- @sprites["back"].opacity-=25.5
- @scene.animateBattleSprites(true)
- @scene.pbGraphicsUpdate
- end
- end
- def useItem?
- Input.update
- bitmap=@sprites["confirm"].bitmap
- bitmap.clear
- bitmap.blt(0,0,pbBitmap("Graphics/Pictures/BattleBag/iteminfo"),Rect.new(0,0,466,156))
- bitmap.blt(20,30,pbBitmap(sprintf("Graphics/Icons/item%03d",@ret)),Rect.new(0,0,48,48))
- drawTextEx(bitmap,80,12,364,3,pbGetMessage(MessageTypes::ItemDescriptions,@ret),@shadowColor,Color.new(200,200,200))
- @sprites["sel"].bitmap=pbBitmap("Graphics/Pictures/battleItemConfirm")
- @sprites["sel"].x=Graphics.width
- @sprites["sel"].src_rect.width=466
- 10.times do
- @sprites["confirm"].x+=52
- @sprites["cancel"].x+=52
- if @pocket
- for i in 0...@pocket.length
- @items["#{i}"].opacity-=25.5
- end
- end
- for i in 0...4
- @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
- end
- # @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
- # @sprites["pocket5"].y+=8 if @sprites["pocket5"].y < 400
- #@sprites["name"].x-=38
- @scene.animateBattleSprites
- @scene.pbGraphicsUpdate
- end
- # @sprites["name"].x=-380
- index=0
- choice=(index==0) ? "confirm" : "cancel"
- loop do
- @sprites["sel"].x=@sprites["#{choice}"].x
- @sprites["sel"].y=@sprites["#{choice}"].y
- @sprites["sel"].src_rect.x=(466*(index+2))
- @sprites["#{choice}"].src_rect.y-=1 if @sprites["#{choice}"].src_rect.y > 0
- if Input.trigger?(Input::UP)
- pbSEPlay("SE_Select1")
- index-=1
- index=1 if index < 0
- choice=(index==0) ? "confirm" : "cancel"
- @sprites["#{choice}"].src_rect.y+=6
- end
- if Input.trigger?(Input::DOWN)
- pbSEPlay("SE_Select1")
- index+=1
- index=0 if index > 1
- choice=(index==0) ? "confirm" : "cancel"
- @sprites["#{choice}"].src_rect.y+=6
- end
- @over=false
- for i in 0...2
- if USEMOUSE
- c=(i==0) ? "confirm" : "cancel"
- if $mouse.over?(@sprites["#{c}"])
- choice=(i==0) ? "confirm" : "cancel"
- index = i
- @over=true
- end
- end
- end
- if Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)
- pbSEPlay("SE_Select2")
- break
- end
- Input.update
- @scene.animateBattleSprites
- @scene.pbGraphicsUpdate
- end
- @sprites["sel"].x=Graphics.width
- self.refresh
- 10.times do
- # @sprites["confirm"].x-=52
- # @sprites["cancel"].x-=52
- # @sprites["pocket5"].y-=8 if index > 0
- @scene.animateBattleSprites
- @scene.pbGraphicsUpdate
- end
- if index > 0
- @ret=nil
- return false
- else
- @index=0 if @index==4 && @lastUsed==0
- return true
- end
- end
- def finish
- if (Input.trigger?(Input::B) || ((Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && @index==5)) && @selPocket==0 && !@doubleback
- pbSEPlay("SE_Select3")
- return true
- end
- @doubleback=false
- return false
- end
- def refresh
- bitmap=@sprites["pocket4"].bitmap
- bitmap.clear
- i=(@lastUsed > 0 ? 1 : 0)
- text=["","#{PBItems.getName(@lastUsed)}"]
- bitmap.blt(0,0,@bitmaps[1],Rect.new(0,0,412,78))
- bitmap.blt(28,6,pbBitmap(sprintf("Graphics/Icons/item%03d",@lastUsed)),Rect.new(0,0,48,48)) if @lastUsed>0
- pbDrawOutlineText(bitmap,0,0,356,60,text[i],@baseColor,@shadowColor,1)
- end
- def update
- if @selPocket==0
- updateMain
- for i in 0...4
- @sprites["pocket#{i}"].opacity+=51 if @sprites["pocket#{i}"].opacity < 255
- end
- # @sprites["pocket4"].y-=8 if @sprites["pocket4"].y > 316
- if @pocket
- for i in 0...@pocket.length
- @items["#{i}"].opacity-=51 if @items["#{i}"] && @items["#{i}"].opacity > 0
- end
- end
- @sprites["name"].x-=38 if @sprites["name"].x > -380
- else
- if (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && !@back
- pbSEPlay("SE_Select2")
- @selPocket=0
- @page=-1
- @lastUsed=0
- @lastUsed=@pocket[@item][0] if @pocket[@item][1] > 1
- $lastUsed=@lastUsed
- @ret=@pocket[@item][0]
- end
- updatePocket
- for i in 0...4
- @sprites["pocket#{i}"].opacity-=51 if @sprites["pocket#{i}"].opacity > 0
- end
- # @sprites["pocket4"].y+=8 if @sprites["pocket4"].y < 316+80
- for i in 0...@pocket.length
- @items["#{i}"].opacity+=51 if @items["#{i}"] && @items["#{i}"].opacity < 255
- end
- end
- end
- def updateMain
- if @index < 4
- @sprites["sel"].bitmap=@bitmaps[0]
- @sprites["sel"].src_rect.set(216*4,0,216,92)
- elsif @index==4
- @sprites["sel"].bitmap=@bitmaps[1]
- @sprites["sel"].src_rect.set(356*2,0,356,60)
- else
- @sprites["sel"].bitmap=@bitmaps[2]
- @sprites["sel"].src_rect.set(120*2,0,120,52)
- end
- @sprites["sel"].x=@sprites["pocket#{@index}"].x
- @sprites["sel"].y=@sprites["pocket#{@index}"].y
- if Input.trigger?(Input::LEFT)
- pbSEPlay("SE_Select1")
- @index-=1
- @index+=2 if @index%2==1
- @index=3 if @index==4 && !(@lastUsed > 0)
- @sprites["pocket#{@index}"].src_rect.y+=6
- end
- if Input.trigger?(Input::RIGHT)
- pbSEPlay("SE_Select1")
- @index+=1
- @index-=2 if @index%2==0
- @index=2 if @index==4 && !(@lastUsed > 0)
- @sprites["pocket#{@index}"].src_rect.y+=6
- end
- if Input.trigger?(Input::UP)
- pbSEPlay("SE_Select1")
- @index-=2
- @index+=6 if @index < 0
- @index=5 if @index==4 && !(@lastUsed > 0)
- @sprites["pocket#{@index}"].src_rect.y+=6
- end
- if Input.trigger?(Input::DOWN)
- pbSEPlay("SE_Select1")
- @index+=2
- @index-=6 if @index > 5
- @index=5 if @index==4 && !(@lastUsed > 0)
- @sprites["pocket#{@index}"].src_rect.y+=6
- end
- @over = false
- for i in 0...6
- if USEMOUSE
- if $mouse.over?(@sprites["pocket#{i}"])
- @index = i if i!=4 || (i==4 && @lastUsed > 0)
- @over = true
- end
- end
- # @sprites["pocket#{i}"].src_rect.y-=1 if @sprites["pocket#{i}"].src_rect.y > 0
- end
- if (Input.trigger?(Input::C) || (USEMOUSE && @over && $mouse.leftClick?)) && !@doubleback && @index < 5
- pbSEPlay("SE_Select2")
- if @index < 4
- cmd=[2,3,5,7]
- self.drawPocket(cmd[@index])
- else
- @selPocket=0
- @page=-1
- @ret=@lastUsed
- @lastUsed=0 if !($PokemonBag.pbQuantity(@lastUsed) > 1)
- end
- end
- end
- end
- class PokeBattle_Scene
- alias pbItemMenu_old pbItemMenu
- def pbItemMenu(index)
- @idleTimer=-1
- @vector.set(VECTOR[0],VECTOR[1],VECTOR[2],VECTOR[3],VECTOR[4],VECTOR[5])
- @vector.inc=0.2
- Input.update
- return pbItemMenu_old(index) if !USENEWUI
- ret=0
- retindex=-1
- pkmnid=-1
- @bagWindow.show
- loop do
- break if @bagWindow.finish
- Input.update
- @bagWindow.update
- if !@bagWindow.ret.nil? && @bagWindow.useItem?
- item=@bagWindow.ret
- usetype=$ItemData[item][ITEMBATTLEUSE]
- if usetype==1 || usetype==3
- modparty=[]
- for i in 0...6
- modparty.push(@battle.party1[@battle.partyorder[i]])
- end
- pkmnlist=PokemonScreen_Scene.new
- pkmnlist.addPriority=true
- pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
- pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
- activecmd=pkmnscreen.pbChoosePokemon
- pkmnid=@battle.partyorder[activecmd]
- if activecmd>=0 && pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
- pkmnlist.pbEndScene
- ret=item
- retindex=pkmnid
- break
- end
- pkmnlist.pbEndScene
- @bagWindow.closeCurrent
- #itemscene.pbStartScene($PokemonBag)
- elsif usetype==2 || usetype==4
- if ItemHandlers.hasBattleUseOnBattler(item)
- ret=item
- retindex=index
- break
- end
- end
- end
- animateBattleSprites
- pbGraphicsUpdate
- end
- @bagWindow.hide
- pbConsumeItemInBattle($PokemonBag,ret) if ret > 0
- return [ret,retindex]
- end
- end
- =begin
- class PokemonScreen_Scene
- attr_accessor :addPriority
- def pbStartScene(party,starthelptext,annotations=nil,multiselect=false)
- @sprites={}
- @party=party
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @viewport.z+=6 if @addPriority
- @multiselect=multiselect
- addBackgroundPlane(@sprites,"partybg","partybg",@viewport)
- @sprites["messagebox"]=Window_AdvancedTextPokemon.new("")
- @sprites["helpwindow"]=Window_UnformattedTextPokemon.new(starthelptext)
- @sprites["messagebox"].viewport=@viewport
- @sprites["messagebox"].visible=false
- @sprites["messagebox"].letterbyletter=true
- @sprites["helpwindow"].viewport=@viewport
- @sprites["helpwindow"].visible=true
- pbBottomLeftLines(@sprites["messagebox"],2)
- pbBottomLeftLines(@sprites["helpwindow"],1)
- pbSetHelpText(starthelptext)
- # Add party Pokémon sprites
- for i in 0...6
- if @party[i]
- @sprites["pokemon#{i}"]=PokeSelectionSprite.new(
- @party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"]=PokeSelectionPlaceholderSprite.new(
- @party[i],i,@viewport)
- end
- if annotations
- @sprites["pokemon#{i}"].text=annotations[i]
- end
- end
- if @multiselect
- @sprites["pokemon6"]=PokeSelectionConfirmSprite.new(@viewport)
- @sprites["pokemon7"]=PokeSelectionCancelSprite2.new(@viewport)
- else
- @sprites["pokemon6"]=PokeSelectionCancelSprite.new(@viewport)
- end
- # Select first Pokémon
- @activecmd=0
- @sprites["pokemon0"].selected=true
- pbFadeInAndShow(@sprites) { update }
- end
- end
- =end
- def clearFakeText
- @sprites["faketext"].bitmap.clear
- end
- def setFakeText(msg)
- @sprites["faketext"].bitmap.clear
- text=[["#{msg}",8,10,false,MESSAGEBASECOLOR,MESSAGESHADOWCOLOR]]
- pbDrawTextPositions(@sprites["faketext"].bitmap,text)
- end
- def increaseTone(sprite,amount)
- sprite.tone.red+=amount
- sprite.tone.green+=amount
- sprite.tone.blue+=amount
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement