diff --git a/modules/heliumGameCore/include/heliumGameCore.h b/modules/heliumGameCore/include/heliumGameCore.h index fb4478d..74b67d5 100644 --- a/modules/heliumGameCore/include/heliumGameCore.h +++ b/modules/heliumGameCore/include/heliumGameCore.h @@ -26,7 +26,7 @@ class HeliumGameCore : public HeliumGameCoreObjects { protected: KeyboardUserInput* keyboardInput; -// MouseUserInput* mouseInput; + MouseUserInput* mouseInput; }; #endif // HELIUM_GAME_CORE_INCLUDED diff --git a/modules/heliumGameCore/src/heliumGameCore.cpp b/modules/heliumGameCore/src/heliumGameCore.cpp index eddf70b..e862c3c 100644 --- a/modules/heliumGameCore/src/heliumGameCore.cpp +++ b/modules/heliumGameCore/src/heliumGameCore.cpp @@ -16,7 +16,8 @@ namespace P = Polycode; HeliumGameCore::HeliumGameCore( Polycode::Core* engCore ) : HeliumGameCoreObjects( engCore ), - keyboardInput(new KeyboardUserInput(this)) + keyboardInput(new KeyboardUserInput()), + mouseInput(new MouseUserInput()) { } @@ -27,6 +28,7 @@ HeliumGameCore::~HeliumGameCore() { void HeliumGameCore::game() { HeliumGlobal::setCurrentGame(this); keyboardInput->setEnable(true); + mouseInput->setEnable(true); bool game_is_running = true; while( game_is_running ) { @@ -34,6 +36,7 @@ void HeliumGameCore::game() { objectWorld.lifeStep(); engineCore->Render(); } + mouseInput->setEnable(false); keyboardInput->setEnable(false); HeliumGlobal::setCurrentGame(NULL); return; diff --git a/modules/heliumScreenObjects/include/heliumScreenObjects.h b/modules/heliumScreenObjects/include/heliumScreenObjects.h index 7b2d540..831f343 100644 --- a/modules/heliumScreenObjects/include/heliumScreenObjects.h +++ b/modules/heliumScreenObjects/include/heliumScreenObjects.h @@ -46,6 +46,8 @@ class ScreenObjectsWorld { void addAlifeObject( AlifeScreenObject* ); void lifeStep(); + bool mouseLeftClick(Polycode::Vector2 position); + bool mouseRightClick(Polycode::Vector2 position); void setPause(bool); bool getPause(); diff --git a/modules/heliumScreenObjects/src/heliumScreenObjects.cpp b/modules/heliumScreenObjects/src/heliumScreenObjects.cpp index 2667894..b3300a5 100644 --- a/modules/heliumScreenObjects/src/heliumScreenObjects.cpp +++ b/modules/heliumScreenObjects/src/heliumScreenObjects.cpp @@ -36,6 +36,14 @@ void ScreenObjectsWorld::lifeStep() { (*it)->lifeStep(); } } + +bool ScreenObjectsWorld::mouseLeftClick(Polycode::Vector2 position) { + +} + +bool ScreenObjectsWorld::mouseRightClick(Polycode::Vector2 position) { + +} void ScreenObjectsWorld::setPause(bool set) { engineScreen->enabled = set; diff --git a/modules/userInput/include/heliumInputDipather.h b/modules/userInput/include/heliumInputDipather.h index 974934a..090f719 100644 --- a/modules/userInput/include/heliumInputDipather.h +++ b/modules/userInput/include/heliumInputDipather.h @@ -19,7 +19,7 @@ class KeyboardUserInput : public Polycode::EventHandler { public: - KeyboardUserInput(HeliumGameCoreObjects*); + KeyboardUserInput(); virtual ~KeyboardUserInput(); void handleEvent(Polycode::Event*); @@ -36,7 +36,7 @@ class KeyboardUserInput : public Polycode::EventHandler { class MouseButtonUserInput : public Polycode::EventHandler { public: MouseButtonUserInput(); - virtual ~MouseButtonUserInput(); + virtual ~MouseButtonUserInput() {} void handleEvent(Polycode::Event*); @@ -57,7 +57,7 @@ class MouseButtonUserInput : public Polycode::EventHandler { class MouseMoveUserInput : public Polycode::EventHandler { public: MouseMoveUserInput(); - virtual ~MouseMoveUserInput(); + virtual ~MouseMoveUserInput() {} void handleEvent(Polycode::Event*){}; // not KeyHandler @@ -71,7 +71,7 @@ class MouseMoveUserInput : public Polycode::EventHandler { class MouseOtherUserInput : public Polycode::EventHandler { public: MouseOtherUserInput(); - virtual ~MouseOtherUserInput(); + virtual ~MouseOtherUserInput(){} void handleEvent(Polycode::Event*){} // not KeyHandler @@ -82,7 +82,7 @@ class MouseOtherUserInput : public Polycode::EventHandler { class MouseWheelUserInput : public Polycode::EventHandler { public: MouseWheelUserInput(); - ~MouseWheelUserInput(); + ~MouseWheelUserInput(){} void handleEvent(Polycode::Event*); void addUpEventHandler(KeyHandler*); @@ -96,7 +96,7 @@ class MouseWheelUserInput : public Polycode::EventHandler { class MouseUserInput : public Polycode::EventHandler { public: - MouseUserInput(HeliumGameCoreObjects*); + MouseUserInput(); virtual ~MouseUserInput(); void addEventHandler(Polycode::PolyKEY, KeyHandler*); diff --git a/modules/userInput/src/heliumInputDipather.cpp b/modules/userInput/src/heliumInputDipather.cpp index d5bde94..6da484b 100644 --- a/modules/userInput/src/heliumInputDipather.cpp +++ b/modules/userInput/src/heliumInputDipather.cpp @@ -7,7 +7,7 @@ * Author: AKindyakov * ======================================================== */ - +#include #include #include "heliumInputDipather.h" @@ -15,7 +15,7 @@ namespace P = Polycode; -KeyboardUserInput::KeyboardUserInput(HeliumGameCoreObjects* gm) { +KeyboardUserInput::KeyboardUserInput() { handlers[P::KEY_ESCAPE] = new EscapeGame(); handlers[P::KEY_PAUSE] = new PauseGame(); } @@ -65,17 +65,24 @@ void KeyboardUserInput::keyUP(P::InputEvent* inputEvent){ void KeyboardUserInput::keyDOWN(P::InputEvent* inputEvent){ } -MouseUserInput::MouseUserInput(HeliumGameCoreObjects*) { -} +MouseUserInput::MouseUserInput() + : buttoninput(new MouseButtonUserInput), + moveInput (new MouseMoveUserInput ), + otherInput (new MouseOtherUserInput), + wheelInput (new MouseWheelUserInput) +{} MouseUserInput::~MouseUserInput() { } void MouseUserInput::setEnable(bool set) { buttoninput->setEnable(set); - moveInput->setEnable(set); - otherInput->setEnable(set); - wheelInput->setEnable(set); + // moveInput->setEnable(set); + // otherInput->setEnable(set); + // wheelInput->setEnable(set); +} + +MouseButtonUserInput::MouseButtonUserInput () { } void MouseButtonUserInput::setEnable(bool set) { @@ -96,32 +103,34 @@ void MouseButtonUserInput::setEnable(bool set) { void MouseButtonUserInput::handleEvent(Polycode::Event* e) { P::InputEvent* ie = dynamic_cast(e); int code = ie->mouseButton; - switch(e->getEventCode()) { - case P::InputEvent::EVENT_MOUSEDOWN: - { - std::map::iterator prc = downHandlers.find(code); - if ( prc != downHandlers.end() ) { - prc->second->process(ie->getMousePosition()); - } - } - break; - case P::InputEvent::EVENT_MOUSEUP: - { - std::map::iterator prc = upHandlers.find(code); - if ( prc != upHandlers.end() ) { - prc->second->process(ie->getMousePosition()); - } - } - break; - case P::InputEvent::EVENT_DOUBLECLICK: - { - std::map::iterator prc = doubleClickHandlers.find(code); - if ( prc != doubleClickHandlers.end() ) { - prc->second->process(ie->getMousePosition()); - } - } - break; - } + std::cout << "Mouse input: " << code << '\n'; +// switch(e->getEventCode()) { +// case P::InputEvent::EVENT_MOUSEDOWN: +// { +// std::map::iterator prc = downHandlers.find(code); +// if ( prc != downHandlers.end() ) { +// prc->second->process(ie->getMousePosition()); +// } +// } +// break; +// case P::InputEvent::EVENT_MOUSEUP: +// { +// std::map::iterator prc = upHandlers.find(code); +// if ( prc != upHandlers.end() ) { +// prc->second->process(ie->getMousePosition()); +// } +// HeliumGlobal::GetCurrentGame()->getSceneWorldPt():E +// } +// break; +// case P::InputEvent::EVENT_DOUBLECLICK: +// { +// std::map::iterator prc = doubleClickHandlers.find(code); +// if ( prc != doubleClickHandlers.end() ) { +// prc->second->process(ie->getMousePosition()); +// } +// } +// break; +// } } void MouseButtonUserInput::addRightEventHandler(MouseKeyHandler*) { @@ -133,6 +142,9 @@ void MouseButtonUserInput::addLeftEventHandler(MouseKeyHandler*) { void MouseButtonUserInput::addButtonEventHandler(int, MouseKeyHandler*) { } +MouseMoveUserInput::MouseMoveUserInput() { +} + void MouseMoveUserInput::setEnable(bool set) { HeliumGameCore* gm = HeliumGlobal::getCurrentGame(); Polycode::CoreInput* input = gm->getEngineCorePt()->getInput(); @@ -144,6 +156,9 @@ void MouseMoveUserInput::setEnable(bool set) { } } +MouseOtherUserInput::MouseOtherUserInput () { +} + void MouseOtherUserInput::setEnable(bool set) { HeliumGameCore* gm = HeliumGlobal::getCurrentGame(); Polycode::CoreInput* input = gm->getEngineCorePt()->getInput(); @@ -159,6 +174,9 @@ void MouseOtherUserInput::setEnable(bool set) { } } +MouseWheelUserInput::MouseWheelUserInput () { +} + void MouseWheelUserInput::setEnable(bool set) { HeliumGameCore* gm = HeliumGlobal::getCurrentGame(); Polycode::CoreInput* input = gm->getEngineCorePt()->getInput();