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))