mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Fixed text positioning and removed individual character offsets
This commit is contained in:
@@ -4,13 +4,6 @@ def mkxp?
|
|||||||
return $MKXP
|
return $MKXP
|
||||||
end
|
end
|
||||||
|
|
||||||
CHARACTER_OFFSETS = {
|
|
||||||
"p" => [0, 2],
|
|
||||||
"g" => [0, 2],
|
|
||||||
"y" => [0, 2],
|
|
||||||
"q" => [0, 2]
|
|
||||||
}
|
|
||||||
|
|
||||||
def pbSetWindowText(string)
|
def pbSetWindowText(string)
|
||||||
if mkxp?
|
if mkxp?
|
||||||
System.set_window_title(string || System.game_title)
|
System.set_window_title(string || System.game_title)
|
||||||
@@ -18,3 +11,13 @@ def pbSetWindowText(string)
|
|||||||
Win32API.SetWindowText(string || "RGSS Player")
|
Win32API.SetWindowText(string || "RGSS Player")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Bitmap
|
||||||
|
if mkxp?
|
||||||
|
alias mkxp_draw_text draw_text
|
||||||
|
def draw_text(x, y, width, height, text, align = 0)
|
||||||
|
height = text_size(text).height
|
||||||
|
mkxp_draw_text(x, y, width, height, text, align)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -1310,12 +1310,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
for ch in fmt
|
for ch in fmt
|
||||||
chx = ch[1]+ch[3]
|
chx = ch[1]+ch[3]
|
||||||
chy = ch[2]+ch[4]
|
chy = ch[2]+ch[4]
|
||||||
if mkxp?
|
|
||||||
offset = (CHARACTER_OFFSETS[ch[0]] || [0, 0])
|
|
||||||
offset[1] -= 2 if offset[1]
|
|
||||||
ch[1] += offset[0] if offset[0]
|
|
||||||
ch[2] += offset[1] if offset[1]
|
|
||||||
end
|
|
||||||
width = chx if width<chx
|
width = chx if width<chx
|
||||||
height = chy if height<chy
|
height = chy if height<chy
|
||||||
if !ch[5] && ch[0]=="\n"
|
if !ch[5] && ch[0]=="\n"
|
||||||
@@ -1343,12 +1337,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
|||||||
for ch in @fmtchars
|
for ch in @fmtchars
|
||||||
chx = ch[1]+ch[3]
|
chx = ch[1]+ch[3]
|
||||||
chy = ch[2]+ch[4]
|
chy = ch[2]+ch[4]
|
||||||
if mkxp?
|
|
||||||
offset = (CHARACTER_OFFSETS[ch[0]] || [0, 0])
|
|
||||||
offset[1] -= 2 if offset[1]
|
|
||||||
ch[1] += offset[0] if offset[0]
|
|
||||||
ch[2] += offset[1] if offset[1]
|
|
||||||
end
|
|
||||||
width = chx if width<chx
|
width = chx if width<chx
|
||||||
height = chy if height<chy
|
height = chy if height<chy
|
||||||
@textchars.push(ch[5] ? "" : ch[0])
|
@textchars.push(ch[5] ? "" : ch[0])
|
||||||
@@ -2234,7 +2222,7 @@ class Window_CommandPokemon < Window_DrawableCommand
|
|||||||
def drawItem(index,_count,rect)
|
def drawItem(index,_count,rect)
|
||||||
pbSetSystemFont(self.contents) if @starting
|
pbSetSystemFont(self.contents) if @starting
|
||||||
rect=drawCursor(index,rect)
|
rect=drawCursor(index,rect)
|
||||||
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,
|
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,
|
||||||
@commands[index],self.baseColor,self.shadowColor)
|
@commands[index],self.baseColor,self.shadowColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ 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 if mkxp?
|
||||||
x=y=0
|
x=y=0
|
||||||
characters=[]
|
characters=[]
|
||||||
textchunks=[]
|
textchunks=[]
|
||||||
@@ -421,6 +422,7 @@ _drawFormattedChars_ function.
|
|||||||
def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
|
def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
|
||||||
newlineBreaks=true,explicitBreaksOnly=false,
|
newlineBreaks=true,explicitBreaksOnly=false,
|
||||||
collapseAlignments=false)
|
collapseAlignments=false)
|
||||||
|
yDst += 4 if mkxp?
|
||||||
dummybitmap=nil
|
dummybitmap=nil
|
||||||
if !bitmap || bitmap.disposed? # allows function to be called with nil bitmap
|
if !bitmap || bitmap.disposed? # allows function to be called with nil bitmap
|
||||||
dummybitmap=Bitmap.new(1,1)
|
dummybitmap=Bitmap.new(1,1)
|
||||||
@@ -888,8 +890,7 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
|
def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
|
||||||
x=0
|
x=0
|
||||||
y=0
|
y=mkxp? ? 4: 0
|
||||||
textheight=0
|
|
||||||
ret=[]
|
ret=[]
|
||||||
if dims
|
if dims
|
||||||
dims[0]=0
|
dims[0]=0
|
||||||
@@ -905,9 +906,7 @@ def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
|
|||||||
ccheck=c
|
ccheck=c
|
||||||
if ccheck=="\n"
|
if ccheck=="\n"
|
||||||
x=0
|
x=0
|
||||||
# y+=(textheight==0) ? bitmap.text_size("X").height : textheight
|
y+=32
|
||||||
y+=(textheight==0) ? bitmap.text_size("X").height + 1 + (mkxp? ? 6 : 0) : textheight
|
|
||||||
textheight=0
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if ccheck[/</] && !plain
|
if ccheck[/</] && !plain
|
||||||
@@ -927,14 +926,10 @@ def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
|
|||||||
minTextSize=bitmap.text_size(word.gsub(/\s*/,""))
|
minTextSize=bitmap.text_size(word.gsub(/\s*/,""))
|
||||||
if x>0 && x+minTextSize.width>width
|
if x>0 && x+minTextSize.width>width
|
||||||
x=0
|
x=0
|
||||||
# y+=32 # (textheight==0) ? bitmap.text_size("X").height : textheight
|
y+=32
|
||||||
y+=(textheight==0) ? bitmap.text_size("X").height + 1 + (mkxp? ? 6 : 0) : textheight
|
|
||||||
textheight=0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# textheight=32 # [textheight,textSize.height].max
|
ret.push([word,x,y,textwidth,32,color])
|
||||||
textheight=[textheight,textSize.height + 1 + (mkxp? ? 6 : 0)].max
|
|
||||||
ret.push([word,x,y,textwidth,textheight,color])
|
|
||||||
x+=textwidth
|
x+=textwidth
|
||||||
dims[0]=x if dims && dims[0]<x
|
dims[0]=x if dims && dims[0]<x
|
||||||
end
|
end
|
||||||
@@ -943,7 +938,7 @@ def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dims[1]=y+textheight if dims
|
dims[1]=y+32 if dims
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -951,7 +946,7 @@ def renderLineBrokenChunks(bitmap,xDst,yDst,normtext,maxheight=0)
|
|||||||
for i in 0...normtext.length
|
for i in 0...normtext.length
|
||||||
width=normtext[i][3]
|
width=normtext[i][3]
|
||||||
textx=normtext[i][1]+xDst
|
textx=normtext[i][1]+xDst
|
||||||
texty=normtext[i][2]+yDst + (mkxp? ? 4 : 0)
|
texty=normtext[i][2]+yDst
|
||||||
if maxheight==0 || normtext[i][2]<maxheight
|
if maxheight==0 || normtext[i][2]<maxheight
|
||||||
bitmap.font.color=normtext[i][5]
|
bitmap.font.color=normtext[i][5]
|
||||||
bitmap.draw_text(textx,texty,width+2,normtext[i][4],normtext[i][0])
|
bitmap.draw_text(textx,texty,width+2,normtext[i][4],normtext[i][0])
|
||||||
@@ -963,7 +958,7 @@ def renderLineBrokenChunksWithShadow(bitmap,xDst,yDst,normtext,maxheight,baseCol
|
|||||||
for i in 0...normtext.length
|
for i in 0...normtext.length
|
||||||
width=normtext[i][3]
|
width=normtext[i][3]
|
||||||
textx=normtext[i][1]+xDst
|
textx=normtext[i][1]+xDst
|
||||||
texty=normtext[i][2]+yDst + (mkxp? ? 4 : 0)
|
texty=normtext[i][2]+yDst
|
||||||
if maxheight==0 || normtext[i][2]<maxheight
|
if maxheight==0 || normtext[i][2]<maxheight
|
||||||
height=normtext[i][4]
|
height=normtext[i][4]
|
||||||
text=normtext[i][0]
|
text=normtext[i][0]
|
||||||
@@ -1114,7 +1109,7 @@ def pbDrawShadowText(bitmap,x,y,width,height,string,baseColor,shadowColor=nil,al
|
|||||||
return if !bitmap || !string
|
return if !bitmap || !string
|
||||||
width=(width<0) ? bitmap.text_size(string).width+1 : width
|
width=(width<0) ? bitmap.text_size(string).width+1 : width
|
||||||
height=(height<0) ? bitmap.text_size(string).height+1 : height
|
height=(height<0) ? bitmap.text_size(string).height+1 : height
|
||||||
y = y + (mkxp? ? -2 : 0)
|
y += -2 if mkxp?
|
||||||
if shadowColor && shadowColor.alpha>0
|
if shadowColor && shadowColor.alpha>0
|
||||||
bitmap.font.color=shadowColor
|
bitmap.font.color=shadowColor
|
||||||
bitmap.draw_text(x+2,y,width,height,string,align)
|
bitmap.draw_text(x+2,y,width,height,string,align)
|
||||||
@@ -1131,7 +1126,6 @@ def pbDrawOutlineText(bitmap,x,y,width,height,string,baseColor,shadowColor=nil,a
|
|||||||
return if !bitmap || !string
|
return if !bitmap || !string
|
||||||
width=(width<0) ? bitmap.text_size(string).width+4 : width
|
width=(width<0) ? bitmap.text_size(string).width+4 : width
|
||||||
height=(height<0) ? bitmap.text_size(string).height+4 : height
|
height=(height<0) ? bitmap.text_size(string).height+4 : height
|
||||||
y = y + (mkxp? ? 4 : 0)
|
|
||||||
if shadowColor && shadowColor.alpha>0
|
if shadowColor && shadowColor.alpha>0
|
||||||
bitmap.font.color=shadowColor
|
bitmap.font.color=shadowColor
|
||||||
bitmap.draw_text(x-2,y-2,width,height,string,align)
|
bitmap.draw_text(x-2,y-2,width,height,string,align)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class LocationWindow
|
|||||||
@window.resizeToFit(name,Graphics.width)
|
@window.resizeToFit(name,Graphics.width)
|
||||||
@window.x = 0
|
@window.x = 0
|
||||||
@window.y = -@window.height
|
@window.y = -@window.height
|
||||||
|
@window.height = 64
|
||||||
@window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
@window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||||
@window.viewport.z = 99999
|
@window.viewport.z = 99999
|
||||||
@currentmap = $game_map.map_id
|
@currentmap = $game_map.map_id
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ class PokemonPartyPanel < SpriteWrapper
|
|||||||
"Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
|
"Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
|
||||||
pbSetSmallFont(@overlaysprite.bitmap)
|
pbSetSmallFont(@overlaysprite.bitmap)
|
||||||
pbDrawTextPositions(@overlaysprite.bitmap,[
|
pbDrawTextPositions(@overlaysprite.bitmap,[
|
||||||
[@pokemon.level.to_s,42,62,0,basecolor,shadowcolor]
|
[@pokemon.level.to_s,42,63,0,basecolor,shadowcolor]
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
# Draw annotation text
|
# Draw annotation text
|
||||||
|
|||||||
Reference in New Issue
Block a user