Added Battle Points message window (\pt), fixed occasional wrong form when viewing Pokédex of newly caught species, other tweaks

This commit is contained in:
Maruno17
2021-04-21 18:45:44 +01:00
parent 3bde4d911a
commit 70b9f65558
11 changed files with 54 additions and 25 deletions

View File

@@ -64,14 +64,14 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width
dims = resizeToFitInternal(text,maxwidth) dims = resizeToFitInternal(text,maxwidth)
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING
self.height = dims[1] + self.borderY - 4 self.height = dims[1] + self.borderY
refresh refresh
end end
def resizeHeightToFit(text, width = -1) # width is current window width def resizeHeightToFit(text, width = -1) # width is current window width
dims = resizeToFitInternal(text,width) dims = resizeToFitInternal(text,width)
self.width = (width < 0) ? Graphics.width : width self.width = (width < 0) ? Graphics.width : width
self.height = dims[1] + self.borderY - 4 self.height = dims[1] + self.borderY
refresh refresh
end end
@@ -101,7 +101,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX, self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
self.height-self.borderY) self.height-self.borderY)
self.contents.clear self.contents.clear
drawTextEx(self.contents,0,0,self.contents.width,0, drawTextEx(self.contents,0,4,self.contents.width,0,
@text.gsub(/\r/,""),@baseColor,@shadowColor) @text.gsub(/\r/,""),@baseColor,@shadowColor)
end end
end end
@@ -215,7 +215,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting oldstarting = @starting
@starting = true @starting = true
self.width = dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING self.width = dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING
self.height = dims[1]+self.borderY - 4 self.height = dims[1]+self.borderY
@starting = oldstarting @starting = oldstarting
redrawText redrawText
end end
@@ -225,7 +225,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting oldstarting = @starting
@starting = true @starting = true
self.width = [dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING,maxwidth].min self.width = [dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING,maxwidth].min
self.height = [dims[1]+self.borderY - 4,maxheight].min self.height = [dims[1]+self.borderY,maxheight].min
@starting = oldstarting @starting = oldstarting
redrawText redrawText
end end
@@ -247,7 +247,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting oldstarting = @starting
@starting = true @starting = true
self.width = (width < 0) ? Graphics.width : width self.width = (width < 0) ? Graphics.width : width
self.height = dims[1] + self.borderY - 4 self.height = dims[1] + self.borderY
@starting = oldstarting @starting = oldstarting
redrawText redrawText
end end

View File

@@ -168,7 +168,6 @@ end
def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
newlineBreaks=true,explicitBreaksOnly=false) newlineBreaks=true,explicitBreaksOnly=false)
yDst += 4
x=y=0 x=y=0
characters=[] characters=[]
textchunks=[] textchunks=[]
@@ -225,7 +224,7 @@ def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
havenl=true if isWaitChar(textchars[position]) havenl=true if isWaitChar(textchars[position])
characters.push([ characters.push([
textchars[position], textchars[position],
x+xStart,texty+yStart,width+2,lineheight, x+xStart,texty,width+2,lineheight,
false,bold,italic,colorclone,nil,false,false, false,bold,italic,colorclone,nil,false,false,
defaultfontname,bitmap.font.size,position,nil,0]) defaultfontname,bitmap.font.size,position,nil,0])
end end
@@ -650,8 +649,8 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
yStart=[(lineheight/2)-(graphicHeight/2),0].max yStart=[(lineheight/2)-(graphicHeight/2),0].max
graphicRect=Rect.new(graphicX,graphicY,graphicWidth,graphicHeight) graphicRect=Rect.new(graphicX,graphicY,graphicWidth,graphicHeight)
else else
yStart=0
xStart=0 xStart=0
yStart=0
width=isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width width=isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width
width+=2 if width>0 && outline2count>0 width+=2 if width>0 && outline2count>0
end end
@@ -665,9 +664,9 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false,false, characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false,false,
defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0]) defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0])
charactersInternal.push([alignment,y,0]) charactersInternal.push([alignment,y,0])
y+=1; y+=1
x=0; x=0
rightalign=0; rightalign=0
lastword=[characters.length,x] lastword=[characters.length,x]
hadspace=false hadspace=false
hadnonspace=false hadnonspace=false
@@ -947,7 +946,7 @@ end
def getLineBrokenChunks(bitmap,value,width,dims,plain=false) def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
x=0 x=0
y=4 y=0
ret=[] ret=[]
if dims if dims
dims[0]=0 dims[0]=0
@@ -1108,6 +1107,7 @@ def drawFormattedChars(bitmap,chars)
bitmap.font=oldfont bitmap.font=oldfont
end end
# Unused
def drawTextTable(bitmap,x,y,totalWidth,rowHeight,columnWidthPercents,table) def drawTextTable(bitmap,x,y,totalWidth,rowHeight,columnWidthPercents,table)
yPos=y yPos=y
for i in 0...table.length for i in 0...table.length
@@ -1138,6 +1138,7 @@ def drawFormattedTextEx(bitmap,x,y,width,text,baseColor=nil,shadowColor=nil,line
drawFormattedChars(bitmap,chars) drawFormattedChars(bitmap,chars)
end end
# Unused
def pbDrawShadow(bitmap,x,y,width,height,string) def pbDrawShadow(bitmap,x,y,width,height,string)
return if !bitmap || !string return if !bitmap || !string
pbDrawShadowText(bitmap,x,y,width,height,string,nil,bitmap.font.color) pbDrawShadowText(bitmap,x,y,width,height,string,nil,bitmap.font.color)

View File

@@ -451,6 +451,22 @@ def pbDisplayCoinsWindow(msgwindow,goldwindow)
return coinwindow return coinwindow
end end
def pbDisplayBattlePointsWindow(msgwindow)
pointsString = ($Trainer) ? $Trainer.battle_points.to_s_formatted : "0"
pointswindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
pointswindow.setSkin("Graphics/Windowskins/goldskin")
pointswindow.resizeToFit(pointswindow.text,Graphics.width)
pointswindow.width=160 if pointswindow.width<=160
if msgwindow.y==0
pointswindow.y=Graphics.height-pointswindow.height
else
pointswindow.y=0
end
pointswindow.viewport=msgwindow.viewport
pointswindow.z=msgwindow.z
return pointswindow
end
#=============================================================================== #===============================================================================
@@ -507,6 +523,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
facewindow=nil facewindow=nil
goldwindow=nil goldwindow=nil
coinwindow=nil coinwindow=nil
battlepointswindow=nil
cmdvariable=0 cmdvariable=0
cmdIfCancel=0 cmdIfCancel=0
msgwindow.waitcount=0 msgwindow.waitcount=0
@@ -576,7 +593,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
### Controls ### Controls
textchunks=[] textchunks=[]
controls=[] controls=[]
while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|wd|wm|op|cl|wu|\.|\||\!|\^))/i] while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
textchunks.push($~.pre_match) textchunks.push($~.pre_match)
if $~[1] if $~[1]
controls.push([$~[1].downcase,$~[2],-1]) controls.push([$~[1].downcase,$~[2],-1])
@@ -689,6 +706,9 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
when "cn" # Display coins window when "cn" # Display coins window
coinwindow.dispose if coinwindow coinwindow.dispose if coinwindow
coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow) coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
when "pt" # Display battle points window
battlepointswindow.dispose if battlepointswindow
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
when "wu" when "wu"
msgwindow.y = 0 msgwindow.y = 0
atTop = true atTop = true
@@ -761,6 +781,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
msgback.dispose if msgback msgback.dispose if msgback
goldwindow.dispose if goldwindow goldwindow.dispose if goldwindow
coinwindow.dispose if coinwindow coinwindow.dispose if coinwindow
battlepointswindow.dispose if battlepointswindow
facewindow.dispose if facewindow facewindow.dispose if facewindow
if haveSpecialClose if haveSpecialClose
pbSEPlay(pbStringToAudioFile(specialCloseSE)) pbSEPlay(pbStringToAudioFile(specialCloseSE))

View File

@@ -48,6 +48,7 @@ module PokeBattle_BattleCommon
pbPlayer.pokedex.set_owned(pkmn.species) pbPlayer.pokedex.set_owned(pkmn.species)
if $Trainer.has_pokedex if $Trainer.has_pokedex
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name)) pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name))
pbPlayer.pokedex.register_last_seen(pkmn)
@scene.pbShowPokedex(pkmn.species) @scene.pbShowPokedex(pkmn.species)
end end
end end

View File

@@ -82,13 +82,13 @@ def pbDisplayMail(mail,_bearer=nil)
shadowForLightBG = Color.new(168,168,176) shadowForLightBG = Color.new(168,168,176)
if mail.message && mail.message!="" if mail.message && mail.message!=""
isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(48,48,Graphics.width-96,32*7)) isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(48,48,Graphics.width-96,32*7))
drawTextEx(overlay,48,48,Graphics.width-(48*2),7,mail.message, drawTextEx(overlay,48,52,Graphics.width-(48*2),7,mail.message,
(isDark) ? baseForDarkBG : baseForLightBG, (isDark) ? baseForDarkBG : baseForLightBG,
(isDark) ? shadowForDarkBG : shadowForLightBG) (isDark) ? shadowForDarkBG : shadowForLightBG)
end end
if mail.sender && mail.sender!="" if mail.sender && mail.sender!=""
isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(336,322,144,32*1)) isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(336,322,144,32*1))
drawTextEx(overlay,336,322,144,1,mail.sender, drawTextEx(overlay,336,326,144,1,mail.sender,
(isDark) ? baseForDarkBG : baseForLightBG, (isDark) ? baseForDarkBG : baseForLightBG,
(isDark) ? shadowForDarkBG : shadowForLightBG) (isDark) ? shadowForDarkBG : shadowForLightBG)
end end

View File

@@ -235,7 +235,7 @@ class PokemonPokedexInfo_Scene
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow]) textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow])
end end
# Draw the Pokédex entry text # Draw the Pokédex entry text
drawTextEx(overlay, 40, 240, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
species_data.pokedex_entry, base, shadow) species_data.pokedex_entry, base, shadow)
# Draw the footprint # Draw the footprint
footprintfile = GameData::Species.footprint_filename(@species, @form) footprintfile = GameData::Species.footprint_filename(@species, @form)

View File

@@ -663,7 +663,7 @@ class PokemonSummary_Scene
ability = @pokemon.ability ability = @pokemon.ability
if ability if ability
textpos.push([ability.name,362,278,0,Color.new(64,64,64),Color.new(176,176,176)]) textpos.push([ability.name,362,278,0,Color.new(64,64,64),Color.new(176,176,176)])
drawTextEx(overlay,224,316,282,2,ability.description,Color.new(64,64,64),Color.new(176,176,176)) drawTextEx(overlay,224,320,282,2,ability.description,Color.new(64,64,64),Color.new(176,176,176))
end end
# Draw all text # Draw all text
pbDrawTextPositions(overlay,textpos) pbDrawTextPositions(overlay,textpos)
@@ -830,7 +830,7 @@ class PokemonSummary_Scene
imagepos = [["Graphics/Pictures/category", 166, 124, 0, selected_move.category * 28, 64, 28]] imagepos = [["Graphics/Pictures/category", 166, 124, 0, selected_move.category * 28, 64, 28]]
pbDrawImagePositions(overlay, imagepos) pbDrawImagePositions(overlay, imagepos)
# Draw selected move's description # Draw selected move's description
drawTextEx(overlay, 4, 218, 230, 5, selected_move.description, base, shadow) drawTextEx(overlay, 4, 222, 230, 5, selected_move.description, base, shadow)
end end
def drawPageFive def drawPageFive
@@ -883,7 +883,7 @@ class PokemonSummary_Scene
] ]
pbDrawTextPositions(overlay,textpos) pbDrawTextPositions(overlay,textpos)
# Draw selected ribbon's description # Draw selected ribbon's description
drawTextEx(overlay,18,318,480,2,desc,base,shadow) drawTextEx(overlay,18,322,480,2,desc,base,shadow)
end end
def pbGoToPrevious def pbGoToPrevious

View File

@@ -132,7 +132,7 @@ class ItemStorage_Scene
def pbRefresh def pbRefresh
bm = @sprites["pocketwindow"].bitmap bm = @sprites["pocketwindow"].bitmap
# Draw title at upper left corner ("Toss Item/Withdraw Item") # Draw title at upper left corner ("Toss Item/Withdraw Item")
drawTextEx(bm,0,0,bm.width,2,@title,TITLEBASECOLOR,TITLESHADOWCOLOR) drawTextEx(bm,0,4,bm.width,2,@title,TITLEBASECOLOR,TITLESHADOWCOLOR)
itemwindow = @sprites["itemwindow"] itemwindow = @sprites["itemwindow"]
# Draw item icon # Draw item icon
@sprites["icon"].item = itemwindow.item @sprites["icon"].item = itemwindow.item

View File

@@ -108,7 +108,7 @@ class MoveRelearner_Scene
imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32]) imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32])
end end
pbDrawImagePositions(overlay,imagepos) pbDrawImagePositions(overlay,imagepos)
drawTextEx(overlay,272,210,230,5,selMoveData.description, drawTextEx(overlay,272,214,230,5,selMoveData.description,
Color.new(64,64,64),Color.new(176,176,176)) Color.new(64,64,64),Color.new(176,176,176))
end end

View File

@@ -24,7 +24,8 @@ class PokemonGlobalMetadata
# @deprecated Use {Player#seen_purify_chamber} instead. This alias is slated to be removed in v20. # @deprecated Use {Player#seen_purify_chamber} instead. This alias is slated to be removed in v20.
def seenPurifyChamber def seenPurifyChamber
Deprecation.warn_method('PokemonGlobalMetadata#seenPurifyChamber', 'v20', '$Trainer.seen_purify_chamber') Deprecation.warn_method('PokemonGlobalMetadata#seenPurifyChamber', 'v20', '$Trainer.seen_purify_chamber')
return @seenPurifyChamber || false return @seenPurifyChamber if !@seenPurifyChamber.nil?
return ($Trainer) ? $Trainer.seen_purify_chamber : false
end end
# @deprecated Use {Player#seen_purify_chamber=} instead. This alias is slated to be removed in v20. # @deprecated Use {Player#seen_purify_chamber=} instead. This alias is slated to be removed in v20.
@@ -40,7 +41,8 @@ class PokemonGlobalMetadata
# @deprecated Use {Player#has_snag_machine} instead. This alias is slated to be removed in v20. # @deprecated Use {Player#has_snag_machine} instead. This alias is slated to be removed in v20.
def snagMachine def snagMachine
Deprecation.warn_method('PokemonGlobalMetadata#snagMachine', 'v20', '$Trainer.has_snag_machine') Deprecation.warn_method('PokemonGlobalMetadata#snagMachine', 'v20', '$Trainer.has_snag_machine')
return @snagMachine || false return @snagMachine if !@snagMachine.nil?
return ($Trainer) ? $Trainer.has_snag_machine : false
end end
# @deprecated Use {Player#has_snag_machine=} instead. This alias is slated to be removed in v20. # @deprecated Use {Player#has_snag_machine=} instead. This alias is slated to be removed in v20.

View File

@@ -638,11 +638,15 @@ PokemonDebugMenuCommands.register("setitem", {
item = pbChooseItemList(pkmn.item_id) item = pbChooseItemList(pkmn.item_id)
if item && item != pkmn.item_id if item && item != pkmn.item_id
pkmn.item = item pkmn.item = item
if GameData::Item.get(item).is_mail?
pkmn.mail = Mail.new(item, _INTL("Text"), $Trainer.name)
end
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
end end
when 1 # Remove item when 1 # Remove item
if pkmn.hasItem? if pkmn.hasItem?
pkmn.item = nil pkmn.item = nil
pkmn.mail = nil
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
end end
else else