diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b1a89..15a38e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ set(MAIN_HEADERS src/modloader.h src/sunshine.h src/lightmap.h + src/define.h ) set(MAIN_SOURCE @@ -311,7 +312,8 @@ else() add_compile_options(-march=native -mtune=native) endif() if(DEBUG) - add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -fcheck-new -gbtf) + add_compile_options(-g3 -fno-omit-frame-pointer) + #add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -fcheck-new -gbtf) else() add_compile_options(-O2 -ffast-math -fipa-pta -ftree-vectorize -fstdarg-opt -fomit-frame-pointer -frename-registers -ffunction-sections -fdata-sections -fvisibility=hidden) diff --git a/PORTING.md b/PORTING.md index 0034a08..d30bb89 100644 --- a/PORTING.md +++ b/PORTING.md @@ -1,10 +1,9 @@ -# О состоянии портов - +# Операционные системы | Платформа | Завершено | Состояние | | Platform | Done % | State | | :--- | :---: | :--- | | Windows | 100% | Играбельно | -| Linux | 90% | В работе, но уже играбельно
TODO:
 * Fix Wallpaper manager | +| Linux | 91% | В работе, но уже играбельно
TODO:
 * Fix Wallpaper manager | | *BSD | 15% | в работе | | GNU/Hurd | 1% | В работе | | Solaris/OpenSolaris | 1% | В работе | @@ -19,3 +18,48 @@ | Аврора ОС | 0% | Возможно, но пока не в работе | | ChromeOS/ChromiumOS | 0.4% | Неизвестное | | MacOS | 10% | Неизвестное, но работа ведётся | + + +# Окружения рабочего стола +| Окружение | Завершено | +| LXDE | 100% | +| XFCE | 0% | +| GNOME | 0% | +| KDE | 0% | +| LXQt | 0% | +| MATE | 0% | +| Cinnamon | 0% | +| Budgie | 0% | +| Deepin | 0% | +| COSMIC | 0% | +| Pantheon | 0% | +| Enlightenment | 0% | +| Unity | 0% | +| Sugar Desktop | 0% | +| ROX Desktop | 0% | +| Fluxbox | 0% | +| Openbox | 0% | +| Trinity | 0% | +| Blackbox | 0% | +| AwesomeWM | 0% | +| DWM | 0% | +| hyperland | 0% | +| niri | 0% | +| Fish | 0% | +| Lumina | 0% | +| IceWM | 0% | +| Window Maker | 0% | +| I3 | 0% | +| Sway | 0% | +| Wayfire | 0% | +| bspwm | 0% | +| herbstluftwm | 0% | +| xmonad | 0% | +| qtile | 0% | +| CDE | 0% | +| Fvwm95 | 0% | +| OpenWindows | 0% | +| Dt | 0% | +| 9wm | 0% | +| Twm | 0% | +| WindowLab | 0% | diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index c9005b4..2cc93aa 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -31,6 +31,7 @@ #include "audio.h" #include "boost-hash.h" #include "meow.h" +#include "sunshine.h" #include #include @@ -129,7 +130,7 @@ void fileIntBindingInit(); void journalBindingInit(); void wallpaperBindingInit(); -#ifdef __linux__ +#ifdef unix_like void wallpaperBindingTerminate(); #endif void nikoBindingInit(); @@ -591,7 +592,7 @@ static void mriBindingExecute(){ static void mriBindingTerminate(){ rb_raise(rb_eSystemExit, " "); -#ifdef __linux__ +#ifdef unix_like wallpaperBindingTerminate(); #endif } diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp index 2ba0cb9..2e2a40f 100644 --- a/binding-mri/journal-binding.cpp +++ b/binding-mri/journal-binding.cpp @@ -3,11 +3,12 @@ #include "pipe.h" #include "debugwriter.h" #include "i18n.h" +#include "define.h" //OS-Specific code #if defined _WIN32 #define OS_W32 -#elif defined __APPLE__ || __linux__ +#elif unix_like #define LINUX #ifdef __APPLE__ #define OS_OSX @@ -38,7 +39,7 @@ static volatile char message_buffer[BUFFER_SIZE]; static volatile bool active = false; static volatile int message_len = 0; -#ifdef LINUX +#ifdef unix_like static std::string PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-pipe"; static volatile int out_pipe = -1; void cleanup_pipe(){ diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index af4253b..f5c1b99 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -3,11 +3,12 @@ #include "sharedstate.h" #include "debugwriter.h" #include "eventthread.h" +#include "define.h" #if defined _WIN32 #define OS_W32 #include -#elif defined __APPLE__ || __linux__ +#elif unix_like #define LINUX #ifdef __APPLE__ #define OS_OSX @@ -42,7 +43,7 @@ static volatile char message_buffer[BUFFER_SIZE]; static volatile bool active = false; static volatile int message_len = 0; -#ifdef LINUX +#ifdef unix_like static std::string NIKO_PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-niko-pipe"; static volatile int out_pipe = -1; void niko_cleanup_pipe(){ @@ -97,7 +98,7 @@ RB_METHOD(nikoPrepare){ //SDL_VERSION(&syswindow.version); //SDL_GetWindowWMInfo(shState->rtData().window, &syswindow); -#ifdef LINUX +#ifdef unix_like char path[PATH_MAX]; std::string journal; @@ -196,7 +197,7 @@ RB_METHOD(nikoStart){ void nikoBindingInit(){ mutex = SDL_CreateMutex(); -#if defined __linux +#if unix_like mkfifo(NIKO_PIPE_PATH.c_str(), 0666); atexit(niko_cleanup_pipe); #endif diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index 4c8400d..ae01836 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -98,7 +98,7 @@ void oneshotBindingInit(){ // Constants rb_const_set(module, rb_intern("OS"), rb_str_new2(shState->oneshot().os().c_str())); - #ifdef __linux__ + #ifdef unix_like rb_const_set(module, rb_intern("DE"), rb_str_new2(shState->oneshot().desktopEnv.c_str())); #endif rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str())); diff --git a/binding-mri/screen-binding.cpp b/binding-mri/screen-binding.cpp index 2d3ddd3..a0bd630 100644 --- a/binding-mri/screen-binding.cpp +++ b/binding-mri/screen-binding.cpp @@ -27,7 +27,7 @@ static void start(){ CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); delete [] args; #else -#if defined __linux +#if defined unix_like char path[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", path, PATH_MAX); if (len == -1) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index b870ce9..b0fc54b 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -3,10 +3,8 @@ #include #include #include - #include -#include "sunshine.h" #include "etc.h" #include "sharedstate.h" #include "binding-util.h" @@ -14,6 +12,7 @@ #include "config.h" #include "oneshot.h" #include "debugwriter.h" +#include "define.h" #ifdef _WIN32 #include @@ -38,6 +37,7 @@ #include #include #include + #include static std::string desktop = "uninitialized"; // GNOME settings static GSettings *bgsetting; @@ -52,21 +52,66 @@ // KDE settings static std::map defPlugins, defPictures, defColors, defModes; static std::map defBlurs; + // LXDE settings + static std::string originalBgPath = ""; + static std::string originalBgMode = ""; // Fallback settings static std::string fallbackPath; #endif #endif -#ifdef __linux__ +#ifdef unix_like void desktopEnvironmentInit(){ printf("[desktopEnvironmentInit] desktopEnvironmentInit()\n"); if (desktop != "uninitialized") return; desktop = shState->oneshot().desktopEnv; - if (desktop != "nope") { + if (desktop == "nope") { return; } + if (desktop == "lxde"){ + const char* homeC = std::getenv("HOME"); + if (!homeC) return; + std::string home(homeC); + std::string path = home + "/.config/pcmanfm/LXDE/desktop-items-0.conf"; + + std::ifstream infile(path); + if (!infile) { + Debug() << "Can't open LXDE settings"; + return; + } + //https://ru.stackoverflow.com/questions/888292/%D0%A0%D0%B0%D0%B7%D0%B4%D0%B5%D0%BB%D0%B8%D1%82%D1%8C-%D0%BE%D0%B4%D0%BD%D1%83-%D1%81%D1%82%D1%80%D0%BE%D0%BA%D1%83-%D0%BD%D0%B0-%D0%B4%D0%B2%D0%B5 + std::string line; + unsigned int lineNumber = 0; + static bool first_found = false; + static bool second_found = false; + while (getline(infile, line)) { + lineNumber++; + if (line.find("wallpaper=") != std::string::npos) { + Debug() << "[LXDEPrepare] " << line; + auto pos = line.find("="); + if (pos != std::string::npos){ + originalBgPath = line.substr(pos+1); + first_found = true; + } + } + if (line.find("wallpaper_mode=") != std::string::npos) { + Debug() << "[LXDEPrepare] " << line; + auto pos = line.find("="); + if (pos != std::string::npos){ + originalBgMode = line.substr(pos+1); + second_found = true; + } + } + if(first_found && second_found){ + Debug() << originalBgPath; + Debug() << originalBgMode; + break; + } + } + infile.close(); + } if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate" || desktop == "deepin") { if (desktop == "cinnamon" || desktop == "gnome" || desktop == "deepin") { if (desktop == "cinnamon") bgsetting = g_settings_new("org.cinnamon.desktop.background"); @@ -356,8 +401,15 @@ end: int result = system(command.str().c_str()); #ifdef DEBUG Debug() << "[wallpaperSet] Wallpaper command:" << command.str(); - Debug() << "[wallpaperSet ] Result:" << result; + Debug() << "[wallpaperSet] Result:" << result; #endif + } else if (desktop == "lxde") { + std::string concatPath = gameDirStr + path; + std::string cmd = "pcmanfm -w \"" + concatPath + "\"" + " --wallpaper-mode=center"; + int status = std::system(cmd.c_str()); + if (status != 0) { + std::printf("bliat ono slomalos\n"); + } } else { std::ifstream srcHint(gameDirStr + path); std::ofstream dstHint(fallbackPath); @@ -484,6 +536,17 @@ RB_METHOD(wallpaperReset){ Debug() << "[wallpaperReset] Reset wallpaper command:" << command.str(); Debug() << "[wallpaperReset] Reset result:" << result; #endif + } else if(desktop == "lxde"){ + if (originalBgPath != "" && originalBgMode != ""){ + std::string cmd = "pcmanfm -w \"" + originalBgPath + "\"" + " --wallpaper-mode=" + originalBgMode; + Debug() << cmd; + int status = std::system(cmd.c_str()); + if (status != 0) { + std::printf("bliat ono slomalos\n"); + } + }else{ + Debug() << "BRUH"; + } } else { if (remove(fallbackPath.c_str()) != 0) { #ifdef DEBUG @@ -505,7 +568,7 @@ void wallpaperBindingInit(){ _rb_define_module_function(module, "reset", wallpaperReset); } -#ifdef __linux__ +#ifdef unix_like void wallpaperBindingTerminate(){ // Clean up. if (desktop == "xfce") { diff --git a/changelogs/0.1.1.txt b/changelogs/0.1.1.txt index 6e96aba..2e8a339 100644 --- a/changelogs/0.1.1.txt +++ b/changelogs/0.1.1.txt @@ -50,3 +50,5 @@ Mirrors! Nice eror formating in Events script command Optimizations for steamshim crash() function update +*NIX support patches +Start house reworked diff --git a/scripts/Main.rb b/scripts/Main.rb index c10ac3e..f313be8 100644 --- a/scripts/Main.rb +++ b/scripts/Main.rb @@ -4,11 +4,10 @@ # After defining each class, actual processing begins here. #============================================================================== -at_exit do - RPG::Mod.exec_hooks("hooks/Main/at_exit", binding) - Wallpaper.reset - save unless $game_switches[99] || ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map)) -end +#at_exit do +# Wallpaper.reset +# save unless $game_switches[99] || ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map)) +#end begin RPG::Mod.exec_hooks("hooks/Main/start", binding) @@ -41,10 +40,9 @@ begin end Oneshot.allow_exit true + Wallpaper.reset + save unless $game_switches[99] || ($game_system.map_interpreter.running? || !$scene.is_a?(Scene_Map)) rescue Errno::ENOENT - if $debug - tp.disable - end # Supplement Errno::ENOENT exception # If unable to open file, display message and end filename = $!.message.sub("No such file or directory - ", "") diff --git a/src/define.h b/src/define.h new file mode 100644 index 0000000..cc02cd8 --- /dev/null +++ b/src/define.h @@ -0,0 +1,5 @@ +#if defined(__linux__) || defined(__sun) || defined(__APPLE__) || \ + defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__GNU__) || defined(__hurd__) || defined(__DragonFly__) + #define unix_like 1 +#endif diff --git a/src/graphics.cpp b/src/graphics.cpp index 304c9e0..23ae2ca 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -38,7 +38,7 @@ #include "binding.h" #include "debugwriter.h" #include "oneshot.h" - +#include "define.h" #include #include #include @@ -730,7 +730,7 @@ void Graphics::transition(unsigned int duration, const char *filename, int vague simpleShader.setProg(prog); } - #if !defined(__linux__) && !defined(BSD) && !defined(__unix__) + #if !unix_like if (p->threadData->exiting) SDL_SetWindowOpacity(p->threadData->window, 1.0f - prog); #endif diff --git a/src/main.cpp b/src/main.cpp index 41dff73..980c6d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,6 +53,7 @@ #include "modloader.h" #include "sunshine.h" +#include "define.h" #include "meow.h" #include "binding.h" @@ -224,7 +225,7 @@ int main(int argc, char *argv[]){ SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "Oneshot: sunshine"); SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE, "Game"); //X11 work on *BSD,Solaris too! - #if defined(__linux__) || defined(BSD) || defined(__sun) + #if unix_like SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); #if SDL_VERSION_ATLEAST(3, 4, 10) SDL_SetHint(SDL_HINT_VIDEO_X11_ENABLE_XSYNC_EXT, "1"); @@ -333,7 +334,7 @@ int main(int argc, char *argv[]){ /* OSX and Windows have their own native ways of * dealing with icons; don't interfere with them */ -#ifdef defined(__linux__) || defined(BSD) +#ifdef unix_like setupWindowIcon(conf, win); #elif __EMSCRIPTEN__ Debug() << "meow"; diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 4dec183..35f93f5 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -9,6 +9,7 @@ #include "bitmap.h" #include "font.h" #include "config.h" +#include "define.h" #include #include @@ -29,7 +30,7 @@ #include #include #include -#elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#elif unix_like #include #include #include @@ -86,7 +87,7 @@ struct OneshotPrivate{ }; //OS-SPECIFIC FUNCTIONS -#if defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if unix_like struct linux_DialogData{ // Input int type; @@ -182,9 +183,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : p->os = "windows"; #elif __APPLE__ p->os = "macos"; - #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(BSD) - p->os = "BSD"; - #elif __LINUX__ + #elif unix_like p->os = "linux"; #endif @@ -242,7 +241,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : // Get user's name #ifdef OS_OSX struct passwd *pwd = getpwuid(geteuid()); - #elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + #elif unix_like struct passwd *pwd = getpwuid(getuid()); #endif if (pwd){ @@ -261,7 +260,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : p->docsPath = path.c_str(); p->gamePath = path.c_str(); p->journal = "_______.app"; - #elif defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + #elif unix_like char * path = xdg_user_dir_lookup("DOCUMENTS"); p->docsPath = path; p->gamePath = path; @@ -272,7 +271,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : Debug() << "[oneshot] Game path :" << p->gamePath; Debug() << "[oneshot] Docs path :" << p->docsPath; -#ifdef defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#ifdef unix_like char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); gtk_init(0, 0); @@ -464,7 +463,7 @@ void Oneshot::setAllowExit(bool allowExit){ bool Oneshot::msgbox(int type, const char *body, const char *title){ if (!title) title = ""; -#ifdef defined(__linux__) || defined(__unix__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#ifdef unix_like linux_DialogData data = {type, body, title, 0}; gdk_threads_add_idle(linux_dialog, &data); gtk_main(); diff --git a/src/oneshot.h b/src/oneshot.h index 2159fed..6694409 100644 --- a/src/oneshot.h +++ b/src/oneshot.h @@ -7,7 +7,7 @@ #include "etc-internal.h" #include - +#include "define.h" struct OneshotPrivate; struct RGSSThreadData; @@ -71,7 +71,7 @@ public: //Dirty flag for obscured texture bool obscuredDirty; -#ifdef __linux__ +#ifdef unix_like std::string desktopEnv; #endif diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index e84f350..baa0a40 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -27,7 +27,6 @@ #include "input.h" #include "audio.h" #include "oneshot.h" -#include "sunshine.h" #ifdef STEAM #include "steam.h" #endif @@ -41,6 +40,7 @@ #include "quad.h" #include "binding.h" #include "exception.h" +#include "sunshine.h" #ifndef _MSC_VER #include diff --git a/src/sunshine.h b/src/sunshine.h index cb091a3..dd05e30 100644 --- a/src/sunshine.h +++ b/src/sunshine.h @@ -4,13 +4,6 @@ //помойка ебаная inline boost::chrono::high_resolution_clock::time_point startTime; -#if defined(__linux__) || defined(BSD) || defined(__sun) || defined(__APPLE__) || \ - defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__GNU__) || defined(__hurd__) || defined(__DragonFly__) - #define unix_like 1 -#endif - - class Sunshine{ public: Sunshine();