diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp index a38c719..7d97832 100644 --- a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp @@ -63,26 +63,6 @@ void cEventControl::CheckEvents() for (it = m_children.begin(); it < m_children.end(); it++) { (*it)->OnEvent(event); } -// iVector2 location = { 0, 0 }; -// switch (event.type) -// { -// case SDL_KEYUP: -// case SDL_KEYDOWN: -// case SDL_JOYAXISMOTION: -// case SDL_JOYBALLMOTION: -// case SDL_JOYHATMOTION: -// case SDL_JOYBUTTONDOWN: -// case SDL_JOYBUTTONUP: -// InputEngine::cInput::Inst().CheckInputs(event); -// break; -// case SDL_MOUSEBUTTONDOWN: -// -// SDL_GetMouseState(&location.x, &location.y); -// GUIEngine::cGUI::Inst().Event(location, GUIEngine::cGUI::eGUIEventType::MouseButton1); -// break; -// case SDL_MOUSEBUTTONUP: -// break; -// } } } diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/Event.h b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/Event.h new file mode 100644 index 0000000..e964a25 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/Event.h @@ -0,0 +1,11 @@ +#ifndef _EVENT_H_ +#define _EVENT_H_ + +/*** Custom Header Files ***/ + +/*** DLL Header File ***/ +#include "dllExport.h" + +#define CLASS(X) + +#endif/// END IFNDEF _EVENT_H_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.cpp new file mode 100644 index 0000000..863356a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.cpp @@ -0,0 +1,20 @@ +#include "cButtonEvent.hpp" + +#include "../../MathEngine/cInside.hpp" + +using GUIEventEngine::cButtonEvent; + +/// protected: +cButtonEvent::cButtonEvent( const unsigned int id ) + : cGUIEvent(GUIHelpers::eEventType::BUTTON, id) +{} + +/*virtual*/ cButtonEvent::~cButtonEvent() +{} + +/// public: +/*virtual*/ void cButtonEvent::OnLButtonDown( int mX, int mY ) +{ +// if (MathEngine::cInside::isInside(mX, mY, m_button->getArea()) == true) + // ; +} diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.hpp new file mode 100644 index 0000000..1277056 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cButtonEvent.hpp @@ -0,0 +1,36 @@ +#ifndef _CBUTTONEVENT_HPP_ +#define _CBUTTONEVENT_HPP_ + +/*** Custom Header Files ***/ +#include "../../EventEngine/cEvent.hpp" + +//#include "../cButton.hpp" +#include "cGUIEvent.hpp" + + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEventEngine { + class EXPORT_FROM_MYDLL cButtonEvent : public cGUIEvent + { + public: + cButtonEvent( const unsigned int id ); + virtual ~cButtonEvent(); + + //bool operator == ( const cButtonEvent& other ); + + public: + /// Functions + virtual void OnLButtonDown( int mX, int mY ); + + /// Sets + + /// Gets + + private: + /// Variables + //GUIEngine::cButton* m_button; + };/// END CLASS DEFINITION cButtonEvent +}/// END NAMESPACE DEFINITION GUIEventEngine +#endif/// END IFNDEF _CBUTTONEVENT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.cpp new file mode 100644 index 0000000..8e45b15 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.cpp @@ -0,0 +1,297 @@ +#include "cGUIEvent.hpp" + +using GUIEventEngine::cGUIEvent; + +cGUIEvent::cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id ) + : m_eventType(eventType), m_id(id) +{ +} + +/*virtual*/ cGUIEvent::~cGUIEvent() +{ +} + +/*virtual*/ void cGUIEvent::OnEvent(const SDL_Event& event) +{ + switch (event.type) + { + case SDL_WINDOWEVENT: + OnWindowsEvent(event); + break; + case SDL_KEYDOWN: + OnKeyDown(event.key.keysym.sym, event.key.keysym.mod);// , Event->key.keysym.unicode); + break; + case SDL_KEYUP: + OnKeyUp(event.key.keysym.sym, event.key.keysym.mod);//, Event->key.keysym.unicode); + break; + case SDL_MOUSEMOTION: + OnMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, (event.motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0); + break; + case SDL_MOUSEBUTTONDOWN: + OnMouseButtonDown(event); + break; + case SDL_MOUSEBUTTONUP: + OnMouseButtonUp(event); + break; + case SDL_JOYAXISMOTION: + OnJoyAxis(event.jaxis.which, event.jaxis.axis, event.jaxis.value); + break; + case SDL_JOYBALLMOTION: + OnJoyBall(event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel); + break; + case SDL_JOYHATMOTION: + OnJoyHat(event.jhat.which, event.jhat.hat, event.jhat.value); + break; + case SDL_JOYBUTTONDOWN: + OnJoyButtonDown(event.jbutton.which, event.jbutton.button); + break; + case SDL_JOYBUTTONUP: + OnJoyButtonUp(event.jbutton.which, event.jbutton.button); + break; + case SDL_QUIT: + OnExit(); + break; + case SDL_SYSWMEVENT: + //Ignore + break; + default: + OnUser(event.user.type, event.user.code, event.user.data1, event.user.data2); + break; + } +} + +/*virtual*/ void cGUIEvent::OnInputFocus() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnInputBlur() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnKeyDown(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode) +{ + sym, mod; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnKeyUp(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode) +{ + sym, mod; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMouseFocus() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMouseBlur() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle) +{ + mX, mY, relX, relY, Left, Right, Middle; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMouseWheel(bool Up, bool Down) +{ + Up, Down; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnLButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnLButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnRButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnRButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value) +{ + which, axis, value; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnJoyButtonDown(SDL_JoystickID which, Uint8 button) +{ + which, button; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnJoyButtonUp(SDL_JoystickID which, Uint8 button) +{ + which, button; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value) +{ + which, hat, value; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel) +{ + which, ball, xrel, yrel; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnMinimize() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnRestore() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnResize(int w, int h) +{ + w, h; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnExpose() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnExit() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnUser(Uint32 type, int code, void* data1, void* data2) +{ + type, code, data1, data2; + //Pure virtual, do nothing +} + +/*virtual*/ void cGUIEvent::OnWindowsEvent(const SDL_Event& event) +{ + switch (event.window.event) + { + case SDL_WINDOWEVENT_SHOWN: + SDL_Log("Window %d shown", event.window.windowID); + break; + case SDL_WINDOWEVENT_HIDDEN: + SDL_Log("Window %d hidden", event.window.windowID); + break; + case SDL_WINDOWEVENT_EXPOSED: + SDL_Log("Window %d exposed", event.window.windowID); + break; + case SDL_WINDOWEVENT_MOVED: + SDL_Log("Window %d moved to %d,%d", + event.window.windowID, event.window.data1, + event.window.data2); + break; + case SDL_WINDOWEVENT_RESIZED: + SDL_Log("Window %d resized to %dx%d", + event.window.windowID, event.window.data1, + event.window.data2); + break; + case SDL_WINDOWEVENT_SIZE_CHANGED: + SDL_Log("Window %d size changed to %dx%d", + event.window.windowID, event.window.data1, + event.window.data2); + break; + case SDL_WINDOWEVENT_MINIMIZED: + SDL_Log("Window %d minimized", event.window.windowID); + break; + case SDL_WINDOWEVENT_MAXIMIZED: + SDL_Log("Window %d maximized", event.window.windowID); + break; + case SDL_WINDOWEVENT_RESTORED: + SDL_Log("Window %d restored", event.window.windowID); + break; + case SDL_WINDOWEVENT_ENTER: + SDL_Log("Mouse entered window %d", + event.window.windowID); + break; + case SDL_WINDOWEVENT_LEAVE: + SDL_Log("Mouse left window %d", event.window.windowID); + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + SDL_Log("Window %d gained keyboard focus", + event.window.windowID); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + SDL_Log("Window %d lost keyboard focus", + event.window.windowID); + break; + case SDL_WINDOWEVENT_CLOSE: + SDL_Log("Window %d closed", event.window.windowID); + break; + default: + SDL_Log("Window %d got unknown event %d", + event.window.windowID, event.window.event); + break; + } +} + +/*virtual*/ void cGUIEvent::OnMouseButtonDown(const SDL_Event& event) +{ + switch (event.button.button) + { + case SDL_BUTTON_LEFT: + OnLButtonDown(event.button.x, event.button.y); + break; + case SDL_BUTTON_RIGHT: + OnRButtonDown(event.button.x, event.button.y); + break; + case SDL_BUTTON_MIDDLE: + OnMButtonDown(event.button.x, event.button.y); + break; + } +} + +/*virtual*/ void cGUIEvent::OnMouseButtonUp(const SDL_Event& event) +{ + switch (event.button.button) + { + case SDL_BUTTON_LEFT: + OnLButtonUp(event.button.x, event.button.y); + break; + case SDL_BUTTON_RIGHT: + OnRButtonUp(event.button.x, event.button.y); + break; + case SDL_BUTTON_MIDDLE: + OnMButtonUp(event.button.x, event.button.y); + break; + } +} diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.hpp new file mode 100644 index 0000000..45f545a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEvent.hpp @@ -0,0 +1,86 @@ +#ifndef _CGUIEVENT_HPP_ +#define _CGUIEVENT_HPP_ + +/*** Custom Header Files ***/ +#include "../../EventEngine/cEvent.hpp" +#include "../GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +#include "../GUIHelpers/cObject.hpp" + +namespace GUIEventEngine { + class EXPORT_FROM_MYDLL cGUIEvent : public EventEngine::cEvent + { + public: + cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id ); + virtual ~cGUIEvent(); + + bool operator == (const cGUIEvent& other); + + /// Functions + virtual void OnEvent(const SDL_Event& event); + + virtual void OnInputFocus(); + + virtual void OnInputBlur(); + + virtual void OnKeyDown(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode); + + virtual void OnKeyUp(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode); + + virtual void OnMouseFocus(); + + virtual void OnMouseBlur(); + + virtual void OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle); + + virtual void OnMouseWheel(bool Up, bool Down); //Not implemented + + virtual void OnLButtonDown(int mX, int mY); + + virtual void OnLButtonUp(int mX, int mY); + + virtual void OnRButtonDown(int mX, int mY); + + virtual void OnRButtonUp(int mX, int mY); + + virtual void OnMButtonDown(int mX, int mY); + + virtual void OnMButtonUp(int mX, int mY); + + virtual void OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value); + + virtual void OnJoyButtonDown(SDL_JoystickID which, Uint8 button); + + virtual void OnJoyButtonUp(SDL_JoystickID which, Uint8 button); + + virtual void OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value); + + virtual void OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel); + + virtual void OnMinimize(); + + virtual void OnRestore(); + + virtual void OnResize(int w, int h); + + virtual void OnExpose(); + + virtual void OnExit(); + + virtual void OnUser(Uint32 type, int code, void* data1, void* data2); + + private: + void OnWindowsEvent(const SDL_Event& event); + void OnMouseButtonDown(const SDL_Event& event); + void OnMouseButtonUp(const SDL_Event& event); + + private: + /// Variables + signed int m_id;// = 0 + GUIHelpers::eEventType m_eventType; + };/// END CLASS DEFINITION cGUIEvent +}/// END NAMESPACE DEFINITION GUIEventEngine +#endif/// END IFNDEF _CGUIEVENT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.cpp new file mode 100644 index 0000000..7c08242 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.cpp @@ -0,0 +1,42 @@ +#include "cGUIEventHandler.hpp" + +using GUIEventEngine::cGUIEventHandler; + +cGUIEventHandler::cGUIEventHandler() +{ +} + +cGUIEventHandler::~cGUIEventHandler() +{ + for (unsigned int i = 0; i < m_events.size(); ++i) { + delete m_events[i]; + m_events[i] = nullptr; + } + m_events.clear(); +} + +/// Functions +void cGUIEventHandler::CheckEvents() +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + std::vector::iterator it; + + for (it = m_events.begin(); it < m_events.end(); it++) { + (*it)->OnEvent(event); + } + } +} + +void cGUIEventHandler::AddEvents(GUIEventEngine::cGUIEvent* event ) +{ + m_events.push_back(event); +} + +/// Sets + +/// Gets +std::vector& cGUIEventHandler::getEvents() +{ + return m_events; +} diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.hpp new file mode 100644 index 0000000..8831f54 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIEventEngine/cGUIEventHandler.hpp @@ -0,0 +1,41 @@ +#ifndef _CGUIEVENTHANDLER_HPP_ +#define _CGUIEVENTHANDLER_HPP_ + +/*** C++ STL Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +#include "cGUIEvent.hpp" + +namespace GUIEventEngine { + class EXPORT_FROM_MYDLL cGUIEventHandler + { + public: + cGUIEventHandler(); + virtual ~cGUIEventHandler(); + + bool operator == (const cGUIEventHandler& other); + + /// Functions + virtual void CheckEvents(); + + void AddEvents( GUIEventEngine::cGUIEvent* event ); + + /// Sets + + /// Gets + std::vector& getEvents(); + + + + private: + /// Variables + std::vector m_events; + };/// END CLASS DEFINITION cGUIEvent +}/// END NAMESPACE DEFINITION GUIEventEngine +#endif/// END IFNDEF _CGUIEVENTHANDLER_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp index a0f113f..c1d2c09 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp @@ -42,5 +42,12 @@ namespace GUIHelpers { BOTTOM, LEFT };/// END enum DEFINITION eAlign + + enum EXPORT_FROM_MYDLL eEventType : unsigned int + { + DEFAULT_EVENT = 0, + /// cButton Press + BUTTON + };/// END enum DEFINITION eEventType }/// END NAMESPACE DEFINITION GUIEngine #endif/// END IFNDEF _ENUMS_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cGUIEvent.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cGUIEvent.hpp new file mode 100644 index 0000000..9ccf54f --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cGUIEvent.hpp @@ -0,0 +1,30 @@ +#ifndef _CGUIEVENT_HPP_ +#define _CGUIEVENT_HPP_ + +/*** Custom Header Files ***/ +#include "Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cGUIEvent + { + public: + cGUIEvent( const GUIHelpers::eEventType eventType ); + virtual ~cGUIEvent(); + + bool operator == ( const cGUIEvent& other ); + + /// Functions + + /// Sets + + /// Gets + + private: + /// Variables + GUIHelpers::eEventType m_eventType; + };/// END CLASS DEFINITION cGUIEvent +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CGUIEVENT_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp index 841f330..a220802 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp @@ -12,12 +12,10 @@ using MathEngine::iVector4; /*static*/ const cString cButton::sNAME = "button"; -cButton::cButton() -{} - cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align /*= sALIGN*/, const GUIHelpers::eLayout layout /*= sLAYOUT*/, const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/, const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ ) + : GUIEventEngine::cButtonEvent(id) { Create(parent, id, align, layout, pos, size, padding, name, image); // mp_texture = nullptr; @@ -57,7 +55,7 @@ void cButton::Display() m_sprite.setPosition(cWindow::getPosition()); m_sprite.Draw(); - m_sprite.SaveImage("test.bmp", "xml/"); + //m_sprite.SaveImage("test.bmp", "xml/"); cWindow::Display(); } diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp index 60e2c51..cc3a907 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp @@ -19,17 +19,16 @@ /*** Custom Header Files ***/ #include "cLayout.hpp" #include "../UtilityEngine/cString.hpp" -#include "../EventEngine/cEvent.hpp" +#include "GUIEventEngine/cButtonEvent.hpp" using UtilityEngine::cString; namespace GUIEngine { - class EXPORT_FROM_MYDLL cButton : public cLayout, public EventEngine::cEvent + class EXPORT_FROM_MYDLL cButton : public cLayout, public GUIEventEngine::cButtonEvent { public: static const cString sNAME; /*= "button";*/ - cButton(); cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign align = sALIGN, const GUIHelpers::eLayout layout = sLAYOUT, const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME, VideoEngine::cImage** image = nullptr ); @@ -53,7 +52,6 @@ namespace GUIEngine { virtual const GUIHelpers::RGBA& getDebugColour() const; private: - void CreateLabel(); void GenerateImage(); void GenerateTexture(); diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp index bdfd669..2b83c90 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp @@ -5,7 +5,6 @@ #include "../UtilityEngine/cUtility.hpp" #include "GUIHelpers/Enums.hpp" -#include "cButton.hpp" #include "GUIHelpers/cXMLoader.hpp" diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp deleted file mode 100644 index a2880a9..0000000 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "cTextButton.hpp" - -using GUIEngine::cTextButton; - -/*static*/ const cString cTextButton::sNAME = "textButton"; - -cTextButton::cTextButton( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align /*= GUIHelpers::eAlign::CENTER*/, - const GUIHelpers::eLayout layout /*= GUIHelpers::eLayout::FILL_PARENT*/, const GUIHelpers::Position& pos /*= POSITION*/, - const GUIHelpers::Size& size /*= SIZE*/, const GUIHelpers::Padding& padding /*= PADDING*/, const cString& name /*= NAME*/ ) - : m_label(this, -1, text) -{ - Create(parent, id, text, align, layout, pos, size, padding, name); -} - -/*virtual*/ cTextButton::~cTextButton() -{} - -///Functions -void cTextButton::Create( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align /*= GUIHelpers::eAlign::CENTER*/, - const GUIHelpers::eLayout layout /*= GUIHelpers::eLayout::FILL_PARENT*/, const GUIHelpers::Position& pos /*= POSITION*/, - const GUIHelpers::Size& size /*= SIZE*/, const GUIHelpers::Padding& padding /*= PADDING*/, const cString& name /*= NAME*/ ) -{ - cButton::Create(parent, id, align, layout, pos, size, padding, name); - setText(text); -} - -/// Sets -void cTextButton::setText( const cString& text ) -{ - m_label.setText(text); -} - -void cTextButton::setTextColour( const GUIHelpers::RGBA& colour ) -{ - m_label.setFontColour(colour); -} - -void cTextButton::setTextSize( const unsigned long int size ) -{ - m_label.setSize(size); -} - -/// Gets -const cString& cTextButton::getText() const -{ - return m_label.getText(); -} - -const GUIHelpers::RGBA& cTextButton::getTextColour() -{ - return m_label.getFontColour(); -} - -const unsigned long int cTextButton::getTextSize() -{ - return m_label.getFontSize(); -} - -/*virtual*/ const GUIHelpers::eType cTextButton::getType() const -{ - return GUIHelpers::eType::CTEXTBUTTON; -} - -/// Private -void CreateLabel() -{} - -void GenerateImage() -{} - -void GenerateTexture() -{} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp deleted file mode 100644 index c959c64..0000000 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _CTEXTBUTTON_HPP_ -#define _CTEXTBUTTON_HPP_ - -/*** SDL Header Files ***/ -#include - -/*** Custom Header Files ***/ -#include "cButton.hpp" -#include "cLabel.hpp" - -#include "GUIHelpers/Enums.hpp" -#include "GUIHelpers/GUIUtility.hpp" -#include "../VideoEngine/cSprite.hpp" -#include "../VideoEngine/cImage.hpp" -#include "../MathEngine/iVector/iVector2.hpp" - -/*** DLL Header File ***/ -#include "dllExport.h" - -/*** Custom Header Files ***/ -#include "../UtilityEngine/cString.hpp" - -using UtilityEngine::cString; - -namespace GUIEngine { - class EXPORT_FROM_MYDLL cTextButton : public cButton - { - public: - static const cString sNAME; /*= "button";*/ - - cTextButton( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align = GUIHelpers::eAlign::CENTER, - const GUIHelpers::eLayout layout = GUIHelpers::eLayout::FILL_PARENT, const GUIHelpers::Position& pos = sPOSITION, - const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME ); - virtual ~cTextButton(); - - /// Functions - void Create( cWindow* parent, const signed int id, const cString& text, const GUIHelpers::eAlign align = GUIHelpers::eAlign::CENTER, - const GUIHelpers::eLayout layout = GUIHelpers::eLayout::FILL_PARENT, const GUIHelpers::Position& pos = sPOSITION, - const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME ); - - /// Sets - void setText( const cString& text ); - void setTextColour( const GUIHelpers::RGBA& colour ); - void setTextSize( const unsigned long int size ); - - /// Gets - const cString& getText() const; - const GUIHelpers::RGBA& getTextColour(); - const unsigned long int getTextSize(); - - virtual const GUIHelpers::eType getType() const; - - private: - void CreateLabel(); - void GenerateImage(); - void GenerateTexture(); - - private: - /// Variables - cLabel m_label;/// = nullptr - };/// END CLASS DEFINITION cButton -}/// END NAMESPACE DEFINITION GUIEngine -#endif/// END IFNDEF _CBUTTON_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.cpp index 392c3d7..af4af60 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.cpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.cpp @@ -1,6 +1,5 @@ #include "cWindow.hpp" - #include "../FXEngine/cGFX.hpp" #include "../UtilityEngine/cUtility.hpp" @@ -257,6 +256,21 @@ const GUIHelpers::Size cWindow::getSize( const bool pad /*= true*/ ) const return rtn; } +const GUIHelpers::Area cWindow::getArea( const bool pad /*= false*/ ) const +{ + GUIHelpers::Area rtn = { 0, 0, 0, 0 }; + + GUIHelpers::Position tmp = getPosition(false); + rtn.x = tmp.x; + rtn.y = tmp.y; + + GUIHelpers::Size tmp2 = getSize(false); + rtn.w = tmp2.x; + rtn.h = tmp2.y; + + return rtn; +} + const GUIHelpers::Padding& cWindow::getPadding() const { return m_padding; diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp index 75f5493..83e4071 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp @@ -1,6 +1,9 @@ #ifndef _CWINDOW_HPP_ #define _CWINDOW_HPP_ +/*** C++ STL Files ***/ +#include + /*** SDL Header Files ***/ #include @@ -53,7 +56,7 @@ namespace GUIEngine { void AddChild( cWindow* obj ); const bool RemoveChild( cWindow* obj ); - + /// Sets static void PositionDefault( const GUIHelpers::Position& pos ); static void SizeDefault( const GUIHelpers::Size& size ); @@ -81,6 +84,7 @@ namespace GUIEngine { const GUIHelpers::eLayout getLayout() const; const GUIHelpers::Position getPosition( const bool pad = true ) const; const GUIHelpers::Size getSize( const bool pad = true ) const; + const GUIHelpers::Area getArea( const bool pad = false ) const; const GUIHelpers::Padding& getPadding() const; const GUIHelpers::Size& getContentSize() const; const cString& getName() const; diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.cpp new file mode 100644 index 0000000..71d6c43 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.cpp @@ -0,0 +1,136 @@ +#include "cInside.hpp" + +using MathEngine::cInside; +using MathEngine::Vector4; +using MathEngine::Vector2; +using MathEngine::iVector4; +using MathEngine::iVector2; + +cInside::cInside() +{ +} + +cInside::~cInside() +{ +} + +/// Functions +/*static*/ const Vector2 cInside::Inside(const Vector4& a, const Vector4& b) +{ + Vector2 rtn; + rtn.x = 0.0f; + rtn.y = 0.0f; + + /// Check if left side of b is inside of a + if (b.x < a.x) + rtn.x = a.x - b.x; + /// Check if right side of b is inside of a + if ((b.x + b.z) > (a.x + a.z)) + rtn.x = (a.x + a.z) - (b.x + b.z); + /// Check if top side of b is inside of a + if (b.y < a.y) + rtn.y = a.y - b.y; + /// Check if bottom side of b is inside of a + if ((b.y + b.w) > (a.y + a.w)) + rtn.y = (a.y + a.w) - (b.y + b.w); + + return rtn; +} + +/*static*/ const Vector2 cInside::Inside(const SDL_Rect& a, const Vector4& b) +{ + Vector4 temp = a; + + return cInside::Inside(temp, b); +} + +/*static*/ const Vector2 cInside::Inside(const Vector4& a, const SDL_Rect& b) +{ + Vector4 temp = b; + + return cInside::Inside(a, temp); +} + +/*static*/ const bool cInside::isInside(const signed long int x, const signed long int y, const SDL_Rect& inside) +{ + iVector4 temp = inside; + return cInside::isInside(x, y, temp); +} + +/*static*/ const bool cInside::isInside(const signed long int x, const signed long int y, const iVector4& inside) +{ + bool rtn = false; + if ((inside.x < x) && (inside.w > x)) { + if ((inside.y < y) && (inside.z > y)) + rtn = true; + } + return rtn; +} + +/*static*/ const iVector2 cInside::Inside(const SDL_Rect& a, const SDL_Rect& b) +{ + iVector2 rtn; + rtn.x = 0.0f; + rtn.y = 0.0f; + + /// Check if left side of b is inside of a + if (b.x < a.x) + rtn.x = (float)(b.x - a.x); + /// Check if right side of b is inside of a + if ((b.x + b.w) > (a.x + a.w)) + rtn.x = (float)((b.x + b.w) - (a.x + a.w)); + /// Check if top side of b is inside of a + if (b.y < a.y) + rtn.y = (float)(b.y - a.y); + /// Check if bottom side of b is inside of a + if ((b.y + b.h) > (a.y + a.h)) + rtn.y = (float)((b.y + b.h) - (a.y + a.h)); + + return rtn; +} + +/*static*/ const iVector2 cInside::Inside(const iVector4& a, const iVector4& b) +{ + iVector2 rtn; + rtn.x = 0; + rtn.y = 0; + + /// Check if left side of b is inside of a + if (b.x < a.x) + rtn.x = b.x - a.x; + /// Check if right side of b is inside of a + if ((b.x + b.z) > (a.x + a.z)) + rtn.x = (b.x + b.z) - (a.x + a.z); + /// Check if top side of b is inside of a + if (b.y < a.y) + rtn.y = b.y - a.y; + /// Check if bottom side of b is inside of a + if ((b.y + b.w) > (a.y + a.w)) + rtn.y = (b.y + b.w) - (a.y + a.w); + + return rtn; +} + +/*static*/ const iVector2 cInside::Inside(const SDL_Rect& a, const iVector4& b) +{ + iVector4 temp = a; + + return cInside::Inside(temp, b); +} + +/*static*/ const iVector2 cInside::Inside(const iVector4& a, const SDL_Rect& b) +{ + return cInside::Inside(b, a); +} + +/*static*/ const Vector2 cInside::Inside(const iVector4& a, const Vector4& b) +{ + Vector4 temp = a; + + return cInside::Inside(temp, b); +} + +/*static*/ const Vector2 cInside::Inside(const Vector4& a, const iVector4& b) +{ + return cInside::Inside(b, a); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.hpp new file mode 100644 index 0000000..cdfbcaf --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cInside.hpp @@ -0,0 +1,51 @@ +#ifndef _CINSIDE_HPP_ +#define _CINSIDE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "Vector/Vector2.hpp" +#include "iVector/iVector2.hpp" + +#include "Vector/Vector4.hpp" +#include "iVector/iVector4.hpp" + +namespace MathEngine { + class EXPORT_FROM_MYDLL cInside + { + private: + cInside(); + ~cInside(); + + public: + /// Functions + /* returns the Vector2 were a over laps b */ + static const Vector2 Inside(const Vector4& a, const Vector4& b); + /* returns the Vector2 were a over laps b */ + static const Vector2 Inside(const SDL_Rect& a, const Vector4& b); + /* returns the Vector2 were a over laps b */ + static const Vector2 Inside(const Vector4& a, const SDL_Rect& b); + + /* returns true if xy are inside SDL_Rect */ + static const bool isInside(const signed long int x, const signed long int y, const SDL_Rect& inside); + /* returns true if xy are inside iVector4 */ + static const bool isInside(const signed long int x, const signed long int y, const iVector4& inside); + + /* returns the iVector2 were a over laps b */ + static const iVector2 Inside(const SDL_Rect& a, const SDL_Rect& b); + /* returns the iVector2 were a over laps b */ + static const iVector2 Inside(const iVector4& a, const iVector4& b); + /* returns the iVector2 were a over laps b */ + static const iVector2 Inside(const SDL_Rect& a, const iVector4& b); + /* returns the iVector2 were a over laps b */ + static const iVector2 Inside(const iVector4& a, const SDL_Rect& b); + + static const Vector2 Inside(const iVector4& a, const Vector4& b); + static const Vector2 Inside(const Vector4& a, const iVector4& b); + };/// END CLASS DEFINITION cInside +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _CINSIDE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngineDLL.vcxproj b/TrooperEngineDLL/TrooperEngineDLL.vcxproj index b565c63..7b3a589 100644 --- a/TrooperEngineDLL/TrooperEngineDLL.vcxproj +++ b/TrooperEngineDLL/TrooperEngineDLL.vcxproj @@ -132,8 +132,11 @@ - + + + + @@ -146,6 +149,7 @@ + @@ -184,8 +188,10 @@ - + + + @@ -197,6 +203,7 @@ + diff --git a/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters b/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters index 22910e5..83f60c5 100644 --- a/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters +++ b/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters @@ -58,6 +58,9 @@ {b13cf78d-bfda-4467-9cdc-79dcb63fd8a9} + + {ecc37f2c-0d3c-425e-9db6-deed712faacd} + @@ -198,9 +201,6 @@ TrooperEngine\GUIEngine - - TrooperEngine\GUIEngine - TrooperEngine\GUIEngine\GUIHelpers @@ -219,6 +219,21 @@ TrooperEngine\GUIEngine + + TrooperEngine\GUIEngine\GUIEventEngine + + + TrooperEngine\MathEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + @@ -344,9 +359,6 @@ TrooperEngine\GUIEngine - - TrooperEngine\GUIEngine - TrooperEngine\GUIEngine\GUIHelpers @@ -368,5 +380,17 @@ TrooperEngine\GUIEngine + + TrooperEngine\MathEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + + + TrooperEngine\GUIEngine\GUIEventEngine + \ No newline at end of file diff --git a/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp b/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp index 5ebd9dc..b9bc606 100644 --- a/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp +++ b/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp @@ -70,7 +70,6 @@ #include "../TrooperEngine/GUIEngine/cLayout.hpp" #include "../TrooperEngine/GUIEngine/cLabel.hpp" #include "../TrooperEngine/GUIEngine/cButton.hpp" -#include "../TrooperEngine/GUIEngine/cTextButton.hpp" #include "../TrooperEngine/GUIEngine/cSizer.hpp" /*** GUIHelper ***/ diff --git a/TrooperEngineTest/xml/test.bmp b/TrooperEngineTest/xml/test.bmp new file mode 100644 index 0000000..e696a60 Binary files /dev/null and b/TrooperEngineTest/xml/test.bmp differ