meow
This commit is contained in:
parent
6dd367d8bf
commit
4b13fed3e1
|
|
@ -68,9 +68,6 @@ static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::s
|
||||||
#define GL_FUN(name, type) \
|
#define GL_FUN(name, type) \
|
||||||
gl.name = (type) SDL_GL_GetProcAddress("gl" #name EXT_SUFFIX);
|
gl.name = (type) SDL_GL_GetProcAddress("gl" #name EXT_SUFFIX);
|
||||||
|
|
||||||
#define EXC(msg) \
|
|
||||||
crash(Exception::MKXPError, "%s", msg)
|
|
||||||
|
|
||||||
void initGLFunctions(){
|
void initGLFunctions(){
|
||||||
#define EXT_SUFFIX ""
|
#define EXT_SUFFIX ""
|
||||||
GL_20_FUN;
|
GL_20_FUN;
|
||||||
|
|
@ -94,7 +91,7 @@ void initGLFunctions(){
|
||||||
int glMajor = *ver - '0';
|
int glMajor = *ver - '0';
|
||||||
|
|
||||||
if (glMajor < 2)
|
if (glMajor < 2)
|
||||||
throw EXC("At least OpenGL (ES) 2.0 is required");
|
crash(Exception::MKXPError, "At least OpenGL (ES) 2.0 is required");
|
||||||
|
|
||||||
if (gles){
|
if (gles){
|
||||||
GL_ES_FUN;
|
GL_ES_FUN;
|
||||||
|
|
@ -129,7 +126,7 @@ void initGLFunctions(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw EXC("No FBO support available");
|
crash(Exception::MKXPError, "No FBO support available");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VAO entrypoints */
|
/* VAO entrypoints */
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void crash(Exception::Type t, const char *fmt, ...){
|
||||||
va_copy(args_copy, args);
|
va_copy(args_copy, args);
|
||||||
short len = SDL_vsnprintf(NULL, 0, fmt, args_copy);
|
short len = SDL_vsnprintf(NULL, 0, fmt, args_copy);
|
||||||
va_end(args_copy);
|
va_end(args_copy);
|
||||||
char *buf = SDL_malloc((size_t)len + 1);
|
char *buf = (char*)SDL_malloc((size_t)len + 1);
|
||||||
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
SDL_vsnprintf(buf, (size_t)len + 1, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ void crash(Exception::Type t, const char *fmt, ...){
|
||||||
|
|
||||||
int buttonid = 0;
|
int buttonid = 0;
|
||||||
if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) {
|
if (SDL_ShowMessageBox(&messageboxdata, &buttonid) == false) {
|
||||||
printf("[CRASHDUMP] %s\n", reason);
|
printf("[CRASHDUMP] %s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buttonid == 1){
|
if(buttonid == 1){
|
||||||
|
|
@ -78,7 +78,7 @@ void crash(Exception::Type t, const char *fmt, ...){
|
||||||
out << "[SUNSHINE CRASHDUMP]" << std::endl;
|
out << "[SUNSHINE CRASHDUMP]" << std::endl;
|
||||||
try{
|
try{
|
||||||
out << boost::stacktrace::stacktrace() << std::endl;
|
out << boost::stacktrace::stacktrace() << std::endl;
|
||||||
out << "REASON: " << reason << std::endl;
|
out << "REASON: " << buf << std::endl;
|
||||||
out << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl;
|
out << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl;
|
||||||
out << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl;
|
out << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl;
|
||||||
out << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl;
|
out << "GL Version: " << glGetStringInt(GL_VERSION) << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -16,33 +16,32 @@
|
||||||
#include <SDL3/SDL_messagebox.h>
|
#include <SDL3/SDL_messagebox.h>
|
||||||
|
|
||||||
// OS-Specific code
|
// OS-Specific code
|
||||||
#if defined _WIN32
|
#if defined(_WIN32)
|
||||||
#define OS_W32
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define SECURITY_WIN32
|
||||||
#define SECURITY_WIN32
|
#include <windows.h>
|
||||||
#include <windows.h>
|
#include <mmsystem.h>
|
||||||
#include <mmsystem.h>
|
#include <security.h>
|
||||||
#include <security.h>
|
#include <shlobj.h>
|
||||||
#include <shlobj.h>
|
#elif defined(__APPLE__)
|
||||||
#elif defined __APPLE__ || __linux__ || BSD
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <unistd.h>
|
||||||
#include <unistd.h>
|
#include <pwd.h>
|
||||||
#include <pwd.h>
|
#include <dlfcn.h>
|
||||||
#include <dlfcn.h>
|
#include <dispatch/dispatch.h>
|
||||||
|
#elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
#ifdef __APPLE__
|
#include <stdlib.h>
|
||||||
#define OS_OSX
|
#include <unistd.h>
|
||||||
#include <dispatch/dispatch.h>
|
#include <pwd.h>
|
||||||
#else
|
#include <dlfcn.h>
|
||||||
#define OS_LINUX || BSD
|
#include <gtk/gtk.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <gdk/gdk.h>
|
#include "xdg-user-dir-lookup.h"
|
||||||
#include "xdg-user-dir-lookup.h"
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#error "Operating system not detected or unsupported."
|
#error "Operating system not detected or unsupported."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const Config conf;
|
const Config conf;
|
||||||
#define DEF_SCREEN_W conf.defScreenW
|
#define DEF_SCREEN_W conf.defScreenW
|
||||||
#define DEF_SCREEN_H conf.defScreenH
|
#define DEF_SCREEN_H conf.defScreenH
|
||||||
|
|
@ -87,7 +86,7 @@ struct OneshotPrivate{
|
||||||
};
|
};
|
||||||
|
|
||||||
//OS-SPECIFIC FUNCTIONS
|
//OS-SPECIFIC FUNCTIONS
|
||||||
#if defined OS_LINUX || BSD
|
#if defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
struct linux_DialogData{
|
struct linux_DialogData{
|
||||||
// Input
|
// Input
|
||||||
int type;
|
int type;
|
||||||
|
|
@ -134,7 +133,7 @@ static int linux_dialog(void *rawData){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined OS_W32
|
#elif defined _WIN32
|
||||||
/* Convert WCHAR pointer to std::string */
|
/* Convert WCHAR pointer to std::string */
|
||||||
static std::string w32_fromWide(const WCHAR *ustr){
|
static std::string w32_fromWide(const WCHAR *ustr){
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
@ -178,20 +177,20 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
p->winPosChanged = false;
|
p->winPosChanged = false;
|
||||||
p->allowExit = true;
|
p->allowExit = true;
|
||||||
p->exiting = false;
|
p->exiting = false;
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
p->os = "windows";
|
p->os = "windows";
|
||||||
#elif defined OS_OSX
|
#elif __APPLE__
|
||||||
p->os = "macos";
|
p->os = "macos";
|
||||||
#elif defined BSD
|
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(BSD)
|
||||||
p->os = "BSD";
|
p->os = "BSD";
|
||||||
#else
|
#elif __LINUX__
|
||||||
p->os = "linux";
|
p->os = "linux";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* USERNAME/DOCS PATH
|
* USERNAME/DOCS PATH
|
||||||
********************/
|
********************/
|
||||||
#if defined OS_W32
|
#if defined _WIN32
|
||||||
//Get language code
|
//Get language code
|
||||||
WCHAR wlang[9];
|
WCHAR wlang[9];
|
||||||
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR));
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR));
|
||||||
|
|
@ -242,7 +241,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
// Get user's name
|
// Get user's name
|
||||||
#ifdef OS_OSX
|
#ifdef OS_OSX
|
||||||
struct passwd *pwd = getpwuid(geteuid());
|
struct passwd *pwd = getpwuid(geteuid());
|
||||||
#elif defined OS_LINUX
|
#elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
struct passwd *pwd = getpwuid(getuid());
|
struct passwd *pwd = getpwuid(getuid());
|
||||||
#endif
|
#endif
|
||||||
if (pwd){
|
if (pwd){
|
||||||
|
|
@ -256,12 +255,12 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get documents path
|
// Get documents path
|
||||||
#ifdef OS_OSX
|
#ifdef __APPLE__
|
||||||
std::string path = std::string(getenv("HOME")) + "/Documents";
|
std::string path = std::string(getenv("HOME")) + "/Documents";
|
||||||
p->docsPath = path.c_str();
|
p->docsPath = path.c_str();
|
||||||
p->gamePath = path.c_str();
|
p->gamePath = path.c_str();
|
||||||
p->journal = "_______.app";
|
p->journal = "_______.app";
|
||||||
#elif defined OS_LINUX
|
#elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
char * path = xdg_user_dir_lookup("DOCUMENTS");
|
char * path = xdg_user_dir_lookup("DOCUMENTS");
|
||||||
p->docsPath = path;
|
p->docsPath = path;
|
||||||
p->gamePath = path;
|
p->gamePath = path;
|
||||||
|
|
@ -272,7 +271,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
Debug() << "[oneshot] Game path :" << p->gamePath;
|
Debug() << "[oneshot] Game path :" << p->gamePath;
|
||||||
Debug() << "[oneshot] Docs path :" << p->docsPath;
|
Debug() << "[oneshot] Docs path :" << p->docsPath;
|
||||||
|
|
||||||
#ifdef OS_LINUX
|
#ifdef defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
|
char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||||
gtk_init(0, 0);
|
gtk_init(0, 0);
|
||||||
|
|
||||||
|
|
@ -309,7 +308,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
/********
|
/********
|
||||||
* MISC
|
* MISC
|
||||||
********/
|
********/
|
||||||
#if defined OS_W32
|
#if defined _WIN32
|
||||||
//Get windows version
|
//Get windows version
|
||||||
OSVERSIONINFOW version;
|
OSVERSIONINFOW version;
|
||||||
ZeroMemory(&version, sizeof(version));
|
ZeroMemory(&version, sizeof(version));
|
||||||
|
|
@ -461,7 +460,7 @@ void Oneshot::setAllowExit(bool allowExit){
|
||||||
bool Oneshot::msgbox(int type, const char *body, const char *title){
|
bool Oneshot::msgbox(int type, const char *body, const char *title){
|
||||||
if (!title)
|
if (!title)
|
||||||
title = "";
|
title = "";
|
||||||
#ifdef OS_LINUX
|
#ifdef defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
linux_DialogData data = {type, body, title, 0};
|
linux_DialogData data = {type, body, title, 0};
|
||||||
gdk_threads_add_idle(linux_dialog, &data);
|
gdk_threads_add_idle(linux_dialog, &data);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
@ -482,7 +481,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
|
||||||
data.colorScheme = 0;
|
data.colorScheme = 0;
|
||||||
data.title = title;
|
data.title = title;
|
||||||
data.message = body;
|
data.message = body;
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
DWORD sound;
|
DWORD sound;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -492,19 +491,19 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
|
||||||
case MSG_YESNO:
|
case MSG_YESNO:
|
||||||
default:
|
default:
|
||||||
data.flags = SDL_MESSAGEBOX_INFORMATION;
|
data.flags = SDL_MESSAGEBOX_INFORMATION;
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
sound = SND_ALIAS_SYSTEMQUESTION;
|
sound = SND_ALIAS_SYSTEMQUESTION;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case MSG_WARN:
|
case MSG_WARN:
|
||||||
data.flags = SDL_MESSAGEBOX_WARNING;
|
data.flags = SDL_MESSAGEBOX_WARNING;
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
sound = SND_ALIAS_SYSTEMEXCLAMATION;
|
sound = SND_ALIAS_SYSTEMEXCLAMATION;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case MSG_ERR:
|
case MSG_ERR:
|
||||||
data.flags = SDL_MESSAGEBOX_WARNING;
|
data.flags = SDL_MESSAGEBOX_WARNING;
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
sound = SND_ALIAS_SYSTEMASTERISK;
|
sound = SND_ALIAS_SYSTEMASTERISK;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
@ -526,12 +525,12 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show messagebox
|
// Show messagebox
|
||||||
#ifdef OS_W32
|
#ifdef _WIN32
|
||||||
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC);
|
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC);
|
||||||
#endif
|
#endif
|
||||||
int button;
|
int button;
|
||||||
|
|
||||||
#ifdef OS_OSX
|
#ifdef __APPLE__
|
||||||
int *btn = &button;
|
int *btn = &button;
|
||||||
|
|
||||||
// Message boxes and UI changes must be performed from the main thread on macOS Mojave and above.
|
// Message boxes and UI changes must be performed from the main thread on macOS Mojave and above.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue