Changed: PokemonPokedex @@ -267,0 +267,1 @@ + addBackgroundPlane(@sprites,"searchbg","searchbg.png",@viewport) @@ -268,0 +269,1 @@ + @sprites["searchbg"].visible=false @@ -514,2 +516,4 @@ - textpos.push([_INTL("??'??\""),146*2,56*2,0,basecolor,shadowcolor]) - textpos.push([_INTL("???.? lbs."),184*2,72*2,1,basecolor,shadowcolor]) + textpos.push([_INTL("???.? m"),184*2,56*2,1,basecolor,shadowcolor]) + textpos.push([_INTL("???.? kg"),184*2,72*2,1,basecolor,shadowcolor]) +# textpos.push([_INTL("??'??\""),146*2,56*2,0,basecolor,shadowcolor]) +# textpos.push([_INTL("???.? lbs."),184*2,72*2,1,basecolor,shadowcolor]) @@ -563,1 +567,7 @@ - if Input.trigger?(Input::B) + if Input.trigger?(Input::C) + pbFadeOutAndHide(@sprites) + scene=PokemonAreaMapScene.new + screen=PokemonAreaMap.new(scene) + screen.pbStartScreen(@dexlist[curindex][0]) + pbChangeToDexEntry(@dexlist[curindex][0]) + elsif Input.trigger?(Input::B) @@ -565,2 +575,1 @@ - end - if Input.trigger?(Input::A) + elsif Input.trigger?(Input::A) @@ -569,2 +578,1 @@ - end - if Input.trigger?(Input::UP) + elsif Input.trigger?(Input::UP) @@ -586,2 +594,1 @@ - end - if Input.trigger?(Input::DOWN) + elsif Input.trigger?(Input::DOWN) @@ -666,0 +673,1 @@ + @sprites["searchbg"].visible=true Changed: PokemonField @@ -1181,2 +1181,2 @@ - message+=". " - end + end + message+=". " Changed: PokeBattle_ActualScene @@ -2297,0 +2297,2 @@ + userwidth=(!user.bitmap || user.bitmap.disposed?) ? 128 : user.bitmap.width + userheight=(!user.bitmap || user.bitmap.disposed?) ? 128 : user.bitmap.height @@ -2299,4 +2301,4 @@ - user.x+(user.bitmap.width/2), - user.y+(user.bitmap.height/2), - user.x+(user.bitmap.width/2), - user.y+(user.bitmap.height/2) + user.x+(userwidth/2), + user.y+(userheight/2), + user.x+(userwidth/2), + user.y+(userheight/2) @@ -2308,0 +2310,4 @@ + userwidth=(!user.bitmap || user.bitmap.disposed?) ? 128 : user.bitmap.width + targetwidth=(!target.bitmap || target.bitmap.disposed?) ? 128 : target.bitmap.width + userheight=(!user.bitmap || user.bitmap.disposed?) ? 128 : user.bitmap.height + targetheight=(!target.bitmap || target.bitmap.disposed?) ? 128 : target.bitmap.height @@ -2310,4 +2316,4 @@ - user.x+(user.bitmap.width/2), - user.y+(user.bitmap.height/2), - target.x+(target.bitmap.width/2), - target.y+(target.bitmap.height/2) + user.x+(userwidth/2), + user.y+(userheight/2), + target.x+(targetwidth/2), + target.y+(targetheight/2) Changed: PokemonTrainers @@ -182,0 +182,140 @@ +def pbMissingTrainer(trainerid, trainername, trainerparty) + traineridstring="#{trainerid}" + traineridstring=getConstantName(PBTrainers,trainerid) rescue nil + if $DEBUG + Kernel.pbMessage(_INTL("Can't find trainer ({1}, {2}) in Trainer data file.\1",traineridstring,trainername)) + if Kernel.pbConfirmMessage(_INTL("Would you like to add this Trainer now?")) + pbNewTrainer(trainerid,trainername,trainerparty) + end + else + raise _INTL("Can't find trainer ({1}, {2})",traineridstring,trainername) + end +end + +def pbDoubleTrainerBattle( + trainerid1, trainername1, trainerparty1, endspeech1, + trainerid2, trainername2, trainerparty2, endspeech2, + canlose=false +) + trainer1=pbLoadTrainer(trainerid1,trainername1,trainerparty1) + if !trainer1 + pbMissingTrainer(trainerid1,trainername1,trainerparty1) + end + trainer2=pbLoadTrainer(trainerid2,trainername2,trainerparty2) + if !trainer2 + pbMissingTrainer(trainerid2,trainername2,trainerparty2) + end + if !trainer1 || !trainer2 + return false + end + currentlevels=[] + for i in $Trainer.party + currentlevels.push(i.level) + end + if $PokemonMap.partner + othertrainer=PokeBattle_Trainer.new( + $PokemonMap.partner[1], + $PokemonMap.partner[0]) + othertrainer.id=$PokemonMap.partner[2] + othertrainer.party=$PokemonMap.partner[3] + playerparty=[] + for i in othertrainer.party; i.heal; end + for i in 0...$Trainer.party.length + playerparty[i]=$Trainer.party[i] + end + for i in 0...othertrainer.party.length + playerparty[6+i]=othertrainer.party[i] + end + fullparty1=true + playertrainer=[$Trainer,othertrainer] + doublebattle=true + else + playerparty=$Trainer.party + playertrainer=$Trainer + fullparty1=false + end + combinedParty=[] + combinedParty2=[] + if trainer1[2].length>3 + raise _INTL("Opponent 1's party has more than three Pokemon, which is not allowed") + end + if trainer2[2].length>3 + raise _INTL("Opponent 2's party has more than three Pokemon, which is not allowed") + end + for i in 0...trainer1[2].length + combinedParty[i]=trainer1[2][i] + end + for i in 0...trainer2[2].length + combinedParty[3+i]=trainer2[2][i] + end + for i in 0...6 + combinedParty2[i]=combinedParty[i].clone if combinedParty[i] + end + scene=PokeBattle_Scene.new + battle=PokeBattle_Battle.new(scene, + playerparty, + combinedParty, + playertrainer, + [trainer1[0],trainer2[0]] + ) + trainerbgm=pbGetTrainerBattleBGM([trainer1[0],trainer2[0]]) + battle.fullparty1=fullparty1 + battle.doublebattle=true + battle.endspeech=endspeech1 + battle.endspeech2=endspeech2 + battle.items=[trainer1[1],trainer2[1]] + if Input.press?(Input::CTRL) && $DEBUG + Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) + Kernel.pbMessage(_INTL("AFTER LOSING...")) + Kernel.pbMessage(battle.endspeech) + Kernel.pbMessage(battle.endspeech2) if battle.endspeech2 + return true + end + battle.internalbattle=true + pbPrepareBattle(battle) + playingBGS=$game_system.getPlayingBGS + playingBGM=$game_system.getPlayingBGM + $game_system.bgm_pause + $game_system.bgs_pause + restorebgm=true + decision=0 + pbBattleAnimation(trainerbgm) { + pbSceneStandby { + decision=battle.pbStartBattle + } + if $PokemonMap.partner + for i in $Trainer.party; i.heal; end + end + if decision==2 + if canlose + for i in $Trainer.party; i.heal; end + for i in 0...10 + Graphics.update + end + else + $game_system.bgm_unpause + $game_system.bgs_unpause + Kernel.pbStartOver + restorebgm=false + end + else + pbEvolutionCheck(currentlevels) + if decision==1 + for pkmn in $Trainer.party + Kernel.pbPickup(pkmn) + end + end + end + } + if restorebgm + $game_system.bgm_resume(playingBGM) + $game_system.bgs_resume(playingBGS) + end + $PokemonGlobal.nextBattleBGM=nil + $PokemonGlobal.nextBattleME=nil + $PokemonEncounters.clearStepCount + Input.update + return (decision==1) +end + + @@ -198,11 +338,2 @@ - traineridstring="#{trainerid}" - traineridstring=getConstantName(PBTrainers,trainerid) rescue nil - if $DEBUG - Kernel.pbMessage(_INTL("Can't find trainer ({1}, {2}) in Trainer data file.\1",traineridstring,trainername)) - if Kernel.pbConfirmMessage(_INTL("Would you like to add this Trainer now?")) - pbNewTrainer(trainerid,trainername,trainerparty) - end - return false - else - raise _INTL("Can't find trainer ({1}, {2})",traineridstring,trainername) if !success - end + pbMissingTrainer(trainerid,trainername,trainerparty) + return false @@ -223,11 +354,2 @@ - traineridstring="#{trainerid}" - traineridstring=getConstantName(PBTrainers,trainerid) rescue nil - if $DEBUG - Kernel.pbMessage(_INTL("Can't find trainer ({1}, {2}) in Trainer data file.\1",traineridstring,trainername)) - if Kernel.pbConfirmMessage(_INTL("Would you like to add this Trainer now?")) - pbNewTrainer(trainerid,trainername,trainerparty) - end - return false - else - raise _INTL("Can't find trainer ({1}, {2})",traineridstring,trainername) if !success - end + pbMissingTrainer(trainerid,trainername,trainerparty) + return false Changed: PokeBattle_AI @@ -515,1 +515,1 @@ - (opponent.level-attacker.level).abs<=6 + (opponent.level-@battlers[index].level).abs<=6 Changed: PokemonEntry @@ -422,1 +422,1 @@ -class Window_TextEntry < SpriteWindow_Base +class CharacterEntryHelper @@ -425,1 +425,2 @@ - attr_reader :passwordChar + attr_reader :passwordChar + attr_accessor :cursor @@ -429,5 +430,11 @@ - self.refresh - end - def initialize(text,x,y,width,height,heading=nil) - super(x,y,width,height) - @heading=heading + end + def textChars + chars=text.scan(/./m) + if @passwordChar!="" + chars.length.times {|i| + chars[i]=@passwordChar + } + end + return chars + end + def initialize(text) @@ -435,1 +442,0 @@ - @frame=0 @@ -438,2 +444,0 @@ - @baseColor=Color.new(12<<3,12<<3,12<<3) - @shadowColor=Color.new(26<<3,26<<3,26<<3) @@ -442,1 +446,0 @@ - refresh @@ -446,1 +449,0 @@ - refresh @@ -451,1 +453,3 @@ - self.refresh + end + def length + return self.text.scan(/./m).length @@ -462,2 +466,0 @@ - @frame=0 - self.refresh @@ -468,0 +470,1 @@ + return false if chars.length<=0 || @cursor<=0 @@ -474,0 +477,24 @@ + return true + end + private + def ensure + return if @maxlength<0 + chars=self.text.scan(/./m) + if chars.length>@maxlength && @maxlength>=0 + chars=chars[0,@maxlength] + end + @text="" + for ch in chars + @text+=ch + end + end +end + +class Window_TextEntry < SpriteWindow_Base + + def initialize(text,x,y,width,height,heading=nil) + super(x,y,width,height) + @helper=CharacterEntryHelper.new(text) + @heading=heading + @baseColor=Color.new(12<<3,12<<3,12<<3) + @shadowColor=Color.new(26<<3,26<<3,26<<3) @@ -475,1 +502,38 @@ - self.refresh + refresh + end + def text + @helper.text + end + def maxlength + @helper.maxlength + end + def passwordChar + @helper.passwordChar + end + def text=(value) + @helper.text=value + self.refresh + end + def passwordChar=(value) + @helper.passwordChar=value + refresh + end + def maxlength=(value) + @helper.maxlength=value + self.refresh + end + def insert(ch) + if @helper.insert(ch) + @frame=0 + self.refresh + return true + end + return false + end + def delete + if @helper.insert(ch) + @frame=0 + self.refresh + return true + end + return false @@ -483,2 +547,2 @@ - if @cursor > 0 - @cursor-=1 + if @helper.cursor > 0 + @helper.cursor-=1 @@ -491,2 +555,2 @@ - if @cursor < self.text.scan(/./m).length - @cursor+=1 + if @helper.cursor < self.text.scan(/./m).length + @helper.cursor+=1 @@ -500,1 +564,1 @@ - self.delete if @cursor > 0 + self.delete if @helper.cursor > 0 @@ -530,3 +594,3 @@ - @cursor=scanlength if @cursor>scanlength - @cursor=0 if @cursor<0 - startpos=@cursor + @helper.cursor=scanlength if @helper.cursor>scanlength + @helper.cursor=0 if @helper.cursor<0 + startpos=@helper.cursor @@ -535,1 +599,1 @@ - c=(@passwordChar!="") ? @passwordChar : textscan[startpos-1] + c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[startpos-1] @@ -541,1 +605,1 @@ - c=(@passwordChar!="") ? @passwordChar : textscan[i] + c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[i] @@ -550,1 +614,1 @@ - if ((@frame/10)&1) == 0 && i==@cursor + if ((@frame/10)&1) == 0 && i==@helper.cursor @@ -556,1 +620,1 @@ - if ((@frame/10)&1) == 0 && textscan.length==@cursor + if ((@frame/10)&1) == 0 && textscan.length==@helper.cursor @@ -558,12 +622,0 @@ - end - end - private - def ensure - return if @maxlength<0 - chars=self.text.scan(/./m) - if chars.length>@maxlength && @maxlength>=0 - chars=chars[0,@maxlength] - end - @text="" - for ch in chars - @text+=ch @@ -582,2 +634,2 @@ - if @cursor > 0 - @cursor-=1 + if @helper.cursor > 0 + @helper.cursor-=1 @@ -599,1 +651,1 @@ - self.delete if @cursor > 0 + self.delete if @helper.cursor > 0 @@ -643,123 +695,0 @@ - end - end -end - - -class Window_TextEntry_ChineseIME < Window_TextEntry - def initialize(*arg) - super(*arg) - @mode=0 - @lastword="" - @imeaid=Window_CommandPokemon.newEmpty(0,0,120,32*6) - @imeaid.visible=false - @imeshow=0 - @imedata=load_data("PBS/codes.dat") - end - def viewport=(v) - super - @imeaid.viewport=v - end - def keyToAscii - # Letter keys - for i in 65..90 - if Input.repeatex?(i) - shift=(Input.press?(Input::SHIFT)) ? 0x41 : 0x61 - return (shift+(i-65)).chr - end - end - # Number keys - shifted=")!@\#$%^&*(" - unshifted="0123456789" - for i in 48..57 - if Input.repeatex?(i) - return (Input.press?(Input::SHIFT)) ? shifted[i-48].chr : unshifted[i-48].chr - end - end - keys=[ - [32," "," "], - [106,"*","*"], - [107,"+","+"], - [109,"-","-"], - [111,"/","/"], - [186,";",":"], - [187,"=","+"], - [189,"-","_"], - [191,"/","?"], - [219,"[","{"], -# [190,".",">"], -# [188,",","<"], -# [220,"\\","|"], - [190,".",""], - [188,",",""], - [221,"]","}"], - [222,"'","\""] - ] - for i in keys - if Input.repeatex?(i[0]) - return (Input.press?(Input::SHIFT)) ? i[2] : i[1] - end - end - return "" - end - def update_ascii - c=keyToAscii - if c!="" - insert(c) - end - end - def update_chinese - c=keyToAscii - if c!="" - @lastword+=c - @imeshow=Graphics.frame_count - @imeaid.visible=false - end - if @imeshow+300 - break - end - } - @imeaid.visible=true - @imeaid.contents.font.name=["Batang","SimSun","MS Mincho","Arial Unicode MS","Code2000"] - @imeaid.commands=commands - end - if @imeaid.visible - @imeaid.update - end - end - def update - @frame+=1 - @frame%=20 - self.refresh if ((@frame%10)==0) - # Moving cursor - if Input.repeat?(Input::LEFT) - if @cursor > 0 - @cursor-=1 - @frame=0 - self.refresh - end - return - end - if Input.repeat?(Input::RIGHT) - if @cursor < self.text.scan(/./m).length - @cursor+=1 - @frame=0 - self.refresh - end - return - end - # Backspace - if Input.repeatex?(8) || Input.repeatex?(0x2E) - self.delete if @cursor > 0 - return - end - if @mode==0 - update_chinese - else - update_ascii @@ -923,0 +852,381 @@ +class PokemonEntryScene2 +@@Characters=[ + [("ABC DEF . "+"GHI JKL , "+"MNO PQRS "+"TUV WXYZ ").scan(/./),_INTL("UPPER")], + [("abc def . "+"ghi jkl , "+"mno pqrs "+"tuv wxyz ").scan(/./),_INTL("lower")], + [("0 1 2 3 4 ( "+"5 6 7 8 9 ) "+"! ? _ + / - "+": ; \" ' = ~ ").scan(/./),_INTL("other")], +] +ROWS=13 +COLUMNS=4 +MODE=ROWS-1 +BACK1=(ROWS*2)-1 +BACK2=(ROWS*3)-1 +OK=(ROWS*4)-1 +class NameEntryCursor + def initialize(viewport) + @sprite=Sprite.new(viewport) + @cursortype=0 + @cursor1=BitmapCache.load_bitmap("Graphics/Pictures/entrycursor.png") + @cursor2=BitmapCache.load_bitmap("Graphics/Pictures/entrycursor2.png") + @direction=1 + @intensity=0 + @cursorPos=0 + updateInternal + end + def setCursorPos(value) + @cursorPos=value + end + def updateCursorPos + value=@cursorPos + if value==PokemonEntryScene2::MODE # Mode + @sprite.x=376 + @sprite.y=154 + @cursortype=1 + elsif value==PokemonEntryScene2::BACK1 || + value==PokemonEntryScene2::BACK2 # Back + @sprite.x=376 + @sprite.y=212 + @cursortype=1 + elsif value==PokemonEntryScene2::OK # OK + @sprite.x=376 + @sprite.y=256 + @cursortype=1 + elsif value>=0 + @sprite.x=64+24*(value%PokemonEntryScene2::ROWS) + @sprite.y=160+32*(value/PokemonEntryScene2::ROWS) + @cursortype=0 + end + end + def visible=(value) + @sprite.visible=value + end + def visible + @sprite.visible + end + def color=(value) + @sprite.color=value + end + def twitch + @intensity=0 + end + def color + @sprite.color + end + def disposed? + @sprite.disposed? + end + def updateInternal + updateCursorPos + if @cursortype==0 + @sprite.color=Color.new(248,248,248,@intensity*16) + @sprite.opacity=255 + else + @sprite.color=Color.new(0,0,0,0) + @sprite.opacity=@intensity*16 + end + @intensity+=@direction + if @intensity<0 || @intensity>16 + @direction=-@direction + end + @sprite.bitmap=(@cursortype==0) ? @cursor1 : @cursor2 + end + def update + updateInternal + end + def dispose + @cursor1.dispose + @cursor2.dispose + @sprite.dispose + end +end +def pbStartScene(helptext,minlength,maxlength,initialText) + @sprites={} + @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport.z=99999 + @helptext=helptext + @helper=CharacterEntryHelper.new(initialText) + @bitmaps=[ + Bitmap.new("Graphics/Pictures/lettertab1.png"), + Bitmap.new("Graphics/Pictures/lettertab2.png"), + Bitmap.new("Graphics/Pictures/lettertab3.png") + ] + for i in 0...3 + pos=0 + pbSetSystemFont(@bitmaps[i]) + textPos=[] + for y in 0...COLUMNS + for x in 0...ROWS-1 + textPos.push([@@Characters[i][0][pos],42+x*24,10+y*32,2, + Color.new(248,248,248), Color.new(12*8,12*8,12*8)]) + pos+=1 + end + end + pbDrawTextPositions(@bitmaps[i],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["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"].y=104 + @blanks=[] + @pointer=0 + @mode=0 + @minlength=minlength + @maxlength=maxlength + @maxlength.times {|i| + @sprites["blank#{i}"]=Sprite.new(@viewport) + @sprites["blank#{i}"].bitmap=underline + @sprites["blank#{i}"].x=172+i*16 + @blanks[i]=0 + } + @sprites["bottomtab"]=Sprite.new(@viewport) + @sprites["toptab"]=Sprite.new(@viewport) + @sprites["bottomtab"].x=34 + @sprites["bottomtab"].y=150 + @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["controls"].x=368 + @sprites["controls"].y=150 + @init=true + @sprites["overlay"]=Sprite.new(@viewport) + @sprites["overlay"].bitmap=Bitmap.new(640,480) + pbDoUpdateOverlay2 + @sprites["cursor"]=NameEntryCursor.new(@viewport) + @cursorpos=0 + @refreshOverlay=true + @sprites["cursor"].setCursorPos(@cursorpos) + pbFadeInAndShow(@sprites) { pbUpdate } +end + +def pbUpdateOverlay + @refreshOverlay=true +end +def pbDoUpdateOverlay2 + overlay=@sprites["overlay"].bitmap + overlay.clear + pbSetSmallFont(overlay) + nextMode=(@mode+1)%3 + textPositions=[ + [_INTL("+: MOVE C: OK X: BACK"),0,4,false, + Color.new(248,248,248), Color.new(12*8,12*8,12*8)], + [_INTL("BACK"),408,212,2, + Color.new(248,248,248), Color.new(23*8,20*8,4*8)], + [_INTL("X Key"),408,232,2, + Color.new(248,248,248), Color.new(0,0,0)], + [_INTL("OK"),408,256,2, + Color.new(248,248,248), Color.new(23*8,20*8,4*8)], + [_INTL("Z Key"),408,276,2, + Color.new(248,248,248), Color.new(0,0,0)], + [_INTL("F5 Key"),408,174,2, + Color.new(248,248,248), Color.new(0,0,0)], + [@@Characters[nextMode][1],408,154,2, + Color.new(248,248,248), Color.new(9*8,14*8,17*8)] + ] + pbDrawTextPositions(overlay,textPositions) +end +def pbDoUpdateOverlay + return if !@refreshOverlay + @refreshOverlay=false + bgoverlay=@sprites["bgoverlay"].bitmap + bgoverlay.clear + pbSetSystemFont(bgoverlay) + textPositions=[ + [@helptext,144,64,false, + Color.new(12*8,12*8,12*8), Color.new(26*8,26*8,25*8)] + ] + chars=@helper.textChars + x=172 + for ch in chars + textPositions.push([ch,x,96,false, + Color.new(12*8,12*8,12*8), Color.new(26*8,26*8,25*8)]) + x+=16 + end + pbDrawTextPositions(bgoverlay,textPositions) +end + +def pbChangeTab + @sprites["cursor"].visible=false + 12.times do + @sprites["toptab"].y+=8 + @sprites["bottomtab"].y-=8 + Graphics.update + Input.update + pbUpdate + end + tempx=@sprites["toptab"].x + @sprites["toptab"].x=@sprites["bottomtab"].x + @sprites["bottomtab"].x=tempx + tempy=@sprites["toptab"].y + @sprites["toptab"].y=@sprites["bottomtab"].y + @sprites["bottomtab"].y=tempy + tempbitmap=@sprites["toptab"].bitmap + @sprites["toptab"].bitmap=@sprites["bottomtab"].bitmap + @sprites["bottomtab"].bitmap=tempbitmap + Graphics.update + Input.update + pbUpdate + 12.times do + @sprites["toptab"].y+=8 + @sprites["bottomtab"].y-=8 + Graphics.update + Input.update + pbUpdate + end + @mode=(@mode+1)%3 + newtab=@bitmaps[(@mode+1)%3] + @sprites["cursor"].visible=true + @sprites["bottomtab"].bitmap=newtab + pbDoUpdateOverlay2 +end + +def pbUpdate + if @init || Graphics.frame_count%5==0 + @init=false + cursorpos=@helper.cursor + cursorpos=@maxlength-1 if cursorpos>=@maxlength + cursorpos=0 if cursorpos<0 + @maxlength.times {|i| + if i==cursorpos + @blanks[i]+=1 + @blanks[i]=1 if @blanks[i]>=5 + else + @blanks[i]=0 + end + @sprites["blank#{i}"].y=[124,126,128,130,128][@blanks[i]] + } + @pointer+=1 + @pointer%=5 + @sprites["pointer"].x=144+(@pointer*2) + end + pbDoUpdateOverlay + @sprites["cursor"].update +end + +def pbColumnEmpty?(m) + return false if m>=ROWS-1 + chset=@@Characters[@mode][0] + return ( + chset[m]==" " && + chset[m+((ROWS-1))]==" " && + chset[m+((ROWS-1)*2)]==" " && + chset[m+((ROWS-1)*3)]==" " + ) +end + +def wrapmod(x,y) + result=x%y + result+=y if result<0 + return result +end + +def pbMoveCursor + oldcursor=@cursorpos + cursordiv=@cursorpos/ROWS + cursormod=@cursorpos%ROWS + cursororigin=@cursorpos-cursormod + if Input.repeat?(Input::LEFT) + begin + cursormod=wrapmod((cursormod-1),ROWS) + @cursorpos=cursororigin+cursormod + end while pbColumnEmpty?(cursormod) + elsif Input.repeat?(Input::RIGHT) + begin + cursormod=wrapmod((cursormod+1),ROWS) + @cursorpos=cursororigin+cursormod + end while pbColumnEmpty?(cursormod) + elsif Input.repeat?(Input::UP) + if @cursorpos==BACK1 || @cursorpos==BACK2 # Back + @cursorpos=MODE + else + cursordiv=wrapmod((cursordiv-1),COLUMNS) + @cursorpos=(cursordiv*ROWS)+cursormod + end + elsif Input.repeat?(Input::DOWN) + if @cursorpos==BACK1 || @cursorpos==BACK2 # Back + @cursorpos=OK + else + cursordiv=wrapmod((cursordiv+1),COLUMNS) + @cursorpos=(cursordiv*ROWS)+cursormod + end + end + if @cursorpos!=oldcursor + @sprites["cursor"].setCursorPos(@cursorpos) + Audio.se_play("Audio/SE/Choose.wav") + return true + else + return false + end +end + +def pbEntry + ret="" + loop do + Graphics.update + Input.update + pbUpdate + next if pbMoveCursor + if Input.trigger?(Input::B) + @helper.delete + Audio.se_play("Audio/SE/Choose.wav") + pbUpdateOverlay + elsif Input.trigger?(Input::C) + if @cursorpos==BACK1 || @cursorpos==BACK2 + @helper.delete + Audio.se_play("Audio/SE/Choose.wav") + pbUpdateOverlay + elsif @cursorpos==OK && @helper.length>=@minlength + ret=@helper.text + Audio.se_play("Audio/SE/Choose.wav") + break + elsif @cursorpos==MODE + pbChangeTab + else + cursormod=@cursorpos%ROWS + cursordiv=@cursorpos/ROWS + charpos=cursordiv*(ROWS-1)+cursormod + chset=@@Characters[@mode][0] + if @helper.length>=@maxlength + @helper.delete + end + @helper.insert(chset[charpos]) + @sprites["cursor"].twitch + Audio.se_play("Audio/SE/Choose.wav") + if @helper.length>=@maxlength + @cursorpos=OK + @sprites["cursor"].setCursorPos(@cursorpos) + end + pbUpdateOverlay + end + elsif Input.trigger?(Input::A) + @cursorpos=OK + @sprites["cursor"].setCursorPos(@cursorpos) + elsif Input.trigger?(Input::F5) + pbChangeTab + end + end + Input.update + return ret +end + +def pbEndScene + pbFadeOutAndHide(@sprites) { pbUpdate } + for bitmap in @bitmaps + bitmap.dispose if bitmap + end + pbDisposeSpriteHash(@sprites) + @viewport.dispose +end + +end + + + @@ -941,1 +1251,1 @@ - sscene=PokemonEntryScene.new + sscene=PokemonEntryScene2.new Added: PokemonArea Changed: Compiler @@ -20,1 +20,1 @@ - print("#{message}\r\nThis exception was logged in errorlog.txt.") + print("#{message}\r\nThis exception was logged in errorlog.txt.\r\nPress Ctrl+C to copy this message to the clipboard.") @@ -1859,2 +1859,6 @@ - if ret=="" || !enumer.const_defined?(ret) - raise _INTL("Undefined value {1} in {2} (section {3}, key {4})",ret,enumer.name,section,key) + begin + if ret=="" || !enumer.const_defined?(ret) + raise _INTL("Undefined value {1} in {2} (section {3}, key {4})",ret,enumer.name,section,key) + end + rescue NameError + raise _INTL("Invalid value {1} in {2} (section {3}, key {4})",ret,enumer.name,section,key) @@ -1866,1 +1870,1 @@ - raise _INTL("Undefined value {1} (expected one of: {2}) (section {3}, key {4})",ret,enumer,section,key) + raise _INTL("Undefined value {1} (expected one of: {2}) (section {3}, key {4})",ret,enumer.inspect,section,key) @@ -1872,1 +1876,1 @@ - raise _INTL("Undefined value {1} (expected one of: {2}) (section {3}, key {4})",ret,enumer.keys,section,key) + raise _INTL("Undefined value {1} (expected one of: {2}) (section {3}, key {4})",ret,enumer.keys.inspect,section,key) Changed: SpriteWindow @@ -257,0 +257,1 @@ + yield if block_given? @@ -296,0 +297,1 @@ + yield if block_given? Changed: PokemonUtilities @@ -1144,4 +1144,5 @@ - -filename=sprintf("Battles/Battle%03d.dat",id) -pbPlayBattleFromFile(filename) -pbWildBattle(PBSpecies::DUSKULL,20) +pbEnterText("Some help text",0,10) + +#filename=sprintf("Battles/Battle%03d.dat",id) +#pbPlayBattleFromFile(filename) +#pbWildBattle(PBSpecies::DUSKULL,20) Changed: PokemonTrading @@ -160,0 +160,2 @@ + speciesname1=PBSpecies.getName(@pokemon.species) + speciesname2=PBSpecies.getName(@pokemon2.species) @@ -166,3 +168,3 @@ - _INTL("For {1}'s {2},\r\n{3} sends {4}.",@trader1,@pokemon.name,@trader2,@pokemon2.name)) - Kernel.pbDisplayMessageFancy(@sprites["msgwindow"], - _INTL("{1} bids farewell to {2}.",@trader2,@pokemon2.name)) + _INTL("For {1}'s {2},\r\n{3} sends {4}.",@trader1,speciesname1,@trader2,speciesname2)) + Kernel.pbDisplayMessageFancy(@sprites["msgwindow"], + _INTL("{1} bids farewell to {2}.",@trader2,speciesname2)) @@ -174,1 +176,1 @@ - _INTL("Take good care of {1}.",@pokemon2.name)) + _INTL("Take good care of {1}.",speciesname2)) Changed: PokemonPokedex Changed: PokemonField Changed: PokeBattle_ActualScene Changed: PokemonTrainers Changed: PokeBattle_AI Changed: PokemonEntry Added: PokemonArea Changed: Compiler Changed: SpriteWindow Changed: PokemonUtilities Changed: PokemonTrading