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
dims = resizeToFitInternal(text,maxwidth)
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING
self.height = dims[1] + self.borderY - 4
self.height = dims[1] + self.borderY
refresh
end
def resizeHeightToFit(text, width = -1) # width is current window width
dims = resizeToFitInternal(text,width)
self.width = (width < 0) ? Graphics.width : width
self.height = dims[1] + self.borderY - 4
self.height = dims[1] + self.borderY
refresh
end
@@ -101,7 +101,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
self.height-self.borderY)
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)
end
end
@@ -215,7 +215,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting
@starting = true
self.width = dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING
self.height = dims[1]+self.borderY - 4
self.height = dims[1]+self.borderY
@starting = oldstarting
redrawText
end
@@ -225,7 +225,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting
@starting = true
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
redrawText
end
@@ -247,7 +247,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
oldstarting = @starting
@starting = true
self.width = (width < 0) ? Graphics.width : width
self.height = dims[1] + self.borderY - 4
self.height = dims[1] + self.borderY
@starting = oldstarting
redrawText
end

View File

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

View File

@@ -451,6 +451,22 @@ def pbDisplayCoinsWindow(msgwindow,goldwindow)
return coinwindow
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
goldwindow=nil
coinwindow=nil
battlepointswindow=nil
cmdvariable=0
cmdIfCancel=0
msgwindow.waitcount=0
@@ -576,7 +593,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
### Controls
textchunks=[]
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)
if $~[1]
controls.push([$~[1].downcase,$~[2],-1])
@@ -689,6 +706,9 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
when "cn" # Display coins window
coinwindow.dispose if coinwindow
coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
when "pt" # Display battle points window
battlepointswindow.dispose if battlepointswindow
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
when "wu"
msgwindow.y = 0
atTop = true
@@ -761,6 +781,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
msgback.dispose if msgback
goldwindow.dispose if goldwindow
coinwindow.dispose if coinwindow
battlepointswindow.dispose if battlepointswindow
facewindow.dispose if facewindow
if haveSpecialClose
pbSEPlay(pbStringToAudioFile(specialCloseSE))

View File

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

View File

@@ -40,7 +40,7 @@ end
def pbStoreMail(pkmn,item,message,poke1=nil,poke2=nil,poke3=nil)
raise _INTL("Pokémon already has mail") if pkmn.mail
pkmn.mail = Mail.new(item,message, $Trainer.name, poke1, poke2, poke3)
pkmn.mail = Mail.new(item, message, $Trainer.name, poke1, poke2, poke3)
end
def pbDisplayMail(mail,_bearer=nil)
@@ -82,13 +82,13 @@ def pbDisplayMail(mail,_bearer=nil)
shadowForLightBG = Color.new(168,168,176)
if mail.message && mail.message!=""
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) ? shadowForDarkBG : shadowForLightBG)
end
if mail.sender && mail.sender!=""
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) ? shadowForDarkBG : shadowForLightBG)
end

View File

@@ -235,7 +235,7 @@ class PokemonPokedexInfo_Scene
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow])
end
# 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)
# Draw the footprint
footprintfile = GameData::Species.footprint_filename(@species, @form)

View File

@@ -663,7 +663,7 @@ class PokemonSummary_Scene
ability = @pokemon.ability
if ability
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
# Draw all text
pbDrawTextPositions(overlay,textpos)
@@ -830,7 +830,7 @@ class PokemonSummary_Scene
imagepos = [["Graphics/Pictures/category", 166, 124, 0, selected_move.category * 28, 64, 28]]
pbDrawImagePositions(overlay, imagepos)
# 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
def drawPageFive
@@ -883,7 +883,7 @@ class PokemonSummary_Scene
]
pbDrawTextPositions(overlay,textpos)
# Draw selected ribbon's description
drawTextEx(overlay,18,318,480,2,desc,base,shadow)
drawTextEx(overlay,18,322,480,2,desc,base,shadow)
end
def pbGoToPrevious

View File

@@ -132,7 +132,7 @@ class ItemStorage_Scene
def pbRefresh
bm = @sprites["pocketwindow"].bitmap
# 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"]
# Draw item icon
@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])
end
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))
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.
def seenPurifyChamber
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
# @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.
def snagMachine
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
# @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)
if item && item != pkmn.item_id
pkmn.item = item
if GameData::Item.get(item).is_mail?
pkmn.mail = Mail.new(item, _INTL("Text"), $Trainer.name)
end
screen.pbRefreshSingle(pkmnid)
end
when 1 # Remove item
if pkmn.hasItem?
pkmn.item = nil
pkmn.mail = nil
screen.pbRefreshSingle(pkmnid)
end
else