diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index 5b02a78..447730d 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -3,6 +3,9 @@ #include "sharedstate.h" #include "binding-util.h" #include "binding-types.h" +#include "eventthread.h" + +#include RB_METHOD(oneshotSetYesNo) { @@ -48,6 +51,21 @@ RB_METHOD(oneshotAllowExit) return Qnil; } +RB_METHOD(oneshotShake) +{ + RB_UNUSED_PARAM; + int absx, absy; + SDL_GetWindowPosition(shState->rtData().window, &absx, &absy); + srand(time(NULL)); + for (int i = 0; i < 60; ++i) { + int max = 60 - i; + int x = rand() % (max * 2) - max; + int y = rand() % (max * 2) - max; + SDL_SetWindowPosition(shState->rtData().window, absx + x, absy + y); + } + return Qnil; +} + void oneshotBindingInit() { VALUE module = rb_define_module("Oneshot"); @@ -69,4 +87,5 @@ void oneshotBindingInit() _rb_define_module_function(module, "reset_obscured", oneshotResetObscured); _rb_define_module_function(module, "obscured_cleared?", oneshotObscuredCleared); _rb_define_module_function(module, "allow_exit", oneshotAllowExit); + _rb_define_module_function(module, "shake", oneshotShake); } diff --git a/binding-mri/screen-binding.cpp b/binding-mri/screen-binding.cpp index d08b502..9b42e95 100644 --- a/binding-mri/screen-binding.cpp +++ b/binding-mri/screen-binding.cpp @@ -13,7 +13,7 @@ static void start() ipc.open("oneshot-pipe", Pipe::Write); // Create process -#ifdef _WIN32 +#if defined _WIN32 WCHAR path[MAX_PATH]; WCHAR gameFolder[MAX_PATH]; MultiByteToWideChar(CP_UTF8, 0, shState->config().gameFolder.c_str(), -1, gameFolder, MAX_PATH); @@ -28,7 +28,7 @@ static void start() CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); delete [] args; #else -#ifdef linux +#if defined __linux char path[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", path, PATH_MAX); if (len == -1)