diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index c937a67..f52af92 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -94,6 +94,17 @@ RB_METHOD(graphicsFrameReset){ shState->graphics().set##PropName(value); \ return rb_bool_new(value); \ } + + +RB_METHOD(graphicsPosX){ + RB_UNUSED_PARAM; + return INT2FIX(shState->graphics().x()); +} + +RB_METHOD(graphicsPosY){ + RB_UNUSED_PARAM; + return INT2FIX(shState->graphics().y()); +} RB_METHOD(graphicsWidth){ RB_UNUSED_PARAM; @@ -163,6 +174,17 @@ RB_METHOD(graphicsResizeScreen){ return Qnil; } +RB_METHOD(graphicsMoveScreen){ + RB_UNUSED_PARAM; + + int x, y; + rb_get_args(argc, argv, "ii", &x, &y RB_ARG_END); + + shState->graphics().moveScreen(x, y); + + return Qnil; +} + RB_METHOD(graphicsReset){ RB_UNUSED_PARAM; @@ -199,6 +221,8 @@ void graphicsBindingInit(){ INIT_GRA_PROP_BIND( FrameRate, "frame_rate" ); INIT_GRA_PROP_BIND( FrameCount, "frame_count" ); + _rb_define_module_function(module, "x", graphicsPosX); + _rb_define_module_function(module, "y", graphicsPosY); _rb_define_module_function(module, "width", graphicsWidth); _rb_define_module_function(module, "height", graphicsHeight); _rb_define_module_function(module, "wait", graphicsWait); @@ -206,6 +230,7 @@ void graphicsBindingInit(){ _rb_define_module_function(module, "fadein", graphicsFadein); _rb_define_module_function(module, "snap_to_bitmap", graphicsSnapToBitmap); _rb_define_module_function(module, "resize_screen", graphicsResizeScreen); + _rb_define_module_function(module, "move_screen", graphicsMoveScreen); INIT_GRA_PROP_BIND( Brightness, "brightness" ); INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); diff --git a/changelogs/0.1.1.txt b/changelogs/0.1.1.txt index 6cb19cd..3b07878 100644 --- a/changelogs/0.1.1.txt +++ b/changelogs/0.1.1.txt @@ -61,4 +61,5 @@ Added 16:10 support SecurityManager can detect Flatpak and Snap now Added 3:2 support Modloader settings -supported gamepads can now change LED color based on map \ No newline at end of file +supported gamepads can now change LED color based on map +sigc is wrapped in signal.h, added the ability to move window from ruby \ No newline at end of file diff --git a/src/bitmap.h b/src/bitmap.h index de8e4f1..02f2dff 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -27,8 +27,7 @@ #include "etc.h" #include "debugwriter.h" -// #include -#include +#include "signals/signal.h" class Font; class ShaderBase; @@ -109,7 +108,7 @@ public: /* Adds 'rect' to tainted area */ void taintArea(const IntRect &rect); - sigc::signal modified; + Signal modified; private: void releaseResources(); diff --git a/src/disposable.h b/src/disposable.h index 835ec1f..3874095 100644 --- a/src/disposable.h +++ b/src/disposable.h @@ -27,14 +27,10 @@ #include "sharedstate.h" #include "graphics.h" #include "meow.h" +#include "signals/signal.h" #include -#include -// #include -#include -// #include - class Disposable{ public: Disposable() @@ -61,7 +57,7 @@ public: return disposed; } - sigc::signal wasDisposed; + Signal wasDisposed; protected: void guardDisposed() const{ diff --git a/src/etc.h b/src/etc.h index e314a40..4efaffc 100644 --- a/src/etc.h +++ b/src/etc.h @@ -22,7 +22,7 @@ #ifndef ETC_H #define ETC_H -#include +#include "signals/signal.h" #include "serializable.h" #include "etc-internal.h" @@ -139,7 +139,7 @@ struct Tone : public Serializable{ /* Normalized (-1.0 ~ 1.0) */ Vec4 norm; - sigc::signal valueChanged; + Signal valueChanged; }; struct Rect : public Serializable{ @@ -190,7 +190,7 @@ struct Rect : public Serializable{ int width; int height; - sigc::signal valueChanged; + Signal valueChanged; }; diff --git a/src/eventthread.cpp b/src/eventthread.cpp index f99e2ba..dd8cd90 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -83,6 +83,7 @@ EventThread::TouchState EventThread::touchState; enum{ REQUEST_SETFULLSCREEN = 0, REQUEST_WINRESIZE, + REQUEST_WINMOVETO, REQUEST_MESSAGEBOX, REQUEST_SETCURSORVISIBLE, @@ -176,10 +177,11 @@ void EventThread::process(RGSSThreadData &rtData){ std::map::iterator gcit; SDL_GetWindowSize(win, &winW, &winH); // SDL_GL_GetDrawableSize(win, &winW, &winH); + SDL_GetWindowPosition(win, &rtData.ethread->winX, &rtData.ethread->winY); while (true) { if (!SDL_WaitEvent(&event)) { - Debug() << "[EventThread::process] EventThread: Event error"; + Debug() << "[EventThread::process] Event error:\n" << SDL_GetError(); break; } @@ -250,8 +252,11 @@ void EventThread::process(RGSSThreadData &rtData){ break; #ifdef __APPLE__ case SDL_EVENT_WINDOW_MOVED: - if (shState != NULL && event.window.data1 && event.window.data2) - shState->oneshot().setWindowPos(event.window.data1, event.window.data2); + if (shState != NULL && event.window.data1 && event.window.data2){ + rtData.ethread->winX = event.window.data1; + rtData.ethread->winY = event.window.data2; + shState->windowSignals.moved.Emit(event.window.data1, event.window.data2); + } break; #endif } @@ -412,7 +417,11 @@ void EventThread::process(RGSSThreadData &rtData){ case REQUEST_WINRESIZE : SDL_SetWindowSize(win, event.window.data1, event.window.data2); break; - + case REQUEST_WINMOVETO : + rtData.ethread->winX = event.window.data1; + rtData.ethread->winY = event.window.data2; + SDL_SetWindowPosition(win, event.window.data1, event.window.data2); + break; case REQUEST_MESSAGEBOX : SDL_ShowSimpleMessageBox(event.user.code, rtData.config.windowTitle.c_str(), (const char*) event.user.data1, win); SDL_free(event.user.data1); @@ -506,7 +515,9 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){ default: if (event->window.type == SDL_EVENT_WINDOW_MOVED){ if (shState != NULL){ - shState->oneshot().setWindowPos(event->window.data1, event->window.data2); + rtData.ethread->winX = event->window.data1; + rtData.ethread->winY = event->window.data2; + shState->windowSignals.moved.Emit(event->window.data1, event->window.data2); shState->graphics().update(false); } return 0; @@ -564,6 +575,14 @@ void EventThread::requestFullscreenMode(bool mode){ SDL_PushEvent(&event); } +void EventThread::requestWindowMove(int x, int y){ + SDL_Event event; + event.type = usrIdStart + REQUEST_WINMOVETO; + event.window.data1 = x; + event.window.data2 = y; + SDL_PushEvent(&event); +} + void EventThread::requestWindowResize(int width, int height){ SDL_Event event; event.type = usrIdStart + REQUEST_WINRESIZE; @@ -594,6 +613,10 @@ void EventThread::showMessageBox(const char *body, int flags){ resetInputStates(); } +Vec2i EventThread::getWindowPosition() const{ + return Vec2i(winX, winY); +} + bool EventThread::getFullscreen() const{ return fullscreen; } diff --git a/src/eventthread.h b/src/eventthread.h index 5b6386a..33cc36e 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -93,11 +93,14 @@ public: /* Called from RGSS thread */ void requestFullscreenMode(bool mode); + void requestWindowMove(int x, int y); void requestWindowResize(int width, int height); void requestShowCursor(bool mode); void requestTerminate(); + Vec2i getWindowPosition() const; + bool getFullscreen() const; bool getShowCursor() const; @@ -115,7 +118,9 @@ private: void resetInputStates(); void setFullscreen(SDL_Window *, bool mode); void updateCursorState(bool inWindow, const SDL_Rect &screen); + void updateWindowPosition(int x, int y); + int winX, winY; bool fullscreen; bool showCursor; AtomicFlag msgBoxDone; diff --git a/src/graphics.cpp b/src/graphics.cpp index b7f654c..40074d1 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -134,7 +134,7 @@ public: const int w = geometry.rect.w; const int h = geometry.rect.h; - shState->prepareDraw(); + shState->graphicsSignals.prepareDraw(); pp.startRender(); @@ -412,6 +412,7 @@ struct GraphicsPrivate{ /* Screen resolution, ie. the resolution at which * RGSS renders at (settable with Graphics.resize_screen). * Can only be changed from within RGSS */ + Vec2i scPos; Vec2i scRes; /* Screen size, to which the rendered frames are scaled up. @@ -477,6 +478,8 @@ struct GraphicsPrivate{ TEX::setRepeat(false); TEX::setSmooth(false); gl.TexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, scRes.x, scRes.y, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0); + + scPos = rtData->ethread->getWindowPosition(); } ~GraphicsPrivate(){ @@ -642,6 +645,7 @@ void Graphics::update(bool limitFps){ p->checkResize(); p->redrawScreen(); + p->scPos = shState->rtData().ethread->getWindowPosition(); } void Graphics::freeze(){ @@ -853,6 +857,14 @@ Bitmap *Graphics::snapToBitmap(){ return bitmap; } +int Graphics::x() const{ + return p->scPos.x; +} + +int Graphics::y() const{ + return p->scPos.y; +} + int Graphics::width() const{ return p->scRes.x; } @@ -861,6 +873,17 @@ int Graphics::height() const{ return p->scRes.y; } +void Graphics::moveScreen(int x, int y){ + Vec2i pos(x, y); + + if (p->scPos == pos) + return; + + p->scPos = pos; + + shState->eThread().requestWindowMove(x, y); +} + void Graphics::resizeScreen(int width, int height){ width = clamp(width, 1, 65000); height = clamp(height, 1, 65000); diff --git a/src/graphics.h b/src/graphics.h index b987897..0948aa1 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -49,9 +49,12 @@ public: Bitmap *snapToBitmap(); + int x() const; + int y() const; int width() const; int height() const; void resizeScreen(int width, int height); + void moveScreen(int x, int y); void reset(); diff --git a/src/lightmap.cpp b/src/lightmap.cpp index ceb84cd..6e7a50d 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -5,6 +5,7 @@ #include "etc.h" #include "etc-internal.h" #include "util.h" +#include "signals/signal.h" #include "gl-util.h" #include "quad.h" @@ -19,8 +20,6 @@ #include #include - -#include #include struct LightMapPrivate{ @@ -38,7 +37,7 @@ struct LightMapPrivate{ Transform trans; Rect *srcRect; - sigc::connection srcRectCon; + SignalConnection srcRectCon; IntRect sceneRect; Vec2i sceneOrig; @@ -49,7 +48,7 @@ struct LightMapPrivate{ EtcTemps tmp; - sigc::connection prepareCon; + SignalConnection prepareCon; LightMapPrivate() : bitmap(new Bitmap(shState->graphics().width(), shState->graphics().height())), @@ -67,7 +66,7 @@ struct LightMapPrivate{ updateSrcRectCon(); - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &LightMapPrivate::prepare)); + prepareCon = shState->graphicsSignals.prepareDraw.Connect(*this, &LightMapPrivate::prepare); bitmap->ensureNonMega(); //bitmap->fillRect(0, 0, shState->graphics().width(), shState->graphics().height(), Vec4(0, 0, 0, 1)); @@ -78,8 +77,8 @@ struct LightMapPrivate{ } ~LightMapPrivate(){ - srcRectCon.disconnect(); - prepareCon.disconnect(); + srcRectCon.Disconnect(); + prepareCon.Disconnect(); } void onSrcRectChange(){ @@ -101,9 +100,9 @@ struct LightMapPrivate{ void updateSrcRectCon(){ /* Cut old connection */ - srcRectCon.disconnect(); + srcRectCon.Disconnect(); /* Create new one */ - srcRectCon = srcRect->valueChanged.connect(sigc::mem_fun(this, &LightMapPrivate::onSrcRectChange)); + srcRectCon = srcRect->valueChanged.Connect(*this, &LightMapPrivate::onSrcRectChange); } void updateVisibility(){ diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 35f93f5..38d8104 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -18,37 +18,36 @@ #include // OS-Specific code #if defined(_WIN32) - #define SECURITY_WIN32 - #include - #include - #include - #include - #include +#define SECURITY_WIN32 +#include +#include +#include +#include +#include #elif defined(__APPLE__) - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include #elif unix_like - #include - #include - #include - #include - #include - #include - #include "xdg-user-dir-lookup.h" +#include +#include +#include +#include +#include +#include +#include "xdg-user-dir-lookup.h" #else - #error "Operating system not detected or unsupported." +#error "Operating system not detected or unsupported." #endif - const Config conf; #define DEF_SCREEN_W conf.defScreenW #define DEF_SCREEN_H conf.defScreenH - -struct OneshotPrivate{ +struct OneshotPrivate +{ // Main SDL window SDL_Window *window; @@ -71,24 +70,26 @@ struct OneshotPrivate{ // Alpha texture data for portions of window obscured by screen edges int winX, winY, winW, winH; SDL_Mutex *winMutex; - bool winPosChanged; std::vector obscuredMap; + bool obscuredNeedToUpdate; bool obscuredCleared; OneshotPrivate() : window(0), - winMutex(SDL_CreateMutex()) + winMutex(SDL_CreateMutex()) { } - ~OneshotPrivate(){ + ~OneshotPrivate() + { SDL_DestroyMutex(winMutex); } }; -//OS-SPECIFIC FUNCTIONS +// OS-SPECIFIC FUNCTIONS #if unix_like -struct linux_DialogData{ +struct linux_DialogData +{ // Input int type; const char *body; @@ -98,28 +99,30 @@ struct linux_DialogData{ bool result; }; -static int linux_dialog(void *rawData){ - linux_DialogData *data = reinterpret_cast(rawData); +static int linux_dialog(void *rawData) +{ + linux_DialogData *data = reinterpret_cast(rawData); // Determine correct flags GtkMessageType gtktype; GtkButtonsType gtkbuttons = GTK_BUTTONS_OK; - switch (data->type){ - case Oneshot::MSG_INFO: - gtktype = GTK_MESSAGE_INFO; - break; - case Oneshot::MSG_YESNO: - gtktype = GTK_MESSAGE_QUESTION; - gtkbuttons = GTK_BUTTONS_YES_NO; - break; - case Oneshot::MSG_WARN: - gtktype = GTK_MESSAGE_WARNING; - break; - case Oneshot::MSG_ERR: - gtktype = GTK_MESSAGE_ERROR; - break; - default: - gtk_main_quit(); - return 0; + switch (data->type) + { + case Oneshot::MSG_INFO: + gtktype = GTK_MESSAGE_INFO; + break; + case Oneshot::MSG_YESNO: + gtktype = GTK_MESSAGE_QUESTION; + gtkbuttons = GTK_BUTTONS_YES_NO; + break; + case Oneshot::MSG_WARN: + gtktype = GTK_MESSAGE_WARNING; + break; + case Oneshot::MSG_ERR: + gtktype = GTK_MESSAGE_ERROR; + break; + default: + gtk_main_quit(); + return 0; } // Display dialog and get result @@ -136,38 +139,43 @@ static int linux_dialog(void *rawData){ #elif defined _WIN32 /* 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; int size = WideCharToMultiByte(CP_UTF8, 0, ustr, -1, 0, 0, 0, 0); - if (size > 0){ + if (size > 0) + { CHAR *str = new CHAR[size]; if (WideCharToMultiByte(CP_UTF8, 0, ustr, -1, str, size, 0, 0) == size) result = str; - delete [] str; + delete[] str; } return result; } /* Convert WCHAR pointer from const char* */ -static WCHAR *w32_toWide(const char *str){ - if (str){ +static WCHAR *w32_toWide(const char *str) +{ + if (str) + { int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0); - if (size > 0){ + if (size > 0) + { WCHAR *ustr = new WCHAR[size]; if (MultiByteToWideChar(CP_UTF8, 0, str, -1, ustr, size) == size) return ustr; - delete [] ustr; + delete[] ustr; } } - //Return empty string + // Return empty string WCHAR *ustr = new WCHAR[1]; *ustr = 0; return ustr; } #endif -Oneshot::Oneshot(RGSSThreadData &threadData) : - threadData(threadData){ +Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData) +{ p = new OneshotPrivate(); p->window = threadData.window; p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1); @@ -176,46 +184,50 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : SDL_GetWindowSize(p->window, &p->winW, &p->winH); p->obscuredMap.resize(p->winW * p->winH, 255); obscuredDirty = true; - p->winPosChanged = false; + p->obscuredNeedToUpdate = false; p->allowExit = true; p->exiting = false; - #ifdef _WIN32 - p->os = "windows"; - #elif __APPLE__ - p->os = "macos"; - #elif unix_like - p->os = "linux"; - #endif +#ifdef _WIN32 + p->os = "windows"; +#elif __APPLE__ + p->os = "macos"; +#elif unix_like + p->os = "linux"; +#endif /******************** * USERNAME/DOCS PATH ********************/ #if defined _WIN32 - //Get language code + // Get language code WCHAR wlang[9]; GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); p->lang = w32_fromWide(wlang) + "_"; GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); p->lang += w32_fromWide(wlang); - //Get user's name + // Get user's name ULONG size = 0; GetUserNameEx(NameDisplay, 0, &size); - if (GetLastError() == ERROR_MORE_DATA){ - //Get their full (display) name + if (GetLastError() == ERROR_MORE_DATA) + { + // Get their full (display) name WCHAR *name = new WCHAR[size]; GetUserNameEx(NameDisplay, name, &size); p->userName = w32_fromWide(name); - delete [] name; - }else{ - //Get their login name + delete[] name; + } + else + { + // Get their login name DWORD size2 = 0; GetUserName(0, &size2); - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){ + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { WCHAR *name = new WCHAR[size2]; GetUserName(name, &size2); p->userName = w32_fromWide(name); - delete [] name; + delete[] name; } } @@ -223,81 +235,107 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : WCHAR path[MAX_PATH]; SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path); p->docsPath = w32_fromWide(path); - p->gamePath = p->docsPath+"\\My Games"; + p->gamePath = p->docsPath + "\\My Games"; p->journal = "_______.exe"; #else // Get language code const char *lc_all = getenv("LC_ALL"); const char *lang = getenv("LANG"); const char *code = (lc_all ? lc_all : lang); - if (code){ + if (code) + { // find first dot, copy language code int end = 0; - for (; code[end] && code[end] != '.'; ++end) {} + for (; code[end] && code[end] != '.'; ++end) + { + } p->lang = std::string(code, end); - }else + } + else p->lang = "en"; - // Get user's name - #ifdef OS_OSX - struct passwd *pwd = getpwuid(geteuid()); - #elif unix_like - struct passwd *pwd = getpwuid(getuid()); - #endif - if (pwd){ - if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ','){ - //Get the user's full name +// Get user's name +#ifdef OS_OSX + struct passwd *pwd = getpwuid(geteuid()); +#elif unix_like + struct passwd *pwd = getpwuid(getuid()); +#endif + if (pwd) + { + if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ',') + { + // Get the user's full name int comma = 0; - for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma) {} + for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma) + { + } p->userName = std::string(pwd->pw_gecos, comma); - }else + } + else p->userName = pwd->pw_name; } - // Get documents path - #ifdef __APPLE__ - std::string path = std::string(getenv("HOME")) + "/Documents"; - p->docsPath = path.c_str(); - p->gamePath = path.c_str(); - p->journal = "_______.app"; - #elif unix_like - char * path = xdg_user_dir_lookup("DOCUMENTS"); - p->docsPath = path; - p->gamePath = path; - p->journal = "_______"; - #endif +// Get documents path +#ifdef __APPLE__ + std::string path = std::string(getenv("HOME")) + "/Documents"; + p->docsPath = path.c_str(); + p->gamePath = path.c_str(); + p->journal = "_______.app"; +#elif unix_like + char *path = xdg_user_dir_lookup("DOCUMENTS"); + p->docsPath = path; + p->gamePath = path; + p->journal = "_______"; +#endif #endif Debug() << "[oneshot] Game path :" << p->gamePath; Debug() << "[oneshot] Docs path :" << p->docsPath; #ifdef unix_like - char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); + char const *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); gtk_init(0, 0); - if (xdg_current_desktop == NULL) { + if (xdg_current_desktop == NULL) + { desktopEnv = "nope"; - } else { + } + else + { std::string desktop(xdg_current_desktop); std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); - if (desktop.find("cinnamon") != std::string::npos) { + if (desktop.find("cinnamon") != std::string::npos) + { desktopEnv = "cinnamon"; - } else if ( + } + else if ( desktop.find("gnome") != std::string::npos || - desktop.find("unity") != std::string::npos - ) { + desktop.find("unity") != std::string::npos) + { desktopEnv = "gnome"; - } else if (desktop.find("mate") != std::string::npos) { + } + else if (desktop.find("mate") != std::string::npos) + { desktopEnv = "mate"; - } else if (desktop.find("xfce") != std::string::npos) { + } + else if (desktop.find("xfce") != std::string::npos) + { desktopEnv = "xfce"; - } else if (desktop.find("kde") != std::string::npos) { + } + else if (desktop.find("kde") != std::string::npos) + { desktopEnv = "kde"; - } else if (desktop.find("lxde") != std::string::npos) { + } + else if (desktop.find("lxde") != std::string::npos) + { desktopEnv = "lxde"; - } else if (desktop.find("lxqt") != std::string::npos) { + } + else if (desktop.find("lxqt") != std::string::npos) + { desktopEnv = "lxqt"; - } else if (desktop.find("deepin") != std::string::npos) { + } + else if (desktop.find("deepin") != std::string::npos) + { desktopEnv = "deepin"; } } @@ -309,7 +347,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : * MISC ********/ #if defined _WIN32 - //Get windows version + // Get windows version OSVERSIONINFOW version; ZeroMemory(&version, sizeof(version)); version.dwOSVersionInfoSize = sizeof(version); @@ -317,150 +355,111 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : #endif } -Oneshot::~Oneshot(){ +Oneshot::~Oneshot() +{ delete p; } -void Oneshot::update(){ - if (p->winPosChanged){ - p->winPosChanged = false; - - //Map of unobscured pixels in this frame - static std::vector obscuredFrame; - obscuredFrame.resize(p->obscuredMap.size()); - std::fill(obscuredFrame.begin(), obscuredFrame.end(), true); - - SDL_Rect screenRect; - SDL_LockMutex(p->winMutex); - screenRect.x = p->winX; - screenRect.y = p->winY; - SDL_UnlockMutex(p->winMutex); - screenRect.w = p->winW; - screenRect.h = p->winH; - - //костыль ебучий - int num_displays; - SDL_DisplayID *displays = SDL_GetDisplays(&num_displays); - if (!displays) - printf("SDL_GetDisplays failed (oneshot.cpp)\n"); - //Update obscured map and texture for window portion offscreen - for (int i = 0, max = num_displays; i < max; ++i){ - SDL_Rect bounds; - if (!SDL_GetDisplayBounds(displays[i], &bounds)) - printf("SDL_GetDisplayBounds failed (oneshot.cpp)\n"); - - //Get intersection of window and the screen - SDL_Rect intersect; - if (!SDL_GetRectIntersection(&screenRect, &bounds, &intersect)) - continue; - intersect.x -= screenRect.x; - intersect.y -= screenRect.y; - - //If it's entirely within the bounds of the screen, we don't need to check out - //any other monitors - if (intersect.x == 0 && intersect.y == 0 && intersect.w == conf.defScreenW && intersect.h == conf.defScreenH) - return; - - for (int y = intersect.y; y < intersect.y + intersect.h; ++y){ - int start = y * p->winW + intersect.x; - std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false); - } - } - SDL_free(displays); - - //Update the obscured map, and return prematurely if we don't have any changes - //to make to the texture - bool needsUpdate = false; - bool cleared = true; - for (size_t i = 0; i < obscuredFrame.size(); ++i){ - if (obscuredFrame[i]){ - p->obscuredMap[i] = 0; - needsUpdate = true; - } - if (p->obscuredMap[i] == 255) - cleared = false; - } - p->obscuredCleared = cleared; - if (!needsUpdate) - return; - - //Flag as dirty - obscuredDirty = true; - } +void Oneshot::update() +{ + p->obscuredNeedToUpdate = true; } -const std::string &Oneshot::os() const{ +const std::string &Oneshot::os() const +{ return p->os; } -const std::string &Oneshot::lang() const{ +const std::string &Oneshot::lang() const +{ return p->lang; } -const std::string &Oneshot::userName() const{ +const std::string &Oneshot::userName() const +{ return p->userName; } -const std::string &Oneshot::savePath() const{ +const std::string &Oneshot::savePath() const +{ return p->savePath; } -const std::string &Oneshot::docsPath() const{ +const std::string &Oneshot::docsPath() const +{ return p->docsPath; } -const std::string &Oneshot::gamePath() const{ +const std::string &Oneshot::gamePath() const +{ return p->gamePath; } -const std::string &Oneshot::journal() const{ +const std::string &Oneshot::journal() const +{ return p->journal; } -const std::vector &Oneshot::obscuredMap() const{ +const std::vector &Oneshot::obscuredMap() const +{ return p->obscuredMap; } -bool Oneshot::obscuredCleared() const{ +bool Oneshot::obscuredCleared() const +{ return p->obscuredCleared; } -bool Oneshot::exiting() const{ +bool Oneshot::exiting() const +{ return p->exiting; } -bool Oneshot::allowExit() const{ +bool Oneshot::allowExit() const +{ return p->allowExit; } -void Oneshot::setYesNo(const char *yes, const char *no){ +void Oneshot::setYesNo(const char *yes, const char *no) +{ p->txtYes = yes; p->txtNo = no; } -void Oneshot::setExiting(bool exiting){ - if (p->exiting != exiting) { +void Oneshot::setExiting(bool exiting) +{ + if (p->exiting != exiting) + { p->exiting = exiting; - if (exiting) { + if (exiting) + { threadData.exiting.set(); - } else { + } + else + { threadData.exiting.clear(); } } } -void Oneshot::setAllowExit(bool allowExit){ - if (p->allowExit != allowExit) { +void Oneshot::setAllowExit(bool allowExit) +{ + if (p->allowExit != allowExit) + { p->allowExit = allowExit; - if (allowExit) { + if (allowExit) + { threadData.allowExit.set(); - } else { + } + else + { threadData.allowExit.clear(); } } } -bool Oneshot::msgbox(int type, const char *body, const char *title){ +bool Oneshot::msgbox(int type, const char *body, const char *title) +{ if (!title) title = ""; #ifdef unix_like @@ -488,8 +487,9 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){ DWORD sound; #endif - //Set type - switch (type){ + // Set type + switch (type) + { case MSG_INFO: case MSG_YESNO: default: @@ -513,7 +513,8 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){ } // Set buttons - switch (type){ + switch (type) + { case MSG_INFO: case MSG_WARN: case MSG_ERR: @@ -533,23 +534,25 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){ #endif int button; - #ifdef __APPLE__ - int *btn = &button; +#ifdef __APPLE__ + int *btn = &button; - // Message boxes and UI changes must be performed from the main thread on macOS Mojave and above. - // This block ensures the message box will show from the main thread. - dispatch_sync(dispatch_get_main_queue(), - ^{ SDL_ShowMessageBox(&data, btn); } - ); - #else - SDL_ShowMessageBox(&data, &button); - #endif + // Message boxes and UI changes must be performed from the main thread on macOS Mojave and above. + // This block ensures the message box will show from the main thread. + dispatch_sync(dispatch_get_main_queue(), + ^{ + SDL_ShowMessageBox(&data, btn); + }); +#else + SDL_ShowMessageBox(&data, &button); +#endif return button ? true : false; #endif // #ifdef OS_LINUX } -std::string Oneshot::textinput(const char* prompt, int char_limit, const char* fontName) { +std::string Oneshot::textinput(const char *prompt, int char_limit, const char *fontName) +{ std::vector *fontNames = new std::vector(); fontNames->push_back(fontName); fontNames->push_back("VL Gothic"); @@ -570,8 +573,10 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f SDL_StartTextInput(this->p->window); // Main loop - while (threadData.acceptingTextInput) { - if (inputTextPrev != threadData.inputText) { + while (threadData.acceptingTextInput) + { + if (inputTextPrev != threadData.inputText) + { inputBmp->clear(); inputBmp->drawText(DEF_SCREEN_W / 2, DEF_SCREEN_H / 2, DEF_SCREEN_W, DEF_SCREEN_H, threadData.inputText.c_str(), 1); inputTextPrev = threadData.inputText; @@ -584,15 +589,82 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f return threadData.inputText; } -void Oneshot::setWindowPos(int x, int y){ +void Oneshot::updateObscured(int winX, int winY) +{ + p->winX = winX; + p->winY = winY; + + if (!p->obscuredNeedToUpdate) return; + + // Map of unobscured pixels in this frame + static std::vector obscuredFrame; + obscuredFrame.resize(p->obscuredMap.size()); + std::fill(obscuredFrame.begin(), obscuredFrame.end(), true); + + SDL_Rect screenRect; SDL_LockMutex(p->winMutex); - p->winX = x; - p->winY = y; - p->winPosChanged = true; + screenRect.x = p->winX; + screenRect.y = p->winY; SDL_UnlockMutex(p->winMutex); + screenRect.w = p->winW; + screenRect.h = p->winH; + + // костыль ебучий + int num_displays; + SDL_DisplayID *displays = SDL_GetDisplays(&num_displays); + if (!displays) + printf("SDL_GetDisplays failed (oneshot.cpp)\n"); + // Update obscured map and texture for window portion offscreen + for (int i = 0, max = num_displays; i < max; ++i) + { + SDL_Rect bounds; + if (!SDL_GetDisplayBounds(displays[i], &bounds)) + printf("SDL_GetDisplayBounds failed (oneshot.cpp)\n"); + + // Get intersection of window and the screen + SDL_Rect intersect; + if (!SDL_GetRectIntersection(&screenRect, &bounds, &intersect)) + continue; + intersect.x -= screenRect.x; + intersect.y -= screenRect.y; + + // If it's entirely within the bounds of the screen, we don't need to check out + // any other monitors + if (intersect.x == 0 && intersect.y == 0 && intersect.w == conf.defScreenW && intersect.h == conf.defScreenH) + return; + + for (int y = intersect.y; y < intersect.y + intersect.h; ++y) + { + int start = y * p->winW + intersect.x; + std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false); + } + } + SDL_free(displays); + + // Update the obscured map, and return prematurely if we don't have any changes + // to make to the texture + bool needsUpdate = false; + bool cleared = true; + for (size_t i = 0; i < obscuredFrame.size(); ++i) + { + if (obscuredFrame[i]) + { + p->obscuredMap[i] = 0; + needsUpdate = true; + } + if (p->obscuredMap[i] == 255) + cleared = false; + } + p->obscuredCleared = cleared; + if (!needsUpdate) + return; + + // Flag as dirty + obscuredDirty = true; } -void Oneshot::resetObscured(){ +void Oneshot::resetObscured() +{ std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255); obscuredDirty = true; p->obscuredCleared = false; diff --git a/src/oneshot.h b/src/oneshot.h index 6694409..3d1ee7e 100644 --- a/src/oneshot.h +++ b/src/oneshot.h @@ -59,9 +59,9 @@ public: //Mutators void setYesNo(const char *yes, const char *no); - void setWindowPos(int x, int y); void setExiting(bool exiting); void setAllowExit(bool allowExit); + void updateObscured(int winX, int winY); void resetObscured(); //Functions diff --git a/src/plane.cpp b/src/plane.cpp index 2086618..d21769e 100644 --- a/src/plane.cpp +++ b/src/plane.cpp @@ -36,7 +36,7 @@ #include "glstate.h" #include "sunshine.h" -#include +#include "signals/signal.h" static float fwrap(float value, float range){ float res = fmod(value, range); @@ -66,8 +66,8 @@ struct PlanePrivate{ EtcTemps tmp; - sigc::connection prepareCon; - sigc::connection srcRectCon; + SignalConnection prepareCon; + SignalConnection srcRectCon; PlanePrivate() : bitmap(0), @@ -82,14 +82,14 @@ struct PlanePrivate{ shader(ShaderType::SHADER_plane) { updateSrcRectCon(); - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &PlanePrivate::prepare)); + prepareCon = shState->graphicsSignals.prepareDraw.Connect(*this, &PlanePrivate::prepare); qArray.resize(1); } ~PlanePrivate(){ - srcRectCon.disconnect(); - prepareCon.disconnect(); + srcRectCon.Disconnect(); + prepareCon.Disconnect(); } void onSrcRectChange(){ @@ -98,9 +98,9 @@ struct PlanePrivate{ void updateSrcRectCon(){ /* Cut old connection */ - srcRectCon.disconnect(); + srcRectCon.Disconnect(); /* Create new one */ - srcRectCon = srcRect->valueChanged.connect(sigc::mem_fun(this, &PlanePrivate::onSrcRectChange)); + srcRectCon = srcRect->valueChanged.Connect(*this, &PlanePrivate::onSrcRectChange); } void updateQuadSource(){ diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index baa0a40..c229692 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -169,6 +169,8 @@ void SharedState::initInstance(RGSSThreadData *threadData){ SharedState::instance->p->defaultFont = defaultFont; SharedState::instance->p->sunshine.loadNoise(); + + SharedState::instance->windowSignals.moved.Connect(SharedState::instance->p->oneshot, &Oneshot::updateObscured); } void SharedState::finiInstance(){ diff --git a/src/sharedstate.h b/src/sharedstate.h index e095979..0194e08 100644 --- a/src/sharedstate.h +++ b/src/sharedstate.h @@ -22,7 +22,7 @@ #ifndef SHAREDSTATE_H #define SHAREDSTATE_H -#include +#include "signals/signal.h" #define shState SharedState::instance #define glState shState->_glState() @@ -55,7 +55,21 @@ struct Config; struct Vec2i; struct SharedMidiState; +struct WindowSignals{ + Signal moved; + Signal resized; +}; + +struct GraphicsSignals{ + Signal prepareDraw; +}; + struct SharedState{ + // signals + WindowSignals windowSignals; + GraphicsSignals graphicsSignals; + + // other shit idk void *bindingData() const; void setBindingData(void *data); @@ -89,8 +103,6 @@ struct SharedState{ SharedFontState &fontState() const; Font &defaultFont() const; - sigc::signal prepareDraw; - unsigned int genTimeStamp(); /* Returns global quad IBO, and ensures it has indices @@ -133,3 +145,28 @@ private: }; #endif // SHAREDSTATE_H + + + +/* this is not part of mkxp :| + meow meow + meow meow + meow meow meow meow + meow meow meow meow + meow meow meow meow meow meow + meow meow meow meow meow meow + meow meow meow meow meow meow meow meow + meow meow meow meow meow meow meow meow + meow meow meow meow meow meow meow meow + meow meow meow meow meow meow meow meow + meow meow meow meow meow meow + meow meow meow meow meow meow +meow meow meow meow meow meow meow meow meow meow +meow meow meow meow meow meow meow meow meow meow + meow meow meow meow meow meow meow + meow meow meow meow meow meow meow +meow meow meow meow meow meow meow +meow meow meow meow meow meow meow + meow meow meow meow meow meow meow meow + meow meow meow meow meow meow meow meow +*/ \ No newline at end of file diff --git a/src/signals/signal.h b/src/signals/signal.h new file mode 100644 index 0000000..fff86a9 --- /dev/null +++ b/src/signals/signal.h @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include "signalconnection.h" + +// мямямя +template +class Signal +{ +public: + size_t listeners = 0; + + template + SignalConnection Connect(Obj& obj, void (Obj::*func)()) + { + return SignalConnection(signal.connect([&obj, func](auto&&...) { (obj.*func)(); })); + } + + template + SignalConnection Connect(Obj& obj, Func func) + { + listeners++; + return SignalConnection(signal.connect(sigc::mem_fun(obj, func))); + } + + template + SignalConnection Connect(Callable cb) + { + return SignalConnection(signal.connect(cb)); + } + + template + void Emit(Args... args) + { + signal(args...); + } + + template + void operator()(Args... args) + { + signal(args...); + } + + void DisconnectAll() + { + signal.clear(); + } + +private: + sigc::signal signal; +}; \ No newline at end of file diff --git a/src/signals/signalconnection.h b/src/signals/signalconnection.h new file mode 100644 index 0000000..756a838 --- /dev/null +++ b/src/signals/signalconnection.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +class SignalConnection{ +public: + SignalConnection() = default; + + void Disconnect() + { + connection.disconnect(); + } + + bool Connected() const + { + return connection.connected(); + } + +private: + SignalConnection(sigc::connection conn) + : connection(std::move(conn)) + {} + + sigc::connection connection; + + template + friend class Signal; +}; \ No newline at end of file diff --git a/src/sprite.cpp b/src/sprite.cpp index 8407ad4..ea02b89 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -26,6 +26,7 @@ #include "etc.h" #include "etc-internal.h" #include "util.h" +#include "signals/signal.h" #include "gl-util.h" #include "quad.h" @@ -41,7 +42,6 @@ #include -#include #include struct SpritePrivate{ @@ -52,7 +52,7 @@ struct SpritePrivate{ Transform trans; Rect *srcRect; - sigc::connection srcRectCon; + SignalConnection srcRectCon; bool mirrorX; bool mirrorY; @@ -92,7 +92,7 @@ struct SpritePrivate{ EtcTemps tmp; - sigc::connection prepareCon; + SignalConnection prepareCon; SpritePrivate() : bitmap(0), @@ -116,7 +116,7 @@ struct SpritePrivate{ updateSrcRectCon(); - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &SpritePrivate::prepare)); + prepareCon = shState->graphicsSignals.prepareDraw.Connect(*this, &SpritePrivate::prepare); wave.amp = 0; wave.length = 180; @@ -126,8 +126,8 @@ struct SpritePrivate{ } ~SpritePrivate(){ - srcRectCon.disconnect(); - prepareCon.disconnect(); + srcRectCon.Disconnect(); + prepareCon.Disconnect(); } void recomputeBushDepth(){ @@ -163,9 +163,9 @@ struct SpritePrivate{ void updateSrcRectCon(){ /* Cut old connection */ - srcRectCon.disconnect(); + srcRectCon.Disconnect(); /* Create new one */ - srcRectCon = srcRect->valueChanged.connect(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange)); + srcRectCon = srcRect->valueChanged.Connect(*this, &SpritePrivate::onSrcRectChange); } void updateVisibility(){ diff --git a/src/table.h b/src/table.h index c222b3a..c94303c 100644 --- a/src/table.h +++ b/src/table.h @@ -22,10 +22,10 @@ #ifndef TABLE_H #define TABLE_H +#include "signals/signal.h" #include "serializable.h" #include -#include #include class Table : public Serializable{ @@ -70,7 +70,7 @@ public: return fallback; } - sigc::signal modified; + Signal modified; private: int xs, ys, zs; diff --git a/src/tilemap-common.h b/src/tilemap-common.h index 393bc18..b4a5a5b 100644 --- a/src/tilemap-common.h +++ b/src/tilemap-common.h @@ -32,13 +32,12 @@ #include "vertex.h" #include "quad.h" #include "etc-internal.h" +#include "signals/signal.h" #include #include #include -#include - static inline int wrap(int value, int range){ int res = value % range; return res < 0 ? res + range : res; @@ -111,7 +110,7 @@ struct FlashMap{ ~FlashMap(){ GLMeta::vaoFini(vao); VBO::del(vao.vbo); - dataCon.disconnect(); + dataCon.Disconnect(); } Table *getData() const{ @@ -123,14 +122,13 @@ struct FlashMap{ return; data = value; - dataCon.disconnect(); + dataCon.Disconnect(); dirty = true; if (!data) return; - dataCon = data->modified.connect - (sigc::mem_fun(this, &FlashMap::setDirty)); + dataCon = data->modified.Connect(*this, &FlashMap::setDirty); } void setViewport(const IntRect &value){ @@ -238,7 +236,7 @@ private: bool dirty; Table *data; - sigc::connection dataCon; + SignalConnection dataCon; IntRect viewp; diff --git a/src/tilemap.cpp b/src/tilemap.cpp index 0c18f13..e2a6856 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -24,6 +24,7 @@ #include "viewport.h" #include "bitmap.h" #include "table.h" +#include "signals/signal.h" #include "sharedstate.h" #include "config.h" @@ -40,7 +41,6 @@ #include "tilemap-common.h" #include "sunshine.h" -#include #include #include @@ -303,16 +303,16 @@ struct TilemapPrivate { bool tilemapReady; /* Change watches */ - sigc::connection tilesetCon; - sigc::connection autotilesCon[autotileCount]; - sigc::connection mapDataCon; - sigc::connection prioritiesCon; + SignalConnection tilesetCon; + SignalConnection autotilesCon[autotileCount]; + SignalConnection mapDataCon; + SignalConnection prioritiesCon; /* Dispose watches */ - sigc::connection autotilesDispCon[autotileCount]; + SignalConnection autotilesDispCon[autotileCount]; /* Draw prepare call */ - sigc::connection prepareCon; + SignalConnection prepareCon; TilemapPrivate(Viewport *viewport) : viewport(viewport), @@ -359,7 +359,7 @@ struct TilemapPrivate { for (size_t i = 0; i < zlayersMax; ++i) elem.zlayers[i] = new ZLayer(this, viewport); - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &TilemapPrivate::prepare)); + prepareCon = shState->graphicsSignals.prepareDraw.Connect(*this, &TilemapPrivate::prepare); updateFlashMapViewport(); } @@ -377,15 +377,15 @@ struct TilemapPrivate { VBO::del(tiles.vbo); /* Disconnect signal handlers */ - tilesetCon.disconnect(); + tilesetCon.Disconnect(); for (int i = 0; i < autotileCount; ++i){ - autotilesCon[i].disconnect(); - autotilesDispCon[i].disconnect(); + autotilesCon[i].Disconnect(); + autotilesDispCon[i].Disconnect(); } - mapDataCon.disconnect(); - prioritiesCon.disconnect(); + mapDataCon.Disconnect(); + prioritiesCon.Disconnect(); - prepareCon.disconnect(); + prepareCon.Disconnect(); } void updateFlashMapViewport(){ @@ -1019,11 +1019,11 @@ void Tilemap::Autotiles::set(int i, Bitmap *bitmap){ p->invalidateAtlasContents(); - p->autotilesCon[i].disconnect(); - p->autotilesCon[i] = bitmap->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents)); + p->autotilesCon[i].Disconnect(); + p->autotilesCon[i] = bitmap->modified.Connect(p, &TilemapPrivate::invalidateAtlasContents); - p->autotilesDispCon[i].disconnect(); - p->autotilesDispCon[i] = bitmap->wasDisposed.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents)); + p->autotilesDispCon[i].Disconnect(); + p->autotilesDispCon[i] = bitmap->wasDisposed.Connect(p, &TilemapPrivate::invalidateAtlasContents); p->updateAutotileInfo(); } @@ -1095,9 +1095,8 @@ void Tilemap::setTileset(Bitmap *value){ return; p->invalidateAtlasSize(); - p->tilesetCon.disconnect(); - p->tilesetCon = value->modified.connect - (sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasSize)); + p->tilesetCon.Disconnect(); + p->tilesetCon = value->modified.Connect(p, &TilemapPrivate::invalidateAtlasSize); p->updateAtlasInfo(); } @@ -1114,9 +1113,8 @@ void Tilemap::setMapData(Table *value){ return; p->invalidateBuffers(); - p->mapDataCon.disconnect(); - p->mapDataCon = value->modified.connect - (sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); + p->mapDataCon.Disconnect(); + p->mapDataCon = value->modified.Connect(p, &TilemapPrivate::invalidateBuffers); } void Tilemap::setFlashData(Table *value){ @@ -1137,8 +1135,8 @@ void Tilemap::setPriorities(Table *value){ return; p->invalidateBuffers(); - p->prioritiesCon.disconnect(); - p->prioritiesCon = value->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateBuffers)); + p->prioritiesCon.Disconnect(); + p->prioritiesCon = value->modified.Connect(p, &TilemapPrivate::invalidateBuffers); } void Tilemap::setVisible(bool value){ diff --git a/src/viewport.cpp b/src/viewport.cpp index 3bf9279..d2fcce8 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -27,17 +27,16 @@ #include "quad.h" #include "glstate.h" #include "graphics.h" +#include "signals/signal.h" #include -#include - struct ViewportPrivate{ /* Needed for geometry changes */ Viewport *self; Rect *rect; - sigc::connection rectCon; + SignalConnection rectCon; Color *color; Tone *tone; @@ -59,7 +58,7 @@ struct ViewportPrivate{ } ~ViewportPrivate(){ - rectCon.disconnect(); + rectCon.Disconnect(); } void onRectChange(){ @@ -69,9 +68,9 @@ struct ViewportPrivate{ } void updateRectCon(){ - rectCon.disconnect(); - rectCon = rect->valueChanged.connect - (sigc::mem_fun(this, &ViewportPrivate::onRectChange)); + rectCon.Disconnect(); + rectCon = rect->valueChanged.Connect + (*this, &ViewportPrivate::onRectChange); } void recomputeOnScreen(){ diff --git a/src/window.cpp b/src/window.cpp index a851e1d..f58d3f2 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -34,7 +34,7 @@ #include "texpool.h" #include "glstate.h" -#include +#include "signals/signal.h" template struct Sides{ @@ -165,7 +165,7 @@ struct WindowPrivate { bool active; bool pause; - sigc::connection cursorRectCon; + SignalConnection cursorRectCon; Vec2i sceneOffset; @@ -227,7 +227,7 @@ struct WindowPrivate { EtcTemps tmp; - sigc::connection prepareCon; + SignalConnection prepareCon; WindowPrivate(Viewport *viewport = 0) : windowskin(0), @@ -254,13 +254,13 @@ struct WindowPrivate { cursorVert.count = 9; pauseAniVert.count = 1; - prepareCon = shState->prepareDraw.connect(sigc::mem_fun(this, &WindowPrivate::prepare)); + prepareCon = shState->graphicsSignals.prepareDraw.Connect(*this, &WindowPrivate::prepare); } ~WindowPrivate(){ shState->texPool().release(baseTex); - cursorRectCon.disconnect(); - prepareCon.disconnect(); + cursorRectCon.Disconnect(); + prepareCon.Disconnect(); } void markControlVertDirty(){ @@ -268,8 +268,8 @@ struct WindowPrivate { } void refreshCursorRectCon(){ - cursorRectCon.disconnect(); - cursorRectCon = cursorRect->valueChanged.connect(sigc::mem_fun(this, &WindowPrivate::markControlVertDirty)); + cursorRectCon.Disconnect(); + cursorRectCon = cursorRect->valueChanged.Connect(*this, &WindowPrivate::markControlVertDirty); } void buildBaseVert(){