Changed: Sprite_Picture
@@ -40,0 +40,1 @@
+ self.bitmap.dispose if self.bitmap
Changed: Particle Engine
@@ -56,1 +56,0 @@
- #--------------------------------------------------------------------------
@@ -91,1 +90,2 @@
- @effect = []
+ @effect.clear
+ @map=nil
@@ -134,3 +134,3 @@
- @particles = []
- @particlex = []
- @particley = []
+ @particles = []
+ @particlex = []
+ @particley = []
Changed: PokemonMap
@@ -487,0 +487,1 @@
+ @maps=[]
@@ -512,1 +513,1 @@
- @maps=[]
+ @maps.clear
Changed: PokeBattle_Pokemon
@@ -7,19 +7,0 @@
-
-$FontConv=[
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 255,171,0,0,183,91,0,180,92,93,185,46,184,174,173,186,
- 161,162,163,164,165,166,167,168,169,170,240,54,0,53,0,172,
- 0,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,
- 202,203,204,205,206,207,208,209,210,211,212,0,0,0,0,0,
- 179,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,
- 228,229,230,231,232,233,234,235,236,237,238,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,82,0,0,0,0,0,0,0,0,43,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,42,0,0,0,0,81,
- 1,2,0,0,241,0,0,4,5,6,7,8,9,90,11,12,
- 0,20,13,14,15,0,242,0,0,17,18,19,243,0,0,21,
- 22,23,104,0,244,0,0,25,26,27,28,29,30,111,32,33,
- 0,41,34,35,36,0,245,0,0,38,39,40,246,0,0,0,0
-]
@@ -145,1 +126,1 @@
- ret+=(i>=namechars.length) ? 0xFF.chr : $FontConv[nextUtf8(namechars[i],0)].chr
+ ret+=(i>=namechars.length) ? 0xFF.chr : toRSChar(namechars[i])
@@ -149,1 +130,1 @@
- ret+=(i>=otchars.length) ? 0xFF.chr : $FontConv[nextUtf8(otchars[i],0)].chr
+ ret+=(i>=otchars.length) ? 0xFF.chr : toRSChar(otchars[i])
Added: DrawText
Changed: PokemonMenu
@@ -51,1 +51,1 @@
- @sprites["infowindow"]=Window_ColoredTextPokemon.newWithSize("",0,0,32,32,@viewport)
+ @sprites["infowindow"]=Window_FormattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
@@ -53,1 +53,1 @@
- @sprites["helpwindow"]=Window_ColoredTextPokemon.newWithSize("",0,0,32,32,@viewport)
+ @sprites["helpwindow"]=Window_FormattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
@@ -113,1 +113,1 @@
- @scene.pbShowInfo(_INTL("STEPS: {1}/600\nBALLS: {2}",pbSafariState.steps,pbSafariState.ballcount))
+ @scene.pbShowInfo(_INTL("STEPS: {1}/600
BALLS: {2}",pbSafariState.steps,pbSafariState.ballcount))
@@ -117,1 +117,1 @@
- @scene.pbShowInfo(_INTL("CAUGHT: {1}\nLEVEL: {2}\nBALLS: {3}",
+ @scene.pbShowInfo(_INTL("CAUGHT: {1}
LEVEL: {2}
BALLS: {3}",
@@ -122,1 +122,1 @@
- @scene.pbShowInfo(_INTL("CAUGHT: None\nBALLS: {1}",pbBugContestState.ballcount))
+ @scene.pbShowInfo(_INTL("CAUGHT: None
BALLS: {1}",pbBugContestState.ballcount))
Changed: PBIntl
@@ -300,3 +300,3 @@
- key.gsub!(/\r/,"")
- key.gsub!(/\n/,"")
- key.gsub!(/\t/,"")
+ key.gsub!(/\r/,"<>")
+ key.gsub!(/\n/,"<>")
+ key.gsub!(/\t/,"<>")
@@ -311,3 +311,3 @@
- ret.gsub!(/\r/,"")
- ret.gsub!(/\n/,"")
- ret.gsub!(/\t/,"")
+ ret.gsub!(/\r/,"<>")
+ ret.gsub!(/\n/,"<>")
+ ret.gsub!(/\t/,"<>")
@@ -319,1 +319,1 @@
- if value[/<[rnt]>/]
+ if value[/<<[rnt]>>/]
@@ -321,3 +321,3 @@
- ret.gsub!(//,"\r")
- ret.gsub!(//,"\n")
- ret.gsub!(//,"\t")
+ ret.gsub!(/<>/,"\r")
+ ret.gsub!(/<>/,"\n")
+ ret.gsub!(/<>/,"\t")
Changed: AnimationSprite
@@ -41,1 +41,2 @@
- pbSetDayNightTone(object.tone)
+ tone=$game_temp.dayNightTone
+ object.tone.set(tone.red,tone.green,tone.blue,tone.gray)
@@ -72,11 +73,0 @@
- def tintScreen
- if !$scene.is_a?(Scene_Map)
- return
- else
- if pbGetMetadata($game_map.map_id,1)
- pbSetDayNightTone(@tilemap.tone)
- else
- @tilemap.tone.set(0,0,0,0)
- end
- end
- end
@@ -88,0 +78,1 @@
+ @usersprites.clear
@@ -98,0 +89,1 @@
+ @viewport3.tone.set(0,0,0,0)
Changed: Pokegear
@@ -41,2 +41,2 @@
- @button_up = Sprite.new
- @button_up.bitmap = RPG::Cache.picture("buttonunp")
+ @button_up = Sprite.new
+ @button_up.bitmap = RPG::Cache.picture("buttonunp")
@@ -44,1 +44,1 @@
- @button_up.y = 80
+ @button_up.y = 80
@@ -46,1 +46,1 @@
- @button_down.bitmap = RPG::Cache.picture("buttonunp")
+ @button_down.bitmap = RPG::Cache.picture("buttonunp")
@@ -48,2 +48,2 @@
- @button_down.y = 165
- @arr_icon=AnimatedSprite.new("Graphics/Pictures/selarr.png",8,50,50,1)
+ @button_down.y = 165
+ @arr_icon=AnimatedSprite.new("Graphics/Pictures/selarr.png",8,50,50,1)
@@ -97,0 +97,1 @@
+ @target_window.dispose
Changed: Resolution*
@@ -23,4 +23,0 @@
-#--------------------------------------------------------------------------
-# Scroll the map down
-# distance : Distance to scroll in real units (4 = 1 pixel).
-#--------------------------------------------------------------------------
@@ -30,4 +26,0 @@
-#--------------------------------------------------------------------------
-# Scroll the map left
-# distance : Distance to scroll in real units (4 = 1 pixel).
-#--------------------------------------------------------------------------
@@ -37,4 +29,0 @@
-#--------------------------------------------------------------------------
-# Scroll the map right
-# distance : Distance to scroll in real units (4 = 1 pixel).
-#--------------------------------------------------------------------------
@@ -44,4 +32,0 @@
-#--------------------------------------------------------------------------
-# Scroll the map up
-# distance : Distance to scroll in real units (4 = 1 pixel).
-#--------------------------------------------------------------------------
Changed: PerspectiveTilemap
@@ -92,0 +92,11 @@
+ @heightcache={}
+ def self.bmHeight(bm)
+ h=@heightcache[bm]
+ if !h
+ bmap=RPG::Cache.character(bm,0)
+ h=bmap.height
+ @heightcache[bm]=h
+ bmap.dispose
+ end
+ return h
+ end
@@ -98,3 +109,1 @@
- bm=RPG::Cache.character(ch.character_name,
- ch.character_hue)
- height=bm.height/4
+ height=bmHeight(ch.character_name)/4
@@ -305,1 +314,0 @@
- @sprites[i][j]=nil
@@ -312,1 +320,1 @@
- # Dispose all sprites
+ return if @disposed
@@ -317,0 +325,3 @@
+ @helper=nil
+ @sprites=nil
+ @bitmaps=nil
Changed: Sprite_Character
@@ -36,0 +36,1 @@
+ @charbitmap.dispose if @charbitmap
@@ -46,0 +47,1 @@
+ @charbitmap.dispose if @charbitmap
@@ -67,1 +69,2 @@
- if $PokemonSystem.tilemap==0 ||
+ if self.visible
+ if $PokemonSystem.tilemap==0 ||
@@ -70,1 +73,1 @@
- else
+ else
@@ -72,0 +75,1 @@
+ end
Changed: PokemonField
@@ -129,4 +129,1 @@
- if rand(15)==0 && $PokemonSystem.tilemap!=0
- pbZoomAndFadeOut
- viewport.color=Color.new(0,0,0,255)
- elsif rand(15)==0
+ if rand(15)==0
@@ -147,1 +144,1 @@
- "021-Normal01","Battle","Mosaic","ShrinkingPieces",
+ "021-Normal01","Battle","Mosaic","ShrinkingPieces","zoomin",
@@ -278,0 +275,1 @@
+ battle.cantescape=!canescape
@@ -318,1 +316,1 @@
- trainerobject=PokeBattle_Trainer.new(trainername,trainerid)
+ trainerobject=PokeBattle_Trainer.new(_INTL(trainername),trainerid)
@@ -332,1 +330,1 @@
-def pbDoubleWildBattle(species1,level1,species2,level2)
+def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true)
@@ -344,5 +342,0 @@
- othertrainer=PokeBattle_Trainer.new(
- $PokemonMap.partner[1],
- $PokemonMap.partner[0])
- othertrainer.id=$PokemonMap.partner[2]
- othertrainer.party=$PokemonMap.partner[3]
@@ -353,9 +346,21 @@
- combinedParty=[]
- for i in 0...$Trainer.party.length
- combinedParty[i]=$Trainer.party[i]
- end
- for i in 0...othertrainer.party.length
- combinedParty[6+i]=othertrainer.party[i]
- end
- battle=PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],
- [$Trainer,othertrainer],nil)
+ if $PokemonMap.partner
+ othertrainer=PokeBattle_Trainer.new(
+ $PokemonMap.partner[1],
+ $PokemonMap.partner[0])
+ othertrainer.id=$PokemonMap.partner[2]
+ othertrainer.party=$PokemonMap.partner[3]
+ combinedParty=[]
+ for i in othertrainer.party; i.heal; end
+ for i in 0...$Trainer.party.length
+ combinedParty[i]=$Trainer.party[i]
+ end
+ for i in 0...othertrainer.party.length
+ combinedParty[6+i]=othertrainer.party[i]
+ end
+ battle=PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],
+ [$Trainer,othertrainer],nil)
+ battle.fullparty1=true
+ else
+ battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],
+ $Trainer,nil)
+ end
@@ -363,1 +368,0 @@
- battle.fullparty1=true
@@ -365,0 +369,1 @@
+ battle.cantescape=!canescape
@@ -375,2 +380,4 @@
- for i in $Trainer.party
- i.heal
+ if $PokemonMap.partner
+ for i in $Trainer.party
+ i.heal
+ end
@@ -402,0 +409,1 @@
+ $game_variables[variable]=decision if variable
Changed: PokemonSave
@@ -12,6 +12,6 @@
- loctext=_INTL("\\[06644bd2]{1}\r\n",mapname)
- loctext+=_INTL("\\[318c675a]PLAYER: \\[65467b14]{1}\r\n",$Trainer.name)
- loctext+=_INTL("\\[318c675a]BADGES: \\[65467b14]{1}\r\n",$Trainer.numbadges)
- loctext+=_INTL("\\[318c675a]POKéDEX: \\[65467b14]{1}\r\n",$Trainer.pokedexOwned)
- loctext+=_INTL("\\[318c675a]TIME: \\[65467b14]{1}",_ISPRINTF("{1:02d}:{2:02d}",hour,min))
- @sprites["locwindow"]=Window_ColoredTextPokemon.new(loctext)
+ loctext=_INTL("{1}
",mapname)
+ loctext+=_INTL("PLAYER: {1}
",$Trainer.name)
+ loctext+=_INTL("BADGES: {1}
",$Trainer.numbadges)
+ loctext+=_INTL("POKéDEX: {1}
",$Trainer.pokedexOwned)
+ loctext+=_INTL("TIME: {1}",_ISPRINTF("{1:02d}:{2:02d}",hour,min))
+ @sprites["locwindow"]=Window_FormattedTextPokemon.new(loctext)
@@ -19,1 +19,0 @@
- @sprites["locwindow"].resizeToFit(loctext,Graphics.width)
@@ -23,2 +22,0 @@
- @sprites["locwindow"].letterbyletter=false
- @sprites["locwindow"].text=loctext
Changed: PokemonMart
@@ -71,1 +71,1 @@
- pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i
+ self.contents.blt(0,ypos,@selarrow,@selarrow.rect) if self.index==i
@@ -119,1 +119,1 @@
- using(numwindow=Window_SimpleTextPokemon.new(_INTL("x000 $000000"))){
+ using(numwindow=Window_SimpleTextPokemon.new("")){
@@ -121,1 +121,1 @@
- using(inbagwindow=Window_SimpleTextPokemon.new(_ISPRINTF("IN BAG: {1:d}",qty))){
+ using(inbagwindow=Window_SimpleTextPokemon.new("")){
@@ -125,1 +125,0 @@
- numwindow.resizeToFit(numwindow.text,480)
@@ -127,0 +126,1 @@
+ numwindow.resizeToFit(_INTL("x000 $000000"),480)
@@ -128,0 +128,1 @@
+ inbagwindow.text=_ISPRINTF("IN BAG: {1:d}",qty)
@@ -499,0 +500,1 @@
+ next if qty==0
Changed: PokeBattle_ActualScene
@@ -280,1 +280,1 @@
- @info=Window_ColoredTextPokemon.newWithSize(
+ @info=Window_FormattedTextPokemon.newWithSize(
@@ -282,2 +282,2 @@
- @info.baseColor=PokeBattle_Scene::MENUBASECOLOR
- @info.shadowColor=PokeBattle_Scene::MENUSHADOWCOLOR
+ @ctag=shadowctag(PokeBattle_Scene::MENUBASECOLOR,
+ PokeBattle_Scene::MENUSHADOWCOLOR)
@@ -299,2 +299,2 @@
- @info.text=_ISPRINTF("PP: {1: 2d}/{2: 2d}\r\nTYPE/{3:s}",
- selmove.pp,selmove.totalpp,movetype)
+ @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}
TYPE/{4:s}",
+ @ctag,selmove.pp,selmove.totalpp,movetype)
@@ -601,1 +601,3 @@
- if @currentexp<@endexp
+ if !@showexp
+ @currentexp=@endexp
+ elsif @currentexp<@endexp
@@ -1216,13 +1218,0 @@
-def pbDisposeSpriteHash(sprites)
- for i in sprites
- sprite=i[1]
- if sprite && !sprite.disposed?
- if sprite.is_a?(Sprite)
- sprite.bitmap.dispose if sprite.bitmap && !sprite.bitmap.disposed?
- end
- sprite.dispose
- end
- end
-end
-
-
@@ -1232,11 +1221,0 @@
-
-def pbDisposeSprite(id)
- sprite=@sprites[id]
- if sprite && !sprite.disposed?
- if sprite.is_a?(Sprite)
- sprite.bitmap.dispose if sprite.bitmap && !sprite.bitmap.disposed?
- end
- sprite.dispose
- end
-end
-
@@ -1592,2 +1570,2 @@
- pbDisposeSprite("trainer")
- pbDisposeSprite("partybase1")
+ pbDisposeSprite(@sprites,"trainer")
+ pbDisposeSprite(@sprites,"partybase1")
@@ -1595,1 +1573,1 @@
- pbDisposeSprite("enemy#{i}")
+ pbDisposeSprite(@sprites,"enemy#{i}")
@@ -1634,2 +1612,2 @@
- pbDisposeSprite("player")
- pbDisposeSprite("partybase2")
+ pbDisposeSprite(@sprites,"player")
+ pbDisposeSprite(@sprites,"partybase2")
@@ -1637,1 +1615,1 @@
- pbDisposeSprite("player#{i}")
+ pbDisposeSprite(@sprites,"player#{i}")
Changed: Shadow
@@ -27,1 +27,4 @@
-
+ def dispose
+ self.bitmap.dispose if self.bitmap
+ super
+ end
@@ -41,0 +44,1 @@
+ self.bitmap.dispose if self.bitmap
@@ -49,0 +53,1 @@
+ self.bitmap.dispose if self.bitmap
Changed: PokemonTrainers
@@ -20,1 +20,1 @@
- pokemon=PokeBattle_Pokemon.new(species,level,$opponent)
+ pokemon=PokeBattle_Pokemon.new(species,level,opponent)
@@ -236,0 +236,1 @@
+ for i in othertrainer.party; i.heal; end
Added: Transitions
Changed: SpriteResizer
@@ -358,0 +358,1 @@
+ @borderbitmap.dispose if @borderbitmap
@@ -376,1 +377,3 @@
- @sprite.bitmap=RPG::Cache.picture(@bordername)
+ @borderbitmap.dispose if @borderbitmap
+ @borderbitmap=RPG::Cache.picture(@bordername)
+ @sprite.bitmap=@borderbitmap
Changed: PokeBattle_Trainer
@@ -47,1 +47,1 @@
- ret+=1 if !@party[i].egg?
+ ret+=1 if @party[i] && !@party[i].egg?
@@ -49,-1 +49,7 @@
+ return ret
+end
+
+def ablePokemonCount
+ ret=0
+ for i in 0...@party.length
+ ret+=1 if @party[i] && !@party[i].egg? && @party[i].hp>0
Changed: PokemonDuel
@@ -4,1 +4,1 @@
-class DuelWindow < Window_ColoredTextPokemon
+class DuelWindow < Window_FormattedTextPokemon
@@ -8,0 +8,4 @@
+ def duelRefresh
+ color= @isenemy ? "" : ""
+ self.text=_INTL("{1}{2}\r\nHP: {3}",color,fmtescape(@name),@hp)
+ end
@@ -12,2 +16,1 @@
- color= @isenemy ? "\\[043c3aff]" : "\\[65467b14]"
- super(_INTL("{1}{2}\\[06644bd2]\r\nHP: {3}",color,@name,@hp))
+ super("")
@@ -16,0 +19,1 @@
+ duelRefresh
@@ -19,2 +23,1 @@
- color=@isenemy ? "\\[043c3aff]" : "\\[65467b14]"
- self.text=_INTL("{1}{2}\\[06644bd2]\r\nHP: {3}",color,@name,@hp)
+ duelRefresh
@@ -24,2 +27,1 @@
- color=@isenemy ? "\\[043c3aff]" : "\\[65467b14]"
- self.text=_INTL("{1}{2}\\[06644bd2]\r\nHP: {3}",color,@name,@hp)
+ duelRefresh
@@ -29,2 +31,1 @@
- color=@isenemy ? "\\[043c3aff]" : "\\[65467b14]"
- self.text=_INTL("{1}{2}\\[06644bd2]\r\nHP: {3}",color,@name,@hp)
+ duelRefresh
Changed: PokemonLoad
@@ -9,1 +9,1 @@
- @sprites["locwindow"]=Window_ColoredTextPokemon.new("")
+ @sprites["locwindow"]=Window_FormattedTextPokemon.new("")
@@ -11,1 +11,0 @@
- @sprites["locwindow"].letterbyletter=false
@@ -118,6 +117,13 @@
- copy_file(Source + f, Dest + f)
- # add font resource
- AFR.call(Dest + f)
- # add entry to win.ini/registry
- WPS.call('Fonts', Names[i] + ' (TrueType)', f)
- if FileTest.exists?(Dest + f)
+ succeeded=false
+ begin
+ copy_file(Source + f, Dest + f)
+ # add font resource
+ AFR.call(Dest + f)
+ # add entry to win.ini/registry
+ WPS.call('Fonts', Names[i] + ' (TrueType)', f)
+ succeeded=FileTest.exists?(Dest + f)
+ rescue SystemCallError
+ # failed
+ succeeded=false
+ end
+ if succeeded
@@ -200,4 +206,4 @@
- loctext+=_INTL("\\[318c675a]PLAYER: \\[65467b14]{1}\r\n",trainer.name)
- loctext+=_INTL("\\[318c675a]BADGES: \\[65467b14]{1}\r\n",trainer.numbadges)
- loctext+=_INTL("\\[318c675a]POKéDEX: \\[65467b14]{1}\r\n",trainer.pokedexOwned)
- loctext+=_INTL("\\[318c675a]TIME: \\[65467b14]")+_ISPRINTF("{1:02d}:{2:02d}",hour,min)
+ loctext+=_INTL("PLAYER: {1}
",fmtescape(trainer.name))
+ loctext+=_INTL("BADGES: {1}
",trainer.numbadges)
+ loctext+=_INTL("POKéDEX: {1}
",trainer.pokedexOwned)
+ loctext+=_INTL("TIME: ")+_ISPRINTF("{1:02d}:{2:02d}",hour,min)
Changed: BitmapCache
@@ -45,0 +45,13 @@
+ def self.debug
+ File.open("bitmapcache2.txt","wb"){|f|
+ for i in @cache
+ if !i[1]
+ f.write("#{i[0]} (nil)\r\n")
+ elsif i[1].disposed?
+ f.write("#{i[0]} (disposed)\r\n")
+ else
+ f.write("#{i[0]} (#{i[1].refcount}, #{i[1].width}x#{i[1].height})\r\n")
+ end
+ end
+ }
+ end
@@ -46,0 +59,1 @@
+ cached=true
@@ -49,4 +63,6 @@
- for i in @cache.keys
- if @cache[i] && @cache[i].disposed?
- @cache[i]=nil
- @cache.delete(i)
+ if rand(10) == 0
+ for i in @cache.keys
+ if !@cache[i] || @cache[i].disposed?
+ @cache[i]=nil
+ @cache.delete(i)
+ end
@@ -57,1 +73,1 @@
- @cache[path] = Bitmap.new(path)
+ @cache[path] = BitmapWrapper.new(path)
@@ -60,1 +76,1 @@
- @cache[path] = Bitmap.new(path)
+ @cache[path] = BitmapWrapper.new(path)
@@ -62,2 +78,2 @@
- @cache[path] = Bitmap.new(32, 32)
- raise _INTL("Failed to load bitmap: {1}",path)
+ @cache[path] = BitmapWrapper.new(32, 32)
+ raise _INTL("Failed to load bitmap: {1}",path)
@@ -66,1 +82,1 @@
- @cache[path] = Bitmap.new(32, 32)
+ @cache[path] = BitmapWrapper.new(32, 32)
@@ -70,2 +86,3 @@
- @cache[path] = Bitmap.new(32, 32)
- end
+ @cache[path] = BitmapWrapper.new(32, 32)
+ end
+ cached=false
@@ -74,1 +91,2 @@
- @cache[path]
+ @cache[path].addRef if cached
+ return @cache[path]
@@ -80,2 +98,5 @@
- end
- @cache[key]
+ @cache[key].resetRef
+ else
+ @cache[key].addRef
+ end
+ return @cache[key]
@@ -126,1 +147,1 @@
- @cache[key] = Bitmap.new(32, 32)
+ @cache[key] = BitmapWrapper.new(32, 32)
@@ -130,1 +151,3 @@
- @cache[key].blt(0, 0, self.tileset(filename), rect)
+ tileset = self.tileset(filename)
+ @cache[key].blt(0, 0, tileset, rect)
+ tileset.dispose
@@ -132,0 +155,2 @@
+ else
+ @cache[key].addRef
@@ -156,1 +181,0 @@
-# File.open("bitmapwrapper.txt","ab"){|f| f.write("[#{@key}] dispose=#{@refcount}\r\n")}
@@ -168,1 +192,0 @@
-# File.open("bitmapwrapper.txt","ab"){|f| f.write("[#{@key}] ref=#{@refcount}\r\n")}
@@ -172,1 +195,0 @@
-# File.open("bitmapwrapper.txt","ab"){|f| f.write("[#{@key}] resetRef=#{@refcount}\r\n")}
@@ -176,1 +198,0 @@
-# File.open("bitmapwrapper.txt","ab"){|f| f.write("[#{@key}] addRef=#{@refcount}\r\n")}
@@ -201,1 +222,1 @@
- if @cache[i] && @cache[i].disposed?
+ if !@cache[i] || @cache[i].disposed?
@@ -288,1 +309,3 @@
- @cache[key].blt(0, 0, self.tileset(filename), rect)
+ tileset = self.tileset(filename)
+ @cache[key].blt(0, 0, tileset, rect)
+ tileset.dispose
Changed: PokeBattle_AI
@@ -510,1 +510,1 @@
- if !@opponent # If wild battle
+ if !@opponent && pbIsOpposing?(index) # If wild battle
Changed: WindowAndTilemap
@@ -582,2 +582,2 @@
- @oldtone=@tone
- @oldcolor=@color
+ @oldtone=Tone.new(0,0,0,0)
+ @oldcolor=Color.new(0,0,0,0)
@@ -594,1 +594,1 @@
- @layer0.bitmap=Bitmap.new(@viewport.rect.width*2,@viewport.rect.height*2)
+ @layer0.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max)
@@ -622,1 +622,1 @@
- @flashChanged=true
+ @flashChanged=true
@@ -626,2 +626,2 @@
- @layer0.tone=tone
- @flash.tone=tone if @flash
+ @layer0.tone=@tone
+ @flash.tone=@tone if @flash
@@ -634,1 +634,1 @@
- @oldtone=@tone
+ @oldtone=@tone.clone
@@ -637,2 +637,2 @@
- @layer0.color=color
- @flash.color=color if @flash
+ @layer0.color=@color
+ @flash.color=@color if @flash
@@ -645,1 +645,1 @@
- @oldcolor=@color
+ @oldcolor=@color.clone
@@ -912,1 +912,1 @@
- @flash.bitmap=Bitmap.new(@viewport.rect.width*2,@viewport.rect.height*2)
+ @flash.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max)
@@ -1036,0 +1036,3 @@
+ if autotiles
+ return true if !shown?
+ end
@@ -1061,1 +1064,0 @@
- return true if !shown?
Changed: PokemonEntry
@@ -627,1 +627,0 @@
- [188,",","<"],
@@ -629,1 +628,0 @@
- [190,_INTL("."),">"],
@@ -632,0 +630,2 @@
+# [190,".",">"],
+# [188,",","<"],
@@ -633,0 +633,2 @@
+ [190,".",""],
+ [188,",",""],
@@ -684,1 +686,0 @@
- [188,",","<"],
@@ -686,1 +687,0 @@
- [190,_INTL("."),">"],
@@ -689,0 +689,2 @@
+# [190,".",">"],
+# [188,",","<"],
@@ -690,0 +692,2 @@
+ [190,".",""],
+ [188,",",""],
Changed: PokemonWeather
@@ -7,0 +7,21 @@
+ def prepareSandstormBitmaps
+ if !@sandstormBitmap1
+ @sandstormBitmap1=Bitmap.new(128,128)
+ @sandstormBitmap2=Bitmap.new(128,128)
+ sandstormColors=[
+ Color.new(31*8,28*8,17*8),
+ Color.new(23*8,16*8,9*8),
+ Color.new(29*8,24*8,15*8),
+ Color.new(26*8,20*8,12*8),
+ Color.new(20*8,13*8,6*8),
+ Color.new(31*8,30*8,20*8),
+ Color.new(27*8,25*8,20*8)
+ ]
+ for i in 0..256
+ @sandstormBitmap1.fill_rect(rand(64)*2, rand(64)*2, 2,2,sandstormColors[rand(7)])
+ @sandstormBitmap2.fill_rect(rand(64)*2, rand(64)*2, 2,2,sandstormColors[rand(7)])
+ end
+ @weatherTypes[4][0][0]=@sandstormBitmap1
+ @weatherTypes[4][0][1]=@sandstormBitmap2
+ end
+ end
@@ -33,15 +54,0 @@
- @sandstormBitmap1=Bitmap.new(128,128)
- @sandstormBitmap2=Bitmap.new(128,128)
- @sandstormColors=[
- Color.new(31*8,28*8,17*8),
- Color.new(23*8,16*8,9*8),
- Color.new(29*8,24*8,15*8),
- Color.new(26*8,20*8,12*8),
- Color.new(20*8,13*8,6*8),
- Color.new(31*8,30*8,20*8),
- Color.new(27*8,25*8,20*8)
- ]
- for i in 0..256
- @sandstormBitmap1.fill_rect(rand(64)*2, rand(64)*2, 2,2,@sandstormColors[rand(7)])
- @sandstormBitmap2.fill_rect(rand(64)*2, rand(64)*2, 2,2,@sandstormColors[rand(7)])
- end
@@ -53,1 +59,1 @@
- [[@sandstormBitmap1,@sandstormBitmap2],-8,-2,-2],
+ [[],-8,-2,-2],
@@ -87,0 +93,2 @@
+ when 4
+ prepareSandstormBitmaps
@@ -148,3 +156,5 @@
- rnd=rand(300)
- if rnd<4 && @type==2
- @viewport.flash(Color.new(255,255,255,230),rnd*20)
+ if @type==2
+ rnd=rand(300)
+ if rnd<4
+ @viewport.flash(Color.new(255,255,255,230),rnd*20)
+ end
Changed: Game_System
@@ -204,0 +204,1 @@
+ $game_temp.updateDayNightTone
@@ -213,0 +214,18 @@
+
+class Game_Temp
+ def dayNightTone
+ if !@dayNightTone
+ @dayNightTone=Tone.new(0,0,0)
+ @dayNightToneNeedUpdate=true
+ end
+ if @dayNightToneNeedUpdate
+ pbSetDayNightTone(@dayNightTone)
+ @dayNightToneNeedUpdate=false
+ end
+ return @dayNightTone
+ end
+ def updateDayNightTone
+ @dayNightToneNeedUpdate=true
+ end
+end
+
Changed: Compiler
@@ -788,1 +788,3 @@
- return pbGetConst(PBItems,item,_INTL("Undefined item constant name: %s\r\n{1}",FileLineData.linereport))
+ return pbGetConst(PBItems,item,
+ _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}",
+ FileLineData.linereport))
@@ -797,1 +799,1 @@
- return pbGetConst(PBSpecies,item,_INTL("Undefined species constant name: %s\r\n{1}",FileLineData.linereport))
+ return pbGetConst(PBSpecies,item,_INTL("Undefined species constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}",FileLineData.linereport))
@@ -804,1 +806,1 @@
- return pbGetConst(PBMoves,item,_INTL("Undefined move constant name: %s\r\n{1}",FileLineData.linereport))
+ return pbGetConst(PBMoves,item,_INTL("Undefined move constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}",FileLineData.linereport))
@@ -811,1 +813,1 @@
- return pbGetConst(PBTrainers,item,_INTL("Undefined Trainer constant name: %s\r\n{1}",FileLineData.linereport))
+ return pbGetConst(PBTrainers,item,_INTL("Undefined Trainer constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}",FileLineData.linereport))
Changed: Game_Player*
@@ -62,1 +62,0 @@
- return
@@ -65,1 +64,0 @@
- return
@@ -68,1 +66,0 @@
- return
@@ -71,1 +68,0 @@
- return
@@ -74,11 +70,11 @@
- end
- case leader.direction
- when 2 # down
- follower.move_down
- when 4 # left
- follower.move_left
- when 6 # right
- follower.move_right
- when 8 # up
- follower.move_up
- end
+ case leader.direction
+ when 2 # down
+ follower.move_down
+ when 4 # left
+ follower.move_left
+ when 6 # right
+ follower.move_right
+ when 8 # up
+ follower.move_up
+ end
+ end
Changed: Audio
@@ -1,16 +1,78 @@
-
-class SafeValue
- def initialize(value)
- @value=value
- end
- def value
- ret=nil
- Thread.critical=true
- ret=@value
- Thread.critical=false
- return ret
- end
- def value=(v)
- Thread.critical=true
- @value=v
- Thread.critical=false
+class Thread
+ def Thread.exclusive
+ _old = Thread.critical
+ begin
+ Thread.critical = true
+ return yield
+ ensure
+ Thread.critical = _old
+ end
+ end
+end
+class Mutex
+ def initialize
+ @waiting = []
+ @locked = false;
+ @waiting.taint # enable tainted comunication
+ self.taint
+ end
+ def locked?
+ @locked
+ end
+ def try_lock
+ result = false
+ Thread.critical = true
+ unless @locked
+ @locked = true
+ result = true
+ end
+ Thread.critical = false
+ result
+ end
+ def lock
+ while (Thread.critical = true; @locked)
+ @waiting.push Thread.current
+ Thread.stop
+ end
+ @locked = true
+ Thread.critical = false
+ self
+ end
+ def unlock
+ return unless @locked
+ Thread.critical = true
+ @locked = false
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
+ Thread.critical = false
+ begin
+ t.run if t
+ rescue ThreadError
+ end
+ self
+ end
+ def synchronize
+ lock
+ begin
+ yield
+ ensure
+ unlock
+ end
+ end
+ def exclusive_unlock
+ return unless @locked
+ Thread.exclusive do
+ @locked = false
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
+ yield
+ end
+ self
@@ -51,0 +113,2 @@
+
+
@@ -53,0 +117,1 @@
+ w32_FL = Win32API.new("kernel32.dll", "FreeLibrary", 'p', 'l')
@@ -56,0 +121,9 @@
+ at_exit { w32_FL.call(@handle) }
+ AudioContextIsActive=Win32API.new("audio.dll","AudioContextIsActive","l","l")
+ AudioContextPlay=Win32API.new("audio.dll","AudioContextPlay","lpllll","")
+ AudioContextStop=Win32API.new("audio.dll","AudioContextStop","l","")
+ AudioContextFadeOut=Win32API.new("audio.dll","AudioContextFadeOut","ll","")
+ AudioContextGetPosition=Win32API.new("audio.dll","AudioContextGetPosition","l","l")
+ AudioContextFadeIn=Win32API.new("audio.dll","AudioContextFadeIn","ll","")
+ AudioContextSetVolume=bgmstop=Win32API.new("audio.dll","AudioContextSetVolume","ll","")
+ AudioContextSEPlay=Win32API.new("audio.dll","AudioContextSEPlay","lplll","")
@@ -81,2 +155,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextIsActive","l","l")
- return (bgmstop.call(@BGMContext.context)!=0)
+ return (AudioContextIsActive.call(@BGMContext.context)!=0)
@@ -85,2 +158,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextIsActive","l","l")
- return (bgmstop.call(@MEContext.context)!=0)
+ return (AudioContextIsActive.call(@MEContext.context)!=0)
@@ -98,1 +170,5 @@
- def self.waitingBGM=(value); @waitingBGM=value; end
+ def self.waitingBGM=(value);
+ Thread.critical=true
+ @waitingBGM=value;
+ Thread.critical=false
+ end
@@ -124,2 +200,1 @@
- bgmplay=Win32API.new("audio.dll","AudioContextPlay","lpllll","")
- bgmplay.call(AudioState.context,filename,volume,pitch,position,1)
+ AudioState::AudioContextPlay.call(AudioState.context,filename,volume,pitch,position,1)
@@ -145,5 +220,3 @@
- bgmstop=Win32API.new("audio.dll","AudioContextStop","l","")
- bgmstop.call(AudioState.context)
- end
- bgmplay=Win32API.new("audio.dll","AudioContextPlay","lpllll","")
- bgmplay.call(AudioState.meContext,filename,volume,pitch,position,0)
+ AudioState::AudioContextStop.call(AudioState.context)
+ end
+ AudioState::AudioContextPlay.call(AudioState.meContext,filename,volume,pitch,position,0)
@@ -156,2 +229,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextFadeOut","ll","")
- bgmstop.call(AudioState.meContext,ms)
+ AudioState::AudioContextFadeOut.call(AudioState.meContext,ms)
@@ -161,2 +233,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextSetVolume","ll","")
- bgmstop.call(AudioState.meContext,0)
+ AudioState::AudioContextSetVolume.call(AudioState.meContext,0)
@@ -167,2 +238,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextStop","l","")
- bgmstop.call(AudioState.context)
+ AudioState::AudioContextStop.call(AudioState.context)
@@ -177,2 +247,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextGetPosition","l","l")
- return bgmstop.call(AudioState.context)
+ return AudioState::AudioContextGetPosition.call(AudioState.context)
@@ -182,2 +251,1 @@
- bgmfade=Win32API.new("audio.dll","AudioContextFadeOut","ll","")
- bgmfade.call(AudioState.context,ms.to_i)
+ AudioState::AudioContextFadeOut.call(AudioState.context,ms.to_i)
@@ -187,2 +255,1 @@
- bgmfade=Win32API.new("audio.dll","AudioContextFadeIn","ll","")
- bgmfade.call(AudioState.context,ms.to_i)
+ AudioState::AudioContextFadeIn.call(AudioState.context,ms.to_i)
@@ -199,2 +266,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextSetVolume","ll","")
- bgmstop.call(AudioState.context,volume.to_i)
+ AudioState::AudioContextSetVolume.call(AudioState.context,volume.to_i)
@@ -208,2 +274,1 @@
- bgmplay=Win32API.new("audio.dll","AudioContextPlay","lpllll","")
- bgmplay.call(AudioState.bgsContext,filename,volume,pitch,position,0)
+ AudioState::AudioContextPlay.call(AudioState.bgsContext,filename,volume,pitch,position,0)
@@ -216,2 +281,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextFadeOut","ll","")
- bgmstop.call(AudioState.bgsContext,ms)
+ AudioState::AudioContextFadeOut.call(AudioState.bgsContext,ms)
@@ -221,2 +285,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextStop","l","")
- bgmstop.call(AudioState.bgsContext)
+ AudioState::AudioContextStop.call(AudioState.bgsContext)
@@ -229,2 +292,1 @@
- bgmplay=Win32API.new("audio.dll","AudioContextSEPlay","lplll","")
- bgmplay.call(AudioState.seContext,filename,volume,pitch,position)
+ AudioState::AudioContextSEPlay.call(AudioState.seContext,filename,volume,pitch,position)
@@ -237,2 +299,1 @@
- bgmstop=Win32API.new("audio.dll","AudioContextStop","l","")
- bgmstop.call(AudioState.seContext)
+ AudioState::AudioContextStop.call(AudioState.seContext)
@@ -258,0 +319,1 @@
+ return if Graphics.frame_count%10!=0
@@ -259,3 +321,3 @@
- waitbgm=AudioState.waitingBGM
- AudioState.waitingBGM=nil
- bgm_play(waitbgm[0],waitbgm[1],waitbgm[2],waitbgm[3])
+ waitbgm=AudioState.waitingBGM
+ AudioState.waitingBGM=nil
+ bgm_play(waitbgm[0],waitbgm[1],waitbgm[2],waitbgm[3])
@@ -309,1 +371,84 @@
-
+=begin
+module AudioThreadSafe
+ @@mutex=Mutex.new
+ @@audiothread=Thread.new {
+ loop do
+ @@mutex.synchronize {
+ params=Thread.current["params"]
+ if params
+ case params[0]
+ when :update
+ AudioInternal.update
+ when :bgm_play
+ AudioInternal.bgm_play(*params[1])
+ when :bgm_fade
+ AudioInternal.bgm_fade(*params[1])
+ when :bgm_stop
+ AudioInternal.bgm_stop(*params[1])
+ when :me_play
+ AudioInternal.me_play(*params[1])
+ when :me_fade
+ AudioInternal.me_fade(*params[1])
+ when :me_stop
+ AudioInternal.me_stop(*params[1])
+ when :bgs_play
+ AudioInternal.bgs_play(*params[1])
+ when :bgs_fade
+ AudioInternal.bgs_fade(*params[1])
+ when :bgs_stop
+ AudioInternal.bgs_stop(*params[1])
+ end
+ end
+ Thread.current["params"]=nil
+ sleep(0.010)
+ }
+ end
+ }
+ def self.passParams(sym,*params)
+ @@mutex.synchronize {
+ @@audiothread["params"]=[sym,params]
+ }
+ end
+ def self.update
+ return if Graphics.frame_count%10!=0
+ if AudioState.waitingBGM && !AudioState.meActive?
+ waitbgm=AudioState.waitingBGM
+ AudioState.waitingBGM=nil
+ bgm_play(waitbgm[0],waitbgm[1],waitbgm[2],waitbgm[3])
+ end
+ end
+ def self.bgm_play(name,volume=80,pitch=100,position=nil)
+ self.passParams(:bgm_play,name,volume,pitch,position)
+ end
+ def self.bgm_fade(ms)
+ self.passParams(:bgm_fade,ms)
+ end
+ def self.bgm_stop
+ self.passParams(:bgm_stop)
+ end
+ def self.bgm_position
+ @@mutex.synchronize {
+ ret=Kernel.Audio_bgm_get_position
+ return ret
+ }
+ end
+ def self.me_play(name,volume=80,pitch=100)
+ self.passParams(:me_play,name,volume,pitch,0)
+ end
+ def self.me_fade(ms)
+ self.passParams(:me_fade,ms)
+ end
+ def self.me_stop
+ self.passParams(:me_stop)
+ end
+ def self.bgs_play(name,volume=80,pitch=100)
+ self.passParams(:bgs_play,name,volume,pitch,0)
+ end
+ def self.bgs_fade(ms)
+ self.passParams(:bgs_fade,ms)
+ end
+ def self.bgs_stop
+ self.passParams(:bgs_stop)
+ end
+end
+=end
Changed: Spriteset_Map
@@ -13,1 +13,1 @@
- @tilemap.tileset = @map.tileset_name=="" ? Bitmap.new(32,32) : BitmapCache.tileset(@map.tileset_name)
+ @tilemap.tileset = RPG::Cache.tileset(@map.tileset_name)
@@ -16,1 +16,1 @@
- @tilemap.autotiles[i] = autotile_name=="" ? Bitmap.new(32,32) : BitmapCache.autotile(autotile_name)
+ @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
@@ -109,2 +109,0 @@
-
-
@@ -133,0 +131,11 @@
+ @tilemap=nil
+ @panorama=nil
+ @fog=nil
+ @character_sprites.clear
+ @reflectedSprites.clear
+ @weather=nil
+ @picture_sprites.clear
+ @viewport1=nil
+ @viewport2=nil
+ @viewport3=nil
+ @timer_sprite=nil
@@ -204,1 +213,0 @@
- i=0
@@ -207,1 +215,3 @@
- if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4
+ if sprite.character.trigger == 3 ||
+ sprite.character.trigger == 4 ||
+ in_range?(sprite.character)
@@ -209,1 +219,0 @@
- i+=1
@@ -213,1 +222,0 @@
- i+=1
Changed: PokemonEditor
@@ -396,1 +396,1 @@
- ret=pbCommands2(cmdwin,realcommands,0,default-1,true)
+ ret=pbCommands2(cmdwin,realcommands,0,default-1,true)
@@ -398,-1 +398,16 @@
+ return ret>=0 ? commands[ret][0] : 0
+end
+
+
+def pbChooseMoveList
+ cmdwin=pbListWindow([],200)
+ commands=[]
+ for i in 1..PBMoves.getCount
+ commands.push([i,PBMoves.getName(i)])
+ end
+ commands.sort! {|a,b| a[1]<=>b[1]}
+ realcommands=[]
+ for command in commands
+ realcommands.push(_ISPRINTF("{2:s}",command[0],command[1]))
+ end
+ ret=pbCommands2(cmdwin,realcommands,-1,0,true)
@@ -1248,2 +1265,2 @@
- [_INTL("Trainer Back"),PictureProperty,
- _INTL("Back of the player, for use in battles.")],
+ [_INTL("Unused"),PictureProperty,
+ _INTL("This field is no longer used.")],
@@ -1269,1 +1286,1 @@
- list.width=Graphics.width*6/10
+ list.width=Graphics.width*5/10
@@ -1275,1 +1292,1 @@
- title.width=Graphics.width*4/10
+ title.width=Graphics.width*5/10
@@ -1282,1 +1299,1 @@
- desc.width=Graphics.width*4/10
+ desc.width=Graphics.width*5/10
Changed: PokemonMessages
@@ -409,1 +409,12 @@
-def Kernel.pbChooseNumber(msgwindow,defaultNum,maxDigits,maxnum=nil)
+def numDigits(number)
+ ans = 1
+ number=number.abs
+ while number >= 10
+ ans+=1
+ number/=10;
+ end
+ return ans
+end
+
+
+def Kernel.pbChooseNumberEx(msgwindow,initialNumber,minNumber,maxNumber,cancelNumber)
@@ -411,1 +422,2 @@
- maximum=maxnum ? maxnum : (10**maxDigits)-1
+ return cancelNumber if minNumber>maxNumber
+ maxDigits=numDigits(maxNumber)
@@ -416,3 +428,5 @@
- cmdwindow.text=sprintf("%0*d",maxDigits,defaultNum)
- curnumber=defaultNum
- curnumber=0 if !curnumber
+ initialNumber=minNumber if initialNumbermaxNumber
+ cmdwindow.text=sprintf("%0*d",maxDigits,initialNumber)
+ curnumber=initialNumber
+ curnumber=minNumber if !curnumber
@@ -433,1 +447,1 @@
- curnumber=0 if curnumber<0
+ curnumber=minNumber if curnumbermaximum
+ curnumber=maxNumber if curnumber>maxNumber
@@ -441,1 +455,1 @@
- curnumber=0 if curnumber>maximum
+ curnumber=minNumber if curnumber>maxNumber
@@ -445,1 +459,1 @@
- curnumber=maximum if curnumber<0
+ curnumber=maxNumber if curnumber" }
+ text.gsub!(/\\[Bb]/,"")
+ text.gsub!(/\\[Rr]/,"")
@@ -695,9 +723,9 @@
- "\\[318c675a]",
- "\\[7E105D08]",
- "\\[421F2117]",
- "\\[43F022E8]",
- "\\[7FF05EE8]",
- "\\[7E1F5D17]",
- "\\[43FF22F7]",
- "\\[63184210]",
- "\\[7FFF5EF7]"
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ""
@@ -731,1 +759,1 @@
- textlen+=textchunks[i].sub(/\\\[([^\]]*)\]/,"").scan(/./m).length
+ textlen+=toUnformattedText(textchunks[i]).scan(/./m).length
@@ -763,1 +791,1 @@
- if controls[i] && controls[i][2]==msgwindow.position && waitcount==0
+ if controls[i] && controls[i][2]<=msgwindow.position && waitcount==0
@@ -775,1 +803,1 @@
- waitcount=param.to_i*2
+ waitcount+=param.to_i*2
Changed: SpriteWindow
@@ -60,0 +60,297 @@
+
+
+def pbDrawShadow(bitmap,x,y,width,height,string)
+ bitmap.draw_text(x+2,y,width,height,string)
+ bitmap.draw_text(x,y+2,width,height,string)
+ bitmap.draw_text(x+2,y+2,width,height,string)
+end
+def pbCopyBitmap(dstbm,srcbm,x,y,opacity=255)
+ rc=Rect.new(0,0,srcbm.width,srcbm.height)
+ dstbm.blt(x,y,srcbm,rc,opacity)
+end
+
+def using(window)
+ begin
+ yield if block_given?
+ ensure
+ window.dispose
+ end
+end
+
+def pbBottomRight(window)
+ window.x=Graphics.width-window.width
+ window.y=Graphics.height-window.height
+end
+
+def pbBottomLeft(window)
+ window.x=0
+ window.y=Graphics.height-window.height
+end
+
+def pbBottomLeftLines(window,lines,width=nil)
+ window.x=0
+ window.width=width ? width : Graphics.width
+ window.height=32+lines*32
+ window.y=Graphics.height-window.height
+end
+
+def pbDisposed?(x)
+ if x.is_a?(Viewport)
+ begin
+ x.rect=x.rect
+ rescue
+ return true
+ end
+ return false
+ else
+ return x.disposed?
+ end
+end
+
+
+def pbEnsureBitmap(bitmap,dwidth,dheight)
+ if !bitmap||bitmap.disposed?||bitmap.width=0 ? i[5] : srcbitmap.width
+ height=i[6]>=0 ? i[6] : srcbitmap.height
+ srcrect=Rect.new(srcx,srcy,width,height)
+ bitmap.blt(x,y,srcbitmap,srcrect)
+ srcbitmap.dispose
+ end
+end
+
+class Game_Temp
+ attr_accessor :fadestate
+ def fadestate
+ return @fadestate ? @fadestate : 0
+ end
+end
+
+def pbPushFade
+ $game_temp.fadestate=[$game_temp.fadestate+1,0].max
+end
+def pbPopFade
+ $game_temp.fadestate=[$game_temp.fadestate-1,0].max
+end
+def pbIsFaded?
+ return $game_temp.fadestate>0
+end
+
+=begin
+pbFadeOutIn(z) { block }
+Fades out the screen before a block is run and fades it back in
+after the block exits. z indicates the z-coordinate of the viewport
+used for this effect
+=end
+
+def pbFadeOutIn(z)
+ col=Color.new(0,0,0,0)
+ viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
+ viewport.z=z
+ for j in 0..17
+ col.set(0,0,0,j*15)
+ viewport.color=col
+ Graphics.update
+ Input.update
+ end
+ pbPushFade
+ yield if block_given?
+ pbPopFade
+ for j in 0..17
+ col.set(0,0,0,(17-j)*15)
+ viewport.color=col
+ Graphics.update
+ Input.update
+ end
+ viewport.dispose
+end
+
+def pbFadeOutAndHide(sprites)
+ visiblesprites={}
+ for j in 0..26
+ for i in sprites
+ next if !i[1]
+ next if pbDisposed?(i[1])
+ if i[1].is_a?(Sprite) || i[1].is_a?(Window)
+ i[1].update
+ elsif i[1].is_a?(Plane)
+ begin
+ i[1].update
+ rescue NoMethodError
+ end
+ end
+ next if pbDisposed?(i[1])
+ i[1].color.red=0
+ i[1].color.green=0
+ i[1].color.blue=0
+ i[1].color.alpha=j*10
+ i[1].color=i[1].color
+ end
+ Graphics.update
+ Input.update
+ end
+ for i in sprites
+ next if !i[1]
+ next if pbDisposed?(i[1])
+ visiblesprites[i[0]]=true if i[1].visible
+ i[1].visible=false
+ end
+ return visiblesprites
+end
+
+def pbFadeInAndShow(sprites,visiblesprites=nil)
+ if visiblesprites
+ for i in visiblesprites
+ if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
+ sprites[i[0]].visible=true
+ end
+ end
+ end
+ for j in 0..26
+ for i in sprites
+ next if !i[1]
+ next if pbDisposed?(i[1])
+ if i[1].is_a?(Sprite) || i[1].is_a?(Window)
+ i[1].update
+ elsif i[1].is_a?(Plane)
+ begin
+ i[1].update
+ rescue NoMethodError
+ end
+ end
+ next if pbDisposed?(i[1])
+ i[1].color.red=0
+ i[1].color.green=0
+ i[1].color.blue=0
+ i[1].color.alpha=((26-j)*10)
+ next if pbDisposed?(i[1])
+ i[1].color=i[1].color
+ end
+ Graphics.update
+ Input.update
+ end
+end
+
+def addBackgroundPlane(sprites,planename,background,viewport=nil)
+ begin
+ bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{background}")
+ rescue
+ return
+ end
+ sprites[planename]=Plane.new(viewport)
+ sprites[planename].bitmap=bitmap
+ for spr in sprites.values
+ if spr.is_a?(Window)
+ spr.windowskin=nil
+ end
+ end
+end
+
+def addBackgroundOrColoredPlane(sprites,planename,background,color,viewport=nil)
+ begin
+ bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{background}")
+ sprites[planename]=Plane.new(viewport)
+ sprites[planename].bitmap=bitmap
+ rescue
+ sprites[planename]=ColoredPlane.new(color,@viewport)
+ end
+end
+
+
+def pbSetSystemFont(bitmap)
+ bitmap.font.name=[$VersionStyles[pbGetSystemFont][0],"Arial Narrow","Arial"]
+ if pbGetSystemFont==2
+ bitmap.font.size=29
+ else
+ bitmap.font.size=31
+ end
+end
+def pbSetSmallFont(bitmap)
+ bitmap.font.name=["Pokemon Emerald Small","Arial Narrow","Arial"]
+ bitmap.font.size=25
+end
+def pbSetNarrowFont(bitmap)
+ bitmap.font.name=["Pokemon Emerald Narrow","Arial Narrow","Arial"]
+ bitmap.font.size=31
+end
+
+#########################################################################
+
@@ -226,1412 +523,1 @@
-def pbDrawShadow(bitmap,x,y,width,height,string)
- bitmap.draw_text(x+2,y,width,height,string)
- bitmap.draw_text(x,y+2,width,height,string)
- bitmap.draw_text(x+2,y+2,width,height,string)
-end
-def pbBltShadow(bitmap,x,y,srcbitmap,srcrect)
- bitmap.blt(x+2,y,srcbitmap,srcrect)
- bitmap.blt(x,y+2,srcbitmap,srcrect)
- bitmap.blt(x+2,y+2,srcbitmap,srcrect)
-end
-
-def pbCopyBitmap(dstbm,srcbm,x,y,opacity=255)
- rc=Rect.new(0,0,srcbm.width,srcbm.height)
- dstbm.blt(x,y,srcbm,rc,opacity)
-end
-
-def using(window)
- begin
- yield if block_given?
- ensure
- window.dispose
- end
-end
-
-def pbBottomRight(window)
- window.x=Graphics.width-window.width
- window.y=Graphics.height-window.height
-end
-
-def pbBottomLeft(window)
- window.x=0
- window.y=Graphics.height-window.height
-end
-
-def pbBottomLeftLines(window,lines,width=nil)
- window.x=0
- window.width=width ? width : Graphics.width
- window.height=32+lines*32
- window.y=Graphics.height-window.height
-end
-
-def pbDisposed?(x)
- if x.is_a?(Viewport)
- begin
- x.rect=x.rect
- rescue
- return true
- end
- return false
- else
- return x.disposed?
- end
-end
-
-def pbUpdateSpriteHash(windows)
- for i in windows
- window=i[1]
- if window
- if window.is_a?(Sprite) || window.is_a?(Window)
- window.update if !pbDisposed?(window)
- elsif window.is_a?(Plane)
- begin
- i[1].update if !window.disposed?
- rescue NoMethodError
- end
- end
- end
- end
-end
-
-def pbDisposeSpriteHash(sprites)
- for i in sprites
- sprite=i[1]
- if sprite && !pbDisposed?(sprite)
- if sprite.is_a?(Sprite) || sprite.is_a?(Plane)
- sprite.bitmap.dispose if sprite.bitmap && !sprite.bitmap.disposed?
- end
- sprite.dispose
- end
- sprites[i[0]]=nil
- end
- sprites.clear
-end
-
-def pbDisposeSprite(id)
- sprite=@sprites[id]
- if sprite && !pbDisposed?(sprite)
- if sprite.is_a?(Sprite) || sprite.is_a?(Plane)
- sprite.bitmap.dispose if sprite.bitmap && !sprite.bitmap.disposed?
- end
- sprite.dispose
- end
- @sprites[id]=nil
-end
-
-def pbDrawTextPositions(bitmap,textpos)
- for i in textpos
- textsize=bitmap.text_size(i[0])
- x=i[1]
- y=i[2]
- if i[3]==true || i[3]==1 # right align
- x-=textsize.width if i[3]
- elsif i[3]==2 # centered
- x-=(textsize.width/2) if i[3]
- end
- if i[5]
- bitmap.font.color=i[5]
- pbDrawShadow(bitmap,x,y,textsize.width,textsize.height,i[0])
- end
- bitmap.font.color=i[4]
- bitmap.draw_text(x,y,textsize.width,textsize.height,i[0])
- end
-end
-
-def pbDrawImagePositions(bitmap,textpos)
- for i in textpos
- srcbitmap=BitmapCache.load_bitmap(i[0])
- x=i[1]
- y=i[2]
- srcx=i[3]
- srcy=i[4]
- width=i[5]>=0 ? i[5] : srcbitmap.width
- height=i[6]>=0 ? i[6] : srcbitmap.height
- srcrect=Rect.new(srcx,srcy,width,height)
- bitmap.blt(x,y,srcbitmap,srcrect)
- srcbitmap.dispose
- end
-end
-
-def pbGetVisibleSprites
- ret=[]
- ObjectSpace.each_object(Sprite){|o|
- next if o.disposed?
- next if !o.visible
- ret.push([
- o,o.x,o.y,o.ox,o.oy,o.zoom_x,o.zoom_y,o.color.clone
- ])
- }
- return ret
-end
-
-def pbZoomOutIn(frames=30)
- vis=pbGetVisibleSprites
- for s in vis
- s[0].x=s[1]-s[3]*s[5]
- s[0].y=s[2]-s[4]*s[6]
- s[0].ox=0
- s[0].oy=0
- end
- genzoom=1.0
- frames.times do
- genzoom+=0.1
- for s in vis
- s[0].x=s[1]-s[3]*s[5]*genzoom
- s[0].y=s[2]-s[4]*s[6]*genzoom
- s[0].x=240-(240-s[1]+s[3])*s[5]*genzoom
- s[0].y=160-(160-s[2]+s[4])*s[6]*genzoom
- s[0].ox=0
- s[0].oy=0
- s[0].zoom_x=s[5]*genzoom
- s[0].zoom_y=s[6]*genzoom
- end
- Graphics.update
- Input.update
- end
- frames.times do
- genzoom-=0.1
- for s in vis
- s[0].x=s[1]-s[3]*s[5]*genzoom
- s[0].y=s[2]-s[4]*s[6]*genzoom
- s[0].x=240-(240-s[1]+s[3])*s[5]*genzoom
- s[0].y=160-(160-s[2]+s[4])*s[6]*genzoom
- s[0].ox=0
- s[0].oy=0
- s[0].zoom_x=s[5]*genzoom
- s[0].zoom_y=s[6]*genzoom
- end
- Graphics.update
- Input.update
- end
- for s in vis
- s[0].x=s[1]
- s[0].y=s[2]
- s[0].ox=s[3]
- s[0].oy=s[4]
- s[0].zoom_x=s[5]
- s[0].zoom_y=s[6]
- end
-end
-
-def pbZoomAndFadeOut(frames=40)
- vis=pbGetVisibleSprites
- for s in vis
- s[0].x=s[1]-s[3]*s[5]
- s[0].y=s[2]-s[4]*s[6]
- s[0].ox=0
- s[0].oy=0
- end
- genzoom=1.0
- alpha=0
- frames.times do
- genzoom+=0.2
- alpha+=255.0/frames
- for s in vis
- s[0].x=s[1]-s[3]*s[5]*genzoom
- s[0].y=s[2]-s[4]*s[6]*genzoom
- s[0].x=240-(240-s[1]+s[3])*s[5]*genzoom
- s[0].y=160-(160-s[2]+s[4])*s[6]*genzoom
- s[0].ox=0
- s[0].oy=0
- s[0].zoom_x=s[5]*genzoom
- s[0].zoom_y=s[6]*genzoom
- s[0].color.set(0,0,0,alpha)
- end
- Graphics.update
- Input.update
- end
- for s in vis
- s[0].x=s[1]
- s[0].y=s[2]
- s[0].ox=s[3]
- s[0].oy=s[4]
- s[0].zoom_x=s[5]
- s[0].zoom_y=s[6]
- s[0].color=s[7]
- end
-end
-
-module Graphics
- @@transition=nil
- STOP_WHILE_TRANSITION = true
- unless defined?(transition_KGC_SpecialTransition)
- class << Graphics
- alias transition_KGC_SpecialTransition transition
- end
- class << Graphics
- alias update_KGC_SpecialTransition update
- end
- end
- def self.transition(duration = 8, filename = "", vague = 20)
- if judge_special_transition(duration,filename)
- duration = 0
- filename=""
- end
- transition_KGC_SpecialTransition(duration, filename, vague)
- if STOP_WHILE_TRANSITION && !@_interrupt_transition
- while @@transition && !@@transition.disposed?
- update
- end
- end
- end
- def self.update
- update_KGC_SpecialTransition
- if @@transition && !@@transition.disposed?
- @@transition.update
- end
- if @@transition && @@transition.disposed?
- @@transition=nil
- end
- end
- def self.judge_special_transition(duration,filename)
- ret=true
- if @_interrupt_transition
- return false
- end
- if @@transition && !@@transition.disposed?
- @@transition.dispose
- @@transition=nil
- end
- dc=File.basename(filename).downcase
- if dc=="splash"
- @@transition=SplashTransition.new(duration)
- elsif dc=="random_stripe_v"
- @@transition=RandomStripeTransition.new(duration,0)
- elsif dc=="random_stripe_h"
- @@transition=RandomStripeTransition.new(duration,1)
- elsif dc=="rotatingpieces"
- @@transition=ShrinkingPieces.new(duration,true)
- elsif dc=="shrinkingpieces"
- @@transition=ShrinkingPieces.new(duration,false)
- elsif dc=="scrolldown"
- @@transition=ScrollScreen.new(duration,2)
- elsif dc=="scrollleft"
- @@transition=ScrollScreen.new(duration,4)
- elsif dc=="scrollright"
- @@transition=ScrollScreen.new(duration,6)
- elsif dc=="scrollup"
- @@transition=ScrollScreen.new(duration,8)
- elsif dc=="scrolldownright"
- @@transition=ScrollScreen.new(duration,3)
- elsif dc=="scrolldownleft"
- @@transition=ScrollScreen.new(duration,1)
- elsif dc=="scrollupleft"
- @@transition=ScrollScreen.new(duration,7)
- elsif dc=="scrollupright"
- @@transition=ScrollScreen.new(duration,9)
- elsif dc=="breakingglass"
- @@transition=BreakingGlass.new(duration)
- elsif dc=="mosaic"
- @@transition=MosaicTransition.new(duration)
- else
- ret=false
- end
- Graphics.frame_reset if ret
- return ret
- end
-end
-
-class BreakingGlass
- def initialize(numframes)
- @disposed=false
- @numframes=numframes
- @opacitychange=(numframes<=0) ? 255 : 255.0/numframes
- cx=6
- cy=5
- @bitmap=Graphics.snap_to_bitmap
- if !@bitmap
- @disposed=true
- return
- end
- width=@bitmap.width/cx
- height=@bitmap.height/cy
- @numtiles=cx*cy
- @sprites=[]
- @offset=[]
- @y=[]
- for i in 0...@numtiles
- @sprites[i]=Sprite.new
- @sprites[i].z=100000
- @sprites[i].bitmap=@bitmap
- @sprites[i].x=width*(i%cx)
- @sprites[i].y=height*(i/cx)
- @sprites[i].src_rect.set(
- @sprites[i].x,@sprites[i].y,width,height)
- @offset[i]=(rand(100)+1)*3.0/100.0
- @y[i]=@sprites[i].y
- end
- end
- def disposed?
- @disposed
- end
- def dispose
- if !disposed?
- @bitmap.dispose
- for i in 0...@numtiles
- @sprites[i].visible=false
- @sprites[i].dispose
- end
- @disposed=true
- end
- end
- def update
- return if disposed?
- continue=false
- for i in 0...@numtiles
- @sprites[i].opacity-=@opacitychange
- @y[i]+=@offset[i]
- @sprites[i].y=@y[i]
- continue=true if @sprites[i].opacity>0
- end
- self.dispose if !continue
- end
-end
-
-class ShrinkingPieces
- def initialize(numframes,rotation)
- @disposed=false
- @rotation=rotation
- @numframes=numframes
- @opacitychange=(numframes<=0) ? 255 : 255.0/numframes
- cx=6
- cy=5
- @bitmap=Graphics.snap_to_bitmap
- if !@bitmap
- @disposed=true
- return
- end
- width=@bitmap.width/cx
- height=@bitmap.height/cy
- @numtiles=cx*cy
- @sprites=[]
- for i in 0...@numtiles
- @sprites[i]=Sprite.new
- @sprites[i].z=200000
- @sprites[i].bitmap=@bitmap
- @sprites[i].ox=width/2
- @sprites[i].oy=height/2
- @sprites[i].x=width*(i%cx)+@sprites[i].ox
- @sprites[i].y=height*(i/cx)+@sprites[i].oy
- @sprites[i].src_rect.set(
- width*(i%cx),height*(i/cx),width,height)
- end
- end
- def disposed?
- @disposed
- end
- def dispose
- if !disposed?
- @bitmap.dispose
- for i in 0...@numtiles
- @sprites[i].visible=false
- @sprites[i].dispose
- end
- @disposed=true
- end
- end
- def update
- return if disposed?
- continue=false
- for i in 0...@numtiles
- @sprites[i].opacity-=@opacitychange
- if @rotation
- @sprites[i].angle+=40
- @sprites[i].angle%=360
- end
- @sprites[i].zoom_x=@sprites[i].opacity/255.0
- @sprites[i].zoom_y=@sprites[i].opacity/255.0
- continue=true if @sprites[i].opacity>0
- end
- self.dispose if !continue
- end
-end
-
-class SplashTransition
- SPLASH_SIZE=32
- def initialize(numframes,vague=9.6)
- @duration=numframes
- @numframes=numframes
- @splash_dir = []
- @disposed=false
- if @numframes<=0
- @disposed=true
- return
- end
- @buffer=Graphics.snap_to_bitmap
- if !@buffer
- @disposed=true
- return
- end
- @sprite = RPG::Sprite.new
- @sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- @sprite.z = 200000
- size = SPLASH_SIZE
- size = [size,1].max
- cells = Graphics.width*Graphics.height / (size ** 2)
- rows = Graphics.width / size
- rect = Rect.new(0, 0, size, size)
- mag = 40.0 / @numframes
- cells.times { |i|
- rect.x = i % rows * size
- rect.y = i / rows * size
- x = rect.x / size - (rows >> 1)
- y = rect.y / size - ((cells / rows) >> 1)
- r = Math.sqrt(x ** 2 + y ** 2) / vague
- @splash_dir[i] = []
- if r != 0
- @splash_dir[i][0] = x / r
- @splash_dir[i][1] = y / r
- else
- @splash_dir[i][0] = x != 0 ? (x * 1.5) : (pmrand * vague)
- @splash_dir[i][1] = y != 0 ? (y * 1.5) : (pmrand * vague)
- end
- @splash_dir[i][0] += (rand - 0.5) * vague
- @splash_dir[i][1] += (rand - 0.5) * vague
- @splash_dir[i][0] *= mag
- @splash_dir[i][1] *= mag
- }
- @sprite.bitmap.blt(0, 0,@buffer,@buffer.rect)
- end
- def disposed?; @disposed; end
- def dispose
- return if disposed?
- @buffer.dispose if @buffer
- @buffer=nil
- @sprite.visible=false
- @sprite.bitmap.dispose
- @sprite.dispose
- @disposed=true
- end
- def update
- return if disposed?
- if @duration==0
- dispose
- else
- size = SPLASH_SIZE
- cells = Graphics.width*Graphics.height / (size ** 2)
- rows = Graphics.width / size
- rect = Rect.new(0, 0, size, size)
- buffer = @buffer
- sprite = @sprite
- phase = @numframes - @duration
- sprite.bitmap.clear
- cells.times { |i|
- rect.x = i % rows * size
- rect.y = i / rows * size
- dx = rect.x + @splash_dir[i][0] * phase
- dy = rect.y + @splash_dir[i][1] * phase
- sprite.bitmap.blt(dx, dy, buffer, rect)
- }
- sprite.opacity = 384 * @duration / @numframes
- @duration-=1
- end
- end
- private
- def pmrand
- return (rand(2) == 0 ? 1 : -1)
- end
-end
-
-class RandomStripeTransition
- RAND_STRIPE_SIZE=2
- def initialize(numframes,direction)
- @duration=numframes
- @numframes=numframes
- @disposed=false
- if @numframes<=0
- @disposed=true
- return
- end
- @buffer=Graphics.snap_to_bitmap
- if !@buffer
- @disposed=true
- return
- end
- @sprite = RPG::Sprite.new
- @sprite.bitmap = Bitmap.new(Graphics.width,Graphics.height)
- @sprite.z = 200000
- ##########
- @direction=direction
- size = RAND_STRIPE_SIZE
- bands = (@direction == 0 ? Graphics.width : Graphics.height) / size
- @rand_stripe_deleted = []
- @rand_stripe_deleted_count = 0
- ary = (0...bands).to_a
- @rand_stripe_index_array = ary.sort_by { rand }
- ##########
- @sprite.bitmap.blt(0, 0,@buffer,@buffer.rect)
- end
- def disposed?; @disposed; end
- def dispose
- return if disposed?
- @buffer.dispose if @buffer
- @buffer=nil
- @sprite.visible=false
- @sprite.bitmap.dispose
- @sprite.dispose
- @disposed=true
- end
- def update
- return if disposed?
- if @duration==0
- dispose
- else
- dir = @direction
- size = RAND_STRIPE_SIZE
- bands = (dir == 0 ? Graphics.width : Graphics.height) / size
- rect = Rect.new(0, 0, (dir == 0 ? size : Graphics.width), (dir == 0 ? Graphics.height : size))
- buffer = @buffer
- sprite = @sprite
- phase = @numframes - @duration
- count = (bands - bands * @duration /
- @numframes) - @rand_stripe_deleted_count
- while count > 0
- @rand_stripe_deleted[@rand_stripe_index_array.pop] = true
- @rand_stripe_deleted_count += 1
- count -= 1
- end
- sprite.bitmap.clear
- bands.times { |i|
- unless @rand_stripe_deleted[i]
- if dir == 0
- rect.x = i * size
- sprite.bitmap.blt(rect.x, 0, buffer, rect)
- else
- rect.y = i * size
- sprite.bitmap.blt(0, rect.y, buffer, rect)
- end
- end
- }
- @duration-=1
- end
- end
-end
-
-class ScrollScreen
- def initialize(numframes,direction)
- @duration=numframes
- @numframes=numframes
- @dir=direction
- @disposed=false
- if @numframes<=0
- @disposed=true
- return
- end
- @buffer=Graphics.snap_to_bitmap
- if !@buffer
- @disposed=true
- return
- end
- @width=@buffer.width
- @height=@buffer.height
- @sprite = RPG::Sprite.new
- @sprite.bitmap = @buffer
- @sprite.z = 200000
- end
- def disposed?; @disposed; end
- def dispose
- return if disposed?
- @buffer.dispose if @buffer
- @buffer=nil
- @sprite.dispose if @sprite
- @disposed=true
- end
- def update
- return if disposed?
- if @duration==0
- dispose
- else
- case @dir
- when 1 # down left
- @sprite.y+=(@buffer.height/@numframes)
- @sprite.x-=(@buffer.width/@numframes)
- when 2 # down
- @sprite.y+=(@buffer.height/@numframes)
- when 3 # down right
- @sprite.y+=(@buffer.height/@numframes)
- @sprite.x+=(@buffer.width/@numframes)
- when 4 # left
- @sprite.x-=(@buffer.width/@numframes)
- when 6 # right
- @sprite.x+=(@buffer.width/@numframes)
- when 7 # up left
- @sprite.y-=(@buffer.height/@numframes)
- @sprite.x-=(@buffer.width/@numframes)
- when 8 # up
- @sprite.y-=(@buffer.height/@numframes)
- when 9 # up right
- @sprite.y-=(@buffer.height/@numframes)
- @sprite.x+=(@buffer.width/@numframes)
- end
- @duration-=1
- end
- end
-end
-
-
-class MosaicTransition
- def initialize(numframes)
- @duration=numframes
- @numframes=numframes
- @disposed=false
- if @numframes<=0
- @disposed=true
- return
- end
- @buffer=Graphics.snap_to_bitmap
- if !@buffer
- @disposed=true
- return
- end
- @width=@buffer.width
- @height=@buffer.height
- @sprite = RPG::Sprite.new
- @sprite.bitmap = @buffer
- @sprite.z = 200000
- @bitmapclone=@buffer.clone
- @bitmapclone2=@buffer.clone
- end
- def disposed?; @disposed; end
- def dispose
- return if disposed?
- @buffer.dispose if @buffer
- @buffer=nil
- @sprite.dispose if @sprite
- @disposed=true
- end
- def update
- return if disposed?
- if @duration==0
- dispose
- else
- @bitmapclone2.stretch_blt(
- Rect.new(0,0,@buffer.width*@duration/@numframes,
- @buffer.height*@duration/@numframes),@bitmapclone,
- Rect.new(0,0,@buffer.width,@buffer.height))
- @buffer.stretch_blt(
- Rect.new(0,0,@buffer.width,@buffer.height),@bitmapclone2,
- Rect.new(0,0,@buffer.width*@duration/@numframes,
- @buffer.height*@duration/@numframes))
- @duration-=1
- end
- end
-end
-
-class Game_Temp
- attr_accessor :fadestate
- def fadestate
- return @fadestate ? @fadestate : 0
- end
-end
-
-def pbPushFade
- $game_temp.fadestate=[$game_temp.fadestate+1,0].max
-end
-def pbPopFade
- $game_temp.fadestate=[$game_temp.fadestate-1,0].max
-end
-def pbIsFaded?
- return $game_temp.fadestate>0
-end
-
-=begin
-pbFadeOutIn(z) { block }
-Fades out the screen before a block is run and fades it back in
-after the block exits. z indicates the z-coordinate of the viewport
-used for this effect
-=end
-
-def pbFadeOutIn(z)
- col=Color.new(0,0,0,0)
- viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- viewport.z=z
- for j in 0..17
- col.set(0,0,0,j*15)
- viewport.color=col
- Graphics.update
- Input.update
- end
- pbPushFade
- yield if block_given?
- pbPopFade
- for j in 0..17
- col.set(0,0,0,(17-j)*15)
- viewport.color=col
- Graphics.update
- Input.update
- end
- viewport.dispose
-end
-
-def pbFadeOutAndHide(sprites)
- visiblesprites={}
- for j in 0..26
- for i in sprites
- next if !i[1]
- next if pbDisposed?(i[1])
- if i[1].is_a?(Sprite) || i[1].is_a?(Window)
- i[1].update
- elsif i[1].is_a?(Plane)
- begin
- i[1].update
- rescue NoMethodError
- end
- end
- next if pbDisposed?(i[1])
- i[1].color.red=0
- i[1].color.green=0
- i[1].color.blue=0
- i[1].color.alpha=j*10
- i[1].color=i[1].color
- end
- Graphics.update
- Input.update
- end
- for i in sprites
- next if !i[1]
- next if pbDisposed?(i[1])
- visiblesprites[i[0]]=true if i[1].visible
- i[1].visible=false
- end
- return visiblesprites
-end
-
-def pbFadeInAndShow(sprites,visiblesprites=nil)
- if visiblesprites
- for i in visiblesprites
- if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
- sprites[i[0]].visible=true
- end
- end
- end
- for j in 0..26
- for i in sprites
- next if !i[1]
- next if pbDisposed?(i[1])
- if i[1].is_a?(Sprite) || i[1].is_a?(Window)
- i[1].update
- elsif i[1].is_a?(Plane)
- begin
- i[1].update
- rescue NoMethodError
- end
- end
- next if pbDisposed?(i[1])
- i[1].color.red=0
- i[1].color.green=0
- i[1].color.blue=0
- i[1].color.alpha=((26-j)*10)
- next if pbDisposed?(i[1])
- i[1].color=i[1].color
- end
- Graphics.update
- Input.update
- end
-end
-
-def addBackgroundPlane(sprites,planename,background,viewport=nil)
- begin
- bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{background}")
- rescue
- return
- end
- sprites[planename]=Plane.new(viewport)
- sprites[planename].bitmap=bitmap
- for spr in sprites.values
- if spr.is_a?(Window)
- spr.windowskin=nil
- end
- end
-end
-
-def addBackgroundOrColoredPlane(sprites,planename,background,color,viewport=nil)
- begin
- bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{background}")
- sprites[planename]=Plane.new(viewport)
- sprites[planename].bitmap=bitmap
- rescue
- sprites[planename]=ColoredPlane.new(color,@viewport)
- end
-end
-
-
-def pbSetSystemFont(bitmap)
- bitmap.font.name=[$VersionStyles[pbGetSystemFont][0],"Arial Narrow","Arial"]
- if pbGetSystemFont==2
- bitmap.font.size=29
- else
- bitmap.font.size=31
- end
-end
-def pbSetSmallFont(bitmap)
- bitmap.font.name=["Pokemon Emerald Small","Arial Narrow","Arial"]
- bitmap.font.size=25
-end
-def pbSetNarrowFont(bitmap)
- bitmap.font.name=["Pokemon Emerald Narrow","Arial Narrow","Arial"]
- bitmap.font.size=31
-end
-
- def getLineBrokenTextEx(bitmap,value,width,numlines,dims,escaped=false)
- x=0
- ret=""
- if dims
- dims[0]=0
- dims[1]=0
- end
- return ret if !bitmap || bitmap.disposed? || width<=0
- textmsg=value.clone
- lines=0
- while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil)
- break if c==""
- ccheck=c
- if escaped
- ccheck=c.gsub(/\\\[[^\]]*\]/,"")
- end
- if ccheck=="\n"
- x=0
- lines+=1
- ret+="\1" if lines>=numlines # "\1" means to pause the message
- ret+="\n"
- next
- end
- textwidth=bitmap.text_size(ccheck).width
- a=x+textwidth
- b=width-2
- if x>0 && x+textwidth>=width-2 # minus window trim minus shadow
- x=0
- lines+=1
- ret+="\1" if lines>=numlines
- ret+="\n"
- end
- ret+=c
- x+=textwidth
- dims[0]=x if dims && dims[0]0 && y>=maxlines
- x = 0
- next
- end
- width=bitmap.text_size(textchars[i]).width
- textx=x+xDst
- texty=(32*y)+yDst
- if shadowColor
- bitmap.font.color=shadowColor
- pbDrawShadow(bitmap,textx,texty,width+2,32,textchars[i])
- end
- bitmap.font.color=baseColor
- bitmap.draw_text(textx,texty,width+2,32,textchars[i])
- totalwidth+=width
- x+=width
- end
- end
-
-def colorToRgb16(color)
- ret=(color.red.to_i>>3)
- ret|=((color.green.to_i>>3)<<5)
- ret|=((color.blue.to_i>>3)<<10)
- return sprintf("%04X",ret)
-end
-
-def ctag(color)
- ret=(color.red.to_i<<24)
- ret|=((color.green.to_i)<<16)
- ret|=((color.blue.to_i)<<8)
- ret|=((color.alpha.to_i))
- return sprintf("",ret)
-end
-
-def RgbToColor(param)
- baseint=param.to_i(16)
- if param.length==8 # 32-bit hex
- return Color.new(
- (baseint>>24)&0xFF,
- (baseint>>16)&0xFF,
- (baseint>>8)&0xFF,
- (baseint)&0xFF
- )
- elsif param.length==6 # 24-bit hex
- return Color.new(
- (baseint>>16)&0xFF,
- (baseint>>8)&0xFF,
- (baseint)&0xFF
- )
- elsif param.length==4 # 16-bit hex
- return Color.new(
- ((baseint)&0x1F)<<3,
- ((baseint>>5)&0x1F)<<3,
- ((baseint>>10)&0x1F)<<3
- )
- elsif param.length==1 # Color number
- i=param.to_i
- return Font.default_color if i>=8
- return [
- Color.new(255, 255, 255, 255),
- Color.new(128, 128, 255, 255),
- Color.new(255, 128, 128, 255),
- Color.new(128, 255, 128, 255),
- Color.new(128, 255, 255, 255),
- Color.new(255, 128, 255, 255),
- Color.new(255, 255, 128, 255),
- Color.new(192, 192, 192, 255)
- ][i]
- else
- return Font.default_color
- end
-end
-
-def Rgb16ToColor(param)
- baseint=param.to_i(16)
- return Color.new(
- ((baseint)&0x1F)<<3,
- ((baseint>>5)&0x1F)<<3,
- ((baseint>>10)&0x1F)<<3
- )
-end
-
-class Color
- def inspect
- return [self.red.to_i,self.green.to_i,self.blue.to_i].inspect
- end
-end
-
-def getLastParam(array,default)
- i=array.length-1
- while i>=0
- return array[i] if array[i]
- i-=1
- end
- return default
-end
-
-=begin
-
-Formats a string of text and returns an array containing a list
-of formatted characters.
-
-Parameters:
-bitmap: Source bitmap. Will be used to determine the default font of the text.
-xDst: X coordinate of the text's top left corner.
-yDst: Y coordinate of the text's top left corner.
-widthDst: Width of the text. Used to determine line breaks.
-heightDst: Height of the text. If -1, there is no height restriction. If 1
- or greater, any characters exceeding the height are removed from the returned
- list.
-newLineBreaks: If true, newline characters will be treated as line breaks.
- The default is true.
-
-Return Values:
-A list of formatted characters. Returns an empty array if _bitmap_ is nil
-or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0.
-
-Formatting Specification:
-This function uses the following syntax when formatting the text.
- ... - Formats the text in bold.
- ... - Formats the text in italics.
- ... - Underlines the text.
- ... - Draws a strikeout line over the text.
- - Right-aligns the text until the next line break.
-
- Causes a line break.
- ... - Color specification. A total of four formats are supported:
- RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers.
- ... - Color specification where the first half is the base color and
- the second half is the shadow color. 16-bit RGB is supported.
- ... - Formats the text in the specified font, or Arial
- if the font doesn't exist.
- ... - Changes the font size to X.
- ... - Centers the text. Causes line breaks before and
- after the text.
- ... - Left-aligns the text. Causes line breaks before and
- after the text.
- ... - Right-aligns the text. Causes line breaks before and
- after the text.
- - Displays the icon X (in Graphics/Icons/).
-In addition, the syntax supports the following:
-' - Converted to "'".
-< - Converted to "<".
-> - Converted to ">".
-& - Converted to "&".
-" - Converted to double quotation mark.
-
-
-To draw the characters, pass the returned array to the
-_drawFormattedChars_ function.
-=end
-def getFormattedText(
- bitmap,xDst,yDst,widthDst,heightDst,text,newlineBreaks=true)
- if !bitmap||bitmap.disposed?||widthDst<=0||heightDst==0
- return []
- end
- numchars=0
- x=y=0
- characters=[]
- charactersInternal=[]
- textchunks=[]
- controls=[]
- charsonline=0
- while text[/<(\/?)([Cc]|[Cc][2]|[Ff][Nn]|[Bb][Rr]|[Ff][Ss]|[Ii]|[Bb]|[Uu]|[Ss]|[Ii][Cc][Oo][Nn]|[Aa][Cc]|[Aa][Rr]|[Aa][Ll]|[Rr])(\s*\=\s*([^>]*))?>/]
- textchunks.push($~.pre_match)
- if $~[3]
- controls.push([$~[2].downcase,$~[4],-1,$~[1]=="/" ? true : false])
- else
- controls.push([$~[2].downcase,"",-1,$~[1]=="/" ? true : false])
- end
- text=$~.post_match
- end
- textchunks.push(text)
- for chunk in textchunks
- chunk.gsub!(/</,"<")
- chunk.gsub!(/>/,">")
- chunk.gsub!(/'/,"'")
- chunk.gsub!(/"/,"\"")
- chunk.gsub!(/&/,"&")
- end
- textlen=0
- for i in 0...controls.length
- textlen+=textchunks[i].scan(/./m).length
- controls[i][2]=textlen
- end
- text=textchunks.join("")
- textchars=text.scan(/./m)
- colorstack=[]
- boldcount=0
- italiccount=0
- underlinecount=0
- strikecount=0
- rightalign=0
- oldfont=bitmap.font.clone
- fontname=bitmap.font.name.clone
- fontsize=bitmap.font.size
- defaultcolors=[bitmap.font.color.clone,nil]
- if fontname.is_a?(Array)
- fontname.push("Arial")
- else
- fontname=[fontname,"Arial"]
- end
- alignstack=[]
- lastword=[0,0] # position of last word
- hadspace=false
- hadnonspace=false
- position=0;while position0 && nextline==0
- else
- alignstack.pop;
- nextline=1 if x>0 && nextline==0
- end
- elsif control=="al" # Left align
- if !endtag
- alignstack.push(0)
- nextline=1 if x>0 && nextline==0
- else
- alignstack.pop;
- nextline=1 if x>0 && nextline==0
- end
- elsif control=="ac" # Center align
- if !endtag
- alignstack.push(2)
- nextline=1 if x>0 && nextline==0
- else
- alignstack.pop;
- nextline=1 if x>0 && nextline==0
- end
- elsif control=="icon" # Icon
- if !endtag
- param=param.sub(/\s+$/,"")
- graphic="Graphics/Icons/#{param}"
- end
- elsif control=="br" # Line break
- if !endtag
- nextline+=1
- end
- elsif control=="r" # Right align this line
- if !endtag
- x=0
- rightalign=1;lastword=[characters.length,x]
- end
- end
- controls[i]=nil
- end
- end
- bitmap.font.bold=(boldcount>0)
- bitmap.font.italic=(italiccount>0)
- if graphic
- tempgraphic=Bitmap.new(graphic)
- width=tempgraphic.width+8
- yStart=4
- xStart=[(32-tempgraphic.height)/2,0].max
- tempgraphic.dispose
- else
- yStart=0
- xStart=0
- width=bitmap.text_size(textchars[position]).width
- end
- if rightalign==1 && nextline==0
- alignment=1
- else
- alignment=getLastParam(alignstack,0)
- end
- nextline.times do
- characters.push(["\n",x,y*32+yDst,0,32,
- false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8])
- charactersInternal.push([alignment,y,0])
- y+=1;
- x=0;
- rightalign=0;
- lastword=[characters.length,x]
- hadspace=false
- hadnonspace=false
- end
- if textchars[position]=="\n"
- if newlineBreaks
- if nextline==0
- characters.push(["\n",x,y*32+yDst,0,32,
- false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8])
- charactersInternal.push([alignment,y,0])
- y+=1
- x=0
- end
- rightalign=0
- hadspace=true
- hadnonspace=false
- position+=1
- next
- else
- textchars[position]=" "
- if !graphic
- width=bitmap.text_size(textchars[position]).width
- end
- end
- end
- isspace=(textchars[position][/\s/]) ? true : false
- if hadspace && !isspace
- # set last word to here
- lastword[0]=characters.length
- lastword[1]=x
- hadspace=false
- hadnonspace=true
- elsif isspace
- hadspace=true
- end
- textx=x+xStart
- texty=(32*y)+yDst+yStart
- colors=getLastParam(colorstack,defaultcolors)
- oldx=x
- # Push character, textx will be calculated later
- if heightDst<0 || texty+yStart0),(italiccount>0),colors[0],colors[1],
- (underlinecount>0),(strikecount>0),fontname,fontsize])
- charactersInternal.push([alignment,y,xStart])
- end
- x+=width
- if x+2>widthDst && lastword[1]!=0 && (!hadnonspace || !hadspace)
- characters.insert(lastword[0],["\n",x,y*32+yDst,0,32,
- false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8])
- charactersInternal.insert(lastword[0],[alignment,y,0])
- lastword[0]+=1
- y+=1
- x=0
- for i in lastword[0]...characters.length
- characters[i][2]+=32
- charwidth=characters[i][3]-2
- characters[i][1]=x+charactersInternal[i][2]
- x+=charwidth
- end
- lastword[1]=0
- end
- position+=1 if !graphic
- end
- # Eliminate spaces before newlines and pause character
- firstspace=-1
- for i in 0...characters.length
- if characters[i][5]!=false # If not a character
- firstspace=-1
- elsif (characters[i][0]=="\n" || characters[i][0]=="\1") &&
- firstspace>=0
- for j in firstspace...i
- characters[j]=nil
- end
- firstspace=-1
- elsif characters[i][0][/[ \r\t]/] && firstspace<0
- firstspace=i
- else
- firstspace=-1
- end
- end
- if firstspace>0
- for j in firstspace...characters.length
- characters[j]=nil
- end
- end
- characters.compact!
- # Calculate Xs based on alignment
- # First, find all text runs with
- # the same alignment on the same line
- totalwidth=0
- widthblocks=[]
- lastalign=0
- lasty=0
- runstart=0
- for i in 0...characters.length
- c=characters[i]
- if i>0 && (charactersInternal[i][0]!=lastalign ||
- charactersInternal[i][1]!=lasty)
- # Found end of run
- widthblocks.push([runstart,i,lastalign,totalwidth])
- runstart=i
- totalwidth=0
- end
- lastalign=charactersInternal[i][0]
- lasty=charactersInternal[i][1]
- totalwidth+=c[3]-2
- end
- widthblocks.push([runstart,characters.length,lastalign,totalwidth])
- # Now, based on the text runs found,
- # recalculate Xs
- for block in widthblocks
- next if block[0]>=block[1]
- for i in block[0]...block[1]
- case block[2]
- when 1;characters[i][1]=xDst+(widthDst-block[3]-4)+characters[i][1]
- when 2;characters[i][1]=xDst+((widthDst/2)-(block[3]/2))+characters[i][1]
- else;characters[i][1]=xDst+characters[i][1]
- end
- end
- end
- # Remove all characters with Y
- # greater or equal to _heightDst_
- if heightDst>=0
- for i in 0...characters.length
- if characters[i][2]>=heightDst
- characters[i]=nil
- end
- end
- characters.compact!
- end
- bitmap.font=oldfont
- return characters
-end
-
-def drawFormattedChars(bitmap,chars)
- if chars.length==0||!bitmap||bitmap.disposed?
- return
- end
- oldfont=bitmap.font.clone
- for ch in chars
- if ch[5] # If a graphic
- graphic=Bitmap.new(ch[0])
- bitmap.blt(ch[1], ch[2], graphic,graphic.rect,ch[8].alpha)
- graphic.dispose
- elsif ch[0]!="\n"
- bitmap.font.bold=ch[6]
- bitmap.font.italic=ch[7]
- if bitmap.font.size!=ch[13]
- bitmap.font.size=ch[13]
- end
- if bitmap.font.name!=ch[12]
- bitmap.font.name=ch[12]
- end
- if ch[9] # shadow
- bitmap.font.color=ch[9]
- pbDrawShadow(bitmap,ch[1],ch[2],ch[3],ch[4],ch[0])
- end
- bitmap.font.color=ch[8]
- bitmap.draw_text(ch[1],ch[2],ch[3],ch[4],ch[0])
- if ch[10] # underline
- bitmap.fill_rect(ch[1],ch[2]+32-[(32-bitmap.font.size)/2,0].max-2,
- ch[3]-2,2,ch[8])
- end
- if ch[11] # strikeout
- bitmap.fill_rect(ch[1],ch[2]+16,ch[3]-2,2,ch[8])
- end
- end
- end
- bitmap.font=oldfont
-end
-
-def drawTextEx(bitmap,x,y,width,numlines,text,baseColor,shadowColor)
- normtext=getLineBrokenTextEx(bitmap,text,width,numlines,nil)
- renderLineBrokenText(bitmap,x,y,normtext,baseColor,shadowColor,numlines)
-end
-
-def drawColoredTextEx(bitmap,x,y,width,text,baseColor=nil,shadowColor=nil)
- base=!baseColor ? Color.new(12*8,12*8,12*8) : baseColor.clone
- shadow=!shadowColor ? Color.new(26*8,26*8,25*8) : shadowColor.clone
- text.gsub!(/&/,"&")
- text.gsub!(/,"<")
- text.gsub!(/>/,">")
- text=text.gsub(/\\\[([A-Fa-f0-9]{8,8})\]/){ "" }
- text=""+text
- text.gsub!(/\\\\/,"\\")
- chars=getFormattedText(bitmap,x,y,width,-1,text)
- drawFormattedChars(bitmap,chars)
-end
-
-def drawFormattedTextOnWindow(window,text)
- chars=getFormattedText(
- window.contents,0,0,window.width-32,window.height-32,text)
- drawFormattedChars(window.contents,chars)
-end
-
+#########################################################################
@@ -2688,13 +1574,0 @@
- def pbEnsureBitmap(bitmap,dwidth,dheight)
- if !bitmap||bitmap.disposed?||bitmap.widthGraphics.height-32
+ windowheight+=self.borderY
+ if !width || width<0
+ width=0
+ tmpbitmap=Bitmap.new(1,1)
+ pbSetSystemFont(tmpbitmap)
+ for i in commands
+ width=[width,textWidth(tmpbitmap,i)].max
+ end
+ width+=64
+ tmpbitmap.dispose
+ else
+ width=[33,width].max
+ end
+ dims[0]=width
+ dims[1]=windowheight
+ end
+ def initialize(commands,width=nil)
+ @starting=true
+ @commands=commands
+ dims=[]
+ getAutoDims(commands,dims,width)
+ super(0,0,dims[0],dims[1])
+ @item_max=commands.length
+ @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png")
+ self.active=true
+ @baseColor=Color.new(12*8,12*8,12*8)
+ @shadowColor=Color.new(26*8,26*8,25*8)
+ self.index=0
+ refresh
+ @starting=false
+ end
+ def self.newEmpty(x,y,width,height,viewport=nil)
+ ret=self.new([],width)
+ ret.x=x
+ ret.y=y
+ ret.width=width
+ ret.height=height
+ ret.viewport=viewport
+ return ret
+ end
+ def index=(value)
+ super
+ refresh if !@starting
+ end
+ def commands=(value)
+ @commands=value
+ @item_max=commands.length
+ self.update_cursor_rect
+ self.refresh
+ end
+ def width=(value)
+ oldvalue=self.width
+ super
+ if !@starting && oldvalue!=value
+ self.index=self.index
+ self.update_cursor_rect
+ end
+ end
+ def height=(value)
+ oldvalue=self.height
+ super
+ if !@starting && oldvalue!=value
+ self.index=self.index
+ self.update_cursor_rect
+ end
+ end
+ def resizeToFit(text,maxwidth=-1)
+ dims=resizeToFitInternal(text,maxwidth)
+ self.width=dims[0]+self.borderX+2+6
+ self.height=dims[1]+self.borderY
+ end
+ def resizeToFit(commands)
+ dims=[]
+ getAutoDims(commands,dims)
+ self.width=dims[0]
+ self.height=dims[1]
+ end
+ def dispose
+ @selarrow.dispose
+ super
+ end
+ def baseColor=(value)
+ @baseColor=value
+ refresh
+ end
+ def shadowColor=(value)
+ @shadowColor=value
+ refresh
+ end
+ def refresh
+ dwidth=self.width-self.borderX
+ dheight=self.height-self.borderY
+ self.contents=pbEnsureBitmap(self.contents,dwidth,dheight)
+ self.contents.clear
+ contentsWidth=self.contents.width
+ ypos=0
+ firstcmd=self.top_row
+ lastcmd=[self.top_row+self.page_row_max,@commands.length].min
+ preamble=shadowctag(@baseColor,@shadowColor)
+ for i in firstcmd...lastcmd
+ if iself.top_row+self.page_row_max
+ next
+ end
+ self.contents.blt(0,ypos,@selarrow,@selarrow.rect) if self.index==i
+ chars=getFormattedText(
+ self.contents,16,ypos,contentsWidth,32,preamble+@commands[i],32,true,true)
+ drawFormattedChars(self.contents,chars)
+ ypos+=32
+ end
+ end
+ def update
+ oldindex=self.index
+ super
+ refresh if self.index!=oldindex
+ end
+end
+
+
+class Window_FormattedTextPokemonOld < SpriteWindow_Base
+ attr_reader :text
+ def text=(value)
+ @text=value
+ refresh
+ end
+ def initialize(text)
+ super(0,0,33,33)
+ self.contents=Bitmap.new(1,1)
+ pbSetSystemFont(self.contents)
+ resizeToFit(text)
+ @text=text
+ refresh
+ end
+ def self.newWithSize(text,x,y,width,height,viewport=nil)
+ ret=self.new(text)
+ ret.x=x
+ ret.y=y
+ ret.width=width
+ ret.height=height
+ ret.viewport=viewport
+ return ret
+ end
+ def resizeToFitInternal(text,maxwidth)
+ dims=[0,0]
+ cwidth=maxwidth<0 ? Graphics.width : maxwidth
+ chars=getFormattedText(self.contents,0,0,cwidth,-1,text,32)
+ for ch in chars
+ dims[0]=[dims[0],ch[1]+ch[3]].max
+ dims[1]=[dims[1],ch[2]+ch[4]].max
+ end
+ return dims
+ end
+ def resizeToFit(text,maxwidth=-1)
+ dims=resizeToFitInternal(text,maxwidth)
+ self.width=dims[0]+self.borderX+2+6
+ self.height=dims[1]+self.borderY
+ end
+ def resizeHeightToFit(text,width=-1)
+ dims=resizeToFitInternal(text,width)
+ self.width=width<0 ? Graphics.width : width
+ self.height=dims[1]+self.borderY
+ end
+ def refresh
+ self.contents=pbEnsureBitmap(self.contents,self.width-32,self.height-32)
+ self.contents.clear
+ chars=getFormattedText(self.contents,0,0,
+ self.contents.width,self.contents.height,""+@text,32)
+ drawFormattedChars(self.contents,chars)
+ end
+end
+
+class Window_AdvancedTextPokemon < SpriteWindow_Base
@@ -2734,1 +1796,0 @@
- attr_reader :position
@@ -2736,0 +1797,3 @@
+ setText(value)
+ end
+ def setText(value)
@@ -2738,0 +1802,1 @@
+ oldtext=@text
@@ -2739,2 +1804,1 @@
- @normtext=getLineBrokenText(value)
- @textchars=@normtext.scan(/./m)
+ @textlength=unformattedTextLength(value)
@@ -2745,1 +1809,50 @@
- prerenderText
+ @textchars=[]
+ width=1
+ height=1
+ numlines=0
+ visiblelines=(self.height-self.borderY)/32
+ if value.length==0
+ @fmtchars=[]
+ @bitmapwidth=width
+ @bitmapheight=height
+ @numtextchars=0
+ else
+ if !@letterbyletter
+ @fmtchars=getFormattedText(self.contents,0,0,
+ self.width-self.borderX,-1,
+ shadowctag(@baseColor,@shadowColor)+value,32,true)
+ for ch in @fmtchars
+ chx=ch[1]+ch[3]
+ chy=ch[2]+ch[4]
+ width=chx if width=visiblelines
+ fclone=ch.clone
+ fclone[0]="\1"
+ @fmtchars.push(fclone)
+ @textchars.push("\1")
+ end
+ end
+ @fmtchars.push(ch)
+ @textchars.push(ch[5] ? "" : ch[0])
+ end
+ fmt.clear
+ end
+ @bitmapwidth=width
+ @bitmapheight=height
+ @numtextchars=@textchars.length
+ end
@@ -2747,2 +1860,2 @@
- @displaying=self.letterbyletter
- self.contents.clear
+ @displaying=@letterbyletter
+ @needclear=true
@@ -2780,3 +1893,1 @@
- @pausesprite.dispose
- @bufferbitmap.dispose if @bufferbitmap
- @buffercontents.dispose if @buffercontents
+ @pausesprite.dispose if @pausesprite
@@ -2784,2 +1895,0 @@
- @bufferbitmap=nil
- @buffercontents=nil
@@ -2799,7 +1908,3 @@
- @pausesprite=AnimatedSprite.new("Graphics/Pictures/pause.png",4,14,27,3)
- @pausesprite.z=100000
- @pausesprite.visible=false
- @buffercontents=nil
- self.contents=Bitmap.new(
- [self.width-self.borderX,1].max,
- [self.height-self.borderY,1].max)
+ @pausesprite=nil
+ @text=""
+ self.contents=Bitmap.new(1,1)
@@ -2826,1 +1931,0 @@
- refresh
@@ -2833,10 +1937,11 @@
- refresh
- end
- end
- def getLineBrokenTextEx(value,width,dims)
- width=self.width if width<0
- return Kernel.getLineBrokenTextEx(self.contents,value,width-self.borderX,
- (self.height-self.borderY)/32,dims,false)
- end
- def getLineBrokenText(value)
- return getLineBrokenTextEx(value,self.width,nil)
+ end
+ end
+ def resizeToFitInternal(text,maxwidth)
+ dims=[0,0]
+ cwidth=maxwidth<0 ? Graphics.width : maxwidth
+ chars=getFormattedTextForDims(self.contents,0,0,cwidth,-1,text,32)
+ for ch in chars
+ dims[0]=[dims[0],ch[1]+ch[3]].max
+ dims[1]=[dims[1],ch[2]+ch[4]].max
+ end
+ return dims
@@ -2845,32 +1950,16 @@
- dims=[]
- getLineBrokenTextEx(text,maxwidth,dims)
- self.width=dims[0]+self.borderX+2+6
- self.height=dims[1]+self.borderY
- end
- def resizeHeightToFit(text,width=640)
- dims=[]
- getLineBrokenTextEx(text,width,dims)
- self.width=width
- self.height=dims[1]+self.borderY
- end
- def startPause
- @pausesprite.visible=true
- @pausesprite.frame=0
- @pausesprite.start
- end
- def stopPause
- @pausesprite.stop
- @pausesprite.visible=false
- end
- def pbEnsureBitmap(bitmap,dwidth,dheight)
- if !bitmap||bitmap.disposed?||bitmap.width=@fmtchars.length
+ if !self.letterbyletter
+ next if @fmtchars[i][1]>=maxX
+ next if @fmtchars[i][2]>=maxY
+ end
+ drawSingleFormattedChar(self.contents,@fmtchars[i])
+ end
+ if numchars>0 && numchars!=@numtextchars && @textchars[numchars]=="\1"
+ fch=@fmtchars[numchars-1]
+ if fch
+ rcdst=Rect.new(fch[1],fch[2],fch[3],fch[4])
+ allocPause
+ @pausesprite.x=self.x+self.startX+rcdst.x+rcdst.width-2
+ @pausesprite.y=self.y+self.startY+rcdst.y-@scrollY
+ end
+ end
@@ -2892,18 +2005,0 @@
- for i in startchar...numchars
- next if !@chardst[i]
- rc=@charsrc[i]
- rcdst=@chardst[i]
- next if rcdst.y-@scrollY+rcdst.height<0
- next if rcdst.x+rcdst.width<0
- rcsrc.set(rc.x,rc.y,rc.width,rc.height)
- pbBltShadow(dstbitmap,rcdst.x,rcdst.y-@scrollY,@bufferbitmap,rcsrc)
- rcsrc.set(rc.x,rc.y+32,rc.width,rc.height)
- dstbitmap.blt(rcdst.x,rcdst.y-@scrollY,@bufferbitmap,rcsrc)
- end
- if numchars>0 && numchars!=@numtextchars && @textchars[numchars]=="\1"
- rcdst=@chardst[numchars-1]
- if rcdst
- @pausesprite.x=self.x+self.startX+rcdst.x+rcdst.width
- @pausesprite.y=self.y+self.startY+rcdst.y-@scrollY
- end
- end
@@ -2912,9 +2007,5 @@
- return @drawncurchar
- end
- def curcharSkip(skip)
- skip.times do
- @curchar+=1
- break if @textchars[@curchar]=="\n" ||
- @textchars[@curchar]=="\1" ||
- @textchars[@curchar]==nil
- end
+ if @drawncurchar>=@fmtchars.length
+ fch=@textlength
+ else
+ fch=@fmtchars[@drawncurchar][14]
+ end
@@ -2923,1 +2014,4 @@
- @pausesprite.update if @pausesprite.visible
+ super
+ if @pausesprite && @pausesprite.visible
+ @pausesprite.update
+ end
@@ -2978,0 +2072,19 @@
+ def allocPause
+ if !@pausesprite
+ @pausesprite=AnimatedSprite.new("Graphics/Pictures/pause.png",4,14,27,3)
+ @pausesprite.z=100000
+ @pausesprite.visible=false
+ end
+ end
+ def startPause
+ allocPause
+ @pausesprite.visible=true
+ @pausesprite.frame=0
+ @pausesprite.start
+ end
+ def stopPause
+ if @pausesprite
+ @pausesprite.stop
+ @pausesprite.visible=false
+ end
+ end
@@ -2979,41 +2092,14 @@
- def prerenderText
- @charsrc=[]
- @chardst=[]
- textchars=@normtext.scan(/./m)
- numchars=0
- x=y=0
- totalwidth=0
- @numtextchars=textchars.length
- for i in 0...@numtextchars
- if textchars[i]=="\n"
- y += 1
- x = 0
- next
- end
- width=self.contents.text_size(textchars[i]).width
- textx=x # +6
- texty=(32*y) # +2
- @chardst[i]=Rect.new(textx,texty,width,32)
- @charsrc[i]=Rect.new(totalwidth,0,width,32)
- totalwidth+=width
- x+=width
- end
- @bufferbitmap=pbEnsureBitmap(@bufferbitmap,totalwidth,64)
- @bufferbitmap.clear
- @bufferbitmap.font=self.contents.font
- @bufferbitmap.font.color=self.shadowColor
- for i in 0...@numtextchars
- rc=@charsrc[i]
- next if !rc
- @bufferbitmap.draw_text(rc.x,rc.y,rc.width+2,rc.height,textchars[i])
- end
- @bufferbitmap.font.color=self.baseColor
- for i in 0...@numtextchars
- rc=@charsrc[i]
- next if !rc
- @bufferbitmap.draw_text(rc.x,rc.y+32,rc.width+2,rc.height,textchars[i])
- end
- end
-end
-
-class Window_ColoredTextPokemon < Window_SimpleTextPokemon
+ def curcharSkip(skip)
+ skip.times do
+ @curchar+=1
+ break if @textchars[@curchar]=="\n" ||
+ @textchars[@curchar]=="\1" ||
+ @textchars[@curchar]==nil
+ end
+ end
+end
+
+class Window_FormattedTextPokemon < Window_AdvancedTextPokemon
+end
+
+class Window_SimpleTextPokemon < Window_AdvancedTextPokemon
@@ -3021,112 +2107,7 @@
- @curchar=0
- @drawncurchar=-1
- @text=value
- @normtext=getLineBrokenTextEx(value,self.width,nil)
- @textchars=@normtext.gsub(/\\\[[^\]]*\]/,"").scan(/./m)
- @scrollstate=0
- @scrollY=0
- @linesdrawn=0
- @realframes=0
- prerenderText
- stopPause
- @displaying=self.letterbyletter
- self.contents.clear
- refresh
- end
- def getLineBrokenTextEx(value,width,dims)
- width=self.width if width<0
- return Kernel.getLineBrokenTextEx(self.contents,value,width-self.borderX,
- (self.height-self.borderY)/32,dims,true)
- end
- private
- def pbEnsureBitmap(bitmap,dwidth,dheight)
- if !bitmap||bitmap.disposed?||bitmap.width>5)&0x1F)<<3,
- ((baseint>>10)&0x1F)<<3
- )
- shadow.set(
- (shadowint&0x1F)<<3,
- ((shadowint>>5)&0x1F)<<3,
- ((shadowint>>10)&0x1F)<<3
- )
- i+=11
- next
- end
- if textchars[i]=="\n"
- @normtext+=textchars[i]
- @chardst.push(nil)
- @charsrc.push(nil)
- basecolors.push(nil)
- shadowcolors.push(nil)
- y += 1
- x = 0
- i+=1
- next
- end
- width=self.contents.text_size(textchars[i]).width
- textx=x # +6
- texty=(32*y) # +2
- @normtext+=textchars[i]
- @chardst.push(Rect.new(textx,texty,width,32))
- @charsrc.push(Rect.new(totalwidth,0,width,32))
- basecolors.push(base)
- shadowcolors.push(shadow)
- totalwidth+=width
- x+=width
- i+=1
- end
- textchars=@normtext.scan(/./m)
- @numtextchars=textchars.length
- @bufferbitmap=pbEnsureBitmap(@bufferbitmap,totalwidth,64)
- @bufferbitmap.clear
- @bufferbitmap.font=self.contents.font
- for i in 0...@numtextchars
- rc=@charsrc[i]
- next if !rc
- @bufferbitmap.font.color=shadowcolors[i]
- @bufferbitmap.draw_text(rc.x,rc.y,rc.width+2,rc.height,textchars[i])
- end
- @bufferbitmap.font.color=base
- for i in 0...@numtextchars
- rc=@charsrc[i]
- next if !rc
- @bufferbitmap.font.color=basecolors[i]
- @bufferbitmap.draw_text(rc.x,rc.y+32,rc.width+2,rc.height,textchars[i])
- end
+ super(fmtescape(value))
+ end
+end
+
+class Window_ColoredTextPokemon < Window_AdvancedTextPokemon
+ def text=(value)
+ super(coloredToFormattedText(value))
Changed: PokemonSystem
@@ -1,1 +1,0 @@
-
@@ -58,6 +57,0 @@
-def pbDebugF7
- if $DEBUG
- $Trainer.party[0].hp=0
- end
-end
-
@@ -75,3 +68,0 @@
- if trigger?(Input::F7)
- pbDebugF7
- end
Changed: PokemonUtilities
@@ -198,0 +198,12 @@
+end
+
+
+def pbFirstAblePokemon(variableNumber)
+ for i in 0...$Trainer.party.length
+ p=$Trainer.party[i]
+ if p && !p.egg? && p.hp>0
+ $game_variables[variableNumber]=i
+ return
+ end
+ end
+ $game_variables[variableNumber]=-1
@@ -655,1 +667,1 @@
-
+=begin
@@ -699,0 +711,1 @@
+=end
Changed: PokeBattle_Battle
@@ -2116,1 +2116,1 @@
- tempexp1=startexp
+ tempexp1=tempexp2
@@ -2208,1 +2208,1 @@
- elsif
+ else
Changed: PokemonBag
@@ -289,1 +289,1 @@
- end
+ end
Changed: PokemonScreen
@@ -534,1 +534,0 @@
- helpwindow.text=helptext
@@ -539,0 +538,1 @@
+ helpwindow.text=""
@@ -540,0 +540,1 @@
+ helpwindow.text=helptext
@@ -583,1 +584,1 @@
- @sprites["helpwindow"]=Window_ColoredTextPokemon.new(starthelptext)
+ @sprites["helpwindow"]=Window_FormattedTextPokemon.new(starthelptext)
@@ -591,3 +592,0 @@
- @sprites["helpwindow"].letterbyletter=false
- @sprites["helpwindow"].baseColor=Color.new(72,72,72)
- @sprites["helpwindow"].shadowColor=Color.new(208,208,208)
@@ -1291,0 +1289,1 @@
+ _INTL("TEACH MOVE"),
@@ -1303,2 +1302,2 @@
- level=Kernel.pbMessageChooseNumber(
- _INTL("Set the Pokemon's level."),pkmn.level,3,nil,100)
+ level=Kernel.pbMessageChooseNumberEx(
+ _INTL("Set the Pokemon's level."),pkmn.level,1,100,pkmn.level)
@@ -1385,0 +1384,5 @@
+ when 8
+ move=pbChooseMoveList
+ if move!=0
+ pbLearnMove(pkmn,move)
+ end
Changed: PokemonEncounters
@@ -140,0 +140,1 @@
+ return nil if !encounter
Changed: PokemonStorage
@@ -627,0 +627,1 @@
+ _INTL("TEACH MOVE"),
@@ -639,2 +640,2 @@
- level=Kernel.pbMessageChooseNumber(
- _INTL("Set the Pokemon's level."),pkmn.level,3,nil,100)
+ level=Kernel.pbMessageChooseNumberEx(
+ _INTL("Set the Pokemon's level."),pkmn.level,1,100,pkmn.level)
@@ -743,0 +744,5 @@
+ when 8
+ move=pbChooseMoveList
+ if move!=0
+ pbLearnMove(pkmn,move)
+ end
Changed: Win32API*
@@ -37,3 +37,0 @@
- #--------------------------------------------------------------------------
- # - Win32API.GetPrivateProfileString // check your game title in Game.ini
- #--------------------------------------------------------------------------
@@ -47,3 +44,0 @@
- #--------------------------------------------------------------------------
- # - Win32API.SetWindowPos // change window positions and sizes
- #--------------------------------------------------------------------------
@@ -61,3 +55,0 @@
- #--------------------------------------------------------------------------
- # - Win32API.client_size // check the window width and height
- #--------------------------------------------------------------------------
Changed: Scene_Intro
@@ -23,0 +23,7 @@
+ def setTitle(sprite,title)
+ @cache={} if !@cache
+ if !@cache[title]
+ @cache[title]=Bitmap.new("Graphics/Titles/#{title}")
+ end
+ sprite.bitmap=@cache[title]
+ end
@@ -31,1 +38,1 @@
- game_system.bgm_play($data_system.title_bgm)
+ game_system.bgm_play(data_system.title_bgm)
@@ -36,1 +43,1 @@
- @sprite.bitmap = RPG::Cache.title(@pics[@item])
+ setTitle(@sprite,@pics[@item])
@@ -40,1 +47,1 @@
- @start.bitmap = RPG::Cache.title("Start")
+ setTitle(@start,"Start")
@@ -61,0 +68,5 @@
+ if @cache
+ for i in @cache.values
+ i.dispose
+ end
+ end
@@ -82,1 +94,1 @@
- @sprite.bitmap = RPG::Cache.title(@pics[@item])
+ setTitle(@sprite,@pics[@item])
@@ -94,1 +106,1 @@
- @sprite.bitmap = RPG::Cache.title(@splash)
+ setTitle(@sprite,@splash)
Changed: PokemonDebug
@@ -248,0 +248,44 @@
+end
+
+def fromRSChar(ch)
+ fontconv=[
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 255,171,0,0,183,91,0,180,92,93,185,46,184,174,173,186,
+ 161,162,163,164,165,166,167,168,169,170,240,54,0,53,0,172,
+ 0,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,
+ 202,203,204,205,206,207,208,209,210,211,212,0,0,0,0,0,
+ 179,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,
+ 228,229,230,231,232,233,234,235,236,237,238,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,82,0,0,0,0,0,0,0,0,43,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,42,0,0,0,0,81,
+ 1,2,0,0,241,0,0,4,5,6,7,8,9,90,11,12,
+ 0,20,13,14,15,0,242,0,0,17,18,19,243,0,0,21,
+ 22,23,104,0,244,0,0,25,26,27,28,29,30,111,32,33,
+ 0,41,34,35,36,0,245,0,0,38,39,40,246,0,0,0,0
+ ]
+ return findIndex(fontconv) {|x| x==ch }
+end
+
+def toRSChar(str)
+ fontconv=[
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 255,171,0,0,183,91,0,180,92,93,185,46,184,174,173,186,
+ 161,162,163,164,165,166,167,168,169,170,240,54,0,53,0,172,
+ 0,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,
+ 202,203,204,205,206,207,208,209,210,211,212,0,0,0,0,0,
+ 179,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,
+ 228,229,230,231,232,233,234,235,236,237,238,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,82,0,0,0,0,0,0,0,0,43,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,42,0,0,0,0,81,
+ 1,2,0,0,241,0,0,4,5,6,7,8,9,90,11,12,
+ 0,20,13,14,15,0,242,0,0,17,18,19,243,0,0,21,
+ 22,23,104,0,244,0,0,25,26,27,28,29,30,111,32,33,
+ 0,41,34,35,36,0,245,0,0,38,39,40,246,0,0,0,0
+ ]
+ return fontconv[nextUtf8(str,0)].chr
@@ -534,1 +578,1 @@
- value=findIndex($FontConv) {|x| x==rawnickname[i] }
+ value=fromRSChar(rawnickname[i])
@@ -539,1 +583,1 @@
- value=findIndex($FontConv) {|x| x==rawotname[i] }
+ value=fromRSChar(rawotname[i])
@@ -912,0 +956,1 @@
+ RPG::Cache.debug
Changed: Sprite_Picture
Changed: Particle Engine
Changed: PokemonMap
Changed: PokeBattle_Pokemon
Added: DrawText
Changed: PokemonMenu
Changed: PBIntl
Changed: AnimationSprite
Changed: Pokegear
Changed: Resolution*
Changed: PerspectiveTilemap
Changed: Sprite_Character
Changed: PokemonField
Changed: PokemonSave
Changed: PokemonMart
Changed: PokeBattle_ActualScene
Changed: Shadow
Changed: PokemonTrainers
Added: Transitions
Changed: SpriteResizer
Changed: PokeBattle_Trainer
Changed: PokemonDuel
Changed: PokemonLoad
Changed: BitmapCache
Changed: PokeBattle_AI
Changed: WindowAndTilemap
Changed: PokemonEntry
Changed: PokemonWeather
Changed: Game_System
Changed: Compiler
Changed: Game_Player*
Changed: Audio
Changed: Spriteset_Map
Changed: PokemonEditor
Changed: PokemonMessages
Changed: SpriteWindow
Changed: PokemonSystem
Changed: PokemonUtilities
Changed: PokeBattle_Battle
Changed: PokemonBag
Changed: PokemonScreen
Changed: PokemonEncounters
Changed: PokemonStorage
Changed: Win32API*
Changed: Scene_Intro
Changed: PokemonDebug