Merge pull request #16 from Marin-MK/master

mkxp-z support
This commit is contained in:
Maruno17
2020-09-11 15:42:02 +01:00
committed by GitHub
39 changed files with 468 additions and 81 deletions
Binary file not shown.
@@ -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
@@ -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)
@@ -384,27 +384,27 @@ end
# Sets a bitmap's font to the system font.
def pbSetSystemFont(bitmap)
fontname=MessageConfig.pbGetSystemFontName
bitmap.font.name=fontname
if fontname=="Pokemon FireLeaf" || fontname=="Power Red and Green"
bitmap.font.size=29
elsif fontname=="Pokemon Emerald Small" || fontname=="Power Green Small"
bitmap.font.size=25
fontname = MessageConfig.pbGetSystemFontName
bitmap.font.name = fontname
if fontname == "Pokemon FireLeaf" || fontname == "Power Red and Green"
bitmap.font.size = mkxp? ? 27 : 29
elsif fontname == "Pokemon Emerald Small" || fontname == "Power Green Small"
bitmap.font.size = mkxp? ? 29 : 31
else
bitmap.font.size=31
bitmap.font.size = mkxp? ? 29 : 31
end
end
# Sets a bitmap's font to the system small font.
def pbSetSmallFont(bitmap)
bitmap.font.name=pbSmallFontName
bitmap.font.size=25
bitmap.font.name = pbSmallFontName
bitmap.font.size = 25
end
# Sets a bitmap's font to the system narrow font.
def pbSetNarrowFont(bitmap)
bitmap.font.name=pbNarrowFontName
bitmap.font.size=31
bitmap.font.name = pbNarrowFontName
bitmap.font.size = mkxp? ? 29 : 31
end
#===============================================================================
@@ -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
@@ -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
+1 -1
View File
@@ -127,7 +127,7 @@ _END_
end
plugin_credits << "\n"
end
CREDIT.gsub!(/{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE}/, plugin_credits)
CREDIT.gsub!(/\{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE\}/, plugin_credits)
credit_lines = CREDIT.split(/\n/)
credit_bitmap = Bitmap.new(Graphics.width,32 * credit_lines.size)
credit_lines.each_index do |i|
@@ -413,14 +413,16 @@ class FightMenuDisplay < BattleMenuBase
def refreshMegaEvolutionButton
return if !USE_GRAPHICS
@megaButton.src_rect.y = (@mode-1)*@megaEvoBitmap.height/2
@megaButton.z = self.z - 1
@megaButton.src_rect.y = (@mode - 1) * @megaEvoBitmap.height / 2
@visibility["megaButton"] = @mode > 0
@megaButton.z = self.z - 1
end
def refreshShiftButton
return if !USE_GRAPHICS
@shiftButton.src_rect.y = (@shiftMode-1)*@shiftBitmap.height
@shiftButton.z = self.z - 1
@shiftButton.src_rect.y = (@shiftMode - 1) * @shiftBitmap.height
@visibility["shiftButton"] = @shiftMode > 0
@shiftButton.z = self.z - 1
end
def refresh
@@ -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
+1 -1
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
@@ -333,7 +333,6 @@ class Window_PokemonOption < Window_DrawableCommand
optionwidth = rect.width*9/20
pbDrawShadowText(self.contents,rect.x,rect.y,optionwidth,rect.height,optionname,
@nameBaseColor,@nameShadowColor)
self.contents.draw_text(rect.x,rect.y,optionwidth,rect.height,optionname)
return if index==@options.length
if @options[index].is_a?(EnumOption)
if @options[index].values.length>1
@@ -350,7 +349,6 @@ class Window_PokemonOption < Window_DrawableCommand
(ivalue==self[index]) ? @selBaseColor : self.baseColor,
(ivalue==self[index]) ? @selShadowColor : self.shadowColor
)
self.contents.draw_text(xpos,rect.y,optionwidth,rect.height,value)
xpos += self.contents.text_size(value).width
xpos += spacing
ivalue += 1
@@ -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
+24 -21
View File
@@ -197,7 +197,7 @@ def pbEachFileSectionEx(f)
end
lineno += 1
Graphics.update if lineno%500==0
Win32API.SetWindowText(_INTL("Processing line {1}",lineno)) if lineno%50==0
pbSetWindowText(_INTL("Processing line {1}",lineno)) if lineno%50==0
}
yield lastsection,sectionname if havesection
end
@@ -1167,18 +1167,19 @@ def pbCompileAllData(mustCompile)
yield(_INTL("Compiling shadow move data"))
pbCompileShadowMoves
yield(_INTL("Compiling messages"))
pbCompileAnimations
pbCompileTrainerEvents(mustCompile)
pbSetTextMessages
MessageTypes.saveMessages
else
if (!$INEDITOR || LANGUAGES.length<2) && safeExists?("Data/messages.dat")
MessageTypes.loadMessageFile("Data/messages.dat")
end
end
pbCompileAnimations
pbCompileTrainerEvents(mustCompile)
pbSetTextMessages
MessageTypes.saveMessages
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)
@@ -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
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+339
View File
@@ -0,0 +1,339 @@
{
// Lines starting with '//' are comments.
//
// About filesystem paths specified in this config:
// The "gameFolder" path is resolved either relative
// to the directory containing the mkxp executable
// (the default behavior), or relative to the current
// working directory (when compiled with
// -DWORKDIR_CURRENT). All other paths are resolved
// relative to gameFolder and ignoring both RTPs and
// encrypted archives.
// Specify the RGSS version to run under.
// Possible values are 0, 1, 2, 3. If set to 0,
// mkxp will try to guess the required version
// based on the game files found in gameFolder.
// If this fails, the version defaults to 1.
// (default: 0)
//
// "rgssVersion": 1,
// Request an OpenGL 4.1 context. This
// introduces these minimum requirements
// for GPUs:
//
// + NVIDIA 400 Series+
// + AMD Radeon HD 5000+
// + Intel HD Graphics 4000+
//
// If disabled, OpenGL 3.3 is used instead.
// (default: disabled)
//
// "openGL4": false,
// Create a debug context and log
// OpenGL debug information to the console
// (default: disabled)
//
// "debugMode": false,
// Continuously print average FPS to console.
// This setting does not affect the window title
// FPS display toggled via F2
// (default: disabled)
//
// "printFPS": false,
// Game window is resizable
// (default: enabled)
//
// "winResizable": true,
// Start game in fullscreen (this can
// always be toggled with Alt-Enter at runtime)
// (default: disabled)
//
// "fullscreen": false,
// Preserve game screen aspect ratio,
// as opposed to stretch-to-fill
// (default: enabled)
//
// "fixedAspectRatio": true,
// Apply linear interpolation when game screen
// is upscaled
// (default: disabled)
//
// "smoothScaling": false,
// Sync screen redraws to the monitor refresh rate
// (default: disabled)
//
// "vsync": false,
// Specify the window width on startup. If set to 0,
// it will default to the default resolution width
// specific to the RGSS version (640 in RGSS1, 544
// in RGSS2 or higher).
// (default: 0)
//
// "defScreenW": 640,
// Specify the window height on startup. If set to 0,
// it will default to the default resolution height
// specific to the RGSS version (480 in RGSS1, 416
// in RGSS2 or higher).
// (default: 0)
//
// "defScreenH": 480,
// Override the game window title
// (default: none)
//
// "windowTitle": "Custom Title",
// Enforce a static frame rate
// This option may be force-disabled at build time.
// (0 = disabled)
//
// "fixedFramerate": 0,
// Skip (don't draw) frames when behind.
// Can be changed at runtime, but this is the
// default value when the game starts.
// (default: disabled)
//
// "frameSkip": false,
// Use a fixed framerate that is approx. equal to the
// native screen refresh rate. This is different from
// "fixedFramerate" because the actual frame rate is
// reported back to the game, ensuring correct timers.
// If the screen refresh rate cannot be determined,
// this option is force-disabled.
// This option may be force-disabled at build time.
// (default: disabled)
//
// "syncToRefreshrate": false,
// Don't use alpha blending when rendering text
// (default: disabled)
//
// "solidFonts": false,
// Work around buggy graphics drivers which don't
// properly synchronize texture access, most
// apparent when text doesn't show up or the map
// tileset doesn't render at all
// (default: disabled)
//
// "subImageFix": false,
// Enable framebuffer blitting if the driver is
// capable of it. Some drivers carry buggy
// implementations of this functionality, so
// disabling it can be used as a workaround
// (default: enabled)
//
// "enableBlitting": true,
// Limit the maximum size (width, height) of
// most textures mkxp will create (exceptions are
// rendering backbuffers and similar).
// If set to 0, the hardware maximum is used.
// This is useful for recording traces that can
// be played back on machines with lower specs.
// (default: 0)
//
// "maxTextureSize": 0,
// Set the base path of the game to '/path/to/game'
// (default: executable directory)
//
// "gameFolder": "/path/to/game",
// Use either right or left Alt + Enter to toggle
// fullscreen
// (default: disabled)
//
// "anyAltToggleFS": false,
// Enable F12 game reset
// (default: enabled)
//
// "enableReset": true,
// Allow symlinks for game assets to be followed
// (default: disabled)
//
// "allowSymlinks": false,
// Organisation / company and application / game
// name to build the directory path where mkxp
// will store game specific data (eg. key bindings).
// If not specified, mkxp will save to a common
// directory shared by all games. Note that these
// are TWO individual config entries, and both need
// to be defined for this to take effect.
// (default: none)
//
// "dataPathOrg": "mycompany",
// "dataPathApp": "mygame",
// Set the game window icon to 'path/to/icon.png'
// (default: none)
//
// "iconPath": "/path/to/icon.png",
// Instead of playing an RPG Maker game,
// execute a single plain text script instead
// (default: none)
//
// "customScript": "/path/to/script.rb",
// Define raw scripts to be executed before the
// actual Scripts.rxdata execution starts
// This option may be force-disabled at build time.
// (default: none)
//
// "preloadScript": ["my_win32_wrapper.rb",
// "ruby18_fixes.rb"],
// Index all accesible assets via their lower case path
// (emulates windows case insensitivity)
// (default: enabled)
//
// "pathCache": true,
// In some versions of Essentials, overworld code
// requests the player's sprite texture from disk
// at least once every frame. The damage this
// causes is less perceptible in RPG Maker XP,
// but MKXP's RGSSAD code is much slower and will
// cause games to lag. Hard.
//
// I have no interest in fixing it, because:
//
// (A) I don't see any point in such frail encryption, and
// (B) One can easily replicate load_data entirely in Ruby
// (https://gist.github.com/inori-z/0800dbdc213b9936e0e81f64c9a98c4c)
//
// If you insist on using archives, you can use a
// version of Essentials that isn't broken,
// otherwise come up with your own solution
// (there are many), or leave your Graphics files
// loose and disable this option.
// (default: false)
//
// "compressedGraphics": false,
// Add 'rtp1', 'rtp2.zip' and 'game.rgssad' to the
// asset search path (multiple allowed)
// (default: none)
//
// "RTP": ["/path/to/rtp1",
// "/path/to/rtp2.zip",
// "/path/to/game.rgssad"],
// Use the script's name as filename in warnings and error messages
// (default: enabled)
//
// "useScriptNames": true,
// Font substitutions allow drop-in replacements of fonts
// to be used without changing the RGSS scripts,
// eg. providing 'Open Sans' when the game thinkgs it's
// using 'Arial'. Font family to be substituted and
// replacement family are separated by one sole '>'.
// Be careful not to include any spaces.
// This is not connected to the built-in font, which is
// always used when a non-existing font family is
// requested by RGSS.
// (default: none)
//
// "fontSub": ["Arial>Open Sans",
// "Times New Roman>Liberation Serif"]
// Because mkxp is usually distributed as a stand alone
// build, no predefined load paths are initialized
// ($:, $LOAD_PATH) in the MRI backend. With this option,
// they can be specified manually (eg. when using a system
// libruby.so). It is however recommended to statically
// link all required gems into libruby.so.
// (default: none)
//
// "rubyLoadpath": ["/usr/lib64/ruby/",
// "/usr/local/share/ruby/site_ruby"],
// SoundFont to use for midi playback (via fluidsynth)
// (default: none)
//
"midiSoundFont": "soundfont.sf2",
// Activate "chorus" effect for midi playback
//
// "midiChorus": false,
// Activate "reverb" effect for midi playback
//
// "midiReverb": false,
// Number of OpenAL sources to allocate for SE playback.
// If there are a lot of sounds playing at the same time
// and audibly cutting each other off, try increasing
// this number. Maximum: 64.
//
// "SESourceCount": 6
// The Windows game executable name minus ".exe". By default
// this is "Game", but some developers manually rename it.
// mkxp needs this name because both the .ini (game
// configuration) and .rgssad (encrypted data archive) must
// carry the same name minus their extension, and we cannot
// guess the executable's name.
// You could just as well rename them both to "Game.ini" and
// "Game.rgssad", but specifying the executable name here
// is a tiny bit less intrusive.
//
// "execName": "Game"
}
BIN
View File
Binary file not shown.