From daf70260de42e98956d4ee3fea3f55b81fdd0fc0 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Wed, 13 Jun 2018 23:10:24 +0200 Subject: [PATCH] Pass the event manager to pixmap --- src/blupi.cxx | 18 +++++++++--------- src/pixmap.cxx | 4 +++- src/pixmap.h | 6 +++++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/blupi.cxx b/src/blupi.cxx index 8c294ad..51a1796 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -779,8 +779,16 @@ DoInit (int argc, char * argv[], bool & exit) info.max_texture_height); } + // Create the event manager. + g_pEvent = new CEvent; + if (g_pEvent == nullptr) + { + InitFail ("New event"); + return EXIT_FAILURE; + } + // Create the main pixmap. - g_pPixmap = new CPixmap; + g_pPixmap = new CPixmap (g_pEvent); if (g_pPixmap == nullptr) { InitFail ("New pixmap"); @@ -981,14 +989,6 @@ DoInit (int argc, char * argv[], bool & exit) g_pDecor->Create (g_pSound, g_pPixmap); g_pDecor->MapInitColors (); - // Create the event manager. - g_pEvent = new CEvent; - if (g_pEvent == nullptr) - { - InitFail ("New event"); - return EXIT_FAILURE; - } - const bool zoom = g_zoom; g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie); diff --git a/src/pixmap.cxx b/src/pixmap.cxx index 58a766a..fea7c0d 100644 --- a/src/pixmap.cxx +++ b/src/pixmap.cxx @@ -33,6 +33,7 @@ #include "blupi.h" #include "def.h" +#include "event.h" #include "misc.h" #include "pixmap.h" @@ -40,7 +41,7 @@ // Constructeur. -CPixmap::CPixmap () +CPixmap::CPixmap (CEvent * event) { Sint32 i; @@ -56,6 +57,7 @@ CPixmap::CPixmap () m_lpSDLCursors[i] = nullptr; m_lpCurrentCursor = nullptr; + this->event = event; } // Destructeur. diff --git a/src/pixmap.h b/src/pixmap.h index 4f0950b..52abe0f 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -47,10 +47,12 @@ struct TextureInfo { } }; +class CEvent; + class CPixmap { public: - CPixmap (); + CPixmap (CEvent * event); ~CPixmap (); bool Create (Point dim); @@ -104,6 +106,8 @@ protected: MouseSprites m_mouseSprite; bool m_bBackDisplayed; + CEvent * event; + SDL_Cursor * m_lpCurrentCursor; SDL_Cursor * m_lpSDLCursors[MAXCURSORS]; SDL_Surface * m_lpSDLBlupi;