Merge branch 'dev' into 'fix-windows-console'

# Conflicts:
#   src/config.cpp
This commit is contained in:
Struma 2022-01-17 04:18:57 +00:00
commit 558942d8e7
19 changed files with 76 additions and 31 deletions

View file

@ -10,7 +10,7 @@ Despite the fact that it was made with Essentials games in mind, there is nothin
It supports Windows, Linux and both Intel and Apple Silicon versions of macOS. It supports Windows, Linux and both Intel and Apple Silicon versions of macOS.
Releases are [here](https://gitlab.com/mkxp-z/mkxp-z/-/releases). Requirements for running them are Windows 8.1+, Ubuntu 18.04+ (Fedora and Manjaro releases that age or newer *should* also be fine), or macOS 10.12+. Releases are [here](https://gitlab.com/mkxp-z/mkxp-z/-/releases). Requirements for running them are Windows 8.1+, Ubuntu 18.04+ (Fedora and Manjaro releases that age or newer *should* also be fine), or macOS 10.12.2+.
I'd highly recommend [checking the gitbook](https://roza-gb.gitbook.io/mkxp-z) for more information than this readme contains. I'd highly recommend [checking the gitbook](https://roza-gb.gitbook.io/mkxp-z) for more information than this readme contains.
@ -48,7 +48,7 @@ pacman -S git ruby base-devel mingw-w64-x86_64-cmake mingw-w64-x86_64-meson ming
pacman -S git ruby base-devel mingw-w64-i686-cmake mingw-w64-i686-meson mingw-w64-i686-gcc pacman -S git ruby base-devel mingw-w64-i686-cmake mingw-w64-i686-meson mingw-w64-i686-gcc
``` ```
+ **Linux (Ubuntu/Debian)** + **Linux (Ubuntu 18.04)**
```sh ```sh
sudo apt install git build-essential cmake meson autoconf automake libtool pkg-config ruby bison zlib1g-dev xorg-dev lib32z1 libasound2-dev libpulse-dev sudo apt install git build-essential cmake meson autoconf automake libtool pkg-config ruby bison zlib1g-dev xorg-dev lib32z1 libasound2-dev libpulse-dev
@ -99,6 +99,6 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
## What doesn't work (yet) ## What doesn't work (yet)
* Movie playback * Movie playback
* wma audio files * wma audio files
* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 16384 on modern cards).^ * Creating Bitmaps with sizes greater than your hardware's texture size limit (around 16384 on modern cards).^
^ There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error. ^ There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error.

View file

@ -62,8 +62,6 @@ extern "C" {
#include <SDL_loadso.h> #include <SDL_loadso.h>
#include <SDL_power.h> #include <SDL_power.h>
#define MACRO_STRINGIFY(x) #x
extern const char module_rpg1[]; extern const char module_rpg1[];
extern const char module_rpg2[]; extern const char module_rpg2[];
extern const char module_rpg3[]; extern const char module_rpg3[];
@ -259,7 +257,7 @@ static void mriBindingInit() {
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
VALUE vers = rb_utf8_str_new_cstr(MACRO_STRINGIFY(MKXPZ_VERSION)); VALUE vers = rb_utf8_str_new_cstr(MKXPZ_VERSION);
rb_str_freeze(vers); rb_str_freeze(vers);
rb_define_const(mod, "VERSION", vers); rb_define_const(mod, "VERSION", vers);

View file

@ -3,6 +3,4 @@ Here lives Google's ANGLE, which is pretty necessary right now.
On top of Apple deprecating OpenGL, MKXP has crashing issues from On top of Apple deprecating OpenGL, MKXP has crashing issues from
the OpenGL -> Metal translation implemented in Apple Silicon macs. the OpenGL -> Metal translation implemented in Apple Silicon macs.
Currently, the build of ANGLE here is the one provided with This particular build of ANGLE is made using [this commit](https://github.com/google/angle/tree/0aae0d7ad535aedba34daea325269e419baead68), built with Metal support enabled. Both arm64 and x64 libraries were built using the `target_cpu` arg, then joined using the `lipo` tool.
Google Chrome/Chromium. Soon as ANGLE's gclient doesn't fail
on Apple Silicon macs, I'll build it myself.

View file

@ -458,7 +458,7 @@
3BC65DEB2584F3AD0063AFF1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BD2B47A256534BA003DAD8A /* IOKit.framework */; }; 3BC65DEB2584F3AD0063AFF1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BD2B47A256534BA003DAD8A /* IOKit.framework */; };
3BC65DED2584F3AD0063AFF1 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081552568D3A60006849F /* Carbon.framework */; }; 3BC65DED2584F3AD0063AFF1 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081552568D3A60006849F /* Carbon.framework */; };
3BC65DEF2584F3AD0063AFF1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081582568D3A60006849F /* AppKit.framework */; }; 3BC65DEF2584F3AD0063AFF1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081582568D3A60006849F /* AppKit.framework */; };
3BC65DF42584F3AD0063AFF1 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081542568D3A60006849F /* Metal.framework */; }; 3BC65DF42584F3AD0063AFF1 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081542568D3A60006849F /* Metal.framework */; settings = {ATTRIBUTES = (Required, ); }; };
3BC65DF52584F3AD0063AFF1 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081572568D3A60006849F /* ForceFeedback.framework */; }; 3BC65DF52584F3AD0063AFF1 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081572568D3A60006849F /* ForceFeedback.framework */; };
3BC65DF62584F3AD0063AFF1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081532568D3A60006849F /* CoreVideo.framework */; }; 3BC65DF62584F3AD0063AFF1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081532568D3A60006849F /* CoreVideo.framework */; };
3BC65DFA2584F3AD0063AFF1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; }; 3BC65DFA2584F3AD0063AFF1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; };
@ -3366,7 +3366,7 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
MKXPZ_BUILD_XCODE, MKXPZ_BUILD_XCODE,
"MKXPZ_ALCDEVICE=ALCdevice", "MKXPZ_ALCDEVICE=ALCdevice",
"MKXPZ_VERSION=\"$(MARKETING_VERSION)\"", "MKXPZ_VERSION=\"\\\"$(MARKETING_VERSION)\\\"\"",
MKXPZ_MINIFFI, MKXPZ_MINIFFI,
MKXPZ_DEBUG, MKXPZ_DEBUG,
MKXPZ_SSL, MKXPZ_SSL,
@ -3437,7 +3437,7 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
MKXPZ_BUILD_XCODE, MKXPZ_BUILD_XCODE,
"MKXPZ_ALCDEVICE=ALCdevice", "MKXPZ_ALCDEVICE=ALCdevice",
"MKXPZ_VERSION=\"$(MARKETING_VERSION)\"", "MKXPZ_VERSION=\"\\\"$(MARKETING_VERSION)\\\"\"",
MKXPZ_MINIFFI, MKXPZ_MINIFFI,
MKXPZ_SSL, MKXPZ_SSL,
AL_LIBTYPE_STATIC, AL_LIBTYPE_STATIC,

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View file

@ -56,6 +56,13 @@
isEnabled = "YES"> isEnabled = "YES">
</CommandLineArgument> </CommandLineArgument>
</CommandLineArguments> </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MKXPZ_SELECT_PATH"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Debug" buildConfiguration = "Debug"

View file

@ -56,6 +56,13 @@
isEnabled = "YES"> isEnabled = "YES">
</CommandLineArgument> </CommandLineArgument>
</CommandLineArguments> </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MKXPZ_SELECT_PATH"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Debug" buildConfiguration = "Debug"

View file

@ -50,6 +50,13 @@
ReferencedContainer = "container:mkxp-z.xcodeproj"> ReferencedContainer = "container:mkxp-z.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "MKXPZ_SELECT_PATH"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View file

@ -56,6 +56,13 @@
isEnabled = "YES"> isEnabled = "YES">
</CommandLineArgument> </CommandLineArgument>
</CommandLineArguments> </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MKXPZ_SELECT_PATH"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@ -78,7 +85,7 @@
buildConfiguration = "Debug"> buildConfiguration = "Debug">
</AnalyzeAction> </AnalyzeAction>
<ArchiveAction <ArchiveAction
buildConfiguration = "Release" buildConfiguration = "Debug"
revealArchiveInOrganizer = "YES"> revealArchiveInOrganizer = "YES">
</ArchiveAction> </ArchiveAction>
</Scheme> </Scheme>

View file

@ -20,6 +20,11 @@
// //
// "rgssVersion": 1, // "rgssVersion": 1,
// Render using Metal instead of OpenGL, if possible.
//
// Using Metal requires macOS 10.13+ and a compatible GPU.
// "preferMetalRenderer": true,
// Create a debug context and log // Create a debug context and log
// OpenGL debug information to the console // OpenGL debug information to the console
// (default: disabled) // (default: disabled)

View file

@ -88,6 +88,7 @@ Config::Config() {}
void Config::read(int argc, char *argv[]) { void Config::read(int argc, char *argv[]) {
auto optsJ = json::object({ auto optsJ = json::object({
{"rgssVersion", 0}, {"rgssVersion", 0},
{"preferMetalRenderer", true},
{"debugMode", false}, {"debugMode", false},
{"printFPS", false}, {"printFPS", false},
{"winResizable", true}, {"winResizable", true},
@ -192,6 +193,7 @@ try { exp } catch (...) {}
#define SET_STRINGOPT(var, key) GUARD(var = std::string(opts[#key].as_string());) #define SET_STRINGOPT(var, key) GUARD(var = std::string(opts[#key].as_string());)
SET_OPT(rgssVersion, integer); SET_OPT(rgssVersion, integer);
SET_OPT(preferMetalRenderer, boolean);
SET_OPT(debugMode, boolean); SET_OPT(debugMode, boolean);
SET_OPT(printFPS, boolean); SET_OPT(printFPS, boolean);
SET_OPT(fullscreen, boolean); SET_OPT(fullscreen, boolean);

View file

@ -35,6 +35,7 @@ struct Config {
int rgssVersion; int rgssVersion;
bool debugMode; bool debugMode;
bool preferMetalRenderer;
bool printFPS; bool printFPS;
bool winResizable; bool winResizable;

View file

@ -30,10 +30,8 @@ std::string contentsOfAssetAsString(const char *baseName, const char *ext);
std::string getResourcePath(); std::string getResourcePath();
#ifdef MKXPZ_DEBUG
std::string selectPath(SDL_Window *win, const char *msg, const char *prompt); std::string selectPath(SDL_Window *win, const char *msg, const char *prompt);
#endif #endif
#endif
}; };
#endif /* filesystemImpl_h */ #endif /* filesystemImpl_h */

View file

@ -5,12 +5,8 @@
// Created by ゾロアーク on 11/21/20. // Created by ゾロアーク on 11/21/20.
// //
#ifdef MKXPZ_DEBUG
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import <SDL_syswm.h> #import <SDL_syswm.h>
#else
#import <Foundation/Foundation.h>
#endif
#import <SDL_filesystem.h> #import <SDL_filesystem.h>
@ -100,7 +96,6 @@ std::string filesystemImpl::getResourcePath() {
return std::string(NSTOPATH(NSBundle.mainBundle.resourcePath)); return std::string(NSTOPATH(NSBundle.mainBundle.resourcePath));
} }
#ifdef MKXPZ_DEBUG
std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const char *prompt) { std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const char *prompt) {
NSOpenPanel *panel = [NSOpenPanel openPanel]; NSOpenPanel *panel = [NSOpenPanel openPanel];
panel.canChooseDirectories = true; panel.canChooseDirectories = true;
@ -126,4 +121,3 @@ std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const c
return std::string(); return std::string();
} }
#endif

View file

@ -325,6 +325,8 @@ int main(int argc, char *argv[]) {
// LoadLibrary properly initializes EGL, it won't work otherwise. // LoadLibrary properly initializes EGL, it won't work otherwise.
// Doesn't completely do it though, needs a small patch to SDL // Doesn't completely do it though, needs a small patch to SDL
#ifdef MKXPZ_BUILD_XCODE #ifdef MKXPZ_BUILD_XCODE
// Setting OpenGL only works when building in Release mode due to the config getting re-read later
SDL_setenv("ANGLE_DEFAULT_PLATFORM", (conf.preferMetalRenderer && isMetalSupported()) ? "metal" : "opengl", true);
SDL_GL_LoadLibrary("@rpath/libEGL.dylib"); SDL_GL_LoadLibrary("@rpath/libEGL.dylib");
#endif #endif
#endif #endif
@ -342,9 +344,10 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
#if defined(MKXPZ_BUILD_XCODE) && defined(MKXPZ_DEBUG) #if defined(MKXPZ_BUILD_XCODE)
#define DEBUG_FSELECT_MSG "Select the folder to load game files from. This is the folder containing the INI and/or configuration JSON.\nThis prompt does not appear in release builds." #define DEBUG_FSELECT_MSG "Select the folder to load game files from. This is the folder containing the INI and/or configuration JSON."
#define DEBUG_FSELECT_PROMPT "Load Game" #define DEBUG_FSELECT_PROMPT "Load Game"
if (SDL_getenv("MKXPZ_SELECT_PATH")) {
std::string dataDirStr = mkxp_fs::selectPath(win, DEBUG_FSELECT_MSG, DEBUG_FSELECT_PROMPT); std::string dataDirStr = mkxp_fs::selectPath(win, DEBUG_FSELECT_MSG, DEBUG_FSELECT_PROMPT);
if (!dataDirStr.empty()) { if (!dataDirStr.empty()) {
conf.gameFolder = dataDirStr; conf.gameFolder = dataDirStr;
@ -353,7 +356,7 @@ int main(int argc, char *argv[]) {
conf.read(argc, argv); conf.read(argc, argv);
conf.readGameINI(); conf.readGameINI();
} }
}
#endif #endif
/* OSX and Windows have their own native ways of /* OSX and Windows have their own native ways of

View file

@ -41,6 +41,7 @@ WineHostType getRealHostType();
#ifdef MKXPZ_BUILD_XCODE #ifdef MKXPZ_BUILD_XCODE
void openSettingsWindow(); void openSettingsWindow();
bool isMetalSupported();
#endif #endif
namespace mkxp_sys = systemImpl; namespace mkxp_sys = systemImpl;

View file

@ -6,6 +6,8 @@
// //
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import <Metal/Metal.h>
#import <sys/sysctl.h> #import <sys/sysctl.h>
#import "system.h" #import "system.h"
#import "SettingsMenuController.h" #import "SettingsMenuController.h"
@ -53,3 +55,10 @@ void openSettingsWindow() {
} }
[smenu raise]; [smenu raise];
} }
bool isMetalSupported() {
if (@available(macOS 10.13.0, *)) {
return MTLCreateSystemDefaultDevice() != nil;
}
return false;
}