mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-23 23:33:45 +02:00
Separate tileset script from main executable
This commit is contained in:
parent
92f57101ec
commit
ced6daede7
5 changed files with 16 additions and 130 deletions
|
@ -67,14 +67,6 @@ extern const char module_rpg1[];
|
|||
extern const char module_rpg2[];
|
||||
extern const char module_rpg3[];
|
||||
|
||||
// Scripts to run at some point during Ruby execution
|
||||
|
||||
#ifdef MKXPZ_ESSENTIALS_DEBUG
|
||||
#ifndef MKXPZ_BUILD_XCODE
|
||||
#include "EssentialsCompatibility.rb.xxd"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void mriBindingExecute();
|
||||
static void mriBindingTerminate();
|
||||
static void mriBindingReset();
|
||||
|
@ -698,33 +690,6 @@ static void runRMXPScripts(BacktraceData &btData) {
|
|||
fname = newStringUTF8(buf, len);
|
||||
btData.scriptNames.insert(buf, scriptName);
|
||||
|
||||
#ifdef MKXPZ_ESSENTIALS_DEBUG
|
||||
// There is 0 reason for anything other than Essentials to have this class
|
||||
if (minimonsters == 0 && rb_const_defined(rb_cObject, rb_intern("PokemonMapMetadata")))
|
||||
minimonsters = 1;
|
||||
#endif
|
||||
|
||||
// Before checking to see if the next script should be skipped,
|
||||
// make sure to check whether it's the last one or not and run
|
||||
// any extra stuff before the end (primarily stupid Essentials fixes)
|
||||
// Will be placed within a build option later if I decide to add more
|
||||
#ifndef MKXPZ_BUILD_XCODE
|
||||
#define SCRIPT(name) rb_str_new((const char*)&___scripts_##name##_rb, ___scripts_##name##_rb_len), #name " (Internal)"
|
||||
#define EVALFILE(name) if (!evalScript(SCRIPT(name))) break;
|
||||
#else
|
||||
#define EVALFILE(name) { \
|
||||
std::string s = mkxp_fs::contentsOfAssetAsString("BindingScripts/" #name, "rb"); \
|
||||
if (!evalScript(rb_str_new_cstr(s.c_str()), #name)) break; \
|
||||
}
|
||||
#endif
|
||||
if (i + 2 == scriptCount){
|
||||
#ifdef MKXPZ_ESSENTIALS_DEBUG
|
||||
if (minimonsters > 0 && !RTEST(rb_gv_get("Z_NOPOKEFIX"))){
|
||||
EVALFILE(EssentialsCompatibility);
|
||||
minimonsters = -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// if the script name starts with |s|, only execute
|
||||
// it if "s" is the same first letter as the platform
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
3B10ECE92568E83D00372D13 /* trans.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B10ECA22568E7B600372D13 /* trans.frag */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
3B10ECEA2568E83D00372D13 /* transSimple.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B10EC922568E7B500372D13 /* transSimple.frag */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
3B10ECF52568E86B00372D13 /* liberation.ttf in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B10EC842568E78400372D13 /* liberation.ttf */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
3B10ECF62568E86B00372D13 /* wqymicrohei.ttf in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B10EC852568E78400372D13 /* wqymicrohei.ttf */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
3B10ECFB2568E88900372D13 /* EssentialsCompatibility.rb in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B10ECA62568E7CB00372D13 /* EssentialsCompatibility.rb */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
3B10EDA62568E95E00372D13 /* eventthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10ED352568E95D00372D13 /* eventthread.cpp */; };
|
||||
3B10EDA72568E95E00372D13 /* rgssad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10ED382568E95D00372D13 /* rgssad.cpp */; };
|
||||
3B10EDA82568E95E00372D13 /* input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10ED462568E95D00372D13 /* input.cpp */; };
|
||||
|
@ -725,17 +723,6 @@
|
|||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
3B10ECF52568E86B00372D13 /* liberation.ttf in CopyFiles */,
|
||||
3B10ECF62568E86B00372D13 /* wqymicrohei.ttf in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
3BA08EE12566499400449CFF /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = BindingScripts;
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
3B10ECFB2568E88900372D13 /* EssentialsCompatibility.rb in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -790,7 +777,6 @@
|
|||
3B10ECA32568E7B600372D13 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.h; path = ../shader/common.h; sourceTree = "<group>"; };
|
||||
3B10ECA42568E7B600372D13 /* gray.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = gray.frag; path = ../shader/gray.frag; sourceTree = "<group>"; };
|
||||
3B10ECA52568E7B600372D13 /* simpleColor.vert */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = simpleColor.vert; path = ../shader/simpleColor.vert; sourceTree = "<group>"; };
|
||||
3B10ECA62568E7CB00372D13 /* EssentialsCompatibility.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; name = EssentialsCompatibility.rb; path = ../scripts/EssentialsCompatibility.rb; sourceTree = "<group>"; };
|
||||
3B10ED352568E95D00372D13 /* eventthread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = eventthread.cpp; sourceTree = "<group>"; };
|
||||
3B10ED372568E95D00372D13 /* rgssad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rgssad.h; sourceTree = "<group>"; };
|
||||
3B10ED382568E95D00372D13 /* rgssad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rgssad.cpp; sourceTree = "<group>"; };
|
||||
|
@ -1289,14 +1275,6 @@
|
|||
name = Shaders;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3B10EC8C2568E7A400372D13 /* BindingScripts */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B10ECA62568E7CB00372D13 /* EssentialsCompatibility.rb */,
|
||||
);
|
||||
name = BindingScripts;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3B10ED342568E95D00372D13 /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -1742,7 +1720,6 @@
|
|||
3BDB23E12564545F00C4A63D /* Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B10EC8C2568E7A400372D13 /* BindingScripts */,
|
||||
3B10EC8B2568E79800372D13 /* Shaders */,
|
||||
3B10EC832568E78400372D13 /* icon.png */,
|
||||
3B10EC842568E78400372D13 /* liberation.ttf */,
|
||||
|
@ -1852,7 +1829,6 @@
|
|||
3BA08EA2256641ED00449CFF /* Resources */,
|
||||
3BA08EAC2566426200449CFF /* CopyFiles */,
|
||||
3BA08EC8256642C900449CFF /* CopyFiles */,
|
||||
3BA08EE12566499400449CFF /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
|
@ -126,7 +126,6 @@ subdir('src')
|
|||
subdir('binding')
|
||||
subdir('shader')
|
||||
subdir('assets')
|
||||
subdir('scripts')
|
||||
|
||||
global_include_dirs += include_directories('src', 'binding')
|
||||
|
||||
|
|
|
@ -17,23 +17,18 @@
|
|||
# 16384 -> 1048576 (what most people have at this point)
|
||||
#
|
||||
# Because of the extra math the game will have to do to find the right
|
||||
# pixels, this will probably cause a performance hit while on these
|
||||
# pixels, this will probably cause a slight performance hit while on these
|
||||
# maps which would normally be megasurfaces.
|
||||
#
|
||||
# It can probably be improved by changing CustomTilemap.getRegularTile
|
||||
# to just find the correct pixels on its own, without having to
|
||||
# translate the coordinates afterwards, but this will satisfy me just
|
||||
# for the moment.
|
||||
# This script was written for games based on 17.1. It may or may not work
|
||||
# with 18, and I assume it'll become part of Essentials itself at some
|
||||
# point. Just place it anywhere after CustomTilemap gets defined and it
|
||||
# should work fine.
|
||||
#
|
||||
# Really, it'd be far better to cut up the image on the C++ end and
|
||||
# use a custom shader to get the image right or something like that,
|
||||
# but that's work for another day.
|
||||
#
|
||||
# For now, I'm just happy I can finally test whatever game I like.
|
||||
# ~Zoro
|
||||
# ~Roza/Zoroark
|
||||
#=======================================================================
|
||||
|
||||
module VWrap
|
||||
module TileWrap
|
||||
|
||||
MAX_TEX_SIZE = Bitmap.max_size
|
||||
TILESET_WIDTH = 0x100
|
||||
|
@ -45,7 +40,7 @@ module VWrap
|
|||
return val
|
||||
end
|
||||
|
||||
def self.makeVWrappedTileset(originalbmp)
|
||||
def self.wrapTileset(originalbmp)
|
||||
width = originalbmp.width
|
||||
height = originalbmp.height
|
||||
if width == TILESET_WIDTH && originalbmp.mega?
|
||||
|
@ -67,7 +62,7 @@ module VWrap
|
|||
return originalbmp
|
||||
end
|
||||
|
||||
def self.blitVWrappedPixels(destX, destY, dest, src, srcrect)
|
||||
def self.blitWrappedPixels(destX, destY, dest, src, srcrect)
|
||||
if (srcrect.y + srcrect.width < MAX_TEX_SIZE)
|
||||
# Save the processing power
|
||||
return dest.blt(destX, destY, src, srcrect)
|
||||
|
@ -97,7 +92,7 @@ if $MKXP == true
|
|||
class CustomTilemap
|
||||
def tileset=(value)
|
||||
if value.mega?
|
||||
@tileset = VWrap::makeVWrappedTileset(value)
|
||||
@tileset = TileWrap::wrapTileset(value)
|
||||
value.dispose
|
||||
else
|
||||
@tileset = value
|
||||
|
@ -107,14 +102,14 @@ if $MKXP == true
|
|||
|
||||
alias old_getRegularTile getRegularTile
|
||||
def getRegularTile(sprite, id)
|
||||
return old_getRegularTile(sprite, id) if @tileset.width <= VWrap::TILESET_WIDTH
|
||||
return old_getRegularTile(sprite, id) if @tileset.width <= TileWrap::TILESET_WIDTH
|
||||
|
||||
bitmap = @regularTileInfo[id]
|
||||
if !bitmap
|
||||
bitmap = Bitmap.new(@tileWidth, @tileHeight)
|
||||
rect=Rect.new(((id - 384)&7)*@tileSrcWidth,((id - 384)>>3)*@tileSrcHeight,
|
||||
@tileSrcWidth,@tileSrcHeight)
|
||||
VWrap::blitVWrappedPixels(0,0, bitmap, @tileset, rect)
|
||||
TileWrap::blitWrappedPixels(0,0, bitmap, @tileset, rect)
|
||||
|
||||
@regularTileInfo[id]=bitmap
|
||||
end
|
||||
|
@ -123,7 +118,7 @@ if $MKXP == true
|
|||
|
||||
alias old_rlayer0 refreshLayer0
|
||||
def refreshLayer0(autotiles=false)
|
||||
return old_rlayer0(autotiles) if @tileset.width <= VWrap::TILESET_WIDTH
|
||||
return old_rlayer0(autotiles) if @tileset.width <= TileWrap::TILESET_WIDTH
|
||||
if autotiles
|
||||
return true if !shown?
|
||||
end
|
||||
|
@ -205,7 +200,7 @@ if $MKXP == true
|
|||
@tileSrcWidth,@tileSrcHeight)
|
||||
xpos=(x*twidth)-@oxLayer0
|
||||
ypos=(y*theight)-@oyLayer0
|
||||
VWrap::blitVWrappedPixels(xpos,ypos, bitmap, @tileset, temprect)
|
||||
TileWrap::blitWrappedPixels(xpos,ypos, bitmap, @tileset, temprect)
|
||||
else
|
||||
tilebitmap=@autotileInfo[id]
|
||||
if !tilebitmap
|
||||
|
@ -254,7 +249,7 @@ if $MKXP == true
|
|||
if id>=384
|
||||
temprect.set(((id - 384)&7)*@tileSrcWidth,((id - 384)>>3)*@tileSrcHeight,
|
||||
@tileSrcWidth,@tileSrcHeight)
|
||||
VWrap::blitVWrappedPixels(xpos,ypos, bitmap, @tileset, temprect)
|
||||
TileWrap::blitWrappedPixels(xpos,ypos, bitmap, @tileset, temprect)
|
||||
else
|
||||
tilebitmap=@autotileInfo[id]
|
||||
if !tilebitmap
|
||||
|
@ -311,7 +306,7 @@ if $MKXP == true
|
|||
if id>=384
|
||||
tmprect.set( ((id - 384)&7)*@tileSrcWidth,((id - 384)>>3)*@tileSrcHeight,
|
||||
@tileSrcWidth,@tileSrcHeight)
|
||||
VWrap::blitVWrappedPixels(xpos,ypos, bitmap, @tileset, tmprect)
|
||||
TileWrap::blitWrappedPixels(xpos,ypos, bitmap, @tileset, tmprect)
|
||||
else
|
||||
frames=@framecount[id/48-1]
|
||||
if frames<=1
|
||||
|
@ -330,32 +325,3 @@ if $MKXP == true
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# =================================================================
|
||||
# Any extra overrides to fix a bunch of break-y things.
|
||||
# This should allow someone to load up games on Windows just fine.
|
||||
# Maybe not perfect compatibility, but better.
|
||||
# =================================================================
|
||||
|
||||
module Graphics
|
||||
def self.snap_to_bitmap
|
||||
return Graphics.mkxp_snap_to_bitmap
|
||||
end
|
||||
end
|
||||
|
||||
def pbScreenCapture
|
||||
capturefile = nil
|
||||
500.times{|i|
|
||||
filename = RTP.getSaveFileName(sprintf("capture%03d.bmp",i))
|
||||
if !safeExists?(filename)
|
||||
capturefile = filename
|
||||
break
|
||||
end
|
||||
}
|
||||
begin
|
||||
Graphics.screenshot(capturefile)
|
||||
pbSEPlay("expfull") if FileTest.audio_exist?("Audio/SE/expfull")
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
embedded_scripts = [
|
||||
'EssentialsCompatibility.rb'
|
||||
]
|
||||
|
||||
embedded_scripts_f = files(embedded_scripts)
|
||||
|
||||
count = 0
|
||||
foreach file : embedded_scripts_f
|
||||
global_sources += custom_target(embedded_scripts[count],
|
||||
input: file,
|
||||
output: '@0@.xxd'.format(embedded_scripts[count]),
|
||||
command: [
|
||||
xxd, '-i', '@INPUT@'
|
||||
],
|
||||
capture: true,
|
||||
depend_files: embedded_scripts_f[count]
|
||||
)
|
||||
count += 1
|
||||
endforeach
|
Loading…
Add table
Reference in a new issue