diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-10 14:29:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-10 14:29:17 +0300 |
commit | 69eed0d99caea86486206f8d45705827f7a6fe19 (patch) | |
tree | 426c59b2e6cbf7724ad4a44d00df6c59fa1e0471 /src | |
parent | ad5bfca7d5df9201e5460e68ca149674bac5ac2c (diff) | |
download | manaverse-69eed0d99caea86486206f8d45705827f7a6fe19.tar.gz manaverse-69eed0d99caea86486206f8d45705827f7a6fe19.tar.bz2 manaverse-69eed0d99caea86486206f8d45705827f7a6fe19.tar.xz manaverse-69eed0d99caea86486206f8d45705827f7a6fe19.zip |
Add mouse move simulation. After char id to name mapping received, simulate mouse move.
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 6 | ||||
-rw-r--r-- | src/gui/gui.cpp | 4 | ||||
-rw-r--r-- | src/gui/gui.h | 1 | ||||
-rw-r--r-- | src/gui/popups/itempopup.cpp | 1 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 21 | ||||
-rw-r--r-- | src/gui/sdlinput.h | 4 |
6 files changed, 32 insertions, 5 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index fd7f51368..53f8c5a6e 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -29,6 +29,7 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" +#include "gui/sdlinput.h" #include "gui/viewport.h" #include "gui/widgets/tabs/chat/chattab.h" @@ -2000,6 +2001,11 @@ void ActorManager::addChar(const int32_t id, const std::string &name) { mChars[id] = name; + + if (!guiInput) + return; + + guiInput->simulateMouseMove(); } #endif diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 330f2c54b..ea527e3ef 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -100,11 +100,7 @@ #include "debug.h" -// Guichan stuff Gui *gui = nullptr; -SDLInput *guiInput = nullptr; - -// Bolded font Font *boldFont = nullptr; Gui::Gui() : diff --git a/src/gui/gui.h b/src/gui/gui.h index 420e79734..1d1b80667 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -535,7 +535,6 @@ class Gui final }; extern Gui *gui; /**< The GUI system */ -extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 56e907620..e70de0a5c 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -281,6 +281,7 @@ std::string ItemPopup::getCardsString(const int *const cards) { name = toString(charId); beingHandler->requestNameByCharId(charId); + mLastId = 0; // allow recreate popup with same data } // TRANSLATORS: named item description label.append(strprintf(_("Item named: %s"), name.c_str())); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 689066fb5..f3dcc47b2 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -79,6 +79,7 @@ #include "input/inputmanager.h" +#include "gui/gui.h" #include "gui/sdlinput.h" #include "render/graphics.h" @@ -92,6 +93,8 @@ #include "debug.h" +SDLInput *guiInput = nullptr; + SDLInput::SDLInput() : mKeyInputQueue(), mMouseInputQueue(), @@ -546,3 +549,21 @@ void SDLInput::simulateMouseClick(const int x, const int y, mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } + +void SDLInput::simulateMouseMove() +{ + if (!gui) + return; + + int x, y; + Gui::getMouseState(x, y); + + MouseInput mouseInput; + mouseInput.setX(x); + mouseInput.setY(y); + mouseInput.setReal(x, y); + mouseInput.setButton(MouseButton::EMPTY); + mouseInput.setType(MouseEventType::MOVED); + mouseInput.setTimeStamp(SDL_GetTicks()); + mMouseInputQueue.push(mouseInput); +} diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index fb1c2e924..4e46b7356 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -120,6 +120,8 @@ class SDLInput final void simulateMouseClick(const int x, const int y, const MouseButtonT button); + void simulateMouseMove(); + protected: /** * Converts a mouse button from SDL to a Guichan mouse button @@ -149,4 +151,6 @@ class SDLInput final bool mMouseInWindow; }; +extern SDLInput *guiInput; /**< GUI input */ + #endif // GUI_SDLINPUT_H |