mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
Window shaking
This commit is contained in:
parent
01b4e7e2a0
commit
50d64ea060
2 changed files with 21 additions and 2 deletions
|
|
@ -3,6 +3,9 @@
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#include "binding-util.h"
|
#include "binding-util.h"
|
||||||
#include "binding-types.h"
|
#include "binding-types.h"
|
||||||
|
#include "eventthread.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
RB_METHOD(oneshotSetYesNo)
|
RB_METHOD(oneshotSetYesNo)
|
||||||
{
|
{
|
||||||
|
|
@ -48,6 +51,21 @@ RB_METHOD(oneshotAllowExit)
|
||||||
return Qnil;
|
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()
|
void oneshotBindingInit()
|
||||||
{
|
{
|
||||||
VALUE module = rb_define_module("Oneshot");
|
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, "reset_obscured", oneshotResetObscured);
|
||||||
_rb_define_module_function(module, "obscured_cleared?", oneshotObscuredCleared);
|
_rb_define_module_function(module, "obscured_cleared?", oneshotObscuredCleared);
|
||||||
_rb_define_module_function(module, "allow_exit", oneshotAllowExit);
|
_rb_define_module_function(module, "allow_exit", oneshotAllowExit);
|
||||||
|
_rb_define_module_function(module, "shake", oneshotShake);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ static void start()
|
||||||
ipc.open("oneshot-pipe", Pipe::Write);
|
ipc.open("oneshot-pipe", Pipe::Write);
|
||||||
|
|
||||||
// Create process
|
// Create process
|
||||||
#ifdef _WIN32
|
#if defined _WIN32
|
||||||
WCHAR path[MAX_PATH];
|
WCHAR path[MAX_PATH];
|
||||||
WCHAR gameFolder[MAX_PATH];
|
WCHAR gameFolder[MAX_PATH];
|
||||||
MultiByteToWideChar(CP_UTF8, 0, shState->config().gameFolder.c_str(), -1, 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);
|
CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
||||||
delete [] args;
|
delete [] args;
|
||||||
#else
|
#else
|
||||||
#ifdef linux
|
#if defined __linux
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
ssize_t len = readlink("/proc/self/exe", path, PATH_MAX);
|
ssize_t len = readlink("/proc/self/exe", path, PATH_MAX);
|
||||||
if (len == -1)
|
if (len == -1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue