From f44138015be342fac97728f145cbfd8b08bd437f Mon Sep 17 00:00:00 2001 From: Mathew Velasquez Date: Sun, 28 Feb 2016 07:42:49 -0500 Subject: [PATCH] Cleaned up config; Fullscreen option now indicates Big Picture --- mkxp.conf.sample => oneshot.conf.sample | 7 +- src/config.cpp | 111 +++--------------------- src/eventthread.cpp | 14 --- 3 files changed, 16 insertions(+), 116 deletions(-) rename mkxp.conf.sample => oneshot.conf.sample (96%) diff --git a/mkxp.conf.sample b/oneshot.conf.sample similarity index 96% rename from mkxp.conf.sample rename to oneshot.conf.sample index 7b82fef..d0c0c05 100644 --- a/mkxp.conf.sample +++ b/oneshot.conf.sample @@ -10,8 +10,7 @@ # encrypted archives. -# Create a debug context and log -# OpenGL debug information to the console +# Start the game in debug/developer mode # (default: disabled) # # debugMode=false @@ -25,8 +24,8 @@ # printFPS=false -# Start game in fullscreen (this can -# always be toggled with Alt-Enter at runtime) +# Start game in fullscreen mode, +# i.e. Big Picture/console mode. # (default: disabled) # # fullscreen=false diff --git a/src/config.cpp b/src/config.cpp index 9f6a3a5..80cae9d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -29,90 +29,12 @@ #include #include +#include #include "debugwriter.h" #include "util.h" #include "sdl-util.h" -/* http://stackoverflow.com/a/1031773 */ -static bool validUtf8(const char *string) -{ - const uint8_t *bytes = (uint8_t*) string; - - while(*bytes) - { - if( (/* ASCII - * use bytes[0] <= 0x7F to allow ASCII control characters */ - bytes[0] == 0x09 || - bytes[0] == 0x0A || - bytes[0] == 0x0D || - (0x20 <= bytes[0] && bytes[0] <= 0x7E) - ) - ) { - bytes += 1; - continue; - } - - if( (/* non-overlong 2-byte */ - (0xC2 <= bytes[0] && bytes[0] <= 0xDF) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) - ) - ) { - bytes += 2; - continue; - } - - if( (/* excluding overlongs */ - bytes[0] == 0xE0 && - (0xA0 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) || - (/* straight 3-byte */ - ((0xE1 <= bytes[0] && bytes[0] <= 0xEC) || - bytes[0] == 0xEE || - bytes[0] == 0xEF) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) || - (/* excluding surrogates */ - bytes[0] == 0xED && - (0x80 <= bytes[1] && bytes[1] <= 0x9F) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) - ) { - bytes += 3; - continue; - } - - if( (/* planes 1-3 */ - bytes[0] == 0xF0 && - (0x90 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) || - (/* planes 4-15 */ - (0xF1 <= bytes[0] && bytes[0] <= 0xF3) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) || - (/* plane 16 */ - bytes[0] == 0xF4 && - (0x80 <= bytes[1] && bytes[1] <= 0x8F) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) - ) { - bytes += 4; - continue; - } - - return false; - } - - return true; -} - static std::string prefPath(const char *org, const char *app) { char *path = SDL_GetPrefPath(org, app); @@ -129,7 +51,7 @@ static std::string prefPath(const char *org, const char *app) typedef std::vector StringVec; namespace po = boost::program_options; -#define CONF_FILE "mkxp.conf" +#define CONF_FILE "oneshot.conf" Config::Config() {} @@ -143,8 +65,6 @@ void Config::read(int argc, char *argv[]) PO_DESC(fixedAspectRatio, bool, true) \ PO_DESC(smoothScaling, bool, false) \ PO_DESC(vsync, bool, false) \ - PO_DESC(defScreenW, int, 0) \ - PO_DESC(defScreenH, int, 0) \ PO_DESC(fixedFramerate, int, 0) \ PO_DESC(frameSkip, bool, true) \ PO_DESC(syncToRefreshrate, bool, false) \ @@ -215,8 +135,6 @@ void Config::read(int argc, char *argv[]) #undef PO_DESC #undef PO_DESC_ALL - rgssVersion = clamp(rgssVersion, 0, 3); - SE.sourceCount = clamp(SE.sourceCount, 1, 64); commonDataPath = prefPath(".", "Oneshot"); @@ -225,18 +143,15 @@ void Config::read(int argc, char *argv[]) rgssVersion = 1; game.title = "Oneshot"; game.scripts = "Data/xScripts.rxdata"; - if (defScreenW <= 0) - defScreenW = 640; - if (defScreenH <= 0) - defScreenH = 480; -} - -static std::string baseName(const std::string &path) -{ - size_t pos = path.find_last_of("/\\"); - - if (pos == path.npos) - return path; - - return path.substr(pos + 1); + defScreenW = 640; + defScreenH = 480; + +#ifdef STEAM + /* Override fullscreen config if Big Picture */ + if (const char *env = std::getenv("SteamTenfoot")) + { + if (!strcmp(env, "1")) + fullscreen = true; + } +#endif } diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 5e336f4..1f2d0f7 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -272,20 +272,6 @@ void EventThread::process(RGSSThreadData &rtData) break; case SDL_KEYDOWN : - if (event.key.keysym.scancode == SDL_SCANCODE_RETURN && - (event.key.keysym.mod & toggleFSMod)) - { - setFullscreen(win, !fullscreen); - if (!fullscreen && havePendingTitle) - { - SDL_SetWindowTitle(win, pendingTitle); - pendingTitle[0] = '\0'; - havePendingTitle = false; - } - - break; - } - if (event.key.keysym.scancode == SDL_SCANCODE_F1) { if (!sMenu)