Changed: PokemonArea --- Left +++ Right @@ -41,6 +41,6 @@ return false end - @sprites["map"]=Sprite.new(@viewport) - @sprites["map"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{@map[1]}") + @sprites["map"]=IconSprite.new(0,0,@viewport) + @sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}") @point=Bitmap.new(22,22) @point.fill_rect(0,0,20,20,Color.new(255,0,0)) Changed: TileDrawingHelper --- Left +++ Right @@ -64,8 +64,8 @@ def self.fromTileset(tileset) - bmtileset=RPG::Cache.tileset(tileset.tileset_name) + bmtileset=pbGetTileset(tileset.tileset_name) bmautotiles=[] for i in 0...7 - bmautotiles.push(RPG::Cache.autotile(tileset.autotile_names[i])) + bmautotiles.push(pbGetAutotile(tileset.autotile_names[i])) end return self.new(bmtileset,bmautotiles) Changed: PokemonOption --- Left +++ Right @@ -9,5 +9,5 @@ super(x,y,width,height) @options=options - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @index=0 @nameBaseColor=Color.new(24*8,15*8,0) @@ -53,5 +53,5 @@ next end - pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i + pbCopyBitmap(self.contents,@selarrow.bitmap,0,ypos) if self.index==i optionname=(i==@options.length) ? _INTL("CANCEL") : @options[i].name self.contents.font.color=@nameShadowColor Changed: PokemonTrainerCard --- Left +++ Right @@ -13,8 +13,11 @@ @viewport.z=99999 addBackgroundPlane(@sprites,"bg","trcardbg",@viewport) - @sprites["card"]=Sprite.new(@viewport) - @sprites["card"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/trcard.png") + @sprites["card"]=IconSprite.new(0,0,@viewport) + @sprites["card"].setBitmap("Graphics/Pictures/trcard") @sprites["overlay"]=Sprite.new(@viewport) @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) + @sprites["trainer"]=IconSprite.new(304,80,@viewport) + @sprites["trainer"].setBitmap(sprintf("Graphics/Characters/trainer%03d",$Trainer.trainertype)) + @sprites["trainer"].z=2 pbSetSystemFont(@sprites["overlay"].bitmap) pbDrawTrainerCardFront @@ -52,12 +55,10 @@ ] pbDrawTextPositions(overlay,textPositions) - imagePositions=[ - [sprintf("Graphics/Characters/trainer%03d.png",$Trainer.trainertype),304,80,0,0,-1,-1], - ] x=64 + imagePositions=[] for i in 0...8 if $Trainer.badges[i] imagePositions[imagePositions.length]=[ - "Graphics/Pictures/badges.png",x,240,i*32,0,32,32 + pbBitmapName("Graphics/Pictures/badges"),x,240,i*32,0,32,32 ] end Changed: PBAnimation --- Left +++ Right @@ -539,5 +539,5 @@ end if !@animbitmap || @animbitmap.disposed? - @animbitmap=BitmapCache.animation(@animation.graphic,@animation.hue) + @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,@animation.hue).deanimate for i in 0...MAXSPRITES @animsprites[i].bitmap=@animbitmap @@ -631,5 +631,5 @@ end if !@animbitmap || @animbitmap.disposed? - @animbitmap=BitmapCache.animation(@animation.graphic,@animation.hue) + @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,@animation.hue).deanimate for i in 0...MAXSPRITES @animsprites[i].bitmap=@animbitmap Changed: Spriteset_Map --- Left +++ Right @@ -11,8 +11,8 @@ @viewport3.z = 500 @tilemap = TilemapLoader.new(@viewport1) - @tilemap.tileset = RPG::Cache.tileset(@map.tileset_name) + @tilemap.tileset = pbGetTileset(@map.tileset_name) for i in 0..6 autotile_name = @map.autotile_names[i] - @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name) + @tilemap.autotiles[i] = pbGetAutotile(autotile_name) end @tilemap.map_data = @map.data Changed: Pokegear_Radio --- Left +++ Right @@ -20,11 +20,10 @@ def main # Make song command window - @spriteset = Spriteset_Map.new fadein = true # Makes the text window - @Background = Sprite.new - @Background.bitmap = RPG::Cache.picture("iPod") - @Background.z += 255 - @Background.opacity = 255 + @sprites={} + @sprites["background"] = IconSprite.new(0,0) + @sprites["background"].setBitmap("Graphics/Pictures/iPod") + @sprites["background"].z=255 @choices=[ _INTL("March"), @@ -34,12 +33,11 @@ _INTL("Exit") ] - @command_window = Window_CommandPokemon.new(@choices,160) - @command_window.index = @menu_index - @command_window.height=160 - @command_window.width=176 - @command_window.x = 150 - @command_window.y = 130 - @command_window.z=256 - @command_window.opacity = 0 + @sprites["command_window"] = Window_CommandPokemon.new(@choices,160) + @sprites["command_window"].index = @menu_index + @sprites["command_window"].height=160 + @sprites["command_window"].width=176 + @sprites["command_window"].x = 150 + @sprites["command_window"].y = 130 + @sprites["command_window"].z=256 @custom=false # Execute transition @@ -61,7 +59,5 @@ Graphics.freeze # Disposes the windows - @command_window.dispose - @spriteset.dispose - @Background.dispose + pbDisposeSpriteHash(@sprites) end #-------------------------------------------------------------------------- @@ -70,5 +66,5 @@ def update # Update windows - @command_window.update + pbUpdateSpriteHash(@sprites) if @custom updateCustom @@ -83,6 +79,6 @@ def updateCustom if Input.trigger?(Input::B) - @command_window.commands=@choices - @command_window.index=3 + @sprites["command_window"].commands=@choices + @sprites["command_window"].index=3 @custom=false return @@ -91,9 +87,9 @@ $PokemonMap.whiteFluteUsed=false if $PokemonMap $PokemonMap.blackFluteUsed=false if $PokemonMap - if @command_window.index==0 + if @sprites["command_window"].index==0 $game_system.setDefaultBGM(nil) else $game_system.setDefaultBGM( - @command_window.commands[@command_window.index] + @sprites["command_window"].commands[@sprites["command_window"].index] ) end @@ -112,5 +108,5 @@ if Input.trigger?(Input::C) # Branch by command window cursor position - case @command_window.index + case @sprites["command_window"].index when 0 $game_system.se_play($data_system.decision_se) @@ -136,6 +132,6 @@ Dir.glob("*.MID"){|f| files.push(f) } } - @command_window.commands=files - @command_window.index=0 + @sprites["command_window"].commands=files + @sprites["command_window"].index=0 @custom=true when 4 Changed: PokemonEvolution --- Left +++ Right @@ -361,5 +361,5 @@ @pokemon=pokemon @newspecies=newspecies - addBackgroundOrColoredPlane(@sprites,"background","evobg.png", + addBackgroundOrColoredPlane(@sprites,"background","evobg", Color.new(248,248,248),@viewport) rsprite1=Sprite.new(@viewport) Changed: Audio --- Left +++ Right @@ -97,14 +97,14 @@ end def self.bgmActive? - return (AudioContextIsActive.call(@BGMContext.context)!=0) + return !@BGMContext ? false : (AudioContextIsActive.call(@BGMContext.context)!=0) end def self.meActive? - return (AudioContextIsActive.call(@MEContext.context)!=0) + return !@MEContext ? false : (AudioContextIsActive.call(@MEContext.context)!=0) end def self.waitingBGM; @waitingBGM; end - def self.context; @BGMContext.context; end - def self.meContext; @MEContext.context; end - def self.bgsContext; @BGSContext.context; end - def self.seContext; @SEContext.context; end + def self.context; @BGMContext ? @BGMContext.context : nil; end + def self.meContext; @MEContext ? @MEContext.context : nil; end + def self.bgsContext; @BGSContext ? @BGSContext.context : nil; end + def self.seContext; @SEContext ? @SEContext.context : nil; end def self.system; @system; end def self.bgm; @bgm; end @@ -292,26 +292,4 @@ def self.update return if Graphics.frame_count%10!=0 -=begin - pm=getPlayMusic() - ps=getPlaySound() - if @@musicstate!=false && !pm - @@musicstate=false - Kernel.Audio_bgm_mute - Kernel.Audio_me_mute - elsif @@musicstate!=true && pm - @@musicstate=true - Kernel.Audio_bgm_unmute - Kernel.Audio_me_unmute - end - if @@soundstate!=false && !ps - @@soundstate=false - Kernel.Audio_bgs_mute - Kernel.Audio_se_mute - elsif @@soundstate!=true && ps - @@musicstate=true - Kernel.Audio_bgs_unmute - Kernel.Audio_se_unmute - end -=end if AudioState.waitingBGM && !AudioState.meActive? waitbgm=AudioState.waitingBGM Changed: PokemonPokedex --- Left +++ Right @@ -7,6 +7,6 @@ @starting=true super(x,y,width,height) - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") - @pokeball=BitmapCache.load_bitmap("Graphics/Pictures/pokeball.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") + @pokeball=AnimatedBitmap.new("Graphics/Pictures/pokeball") @baseColor=Color.new(9<<3,9<<3,9<<3) @shadowColor=Color.new(26<<3,26<<3,26<<3) @@ -47,5 +47,5 @@ next end - pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i + pbCopyBitmap(self.contents,@selarrow.bitmap,0,ypos) if self.index==i indexNumber=@commands[i][4] species=@commands[i][0] @@ -53,5 +53,5 @@ j=self.top_row if $Trainer.owned[species] - pbCopyBitmap(self.contents,@pokeball,210,(i-j)*32) + pbCopyBitmap(self.contents,@pokeball.bitmap,210,(i-j)*32) end text=_ISPRINTF("No.{1:03d} {2:s}",indexNumber,@commands[i][1]) @@ -104,5 +104,5 @@ super(0,0,dims[0],dims[1]) @item_max=commands.length - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @index=0 self.active=true @@ -207,5 +207,5 @@ for j in 0...@commands[i+1].length if icommand>=self.top_row && icommand1 + @facebitmaptmp.update + @facebitmap.blt(0,0,@facebitmaptmp,Rect.new( + (@faceIndex % 4) * 96, + (@faceIndex / 4) * 96, 96, 96 + )) + end + end def dispose + @facebitmaptmp.dispose @facebitmap.dispose if @facebitmap super @@ -1209,8 +1220,7 @@ when 1 # dim msgwindow.opacity=0 - msgback=Sprite.new(msgwindow.viewport) + msgback=IconWindow(0,msgwindow.y,msgwindow.viewport) msgback.z=msgwindow.z-1 - msgback.bitmap=RPG::Cache.load_bitmap("Graphics/System/","MessageBack") - msgback.y=msgwindow.y + msgback.setBitmap("Graphics/System/MessageBack") when 2 # transparent msgwindow.opacity=0 @@ -1305,4 +1315,5 @@ Graphics.update Input.update + facewindow.update if facewindow if $DEBUG && Input.trigger?(Input::F6) pbRecord(unformattedText) Changed: PokemonEntry --- Left +++ Right @@ -222,5 +222,5 @@ @charset=charset @othercharset="" - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @index=0 colors=getDefaultTextColors(self.windowskin) @@ -329,5 +329,5 @@ def textHelper(x,y,text,i) if @index==i - pbCopyBitmap(self.contents,@selarrow,x,y) + pbCopyBitmap(self.contents,@selarrow.bitmap,x,y) end textwidth=self.contents.text_size(text).width @@ -1128,5 +1128,5 @@ @sprites["helpwindow"].visible=USEKEYBOARD pbBottomLeftLines(@sprites["helpwindow"],2) - addBackgroundPlane(@sprites,"background","entrybg.png",@viewport) + addBackgroundPlane(@sprites,"background","entrybg",@viewport) pbFadeInAndShow(@sprites) end @@ -1220,6 +1220,6 @@ @sprite=Sprite.new(viewport) @cursortype=0 - @cursor1=BitmapCache.load_bitmap("Graphics/Pictures/entrycursor.png") - @cursor2=BitmapCache.load_bitmap("Graphics/Pictures/entrycursor2.png") + @cursor1=AnimatedBitmap.new("Graphics/Pictures/entrycursor") + @cursor2=AnimatedBitmap.new("Graphics/Pictures/entrycursor2") @direction=1 @intensity=0 @@ -1270,4 +1270,6 @@ end def updateInternal + @cursor1.update + @cursor2.update updateCursorPos if @cursortype==0 @@ -1282,5 +1284,5 @@ @direction=-@direction end - @sprite.bitmap=(@cursortype==0) ? @cursor1 : @cursor2 + @sprite.bitmap=(@cursortype==0) ? @cursor1.bitmap : @cursor2.bitmap end def update @@ -1300,11 +1302,14 @@ @helper=CharacterEntryHelper.new(initialText) @bitmaps=[ - Bitmap.new("Graphics/Pictures/lettertab1.png"), - Bitmap.new("Graphics/Pictures/lettertab2.png"), - Bitmap.new("Graphics/Pictures/lettertab3.png") + AnimatedBitmap.new("Graphics/Pictures/lettertab1"), + AnimatedBitmap.new("Graphics/Pictures/lettertab2"), + AnimatedBitmap.new("Graphics/Pictures/lettertab3") ] + @bitmaps[3]=@bitmaps[0].bitmap.clone + @bitmaps[4]=@bitmaps[1].bitmap.clone + @bitmaps[5]=@bitmaps[2].bitmap.clone for i in 0...3 pos=0 - pbSetSystemFont(@bitmaps[i]) + pbSetSystemFont(@bitmaps[i+3]) textPos=[] for y in 0...COLUMNS @@ -1315,16 +1320,16 @@ end end - pbDrawTextPositions(@bitmaps[i],textPos) + pbDrawTextPositions(@bitmaps[i+3],textPos) end underline=Bitmap.new(12,4) underline.fill_rect(0,0,12,2,Color.new(7*8,7*8,7*8)) underline.fill_rect(0,2,12,2,Color.new(14*8,14*8,14*8)) - @sprites["bg"]=Sprite.new(@viewport) - @sprites["bg"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/nameentrybg.png") + @sprites["bg"]=IconSprite.new(0,0,@viewport) + @sprites["bg"].setBitmap("Graphics/Pictures/nameentrybg") @sprites["bgoverlay"]=Sprite.new(@viewport) @sprites["bgoverlay"].bitmap=Bitmap.new(640,480) pbDoUpdateOverlay - @sprites["pointer"]=Sprite.new(@viewport) - @sprites["pointer"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/nameentryptr.png") + @sprites["pointer"]=IconSprite.new(0,0,@viewport) + @sprites["pointer"].setBitmap("Graphics/Pictures/nameentryptr") @sprites["pointer"].y=104 @blanks=[] @@ -1345,8 +1350,8 @@ @sprites["toptab"].x=34 @sprites["toptab"].y=150 - @sprites["toptab"].bitmap=@bitmaps[0] - @sprites["bottomtab"].bitmap=@bitmaps[1] - @sprites["controls"]=Sprite.new(@viewport) - @sprites["controls"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/nameentryctls.png") + @sprites["toptab"].bitmap=@bitmaps[0+3] + @sprites["bottomtab"].bitmap=@bitmaps[1+3] + @sprites["controls"]=IconSprite.new(0,0,@viewport) + @sprites["controls"].setBitmap("Graphics/Pictures/nameentryctls") @sprites["controls"].x=368 @sprites["controls"].y=150 @@ -1437,5 +1442,5 @@ end @mode=(@mode+1)%3 - newtab=@bitmaps[(@mode+1)%3] + newtab=@bitmaps[((@mode+1)%3)+3] @sprites["cursor"].visible=true @sprites["bottomtab"].bitmap=newtab @@ -1444,4 +1449,7 @@ def pbUpdate + for i in 0...3 + @bitmaps[i].update + end if @init || Graphics.frame_count%5==0 @init=false @@ -1579,4 +1587,5 @@ bitmap.dispose if bitmap end + @bitmaps.clear pbDisposeSpriteHash(@sprites) @viewport.dispose Changed: SpriteWindow --- Left +++ Right @@ -5,7 +5,7 @@ FontName="Power Green" # in Graphics/Windowskins/ - TextSkinName="frlgtextskin.png" + TextSkinName="frlgtextskin" # full path to file - ChoiceSkinName="skin1.png" + ChoiceSkinName="skin1" WindowOpacity=255 end @@ -20,4 +20,75 @@ CURSORMODE=0 + +$VersionStyles=[ + [MessageConfig::FontName], + ["Power Red and Blue"], + ["Power Red and Green"], + ["Power Clear"], + ["Power Red and Blue Intl"] +] + +$TextFrames=[ +"Graphics/Windowskins/"+MessageConfig::ChoiceSkinName, +"Graphics/Windowskins/skin2", +"Graphics/Windowskins/skin3", +"Graphics/Windowskins/skin4", +"Graphics/Windowskins/skin5", +"Graphics/Windowskins/skin6", +"Graphics/Windowskins/skin7", +"Graphics/Windowskins/skin8", +"Graphics/Windowskins/skin9", +"Graphics/Windowskins/skin10", +"Graphics/Windowskins/skin11", +"Graphics/Windowskins/skin12", +"Graphics/Windowskins/skin13", +"Graphics/Windowskins/skin14", +"Graphics/Windowskins/skin15", +"Graphics/Windowskins/skin16", +"Graphics/Windowskins/skin17", +"Graphics/Windowskins/skin18", +"Graphics/Windowskins/skin19", +"Graphics/Windowskins/skin20", +"Graphics/Windowskins/skin21", +"Graphics/Windowskins/skin22", +"Graphics/Windowskins/skin23", +"Graphics/Windowskins/skin24", +"Graphics/Windowskins/skin25", +"Graphics/Windowskins/skin26", +"Graphics/Windowskins/skin27", +"Graphics/Windowskins/skin28", +"Graphics/Windowskins/textbox0", +"Graphics/Windowskins/textbox1", +"Graphics/Windowskins/textbox2", +"Graphics/Windowskins/textbox3", +"Graphics/Windowskins/textbox4" +] +$SpeechFrames=[ +nil, # Default text skin, leave as nil +"rstextskin", +"frlgtextskin", +"emtextskin", +"textbox0", +"textbox1", +"textbox2", +"textbox3", +"textbox4", +"textbox5", +"textbox6", +"textbox7", +"textbox8", +"textbox9", +"textbox10", +"textbox11", +"textbox12", +"textbox13", +"textbox14", +"textbox15", +"textbox16", +"textbox17", +"textbox18", +"textbox19" +] + ############################# ############################# @@ -47,6 +118,9 @@ end +################################ + class AnimatedBitmap def initialize(file,hue=0) + #echoln([file,hue]) if file[/^\[(\d+)\]/] @bitmap=PngAnimatedBitmap.new(file,hue) @@ -56,4 +130,6 @@ end def [](index); @bitmap[index]; end + def width; @bitmap.bitmap.width; end + def height; @bitmap.bitmap.height; end def length; @bitmap.length; end def each; @bitmap.each { yield }; end @@ -65,6 +141,29 @@ def update; @bitmap.update; end def dispose; @bitmap.dispose; end + def deanimate; @bitmap.deanimate; end end +def pbGetTileBitmap(filename, tile_id, hue) + return BitmapCache.tileEx(filename, tile_id, hue){|f| + AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate; + } +end + +def pbGetAnimation(name,hue=0) + return AnimatedBitmap.new("Graphics/Animations/"+name,hue).deanimate +end + +def pbGetTileset(name,hue=0) + return AnimatedBitmap.new("Graphics/Tilesets/"+name,hue).deanimate +end + +def pbGetAutotile(name,hue=0) + return AnimatedBitmap.new("Graphics/Autotiles/"+name,hue).deanimate +end + + +########### + +# internal class class PngAnimatedBitmap # Creates an animated bitmap from a PNG file. @@ -98,4 +197,14 @@ return @frames[index] end + def width; self.bitmap.width; end + def height; self.bitmap.height; end + def deanimate + for i in 1...@frames.length + @frames[i].dispose + end + @frames=[@frames[0]] + @currentFrame=0 + return @frames[0] + end def bitmap @gifbitmaps[@currentFrame] @@ -149,17 +258,37 @@ @disposed=false bitmap=nil - filestring=pbGetFileString(file) - filestring=pbGetFileString(file+".gif") if !filestring - filestring=pbGetFileString(file+".png") if !filestring - filestring=pbGetFileString(file+".jpg") if !filestring - filestring=pbGetFileString(file+".bmp") if !filestring - if filestring && filestring[0]!=0x47 - begin - bitmap=BitmapCache.load_bitmap(file) - rescue - bitmap=nil + filestring=nil + filestrName=nil + file="" if !file + file=canonicalize(file) + #File.open("debug.txt","ab"){|f| f.puts([file,Time.now.to_i].inspect) } + begin + bitmap=BitmapCache.load_bitmap(file,hue) + rescue + bitmap=nil + end + if !bitmap || (bitmap.width==32 && bitmap.height==32) + if !file || file.length<1 || file[file.length-1]!=0x2F + if (filestring=pbGetFileChar(file)) + filestrName=file + elsif (filestring=pbGetFileChar(file+".gif")) + filestrName=file+".gif" + elsif (filestring=pbGetFileChar(file+".png")) + filestrName=file+".png" + elsif (filestring=pbGetFileChar(file+".jpg")) + filestrName=file+".jpg" + elsif (filestring=pbGetFileChar(file+".bmp")) + filestrName=file+".bmp" + end end end + if bitmap && filestring && filestring[0]==0x47 && + bitmap.width==32 && bitmap.height==32 + #File.open("debug.txt","ab"){|f| f.puts("rejecting bitmap") } + bitmap.dispose + bitmap=nil + end if bitmap + #File.open("debug.txt","ab"){|f| f.puts("reusing bitmap") } # Have a regular non-animated bitmap @totalframes=1 @@ -168,27 +297,36 @@ @gifdelays=[1] else - if filestring && GifLibrary::PngDll - result=GifLibrary::GifToPngFilesInMemory.call(filestring,filestring.length,File.basename(file)) - else - result=0 - end - if result>0 - @gifdelays=GifLibrary.getDataFromResult(result) - @totalframes=@gifdelays.pop - for i in 0...@gifdelays.length - @gifdelays[i]=[@gifdelays[i],1].max - bmfile=sprintf("%s%d.png",File.basename(file),i); - if FileTest.exist?(bmfile) - @gifbitmaps.push(Bitmap.new(bmfile)) - File.delete(bmfile) - else - @gifbitmaps.push(Bitmap.new(32,32)) + tmpBase=File.basename(file)+"_tmp_" + filestring=pbGetFileString(filestrName) if filestring + Dir.chdir(ENV["TEMP"]){ # navigate to temp folder since game might be on a CD-ROM + if filestring && filestring[0]==0x47 && GifLibrary::PngDll + result=GifLibrary::GifToPngFilesInMemory.call(filestring,filestring.length, + tmpBase) + else + result=0 + end + if result>0 + @gifdelays=GifLibrary.getDataFromResult(result) + @totalframes=@gifdelays.pop + for i in 0...@gifdelays.length + @gifdelays[i]=[@gifdelays[i],1].max + bmfile=sprintf("%s%d.png",tmpBase,i); + if FileTest.exist?(bmfile) + @gifbitmaps.push(BitmapWrapper.new(bmfile)) + bmfile.hue_change(hue) if hue!=0 + File.delete(bmfile) + else + @gifbitmaps.push(BitmapWrapper.new(32,32)) + end end end - end + } if @gifbitmaps.length==0 - @gifbitmaps=[Bitmap.new(32,32)] + @gifbitmaps=[BitmapWrapper.new(32,32)] @gifdelays=[1] end + if @gifbitmaps.length==1 + BitmapCache.setKey(file,@gifbitmaps[0]) + end end end @@ -196,4 +334,14 @@ return @gifbitmaps[index] end + def width; self.bitmap.width; end + def height; self.bitmap.height; end + def deanimate + for i in 1...@gifbitmaps.length + @gifbitmaps[i].dispose + end + @gifbitmaps=[@gifbitmaps[0]] + @currentIndex=0 + return @gifbitmaps[0] + end def bitmap @gifbitmaps[@currentIndex] @@ -245,68 +393,4 @@ end -class GifSprite - # Creates a sprite from a GIF file with the specified - # optional viewport. Can also load non-animated bitmaps. - # 'File' can be nil. - def initialize(file=nil,viewport=nil) - @sprite=SpriteWrapper.new(viewport) - if file - @bitmap=AnimatedBitmap.new(file) - @sprite.bitmap=@bitmap.bitmap - end - end - def [](index); @bitmap[index]; end - def length; @bitmap.length; end - def each; @bitmap.each { yield }; end - def currentIndex; @bitmap.currentIndex; end - def frameDelay; @bitmap.frameDelay; end - def totalFrames; @bitmap.totalFrames; end - def setBitmap(file) - @bitmap.dispose if @bitmap - @bitmap=AnimatedBitmap.new(file) - @sprite.bitmap=@bitmap.bitmap - end - def bitmap - @sprite.bitmap - end - def bitmap=(value) - @sprite.bitmap=value - end - def disposed? - @sprite.disposed? - end - def width - @bitmap.bitmap.width - end - def height - @bitmap.bitmap.height - end - # This function must be called in order to animate - # the GIF image. - def update - @bitmap.update - @sprite.update - if @sprite.bitmap!=@bitmap.bitmap - oldsrc=@sprite.src_rect ? @sprite.src_rect.clone : nil - @sprite.bitmap=@bitmap.bitmap - @sprite.src_rect=oldsrc if oldsrc - end - end - def dispose - @bitmap.dispose - @sprite.dispose - end - def flash(*arg); sprite.flash(*arg); end - %w[ - x y z ox oy visible zoom_x zoom_y - angle mirror bush_depth opacity blend_type - color tone src_rect viewport - ].each do |s| - eval <<-__END__ - def #{s}; @sprite.#{s}; end - def #{s}=(value); @sprite.#{s}=value; end - __END__ - end -end ############################# @@ -338,73 +422,4 @@ end -$VersionStyles=[ - [MessageConfig::FontName], - ["Power Red and Blue"], - ["Power Red and Green"], - ["Power Clear"], - ["Power Red and Blue Intl"] -] - -$TextFrames=[ -"Graphics/Windowskins/"+MessageConfig::ChoiceSkinName, -"Graphics/Windowskins/skin2.png", -"Graphics/Windowskins/skin3.png", -"Graphics/Windowskins/skin4.png", -"Graphics/Windowskins/skin5.png", -"Graphics/Windowskins/skin6.png", -"Graphics/Windowskins/skin7.png", -"Graphics/Windowskins/skin8.png", -"Graphics/Windowskins/skin9.png", -"Graphics/Windowskins/skin10.png", -"Graphics/Windowskins/skin11.png", -"Graphics/Windowskins/skin12.png", -"Graphics/Windowskins/skin13.png", -"Graphics/Windowskins/skin14.png", -"Graphics/Windowskins/skin15.png", -"Graphics/Windowskins/skin16.png", -"Graphics/Windowskins/skin17.png", -"Graphics/Windowskins/skin18.png", -"Graphics/Windowskins/skin19.png", -"Graphics/Windowskins/skin20.png", -"Graphics/Windowskins/skin21.png", -"Graphics/Windowskins/skin22.png", -"Graphics/Windowskins/skin23.png", -"Graphics/Windowskins/skin24.png", -"Graphics/Windowskins/skin25.png", -"Graphics/Windowskins/skin26.png", -"Graphics/Windowskins/skin27.png", -"Graphics/Windowskins/skin28.png", -"Graphics/Windowskins/textbox0.png", -"Graphics/Windowskins/textbox1.png", -"Graphics/Windowskins/textbox2.png", -"Graphics/Windowskins/textbox3.png", -"Graphics/Windowskins/textbox4.png" -] -$SpeechFrames=[ -nil, # Default text skin, leave as nil -"rstextskin", -"frlgtextskin", -"emtextskin", -"textbox0", -"textbox1", -"textbox2", -"textbox3", -"textbox4", -"textbox5", -"textbox6", -"textbox7", -"textbox8", -"textbox9", -"textbox10", -"textbox11", -"textbox12", -"textbox13", -"textbox14", -"textbox15", -"textbox16", -"textbox17", -"textbox18", -"textbox19" -] ######################### @@ -558,5 +573,5 @@ def pbDrawImagePositions(bitmap,textpos) for i in textpos - srcbitmap=BitmapCache.load_bitmap(i[0]) + srcbitmap=AnimatedBitmap.new(pbBitmapName(i[0])) x=i[1] y=i[2] @@ -566,5 +581,5 @@ height=i[6]>=0 ? i[6] : srcbitmap.height srcrect=Rect.new(srcx,srcy,width,height) - bitmap.blt(x,y,srcbitmap,srcrect) + bitmap.blt(x,y,srcbitmap.bitmap,srcrect) srcbitmap.dispose end @@ -694,18 +709,15 @@ def pbHaveString(x) - ret=pbGetFileString(x) + ret=pbGetFileChar(x) return (ret!=nil && ret!="") end -def pbHaveBitmap(x) - return BitmapCache.load_bitmap(x) rescue nil -end - def pbTryString(x) return pbHaveString(x) ? x : nil end -def pbTryBitmap(x) - return pbHaveBitmap(x) ? x : nil +def pbBitmapName(x) + ret=pbResolveBitmap(x) + return ret ? ret : x end @@ -713,11 +725,11 @@ return nil if !x noext=x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/,"") - filename=pbTryBitmap(x) - filename=pbTryBitmap("#{noext}.png") if !filename + filename=pbTryString(x) + filename=pbTryString("#{noext}.png") if !filename filename=pbTryString("#{x}.gif") if !filename filename=pbTryString("#{noext}.gif") if !filename - filename=pbTryBitmap("#{noext}.jpg") if !filename - filename=pbTryBitmap("#{noext}.jpeg") if !filename - filename=pbTryBitmap("#{noext}.bmp") if !filename + filename=pbTryString("#{noext}.jpg") if !filename + filename=pbTryString("#{noext}.jpeg") if !filename + filename=pbTryString("#{noext}.bmp") if !filename return filename end @@ -981,5 +993,5 @@ def pbRgssExists?(filename) filename=canonicalize(filename) - if FileTest.exist?("./Game.rgssad") + if (FileTest.exist?("./Game.rgssad") || FileTest.exist?("./Game.rgss2a")) return pbGetFileString(filename)!=nil else @@ -1004,6 +1016,33 @@ end + +def pbGetFileChar(file) + file=canonicalize(file) + if !(FileTest.exist?("./Game.rgssad") || FileTest.exist?("./Game.rgss2a")) + return nil if !FileTest.exist?(file) + File.open(file,"rb"){|f| + return f.read(1) # read one byte + } + end + Marshal.neverload=true + str=nil + begin + str=load_data(file) + rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES, RGSSError + str=nil + ensure + Marshal.neverload=false + end + return str +end + def pbGetFileString(file) file=canonicalize(file) + if !(FileTest.exist?("./Game.rgssad") || FileTest.exist?("./Game.rgss2a")) + return nil if !FileTest.exist?(file) + File.open(file,"rb"){|f| + return f.read # read all data + } + end Marshal.neverload=true str=nil @@ -1808,7 +1847,7 @@ @curframe=pbGetSystemFrame @curfont=pbGetSystemFont - @sysframe=BitmapCache.load_bitmap($TextFrames[pbGetSystemFrame]) + @sysframe=AnimatedBitmap.new($TextFrames[pbGetSystemFrame]) @customskin=nil - __setWindowskin(@sysframe) + __setWindowskin(@sysframe.bitmap) end def __setWindowskin(skin) @@ -1821,21 +1860,28 @@ self.windowskin=skin end - def setSkin(skin) + def setSkin(skin) # Sets the bitmap's windowskin. Supports animated images. @customskin.dispose if @customskin - @customskin=BitmapCache.load_bitmap(skin) - __setWindowskin(@customskin) + @customskin=AnimatedBitmap.new(skin) + __setWindowskin(@customskin.bitmap) end def setSystemFrame @customskin.dispose if @customskin - __setWindowskin(@sysframe) + __setWindowskin(@sysframe.bitmap) end def update super + if @customskin && @customskin.totalFrames>1 + @customskin.update + __setWindowskin(@customskin.bitmap) + elsif @sysframe && @sysframe.totalFrames>1 + @sysframe.update + __setWindowskin(@sysframe.bitmap) + end if @curframe!=pbGetSystemFrame @curframe=pbGetSystemFrame if @sysframe && !@customskin @sysframe.dispose if @sysframe - @sysframe=BitmapCache.load_bitmap($TextFrames[pbGetSystemFrame]) - __setWindowskin(@sysframe) + @sysframe=AnimatedBitmap.new($TextFrames[pbGetSystemFrame]) + __setWindowskin(@sysframe.bitmap) end begin @@ -2027,5 +2073,5 @@ super(0,0,dims[0],dims[1]) @item_max=commands.length - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") self.active=true colors=getDefaultTextColors(self.windowskin) @@ -2112,5 +2158,5 @@ next end - self.contents.blt(0,ypos,@selarrow,@selarrow.rect) if self.index==i + self.contents.blt(0,ypos,@selarrow.bitmap,@selarrow.bitmap.rect) if self.index==i self.contents.font.color=self.shadowColor pbDrawShadow(self.contents,16,ypos,contentsWidth,32,@commands[i]) @@ -2169,5 +2215,5 @@ super(0,0,dims[0],dims[1]) @item_max=commands.length - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") self.active=true colors=getDefaultTextColors(self.windowskin) @@ -2250,5 +2296,5 @@ next end - self.contents.blt(0,ypos,@selarrow,@selarrow.rect) if self.index==i + self.contents.blt(0,ypos,@selarrow.bitmap,@selarrow.bitmap.rect) if self.index==i chars=getFormattedText( self.contents,16,ypos,contentsWidth,32,preamble+@commands[i],32,true,true) @@ -2782,5 +2828,5 @@ def allocPause if !@pausesprite - @pausesprite=AnimatedSprite.create("Graphics/Pictures/pause.png",4,3) + @pausesprite=AnimatedSprite.create("Graphics/Pictures/pause",4,3) @pausesprite.z=100000 @pausesprite.visible=false @@ -2823,5 +2869,4 @@ @baseColor=colors[0] @shadowColor=colors[1] - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") @index=digits_max-1 refresh @@ -2836,8 +2881,4 @@ refresh end - def dispose - @selarrow.dispose - super - end def number=(value) value=0 if !value.is_a?(Numeric) @@ -2916,5 +2957,5 @@ attr_reader :animname def initializeLong(animname,framecount,framewidth,frameheight,frameskip) - @animname=animname + @animname=pbBitmapName(animname) @realframes=0 @frameskip=[1,frameskip].max @@ -2922,5 +2963,5 @@ raise _INTL("Frame height is 0") if frameheight==0 begin - @animbitmap=BitmapCache.load_bitmap(animname) + @animbitmap=AnimatedBitmap.new(animname).deanimate rescue @animbitmap=Bitmap.new(framewidth,frameheight) @@ -2946,9 +2987,9 @@ # the width and height need not be defined beforehand def initializeShort(animname,framecount,frameskip) - @animname=animname + @animname=pbBitmapName(animname) @realframes=0 @frameskip=[1,frameskip].max begin - @animbitmap=BitmapCache.load_bitmap(animname) + @animbitmap=AnimatedBitmap.new(animname).deanimate rescue @animbitmap=Bitmap.new(framecount*4,32) @@ -3014,26 +3055,8 @@ end end - -class ColoredPlane < Plane - def initialize(color,viewport=nil) - super(viewport) - self.bitmap=Bitmap.new(32,32) - setPlaneColor(color) - end - def dispose - self.bitmap.dispose if self.bitmap - super - end - def update; end - def setPlaneColor(value) - self.bitmap.fill_rect(0,0,self.bitmap.width,self.bitmap.height,value) - end -end - - -#A simple sprite class that displays an icon. +#Displays an icon bitmap in a sprite. Supports animated images. class IconSprite < SpriteWrapper attr_reader :name - def initialize(x,y,viewport=nil) + def initialize(x=0,y=0,viewport=nil) super(viewport) self.bitmap=nil @@ -3041,9 +3064,26 @@ self.y=y @name="" + @_iconbitmap=nil end def dispose - self.bitmap.dispose if self.bitmap + clearBitmaps() super end + def update + super + if @_iconbitmap + @_iconbitmap.update + if self.bitmap!=@_iconbitmap.bitmap + oldrc=self.src_rect + self.bitmap=@_iconbitmap.bitmap + self.src_rect=oldrc + end + end + end + def clearBitmaps + @_iconbitmap.dispose if @_iconbitmap + @_iconbitmap=nil + self.bitmap=nil if !self.disposed? + end # Sets the icon's filename. Alias for setBitmap. def name=(value) @@ -3051,47 +3091,49 @@ end # Sets the icon's filename. - def setBitmap(file) + def setBitmap(file,hue=0) + oldrc=self.src_rect + clearBitmaps() @name=file - self.bitmap.dispose if self.bitmap - if @name!="" - self.bitmap=BitmapCache.load_bitmap(file) + return if file==nil + if file!="" + @_iconbitmap=AnimatedBitmap.new(file,hue) + # for compatibility + self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil + self.src_rect=oldrc else - self.bitmap=nil + @_iconbitmap=nil end end end -class IconWindow < SpriteWindow_Base - def initialize(x,y,width,height,viewport=nil) - super(x,y,width,height) - self.viewport=viewport - self.contents=nil +#Old GifSprite class, retained for compatibility +class GifSprite < IconSprite + def initialize(path) + super(0,0) + setBitmap(path) end +end + +# A plane class that displays a single color. +class ColoredPlane < Plane + def initialize(color,viewport=nil) + super(viewport) + self.bitmap=Bitmap.new(32,32) + setPlaneColor(color) + end def dispose - self.contents.dispose if self.contents + self.bitmap.dispose if self.bitmap super end - def clearBitmap - self.contents.clear if self.contents && !self.contents.disposed? + def update; end + def setPlaneColor(value) + self.bitmap.fill_rect(0,0,self.bitmap.width,self.bitmap.height,value) end - def setBitmap(file) - iconbitmap=(!file||file.length==0) ? Bitmap.new(32,32) : BitmapCache.load_bitmap(file) - dwidth=iconbitmap.width - dheight=iconbitmap.height - if !self.contents || self.contents.disposed? || - self.contents.height= 384 @charbitmap.dispose if @charbitmap - @charbitmap = RPG::Cache.tile(@character.map.tileset_name, + @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @character.character_hue) + @charbitmapAnimated=false @bushbitmap.dispose if @bushbitmap @bushbitmap=nil @@ -60,6 +88,8 @@ else @charbitmap.dispose if @charbitmap - @charbitmap = RPG::Cache.character(@character.character_name, + @charbitmap = AnimatedBitmap.new( + "Graphics/Characters/"+@character.character_name, @character.character_hue) + @charbitmapAnimated=true @bushbitmap.dispose if @bushbitmap @bushbitmap=nil @@ -70,15 +100,12 @@ end end + @charbitmap.update if @charbitmapAnimated if @character.bush_depth==0 - self.bitmap=@charbitmap + self.bitmap=@charbitmapAnimated ? @charbitmap.bitmap : @charbitmap else if !@bushbitmap - if @tile_id >= 384 - @bushbitmap=pbBushDepthTile(@charbitmap,12) - else - @bushbitmap=pbBushDepthBitmap(@charbitmap,12) - end + @bushbitmap=BushBitmap.new(@charbitmap,@tile_id >= 384) end - self.bitmap=@bushbitmap + self.bitmap=@bushbitmap.bitmap end self.visible = (not @character.transparent) @@ -109,2 +136,3 @@ end end + Changed: Scene_Credits --- Left +++ Right @@ -1,4 +1,4 @@ -CREDITS_FONT = ["Calligraph421 BT", "Viner Hand ITC", "Arial", "Times New Roman"] -CREDITS_SIZE = 24 +# Backgrounds to show in credits. Found in Graphics/Titles/ folder +CreditsBackgroundList=["Pic_2","Black"] CREDITS_OUTLINE = Color.new(0,0,127, 255) CREDITS_SHADOW = Color.new(0,0,0, 100) @@ -6,5 +6,5 @@ #============================================================================== -# ¦ Scene_Credits +# * Scene_Credits #------------------------------------------------------------------------------ # Scrolls the credits you make below. Original Author unknown. Edited by @@ -28,5 +28,40 @@ CREDIT=<<_END_ +Credits go here. +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + +Credits go here. + _END_ #Stop Editing @@ -37,11 +72,10 @@ #------------------------------- -@sprite = Sprite.new -#@sprite.bitmap = RPG::Cache.title($data_system.title_name) -@backgroundList = ["Black"] #Edit this to the title screen(s) you wish to show in the background. They do repeat. +@sprite = IconSprite.new(0,0) +@backgroundList = CreditsBackgroundList @backgroundGameFrameCount = 0 # Number of game frames per background frame. -@backgroundG_BFrameCount = 3.4 -@sprite.bitmap = RPG::Cache.title(@backgroundList[0]) +@backgroundG_BFrameCount = 400 +@sprite.setBitmap("Graphics/Titles/"+@backgroundList[0]) #------------------ @@ -50,24 +84,30 @@ credit_lines = CREDIT.split(/\n/) -credit_bitmap = Bitmap.new(640,32 * credit_lines.size) +credit_bitmap = Bitmap.new(Graphics.width,32 * credit_lines.size) credit_lines.each_index do |i| line = credit_lines[i] -credit_bitmap.font.name = CREDITS_FONT -credit_bitmap.font.size = CREDITS_SIZE +# LINE ADDED: If you use in your own game, you +# should remove this line +pbSetSystemFont(credit_bitmap) x = 0 credit_bitmap.font.color = CREDITS_OUTLINE -credit_bitmap.draw_text(0 + 1,i * 32 + 1,640,32,line,1) -credit_bitmap.draw_text(0 - 1,i * 32 + 1,640,32,line,1) -credit_bitmap.draw_text(0 + 1,i * 32 - 1,640,32,line,1) -credit_bitmap.draw_text(0 - 1,i * 32 - 1,640,32,line,1) +credit_bitmap.draw_text(0 + 2,i * 32 - 2,Graphics.width,32,line,1) +credit_bitmap.draw_text(0,i * 32 - 2,Graphics.width,32,line,1) +credit_bitmap.draw_text(0 - 2,i * 32 - 2,Graphics.width,32,line,1) +credit_bitmap.draw_text(0 + 2,i * 32,Graphics.width,32,line,1) +credit_bitmap.draw_text(0 - 2,i * 32,Graphics.width,32,line,1) +credit_bitmap.draw_text(0 + 2,i * 32 + 2,Graphics.width,32,line,1) +credit_bitmap.draw_text(0,i * 32 + 2,Graphics.width,32,line,1) +credit_bitmap.draw_text(0 - 2,i * 32 + 2,Graphics.width,32,line,1) credit_bitmap.font.color = CREDITS_SHADOW -credit_bitmap.draw_text(0,i * 32 + 8,640,32,line,1) +credit_bitmap.draw_text(0,i * 32 + 8,Graphics.width,32,line,1) credit_bitmap.font.color = CREDITS_FILL -credit_bitmap.draw_text(0,i * 32,640,32,line,1) +credit_bitmap.draw_text(0,i * 32,Graphics.width,32,line,1) end -@credit_sprite = Sprite.new(Viewport.new(0,50,640,380)) +@trim=Graphics.height/10 +@credit_sprite = Sprite.new(Viewport.new(0,@trim,Graphics.width,Graphics.height-(@trim*2))) @credit_sprite.bitmap = credit_bitmap @credit_sprite.z = 9998 -@credit_sprite.oy = -430 #-430 +@credit_sprite.oy = -(Graphics.height-@trim) #-430 @frame_index = 0 @last_flag = false @@ -102,6 +142,6 @@ ##Checks if credits bitmap has reached it's ending point def last? - if @frame_index > (@credit_sprite.bitmap.height + 500) - $scene = Scene_Map.new + if @frame_index > (@credit_sprite.bitmap.height + Graphics.height + (@trim/2)) + $scene = ($game_map) ? Scene_Map.new : nil Audio.bgm_fade(10000) #aprox 10 seconds return true @@ -112,25 +152,25 @@ #Check if the credits should be cancelled def cancel? - if Input.trigger?(Input::C) - $scene = Scene_Map.new - return true - end - return false - end -def update -@backgroundGameFrameCount = @backgroundGameFrameCount + 1 -if @backgroundGameFrameCount >= @backgroundG_BFrameCount -@backgroundGameFrameCount = 0 -# Add current background frame to the end -@backgroundList = @backgroundList << @backgroundList[0] -# and drop it from the first position -@backgroundList.delete_at(0) -@sprite.bitmap = RPG::Cache.title(@backgroundList[0]) + if Input.trigger?(Input::C) + $scene = Scene_Map.new + return true + end + return false end -return if cancel? -return if last? -@credit_sprite.oy += 1 #this is the speed that the text scrolls. 1 is default -#The fastest I'd recomend is 5, after that it gets hard to read. -@frame_index += 1 #This should fix the non-self-ending credits +def update + @backgroundGameFrameCount = @backgroundGameFrameCount + 1 + if @backgroundGameFrameCount >= @backgroundG_BFrameCount + @backgroundGameFrameCount = 0 + # Add current background frame to the end + @backgroundList = @backgroundList << @backgroundList[0] + # and drop it from the first position + @backgroundList.delete_at(0) + @sprite.setBitmap("Graphics/Titles/"+@backgroundList[0]) + end + return if cancel? + return if last? + @credit_sprite.oy += 1 #this is the speed that the text scrolls. 1 is default + #The fastest I'd recomend is 5, after that it gets hard to read. + @frame_index += 1 #This should fix the non-self-ending credits end end Changed: PokemonSystem --- Left +++ Right @@ -1,4 +1,4 @@ def pbSafeLoad(file) - if FileTest.exist?("./Game.rgssad") && FileTest.exist?(file) + if (FileTest.exist?("./Game.rgssad") || FileTest.exist?("./Game.rgss2a")) && FileTest.exist?(file) File.delete(file) rescue nil end @@ -127,36 +127,4 @@ end end -=begin -module Graphics - unless defined?(update_gs_grap) - class << Graphics - alias update_gs_grap update - end - end - def self.update - update_gs_grap - if Graphics.frame_count%10==0 - activesprites=0 - activeviewports=0 - activebitmaps=0 - activeplanes=0 - activewindows=0 - activetilemaps=0 - activetmsprites=0 - numsprites=ObjectSpace.each_object(Sprite){|o| activesprites+=1 if !o.disposed?} - numtmsprites=ObjectSpace.each_object(CustomTilemapSprite){|o| activetmsprites+=1 if !o.disposed?} - numviewports=ObjectSpace.each_object(Viewport){|o| activeviewports+=1; o.x rescue activeviewports-=1} - numbitmaps=ObjectSpace.each_object(Bitmap){|o| activebitmaps+=1 if !o.disposed?} - numplanes=ObjectSpace.each_object(Plane){|o| activeplanes+=1 if !o.disposed?} - numwindows=ObjectSpace.each_object(Window){|o| activewindows+=1 if !o.disposed?} - numtilemaps=ObjectSpace.each_object(TilemapLoader){|o| activetilemaps+=1 if !o.disposed?} - echoln sprintf("spr=%d,%d,%d vp=%d,%d bm=%d,%d p=%d,%d win=%d,%d tile=%d,%d", - numsprites,activesprites,activetmsprites,numviewports,activeviewports, - numbitmaps,activebitmaps,numplanes,activeplanes, - numwindows,activewindows,numtilemaps,activetilemaps) - end - end -end -=end def pbDebugF7 if $DEBUG @@ -172,94 +140,2 @@ pbSetUpSystem -class Bitmap - # Fast methods for retrieving bitmap data - RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i') - RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i') - def setData(x) - RtlMoveMemory_ip.call(self.address, x, x.length) - end - def getData - data = "rgba" * width * height - RtlMoveMemory_pi.call(data, self.address, data.length) - return data - end - def swap32(x) - return ((x>>24)&0x000000FF)| - ((x>>8)&0x0000FF00)| - ((x<<8)&0x00FF0000)| - ((x<<24)&0xFF000000) - end - def saveToPng(filename) - bytes=[ - 0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A, - 0x00,0x00,0x00,0x0D - ].pack("CCCCCCCCCCCC") - ihdr=[ - 0x49,0x48,0x44,0x52, - swap32(self.width), - swap32(self.height), - 0x08,0x06,0x00,0x00,0x00 - ].pack("CCCCVVCCCCC") - crc=Zlib::crc32(ihdr) - ihdr+=[swap32(crc)].pack("V") - bytesPerScan=self.width*4 - row=(self.height-1)*bytesPerScan - data=self.getData - width=self.width - x="" - ttt=Time.now - noswaps=0 - while row>=0 - x.concat("\0") - thisRow=data[row,bytesPerScan] - t=0;b=0;bp2=0 - i=0 - while i=timeout end @@ -588,5 +588,5 @@ end @sprites["entry"].visible=true - addBackgroundPlane(@sprites,"background","loginbg.png",@viewport) + addBackgroundPlane(@sprites,"background","loginbg",@viewport) pbFadeInAndShow(@sprites) end @@ -669,5 +669,5 @@ @sprites["entry"].visible=true pbChange - addBackgroundPlane(@sprites,"background","registerbg.png",@viewport) + addBackgroundPlane(@sprites,"background","registerbg",@viewport) pbFadeInAndShow(@sprites) end Changed: PokemonUtilities --- Left +++ Right @@ -1,47 +1,25 @@ module PBDayNight - # Screen tints for each hour of the day. - HourlyTones=[ + Shades=[ Tone.new(-142.5,-142.5,-22.5,68), - Tone.new(-135.5,-135.5,-24,68), + Tone.new(-142.5,-142.5,-22.5,68), + Tone.new(-142.5,-142.5,-22.5,68), + Tone.new(-135.5,-135.5,-24.0,68), + Tone.new(-127.5,-127.5,-25.5,68), - Tone.new(-127.5,-127.5,-25.5,68), - Tone.new(-119,-96.3,-45.3,45.3), - Tone.new(-51,-73.7,-73.7,22.7), - Tone.new(17,-51,-102,0), - Tone.new(14.2,-42.5,-85,0), - Tone.new(11.3,-34,-68,0), - Tone.new(8.5,-25.5,-51,0), - Tone.new(5.7,-17,-34,0), - Tone.new(2.8,-8.5,-17,0), + Tone.new(-88.5,-133,-31,34), + Tone.new(-44.5,-39,-17,34), + Tone.new(-10,-18,-11,0), + + Tone.new(5.7,-9,-5,0), + Tone.new(2,-2,-2,0), Tone.new(0,0,0,0), Tone.new(0,0,0,0), + Tone.new(0,0,0,0), Tone.new(0,0,0,0), - Tone.new(-3,-7,-2,0), - Tone.new(-10,-18,-5,0), - Tone.new(-36,-75,-13,0), - Tone.new(-72,-136,-34,3), - Tone.new(-88.5,-133,-31,34), - Tone.new(-108.5,-129,-28,68), - Tone.new(-127.5,-127.5,-25.5,68), - Tone.new(-142.5,-142.5,-22.5,68) + Tone.new(0,0,0,0), + Tone.new(0,0,0,0) ] - # Adjustments to the clock in summer - SummerAdjustment=[ - 0, 1.25, 2.75, 4, 5, 6, - 7, 8, 9, 9.75, 10.5, 11.25, - 12, 12,75, 13.25, 14, 15, 16, - 17, 18, 19.5, 21, 22.5, 23.5] - # Adjustments to the clock in winter - WinterAdjustment=[ - 0, 0.5, 1, 1.5, 2, 3.5, - 5, 6.5, 7.5, 9, 10, 11, - 12, 14, 16, 18.5, 19.5, 20.75, - 21.5, 22, 22.25, 22.75, 23.25, 23.75] - # Proportion of the summer adjustment to apply for each month - SummerMultiplier=[0.0, 0.1, 0.2, 0.5, 0.7, 0.8, 1.0, 0.95, 0.8, 0.5, 0.2, 0.05] - # Proportion of the winter adjustment to apply for each month - WinterMultiplier= [1.0, 0.9, 0.8, 0.5, 0.3, 0.2, 0.0, 0.05, 0.2, 0.5, 0.8, 0.95] end @@ -62,34 +40,96 @@ end -def pbGetDayNightMinutes - now=Time.now # Get the current system time - hour=now.hour - minute=now.min - month=now.mon-1 - nextMonth=(month+1)%12 - nextHour=hour==0 ? 23 : hour-1 - dayPosition=month==1 ? ([28,now.mday].min-1)/28.0 : ([30,now.mday].min-1)/30.0 - summerMult=PBDayNight::SummerMultiplier[month]*1.0; - summerMult+=(PBDayNight::SummerMultiplier[nextMonth]-PBDayNight::SummerMultiplier[month])*dayPosition - winterMult=PBDayNight::WinterMultiplier[month]*1.0; - winterMult+=(PBDayNight::WinterMultiplier[nextMonth]-PBDayNight::WinterMultiplier[month])*dayPosition - realHour=PBDayNight::SummerAdjustment[hour]*summerMult+ - PBDayNight::WinterAdjustment[hour]*winterMult - realNextHour=PBDayNight::SummerAdjustment[nextHour]*summerMult+ - PBDayNight::WinterAdjustment[nextHour]*winterMult - realMinutes=realHour+((realNextHour-realHour)*(minute/60.0)) - realMinutes=((realMinutes*60).to_i)%(60*24) - realMinutes=0 if realMinutes<0 - realMinutes=3599 if realMinutes>3599 - return realMinutes +def getShade(lat,lon,sunPos) # all coordinates in radians + # 0 = full night; 255 = full day + vec=[Math.sin(lon)*Math.cos(lat),Math.sin(lat),Math.cos(lon)*Math.cos(lat)] + lat=sunPos[0]; lon=sunPos[1] + vec2=[Math.sin(lon)*Math.cos(lat),Math.sin(lat),Math.cos(lon)*Math.cos(lat)] + ret=((vec[0]*vec2[0]+vec[1]*vec2[1]+vec[2]*vec2[2])+1)*128 + ret=0 if ret<0 + ret=255 if ret>255 + return ret end +def modulus(x,y) + return x-(x/y).floor*y +end + +def getSunCoords(time) + d=(2440586.5+time.to_i/86400.0)-2447891.5 + twopi=Math::PI*2 + n=modulus(d*0.0172027916325241,twopi) + m=modulus(n-0.0587324062714191,twopi) + e = m + while true + d=e-0.016713*Math.sin(e)-m + break if d.abs<=1e-8 + e-= (d / (1 - 0.016713 * Math.cos(e))) + end + n=Math.tan(e/2)*1.0168550261128 + l=Math.atan(n)*2+4.93523998456877 + sinL=Math.sin(l) + lon = Math.atan2(sinL*0.917473044269959, Math.cos(l)) + lat = Math.asin(sinL*0.397797955045038) + seconds=modulus(time.to_i,86400.0) + d=(2440586.5+(time.to_i-seconds)/86400.0) + t = (d - 2451545) / 36525.0 + t=modulus(6.697374558 + (2400.051336 * t) + (2.5862e-5 * t * t),24.0) + t=modulus( t + (seconds/3600.0) * 1.002737909,24.0) + lon=(lon-(Math::PI/12)*t) + return [ + modulus(lat,twopi), # latitude of sun in radians + modulus(lon,twopi) # longitude of sun in radians + ] +end + +class PokemonTemp + attr_accessor :hourlyTones +end + +def pbShadeToTone(shade) + part=shade%16 + thisTone=PBDayNight::Shades[shade/16] + nextTone=PBDayNight::Shades[((shade/16)+1)%16] + red = ((nextTone.red-thisTone.red)*part/16.0)+thisTone.red + green = ((nextTone.green-thisTone.green)*part/16.0)+thisTone.green + blue = ((nextTone.blue-thisTone.blue)*part/16.0)+thisTone.blue + gray = ((nextTone.gray-thisTone.gray)*part/16.0)+thisTone.gray + return Tone.new(red,green,blue,gray) +end + +def pbGetDayNightShade() + sun=getSunCoords(Time.now) + return getShade( + -42*Math::PI/180, + ((Time.now.gmt_offset/3600)*15)*Math::PI/180,sun) +end + def pbSetDayNightTone(toneToSet) - # Gets the time of day in minutes that the current time "feels like" - realMinutes=pbGetDayNightMinutes() - hour=realMinutes/60 - minute=realMinutes%60 - tone=PBDayNight::HourlyTones[hour] - nexthourtone=PBDayNight::HourlyTones[(hour+1)%24] + return if !$PokemonTemp + now=Time.now + if (!$PokemonTemp.hourlyTones || (Graphics.frame_count%5000)==0) + $PokemonTemp.hourlyTones=[] + day=0 + # Get just the day + if now.gmt? + day=Time.gm(now.year,now.mon,now.day).to_i + else + day=Time.local(now.year,now.mon,now.day).to_i + end + # Calculate the position of the sun for each hour depending + # on the current day and time zone + shades=[] + for i in 0...24 + sun=getSunCoords(Time.at(day+i*3600)) + shade=getShade( + -42*Math::PI/180, + ((now.gmt_offset/3600)*15)*Math::PI/180,sun) + $PokemonTemp.hourlyTones[i]=pbShadeToTone(shade) + end + end + hour=now.hour + minute=now.min + tone=$PokemonTemp.hourlyTones[hour] + nexthourtone=$PokemonTemp.hourlyTones[(hour+1)%24] # Calculate current tint according to current and next hour's tint and # depending on current minute @@ -320,10 +360,10 @@ def pbLoadPokemonIcon(pokemon) - return BitmapCache.load_bitmap(pbPokemonIconFile(pokemon)) + return AnimatedBitmap.new(pbPokemonIconFile(pokemon)).deanimate end def pbPokemonIconFile(pokemon) if pokemon.egg? # Special case for eggs - return sprintf("Graphics/Pictures/iconEgg.png") + return sprintf("Graphics/Pictures/iconEgg") end if isConst?(pokemon.species,PBSpecies,:UNOWN) @@ -334,5 +374,5 @@ d|=((pokemon.personalID>>24)&3)<<6 d%=28 # index of letter : ABCDEFGHIJKLMNOPQRSTUVWXYZ!? - filename=sprintf("Graphics/Icons/icon%03d_%02d.png",pokemon.species,d) + filename=sprintf("Graphics/Icons/icon%03d_%02d",pokemon.species,d) begin load_data(filename) @@ -342,5 +382,5 @@ end end - return sprintf("Graphics/Icons/icon%03d.png",pokemon.species) + return sprintf("Graphics/Icons/icon%03d",pokemon.species) end @@ -460,8 +500,7 @@ def pbLoadPokemonBitmapSpecies(pokemon, species, back=false) if pokemon.egg? - return BitmapCache.load_bitmap( - sprintf("Graphics/Pictures/egg.png")) + return AnimatedBitmap.new(sprintf("Graphics/Pictures/egg")).deanimate end - bitmapFileName=sprintf("Graphics/Battlers/%03d%s%s.png",species, + bitmapFileName=sprintf("Graphics/Battlers/%03d%s%s",species, pokemon.isShiny? ? "s" : "", back ? "b" : "") @@ -479,14 +518,14 @@ # Load special bitmap if found # Example: 201b_02 for the letter C - return BitmapCache.load_bitmap( - sprintf("Graphics/Battlers/%03d%s%s_%02d.png",species, + return AnimatedBitmap.new( + sprintf("Graphics/Battlers/%03d%s%s_%02d",species, pokemon.isShiny? ? "s" : "", back ? "b" : "", d) - ) + ).deanimate rescue # Load plain bitmap as usual (see below) end end - return BitmapCache.load_bitmap(bitmapFileName) + return AnimatedBitmap.new(bitmapFileName).deanimate end @@ -742,8 +781,8 @@ if shiny # Load shiny bitmap - return sprintf("Graphics/Battlers/%03ds%s.png",species,back ? "b" : "") + return sprintf("Graphics/Battlers/%03ds%s",species,back ? "b" : "") else # Load normal bitmap - return sprintf("Graphics/Battlers/%03d%s.png",species,back ? "b" : "") + return sprintf("Graphics/Battlers/%03d%s",species,back ? "b" : "") end end @@ -1203,5 +1242,5 @@ for i in 0...1000 begin - filename=sprintf("%s%d.tmp",prefix,i) + filename=sprintf(ENV["TEMP"]+"\\%s%d.tmp",prefix,i) return File.open(filename,mode) rescue Errno::EINVAL, Errno::EACCES, Errno::ENOENT @@ -1548,2 +1587,89 @@ end end + + + +=begin +module PBDayNight + # Screen tints for each hour of the day. + HourlyTones=[ + Tone.new(-142.5,-142.5,-22.5,68), + Tone.new(-135.5,-135.5,-24,68), + Tone.new(-127.5,-127.5,-25.5,68), + Tone.new(-127.5,-127.5,-25.5,68), + Tone.new(-119,-96.3,-45.3,45.3), + Tone.new(-51,-73.7,-73.7,22.7), + Tone.new(17,-51,-102,0), + Tone.new(14.2,-42.5,-85,0), + Tone.new(11.3,-34,-68,0), + Tone.new(8.5,-25.5,-51,0), + Tone.new(5.7,-17,-34,0), + Tone.new(2.8,-8.5,-17,0), + Tone.new(0,0,0,0), + Tone.new(0,0,0,0), + Tone.new(0,0,0,0), + Tone.new(0,0,0,0), + Tone.new(-3,-7,-2,0), + Tone.new(-10,-18,-5,0), + Tone.new(-36,-75,-13,0), + Tone.new(-72,-136,-34,3), + Tone.new(-88.5,-133,-31,34), + Tone.new(-108.5,-129,-28,68), + Tone.new(-127.5,-127.5,-25.5,68), + Tone.new(-142.5,-142.5,-22.5,68) + ] + # Adjustments to the clock in summer + SummerAdjustment=[ + 0, 1.25, 2.75, 4, 5, 6, + 7, 8, 9, 9.75, 10.5, 11.25, + 12, 12,75, 13.25, 14, 15, 16, + 17, 18, 19.5, 21, 22.5, 23.5] + # Adjustments to the clock in winter + WinterAdjustment=[ + 0, 0.5, 1, 1.5, 2, 3.5, + 5, 6.5, 7.5, 9, 10, 11, + 12, 14, 16, 18.5, 19.5, 20.75, + 21.5, 22, 22.25, 22.75, 23.25, 23.75] + # Proportion of the summer adjustment to apply for each month + SummerMultiplier=[0.0, 0.1, 0.2, 0.5, 0.7, 0.8, 1.0, 0.95, 0.8, 0.5, 0.2, 0.05] + # Proportion of the winter adjustment to apply for each month + WinterMultiplier= [1.0, 0.9, 0.8, 0.5, 0.3, 0.2, 0.0, 0.05, 0.2, 0.5, 0.8, 0.95] +end +def pbGetDayNightMinutes + now=Time.now # Get the current system time + hour=now.hour + minute=now.min + month=now.mon-1 + nextMonth=(month+1)%12 + nextHour=hour==0 ? 23 : hour-1 + dayPosition=month==1 ? ([28,now.mday].min-1)/28.0 : ([30,now.mday].min-1)/30.0 + summerMult=PBDayNight::SummerMultiplier[month]*1.0; + summerMult+=(PBDayNight::SummerMultiplier[nextMonth]-PBDayNight::SummerMultiplier[month])*dayPosition + winterMult=PBDayNight::WinterMultiplier[month]*1.0; + winterMult+=(PBDayNight::WinterMultiplier[nextMonth]-PBDayNight::WinterMultiplier[month])*dayPosition + realHour=PBDayNight::SummerAdjustment[hour]*summerMult+ + PBDayNight::WinterAdjustment[hour]*winterMult + realNextHour=PBDayNight::SummerAdjustment[nextHour]*summerMult+ + PBDayNight::WinterAdjustment[nextHour]*winterMult + realMinutes=realHour+((realNextHour-realHour)*(minute/60.0)) + realMinutes=((realMinutes*60).to_i)%(60*24) + realMinutes=0 if realMinutes<0 + realMinutes=3599 if realMinutes>3599 + return realMinutes +end + +def pbSetDayNightTone(toneToSet) + # Gets the time of day in minutes that the current time "feels like" + realMinutes=pbGetDayNightMinutes() + hour=realMinutes/60 + minute=realMinutes%60 + tone=PBDayNight::HourlyTones[hour] + nexthourtone=PBDayNight::HourlyTones[(hour+1)%24] + # Calculate current tint according to current and next hour's tint and + # depending on current minute + toneToSet.red = ((nexthourtone.red-tone.red)*minute/60.0)+tone.red + toneToSet.green = ((nexthourtone.green-tone.green)*minute/60.0)+tone.green + toneToSet.blue = ((nexthourtone.blue-tone.blue)*minute/60.0)+tone.blue + toneToSet.gray = ((nexthourtone.gray-tone.gray)*minute/60.0)+tone.gray +end +=end Changed: PokemonScreen --- Left +++ Right @@ -1,2 +1,3 @@ + # Data structure representing mail that the Pokémon can hold class PokemonMail @@ -37,6 +38,6 @@ viewport.z=99999 addBackgroundPlane(@sprites,"background","mailbg",@viewport) - sprites["card"]=Sprite.new(viewport) - sprites["card"].bitmap=BitmapCache.load_bitmap(sprintf("Graphics/Pictures/item%03d.png",mail.item)) + sprites["card"]=IconSprite.new(0,0,viewport) + sprites["card"].setBitmap(sprintf("Graphics/Pictures/item%03d",mail.item)) sprites["overlay"]=Sprite.new(viewport) sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) @@ -95,6 +96,6 @@ def pokemon=(value) @animbitmap.dispose if @animbitmap - @animbitmap=pbLoadPokemonIcon(value) - self.bitmap=@animbitmap + @animbitmap=AnimatedBitmap.new(pbPokemonIconFile(value)) + self.bitmap=@animbitmap.bitmap self.src_rect=@frames[@animframe] end @@ -114,4 +115,9 @@ @updating=true super + if @animbitmap + @animbitmap.update + self.bitmap=@animbitmap.bitmap + self.src_rect=@frames[@animframe] + end frameskip=5 frameskip=10 if @pokemon.hp<=(@pokemon.totalhp/2) @@ -154,9 +160,15 @@ yvalues=[20,132,20,84,148,212] end - self.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/advPartyEmpty.png") + @pbitmap=AnimatedBitmap.new("Graphics/Pictures/advPartyEmpty") + self.bitmap=@pbitmap.bitmap self.x=xvalues[index] self.y=yvalues[index] @text=nil end + def update + super + @pbitmap.update + self.bitmap=@pbitmap.bitmap + end def selected return false @@ -182,15 +194,20 @@ super(viewport) @refreshBitmap=true - @deselbitmap=Bitmap.new("Graphics/Pictures/pokeselcancel.png") - @selbitmap=Bitmap.new("Graphics/Pictures/pokeselcancelsel.png") + @bgsprite=ChangelingSprite.new(0,0,viewport) + @bgsprite.addBitmap("deselbitmap","Graphics/Pictures/pokeselcancel") + @bgsprite.addBitmap("selbitmap","Graphics/Pictures/pokeselcancelsel") + @bgsprite.changeBitmap("deselbitmap") + @overlaysprite=SpriteWrapper.new(viewport) + @overlaysprite.bitmap=Bitmap.new( + @bgsprite.bitmap.width,@bgsprite.bitmap.height) + @pokeballsprite=ChangelingSprite.new(0,0,viewport) if smallicons - @pokeballdesel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselballsm.png") - @pokeballsel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselopenballsm.png") + @pokeballsprite.addBitmap("pokeballdesel","Graphics/Pictures/pokeselballsm") + @pokeballsprite.addBitmap("pokeballsel","Graphics/Pictures/pokeselopenballsm") else - @pokeballdesel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselball.png") - @pokeballsel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselopenball.png") + @pokeballsprite.addBitmap("pokeballdesel","Graphics/Pictures/pokeselball") + @pokeballsprite.addBitmap("pokeballsel","Graphics/Pictures/pokeselopenball") end - pbSetSmallFont(@deselbitmap) - pbSetSmallFont(@selbitmap) + pbSetSmallFont(@overlaysprite.bitmap) @yoffset=(smallicons) ? 0 : 8 base=Color.new(31*8,31*8,31*8) @@ -199,17 +216,15 @@ [text,(smallicons) ? 24 : 36,4,false,base,shadow], ] - pbDrawTextPositions(@deselbitmap,textpos) - pbDrawTextPositions(@selbitmap,textpos) - @pokeballsprite=SpriteWrapper.new(viewport) - @pokeballsprite.z=self.z+1 # For compatibility with RGSS2 + pbDrawTextPositions(@overlaysprite.bitmap,textpos) + @overlaysprite.z=self.z+1 # For compatibility with RGSS2 + @pokeballsprite.z=self.z+2 # For compatibility with RGSS2 self.x=x self.y=y end def dispose - @selbitmap.dispose - @deselbitmap.dispose + @overlaysprite.bitmap.dispose + @overlaysprite.dispose + @bgsprite.dispose @pokeballsprite.dispose - @pokeballsel.dispose - @pokeballdesel.dispose super end @@ -235,9 +250,15 @@ end def refresh - self.bitmap=(@selected) ? @selbitmap : @deselbitmap + @bgsprite.changeBitmap((@selected) ? "selbitmap" : "deselbitmap") if @pokeballsprite && !@pokeballsprite.disposed? @pokeballsprite.x=self.x-8 @pokeballsprite.y=self.y-@yoffset - @pokeballsprite.bitmap=self.selected ? @pokeballsel : @pokeballdesel + @bgsprite.x=self.x + @bgsprite.y=self.y + @overlaysprite.x=self.x + @overlaysprite.y=self.y + @bgsprite.color=self.color + @overlaysprite.color=self.color + @pokeballsprite.changeBitmap(self.selected ? "pokeballsel" : "pokeballdesel") @pokeballsprite.color=self.color end @@ -264,4 +285,34 @@ end +class ChangelingSprite < SpriteWrapper + def initialize(x=0,y=0,viewport=nil) + super(viewport) + self.x=x + self.y=y + @bitmaps={} + @currentBitmap=nil + end + def addBitmap(key,path) + if @bitmaps[key] + @bitmaps[key].dispose + end + @bitmaps[key]=AnimatedBitmap.new(path) + end + def changeBitmap(key) + @currentBitmap=@bitmaps[key] + self.bitmap=@currentBitmap ? @currentBitmap.bitmap : nil + end + def dispose + return if disposed? + for bm in @bitmaps.values; bm.dispose; end + @bitmaps.clear + super + end + def update + return if disposed? + for bm in @bitmaps.values; bm.update; end + self.bitmap=@currentBitmap ? @currentBitmap.bitmap : nil + end +end class PokeSelectionSprite < SpriteWrapper @@ -277,6 +328,6 @@ @active=active if active - @deselbitmap=BitmapCache.load_bitmap("Graphics/Pictures/advPartyActive.png") - @selbitmap=BitmapCache.load_bitmap("Graphics/Pictures/advPartyActiveSel.png") + @deselbitmap=AnimatedBitmap.new("Graphics/Pictures/advPartyActive") + @selbitmap=AnimatedBitmap.new("Graphics/Pictures/advPartyActiveSel") @spriteXOffset=-16 @spriteYOffset=-2 @@ -302,6 +353,6 @@ @annotY=64 else - @deselbitmap=BitmapCache.load_bitmap("Graphics/Pictures/advPartyInactive.png") - @selbitmap=BitmapCache.load_bitmap("Graphics/Pictures/advPartyInactiveSel.png") + @deselbitmap=AnimatedBitmap.new("Graphics/Pictures/advPartyInactive") + @selbitmap=AnimatedBitmap.new("Graphics/Pictures/advPartyInactiveSel") @spriteXOffset=-16 @spriteYOffset=-16 @@ -335,14 +386,13 @@ end @text=nil - @statuses=BitmapCache.load_bitmap(_INTL("Graphics/Pictures/statuses.png")) - @hpbar=BitmapCache.load_bitmap("Graphics/Pictures/advHPBar.png") - @pokeballdesel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselball.png") - @pokeballsel=BitmapCache.load_bitmap("Graphics/Pictures/pokeselopenball.png") - @pokeballsprite=SpriteWrapper.new(viewport) + @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses")) + @hpbar=AnimatedBitmap.new("Graphics/Pictures/advHPBar") + @pokeballsprite=ChangelingSprite.new(0,0,viewport) + @pokeballsprite.addBitmap("pokeballdesel","Graphics/Pictures/pokeselball") + @pokeballsprite.addBitmap("pokeballsel","Graphics/Pictures/pokeselopenball") @pkmnsprite=PokemonPartyIcon.new(pokemon,active,viewport) - @itemsprite=SpriteWrapper.new(viewport) - @itembitmap=BitmapCache.load_bitmap("Graphics/Pictures/item.png") - @mailbitmap=BitmapCache.load_bitmap("Graphics/Pictures/mail.png") - @itemsprite.bitmap=@itembitmap + @itemsprite=ChangelingSprite.new(0,0,viewport) + @itemsprite.addBitmap("itembitmap","Graphics/Pictures/item") + @itemsprite.addBitmap("mailbitmap","Graphics/Pictures/mail") @spriteX=xvalues[index] @spriteY=yvalues[index] @@ -360,12 +410,8 @@ end def dispose - @mailbitmap.dispose - @itembitmap.dispose @selbitmap.dispose @statuses.dispose @hpbar.dispose @deselbitmap.dispose - @pokeballsel.dispose - @pokeballdesel.dispose @itemsprite.dispose @pkmnsprite.dispose @@ -434,11 +480,11 @@ @pokeballsprite.x=self.x+@pokeballXOffset @pokeballsprite.y=self.y+@pokeballYOffset - @pokeballsprite.bitmap=self.selected ? @pokeballsel : @pokeballdesel @pokeballsprite.color=self.color + @pokeballsprite.changeBitmap(self.selected ? "pokeballsel" : "pokeballdesel") end if @itemsprite && !@itemsprite.disposed? @itemsprite.visible=(@pokemon.item>0) if @itemsprite.visible - @itemsprite.bitmap=(@pokemon.mail) ? @mailbitmap : @itembitmap + @itemsprite.changeBitmap(@pokemon.mail ? "mailbitmap" : "itembitmap") @itemsprite.x=self.x+@itemXOffset @itemsprite.y=self.y+@itemYOffset @@ -449,8 +495,8 @@ @refreshBitmap=false if self.selected - self.bitmap.blt(0,0,@selbitmap,Rect.new(0,0,@selbitmap.width,@selbitmap.height)) + self.bitmap.blt(0,0,@selbitmap.bitmap,Rect.new(0,0,@selbitmap.width,@selbitmap.height)) self.bitmap.hue_change(180) if @pokemon.hp<=0 && !@pokemon.egg? else - self.bitmap.blt(0,0,@deselbitmap,Rect.new(0,0,@deselbitmap.width,@deselbitmap.height)) + self.bitmap.blt(0,0,@deselbitmap.bitmap,Rect.new(0,0,@deselbitmap.width,@deselbitmap.height)) self.bitmap.hue_change(180) if @pokemon.hp<=0 && !@pokemon.egg? end @@ -467,5 +513,5 @@ textpos.push([_ISPRINTF("{1: 3d}/{2: 3d}",@pokemon.hp,@pokemon.totalhp), @hpX,@hpY,true,base,shadow]) - self.bitmap.blt(@hpbarX,@hpbarY,@hpbar,Rect.new(0,0,@hpbar.width,@hpbar.height)) + self.bitmap.blt(@hpbarX,@hpbarY,@hpbar.bitmap,Rect.new(0,0,@hpbar.width,@hpbar.height)) end if @pokemon.gender==0 @@ -487,5 +533,5 @@ status=(@pokemon.hp==0) ? 5 : @pokemon.status-1 statusrect=Rect.new(0,16*status,44,16) - self.bitmap.blt(@statusX,@statusY,@statuses,statusrect) + self.bitmap.blt(@statusX,@statusY,@statuses.bitmap,statusrect) end end @@ -521,4 +567,6 @@ def update super + @pokeballsprite.update if @pokeballsprite && !@pokeballsprite.disposed? + @itemsprite.update if @itemsprite && !@itemsprite.disposed? if @pkmnsprite && !@pkmnsprite.disposed? @pkmnsprite.update Changed: PokemonStorage --- Left +++ Right @@ -852,12 +852,12 @@ -class PokemonBoxIcon < SpriteWrapper +class PokemonBoxIcon < IconSprite def initialize(pokemon,viewport=nil) - super(viewport) + super(0,0,viewport) @release=Interpolator.new @startRelease=false @pokemon=pokemon if pokemon - self.bitmap=Bitmap.new(pbPokemonIconFile(pokemon)) + self.setBitmap(pbPokemonIconFile(pokemon)) end self.src_rect=Rect.new(0,0,64,64) @@ -879,4 +879,5 @@ end def update + super @release.update dispose if @startRelease && !releasing? @@ -891,5 +892,4 @@ def initialize(viewport=nil) super(viewport) - @fist=BitmapCache.load_bitmap("Graphics/Pictures/boxfist.png") @frame=0 @holding=false @@ -899,10 +899,12 @@ @heldpkmn=nil @swapsprite=nil - @point1=BitmapCache.load_bitmap("Graphics/Pictures/boxpoint1.png") - @point2=BitmapCache.load_bitmap("Graphics/Pictures/boxpoint2.png") - @grab=BitmapCache.load_bitmap("Graphics/Pictures/boxgrab.png") + @fist=AnimatedBitmap.new("Graphics/Pictures/boxfist") + @point1=AnimatedBitmap.new("Graphics/Pictures/boxpoint1") + @point2=AnimatedBitmap.new("Graphics/Pictures/boxpoint2") + @grab=AnimatedBitmap.new("Graphics/Pictures/boxgrab") + @currentBitmap=@fist @spriteX=self.x @spriteY=self.y - self.bitmap=@fist + self.bitmap=@currentBitmap.bitmap end def heldPokemon @@ -984,13 +986,20 @@ heldpkmn=heldPokemon heldpkmn.update if heldpkmn + @fist.update + @point2.update + @point1.update + @grab.update + self.bitmap=@currentBitmap.bitmap @holding=false if !heldpkmn if @grabbingState>0 if @grabbingState<=8 - self.bitmap=@grab + @currentBitmap=@grab + self.bitmap=@currentBitmap.bitmap self.y=@spriteY+(@grabbingState)*2 @grabbingState+=1 elsif @grabbingState<=16 @holding=true - self.bitmap=@fist + @currentBitmap=@fist + self.bitmap=@currentBitmap.bitmap self.y=@spriteY+(16-@grabbingState)*2 @grabbingState+=1 @@ -1000,5 +1009,6 @@ elsif @placingState>0 if @placingState<=8 - self.bitmap=@fist + @currentBitmap=@fist + self.bitmap=@currentBitmap.bitmap self.y=@spriteY+(@placingState)*2 @placingState+=1 @@ -1006,5 +1016,6 @@ @holding=false @heldpkmn=nil - self.bitmap=@grab + @currentBitmap=@grab + self.bitmap=@currentBitmap.bitmap self.y=@spriteY+(16-@placingState)*2 @placingState+=1 @@ -1013,12 +1024,15 @@ end elsif holding? - self.bitmap=@fist + @currentBitmap=@fist + self.bitmap=@currentBitmap.bitmap else self.x=@spriteX self.y=@spriteY if (@frame/20)==1 - self.bitmap=@point2 + @currentBitmap=@point2 + self.bitmap=@currentBitmap.bitmap else - self.bitmap=@point1 + @currentBitmap=@point1 + self.bitmap=@currentBitmap.bitmap end end @@ -1089,8 +1103,7 @@ def initialize(party,viewport=nil) super(viewport) - @boxspace=BitmapCache.load_bitmap("Graphics/Pictures/boxparty.png") - @boxbitmap=BitmapCache.load_bitmap("Graphics/Pictures/boxpartytab.png") + @boxspace=AnimatedBitmap.new("Graphics/Pictures/boxparty") + @boxbitmap=AnimatedBitmap.new("Graphics/Pictures/boxpartytab") @pokemonsprites=[] - @shadow=BitmapCache.load_bitmap("Graphics/Pictures/boxshadow.png") for i in 0...6 @pokemonsprites[i]=nil @@ -1115,5 +1128,5 @@ end def refresh - @contents.blt(0,0,@boxbitmap,Rect.new(0,0,192,352)) + @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,192,352)) xvalues=[88*2,136*2,136*2,136*2,136*2,136*2] yvalues=[48*2,0,48,96,144,192] @@ -1132,5 +1145,5 @@ if $Trainer.party[j] @contents.blt(xvalues[j]-158,yvalues[j]+16, - @boxspace,Rect.new(0,0,@boxspace.width,@boxspace.height)) + @boxspace.bitmap,Rect.new(0,0,@boxspace.width,@boxspace.height)) end end @@ -1210,5 +1223,5 @@ end @boxbitmap.dispose if @boxbitmap - @boxbitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{@bg}.png") + @boxbitmap=AnimatedBitmap.new("Graphics/Pictures/#{@bg}") end end @@ -1224,5 +1237,5 @@ getBoxBitmap @pokemonsprites=[] - @shadow=BitmapCache.load_bitmap("Graphics/Pictures/boxshadow.png") + @shadow=AnimatedBitmap.new("Graphics/Pictures/boxshadow") for i in 0...30 @pokemonsprites[i]=nil @@ -1253,5 +1266,5 @@ boxname=@storage[@boxnumber].name getBoxBitmap - @contents.blt(0,0,@boxbitmap,Rect.new(0,0,160*2,144*2)) + @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,160*2,144*2)) pbSetSystemFont(@contents) widthval=@contents.text_size(boxname).width @@ -1294,6 +1307,7 @@ end -class PokemonBoxPlane < Plane +class PokemonBoxPlane < AnimatedPlane def update + super self.ox+=2 self.oy-=2 @@ -1321,8 +1335,8 @@ @command=command @sprites["boxbg"]=PokemonBoxPlane.new(@bgviewport) - @sprites["boxbg"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/boxbg.png") + @sprites["boxbg"].setBitmap("Graphics/Pictures/boxbg") @sprites["box"]=PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport) - @sprites["boxsides"]=Sprite.new(@boxsidesviewport) - @sprites["boxsides"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/boxsides.png") + @sprites["boxsides"]=IconSprite.new(0,0,@boxsidesviewport) + @sprites["boxsides"].setBitmap("Graphics/Pictures/boxsides") @sprites["overlay"]=Sprite.new(@boxsidesviewport) @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) Changed: PokemonBerryTag --- Left +++ Right @@ -13,6 +13,8 @@ @viewport.z=99999 addBackgroundPlane(@sprites,"background","trcardbg",@viewport) - @sprites["card"]=SpriteWrapper.new(@viewport) - @sprites["card"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/berrytag.png") + @sprites["card"]=IconSprite.new(0,0,@viewport) + @sprites["card"].setBitmap("Graphics/Pictures/berrytag") + @sprites["trainer"]=IconSprite.new(64,80,@viewport) + @sprites["trainer"].setBitmap(sprintf("Graphics/Characters/trainer%03d",0)) @sprites["overlay"]=Sprite.new(@viewport) @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) @@ -55,10 +57,8 @@ ] pbDrawTextPositions(overlay,textPositions) - imagePositions=[ - [sprintf("Graphics/Characters/trainer%03d.png",0),64,80,0,0,-1,-1], - ] x=64 + tagcircle=pbBitmapName("Graphics/Pictures/tagcircle") for i in 0...5 - imagePositions.push(["Graphics/Pictures/tagcircle.png",x,83*2,0,0,-1,-1]) + imagePositions.push([tagcircle,x,83*2,0,0,-1,-1]) x+=80 end Changed: PokemonDuel --- Left +++ Right @@ -52,7 +52,7 @@ @sprites["opponentwindow"].viewport=@viewport @sprites["player"].setBitmap( - sprintf("Graphics/Characters/trainer%03d.png",$Trainer.trainertype)) + sprintf("Graphics/Characters/trainer%03d",$Trainer.trainertype)) @sprites["opponent"].setBitmap( - sprintf("Graphics/Characters/trainer%03d.png",opponent.trainertype)) + sprintf("Graphics/Characters/trainer%03d",opponent.trainertype)) pbWait(20) while @sprites["player"].x<0 Changed: Scene_Intro --- Left +++ Right @@ -40,9 +40,9 @@ @item, @speed, @o_speed, @phase = 0, 15, 20, 0 # Background Images - @sprite = GifSprite.new + @sprite = IconSprite.new(0,0) setTitle(@sprite, @pics[@item]) @sprite.opacity = 5 # Start Logo - @start = GifSprite.new + @start = IconSprite.new(0,0) setTitle(@start,"Start") @start.y, @start.z, @start.opacity = 250, 10, 0 Changed: PokemonDebug --- Left +++ Right @@ -982,5 +982,4 @@ elsif ret==12 BitmapCache.debug - RPG::Cache.debug Kernel.pbMessage(_INTL("Saved info on the bitmap cache.")) elsif ret==13 @@ -1053,9 +1052,13 @@ self.active = false @item_max = 0 - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @mode = 0 refresh initUpDownArrow end + def dispose + @selarrow.dispose + super + end def shadowtext(x,y,w,h,t,align=0) width=self.contents.text_size(t).width @@ -1087,5 +1090,5 @@ width = self.contents.text_size(id_text).width if self.top_row+i == self.index - pbCopyBitmap(self.contents,@selarrow,0,i*32) + pbCopyBitmap(self.contents,@selarrow.bitmap,0,i*32) end self.shadowtext(4+16, i * 32, width, 32, id_text) Changed: Main --- Left +++ Right @@ -1,17 +1,2 @@ -=begin -Graphics.frame_rate=40 -window=Window.new -window.x=0 -window.y=0 -window.width=200 -window.height=200 -window.windowskin=Bitmap.new("Graphics/Windowskins/Window.png") -window.openness=255 -loop do - window.openness=(Graphics.frame_count*2)&0xFF - Graphics.update -end -exit -=end def pbCallTitle @@ -27,4 +12,6 @@ end + + def mainFunction if $DEBUG @@ -49,5 +36,5 @@ $data_system = pbLoadRxData("Data/System") $game_system = Game_System.new - setScreenBorderName("border.png") + setScreenBorderName("border") # Sets image file for the border Graphics.update Graphics.freeze Changed: PokemonAnimEditor --- Left +++ Right @@ -777,5 +777,5 @@ super(viewport) @animbitmap=nil - @arrows=Bitmap.new("Graphics/Pictures/arrows.png") + @arrows=AnimatedBitmap.new("Graphics/Pictures/arrows") self.y=320 self.x=240 @@ -802,6 +802,6 @@ color=Color.new(180,180,180) @contents.fill_rect(0,0,@contents.width,@contents.height,color) - @contents.blt(0,0,@arrows,Rect.new(0,0,8,96)) - @contents.blt(392,0,@arrows,Rect.new(8,0,8,96)) + @contents.blt(0,0,@arrows.bitmap,Rect.new(0,0,8,96)) + @contents.blt(392,0,@arrows.bitmap,Rect.new(8,0,8,96)) havebitmap=(self.animbitmap && !self.animbitmap.disposed?) if havebitmap @@ -955,5 +955,5 @@ @selected=false @contents=Bitmap.new(128,128) - @iconbitmap=Bitmap.new("Graphics/Pictures/icon.png") + @iconbitmap=AnimatedBitmap.new("Graphics/Pictures/icon") self.bitmap=@contents self.invalidate @@ -973,8 +973,8 @@ @contents.fill_rect(127,0,1,128,color) bmrect=Rect.new((@id%10)*16,(@id/10)*16,16,16) - @contents.blt(0,0,@iconbitmap,bmrect) + @contents.blt(0,0,@iconbitmap.bitmap,bmrect) if @locked bmrect=Rect.new(0,48,16,16) - @contents.blt(16,0,@iconbitmap,bmrect) + @contents.blt(16,0,@iconbitmap.bitmap,bmrect) end end @@ -1002,7 +1002,9 @@ @playingframe=0 @player=nil - @user=BitmapCache.picture("testback.png") - @target=BitmapCache.picture("testfront.png") - self.bitmap=BitmapCache.picture("testscreen.png") + @user=AnimatedBitmap.new("Graphics/Pictures/testback").deanimate + @target=AnimatedBitmap.new("Graphics/Pictures/testfront").deanimate + + @testscreen=AnimatedBitmap.new("Graphics/Pictures/testscreen") + self.bitmap=@testscreen.bitmap for i in 0...PBAnimation::MAXSPRITES @sprites[i]=Sprite.new(viewport) @@ -1047,6 +1049,6 @@ else begin - @animbitmap=BitmapCache.animation( - @animation.graphic,@animation.hue) + @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic, + @animation.hue).deanimate rescue @animbitmap=nil @@ -1390,4 +1392,6 @@ end updateInput + @testscreen.update + self.bitmap=@testscreen.bitmap if @currentframe < @animation.length count=0 @@ -2295,5 +2299,5 @@ def refresh self.contents.clear - bmap=BitmapCache.animation(@bitmapname,@hue) + bmap=AnimatedBitmap.new("Graphics/Animations/"+@bitmapname,@hue).deanimate return if !bmap ww=bmap.width @@ -2417,5 +2421,5 @@ end if (Input.trigger?(Input::C) || cmdwin.doubleclick?) && animfiles.length>0 - bitmap=BitmapCache.animation(cmdwin.commands[cmdwin.index],ctlwin.value(0)) + bitmap=AnimatedBitmap.new("Graphics/Animations/"+cmdwin.commands[cmdwin.index],ctlwin.value(0)).deanimate canvas.animation.graphic=cmdwin.commands[cmdwin.index] canvas.animation.hue=ctlwin.value(0) Changed: RPG__Sprite --- Left +++ Right @@ -30,5 +30,5 @@ animation_name = @_animation.animation_name animation_hue = @_animation.animation_hue - bitmap = RPG::Cache.animation(animation_name, animation_hue) + bitmap = pbGetAnimation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 @@ -58,5 +58,5 @@ animation_name = @_loop_animation.animation_name animation_hue = @_loop_animation.animation_hue - bitmap = RPG::Cache.animation(animation_name, animation_hue) + bitmap = pbGetAnimation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 Changed: Compiler --- Left +++ Right @@ -3191,5 +3191,5 @@ page=RPG::Event::Page.new if !hidden - page.graphic.character_name="itemball.png" + page.graphic.character_name="itemball" end page.list=[] Changed: Sprite_Picture --- Left +++ Right @@ -20,6 +20,6 @@ if @picture_name != "" # Get picture graphic - @sprite.dispose if @sprite - @sprite=GifSprite.new("Graphics/Pictures/"+@picture_name,@viewport) + @sprite=IconSprite.new(0,0,@viewport) if !@sprite + @sprite.setBitmap("Graphics/Pictures/"+@picture_name) end end Changed: PokemonTriad --- Left +++ Right @@ -58,7 +58,8 @@ end if type>=0 - typebitmap=Bitmap.new(_INTL("Graphics/Pictures/types.png")) + typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) typerect=Rect.new(0,type*28,64,28) - bitmap.blt(10,28,typebitmap,typerect) + bitmap.blt(10,28,typebitmap.bitmap,typerect) + typebitmap.dispose end bitmap.fill_rect(0,0,84,2,Color.new(0,0,0)) @@ -74,7 +75,7 @@ end bitmap=Bitmap.new(84,84) - iconfile=sprintf("Graphics/Icons/icon%03d.png",@species) - typebitmap=Bitmap.new(_INTL("Graphics/Pictures/types.png")) - icon=Bitmap.new(iconfile) + iconfile=sprintf("Graphics/Icons/icon%03d",@species) + typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) + icon=AnimatedBitmap.new(iconfile) typerect=Rect.new(0,@type*28,64,28) if owner==2 @@ -85,6 +86,6 @@ bitmap.fill_rect(0,0,84,84,Color.new(128,128,255)) end - bitmap.blt(10,28,typebitmap,typerect,192) - bitmap.blt(10,2,icon,Rect.new(0,0,64,64)) + bitmap.blt(10,28,typebitmap.bitmap,typerect,192) + bitmap.blt(10,2,icon.bitmap,Rect.new(0,0,64,64)) bitmap.fill_rect(0,0,84,2,Color.new(0,0,0)) bitmap.fill_rect(0,0,2,84,Color.new(0,0,0)) @@ -181,5 +182,5 @@ [@battle.playerName,Graphics.width,0,1,Color.new(248,248,248),Color.new(18*8,18*8,18*8)] ]) - addBackgroundPlane(@sprites,"background","triadbg.png",@viewport) + addBackgroundPlane(@sprites,"background","triadbg",@viewport) $game_system.bgm_play("021-Field04.mid") # Fade in all sprites Changed: VXEvents --- Left +++ Right @@ -398,5 +398,5 @@ @d.sort! @e.sort! - srcbitmap=RPG::Cache.tileset(@filename) + srcbitmap=pbGetTileset(@filename) a5bitmap=Bitmap.new(256,512) putTiles(srcbitmap,a5bitmap,@a5) @@ -467,5 +467,5 @@ srcX=(id%8)*32 srcY=(id/8)*32 - dst.blt(dstX,dstY,RPG::Cache.tileset(arr[i].filename),Rect.new(srcX,srcY,32,32)) + dst.blt(dstX,dstY,pbGetTileset(arr[i].filename),Rect.new(srcX,srcY,32,32)) end end Changed: PokemonEditor --- Left +++ Right @@ -362,5 +362,5 @@ } @map=@mapdata[map] - bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{@map[1]}") + bitmap=AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}") retbitmap=Bitmap.new(bitmap.width/2,bitmap.height/2) retbitmap.stretch_blt( @@ -964,5 +964,5 @@ class GraphicsLister def initialize(folder,selection) - @sprite=SpriteWrapper.new + @sprite=IconSprite.new(0,0) @sprite.bitmap=nil @sprite.z=2 @@ -983,4 +983,8 @@ Dir.glob("*.png"){|f| @commands.push(f) } Dir.glob("*.PNG"){|f| @commands.push(f) } + Dir.glob("*.gif"){|f| @commands.push(f) } + Dir.glob("*.GIF"){|f| @commands.push(f) } + Dir.glob("*.bmp"){|f| @commands.push(f) } + Dir.glob("*.BMP"){|f| @commands.push(f) } Dir.glob("*.jpg"){|f| @commands.push(f) } Dir.glob("*.JPG"){|f| @commands.push(f) } @@ -1004,7 +1008,6 @@ end def refresh(index) - @sprite.bitmap.dispose if @sprite.bitmap return if index<0 - @sprite.bitmap=BitmapCache.load_bitmap(@folder+@commands[index]) + @sprite.setBitmap(@folder+@commands[index]) ww=@sprite.bitmap.width wh=@sprite.bitmap.height @@ -1077,7 +1080,7 @@ return if index<0 begin - @sprite.bitmap=BitmapCache.character(sprintf("trainer%03d",@ids[index]),0) + @sprite.setBitmap(sprintf("Graphics/Characters/trainer%03d",@ids[index]),0) rescue - @sprite.bitmap=Bitmap.new(32,32) + @sprite.setBitmap(nil) end ww=@sprite.bitmap.width @@ -2321,5 +2324,5 @@ class TrainerBattleLister def initialize(selection,includeNew) - @sprite=SpriteWrapper.new + @sprite=IconSprite.new @sprite.bitmap=nil @sprite.z=2 @@ -2372,7 +2375,7 @@ return if index<0 begin - @sprite.bitmap=BitmapCache.character(sprintf("trainer%03d",@ids[index]),0) + @sprite.setBitmap(sprintf("Graphics/Characters/trainer%03d",@ids[index]),0) rescue - @sprite.bitmap=Bitmap.new(32,32) + @sprite.setBitmap(nil) end ww=@sprite.bitmap.width @@ -2399,5 +2402,5 @@ class PokemonLister def initialize(selection,includeNew) - @sprite=SpriteWrapper.new + @sprite=IconSprite.new(0,0) @sprite.bitmap=nil @sprite.z=2 @@ -2446,7 +2449,7 @@ return if index<0 begin - @sprite.bitmap=BitmapCache.battler(sprintf("%03d",@ids[index]),0) + @sprite.setBitmap(sprintf("Graphics/Battlers/%03d",@ids[index]),0) rescue - @sprite.bitmap=Bitmap.new(32,32) + @sprite.setBitmap(nil) end ww=@sprite.bitmap.width Changed: EventScene --- Left +++ Right @@ -63,4 +63,5 @@ attr_accessor :angle # rotation angle attr_accessor :visible + attr_accessor :hue # filename hue class Processes XY=0 @@ -76,4 +77,5 @@ Name=10 Curve=11 + Hue=12 end def callback(cb) @@ -92,4 +94,5 @@ @x = 0.0 @y = 0.0 + @hue = 0 @zoom_x = 100.0 @zoom_y = 100.0 @@ -243,4 +246,12 @@ end end + def moveHue(duration, delay,hue, cb=nil) + delay=self.totalDuration if delay<0 + if duration==0 && delay==0 + @hue=hue + else + @processes.push([Processes::Hue,duration,delay,@hue,hue,cb]) + end + end def moveTone(duration, delay,tone, cb=nil) delay=self.totalDuration if delay<0 @@ -287,4 +298,6 @@ when Processes::Tone process[3]=@tone.clone + when Processes::Hue + process[3]=@hue when Processes::Color process[3]=@color.clone @@ -325,4 +338,8 @@ @opacity=process[3] cb=process[5] + when Processes::Hue + process[3] = (process[3] * (d - 1) + process[4]) / d + @hue=process[3] + cb=process[5] when Processes::BlendType process[3] = (process[3] * (d - 1) + process[4]) / d @@ -454,35 +471,39 @@ @pictureBitmap = nil @customBitmap = nil + @customBitmapIsBitmap = true + @hue=0 update end + # Doesn't free the bitmap def setCustomBitmap(bitmap) - @customBitmap.dispose if @customBitmap @customBitmap=bitmap + @customBitmapIsBitmap = @customBitmap.is_a?(Bitmap) end def dispose @pictureBitmap.dispose if @pictureBitmap - @customBitmap.dispose if @customBitmap super end def update super + @pictureBitmap.update if @pictureBitmap # If picture file name is different from current one if @customBitmap && @picture.name=="" - self.bitmap=@customBitmap - elsif @picture_name != @picture.name + self.bitmap=@customBitmapIsBitmap ? @customBitmap : @customBitmap.bitmap + elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i # Remember file name to instance variables @picture_name = @picture.name + @hue = @picture.hue.to_i # If file name is not empty if @picture_name != "" # Get picture graphic - @pictureBitmap.dispose if self.bitmap - @pictureBitmap = BitmapCache.load_bitmap(@picture_name) + @pictureBitmap.dispose if @pictureBitmap + @pictureBitmap = AnimatedBitmap.new(@picture_name, @hue) else - @pictureBitmap.dispose if self.bitmap + @pictureBitmap.dispose if @pictureBitmap @pictureBitmap=nil self.visible = false return end - self.bitmap=@pictureBitmap + self.bitmap=@pictureBitmap ? @pictureBitmap.bitmap : nil elsif @picture_name == "" # Set sprite to invisible @@ -497,7 +518,7 @@ self.oy=0 when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right - self.oy=self.bitmap.height/2 + self.oy=self.bitmap ? self.bitmap.height/2 : 0 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight - self.oy=self.bitmap.height + self.oy=self.bitmap ? self.bitmap.height : 0 end case @picture.origin @@ -505,7 +526,7 @@ self.ox=0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - self.ox=self.bitmap.width/2 + self.ox=self.bitmap ? self.bitmap.width/2 : 0 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight - self.ox=self.bitmap.width + self.ox=self.bitmap ? self.bitmap.width : 0 end # Set sprite coordinates @@ -525,7 +546,7 @@ end angle %= 360 - if @picture.angle!=0 - echo([angle,@picture.angle]+"\r\n") - end + #if @picture.angle!=0 + # echo([angle,@picture.angle]+"\r\n") + #end self.angle=angle end @@ -617,5 +638,11 @@ @disposed=true end - def addBitmap(x,y,bitmap) + def addBitmap(x,y,bitmap) + +# _bitmap_ can be a Bitmap or an AnimatedBitmap + +# (update method isn't called if it's animated) +# EventScene doesn't take ownership of the passed-in +# bitmap num=@pictures.length picture=PictureEx.new(num) @@ -698,35 +725,38 @@ ] @keys=[ - addImage(26*2,24,"Graphics/Pictures/arrowkeys.png"), - addImage(26*2,(24+48)*2,"Graphics/Pictures/ckey.png"), - addImage(26*2,(24+48+32)*2,"Graphics/Pictures/xkey.png"), - addImage(26*2,24,"Graphics/Pictures/f5key.png"), - addImage(26*2,(24+64)*2,"Graphics/Pictures/zkey.png") + addImage(26*2,24,"Graphics/Pictures/arrowkeys"), + addImage(26*2,(24+48)*2,"Graphics/Pictures/ckey"), + addImage(26*2,(24+48+32)*2,"Graphics/Pictures/xkey"), + addImage(26*2,24,"Graphics/Pictures/f5key"), + addImage(26*2,(24+64)*2,"Graphics/Pictures/zkey") ] for key in @keys key.origin=PictureOrigin::Top end - for i in [3,4] - @labels[i].moveOpacity(0,0,0) - @keys[i].moveOpacity(0,0,0) + for i in [3,4] # Hide the last two labels + @labels[i].moveOpacity(1,0,0) + @keys[i].moveOpacity(1,0,0) end - update + pictureWait # Update event scene with the changes Graphics.transition(20) + # Go to next screen when user presses C onCTrigger.set(method(:pbOnScreen1)) end def pbOnScreen1(scene,args) onCTrigger.clear - for i in [0,1,2] + for i in [0,1,2]# Hide the first three labels @labels[i].moveOpacity(20,0,0) @keys[i].moveOpacity(20,0,0) end - for i in [3,4] - @labels[i].moveOpacity(20,30,255) + for i in [3,4] # Show the last two labels + @labels[i].moveOpacity(20,30,255) # fade in for 20 frames after waiting 30 frames @keys[i].moveOpacity(20,30,255) end - pictureWait + pictureWait # wait until entire event scene is finished + # Go to next screen when user presses C onCTrigger.set(method(:pbOnScreen2)) end def pbOnScreen2(scene,args) + # End scene Graphics.freeze scene.dispose Changed: PokemonField --- Left +++ Right @@ -924,8 +924,6 @@ class LightEffect def initialize(event,map=nil) - @light = Sprite.new - @light.bitmap = BitmapCache.picture("LE.PNG") - @light.src_rect = Rect.new(0, 0, 64, 64) - @light.visible = true + @light = IconSprite.new(0,0) + @light.setBitmap("Graphics/Pictures/LE") @light.z = 1000 @event = event @@ -937,5 +935,4 @@ end def dispose - @light.bitmap.dispose @light.dispose @map=nil @@ -944,4 +941,5 @@ end def update + @light.update end end @@ -950,9 +948,9 @@ def initialize(event,map=nil) @light = Sprite.new - lamp = BitmapCache.picture("LE.PNG") + lamp = AnimatedBitmap.new("Graphics/Pictures/LE") @light.bitmap = Bitmap.new(128,64) src_rect = Rect.new(0, 0, 64, 64) - @light.bitmap.blt(0, 0, lamp, src_rect) - @light.bitmap.blt(20, 0, lamp, src_rect) + @light.bitmap.blt(0, 0, lamp.bitmap, src_rect) + @light.bitmap.blt(20, 0, lamp.bitmap, src_rect) lamp.dispose @light.visible = true @@ -995,11 +993,8 @@ return if !@light || !@event super - # Gets the time of day in minutes that the current time "feels like" - realMinutes=pbGetDayNightMinutes() - hour=realMinutes/60 - minute=realMinutes%60 - thisOpacity=@opacities[hour] - nextOpacity=@opacities[(hour+1)%24] - @light.opacity = (((nextOpacity-thisOpacity)*minute/60.0)+thisOpacity).to_i + shade=pbGetDayNightShade() + shade=255 if shade>144 + @light.opacity = 255-shade + @light.opacity = 0 if @light.opacity<16 if @light.opacity>0 @light.ox=32 @@ -1359,6 +1354,7 @@ end end - endRecord("record.wav") - wave=getWaveDataUI("record.wav",true) + tmpFile=ENV["TEMP"]+"\\record.wav" + endRecord(tmpFile) + wave=getWaveDataUI(tmpFile,true) if wave Kernel.pbDisplayMessageFancy(msgwindow, Changed: PokemonSummary --- Left +++ Right @@ -6,5 +6,5 @@ def initialize(viewport=nil) super(viewport) - @movesel=BitmapCache.load_bitmap("Graphics/Pictures/movesel.png") + @movesel=AnimatedBitmap.new("Graphics/Pictures/movesel") @frame=0 @index=0 @@ -35,5 +35,5 @@ self.x=162 self.y=64+(self.index*h) - self.bitmap=@movesel + self.bitmap=@movesel.bitmap if self.preselected self.src_rect.set(0,h,w,h) @@ -45,4 +45,5 @@ @updating=true super + @movesel.update @frame+=1 if !self.preselected && @spriteVisible @@ -51,4 +52,5 @@ @frame=0 if @frame>=20 @updating=false + refresh end end @@ -63,5 +65,5 @@ @pokemon=@party[@partyindex] @sprites={} - @typebitmap=BitmapCache.load_bitmap(_INTL("Graphics/Pictures/types.png")) + @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) @sprites["overlay"]=SpriteWrapper.new(@viewport) @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) @@ -90,5 +92,5 @@ @sprites={} @page=2 - @typebitmap=BitmapCache.load_bitmap(_INTL("Graphics/Pictures/types.png")) + @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) @sprites["overlay"]=SpriteWrapper.new(@viewport) @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) @@ -124,5 +126,5 @@ overlay.clear imagepos=[ - ["Graphics/Pictures/summary1.png",0,0,0,0,-1,-1] + ["Graphics/Pictures/summary1",0,0,0,0,-1,-1] ] if pokemon.pokerus==1 || pokemon.hp==0 || @pokemon.status>0 @@ -130,9 +132,9 @@ status=6 if pokemon.pokerus==1 status=5 if pokemon.hp==0 - imagepos.push(["Graphics/Pictures/statuspane.png",0,288,0,0,-1,-1]) - imagepos.push(["Graphics/Pictures/statuses.png",106,296,0,16*status,44,16]) + imagepos.push(["Graphics/Pictures/statuspane",0,288,0,0,-1,-1]) + imagepos.push(["Graphics/Pictures/statuses",106,296,0,16*status,44,16]) end ballused=@pokemon.ballused ? @pokemon.ballused : 0 - ballimage=sprintf("Graphics/Pictures/ball%02d_0.png",@pokemon.ballused) + ballimage=sprintf("Graphics/Pictures/ball%02d_0",@pokemon.ballused) imagepos.push([ballimage,16,254,0,0,-1,-1]) pbDrawImagePositions(overlay,imagepos) @@ -183,6 +185,6 @@ type1rect=Rect.new(0,pokemon.type1*28,64,28) type2rect=Rect.new(0,pokemon.type2*28,64,28) - overlay.blt(240,98,@typebitmap,type1rect) - overlay.blt(320,98,@typebitmap,type2rect) if pokemon.type1!=pokemon.type2 + overlay.blt(240,98,@typebitmap.bitmap,type1rect) + overlay.blt(320,98,@typebitmap.bitmap,type2rect) if pokemon.type1!=pokemon.type2 end @@ -192,5 +194,5 @@ overlay.clear imagepos=[ - ["Graphics/Pictures/summaryEgg.png",0,0,0,0,-1,-1] + ["Graphics/Pictures/summaryEgg",0,0,0,0,-1,-1] ] pbDrawImagePositions(overlay,imagepos) @@ -221,5 +223,5 @@ pbDrawTextPositions(overlay,textpos) type1rect=Rect.new(0,9*28,64,28) - overlay.blt(240,98,@typebitmap,type1rect) + overlay.blt(240,98,@typebitmap.bitmap,type1rect) end @@ -232,5 +234,5 @@ publicID=pokemon.trainerID&0xFFFF imagepos=[ - ["Graphics/Pictures/summary2.png",0,0,0,0,-1,-1] + ["Graphics/Pictures/summary2",0,0,0,0,-1,-1] ] if pokemon.pokerus==1 || pokemon.hp==0 || @pokemon.status>0 @@ -238,9 +240,9 @@ status=6 if pokemon.pokerus==1 status=5 if pokemon.hp==0 - imagepos.push(["Graphics/Pictures/statuspane.png",0,288,0,0,-1,-1]) - imagepos.push(["Graphics/Pictures/statuses.png",106,296,0,16*status,44,16]) + imagepos.push(["Graphics/Pictures/statuspane",0,288,0,0,-1,-1]) + imagepos.push(["Graphics/Pictures/statuses",106,296,0,16*status,44,16]) end ballused=@pokemon.ballused ? @pokemon.ballused : 0 - ballimage=sprintf("Graphics/Pictures/ball%02d_0.png",@pokemon.ballused) + ballimage=sprintf("Graphics/Pictures/ball%02d_0",@pokemon.ballused) imagepos.push([ballimage,16,254,0,0,-1,-1]) pbDrawImagePositions(overlay,imagepos) @@ -308,5 +310,5 @@ publicID=pokemon.trainerID&0xFFFF imagepos=[ - ["Graphics/Pictures/summary3.png",0,0,0,0,-1,-1] + ["Graphics/Pictures/summary3",0,0,0,0,-1,-1] ] if pokemon.pokerus==1 || pokemon.hp==0 || @pokemon.status>0 @@ -314,9 +316,9 @@ status=6 if pokemon.pokerus==1 status=5 if pokemon.hp==0 - imagepos.push(["Graphics/Pictures/statuspane.png",0,288,0,0,-1,-1]) - imagepos.push(["Graphics/Pictures/statuses.png",106,296,0,16*status,44,16]) + imagepos.push(["Graphics/Pictures/statuspane",0,288,0,0,-1,-1]) + imagepos.push(["Graphics/Pictures/statuses",106,296,0,16*status,44,16]) end ballused=@pokemon.ballused ? @pokemon.ballused : 0 - ballimage=sprintf("Graphics/Pictures/ball%02d_0.png",@pokemon.ballused) + ballimage=sprintf("Graphics/Pictures/ball%02d_0",@pokemon.ballused) imagepos.push([ballimage,16,254,0,0,-1,-1]) pbDrawImagePositions(overlay,imagepos) @@ -344,5 +346,5 @@ for i in 0...pokemon.moves.length if pokemon.moves[i].id>0 - imagepos.push(["Graphics/Pictures/types.png",170,yPos+2,0, + imagepos.push(["Graphics/Pictures/types",170,yPos+2,0, pokemon.moves[i].type*28,64,28]) textpos.push([PBMoves.getName(pokemon.moves[i].id),240,yPos,0,base,shadow]) @@ -397,5 +399,5 @@ publicID=pokemon.trainerID&0xFFFF pbDrawImagePositions(overlay,[ - ["Graphics/Pictures/summary4.png",0,0,0,0,-1,-1] + ["Graphics/Pictures/summary4",0,0,0,0,-1,-1] ]) pbSetSystemFont(overlay) @@ -429,5 +431,5 @@ if moveobject if moveobject.id!=0 - imagepos.push(["Graphics/Pictures/types.png",170,yPos+2,0, + imagepos.push(["Graphics/Pictures/types",170,yPos+2,0, moveobject.type*28,64,28]) textpos.push([PBMoves.getName(moveobject.id),240,yPos,0,moveBase,moveShadow]) Changed: PokemonMart --- Left +++ Right @@ -9,7 +9,7 @@ @stock=stock self.windowskin=nil - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") - @uparrow=AnimatedSprite.create("Graphics/Pictures/uparrow.png",8,2,@viewport) - @downarrow=AnimatedSprite.create("Graphics/Pictures/downarrow.png",8,2,@viewport) + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") + @uparrow=AnimatedSprite.create("Graphics/Pictures/uparrow",8,2,@viewport) + @downarrow=AnimatedSprite.create("Graphics/Pictures/downarrow",8,2,@viewport) @uparrow.play @downarrow.play @@ -69,5 +69,5 @@ textpos=[] if i==thispocket.length - self.contents.blt(0,ypos,@selarrow,@selarrow.rect) if self.index==i + self.contents.blt(0,ypos,@selarrow.bitmap,@selarrow.bitmap.rect) if self.index==i textpos.push([_INTL("CANCEL"),16,ypos,false,self.baseColor,self.shadowColor]) else @@ -82,5 +82,5 @@ sizeQty=self.contents.text_size(qty).width xQty=contentsWidth-sizeQty-2 - pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i + pbCopyBitmap(self.contents,@selarrow.bitmap,0,ypos) if self.index==i textpos.push([itemname,16,ypos,false,self.baseColor,self.shadowColor]) textpos.push([qty,xQty,ypos,false,self.baseColor,self.shadowColor]) @@ -182,6 +182,6 @@ @stock=stock @sprites={} - @sprites["background"]=SpriteWrapper.new(@viewport) - @sprites["background"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/martscreen.png") + @sprites["background"]=IconSprite.new(0,0,@viewport) + @sprites["background"].setBitmap("Graphics/Pictures/martscreen") @sprites["icon"]=IconSprite.new(16,Graphics.height-72,@viewport) @sprites["itemwindow"]=Window_PokemonMart.new(stock,160,0,304,224) @@ -351,5 +351,5 @@ if @buying itemwindow=@sprites["itemwindow"] - filename=sprintf("Graphics/Icons/item%03d.png",itemwindow.item) + filename=sprintf("Graphics/Icons/item%03d",itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @@ -370,5 +370,5 @@ self.update if itemwindow.item!=olditem - filename=sprintf("Graphics/Icons/item%03d.png",itemwindow.item) + filename=sprintf("Graphics/Icons/item%03d",itemwindow.item) @sprites["icon"].setBitmap(filename) @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : Changed: PokemonRegionMap --- Left +++ Right @@ -3,9 +3,8 @@ def initialize(viewport=nil) super(viewport) - @bottom=BitmapCache.load_bitmap("Graphics/Pictures/mapbottom.png") @mapname="" @maplocation="" @mapdetails="" - @thisbitmap=Bitmap.new(@bottom.width,@bottom.height) + @thisbitmap=Bitmap.new(Graphics.width,32) pbSetSystemFont(@thisbitmap) self.y=Graphics.height-32 @@ -16,5 +15,4 @@ def dispose @thisbitmap.dispose - @bottom.dispose super end @@ -38,6 +36,5 @@ end def refresh - self.bitmap.clear # in case part of the mapbottom is transparent - self.bitmap.blt(0,0,@bottom,Rect.new(0,0,@bottom.width,@bottom.height)) + self.bitmap.clear textpos=[ [@mapname,0,0,0,Color.new(248,248,248),Color.new(0,0,0)], @@ -80,9 +77,11 @@ return false end - @sprites["map"]=Sprite.new(@viewport) - @sprites["map"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/#{@map[1]}") - @sprites["cursor"]=AnimatedSprite.create("Graphics/Pictures/mapcursor.png",2,15) + @sprites["map"]=IconSprite.new(0,0,@viewport) + @sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}") + @sprites["cursor"]=AnimatedSprite.create("Graphics/Pictures/mapcursor",2,15) @sprites["cursor"].viewport=@viewport @sprites["cursor"].play + @sprites["mapbottombm"]=IconSprite.new(0,Graphics.height-32,@viewport) + @sprites["mapbottombm"].setBitmap("Graphics/Pictures/mapbottom") @sprites["mapbottom"]=MapBottomSprite.new(@viewport) @sprites["mapbottom"].mapname=pbGetMessage(MessageTypes::RegionNames,mapindex) Changed: PokeBattle_ActualScene --- Left +++ Right @@ -65,5 +65,5 @@ @choice3="" @choice4="" - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @index=0 @menuBaseColor=PokeBattle_Scene::MENUBASECOLOR @@ -77,8 +77,8 @@ def refresh self.contents.clear - pbCopyBitmap(self.contents,@selarrow,4,0) if @index==0 - pbCopyBitmap(self.contents,@selarrow,116,0) if @index==1 - pbCopyBitmap(self.contents,@selarrow,4,32) if @index==2 - pbCopyBitmap(self.contents,@selarrow,116,32) if @index==3 + pbCopyBitmap(self.contents,@selarrow.bitmap,4,0) if @index==0 + pbCopyBitmap(self.contents,@selarrow.bitmap,116,0) if @index==1 + pbCopyBitmap(self.contents,@selarrow.bitmap,4,32) if @index==2 + pbCopyBitmap(self.contents,@selarrow.bitmap,116,32) if @index==3 self.contents.font.color=@menuShadowColor pbDrawShadow(self.contents,20,0,96,32,@choice1) @@ -113,5 +113,5 @@ self.contents=Bitmap.new(self.width-32,self.height-32) pbSetNarrowFont(self.contents) - @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png") + @selarrow=AnimatedBitmap.new("Graphics/Pictures/selarrow") @index=0 @menuBaseColor=PokeBattle_Scene::MENUBASECOLOR @@ -125,8 +125,8 @@ def refresh self.contents.clear - pbCopyBitmap(self.contents,@selarrow,0,0) if @index==0 - pbCopyBitmap(self.contents,@selarrow,144,0) if @index==1 - pbCopyBitmap(self.contents,@selarrow,0,32) if @index==2 - pbCopyBitmap(self.contents,@selarrow,144,32) if @index==3 + pbCopyBitmap(self.contents,@selarrow.bitmap,0,0) if @index==0 + pbCopyBitmap(self.contents,@selarrow.bitmap,144,0) if @index==1 + pbCopyBitmap(self.contents,@selarrow.bitmap,0,32) if @index==2 + pbCopyBitmap(self.contents,@selarrow.bitmap,144,32) if @index==3 self.contents.font.color=@menuShadowColor pbDrawShadow(self.contents,16,0,128,32,@choices[0]) @@ -145,8 +145,6 @@ @display=nil if PokeBattle_Scene::USECOMMANDBOX - @display=Sprite.new(viewport) - @display.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/commandbox.png") - @display.x=0 - @display.y=Graphics.height-96 + @display=IconSprite.new(0,Graphics.height-96,viewport) + @display.setBitmap("Graphics/Pictures/commandbox") end @window=Window_CommandMenuInner.new @@ -307,8 +305,6 @@ @display=nil if PokeBattle_Scene::USEFIGHTBOX - @display=Sprite.new(viewport) - @display.bitmap=BitmapCache.load_bitmap("Graphics/Pictures/fightbox.png") - @display.x=0 - @display.y=Graphics.height-96 + @display=IconSprite.new(0,Graphics.height-96,viewport) + @display.setBitmap("Graphics/Pictures/fightbox") end @window=TwoColumnWindow.new(0,Graphics.height-96,320,96,viewport) @@ -408,5 +404,5 @@ @selected=0 @battle=battle - @databox=BitmapCache.load_bitmap("Graphics/Pictures/safariPlayerBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/safariPlayerBox") @spriteX=254 @spriteY=148+(Graphics.height-320) @@ -430,5 +426,5 @@ def refresh self.bitmap.clear - self.bitmap.blt(0,0,@databox,Rect.new(0,0,@databox.width,@databox.height)) + self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height)) pbSetSmallFont(self.bitmap) textpos=[] @@ -484,9 +480,9 @@ case @battler.index when 0 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/doublePlayerBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/doublePlayerBox") @spriteX=256 @spriteY=124+yoffset when 1 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/doubleEnemyBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/doubleEnemyBox") @spriteX=26 @spriteY=10+yoffset @@ -494,9 +490,9 @@ @spritebaseY=0 when 2 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/doublePlayerBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/doublePlayerBox") @spriteX=280 @spriteY=174+yoffset when 3 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/doubleEnemyBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/doubleEnemyBox") @spriteX=2 @spriteY=60+yoffset @@ -505,5 +501,5 @@ case @battler.index when 0 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/singlePlayerBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/singlePlayerBox") @spriteX=254 @spriteY=148+yoffset @@ -513,10 +509,10 @@ @statusY=44 when 1 - @databox=BitmapCache.load_bitmap("Graphics/Pictures/singleEnemyBox.png") + @databox=AnimatedBitmap.new("Graphics/Pictures/singleEnemyBox") @spriteX=26 @spriteY=32+yoffset end end - @statuses=BitmapCache.load_bitmap(_INTL("Graphics/Pictures/boxstatuses.png")) + @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/boxstatuses")) @contents=Bitmap.new(@databox.width,@databox.height) self.bitmap=@contents @@ -578,5 +574,5 @@ self.bitmap.clear return if !@battler.pokemon - self.bitmap.blt(0,0,@databox,Rect.new(0,0,@databox.width,@databox.height)) + self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height)) pbSetSmallFont(self.bitmap) hpstring=_ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp) @@ -598,5 +594,5 @@ pbDrawTextPositions(self.bitmap,textpos) if @battler.status>0 - self.bitmap.blt(@spritebaseX+14,@spritebaseY+@statusY,@statuses, + self.bitmap.blt(@spritebaseX+14,@spritebaseY+@statusY,@statuses.bitmap, Rect.new(0,(@battler.status-1)*16,@statusCX,16)) end @@ -698,6 +694,7 @@ def initialize(sprite,spritehash,pkmn,doublebattle) @disposed=false - @pokeballopen=BitmapCache.load_bitmap("Graphics/Pictures/pokeballopen.png") - @pokeballclosed=BitmapCache.load_bitmap("Graphics/Pictures/pokeball.png") + @pokeballopen=AnimatedBitmap.new("Graphics/Pictures/pokeballopen") + @pokeballclosed=AnimatedBitmap.new("Graphics/Pictures/pokeball") + @currentBitmap=@pokeballclosed @pokemonsprite=sprite @pokemonsprite.visible=false @@ -729,5 +726,5 @@ @stepspritey=(@spritey-@endspritey) @zoomstep=(1.0-STARTZOOM)/SPRITESTEPS - @pokeballsprite.bitmap=@pokeballclosed + @pokeballsprite.bitmap=@currentBitmap.bitmap @animdone=false @frame=0 @@ -748,8 +745,11 @@ def update return if disposed? + @pokeballclosed.update + @pokeballopen.update + @pokeballsprite.update @frame+=1 if @frame==2 Audio.se_play("Audio/SE/recall.wav") - @pokeballsprite.bitmap=@pokeballopen + @currentBitmap=@pokeballopen end if @frame==4 @@ -788,4 +788,5 @@ @animdone=true end + @pokeballsprite.bitmap=@currentBitmap.bitmap end end @@ -793,7 +794,7 @@ def pokeballThrow(ball,shakes,targetBattler) balltype=@battle.pbGetBallType(ball) - ball0=sprintf("Graphics/Pictures/ball%02d_0.png",balltype) - ball1=sprintf("Graphics/Pictures/ball%02d_1.png",balltype) - ball2=sprintf("Graphics/Pictures/ball%02d_2.png",balltype) + ball0=sprintf("Graphics/Pictures/ball%02d_0",balltype) + ball1=sprintf("Graphics/Pictures/ball%02d_1",balltype) + ball2=sprintf("Graphics/Pictures/ball%02d_2",balltype) # sprites spriteBall=IconSprite.new(0,0,@viewport) @@ -1281,13 +1282,8 @@ def pbAddSprite(id,x,y,filename,viewport) - sprite=GifSprite.new(nil,viewport) + sprite=IconSprite.new(x,y,viewport) if filename - sprite.setBitmap(filename) rescue sprite.bitmap=nil + sprite.setBitmap(filename) rescue nil end - sprite.x=x - sprite.y=y - sprite.zoom_x=1.0 - sprite.zoom_y=1.0 - sprite.visible=true @sprites[id]=sprite return sprite @@ -1315,10 +1311,10 @@ if @battle.opponent if @battle.opponent.is_a?(Array) - trainerfile=sprintf("Graphics/Characters/trainer%03d.png",@battle.opponent[index].trainertype) + trainerfile=sprintf("Graphics/Characters/trainer%03d",@battle.opponent[index].trainertype) else - trainerfile=sprintf("Graphics/Characters/trainer%03d.png",@battle.opponent.trainertype) + trainerfile=sprintf("Graphics/Characters/trainer%03d",@battle.opponent.trainertype) end else - trainerfile="Graphics/Pictures/trfront.png" + trainerfile="Graphics/Pictures/trfront" end pbAddSprite("trainer",Graphics.width,16+@yoffset,trainerfile,@viewport) @@ -1382,22 +1378,8 @@ id=$PokemonGlobal.nextBattleBack end - battlebg="Graphics/Pictures/battlebg#{id}.png" - enemybase="Graphics/Pictures/enemybase#{id}.png" - playerbase="Graphics/Pictures/playerbase#{id}.png" -if true # !$game_temp.background_bitmap.respond_to?("radial_blur") + battlebg="Graphics/Pictures/battlebg#{id}" + enemybase="Graphics/Pictures/enemybase#{id}" + playerbase="Graphics/Pictures/playerbase#{id}" pbAddPlane("battlebg",battlebg,@viewport) -else - source = $game_temp.background_bitmap - bitmap = Bitmap.new(Graphics.width+32,Graphics.height) - bitmap.stretch_blt(bitmap.rect, source, source.rect) - bitmap.radial_blur(90, 12) - @sprites["battlebg"] = Sprite.new(@viewport) - @sprites["battlebg"].bitmap = bitmap - @sprites["battlebg"].x = -16 - @sprites["battlebg"].y = 0 - @sprites["battlebg"].wave_amp = 8 - @sprites["battlebg"].wave_length = 240 - @sprites["battlebg"].wave_speed = 120 -end pbAddSprite("enemybase",-256,96+@yoffset,enemybase,@viewport) # ends at (224,96) pbAddSprite("playerbase",Graphics.width,192+@yoffset,playerbase,@viewport) # ends at (0,192) @@ -1439,16 +1421,16 @@ end if @partyAnimI>=@battle.party2.length || !@battle.party2[@partyAnimI] - pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballempty.png",@viewport) + pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballempty",@viewport) elsif @battle.party2[@partyAnimI].hp<=0 || @battle.party2[@partyAnimI].status>0 || @battle.party2[@partyAnimI].egg? - pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballfainted.png",@viewport) + pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballfainted",@viewport) else - pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballnormal.png",@viewport) + pbAddSprite("enemy#{@partyAnimI}",-28,64+@yoffset,"Graphics/Pictures/ballnormal",@viewport) end if @partyAnimI==@battle.party1.length || !@battle.party1[@partyAnimI] - pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballempty.png",@viewport) + pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballempty",@viewport) elsif @battle.party1[@partyAnimI].hp<=0 || @battle.party1[@partyAnimI].status>0 || @battle.party1[@partyAnimI].egg? - pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballfainted.png",@viewport) + pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballfainted",@viewport) else - pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballnormal.png",@viewport) + pbAddSprite("player#{@partyAnimI}",492,176+@yoffset,"Graphics/Pictures/ballnormal",@viewport) end @partyAnimPhase=3 @@ -1484,6 +1466,6 @@ @spriteskin=Bitmap.new($TextFrames[$PokemonSystem.frame]) pbBackdrop - pbAddSprite("partybase1",-400,80+@yoffset,"Graphics/Pictures/pbarrow.png",@viewport) - pbAddSprite("partybase2",480,192+@yoffset,"Graphics/Pictures/pbarrow.png",@viewport) + pbAddSprite("partybase1",-400,80+@yoffset,"Graphics/Pictures/pbarrow",@viewport) + pbAddSprite("partybase2",480,192+@yoffset,"Graphics/Pictures/pbarrow",@viewport) @sprites["partybase2"].mirror=true @sprites["partybase1"].visible=false @@ -1491,14 +1473,14 @@ if @battle.opponent if @battle.opponent.is_a?(Array) - trainerfile=sprintf("Graphics/Characters/trainer%03d.png",@battle.opponent[0].trainertype) + trainerfile=sprintf("Graphics/Characters/trainer%03d",@battle.opponent[0].trainertype) pbAddSprite("trainer",-144,16+@yoffset,trainerfile,@viewport) - trainerfile=sprintf("Graphics/Characters/trainer%03d.png",@battle.opponent[1].trainertype) + trainerfile=sprintf("Graphics/Characters/trainer%03d",@battle.opponent[1].trainertype) pbAddSprite("trainer2",-240,16+@yoffset,trainerfile,@viewport) else - trainerfile=sprintf("Graphics/Characters/trainer%03d.png",@battle.opponent.trainertype) + trainerfile=sprintf("Graphics/Characters/trainer%03d",@battle.opponent.trainertype) pbAddSprite("trainer",-192,16+@yoffset,trainerfile,@viewport) end else - trainerfile="Graphics/Pictures/trfront.png" + trainerfile="Graphics/Pictures/trfront" pbAddSprite("trainer",-192,16+@yoffset,trainerfile,@viewport) end @@ -1522,7 +1504,7 @@ end if @battle.player.is_a?(Array) - trainerfile=sprintf("Graphics/Pictures/trback%03d.png",@battle.player[0].trainertype) + trainerfile=sprintf("Graphics/Pictures/trback%03d",@battle.player[0].trainertype) pbAddSprite("player",576-48,96+@yoffset,trainerfile,@viewport) - trainerfile=sprintf("Graphics/Pictures/trback%03d.png",@battle.player[1].trainertype) + trainerfile=sprintf("Graphics/Pictures/trback%03d",@battle.player[1].trainertype) pbAddSprite("playerB",576+48,96+@yoffset,trainerfile,@viewport) if @sprites["player"].bitmap @@ -1539,5 +1521,5 @@ end else - trainerfile=sprintf("Graphics/Pictures/trback%03d.png",@battle.player.trainertype) + trainerfile=sprintf("Graphics/Pictures/trback%03d",@battle.player.trainertype) pbAddSprite("player",576,96+@yoffset,trainerfile,@viewport) if @sprites["player"].bitmap @@ -1548,5 +1530,5 @@ end end - pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/messagebox.png",@viewport) + pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/messagebox",@viewport) @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport) @sprites["helpwindow"].visible=false @@ -1755,5 +1737,5 @@ while inPartyAnimation?; end balltype=pkmn.ballused -ballbitmap=sprintf("Graphics/Pictures/ball%02d_0.png",balltype) +ballbitmap=sprintf("Graphics/Pictures/ball%02d_0",balltype) pictureBall=PictureEx.new(0) delay=1 Changed: Shadow --- Left +++ Right @@ -26,5 +26,5 @@ end def dispose - self.bitmap.dispose if self.bitmap + @chbitmap.dispose if @chbitmap super end @@ -42,6 +42,6 @@ @character_hue = @character.character_hue if @tile_id >= 384 - self.bitmap.dispose if self.bitmap - self.bitmap = RPG::Cache.tile(@character.map.tileset_name, + @chbitmap.dispose if @chbitmap + @chbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) @@ -51,12 +51,24 @@ self.oy = 32 else - self.bitmap.dispose if self.bitmap - self.bitmap = RPG::Cache.character(@character.character_name, + @chbitmap.dispose if @chbitmap + + @chbitmap=AnimatedBitmap.new( + "Graphics/Characters/"+@character.character_name, @character.character_hue) - @cw = bitmap.width / 4 - @ch = bitmap.height / 4 + @cw = @chbitmap.width / 4 + @ch = @chbitmap.height / 4 self.ox = @cw / 2 self.oy = @ch end + end + + if @chbitmap.is_a?(AnimatedBitmap) + + @chbitmap.update; + self.bitmap=@chbitmap.bitmap + + else + self.bitmap=@chbitmap + end self.visible = (not @character.transparent) Changed: PokemonTrading --- Left +++ Right @@ -31,5 +31,5 @@ @trader1=trader1 @trader2=trader2 - addBackgroundOrColoredPlane(@sprites,"background","tradebg.png", + addBackgroundOrColoredPlane(@sprites,"background","tradebg", Color.new(248,248,248),@viewport) rsprite1=Sprite.new(@viewport) @@ -58,5 +58,5 @@ # Starting position of ball pictureBall.moveVisible(1,true) - pictureBall.moveName(1,"Graphics/Pictures/ball00_0.png") + pictureBall.moveName(1,"Graphics/Pictures/ball00_0") pictureBall.moveOrigin(1,PictureOrigin::Center) pictureBall.moveXY(0,1,Graphics.width/2,48) @@ -74,6 +74,6 @@ delay=picturePoke.totalDuration picturePoke.moveSE(delay,"Audio/SE/recall.wav") - pictureBall.moveName(delay,"Graphics/Pictures/ball00_1.png") - pictureBall.moveName(delay+4,"Graphics/Pictures/ball00_2.png") + pictureBall.moveName(delay,"Graphics/Pictures/ball00_1") + pictureBall.moveName(delay+4,"Graphics/Pictures/ball00_2") # Move sprite to ball picturePoke.moveZoom(15,delay,0) @@ -81,5 +81,5 @@ picturePoke.moveSE(delay+10,"Audio/SE/jumptoball.wav") picturePoke.moveVisible(delay+15,false) - pictureBall.moveName(picturePoke.totalDuration+2,"Graphics/Pictures/ball00_0.png") + pictureBall.moveName(picturePoke.totalDuration+2,"Graphics/Pictures/ball00_0") delay=picturePoke.totalDuration+20 pictureBall.moveXY(12,delay,Graphics.width/2,-32) @@ -97,5 +97,5 @@ # Starting position of ball pictureBall.moveVisible(1,true) - pictureBall.moveName(1,"Graphics/Pictures/ball00_0.png") + pictureBall.moveName(1,"Graphics/Pictures/ball00_0") pictureBall.moveOrigin(1,PictureOrigin::Center) pictureBall.moveXY(0,1,Graphics.width/2,-32) @@ -125,6 +125,6 @@ picturePoke.moveSE(delay, sprintf("Audio/SE/%03dCry.wav",@pokemon2.species)) - pictureBall.moveName(delay,"Graphics/Pictures/ball00_1.png") - pictureBall.moveName(delay+4,"Graphics/Pictures/ball00_2.png") + pictureBall.moveName(delay,"Graphics/Pictures/ball00_1") + pictureBall.moveName(delay+4,"Graphics/Pictures/ball00_2") pictureBall.moveVisible(delay+10,false) picturePoke.moveVisible(delay,true) Changed: SpriteResizer --- Left +++ Right @@ -81,5 +81,6 @@ @@deletefailed=false def self.snap_to_bitmap - if FileTest.exist?("./tempscreen.bmp") && @@deletefailed + tempPath=ENV["TEMP"]+"\\tempscreen.bmp" + if FileTest.exist?(tempPath) && @@deletefailed begin File.delete("./tempscreen.bmp") @@ -92,11 +93,11 @@ if FileTest.exist?("./rubyscreen.dll") takescreen=Win32API.new("rubyscreen.dll","TakeScreenshot","%w(p)","i") - takescreen.call("./tempscreen.bmp") + takescreen.call(tempPath) end bm=nil - if FileTest.exist?("./tempscreen.bmp") - bm=Bitmap.new("./tempscreen.bmp") + if FileTest.exist?(tempPath) + bm=Bitmap.new(tempPath) begin - File.delete("./tempscreen.bmp") + File.delete(tempPath) @@deletefailed=false rescue Errno::EACCES @@ -160,5 +161,5 @@ } end - if $ResizeBorder + if $HaveResizeBorder $ResizeBorder.refresh end @@ -470,14 +471,17 @@ ################### +# New version class ScreenBorder def initialize + initializeInternal + refresh + end + def initializeInternal @maximumZ=500000 @bordername="" - @sprite=Sprite.new - @sprite.z=@maximumZ + @sprite=IconSprite.new(0,0) @defaultwidth=640 @defaultheight=480 @defaultbitmap=Bitmap.new(@defaultwidth,@defaultheight) - refresh end def dispose @@ -497,4 +501,5 @@ end def refresh + @sprite.z=@maximumZ @sprite.x=-$ResizeOffsetX @sprite.y=-$ResizeOffsetY @@ -503,8 +508,7 @@ if @sprite.visible if @bordername!=nil && @bordername!="" - @borderbitmap.dispose if @borderbitmap - @borderbitmap=RPG::Cache.picture(@bordername) - @sprite.bitmap=@borderbitmap + @sprite.setBitmap("Graphics/Pictures/"+@bordername) else + @sprite.setBitmap(nil) @sprite.bitmap=@defaultbitmap end @@ -520,8 +524,12 @@ end -$ResizeBorder=ScreenBorder.new +$HaveResizeBorder=false def setScreenBorderName(border) + if !$HaveResizeBorder + $ResizeBorder=ScreenBorder.new + $HaveResizeBorder=true + end if $ResizeBorder $ResizeBorder.bordername=border end end Changed: PokemonTilesetEditor --- Left +++ Right @@ -52,6 +52,5 @@ if ret>=0 @tileset=@tilesetwrapper.data[ret+1] - @sprites["tileset"].bitmap.dispose - @sprites["tileset"].bitmap=BitmapCache.load_bitmap("Graphics/Tilesets/#{@tileset.tileset_name}") + @sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}") @x=0 @y=0 @@ -73,8 +72,6 @@ @sprites["title"].width=480 @sprites["title"].height=64 - @sprites["tileset"]=SpriteWrapper.new(@viewport) - @sprites["tileset"].x=0 - @sprites["tileset"].y=64 - @sprites["tileset"].bitmap=BitmapCache.load_bitmap("Graphics/Tilesets/#{@tileset.tileset_name}") + @sprites["tileset"]=IconSprite.new(0,64,@viewport) + @sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}") @sprites["tileset"].src_rect=Rect.new(0,0,256,Graphics.height-64) @sprites["overlay"]=SpriteWrapper.new(@viewport) Changed: PokemonLoad --- Left +++ Right @@ -5,5 +5,5 @@ @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 - addBackgroundOrColoredPlane(@sprites,"clrvp","loadbg.png", + addBackgroundOrColoredPlane(@sprites,"clrvp","loadbg", Color.new(17<<3,18<<3,31<<3),@viewport) @sprites["locwindow"]=Window_AdvancedTextPokemon.new("") @@ -114,4 +114,5 @@ return if exist # Check if all source fonts exist + exist=false for i in 0...Names.size Changed: BitmapCache --- Left +++ Right @@ -143,80 +143,24 @@ end +# Cache from RPG Maker VX library +module Cache + def self.system(x,hue=0) + BitmapCache.load_bitmap("Graphics/System/",x,hue) + end + def self.character(x,hue=0) + BitmapCache.load_bitmap("Graphics/Characters/",x,hue) + end + def self.picture(x,hue=0) + BitmapCache.load_bitmap("Graphics/Pictures/",x,hue) + end +end + +# RPG::Cache from RPG Maker XP library + module RPG module Cache - @cache = WeakHashtable.new - def self.fromCache(i) - return nil if !@cache.include?(i) - obj=@cache[i] - return nil if obj && obj.disposed? - return obj - end - def self.debug - File.open("bitmapcache2.txt","wb"){|f| - for i in @cache.keys - k=fromCache(i) - if !k - f.write("#{i} (nil)\r\n") - elsif k.disposed? - f.write("#{i} (disposed)\r\n") - else - f.write("#{i} (#{k.refcount}, #{k.width}x#{k.height})\r\n") - end - end - } - end def self.load_bitmap(folder_name, filename, hue = 0) - cached=true - path = folder_name + filename.to_s - path=canonicalize(path) - objPath=fromCache(path) - if !objPath - if rand(10) == 0 - for i in @cache.keys - obj=fromCache(i) - if !obj - @cache.delete(i) - end - end - end - if filename != "" - begin - bm = BitmapWrapper.new(path) - rescue Hangup - begin - bm = BitmapWrapper.new(path) - rescue - bm = BitmapWrapper.new(32, 32) - raise _INTL("Failed to load bitmap: {1}",path) - end - rescue - bm = BitmapWrapper.new(32, 32) - raise _INTL("Failed to load bitmap: {1}",path) - end - else - bm = BitmapWrapper.new(32, 32) - end - objPath=bm - @cache[path]=objPath - cached=false - end - if hue == 0 - objPath.addRef if cached - return objPath - else - key = [path, hue] - objKey=fromCache(key) - if !objKey - bitmap= objPath.clone - bitmap.hue_change(hue) - bitmap.resetRef - objKey=bitmap - @cache[key]=objKey - else - objKey.addRef - end - return objKey - end + BitmapCache.load_bitmap(folder_name+filename.to_s,hue, true) end def self.animation(filename, hue) @@ -260,25 +204,8 @@ end def self.tile(filename, tile_id, hue) - key = [filename, tile_id, hue] - objKey=fromCache(key) - if !objKey - bitmap=BitmapWrapper.new(32, 32) - x = (tile_id - 384) % 8 * 32 - y = (tile_id - 384) / 8 * 32 - rect = Rect.new(x, y, 32, 32) - tileset = self.tileset(filename) - bitmap.blt(0, 0, tileset, rect) - tileset.dispose - bitmap.hue_change(hue) - objKey=bitmap - @cache[key]=objKey - else - objKey.addRef - end - objKey + BitmapCache(filename,tile_id,hue) end def self.clear - @cache = {} - GC.start + BitmapCache.clear() end end @@ -327,4 +254,7 @@ return obj end + def self.setKey(key,obj) + @cache[key]=obj + end def self.debug File.open("bitmapcache2.txt","wb"){|f| @@ -341,5 +271,5 @@ } end - def self.load_bitmap(path, hue = 0) + def self.load_bitmap(path, hue = 0, failsafe = false) cached=true path=canonicalize(path) @@ -360,8 +290,10 @@ bm = BitmapWrapper.new(path) rescue - raise _INTL("Failed to load bitmap: {1}",path) + raise _INTL("Failed to load bitmap: {1}",path) if !failsafe + bm = BitmapWrapper.new(32,32) end rescue - raise _INTL("Failed to load bitmap: {1}",path) + raise _INTL("Failed to load bitmap: {1}",path) if !failsafe + bm = BitmapWrapper.new(32,32) end objPath=bm @@ -377,5 +309,5 @@ if !objKey bitmap= objPath.clone - bitmap.hue_change(hue) + bitmap.hue_change(hue) if hue!=0 bitmap.resetRef objKey=bitmap @@ -426,5 +358,5 @@ self.load_bitmap("Graphics/Windowskins/"+ filename) end - def self.tile(filename, tile_id, hue) + def self.tileEx(filename, tile_id, hue) key = [filename, tile_id, hue] objKey=fromCache(key) @@ -434,8 +366,8 @@ y = (tile_id - 384) / 8 * 32 rect = Rect.new(x, y, 32, 32) - tileset = self.tileset(filename) + tileset = yield(filename) bitmap.blt(0, 0, tileset, rect) tileset.dispose - bitmap.hue_change(hue) + bitmap.hue_change(hue) if hue!=0 objKey=bitmap @cache[key]=objKey @@ -444,4 +376,7 @@ end objKey + end + def self.tile(filename, tile_id, hue) + return self.tileEx(filename, tile_id,hue) {|f| self.tileset(f,0,true) } end def self.clear Changed: PokemonBugContest --- Left +++ Right @@ -23,5 +23,5 @@ def pbContestHeld? return false if !@lastContest - return Time.new.to_i-@lastContest<86400 + return Time.now.to_i-@lastContest<86400 end def expired? Changed: PerspectiveTilemap --- Left +++ Right @@ -25,5 +25,5 @@ map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) tileset=$data_tilesets[map.tileset_id] - minimap=Bitmap.new("Graphics/Pictures/minimap_tiles.png") + minimap=AnimatedBitmap.new("Graphics/Pictures/minimap_tiles") ret=Bitmap.new(map.width*6,map.height*6) passtable=Table.new(map.width,map.height) @@ -47,9 +47,9 @@ nb=TileDrawingHelper.tableNeighbors(passtable,i,j) tile=neighbors[nb] - bltMinimapAutotile(ret,i*6,j*6,minimap,tile) + bltMinimapAutotile(ret,i*6,j*6,minimap.bitmap,tile) end end end - minimap.dispose + minimap.disposes return ret end @@ -94,5 +94,5 @@ h=@heightcache[bm] if !h - bmap=RPG::Cache.character(bm,0) + bmap=AnimatedBitmap.new("Graphics/Characters/"+bm,0) h=bmap.height @heightcache[bm]=h Changed: PokemonOrgBattle --- Left +++ Right @@ -501,7 +501,7 @@ nextTrainer=pbBattleChallenge.nextTrainer bttrainers=load_data("Data/bttrainers.dat") - filename=sprintf("trchar%03d.png",bttrainers[nextTrainer][0]) + filename=sprintf("trchar%03d",bttrainers[nextTrainer][0]) begin - bitmap=BitmapCache.character(filename,0) + bitmap=AnimatedBitmap.new("Graphics/Characters/"+filename) bitmap.dispose event.character_name=filename