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