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.
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.
@ -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
```
+ **Linux (Ubuntu/Debian)**
+ **Linux (Ubuntu 18.04)**
```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
@ -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)
* Movie playback
* 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.

View file

@ -62,8 +62,6 @@ extern "C" {
#include <SDL_loadso.h>
#include <SDL_power.h>
#define MACRO_STRINGIFY(x) #x
extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
@ -259,7 +257,7 @@ static void mriBindingInit() {
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_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
the OpenGL -> Metal translation implemented in Apple Silicon macs.
Currently, the build of ANGLE here is the one provided with
Google Chrome/Chromium. Soon as ANGLE's gclient doesn't fail
on Apple Silicon macs, I'll build it myself.
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.

View file

@ -458,7 +458,7 @@
3BC65DEB2584F3AD0063AFF1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BD2B47A256534BA003DAD8A /* IOKit.framework */; };
3BC65DED2584F3AD0063AFF1 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081552568D3A60006849F /* Carbon.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 */; };
3BC65DF62584F3AD0063AFF1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081532568D3A60006849F /* CoreVideo.framework */; };
3BC65DFA2584F3AD0063AFF1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; };
@ -3366,7 +3366,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
MKXPZ_BUILD_XCODE,
"MKXPZ_ALCDEVICE=ALCdevice",
"MKXPZ_VERSION=\"$(MARKETING_VERSION)\"",
"MKXPZ_VERSION=\"\\\"$(MARKETING_VERSION)\\\"\"",
MKXPZ_MINIFFI,
MKXPZ_DEBUG,
MKXPZ_SSL,
@ -3437,7 +3437,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
MKXPZ_BUILD_XCODE,
"MKXPZ_ALCDEVICE=ALCdevice",
"MKXPZ_VERSION=\"$(MARKETING_VERSION)\"",
"MKXPZ_VERSION=\"\\\"$(MARKETING_VERSION)\\\"\"",
MKXPZ_MINIFFI,
MKXPZ_SSL,
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">
</CommandLineArgument>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MKXPZ_SELECT_PATH"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Debug"

View file

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

View file

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

View file

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

View file

@ -19,6 +19,11 @@
// (default: 0)
//
// "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
// OpenGL debug information to the console

View file

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

View file

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

View file

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

View file

@ -5,12 +5,8 @@
// Created by ゾロアーク on 11/21/20.
//
#ifdef MKXPZ_DEBUG
#import <AppKit/AppKit.h>
#import <SDL_syswm.h>
#else
#import <Foundation/Foundation.h>
#endif
#import <SDL_filesystem.h>
@ -100,7 +96,6 @@ std::string filesystemImpl::getResourcePath() {
return std::string(NSTOPATH(NSBundle.mainBundle.resourcePath));
}
#ifdef MKXPZ_DEBUG
std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const char *prompt) {
NSOpenPanel *panel = [NSOpenPanel openPanel];
panel.canChooseDirectories = true;
@ -126,4 +121,3 @@ std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const c
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.
// Doesn't completely do it though, needs a small patch to SDL
#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");
#endif
#endif
@ -342,18 +344,19 @@ int main(int argc, char *argv[]) {
return 0;
}
#if defined(MKXPZ_BUILD_XCODE) && defined(MKXPZ_DEBUG)
#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."
#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."
#define DEBUG_FSELECT_PROMPT "Load Game"
std::string dataDirStr = mkxp_fs::selectPath(win, DEBUG_FSELECT_MSG, DEBUG_FSELECT_PROMPT);
if (!dataDirStr.empty()) {
conf.gameFolder = dataDirStr;
mkxp_fs::setCurrentDirectory(dataDirStr.c_str());
Debug() << "DEBUG: Current directory set to" << dataDirStr;
conf.read(argc, argv);
conf.readGameINI();
if (SDL_getenv("MKXPZ_SELECT_PATH")) {
std::string dataDirStr = mkxp_fs::selectPath(win, DEBUG_FSELECT_MSG, DEBUG_FSELECT_PROMPT);
if (!dataDirStr.empty()) {
conf.gameFolder = dataDirStr;
mkxp_fs::setCurrentDirectory(dataDirStr.c_str());
Debug() << "DEBUG: Current directory set to" << dataDirStr;
conf.read(argc, argv);
conf.readGameINI();
}
}
#endif
/* OSX and Windows have their own native ways of

View file

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

View file

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