allow enabling/disabling certain options through env

This commit is contained in:
Struma 2022-01-23 08:21:59 -05:00
parent 27f7ee78e1
commit 56ef0ed900
6 changed files with 30 additions and 7 deletions

View file

@ -266,8 +266,9 @@ static void mriBindingInit() {
rb_define_const(mod, "CONFIG", cfg); rb_define_const(mod, "CONFIG", cfg);
// Set $stdout and its ilk accordingly on Windows // Set $stdout and its ilk accordingly on Windows
// I regret teaching you that word
#ifdef __WIN32__ #ifdef __WIN32__
if (shState->config().editor.debug) if (shState->config().winConsole)
configureWindowsStreams(); configureWindowsStreams();
#endif #endif

View file

@ -76,6 +76,7 @@ MKXPZTouchBar *_sharedTouchBar;
} }
else if ([identifier isEqualToString:@"icon"]) { else if ([identifier isEqualToString:@"icon"]) {
NSImage *appIcon = [NSWorkspace.sharedWorkspace iconForFile:NSBundle.mainBundle.bundlePath]; NSImage *appIcon = [NSWorkspace.sharedWorkspace iconForFile:NSBundle.mainBundle.bundlePath];
appIcon.size = NSSizeFromCGSize(CGSizeMake(30,30));
ret.view = [NSImageView imageViewWithImage:appIcon]; ret.view = [NSImageView imageViewWithImage:appIcon];
} }

View file

@ -23,6 +23,8 @@
#include "util/iniconfig.h" #include "util/iniconfig.h"
#include "util/encoding.h" #include "util/encoding.h"
#include "system/system.h"
namespace json = json5pp; namespace json = json5pp;
@ -251,6 +253,14 @@ try { exp } catch (...) {}
rgssVersion = clamp(rgssVersion, 0, 3); rgssVersion = clamp(rgssVersion, 0, 3);
SE.sourceCount = clamp(SE.sourceCount, 1, 64); SE.sourceCount = clamp(SE.sourceCount, 1, 64);
// Determine whether to open a console window on... Windows
const char *consoleEnv = SDL_getenv("MKXPZ_WINDOWS_CONSOLE");
winConsole = ((consoleEnv && !strcmp(consoleEnv, "1")) || editor.debug);
// Determine whether to use the Metal renderer on macOS
const char *metalEnv = SDL_getenv("MKXPZ_MACOS_METAL");
preferMetalRenderer = (!metalEnv || strcmp(metalEnv, "0")) && isMetalSupported();
} }
static void setupScreenSize(Config &conf) { static void setupScreenSize(Config &conf) {

View file

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

View file

@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <unistd.h> #include <unistd.h>
#include <regex>
#include "binding.h" #include "binding.h"
#include "sharedstate.h" #include "sharedstate.h"
@ -86,8 +87,18 @@ static inline const char *glGetStringInt(GLenum name) {
} }
static void printGLInfo() { static void printGLInfo() {
const std::string renderer(glGetStringInt(GL_RENDERER));
std::regex rgx("ANGLE \\((.+), ANGLE Metal Renderer: (.+), Version (.+)\\)");
std::smatch matches;
if (std::regex_search(renderer, matches, rgx)) {
Debug() << "Metal Device :" << matches[2] << "(" + matches[1].str() + ")";
Debug() << "ANGLE Version :" << matches[3].str();
return;
}
Debug() << "GL Vendor :" << glGetStringInt(GL_VENDOR); Debug() << "GL Vendor :" << glGetStringInt(GL_VENDOR);
Debug() << "GL Renderer :" << glGetStringInt(GL_RENDERER); Debug() << "GL Renderer :" << renderer;
Debug() << "GL Version :" << glGetStringInt(GL_VERSION); Debug() << "GL Version :" << glGetStringInt(GL_VERSION);
Debug() << "GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION); Debug() << "GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
} }
@ -230,7 +241,7 @@ int main(int argc, char *argv[]) {
#if defined(__WIN32__) #if defined(__WIN32__)
// Create a debug console in debug mode // Create a debug console in debug mode
if (conf.editor.debug) { if (conf.winConsole) {
if (setupWindowsConsole()) { if (setupWindowsConsole()) {
reopenWindowsStreams(); reopenWindowsStreams();
} else { } else {
@ -241,7 +252,6 @@ int main(int argc, char *argv[]) {
} }
} }
#endif #endif
conf.readGameINI(); conf.readGameINI();
#ifdef MKXPZ_STEAM #ifdef MKXPZ_STEAM
@ -326,7 +336,7 @@ int main(int argc, char *argv[]) {
// 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 // 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_setenv("ANGLE_DEFAULT_PLATFORM", (conf.preferMetalRenderer) ? "metal" : "opengl", true);
SDL_GL_LoadLibrary("@rpath/libEGL.dylib"); SDL_GL_LoadLibrary("@rpath/libEGL.dylib");
#endif #endif
#endif #endif

View file

@ -70,10 +70,10 @@ struct VButton
BTN_STRING(R), BTN_STRING(R),
BTN_STRING(A), BTN_STRING(A),
BTN_STRING(B), BTN_STRING(B),
BTN_STRING_CUSTOM(ZL, "C"), BTN_STRING(C),
BTN_STRING(X), BTN_STRING(X),
BTN_STRING(Y), BTN_STRING(Y),
BTN_STRING_CUSTOM(ZR, "Z"), BTN_STRING(Z)
}; };
static elementsN(vButtons); static elementsN(vButtons);