Merge remote-tracking branch 'origin/mkxp-z' into mkxp-z

This commit is contained in:
Maruno17
2020-09-13 15:46:57 +01:00
35 changed files with 450 additions and 63 deletions

View File

@@ -0,0 +1,23 @@
$MKXP = !!defined?(System)
def mkxp?
return $MKXP
end
def pbSetWindowText(string)
if mkxp?
System.set_window_title(string || System.game_title)
else
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

View File

@@ -16,9 +16,26 @@ if true # Disables using Alt+Enter to go fullscreen
regHotKey.call(0, 1, 1, 0x0D)
end
def pbSetResizeFactor(factor=1,norecalc=false)
factor = [0.5,1.0,2.0,-1][factor] if !norecalc
(factor<0) ? pbConfigureFullScreen : pbConfigureWindowedScreen(factor)
if mkxp?
# This kinda puts most of SpriteResizer out of business
def pbSetResizeFactor(factor)
if !$ResizeInitialized
Graphics.resize_screen(SCREEN_WIDTH, SCREEN_HEIGHT)
$ResizeInitialized = true
end
if factor < 0 || factor == 3
Graphics.fullscreen = true if !Graphics.fullscreen
else
Graphics.fullscreen = false if Graphics.fullscreen
Graphics.scale = factor
Graphics.center
end
end
else
def pbSetResizeFactor(factor=1,norecalc=false)
factor = [0.5,1.0,2.0,-1][factor] if !norecalc
(factor<0) ? pbConfigureFullScreen : pbConfigureWindowedScreen(factor)
end
end
def pbSetResizeFactor2(factor,force=false)
@@ -172,33 +189,37 @@ module Graphics
end
end
class << self
begin
x = @@haveresizescreen
rescue NameError # If exception is caught, the class
if !method_defined?(:oldresizescreen) # variable wasn't defined yet
begin
alias oldresizescreen resize_screen
@@haveresizescreen = true
rescue
if mkxp?
@@haveresizescreen = true
else
class << self
begin
x = @@haveresizescreen
rescue NameError # If exception is caught, the class
if !method_defined?(:oldresizescreen) # variable wasn't defined yet
begin
alias oldresizescreen resize_screen
@@haveresizescreen = true
rescue
@@haveresizescreen = false
end
else
@@haveresizescreen = false
end
else
@@haveresizescreen = false
end
def haveresizescreen
@@haveresizescreen
end
end
def haveresizescreen
@@haveresizescreen
def self.resize_screen(w,h)
@@width = w
@@height = h
pbSetResizeFactor($ResizeFactor,true)
end
end
def self.resize_screen(w,h)
@@width = w
@@height = h
pbSetResizeFactor($ResizeFactor,true)
end
@@deletefailed = false
def self.snap_to_bitmap(resize=true)

View File

@@ -387,11 +387,11 @@ def pbSetSystemFont(bitmap)
fontname = MessageConfig.pbGetSystemFontName
bitmap.font.name = fontname
if fontname == "Pokemon FireLeaf" || fontname == "Power Red and Green"
bitmap.font.size = 29
bitmap.font.size = mkxp? ? 27 : 29
elsif fontname == "Pokemon Emerald Small" || fontname == "Power Green Small"
bitmap.font.size = 25
bitmap.font.size = mkxp? ? 29 : 25
else
bitmap.font.size = 31
bitmap.font.size = mkxp? ? 29 : 31
end
end
@@ -404,7 +404,7 @@ end
# Sets a bitmap's font to the system narrow font.
def pbSetNarrowFont(bitmap)
bitmap.font.name = pbNarrowFontName
bitmap.font.size = 31
bitmap.font.size = mkxp? ? 29 : 31
end
#===============================================================================

View File

@@ -2222,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

View File

@@ -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 : 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 : textheight
textheight=0
y+=32
end
end
# textheight=32 # [textheight,textSize.height].max
textheight=[textheight,textSize.height+1].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
@@ -1112,8 +1107,9 @@ end
def pbDrawShadowText(bitmap,x,y,width,height,string,baseColor,shadowColor=nil,align=0)
return if !bitmap || !string
width=(width<0) ? bitmap.text_size(string).width+4 : width
height=(height<0) ? bitmap.text_size(string).height+4 : height
width=(width<0) ? bitmap.text_size(string).width+1 : width
height=(height<0) ? bitmap.text_size(string).height+1 : height
y += -2 if mkxp?
if shadowColor && shadowColor.alpha>0
bitmap.font.color=shadowColor
bitmap.draw_text(x+2,y,width,height,string,align)
@@ -1161,7 +1157,7 @@ def pbDrawTextPositions(bitmap,textpos)
for i in textpos
textsize = bitmap.text_size(i[0])
x = i[1]
y = i[2]
y = i[2] + (mkxp? ? 6 : 0)
if i[3]==true || i[3]==1 # right align
x -= textsize.width
elsif i[3]==2 # centered

View File

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

View File

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

View File

@@ -96,7 +96,11 @@ def pbScreenCapture
filestart = sprintf("%s.%03d",filestart,(t.to_f-t.to_i)*1000) # milliseconds
capturefile = RTP.getSaveFileName(sprintf("%s.png",filestart))
if capturefile && safeExists?("rubyscreen.dll")
Graphics.snap_to_bitmap(false).saveToPng(capturefile)
if mkxp?
Graphics.screenshot(capturefile)
else
Graphics.snap_to_bitmap(false).saveToPng(capturefile)
end
pbSEPlay("Pkmn exp full") if FileTest.audio_exist?("Audio/SE/Pkmn exp full")
end
end

View File

@@ -197,7 +197,7 @@ def pbEachFileSectionEx(f)
end
lineno += 1
Graphics.update if lineno%500==0
Win32API.SetWindowText(_INTL("Processing {1} line {2}",FileLineData.file,lineno)) if lineno%50==0
pbSetWindowText(_INTL("Processing {1} line {2}",FileLineData.file,lineno)) if lineno%50==0
}
yield lastsection,sectionname if havesection
end
@@ -1179,6 +1179,7 @@ def pbCompileAllData(mustCompile)
if !$INEDITOR && LANGUAGES.length>=2
pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1])
end
pbSetWindowText(nil) if mkxp?
end
def pbCompiler
@@ -1242,24 +1243,26 @@ def pbCompiler
end
# Check data files and PBS files, and recompile if any PBS file was edited
# more recently than the data files were last created
for i in 0...dataFiles.length
begin
File.open("Data/#{dataFiles[i]}") { |file|
latestDataTime = [latestDataTime,file.mtime.to_i].max
}
rescue SystemCallError
mustCompile = true
if !mkxp?
for i in 0...dataFiles.length
begin
File.open("Data/#{dataFiles[i]}") { |file|
latestDataTime = [latestDataTime,file.mtime.to_i].max
}
rescue SystemCallError
mustCompile = true
end
end
end
for i in 0...textFiles.length
begin
File.open("PBS/#{textFiles[i]}") { |file|
latestTextTime = [latestTextTime,file.mtime.to_i].max
}
rescue SystemCallError
for i in 0...textFiles.length
begin
File.open("PBS/#{textFiles[i]}") { |file|
latestTextTime = [latestTextTime,file.mtime.to_i].max
}
rescue SystemCallError
end
end
mustCompile |= (latestTextTime>=latestDataTime)
end
mustCompile |= (latestTextTime>=latestDataTime)
# Should recompile if holding Ctrl
Input.update
mustCompile = true if Input.press?(Input::CTRL)
@@ -1273,7 +1276,7 @@ def pbCompiler
end
end
# Recompile all data
pbCompileAllData(mustCompile) { |msg| Win32API.SetWindowText(msg) }
pbCompileAllData(mustCompile) { |msg| pbSetWindowText(msg) }
rescue Exception
e = $!
raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)

View File

@@ -1416,7 +1416,7 @@ def pbCompileTrainerEvents(_mustcompile)
changed = false
map = mapData.getMap(id)
next if !map || !mapData.mapinfos[id]
Win32API.SetWindowText(_INTL("Processing map {1} ({2})",id,mapData.mapinfos[id].name))
pbSetWindowText(_INTL("Processing map {1} ({2})",id,mapData.mapinfos[id].name))
for key in map.events.keys
if Time.now.to_i-t>=5
Graphics.update
@@ -1448,7 +1448,7 @@ def pbCompileTrainerEvents(_mustcompile)
changed = false
Graphics.update
commonEvents = pbLoadRxData("Data/CommonEvents")
Win32API.SetWindowText(_INTL("Processing common events"))
pbSetWindowText(_INTL("Processing common events"))
for key in 0...commonEvents.length
newevent = pbFixEventUse(commonEvents[key],0,mapData)
if newevent