diff --git a/.svn/entries b/.svn/entries new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/.svn/entries @@ -0,0 +1 @@ +12 diff --git a/.svn/format b/.svn/format new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/.svn/format @@ -0,0 +1 @@ +12 diff --git a/.svn/pristine/00/000a87347b31e15fa3b700f0a15e5aa8a6d0c857.svn-base b/.svn/pristine/00/000a87347b31e15fa3b700f0a15e5aa8a6d0c857.svn-base new file mode 100644 index 0000000..7ee78a7 --- /dev/null +++ b/.svn/pristine/00/000a87347b31e15fa3b700f0a15e5aa8a6d0c857.svn-base @@ -0,0 +1,101 @@ +#include "cGFX.hpp" + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using FXEngine::cGFX; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cGFX* cGFX::sp_inst = nullptr; + +//private: +cGFX::cGFX() +{} + +cGFX::~cGFX() +{} + +//public: +///Functions +/*static*/ cGFX& cGFX::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGFX(); + return *sp_inst; +} + +/*static*/ void cGFX::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const +{ + if (stringRGBA(cRenderer::Inst().getRenderer(), (Sint16)pos.x, (Sint16)pos.y, text.c_str(), colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + StringDefault(text, pos, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Box(const SDL_Rect& rect, const SDL_Colour& colour) const +{ + if (boxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. boxRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Box(const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Box(rect, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const +{ + if (roundedBoxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, (Sint16)rad, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. roundedBoxRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + RoundedBox(rect, rad, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour) const +{ + if (pixelRGBA(cRenderer::Inst().getRenderer(), (Sint16)x, (Sint16)y, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. pixelRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Pixel(x, y, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour) const +{ + if (rectangleRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. rectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Rectangle(rect, colour); + cRenderer::Inst().ResetRenderTarget(); +} \ No newline at end of file diff --git a/.svn/pristine/00/0034f153fbdb8a0380b88576ce13105b6ebb8f7f.svn-base b/.svn/pristine/00/0034f153fbdb8a0380b88576ce13105b6ebb8f7f.svn-base new file mode 100644 index 0000000..df94b87 --- /dev/null +++ b/.svn/pristine/00/0034f153fbdb8a0380b88576ce13105b6ebb8f7f.svn-base @@ -0,0 +1,275 @@ +#include "cWindow.hpp" + +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RBGA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; + +cWindow::cWindow(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, 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*/ ) + : mp_parent(parent), GUIHelpers::cObject(id), m_align(align), m_layout(layout), m_pos(pos), m_size(size), m_content(size), m_padding(padding), m_name(name) +{ +// if (mp_parent != nullptr) { +// switch (this->getType()) { +// case GUIHelpers::eType::CLABEL: +// mp_parent->AddChild((cLabel*)this); +// break; +// case GUIHelpers::eType::CLAYOUT: +// mp_parent->AddChild((cLayout*)this); +// break; +// } +// } +} + +/*virtual*/ cWindow::~cWindow() +{ + m_children.clear(); +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } +} + +///Functions +const bool cWindow::Inside(const MathEngine::iVector2& location) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild(cWindow* obj) +{ + //m_obj = obj; + m_children.push_back(obj); +} + +void cWindow::RemoveChild(cWindow* obj) +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + //break out of the for loop + break; + } + } +} + +void cWindow::AddSizeX(const unsigned long int x) +{ + m_size.x += x; +} + +void cWindow::AddSizeY(const unsigned long int y) +{ + m_size.y += y; +} + +///Sets +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/) +{ + m_align = align; +} + +void cWindow::setLayout(const GUIHelpers::eLayout& layout /*= GUIHelpers::eLayout::FILL_PARENT*/) +{ + m_layout = layout; +} + +void cWindow::setPosition(const GUIHelpers::Position& pos /*= POSITION*/) +{ + m_pos = pos; +} + +void cWindow::setSize(const GUIHelpers::Size& size /*= SIZE*/) +{ + m_size = size; + this->Resize(); +} + +void cWindow::setPadding(const GUIHelpers::Padding& padding/* = PADDING*/) +{ + m_padding = padding; +} + +void cWindow::setContentSize(const GUIHelpers::Size& content) +{ + m_content = content; +} + +void cWindow::setName(const cString& name /*= NAME*/) +{ + m_name = name; +} + + +void cWindow::setParent(cWindow* parent) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position& cWindow::getPosition() const +{ + return m_pos; +} + +const GUIHelpers::Size& cWindow::getSize() const +{ + return m_size; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + GUIHelpers::Size mySize = (0, 0); + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + mySize = mp_parent->getSize(); + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + } else { + mySize = GUIEngine::cGUI::Inst().DisplayArea(); + } + + m_size = mySize; + + for (it = m_children.begin(); it < m_children.end(); it++) { + //if ((*it)->getLayout() != GUIHelpers::eLayout::WRAP_CONTENT) + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + GUIHelpers::Padding pad = { 0, 0, 0, 0 }; + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + pad = (*it)->getPadding(); + size.x += pad.x + pad.w; + size.y += pad.y + pad.z; + mySize += size; + //AddSize(size.x, size.y, mySize); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ + if (mp_parent != nullptr) + RebuildPos(); + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } +} + +/*virtual*/ void cWindow::RebuildPos() +{ + GUIHelpers::Size prtSize = mp_parent->getSize(); + GUIHelpers::Position prtCenter = { (prtSize.x / 2), (prtSize.y / 2) }; + + GUIHelpers::Size ourSize = this->getSize(); + GUIHelpers::Position ourCenter = { (ourSize.x / 2), (ourSize.y / 2) }; + + GUIHelpers::Position ourSet = { 0, 0 }; + + switch (this->getAlign()) { + case GUIHelpers::eAlign::CENTER: + ourSet.x = prtCenter.x - ourCenter.x; + ourSet.y = prtCenter.y - ourCenter.y; + this->setPosition(ourSet); + break; + case GUIHelpers::eAlign::TOP: + break; + case GUIHelpers::eAlign::RIGHT: + break; + case GUIHelpers::eAlign::BOTTOM: + break; + case GUIHelpers::eAlign::LEFT: + break; + } +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} \ No newline at end of file diff --git a/.svn/pristine/01/01f6cfd98cf54fc69d9a3d2cfbd70abbbe21743c.svn-base b/.svn/pristine/01/01f6cfd98cf54fc69d9a3d2cfbd70abbbe21743c.svn-base new file mode 100644 index 0000000..fe20350 --- /dev/null +++ b/.svn/pristine/01/01f6cfd98cf54fc69d9a3d2cfbd70abbbe21743c.svn-base @@ -0,0 +1,41 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +/*virtual*/ void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + cWindow::Create(parent, id, orientation, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set + +///Get + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} \ No newline at end of file diff --git a/.svn/pristine/02/0234c1fd95494e9c362365ed31e7db9cf7504732.svn-base b/.svn/pristine/02/0234c1fd95494e9c362365ed31e7db9cf7504732.svn-base new file mode 100644 index 0000000..fd85e0b --- /dev/null +++ b/.svn/pristine/02/0234c1fd95494e9c362365ed31e7db9cf7504732.svn-base @@ -0,0 +1,31 @@ + + + + + {549e0f16-9635-455e-b19a-4a887771cf5d} + + + {50a06b19-0711-478a-a15e-df325d10bebc} + + + {3305ea52-bd3f-4a02-a012-eb2923a77dbf} + + + + + UTest + + + UtitlityEngineTest + + + + + UTest + + + + UtitlityEngineTest + + + \ No newline at end of file diff --git a/.svn/pristine/03/03d3ab8f5ee5863c2a14f0b20fe713807dbcd18a.svn-base b/.svn/pristine/03/03d3ab8f5ee5863c2a14f0b20fe713807dbcd18a.svn-base new file mode 100644 index 0000000..f3cc21e --- /dev/null +++ b/.svn/pristine/03/03d3ab8f5ee5863c2a14f0b20fe713807dbcd18a.svn-base @@ -0,0 +1,43 @@ +#ifndef _CGFX_HPP_ +#define _CGFX_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace EXPORT_FROM_MYDLL FXEngine { + /* Singleton */ + class cGFX + { + private: + cGFX(); + ~cGFX(); + + public: + static cGFX& Inst(); + static void Delete(); + + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const; + void RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const; + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const; + void Rectangle (const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + + private: + static cGFX* sp_inst;// = nullptr + };/// END CLASS DEFINITION cGFX +}/// END NAMESPACE DEFINITION FXEngine +#endif/// END IFNDEF _CGFX_HPP_ \ No newline at end of file diff --git a/.svn/pristine/04/042698b3d112246dabec525a25ea1de3c610c6d2.svn-base b/.svn/pristine/04/042698b3d112246dabec525a25ea1de3c610c6d2.svn-base new file mode 100644 index 0000000..9060457 --- /dev/null +++ b/.svn/pristine/04/042698b3d112246dabec525a25ea1de3c610c6d2.svn-base @@ -0,0 +1,30 @@ +#include "cPlayerDown.hpp" + +using Input::cPlayerDown; + +cPlayerDown::cPlayerDown( SDL_Keycode key, Equipment::cPaddle** player ) +: cKey( key ), mpp_player(player) +{} + +cPlayerDown::~cPlayerDown() +{} + +///Funtions +void cPlayerDown::KeyPress() +{} + +void cPlayerDown::KeyUP() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + { + if ((*mpp_player)->getState() == Equipment::cPaddle::Down) + (*mpp_player)->setState(Equipment::cPaddle::Still); + } + +} + +void cPlayerDown::KeyDown() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + (*mpp_player)->setState(Equipment::cPaddle::Down); +} \ No newline at end of file diff --git a/.svn/pristine/04/04dfa028e18a4b0ad0918ce5fc29e3bc4a1e9ca5.svn-base b/.svn/pristine/04/04dfa028e18a4b0ad0918ce5fc29e3bc4a1e9ca5.svn-base new file mode 100644 index 0000000..9f29440 --- /dev/null +++ b/.svn/pristine/04/04dfa028e18a4b0ad0918ce5fc29e3bc4a1e9ca5.svn-base @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/.svn/pristine/05/054aee298ac4201969b2e1c3c41ea1762ba34fa2.svn-base b/.svn/pristine/05/054aee298ac4201969b2e1c3c41ea1762ba34fa2.svn-base new file mode 100644 index 0000000..c48b3d3 --- /dev/null +++ b/.svn/pristine/05/054aee298ac4201969b2e1c3c41ea1762ba34fa2.svn-base @@ -0,0 +1,50 @@ +#ifndef _CCOLLISION_HPP_ +#define _CCOLLISION_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 cCollision + { + private: + cCollision(); + ~cCollision(); + public: + ///Functions + static const bool BoundingBox( const SDL_Rect& a, const SDL_Rect& b ); + static const bool BoundingBox( const Vector4& a, const Vector4& b ); + static const bool BoundingBox( const SDL_Rect& a, const Vector4& b ); + static const bool BoundingBox( const Vector4& a, const SDL_Rect& b ); + + static const bool BoundingBox( const iVector4& a, const iVector4& b ); + static const bool BoundingBox( const SDL_Rect& a, const iVector4& b ); + static const bool BoundingBox( const iVector4& a, const SDL_Rect& b ); + static const bool BoundingBox( const iVector4& a, const Vector4& b ); + static const bool BoundingBox( const Vector4& a, const iVector4& b ); + + + static const Vector2 Inside( const SDL_Rect& a, const SDL_Rect& b ); + static const Vector2 Inside( const Vector4& a, const Vector4& b ); + static const Vector2 Inside( const SDL_Rect& a, const Vector4& b ); + static const Vector2 Inside( const Vector4& a, const SDL_Rect& b ); + + static const iVector2 Inside( const iVector4& a, const iVector4& b ); + static const iVector2 Inside( const SDL_Rect& a, const iVector4& 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 cCollision +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _CCOLLISION_HPP_ diff --git a/.svn/pristine/05/05b383bb9cfdcbc0b7c976a152b6e3bdae3bbc1b.svn-base b/.svn/pristine/05/05b383bb9cfdcbc0b7c976a152b6e3bdae3bbc1b.svn-base new file mode 100644 index 0000000..1783d14 --- /dev/null +++ b/.svn/pristine/05/05b383bb9cfdcbc0b7c976a152b6e3bdae3bbc1b.svn-base @@ -0,0 +1,18 @@ +#ifndef _EOPTIONS_HPP_ +#define _EOPTIONS_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace MainMenu { + enum eOptions + { + Start, + Head, + Quit + };/// END ENUM DEFINITION eOptions + + void operator++(eOptions& option); + void operator--(eOptions& option); +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _EOPTIONS_HPP_ \ No newline at end of file diff --git a/.svn/pristine/07/0747d792ee9f154212480ff353feded163224abc.svn-base b/.svn/pristine/07/0747d792ee9f154212480ff353feded163224abc.svn-base new file mode 100644 index 0000000..973e81b --- /dev/null +++ b/.svn/pristine/07/0747d792ee9f154212480ff353feded163224abc.svn-base @@ -0,0 +1,92 @@ +#ifndef _CTEXT_HPP_ +#define _CTEXT_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** VideoEngine ***/ +#include "../VideoEngine/cImage.hpp" + +/*** TextTypeEngine ***/ +#include "cFont.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace TextTypeEngine { + class EXPORT_FROM_MYDLL cText : public VideoEngine::cImage + { + public: + enum eRender: unsigned int + { + Solid = 0, + Shaded, + Blended + }; + public: + cText( const cString& text, const unsigned long int size = 16 ); + cText( SDL_Colour& colour, TextTypeEngine::cFont** font = nullptr, const cString& text = "", const unsigned long int size = 16, const eRender& render = eRender::Solid ); + cText( TextTypeEngine::cFont** font = nullptr, const cString& text = "", const unsigned long int size = 16, + const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0, const eRender& render = eRender::Solid ); + cText( const cText& copy ); + ~cText(); + + + ///Function + + /* Change the colour of the text to White */ + void White(); + /* Change the colour of the text to Black */ + void Black(); + /* Change the colour of the text to Blue */ + void Blue(); + /* Change the colour of the text to Green */ + void Green(); + /* Change the colour of the text to Red */ + void Red(); + + ///Sets + /* Sets the Size */ + void setSize( const unsigned long int size = 16 ); + void setFont( cFont** font ); + /* Sets the text to be printed */ + void setText( const cString& text ); + /* Sets the colour of the text via SDL_Colour. */ + void setColour( const SDL_Colour& colour ); + /* Sets the colour of the text via RGB. Default is Black */ + void setColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0, unsigned long int alpha = 255 ); + /* Sets the render of the text. Default is Solid */ + void setRender( const eRender& render = eRender::Solid ); + + ///Gets + /* Gets the Size */ + const unsigned long int getSize() const; + cFont* getFont() const; + /* Gets the text to be printed. */ + const cString& getText() const; + /* Gets the SDL_Colour of the text */ + const SDL_Colour& getColour() const; + /* Gets the RGB of the text. */ + void getColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue, unsigned long int& alpha ) const; + /* Gets the render of the text. */ + const eRender& getRender() const; + + private: + void Text(); + + private: + TextTypeEngine::cFont** mpp_font; + cString m_text;// = "" + + unsigned long int m_size;// = 16 + SDL_Colour m_colour;// = nullptr + eRender m_render;// = Solid + };/// END CLASS DEFINITION cText +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CTEXT_HPP_ diff --git a/.svn/pristine/08/080a680f16ad3a416b239adf731cd14097076453.svn-base b/.svn/pristine/08/080a680f16ad3a416b239adf731cd14097076453.svn-base new file mode 100644 index 0000000..55ac022 --- /dev/null +++ b/.svn/pristine/08/080a680f16ad3a416b239adf731cd14097076453.svn-base @@ -0,0 +1,6 @@ +#ifndef __STRINGTEST__ +#define __STRINGTEST__ + +void StringTest(); + +#endif // __STRINGTEST__ diff --git a/.svn/pristine/0a/0ade4763b87677c6644264ef6a93208a30daefa0.svn-base b/.svn/pristine/0a/0ade4763b87677c6644264ef6a93208a30daefa0.svn-base new file mode 100644 index 0000000..1438417 --- /dev/null +++ b/.svn/pristine/0a/0ade4763b87677c6644264ef6a93208a30daefa0.svn-base @@ -0,0 +1,151 @@ +#include "cTrooperEngineCore.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" +#include "../AudioEngine/cAudio.hpp" +#include "../InputEngine/cInput.hpp" + +#include "../TimingEngine/cTiming.hpp" + +#include "../TextTypeEngine/cTextType.hpp" + +#include "../MathEngine/cRandom.hpp" + +#include "../EventEngine/cEvent.hpp" + +#include "../UtilityEngine/cUtility.hpp" + +#include "../GUIEngine/cGUI.hpp" + +using TrooperEngineCore::cTrooperEngineCore; + +/*static*/ cTrooperEngineCore* cTrooperEngineCore::sp_inst = nullptr; + +cTrooperEngineCore::cTrooperEngineCore() +{ +} + +cTrooperEngineCore::~cTrooperEngineCore() +{ + CleanUp(); + VideoEngine::cVideo::Delete(); + AudioEngine::cAudio::Delete(); + InputEngine::cInput::Delete(); + TimingEngine::cTiming::Delete(); + + TextTypeEngine::cTextType::Delete(); + MathEngine::cRandom::Delete(); + EventEngine::cEvent::Delete(); + SDL_Quit(); + UtilityEngine::cUtility::Inst().Message("SDL shut down!"); + UtilityEngine::cUtility::Delete(); + + GUIEngine::cGUI::Delete(); +} + +///Functions +/*static*/ const char* cTrooperEngineCore::Version() +{ + return __TROOPERENGINE__VERSION; +} + +/*static*/ cTrooperEngineCore& cTrooperEngineCore::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTrooperEngineCore(); + return *sp_inst; +} + +/*static*/ void cTrooperEngineCore::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTrooperEngineCore::VideoInit() +{ + return VideoEngine::cVideo::Inst().Initialize(); +} + +const bool cTrooperEngineCore::AudioInit() +{ + return AudioEngine::cAudio::Inst().Initialize(); +} + +const bool cTrooperEngineCore::InputInit() +{ + return true; +} + +const bool cTrooperEngineCore::JoystickInit() +{ + return InputEngine::cInput::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TimerInit() +{ + return TimingEngine::cTiming::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TextTypeInit() +{ + return TextTypeEngine::cTextType::Inst().Initialize(); +} + +const bool cTrooperEngineCore::EventInit() +{ + return EventEngine::cEvent::Inst().Initialize(); +} + +/* Print lib versions */ +void cTrooperEngineCore::PrintSDLVersion() const +{ + UtilityEngine::cUtility::Inst().PrintVersion(); +} + +void cTrooperEngineCore::CleanUp() +{ + VideoEngine::cVideo::Inst().CleanUp(); + AudioEngine::cAudio::Inst().CleanUp(); + TimingEngine::cTiming::Inst().CleanUp(); + TextTypeEngine::cTextType::Inst().CleanUp(); + InputEngine::cInput::Inst().CleanUp(); + EventEngine::cEvent::Inst().CleanUp(); +} + +///Gets +const bool cTrooperEngineCore::getVideo() const +{ + return VideoEngine::cVideo::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getAudio() const +{ + return AudioEngine::cAudio::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getInput() const +{ + return InputEngine::cInput::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getJoystick() const +{ + return false; +} + +const bool cTrooperEngineCore::getTimer() const +{ + return TimingEngine::cTiming::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getText() const +{ + return TextTypeEngine::cTextType::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getEvent() const +{ + return EventEngine::cEvent::Inst().IsInit(); +} + diff --git a/.svn/pristine/0b/0b22d86a6ce3d10e9b67f477fef99acdace6aacf.svn-base b/.svn/pristine/0b/0b22d86a6ce3d10e9b67f477fef99acdace6aacf.svn-base new file mode 100644 index 0000000..6f2a6d0 --- /dev/null +++ b/.svn/pristine/0b/0b22d86a6ce3d10e9b67f477fef99acdace6aacf.svn-base @@ -0,0 +1,31 @@ +#ifndef _CESC_HPP_ +#define _CESC_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cEsc : public InputEngine::cKey + { + public: + cEsc( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuUp& copy ); + ~cEsc(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cEsc +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CESC_HPP_ \ No newline at end of file diff --git a/.svn/pristine/0c/0c186beef8b572b62e86fbce7b19d8eecb50a703.svn-base b/.svn/pristine/0c/0c186beef8b572b62e86fbce7b19d8eecb50a703.svn-base new file mode 100644 index 0000000..a1a7e6a --- /dev/null +++ b/.svn/pristine/0c/0c186beef8b572b62e86fbce7b19d8eecb50a703.svn-base @@ -0,0 +1,193 @@ +#include "cGUI.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" + +#include "../UtilityEngine/cUtility.hpp" +#include "GUIHelpers/Enums.hpp" +#include "cButton.hpp" + +#include "GUIHelpers/cXMLoader.hpp" + +using GUIEngine::cGUI; +using GUIEngine::cWindow; +using UtilityEngine::cUtility; + +/*static*/ cGUI* cGUI::sp_inst = nullptr; + +//private +cGUI::cGUI() + : mp_font(nullptr), m_inited(false) +{ + setTextColour(); + setPadding(); +} + +cGUI::~cGUI() +{ + delete mp_font; + mp_font = nullptr; + + m_guiObjects.clear(); +} + +//public: +///Functions +/*static*/ cGUI& cGUI::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGUI(); + return *sp_inst; +} + +/*static*/ void cGUI::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cGUI::Initialize( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +{ + bool rtn = IsInit(); + + GUIHelpers::cXMLoader::Inst().Load(filename, dir); +// if (rtn == false) { +// setFont( filename, dir, size ); +// cUtility::Inst().Message("GUI initialized."); +// } + + return rtn; +} + +void cGUI::Event(const MathEngine::iVector2& location, const eGUIEventType& type) +{ + location; + type; +// std::vector::iterator it; +// +// for (it = m_objects.begin(); it < m_objects.end(); it++) { +// switch ((*it)->getType()) { +// case GUIHelpers::eType::CBUTTON: +// cButton* tmp = (cButton*)(*it); +// if (tmp->InSide(location) == true) +// cUtility::Inst().Message("Button Inside!"); +// break; +// } +// } +} + +const MathEngine::iVector2 cGUI::DisplayArea() const +{ + MathEngine::iVector2 rtn = { 0, 0 }; + rtn.x = VideoEngine::cVideo::Inst().getWidth(); + rtn.y = VideoEngine::cVideo::Inst().getHeight(); + + return rtn; +} + +void cGUI::AddObject(cWindow* obj) +{ + //this->m_obj = obj; + m_guiObjects.push_back(obj); +} + +void cGUI::Display() +{ + //m_obj->Display(); + std::vector::iterator it; + + for (it = m_guiObjects.begin(); it < m_guiObjects.end(); it++) { + (*it)->Display(); + } +} + +///Sets +void cGUI::setFont( TextTypeEngine::cFont* font ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = font; +} + +void cGUI::setFont( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont( dir, filename, size ); +} + +void cGUI::setTextColour( const GUIHelpers::RGBA& colour ) +{ + cWindow::sCOLOUR = colour; +} + +void cGUI::setTextColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/ ) +{ + GUIHelpers::RGBA colour = {Uint8(red), Uint8(green), Uint8(blue)}; + setTextColour(colour); +} + +void cGUI::setPadding( const GUIHelpers::Padding& padding ) +{ + cWindow::sPADDING = padding; +} + +void cGUI::setPadding( const unsigned int top /*= 5*/, const unsigned int right /*= 5*/, const unsigned int bottom /*= 5*/, const unsigned int left /*= 5*/ ) +{ + setPadding(GUIHelpers::Padding(top, right, bottom, left)); +} + +void cGUI::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/ ) +{ + cWindow::sALIGN = align; +} + +///Gets +TextTypeEngine::cFont* cGUI::getFont() +{ + return mp_font; +} + +const GUIHelpers::RGBA& cGUI::getTextColour() const +{ + return cWindow::sCOLOUR; +} + +void cGUI::getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const +{ + red = cWindow::sCOLOUR.r; + green = cWindow::sCOLOUR.g; + blue = cWindow::sCOLOUR.b; +} + +const GUIHelpers::Padding& cGUI::getPadding() const +{ + return cWindow::sPADDING; +} + +void cGUI::getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const +{ + top = cWindow::sPADDING.x; + right = cWindow::sPADDING.y; + bottom = cWindow::sPADDING.z; + left = cWindow::sPADDING.w; +} + +const GUIHelpers::eAlign& cGUI::getAlign() const +{ + return cWindow::sALIGN; +} + +const bool cGUI::IsInit() const +{ + bool rtn = m_inited; + + if (rtn == true) + cUtility::Inst().Message("GUI is initialized."); + else + cUtility::Inst().Message("GUI is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/0e/0e592e788d387dc611c68ddfb6b327b71d5a19b0.svn-base b/.svn/pristine/0e/0e592e788d387dc611c68ddfb6b327b71d5a19b0.svn-base new file mode 100644 index 0000000..3543bd2 --- /dev/null +++ b/.svn/pristine/0e/0e592e788d387dc611c68ddfb6b327b71d5a19b0.svn-base @@ -0,0 +1,116 @@ +#ifndef _CSPRITE_HPP_ +#define _CSPRITE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cImage.hpp" +#include "cCamera.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../MathEngine/iVector/iVector2.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "../UtilityEngine/cString.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cSprite + { + public: + cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera = nullptr ); + cSprite( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + + cSprite& operator=( const cSprite& copy ); + ~cSprite(); + + ///Functions + /* Draws the sprite to the video buffer */ + void Draw(); + /* Draws the sprite to the camera */ + void CameraDraw(); + /* Draws the sprite to a SDL_Renderer */ + /*void RendererDraw( SDL_Renderer* rend );*/ + /* Draws the sprite to the video buffer with out positioning it */ + void DefaltDraw(); + + void AddPosX( const signed long int x ); + void AddPosY( const signed long int y ); + + void SaveImage( const cString& fileName, const cString& dir = "" ); + + ///Sets + /* Sets the X position of the sprite on the surface, camera or video buffer */ + void setPosX( const signed long int x ); + /* Sets the Y position of the sprite on the surface, camera or video buffer */ + void setPosY( const signed long int y ); + /* Sets the position of the sprite on the surface, camera or video buffer */ + void setPosition( const signed long int x, const signed long int y ); + /* Sets the position of the sprite on the surface, camera or video buffer */ + void setPosition( const MathEngine::iVector2& position = MathEngine::iVector2(0,0) ); + + /* Sets the start and end of the image area */ + void setImageArea( const MathEngine::iVector4& area = MathEngine::iVector4(0,0,0,0) ); + /* Sets the top left of the area to take from the image */ + void setStartImageArea( const signed long int x, const signed long int y ); /// Top left starting area. + /* Sets the bottom right of the area to take from the image */ + void setEndImageArea( const unsigned long int w, const unsigned long int h ); /// Bottom right image ends. + + /* Sets the pointer to a pointer for the image that the sprite will use */ + void setImage( VideoEngine::cImage** image ); + /* Sets the pointer to a pointer for the camera the sprite will be draw on */ + void setCamera( VideoEngine::cCamera** camera ); + + ///Gets + /* Gets the X position of the sprite on the surface, camera or video buffer */ + const signed long int getPosX() const; + /* Gets the Y position of the sprite on the surface, camera of video buffer */ + const signed long int getPosY() const; + /* Gets the position of the sprite on the surface, camera or video buffer */ + void getPosition( signed long int& x, signed long int& y ) const; + /* Gets the position of the sprite on the surface, camera or video buffer */ + const MathEngine::iVector4 getPosition() const; + + /* Gets the top left of the area to take from the image */ + void getStartImageArea( signed long int& x, signed long int& y ) const; + /* Gets the bottom right of the area to take from the image */ + void getEndImageArea( unsigned long int& w, unsigned long int& h ) const; + /* Gets the area of the image */ + const SDL_Rect& getImageArea() const; + + /* Gets the width of the sprite */ + const unsigned long int getWidth() const; + /* Gets the height of the sprite */ + const unsigned long int getHeight() const; + + /* Gets a pointer to the image used by the sprite */ + VideoEngine::cImage* getImage() const; + /* Gets a pointer to the camera used by the sprite */ + VideoEngine::cCamera* getCamera() const; + + /* Gets returns true if image pointer is not null other wise returns false */ + const bool getImageSetup() const; + /* Gets returns true if camera pointer is not null other wise returns false */ + const bool getCameraSetup() const; + + private: + void setPositionEnd(); + + private: + ///Variables + SDL_Rect m_position; /// Were the Sprite will be position on the screen (Upper Left) + + SDL_Rect m_imageArea; /// What part of the image to take + + VideoEngine::cImage** mpp_image;// = nullptr + VideoEngine::cCamera** mpp_camera;// = nullptr + };/// END CLASS DEFINITION cSprite +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CSPRITE_HPP_ diff --git a/.svn/pristine/10/102e2aee1cf2452e0327ec761ee216bc333cc35b.svn-base b/.svn/pristine/10/102e2aee1cf2452e0327ec761ee216bc333cc35b.svn-base new file mode 100644 index 0000000..4364d62 --- /dev/null +++ b/.svn/pristine/10/102e2aee1cf2452e0327ec761ee216bc333cc35b.svn-base @@ -0,0 +1,72 @@ +#ifndef _CAUDIO_HPP_ +#define _CAUDIO_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace AudioEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cAudio + { + private: + cAudio(); + ~cAudio(); + + public: + //Functions + static cAudio& Inst(); + static void Delete(); + + const bool Initialize() const; + + /* Sets up the audio */ + void Setup(); + /* Cleans up */ + void CleanUp(); + + /* Plays the sounds */ + void SoundPlay(); + /* Plays the music */ + void MusicPlay(); + + + ///Set + /* Sets the rate */ + void setRate( const unsigned long int rate = 22050 ); + /* Sets the audio format */ + void setFormat( const unsigned long int format = AUDIO_S16 ); + /* Sets the channels */ + void setChannels( const unsigned long int channels = 2 ); + + /* Sets the buffer */ + void setBuffers( const unsigned long int buffers = 4096 ); + + ///Get + /* Gets return true if Audio was initialized */ + const bool IsInit() const; + /* Gets the rate */ + const unsigned long int getRate() const; + /* Gets the format */ + const unsigned long int getFormat() const; + /* Gets the channels */ + const unsigned long int getChannels() const; + + /* Gets the buffers */ + const unsigned long int getBuffers() const; + + private: + private: + ///Variables + unsigned long int m_rate;// = 22050; + unsigned long int m_format;// = AUDIO_S16; + unsigned long int m_channels;// = 2; + unsigned long int m_buffers;// = 4096; + + static cAudio* sp_inst;// = nullptr; + };/// END CLASS DEFINITION cAudio +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CAUDIO_HPP_ diff --git a/.svn/pristine/10/10dcbe5c30c1550f31eb1abc0a7c5aa619313a99.svn-base b/.svn/pristine/10/10dcbe5c30c1550f31eb1abc0a7c5aa619313a99.svn-base new file mode 100644 index 0000000..56b0832 --- /dev/null +++ b/.svn/pristine/10/10dcbe5c30c1550f31eb1abc0a7c5aa619313a99.svn-base @@ -0,0 +1,274 @@ +#include "cRenderer.hpp" + +/*** Custom Header Files ***/ +#include "cVideo.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cRenderer; +using VideoEngine::cVideo; +using UtilityEngine::cUtility; + +/*static*/ cRenderer* cRenderer::sp_inst = nullptr; + +//private: +cRenderer::cRenderer() +{ + Setup(); +} + +cRenderer::~cRenderer() +{ + CleanUp(); +} + +//public: +///Functions +/*static*/ cRenderer& cRenderer::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cRenderer(); + return *sp_inst; +} + +/*static*/ void cRenderer::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cRenderer::Setup() +{ + bool rtn = false; + if (cVideo::Inst().IsInit() == false) + cUtility::Inst().Message("Unable to setup until SDL_Video is initialized."); + else { + mp_renderer = cVideo::Inst().CreateRender(); + if (mp_renderer != nullptr) + rtn = true; + } + return rtn; +} + +void cRenderer::CleanUp() +{ + SDL_DestroyRenderer(mp_renderer); + mp_renderer = nullptr; +} + +void cRenderer::Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + cRenderer::Render(texture, srcrect, mp_renderer, dstrect); +} + +void cRenderer::Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + SDL_Texture* texture = SurfaceToTexture(surface); + Render( texture, srcrect, dstrect ); + SDL_DestroyTexture(texture); +} + +void cRenderer::Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + if (SDL_BlitSurface(src, srcrect, dst, dstrect) < 0) + cUtility::Inst().Message("Unable to BlitSurface. SDL_BlitSurface():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + src; + srcrect; + dst; + dstrect; + //??????? +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ) +{ + if (SDL_RenderCopy(dst, src, srcrect, dstrect) < 0) + cUtility::Inst().Message("Unable to copy Texture to Renderer. SDL_RenderCopy():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ) +{ + SetRenderTarget(dst); + Render( src, srcrect, dstrect ); + ResetRenderTarget(); +} + +void cRenderer::RenderDrawColor( const SDL_Colour& colour ) +{ + if (SDL_SetRenderDrawColor(mp_renderer, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to set render draw colour. SDL_SetRenderDrawColor():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst /*= nullptr */ ) +{ + SetRenderTarget(dst); + if (SDL_RenderFillRect(mp_renderer, &rect) < 0) + cUtility::Inst().Message("Unable to draw rectangle. SDL_RenderFillRect():", __AT__, cUtility::eTypeSDL::SDL); + ResetRenderTarget(); +} + +void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/ ) +{ + SDL_Surface* infoSurface = SDL_GetWindowSurface(VideoEngine::cVideo::Inst().getWindow()); + SDL_Surface* saveSurface = NewSurface(); + + if (infoSurface == NULL) { + cUtility::Inst().Message("Failed to create info surface from window.\n", __AT__, cUtility::eTypeSDL::SDL); + } else { + if (SDL_RenderReadPixels(mp_renderer, &infoSurface->clip_rect, infoSurface->format->format, saveSurface->pixels, infoSurface->w * infoSurface->format->BytesPerPixel) != 0) + cUtility::Inst().Message("Failed to read pixel data from SDL_Renderer object.\n", __AT__, cUtility::eTypeSDL::SDL); + else + SaveSurface(saveSurface, filename, dir); + SDL_FreeSurface(infoSurface); + infoSurface = NULL; + } + SDL_FreeSurface(saveSurface); + saveSurface = NULL; +} + + +void cRenderer::SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir /*= ""*/ ) +{ + cString temp = dir + fileName; + if (SDL_SaveBMP(surface, temp.c_str()) < 0) + cUtility::Inst().Message("Unable to save Surface. SDL_SaveBMP()", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir /*= ""*/ ) +{ + SDL_Surface* surface = TextureToSurface(texture); + + if (surface != nullptr) + SaveSurface(surface, fileName, dir); + else + cUtility::Inst().Message("Unable to create Surface from Texture. TextureToSurface():", __AT__); + + SDL_FreeSurface(surface); +} + +SDL_Texture* cRenderer::SurfaceToTexture( SDL_Surface* surface ) +{ + SDL_Texture* rtn = nullptr; + rtn = SDL_CreateTextureFromSurface( mp_renderer, surface ); + if ( rtn == nullptr) + cUtility::Inst().Message("Unable to create Texture. SDL_CreateTextureFromSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture ) +{ + SDL_Surface* rtn = nullptr; + + int w = 0; + int h = 0; + + if (SDL_QueryTexture(texture, nullptr, nullptr, &w, &h) < 0) + cUtility::Inst().Message("Unable to Query Texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + rtn = NewSurface(w, h); + + void* srcPixels = nullptr; + int srcPitch = 0; + + //Lock texture for manipulation + if (SDL_LockTexture( texture, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockSurface(rtn)) + cUtility::Inst().Message("Unable to lock surface rtn. SDL_LockSurface():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( rtn->pixels, srcPixels, srcPitch * h ); + + //Unlock texture to update + SDL_UnlockSurface(rtn); + SDL_UnlockTexture( texture ); + + srcPixels = nullptr; + + return rtn; +} + +void cRenderer::CopyTexture( SDL_Texture* src, SDL_Texture* dst ) +{ + void* srcPixels = nullptr; + int srcPitch = 0; + + void* dstPixels = nullptr; + int dstPitch = 0; + + int height = 0; + + if (SDL_QueryTexture( src, nullptr, nullptr, nullptr, &height ) < 0) + cUtility::Inst().Message("Unable to query texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Lock texture for manipulation + if (SDL_LockTexture( src, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture src. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockTexture( dst, nullptr, &dstPixels, &dstPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture dst. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( dstPixels, srcPixels, srcPitch * height ); + + //Unlock texture to update + SDL_UnlockTexture( dst ); + SDL_UnlockTexture( src ); + srcPixels = nullptr; + dstPixels = nullptr; + +} + +SDL_Surface* cRenderer::CopySurface( SDL_Surface* src ) +{ + return SDL_ConvertSurface( src, src->format, src->flags ); +} + +SDL_Surface* cRenderer::NewSurface( long int width /*= -1*/, long int height /*= -1*/ ) const +{ + if (width < 0) + width = cVideo::Inst().getWidth(); + if (height < 0) + height = cVideo::Inst().getHeight(); + + SDL_Surface* rtn = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), width, height, cVideo::Inst().getColour(), cVideo::Inst().getRmask(), cVideo::Inst().getGmask(), cVideo::Inst().getBmask(), cVideo::Inst().getAmask()); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create surface. SDL_CreateRGBSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Texture* cRenderer::NewTexture( long int width, long int height, const unsigned long int access /*= SDL_TEXTUREACCESS_TARGET*/ ) const +{ + if (width < 0) + width = cVideo::Inst().getWidth(); + if (height < 0) + height = cVideo::Inst().getHeight(); + + SDL_Texture* rtn = SDL_CreateTexture(mp_renderer, SDL_PIXELFORMAT_ABGR8888, access, width, height); + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create texture. SDL_CreateTexture:", __AT__, cUtility::eTypeSDL::SDL); + return rtn; +} + +void cRenderer::SetRenderTarget( SDL_Texture* target /*= nullptr*/ ) +{ + if (SDL_SetRenderTarget(mp_renderer, target) < 0) + cUtility::Inst().Message("Unable to set render target to dst. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::ResetRenderTarget() +{ + if (SDL_SetRenderTarget(mp_renderer, nullptr) < 0) + cUtility::Inst().Message("Unable to set render target to mp_rend. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +SDL_Renderer* cRenderer::getRenderer() +{ + return mp_renderer; +} diff --git a/.svn/pristine/12/12a4d588a51f22f8ceea58e0fb7e22ae1194b434.svn-base b/.svn/pristine/12/12a4d588a51f22f8ceea58e0fb7e22ae1194b434.svn-base new file mode 100644 index 0000000..337c510 --- /dev/null +++ b/.svn/pristine/12/12a4d588a51f22f8ceea58e0fb7e22ae1194b434.svn-base @@ -0,0 +1,39 @@ + + + + + {549e0f16-9635-455e-b19a-4a887771cf5d} + + + {50a06b19-0711-478a-a15e-df325d10bebc} + + + {3305ea52-bd3f-4a02-a012-eb2923a77dbf} + + + {510356f7-3573-4526-b0a4-73d691ecba95} + + + + + UTest + + + UtitlityEngineTest + + + + + UTest + + + + UtitlityEngineTest + + + + + xml + + + \ No newline at end of file diff --git a/.svn/pristine/13/132f4d08f294eaaa53fec03a654dfd1dbd4ee202.svn-base b/.svn/pristine/13/132f4d08f294eaaa53fec03a654dfd1dbd4ee202.svn-base new file mode 100644 index 0000000..ac63673 --- /dev/null +++ b/.svn/pristine/13/132f4d08f294eaaa53fec03a654dfd1dbd4ee202.svn-base @@ -0,0 +1,121 @@ +#include "cFont.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cFont; +using TextTypeHelpers::cFontHolder; +using UtilityEngine::cUtility; + +cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +: m_dir(dir), m_fileName(filename), mpp_default(nullptr) +{ + setSize(size); +} + +cFont::cFont( const cFont& copy ) +: m_dir(copy.getDir()), m_fileName(copy.getFileName()), mpp_default(nullptr) +{ + setSize(copy.getSize()); +} + +cFont::~cFont() +{ + UnloadFont(); +} + +///Functions +///Sets +void cFont::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cFont::setFileName( const cString& filename ) +{ + m_fileName = filename; +} + +void cFont::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cFont::setSize( const unsigned long int size /*= 16*/ ) +{ + while ((mpp_default == nullptr) || ((*mpp_default) == nullptr)) { + getFont(size); + mpp_default = (cFontHolder**)getFontHolder(size); + } +} + +///Gets +const cString& cFont::getDir() const +{ + return m_dir; +} + +const cString& cFont::getFileName() const +{ + return m_fileName; +} + +const unsigned long int cFont::getSize() const +{ + return (*mpp_default)->getSize(); +} + +TTF_Font* cFont::getFont() +{ + return (*mpp_default)->getFont(); +} + +TTF_Font* cFont::getFont( const unsigned long int size ) +{ + TTF_Font* rtn = nullptr; + + rtn = getFontHolder(size)->getFont(); + //We Can't find the Font in that size so we make a new one + if (rtn == nullptr) { + rtn = LoadFont(size); + } + + return rtn; +} + +//private: +TTF_Font* cFont::LoadFont( const unsigned long int size ) +{ + TTF_Font* rtn = nullptr; + if (m_fileName != "") { + cString temp = m_dir + m_fileName; + if ((rtn = TTF_OpenFont(temp.c_str(), size)) == nullptr) + cUtility::Inst().Message("Unable to load necessary TTF file. " + temp + " TTF_OpenFont():", "", cUtility::eTypeSDL::TTF); + else { + cFontHolder* holder = new cFontHolder(rtn, size); + m_fonts.push_back(holder); + } + } + return rtn; +} + +TextTypeHelpers::cFontHolder* cFont::getFontHolder(const unsigned long int size) +{ + cFontHolder* rtn = nullptr; + std::vector::iterator it; + + for (it = m_fonts.begin(); it < m_fonts.end(); it++) { + if (size == (*it)->getSize()) { + rtn = (*it); + //break out of the for loop + break; + } + } + return rtn; +} + +void cFont::UnloadFont() +{ + m_fonts.clear(); +} \ No newline at end of file diff --git a/.svn/pristine/13/134d7105c89089d2a96f58dd025521e40e8ed6ee.svn-base b/.svn/pristine/13/134d7105c89089d2a96f58dd025521e40e8ed6ee.svn-base new file mode 100644 index 0000000..fa48e02 --- /dev/null +++ b/.svn/pristine/13/134d7105c89089d2a96f58dd025521e40e8ed6ee.svn-base @@ -0,0 +1,21 @@ +#ifndef _CMOUSE_HPP_ +#define _CMOUSE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cInput.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cMouse + { + public: + cMouse(); + ~cMouse(); + };/// END CLASS DEFINITION cMouse +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CMOUSE_HPP_ diff --git a/.svn/pristine/13/1352d1d6e5322c698c274f6491679d3e2d15f1c7.svn-base b/.svn/pristine/13/1352d1d6e5322c698c274f6491679d3e2d15f1c7.svn-base new file mode 100644 index 0000000..32bc245 --- /dev/null +++ b/.svn/pristine/13/1352d1d6e5322c698c274f6491679d3e2d15f1c7.svn-base @@ -0,0 +1,348 @@ + + + + + {785f0a83-5f26-4f52-8607-42d79ef7e4a0} + + + {ce87c954-26c7-497c-a5c1-ca307fa85446} + + + {9447735f-408f-4a4c-896b-3cb056516952} + + + {78ca6e8e-15cd-4c35-a4c7-f718c6f2e517} + + + {a48949b4-948d-4bdb-a48d-a2bb08c05f43} + + + {fb99b84e-7997-4ebd-b3ea-dd0240ce62f6} + + + {98b7ca98-2ed4-4a41-84f2-abcb3fb384aa} + + + {aef9e043-2065-4d89-acae-33d6f5f55958} + + + {59e0e88b-7be3-4b1d-b3ac-6477daa761c8} + + + {4aa00373-6815-4cd3-a1c7-470f34bfa3d9} + + + {74c65105-2ee7-4bb9-8d44-ca75c80e8b9e} + + + {5a07ee53-1695-400c-86b3-c493e8e34417} + + + {839730ba-b9b8-40bc-a0e0-bcb2b16b83f7} + + + {2b72b3ea-71a4-4c02-988e-603172b3eda3} + + + {4a09c4e8-7d59-490d-8049-7a52f0aed3c8} + + + {6d0af3ff-4b2b-4b9c-85a2-c7db41550092} + + + {db4ff7f3-2b38-4f9d-9a92-aed4cb51f0ac} + + + {f6fc613b-8e1a-4df1-aee7-f37382d38981} + + + + + dllExportFiles + + + dllExportFiles + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + dllExportFiles + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + \ No newline at end of file diff --git a/.svn/pristine/13/1356a7a7e1aed9ab8fd01bbd7e9e113179ef406e.svn-base b/.svn/pristine/13/1356a7a7e1aed9ab8fd01bbd7e9e113179ef406e.svn-base new file mode 100644 index 0000000..98fb4be --- /dev/null +++ b/.svn/pristine/13/1356a7a7e1aed9ab8fd01bbd7e9e113179ef406e.svn-base @@ -0,0 +1,83 @@ +#ifndef _TROOPERENGINE_HPP_ +#define _TROOPERENGINE_HPP_ + +#define _MYDLL_ + +#include "dllExport.h" + +/*** SDL Header Files ***/ +#include + +/*** TropperEngineCore Folder ***/ +#include "../TrooperEngine/TrooperEngineCore/cTrooperEngineCore.hpp" + +/*** VideoEngine Folder ***/ +#include "../TrooperEngine/VideoEngine/cVideo.hpp" +#include "../TrooperEngine/VideoEngine/cRenderer.hpp" +#include "../TrooperEngine/VideoEngine/cSprite.hpp" +#include "../TrooperEngine/VideoEngine/cAnimatedSprite.hpp" +#include "../TrooperEngine/VideoEngine/cImage.hpp" +#include "../TrooperEngine/VideoEngine/cCamera.hpp" + +/*** AudioEngine Folder ***/ +#include "../TrooperEngine/AudioEngine/cAudio.hpp" +#include "../TrooperEngine/AudioEngine/cSound.hpp" +#include "../TrooperEngine/AudioEngine/cMusic.hpp" + +/*** NetworkingEngine Folder ***/ +#include "../TrooperEngine/NetworkEngine/cNetwork.hpp" + +/*** InputEngine Folder ***/ +#include "../TrooperEngine/InputEngine/cInput.hpp" +#include "../TrooperEngine/InputEngine/cJoystick.hpp" +#include "../TrooperEngine/InputEngine/cKeyboard.hpp" +#include "../TrooperEngine/InputEngine/cMouse.hpp" +#include "../TrooperEngine/InputEngine/cKey.hpp" +#include "../TrooperEngine/InputEngine/cTextInput.hpp" + +/*** TimingEngine Folder ***/ +#include "../TrooperEngine/TimingEngine/cTiming.hpp" + +/*** MathEngine Folder ***/ +#include "../TrooperEngine/MathEngine/Vector/Vector2.hpp" +#include "../TrooperEngine/MathEngine/Vector/Vector3.hpp" +#include "../TrooperEngine/MathEngine/Vector/Vector4.hpp" + +#include "../TrooperEngine/MathEngine/iVector/iVector2.hpp" +#include "../TrooperEngine/MathEngine/iVector/iVector3.hpp" +#include "../TrooperEngine/MathEngine/iVector/iVector4.hpp" + +#include "../TrooperEngine/MathEngine/cCollision.hpp" +#include "../TrooperEngine/MathEngine/cRandom.hpp" + +/*** TextTypeEngine ***/ +#include "../TrooperEngine/TextTypeEngine/cTextType.hpp" +#include "../TrooperEngine/TextTypeEngine/cFont.hpp" +#include "../TrooperEngine/TextTypeEngine/cText.hpp" + +/*** EventEngine ***/ +#include "../TrooperEngine/EventEngine/cEvent.hpp" + +/*** GUIEngine ***/ +#include "../TrooperEngine/GUIEngine/cGUI.hpp" +#include "../TrooperEngine/GUIEngine/cWindow.hpp" +#include "../TrooperEngine/GUIEngine/cLayout.hpp" +#include "../TrooperEngine/GUIEngine/cLabel.hpp" +#include "../TrooperEngine/GUIEngine/cButton.hpp" +#include "../TrooperEngine/GUIEngine/cTextButton.hpp" +#include "../TrooperEngine/GUIEngine/cBoxSizer.hpp" + +/*** GUIHelper ***/ +#include "../TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/cTexture.hpp" + +/*** UtilityEngine ***/ +#include "../TrooperEngine/UtilityEngine/cUtility.hpp" +#include "../TrooperEngine/UtilityEngine/cString.hpp" + +/*** FXEngine ***/ +#include "../TrooperEngine/FXEngine/cGFX.hpp" + +#endif/// END IFNDEF _TROOPERENGINE_HPP_ \ No newline at end of file diff --git a/.svn/pristine/15/15f77bb7b97e5eb731c699038b84e222b804a517.svn-base b/.svn/pristine/15/15f77bb7b97e5eb731c699038b84e222b804a517.svn-base new file mode 100644 index 0000000..92ea09d --- /dev/null +++ b/.svn/pristine/15/15f77bb7b97e5eb731c699038b84e222b804a517.svn-base @@ -0,0 +1,27 @@ +#ifndef _CSCOREBOARD_HPP_ +#define _CSCOREBOARD_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ + +using UtilityEngine::cString; + +namespace Equipment { + class cScoreBoard + { + public: + cScoreBoard(); + ~cScoreBoard(); + + ///Functions + void Score( const unsigned long int player = 1 ); + + private: + private: + unsigned long int m_player1Score;// = 0 + unsigned long int m_player2Score;// = 0 + };/// END CLASS DEFINITION cScoreBoard +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CSCOREBOARD_HPP_ \ No newline at end of file diff --git a/.svn/pristine/16/1603975d16bd9fc7fcd1bc5b096d560a853e4be9.svn-base b/.svn/pristine/16/1603975d16bd9fc7fcd1bc5b096d560a853e4be9.svn-base new file mode 100644 index 0000000..184a79b --- /dev/null +++ b/.svn/pristine/16/1603975d16bd9fc7fcd1bc5b096d560a853e4be9.svn-base @@ -0,0 +1,45 @@ +#ifndef _CBUILDMAINMENU_HPP_ +#define _CBUILDMAINMENU_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** TinyXML Header File ***/ +#include "C:\Users\Laptop\programming\tinyxml2-master\tinyxml2.h" + +/*** Custom Header Files ***/ +#include "cMainMenu.hpp" + +using UtilityEngine::cString; +using tinyxml2::XMLElement; + +namespace MainMenu { + class cBuildMainMenu + { + public: + cBuildMainMenu(); + ~cBuildMainMenu(); + + ///Functions + cMainMenu* ReadXML(); + + ///Sets + ///Gets + + private: + void GetOptions( const XMLElement* element, const cString name ); + const char* GetAttribute( const XMLElement* element, const cString attribute ) const; + const unsigned long int HexToInt( const cString str ) const; + const SDL_Colour IntToSDLColour( const unsigned long int colour ) const; + + private: + cString m_langSettings;// = "" + cString m_lang;// = "" + + cString m_ttf;// = "" + cString m_dir;// = "" + + cMainMenu* mp_mainMenu;// = new cMainMenu() + };/// END CLASS DEFINITION cBuildMainMenu +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _CBUILDMAINMENU_HPP_ \ No newline at end of file diff --git a/.svn/pristine/19/1984cae4cfb573fc69eb8d206fd3e65e265101a7.svn-base b/.svn/pristine/19/1984cae4cfb573fc69eb8d206fd3e65e265101a7.svn-base new file mode 100644 index 0000000..6333428 --- /dev/null +++ b/.svn/pristine/19/1984cae4cfb573fc69eb8d206fd3e65e265101a7.svn-base @@ -0,0 +1,19 @@ +#ifndef _DLLEXPORT_H_ +#define _DLLEXPORT_H_ + +#include "CompileSettings.h" + +#if _STATIC_LIB_ == 0 +# ifdef _MYDLL_ +# define EXPORT_FROM_MYDLL __declspec(dllimport) +# define EXPIMP_TEMPLATE extern +# else +# define EXPORT_FROM_MYDLL __declspec(dllexport) +# define EXPIMP_TEMPLATE +# endif +#else +# define EXPORT_FROM_MYDLL +# define EXPIMP_TEMPLATE +#endif + +#endif/// END IFNDEF _DLLEXPORT_H_ \ No newline at end of file diff --git a/.svn/pristine/1a/1a58545a4bf1690d5bf9a7bfbb07641eb3a821b5.svn-base b/.svn/pristine/1a/1a58545a4bf1690d5bf9a7bfbb07641eb3a821b5.svn-base new file mode 100644 index 0000000..1829f41 Binary files /dev/null and b/.svn/pristine/1a/1a58545a4bf1690d5bf9a7bfbb07641eb3a821b5.svn-base differ diff --git a/.svn/pristine/1b/1bbc93fe2f13a1962db0014ec292db3a39f68b5a.svn-base b/.svn/pristine/1b/1bbc93fe2f13a1962db0014ec292db3a39f68b5a.svn-base new file mode 100644 index 0000000..3008cf8 --- /dev/null +++ b/.svn/pristine/1b/1bbc93fe2f13a1962db0014ec292db3a39f68b5a.svn-base @@ -0,0 +1,34 @@ +#include "cMenuSelect.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuSelect; + +cMenuSelect::cMenuSelect( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuSelect::cMenuSelect( const cMenuSelect& copy ) +{}*/ + +cMenuSelect::~cMenuSelect() +{} + +///Funtions +void cMenuSelect::KeyPress() +{ +} + +void cMenuSelect::KeyUP() +{ +} + +void cMenuSelect::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionSelect(); +} \ No newline at end of file diff --git a/.svn/pristine/1b/1bfb2e6dfa2d46ab171444fffa05c0d8e825883d.svn-base b/.svn/pristine/1b/1bfb2e6dfa2d46ab171444fffa05c0d8e825883d.svn-base new file mode 100644 index 0000000..8e5fa2f --- /dev/null +++ b/.svn/pristine/1b/1bfb2e6dfa2d46ab171444fffa05c0d8e825883d.svn-base @@ -0,0 +1,7 @@ +#ifndef _COMPILESETTINGS_H_ +#define _COMPILESETTINGS_H_ + +#define _STATIC_LIB_ 1 +#define _DEBUG_ 0 + +#endif/// END IFNDEF _COMPILESETTINGS_H_ \ No newline at end of file diff --git a/.svn/pristine/1c/1c86849a10dea1eeffb3c3d11ee3ed384a9f58fa.svn-base b/.svn/pristine/1c/1c86849a10dea1eeffb3c3d11ee3ed384a9f58fa.svn-base new file mode 100644 index 0000000..e75685b Binary files /dev/null and b/.svn/pristine/1c/1c86849a10dea1eeffb3c3d11ee3ed384a9f58fa.svn-base differ diff --git a/.svn/pristine/1e/1e983cfa9be12d64bcb5331a4c5b1f4701aba14c.svn-base b/.svn/pristine/1e/1e983cfa9be12d64bcb5331a4c5b1f4701aba14c.svn-base new file mode 100644 index 0000000..a8c9e49 --- /dev/null +++ b/.svn/pristine/1e/1e983cfa9be12d64bcb5331a4c5b1f4701aba14c.svn-base @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/.svn/pristine/1e/1ec02a26e379f6efacc72836610e3f43acd69720.svn-base b/.svn/pristine/1e/1ec02a26e379f6efacc72836610e3f43acd69720.svn-base new file mode 100644 index 0000000..94576fa --- /dev/null +++ b/.svn/pristine/1e/1ec02a26e379f6efacc72836610e3f43acd69720.svn-base @@ -0,0 +1,37 @@ +#ifndef _IVECTOR3_HPP_ +#define _IVECTOR3_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "iVector2.hpp" + +namespace MathEngine { + struct Vector3; + + struct EXPORT_FROM_MYDLL iVector3 : public iVector2 + { + iVector3( const int X = 0, const int Y = 0, const int Z = 0); + + iVector3( const iVector2& copy ); + + iVector3( const SDL_Rect& copy ); + + iVector3& operator=( const SDL_Rect& copy ); + + bool operator==( const SDL_Rect& other ) const; + + iVector3( const Vector3& copy ); + + iVector3& operator=( const Vector3& copy ); + + bool operator==( const iVector3& other ) const; + + int z; + };/// END STRUCT DEFINITION iVector3 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _IVECTOR3_HPP_ \ No newline at end of file diff --git a/.svn/pristine/21/21f62883dee13e6c07cf7688b53e86a2c2ab019e.svn-base b/.svn/pristine/21/21f62883dee13e6c07cf7688b53e86a2c2ab019e.svn-base new file mode 100644 index 0000000..b459e5b --- /dev/null +++ b/.svn/pristine/21/21f62883dee13e6c07cf7688b53e86a2c2ab019e.svn-base @@ -0,0 +1,126 @@ +#include "cLabel.hpp" + +using GUIEngine::cLabel; + +/*static*/ const cString cLabel::sNAME = "label"; +/*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; + +cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) + : cWindow(parent, id, align, layout, pos, size, padding, name) +{ + mp_text = new TextTypeEngine::cText(label); + //Create(parent, id, label, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setText(label); +} + +/*virtual*/ cLabel::~cLabel() +{ + delete mp_text; + mp_text = nullptr; +} + +///Functions +void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + //cWindow(parent, id, align, layout, pos, size, padding, name); + this->getParent()->AddChild(this); + setText(label); +} + +/*virtual*/ void cLabel::Display() +{ + GenerateTexture(); + + cSprite::setPosition(cWindow::getPosition()); + cSprite::Draw(); +} + +void cLabel::GenerateTexture() +{ + this->setImage((VideoEngine::cImage**)(&mp_text)); + + this->setImageArea(mp_text->getWH()); + + + + //this->setTransparent(); + //this->setPosition() +} + +//Sets +void cLabel::setFontColour(const GUIHelpers::RBGA& colour) +{ + mp_text->setColour(colour); +} + +void cLabel::setFontSize(const unsigned long int size) +{ + mp_text->setSize(size); +} + +void cLabel::setText(const cString& text) +{ + mp_text->setText(text); +} + +void cLabel::setFont(const TextTypeEngine::cFont* font) +{ + mp_text->setFont((TextTypeEngine::cFont**)(&font)); +} + +///Gets +const GUIHelpers::RBGA& cLabel::getFontColour() const +{ + return mp_text->getColour(); +} + +const unsigned long int cLabel::getFontSize() const +{ + return mp_text->getSize(); +} + +const TextTypeEngine::cFont* cLabel::getFont() const +{ + return mp_text->getFont(); +} + +const cString& cLabel::getText() const +{ + return mp_text->getText(); +} + +/*virtual*/ const GUIHelpers::eType cLabel::getType() const +{ + return GUIHelpers::eType::CLABEL; +} + +/*virtual*/ void cLabel::Resize() +{ + RebuildLayout(this->getLayout()); +} + +/*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + GUIHelpers::Size mySize = (0, 0); + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + cWindow::RebuildLayout(layout); + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + long int x = (mp_text->getText().length() * mp_text->getSize()); + GUIHelpers::Size size = { x, 8 }; + size.x += this->getPadding().x + this->getPadding().w; + size.y += this->getPadding().y + this->getPadding().z; + this->setSize(size); + break; + } +} \ No newline at end of file diff --git a/.svn/pristine/24/244d1678ed9e7e3ce45a48bbf20c6bd7770841ef.svn-base b/.svn/pristine/24/244d1678ed9e7e3ce45a48bbf20c6bd7770841ef.svn-base new file mode 100644 index 0000000..c3702c8 Binary files /dev/null and b/.svn/pristine/24/244d1678ed9e7e3ce45a48bbf20c6bd7770841ef.svn-base differ diff --git a/.svn/pristine/24/2480e53b3385cf794500d7259924ce8460d5a865.svn-base b/.svn/pristine/24/2480e53b3385cf794500d7259924ce8460d5a865.svn-base new file mode 100644 index 0000000..10d176f --- /dev/null +++ b/.svn/pristine/24/2480e53b3385cf794500d7259924ce8460d5a865.svn-base @@ -0,0 +1,55 @@ +#ifndef _CXMLOADER_HPP_ +#define _CXMLOADER_HPP_ + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "GUIUtility.hpp" + +#include "../cWindow.hpp" +#include "../cLayout.hpp" +#include "../cLabel.hpp" + +#include "../../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cXMLoader + { + private: + cXMLoader(); + ~cXMLoader(); + + public: + ///Functions + static cXMLoader& Inst(); + static void Delete(); + + void Load( const cString& filename, const cString& dir = "" ); + + private: + void GetNode( tinyxml2::XMLElement* element, GUIEngine::cWindow* parent = nullptr ); + const char* GetAttribute(const tinyxml2::XMLElement* element, const cString& attribute) const; + + GUIEngine::cLayout* LayoutBuild( tinyxml2::XMLElement* element, GUIEngine::cWindow* parent ); + GUIEngine::cLabel* LabelBuild( tinyxml2::XMLElement* element, GUIEngine::cWindow* parent ); + + const signed long int getID(tinyxml2::XMLElement* element); + const GUIHelpers::eOrientation getOrientation(tinyxml2::XMLElement* element); + const GUIHelpers::eAlign getAlign(tinyxml2::XMLElement* element); + const GUIHelpers::eLayout getLayout(tinyxml2::XMLElement* element); + const GUIHelpers::Position getPosition(tinyxml2::XMLElement* element); + const GUIHelpers::Size getSize(tinyxml2::XMLElement* element); + const GUIHelpers::Padding getPadding(tinyxml2::XMLElement* element); + const cString getText(tinyxml2::XMLElement* element); + + private: + static cXMLoader* sp_inst;// = nullptr + };/// END CLASS DEFINITION cObject +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _CXMLOADER_HPP_ diff --git a/.svn/pristine/26/261324cfee4d158d38f69c6d8a0ace7d4860c04f.svn-base b/.svn/pristine/26/261324cfee4d158d38f69c6d8a0ace7d4860c04f.svn-base new file mode 100644 index 0000000..31be607 --- /dev/null +++ b/.svn/pristine/26/261324cfee4d158d38f69c6d8a0ace7d4860c04f.svn-base @@ -0,0 +1,11 @@ +// Static Model +#include "cNetwork.hpp" + +using NetworkEngine::cNetwork; + +cNetwork::cNetwork() +{} + +cNetwork::~cNetwork() +{} + diff --git a/.svn/pristine/27/27bcd65ab48a4c400bcdbf10bed839ea2fd0aefb.svn-base b/.svn/pristine/27/27bcd65ab48a4c400bcdbf10bed839ea2fd0aefb.svn-base new file mode 100644 index 0000000..1028280 --- /dev/null +++ b/.svn/pristine/27/27bcd65ab48a4c400bcdbf10bed839ea2fd0aefb.svn-base @@ -0,0 +1,36 @@ +#ifndef __UTEST__ +#define __UTEST__ + +#include + +#define __UTest_VERSION "1.0.0" + +class UTest { +private: + UTest( UTest & ); // no copy constructor + UTest operator = ( UTest & ); // no assignment operator + UTest(){} +public: + static const char * version() { return __UTest_VERSION; } + + UTest( const char * ); + void init( const char * ); + void test( const char * description, const int flag ); + void report() const; + + static void OverAllReport(); + +private: + unsigned long int m_pass = 0; + unsigned long int m_fail = 0; + + const char * mp_tstr = nullptr; + + const static char * sp_pstr; /*= "pass";*/ + const static char * sp_fstr; /*= "fail";*/ + + static unsigned long int s_pass; + static unsigned long int s_fail; +}; + +#endif // __UTEST__ diff --git a/.svn/pristine/28/2896a32d5cb78250eb1f26cda92a4d258066f0a2.svn-base b/.svn/pristine/28/2896a32d5cb78250eb1f26cda92a4d258066f0a2.svn-base new file mode 100644 index 0000000..fcc74e1 --- /dev/null +++ b/.svn/pristine/28/2896a32d5cb78250eb1f26cda92a4d258066f0a2.svn-base @@ -0,0 +1,81 @@ +#include "cTexture.hpp" + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cRenderer.hpp" +#include "../../FXEngine/cGFX.hpp" +#include "GUIUtility.hpp" + +using GUIHelpers::cTexture; + +cTexture::cTexture() +{} + +cTexture::~cTexture() +{} + +///Functions + +//private +SDL_Texture* cTexture::GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text /*= nullptr*/ ) +{ + SDL_Rect t = text->getWH(); + SDL_Rect centerText = { 0, 0, 0, 0 }; + SDL_Rect centerButton = { 0, 0, 0, 0 }; + SDL_Rect dim = dimensions; + + ///Find the min padding around the text. +// if (dim.w < (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w) ) +// dim.w += (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w); +// +// if (dim.h < (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z) ) +// dim.h += (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z); + + ///Find the center of the button + centerButton.x = dim.w / 2; + centerButton.y = dim.h / 2; + + ///Find the center of the text + centerText.x = t.w / 2; + centerText.y = t.h / 2; + + if (centerText.x < centerButton.x) + t.x = centerButton.x - centerText.x; + + if (centerText.y < centerButton.y) + t.y = centerButton.y - centerText.y; + + SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); + + GUIHelpers::RGBA colour = { 100, 100, 100, 255 }; + + FXEngine::cGFX::Inst().RoundedBox(dim, 0, colour, temptext); + + + VideoEngine::cRenderer::Inst().RenderToTexture(text->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + + setImage(temptext); + + return temptext; +} \ No newline at end of file diff --git a/.svn/pristine/29/291ee4f85f1d88a69a4e185ef22d74895576358a.svn-base b/.svn/pristine/29/291ee4f85f1d88a69a4e185ef22d74895576358a.svn-base new file mode 100644 index 0000000..6eca16e --- /dev/null +++ b/.svn/pristine/29/291ee4f85f1d88a69a4e185ef22d74895576358a.svn-base @@ -0,0 +1,70 @@ +#ifndef _CANIMATEDSPRITE_HPP_ +#define _CANIMATEDSPRITE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cAnimatedSprite : public cSprite + { + public: + cAnimatedSprite( const unsigned long int x = 0, const unsigned long int y = 0, const unsigned long int fps = 16 ); + /* Copy constructor */ + cAnimatedSprite( const cAnimatedSprite& copy ); + ~cAnimatedSprite(); + + ///Functions + /* Runs down the image */ + void UptoDown(); + /* Runs up the image */ + void DowntoUp(); + /* Runs right of the image */ + void LefttoRight(); + /* Runs Left of the image */ + void RighttoLeft(); + + ///Sets + /* Sets the x increment */ + void setXIncrement( const unsigned long int x ); + /* Sets the y increment */ + void setYIncrement( const unsigned long int y ); + /* Sets the how fare the sprite should move along the image */ + void setIncrement( const unsigned long int x, const unsigned long int y ); + /* Sets the speed of going from one frame to the next */ + void setFPS( const unsigned long int fps = 16 ); + + ///Gets + /* Gets the x increment */ + const unsigned long int getXIncrement() const; + /* Gets the y increment */ + const unsigned long int getYIncrement() const; + /* Gets how fare the sprite should move along the image */ + void getIncrement( unsigned long int& x, unsigned long int& y ) const; + + /* Gets the speed of going from one frame to the next */ + const unsigned long int getFPS() const; + + private: + const unsigned long int TimeLeft(); + void AddTimeandRate(); + + private: + ///Variables + unsigned long int m_xIncrement;// = 0 + unsigned long int m_yIncrement;// = 0 + + unsigned long int m_fps;// = 16 + + unsigned long int m_nextTime;// = 0 + + unsigned long int m_RATE;// = 0 + + };/// END CLASS DEFINITION cAnimatedSprite +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CANIMATEDSPRITE_HPP_ diff --git a/.svn/pristine/2a/2adb549f5b8989492ee90d2ac8ab90102f0171b7.svn-base b/.svn/pristine/2a/2adb549f5b8989492ee90d2ac8ab90102f0171b7.svn-base new file mode 100644 index 0000000..85a35b1 --- /dev/null +++ b/.svn/pristine/2a/2adb549f5b8989492ee90d2ac8ab90102f0171b7.svn-base @@ -0,0 +1,19 @@ +#include "cScoreBoard.hpp" + +using Equipment::cScoreBoard; + +cScoreBoard::cScoreBoard() + : m_player1Score(0), m_player2Score(0) +{} + +cScoreBoard::~cScoreBoard() +{} + +///Functions +void cScoreBoard::Score( const unsigned long int player /*= 1*/ ) +{ + if (player == 1) + ++m_player1Score; + if (player == 2) + ++m_player2Score; +} \ No newline at end of file diff --git a/.svn/pristine/2b/2bb051e729a4b3052fd4bccf878a3d3495026f57.svn-base b/.svn/pristine/2b/2bb051e729a4b3052fd4bccf878a3d3495026f57.svn-base new file mode 100644 index 0000000..b3c2771 --- /dev/null +++ b/.svn/pristine/2b/2bb051e729a4b3052fd4bccf878a3d3495026f57.svn-base @@ -0,0 +1,113 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) + : cWindow(parent, id, align, layout, pos, size, padding, name) +{ + //Create(parent, id, orientation, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setOrientation(orientation); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + //cWindow(parent, id, align, layout, pos, size, padding, name); + this->getParent()->AddChild(this); + setOrientation(orientation); +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set +void cLayout::setOrientation(const GUIHelpers::eOrientation& orientation /*= GUIHelpers::eOrientation::VERTICAL*/) +{ + m_orientation = orientation; +} + +///Get +const GUIHelpers::eOrientation& cLayout::getOrientation() const +{ + return m_orientation; +} + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} + +/*virtual*/ void cLayout::Resize() +{ + RebuildLayout(this->getLayout()); +} + +/*virtual*/ void cLayout::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + GUIHelpers::Size mySize = (0, 0); + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + cWindow::RebuildLayout(layout); + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + std::vector children = this->getChildren(); + std::vector::iterator it; + + for (it = children.begin(); it < children.end(); it++) { + (*it)->Resize(); + GUIHelpers::Size size = (*it)->getSize(); + GUIHelpers::Padding pad = (*it)->getPadding(); + size.x += pad.x + pad.w; + size.y += pad.y + pad.z; + AddSize(size.x, size.y, mySize); + } + this->setSize(mySize); + break; + } +} + +// /*virtual*/ void cLayout::RebuildPos() +// { +// cWindow::RebuildPos(); +// } + +///Private +/*virtual*/ void cLayout::AddSize(int x, int y, GUIHelpers::Size& mySize) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo > largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} \ No newline at end of file diff --git a/.svn/pristine/2b/2bbb9fefa6dd43a2fa17b82fcbdab86cf1beece8.svn-base b/.svn/pristine/2b/2bbb9fefa6dd43a2fa17b82fcbdab86cf1beece8.svn-base new file mode 100644 index 0000000..a67f3d4 --- /dev/null +++ b/.svn/pristine/2b/2bbb9fefa6dd43a2fa17b82fcbdab86cf1beece8.svn-base @@ -0,0 +1,28 @@ +#include "cBoxSizer.hpp" + +using GUIEngine::cBoxSizer; + +/*static*/ const cString cBoxSizer::sNAME = "boxsizer"; + +cBoxSizer::cBoxSizer( 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*/ ) +{ + Create(parent, id, align, layout, pos, size, padding, name); +} + +/*virtual*/ cBoxSizer::~cBoxSizer() +{} + +///Functions +void cBoxSizer::Create( 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*/ ) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); +} + +/*virtual*/ const GUIHelpers::eType cBoxSizer::getType() const +{ + return GUIHelpers::eType::CBOXSIZER; +} \ No newline at end of file diff --git a/.svn/pristine/2c/2cd9621f2ef97f17bbb61788bfada00183c6bb13.svn-base b/.svn/pristine/2c/2cd9621f2ef97f17bbb61788bfada00183c6bb13.svn-base new file mode 100644 index 0000000..f285b41 --- /dev/null +++ b/.svn/pristine/2c/2cd9621f2ef97f17bbb61788bfada00183c6bb13.svn-base @@ -0,0 +1,44 @@ +#ifndef _CEVENT_HPP_ +#define _CEVENT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace EventEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cEvent + { + private: + cEvent(); + ~cEvent(); + + public: + static cEvent& Inst(); + static void Delete(); + + //Functions + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + /* Checks for Events */ + void CheckEvents(); + + + ///Sets + + ///Gets + /* Gets return true if Event was initialized */ + const bool IsInit() const; + + private: + SDL_Event m_event; + + static cEvent* sp_inst;// = nullptr + };/// END CLASS DEFINITION cEvent +}/// END NAMESPACE DEFINITION EventEngine +#endif/// END IFNDEF _CEVENT_HPP_ diff --git a/.svn/pristine/32/32b06ca8df46c585780c9c8bf0adbc5c6422d81c.svn-base b/.svn/pristine/32/32b06ca8df46c585780c9c8bf0adbc5c6422d81c.svn-base new file mode 100644 index 0000000..9b2fcaa Binary files /dev/null and b/.svn/pristine/32/32b06ca8df46c585780c9c8bf0adbc5c6422d81c.svn-base differ diff --git a/.svn/pristine/33/33e77ab9ea9d10cef23f64e2db70ed63ae843ed0.svn-base b/.svn/pristine/33/33e77ab9ea9d10cef23f64e2db70ed63ae843ed0.svn-base new file mode 100644 index 0000000..9c147ef --- /dev/null +++ b/.svn/pristine/33/33e77ab9ea9d10cef23f64e2db70ed63ae843ed0.svn-base @@ -0,0 +1,105 @@ +#ifndef _CGUI_HPP_ +#define _CGUI_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../TextTypeEngine/cFont.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "cWindow.hpp" +//#include "cPanel.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cGUI + { + private: + cGUI(); + ~cGUI(); + + public: + enum EXPORT_FROM_MYDLL eGUIEventType: unsigned int + { + MouseButton1 = 0, + MouseButton2, + MouseButton3, + Keyboard + }; + ///Functions + static cGUI& Inst(); + static void Delete(); + + const bool Initialize( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void Event( const MathEngine::iVector2& location, const eGUIEventType& type ); + const MathEngine::iVector2 DisplayArea() const; + + void AddObject( GUIEngine::cWindow* obj ); + + std::vector& GetObjects(); + + void Display(); + + ///Sets + void setDebugLevel( const unsigned long int debugLevel ); + + void setFont( TextTypeEngine::cFont* font ); + void setFont( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void setTextColour( const GUIHelpers::RGBA& colour ); + void setTextColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0 ); + + void setPadding( const GUIHelpers::Padding& padding ); + void setPadding( const unsigned int top = 5, const unsigned int right = 5, const unsigned int bottom = 5, const unsigned int left = 5 ); + + void setAlign( const GUIHelpers::eAlign& align = GUIHelpers::eAlign::CENTER ); + + ///Gets + const unsigned long int getDebugLevel() const; + + TextTypeEngine::cFont* getFont(); + + const GUIHelpers::RGBA& getTextColour() const; + void getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const; + + const GUIHelpers::Padding& getPadding() const; + void getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const; + + const GUIHelpers::eAlign& getAlign() const; + + const bool IsInit() const; + + private: + static cGUI* sp_inst;// = nullptr + + unsigned long int m_debugLevel;// = 0 + + bool m_inited;// = false + + /* default GUI font */ + TextTypeEngine::cFont* mp_font;// = nullptr + + /* default GUI text colour black*/ + //GUIHelpers::RBGA m_textColour;// = { 0, 0, 0 } + + /* default GUI padding */ + //GUIHelpers::Padding m_padding;// = { 5, 5, 5, 5 } + + /* default GUI align */ + //GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::CENTER + + std::vector m_children; + };/// END CLASS DEFINITION cGUI +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CGUI_HPP_ diff --git a/.svn/pristine/34/34ca788f1053415fa5aaca6cddab94fed6a71ccb.svn-base b/.svn/pristine/34/34ca788f1053415fa5aaca6cddab94fed6a71ccb.svn-base new file mode 100644 index 0000000..992349e --- /dev/null +++ b/.svn/pristine/34/34ca788f1053415fa5aaca6cddab94fed6a71ccb.svn-base @@ -0,0 +1,222 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + TrooperEngineDLL + + + + DynamicLibrary + MultiByte + true + v140 + + + StaticLibrary + MultiByte + false + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + /MP %(AdditionalOptions) + Disabled + $(TINYXML);$(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + NotUsing + %(PreprocessorDefinitions) + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + ../Debug;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.11\lib;$(SDL)\SDL_image-1.2.10\lib;$(SDL)\SDL-1.2.14\lib;%(AdditionalLibraryDirectories) + true + NotSet + false + + + + + MachineX86 + + + + + Full + ../LinkListDLLProject/dllExportFiles;dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level4 + true + ProgramDatabase + true + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;LinkList.lib;%(AdditionalDependencies) + $(OutDir)TrooperEngine.dll + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + true + true + false + + + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/35/357a47d4e79321aead4e084c20951fb108638989.svn-base b/.svn/pristine/35/357a47d4e79321aead4e084c20951fb108638989.svn-base new file mode 100644 index 0000000..c8652fc --- /dev/null +++ b/.svn/pristine/35/357a47d4e79321aead4e084c20951fb108638989.svn-base @@ -0,0 +1,45 @@ +#ifndef _CBUILDMAINMENU_HPP_ +#define _CBUILDMAINMENU_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** Custom Header Files ***/ +#include "cMainMenu.hpp" + +using UtilityEngine::cString; +using tinyxml2::XMLElement; + +namespace MainMenu { + class cBuildMainMenu + { + public: + cBuildMainMenu(); + ~cBuildMainMenu(); + + ///Functions + cMainMenu* ReadXML(); + + ///Sets + ///Gets + + private: + void GetOptions( const XMLElement* element, const cString name ); + const char* GetAttribute( const XMLElement* element, const cString attribute ) const; + const unsigned long int HexToInt( const cString str ) const; + const SDL_Colour IntToSDLColour( const unsigned long int colour ) const; + + private: + cString m_langSettings;// = "" + cString m_lang;// = "" + + cString m_ttf;// = "" + cString m_dir;// = "" + + cMainMenu* mp_mainMenu;// = new cMainMenu() + };/// END CLASS DEFINITION cBuildMainMenu +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _CBUILDMAINMENU_HPP_ \ No newline at end of file diff --git a/.svn/pristine/35/358175669032a67092ca5d215a9b72d1143d4a49.svn-base b/.svn/pristine/35/358175669032a67092ca5d215a9b72d1143d4a49.svn-base new file mode 100644 index 0000000..4e78dda --- /dev/null +++ b/.svn/pristine/35/358175669032a67092ca5d215a9b72d1143d4a49.svn-base @@ -0,0 +1,32 @@ + + + + + + SDL Pong C + + + Single Player + + + Head to Head + + + Options + + + Language + + English + + + French + + + + + + Quit + + + \ No newline at end of file diff --git a/.svn/pristine/35/35a962e5ee51b27eab659bf3c22600f47e95ab3b.svn-base b/.svn/pristine/35/35a962e5ee51b27eab659bf3c22600f47e95ab3b.svn-base new file mode 100644 index 0000000..a918a00 --- /dev/null +++ b/.svn/pristine/35/35a962e5ee51b27eab659bf3c22600f47e95ab3b.svn-base @@ -0,0 +1,33 @@ +#ifndef _CQUITBUTTON_HPP_ +#define _CQUITBUTTON_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cCourt.hpp" + +namespace Input { + class cQuitButton : public InputEngine::cKey + { + public: + cQuitButton( SDL_Keycode key, Equipment::cCourt** court); + virtual ~cQuitButton(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cCourt** mpp_court;// + };/// END CLASS DEFINITION cQuitButton +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CQUITBUTTON_HPP_ \ No newline at end of file diff --git a/.svn/pristine/37/37daf20b16306cd98ddbebea30dba20240e8d412.svn-base b/.svn/pristine/37/37daf20b16306cd98ddbebea30dba20240e8d412.svn-base new file mode 100644 index 0000000..e3a4c97 --- /dev/null +++ b/.svn/pristine/37/37daf20b16306cd98ddbebea30dba20240e8d412.svn-base @@ -0,0 +1,40 @@ +#include "cEsc.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" +#include "../eOptions.hpp" + +using Input::cEsc; + +using MainMenu::eOptions; + +cEsc::cEsc( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cEsc::cEsc( const cEsc& copy ) +{}*/ + +cEsc::~cEsc() +{} + +///Funtions +void cEsc::KeyPress() +{ +} + +void cEsc::KeyUP() +{ +} + +void cEsc::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + { + (*mpp_menu)->setOption(eOptions::Quit); + (*mpp_menu)->OptionSelect(); + } +} \ No newline at end of file diff --git a/.svn/pristine/3c/3c39dfbbe8ba59d94d0bb135b8f7310be8c37cda.svn-base b/.svn/pristine/3c/3c39dfbbe8ba59d94d0bb135b8f7310be8c37cda.svn-base new file mode 100644 index 0000000..8a61814 --- /dev/null +++ b/.svn/pristine/3c/3c39dfbbe8ba59d94d0bb135b8f7310be8c37cda.svn-base @@ -0,0 +1,29 @@ +#include "cBoxSizer.hpp" + +using GUIEngine::cBoxSizer; + +/*static*/ const cString cBoxSizer::sNAME = "boxsizer"; + +cBoxSizer::cBoxSizer( 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*/ ) + : cWindow(parent, id, align, layout, pos, size, padding, name) +{ + //Create(parent, id, align, layout, pos, size, padding, name); +} + +/*virtual*/ cBoxSizer::~cBoxSizer() +{} + +///Functions +void cBoxSizer::Create( 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*/ ) +{ + //cWindow(parent, id, align, layout, pos, size, padding, name); +} + +/*virtual*/ const GUIHelpers::eType cBoxSizer::getType() const +{ + return GUIHelpers::eType::CBOXSIZER; +} \ No newline at end of file diff --git a/.svn/pristine/3c/3c8b7874b492a254154ba7460e73289c824ee938.svn-base b/.svn/pristine/3c/3c8b7874b492a254154ba7460e73289c824ee938.svn-base new file mode 100644 index 0000000..f1b0e05 --- /dev/null +++ b/.svn/pristine/3c/3c8b7874b492a254154ba7460e73289c824ee938.svn-base @@ -0,0 +1,31 @@ +#ifndef _CMENUSELECT_HPP_ +#define _CMENUSELECT_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuSelect : public InputEngine::cKey + { + public: + cMenuSelect( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuSelect( const cMenuSelect& copy ); + ~cMenuSelect(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuSelect +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUSELECT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/3c/3ccec6df214003e473144d4b6017d8e81b6856cb.svn-base b/.svn/pristine/3c/3ccec6df214003e473144d4b6017d8e81b6856cb.svn-base new file mode 100644 index 0000000..9f803ef --- /dev/null +++ b/.svn/pristine/3c/3ccec6df214003e473144d4b6017d8e81b6856cb.svn-base @@ -0,0 +1,62 @@ +#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::RBGA& colour ); + void setTextSize( const unsigned long int size ); + + ///Gets + const cString getText() const; + const GUIHelpers::RBGA getTextColour(); + const unsigned long int getTextSize(); + + virtual const GUIHelpers::eType getType() const; + + private: + void CreateLabel(); + void GenerateImage(); + void GenerateTexture(); + + private: + 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/.svn/pristine/3d/3d0fd990c7d7ecb9a1683fc54023ccbaef130b7d.svn-base b/.svn/pristine/3d/3d0fd990c7d7ecb9a1683fc54023ccbaef130b7d.svn-base new file mode 100644 index 0000000..a2f0c8a --- /dev/null +++ b/.svn/pristine/3d/3d0fd990c7d7ecb9a1683fc54023ccbaef130b7d.svn-base @@ -0,0 +1,86 @@ +#include "cEvent.hpp" + +/*** Custom Header Files ***/ +#include "../InputEngine/cInput.hpp" +#include "../MathEngine/iVector/iVector2.hpp" +#include "../GUIEngine/cGUI.hpp" + +using EventEngine::cEvent; +using MathEngine::iVector2; + +/*static*/ cEvent* cEvent::sp_inst = nullptr; + +//Private +cEvent::cEvent() +{} + +cEvent::~cEvent() +{ + CleanUp(); +} + +//Public +/*static*/ cEvent& cEvent::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cEvent(); + return *sp_inst; +} + +/*static*/ void cEvent::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +//Functions +const bool cEvent::Initialize() const +{ + return true; +} + +const bool cEvent::Setup() +{ + return true; +} + +void cEvent::CleanUp() +{ +} + +/* Checks for Events */ +void cEvent::CheckEvents() +{ + while ( SDL_PollEvent(&m_event)) { + iVector2 location = { 0, 0 }; + switch (m_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(m_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; + } + } +} + + +///Sets + +///Gets +/* Gets return true if Event was initialized */ +const bool cEvent::IsInit() const +{ + return true; +} \ No newline at end of file diff --git a/.svn/pristine/3d/3d5b04ea16a4c934732aa9099fd54dbedb9d9643.svn-base b/.svn/pristine/3d/3d5b04ea16a4c934732aa9099fd54dbedb9d9643.svn-base new file mode 100644 index 0000000..e5502ea --- /dev/null +++ b/.svn/pristine/3d/3d5b04ea16a4c934732aa9099fd54dbedb9d9643.svn-base @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineDLL", "TrooperEngineDLL\TrooperEngineDLL.vcxproj", "{B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineTest", "TrooperEngineTest\TrooperEngineTest.vcxproj", "{9225E043-EE77-43AA-A140-C9C2F85B1013}" + ProjectSection(ProjectDependencies) = postProject + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} = {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPongCPP", "SDLPongCPP\SDLPongCPP.vcxproj", "{D0670630-6CBB-4894-BAC6-35FD775E8D8E}" +EndProject +Global + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.Build.0 = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|x64.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.ActiveCfg = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.Build.0 = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|x64.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.ActiveCfg = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.Build.0 = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.ActiveCfg = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.Build.0 = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.Build.0 = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.ActiveCfg = Release|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.Build.0 = Release|x64 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.Build.0 = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|x64.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.ActiveCfg = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.Build.0 = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/.svn/pristine/41/414c93cacc71bc7a238c568cf206a7c5ffaf79f9.svn-base b/.svn/pristine/41/414c93cacc71bc7a238c568cf206a7c5ffaf79f9.svn-base new file mode 100644 index 0000000..f60ecbe --- /dev/null +++ b/.svn/pristine/41/414c93cacc71bc7a238c568cf206a7c5ffaf79f9.svn-base @@ -0,0 +1,507 @@ +#include "cWindow.hpp" + + +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RGBA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; +/*static*/ GUIHelpers::eOrientation cWindow::sORIENTATION = GUIHelpers::eOrientation::NONE; + +cWindow::cWindow( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) + : cObject(id) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cWindow::~cWindow() +{ + for (unsigned int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +/*virtual*/ void cWindow::Create( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) +{ + mp_parent = parent; + cObject::setID(id); + setOrientation(orientation); + setAlign(align); + setLayout(layout); + setPosition(pos); + setSize(size); + setPadding(padding); + m_name = name; +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } + + DebugDisplay(); +} + +///Functions +const bool cWindow::Inside( const MathEngine::iVector2& location ) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild( cWindow* obj ) +{ + m_children.push_back(obj); +} + +void cWindow::RemoveChild( cWindow* obj ) +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + //break out of the for loop + break; + } + } +} + +///Sets +/*static*/ void cWindow::PositionDefault( const GUIHelpers::Position& pos ) +{ + if (pos.x >= 0) + sPOSITION = pos; +} + +/*static*/ void cWindow::SizeDefault( const GUIHelpers::Size& size ) +{ + if (size.x >= 0) + sSIZE = size; +} + +/*static*/ void cWindow::PaddingDefault( const GUIHelpers::Padding& pad ) +{ + if (pad.x >= 0) + sPADDING = pad; +} + +/*static*/ void cWindow::AlignDefault( const GUIHelpers::eAlign& align ) +{ + if (align != GUIHelpers::eAlign::DEFAULT_ALIGN) + sALIGN = align; +} + +/*static*/ void cWindow::LayoutDefault( const GUIHelpers::eLayout& layout ) +{ + if (layout != GUIHelpers::eLayout::DEFAULT_LAYOUT) + sLAYOUT = layout; +} + +/*static*/ void cWindow::OrientationDefault( const GUIHelpers::eOrientation& orientation ) +{ + if (orientation != GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + sORIENTATION = orientation; +} + +void cWindow::setOrientation( const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/ ) +{ + if (orientation == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + m_orientation = cWindow::sORIENTATION; + else + m_orientation = orientation; +} + +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= sALIGN*/ ) +{ + if (align == GUIHelpers::eAlign::DEFAULT_ALIGN) + m_align = cWindow::sALIGN; + else + m_align = align; +} + +void cWindow::setLayout( const GUIHelpers::eLayout& layout /*= sLAYOUT*/ ) +{ + if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT) + m_layout = cWindow::sLAYOUT; + else + m_layout = layout; +} + +void cWindow::setPosition( const GUIHelpers::Position& pos /*= POSITION*/ ) +{ + if (pos.x < 0) + m_pos = cWindow::sPOSITION; + else + m_pos = pos; +} + +void cWindow::setSize( const GUIHelpers::Size& size /*= sSIZE*/ ) +{ + if (size.x < 0) + m_size = cWindow::sSIZE; + else + m_size = size; +} + +void cWindow::setPadding( const GUIHelpers::Padding& padding /*= PADDING*/ ) +{ + if (padding.x < 0) + m_padding = cWindow::sPADDING; + else + m_padding = padding; +} + +void cWindow::setContentSize( const GUIHelpers::Size& content ) +{ + m_content = content; +} + +void cWindow::setName( const cString& name /*= NAME*/ ) +{ + m_name = name; +} + +void cWindow::setParent( cWindow* parent ) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::Position cWindow::getCenter( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = { 0, 0 }; + rtn.x = (m_size.x / 2) + m_pos.x; + rtn.y = (m_size.y / 2) + m_pos.y; + if (pad == true) { + rtn.x += (m_padding.x - m_padding.w); + rtn.y += (m_padding.y - m_padding.z); + } + return rtn; +} + +const GUIHelpers::eOrientation& cWindow::getOrientation() const +{ + return m_orientation; +} + +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position cWindow::getPosition( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = m_pos; + + if (pad == false) { + rtn.x -= m_padding.x; + rtn.y -= m_padding.y; + } + + return rtn; +} + +const GUIHelpers::Size cWindow::getSize( const bool pad /*= true*/ ) const +{ + GUIHelpers::Size rtn = m_size; + + if (pad == true) { + rtn.x += m_padding.x + m_padding.w; + rtn.y += m_padding.y + m_padding.z; + } + + return rtn; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout( const GUIHelpers::eLayout& layout ) +{ + GUIHelpers::Size mySize = { 0, 0 }; + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + GUIHelpers::Position myPos = mp_parent->getPosition(false); + myPos.x += m_padding.x; + myPos.y += m_padding.y; + mySize = mp_parent->getSize(false); + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + m_pos = myPos; + m_size = mySize; + } + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + if (m_children.size() > 0) { + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + AddSize(size.x, size.y, mySize); + } + } + else { + if (mp_parent != nullptr) + m_pos = mp_parent->getCenter(); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } + + if (this->getType() == GUIHelpers::eType::CLAYOUT) { + GUIHelpers::Position prtCenter = getCenter(); + GUIHelpers::Position ourSet = prtCenter; + GUIHelpers::Size totalSize = { 0, 0 }; + GUIHelpers::Position totalCenter = { 0, 0 }; + + for (it = m_children.begin(); it < m_children.end(); it++) { + totalSize += (*it)->getSize(); + } + totalCenter.x = totalSize.x / 2; + totalCenter.y = totalSize.y / 2; + + ourSet.x -= totalCenter.x; + ourSet.y -= totalCenter.y; + + + GUIHelpers::Position posSet = ourSet; + GUIHelpers::Position posNext = posSet; + for (it = m_children.begin(); it < m_children.end(); it++) { + posSet = posNext; + GUIHelpers::Padding pad = (*it)->getPadding(); + GUIHelpers::Size size = (*it)->getSize(false); + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + posSet.x += pad.x; + posSet.y = (pad.y - pad.z - (size.y / 2)) + prtCenter.y; + + posNext = posSet; + + posNext.x += size.x + pad.w; + //posNext.y = ourSet.y; + } + else { + posSet.x = (pad.x - pad.w - (size.x / 2)) + prtCenter.x; + posSet.y += pad.y; + + posNext = posSet; + + //posNext.x = ourSet.x; + posNext.y += size.y + pad.z; + } + + (*it)->setPosition(posSet); + (*it)->RebuildPos(); + } + } +} + +/*virtual*/ void cWindow::RebuildPos() +{ + if (this->getAlign() != GUIHelpers::eAlign::CENTER) { + GUIHelpers::Position prtPos = mp_parent->getPosition(); + GUIHelpers::Size prtSize = mp_parent->getSize(); + + GUIHelpers::Position pos = this->getPosition(); + GUIHelpers::Size size = this->getSize(); + + GUIHelpers::Padding pad = this->getPadding(); + + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + switch (this->getAlign()) { + case GUIHelpers::eAlign::BOTTOM: + pos.y = prtSize.y - size.y; + break; + case GUIHelpers::eAlign::TOP: + pos.y = prtPos.y + pad.y; + break; + } + } + else { + switch (this->getAlign()) { + case GUIHelpers::eAlign::RIGHT: + pos.x = prtSize.x - size.x; + break; + case GUIHelpers::eAlign::LEFT: + pos.x = prtPos.x + pad.x; + break; + } + } + this->setPosition(pos); + } +} + +/*virtual*/ const GUIHelpers::RGBA cWindow::getDebugColour() const +{ + return GUIHelpers::WHITE; +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} + +//private +void cWindow::AddSize( int x, int y, GUIHelpers::Size& mySize ) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo < largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} + +void cWindow::DebugDisplay() const +{ + unsigned long int debugLvl = GUIEngine::cGUI::Inst().getDebugLevel(); + if (debugLvl > 0) { + SDL_Rect rect; + rect.x = m_pos.x; + rect.y = m_pos.y; + rect.w = m_pos.x + m_size.x; + rect.h = m_pos.y + m_size.y; + + GUIHelpers::Position strPos = getCenter(); + + GUIHelpers::RGBA colour = getDebugColour(); + FXEngine::cGFX::Inst().Pixel(strPos.x, strPos.y, colour); + + cString str = ""; + str.format("X: %d Y: %d", strPos.x, strPos.y); + FXEngine::cGFX::Inst().StringDefault(str, { strPos.x + 2, strPos.y + 2, 0, 0 }, colour); + + if (debugLvl > 1) { + SDL_Rect typePos = { 2, 2, 0, 0 }; + cString type = ""; + switch (getType()) { + case GUIHelpers::eType::CPANEL: + type = "Panel"; + break; + case GUIHelpers::eType::CLAYOUT: + type = "Layout"; + break; + case GUIHelpers::eType::CLABEL: + typePos = { -10, -10, 0, 0 }; + type = "Label"; + break; + default: + type = ""; + } + + typePos.x += m_pos.x; + typePos.y += m_pos.y; + + FXEngine::cGFX::Inst().StringDefault(type, typePos, colour); + +// if (debugLvl > 2) { +// GUIHelpers::Position pos = getPosPPad(); +// //GUIHelpers::Size size = getSizePPad(); +// SDL_Rect box{ 0, 0, 0, 0 }; +// box.x += pos.x; +// box.y += pos.y; +// box.h += pos.y + m_size.y + m_padding.y + m_padding.z; +// box.w += pos.x + m_padding.x; +// +// FXEngine::cGFX::Inst().Box(box, colour); +// } + } + + FXEngine::cGFX::Inst().Rectangle(rect, colour); + } +} \ No newline at end of file diff --git a/.svn/pristine/43/4364afa90665dd6b57e561b9335a3364b963c56b.svn-base b/.svn/pristine/43/4364afa90665dd6b57e561b9335a3364b963c56b.svn-base new file mode 100644 index 0000000..fff4124 --- /dev/null +++ b/.svn/pristine/43/4364afa90665dd6b57e561b9335a3364b963c56b.svn-base @@ -0,0 +1,14 @@ +#ifndef __MSUNIX__ +#define __MSUNIX__ + +#define _MSUNIX_VERSION "1.0.0" + +#include +#include +#include + +int vasprintf(char ** ret, const char * format, va_list ap); +//int snprintf(char * str, size_t size, const char * format, ...); +int setenv(const char *name, const char *value, int overwrite); + +#endif // __MSUNIX__ diff --git a/.svn/pristine/43/437d91649e42fa9eeb25c1cda91c65a4a1961211.svn-base b/.svn/pristine/43/437d91649e42fa9eeb25c1cda91c65a4a1961211.svn-base new file mode 100644 index 0000000..bad9577 Binary files /dev/null and b/.svn/pristine/43/437d91649e42fa9eeb25c1cda91c65a4a1961211.svn-base differ diff --git a/.svn/pristine/43/43a0ea7dcac74a8eb3e8fdb7e78aef97a2aaee94.svn-base b/.svn/pristine/43/43a0ea7dcac74a8eb3e8fdb7e78aef97a2aaee94.svn-base new file mode 100644 index 0000000..14be436 --- /dev/null +++ b/.svn/pristine/43/43a0ea7dcac74a8eb3e8fdb7e78aef97a2aaee94.svn-base @@ -0,0 +1,47 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineDLL", "TrooperEngineDLL\TrooperEngineDLL.vcxproj", "{B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineTest", "TrooperEngineTest\TrooperEngineTest.vcxproj", "{9225E043-EE77-43AA-A140-C9C2F85B1013}" + ProjectSection(ProjectDependencies) = postProject + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} = {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPongCPP", "SDLPongCPP\SDLPongCPP.vcxproj", "{D0670630-6CBB-4894-BAC6-35FD775E8D8E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.Build.0 = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|x64.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.ActiveCfg = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.Build.0 = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|x64.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.ActiveCfg = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.Build.0 = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.ActiveCfg = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.Build.0 = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.Build.0 = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.ActiveCfg = Release|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.Build.0 = Release|x64 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.Build.0 = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|x64.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.ActiveCfg = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.Build.0 = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/.svn/pristine/44/4419c0418fd87dbd92345995ac016665620acf08.svn-base b/.svn/pristine/44/4419c0418fd87dbd92345995ac016665620acf08.svn-base new file mode 100644 index 0000000..7d83d35 --- /dev/null +++ b/.svn/pristine/44/4419c0418fd87dbd92345995ac016665620acf08.svn-base @@ -0,0 +1,108 @@ +#ifndef _CWINDOW_HPP_ +#define _CWINDOW_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject + { + public: + static const UtilityEngine::cString sNAME; /*= "windows";*/ + static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/ + static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/ + static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/ + static GUIHelpers::RBGA sCOLOUR; /*= { 100, 100, 100, 255 };*/ + + static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/ + static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/ + static GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::NONE;*/ + + protected: + cWindow( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cWindow(); + + virtual void Create(cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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); + + public: + ///Functions + virtual void Display(); + + const bool Inside( const MathEngine::iVector2& location ) const; + + void AddChild( cWindow* obj ); + + void RemoveChild( cWindow* obj ); + + ///Sets + void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION ); + void setAlign( const GUIHelpers::eAlign& align = sALIGN ); + void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT ); + void setPosition( const GUIHelpers::Position& pos = sPOSITION ); + void setSize( const GUIHelpers::Size& size = sSIZE ); + void setPadding(const GUIHelpers::Padding& padding = sPADDING); + void setContentSize( const GUIHelpers::Size& content ); + void setName( const cString& name = sNAME ); + + void setParent( cWindow* parent ); + + ///Gets + const GUIHelpers::eOrientation& getOrientation() const; + const GUIHelpers::eAlign& getAlign() const; + const GUIHelpers::eLayout& getLayout() const; + const GUIHelpers::Position& getPosition() const; + const GUIHelpers::Size& getSize() const; + const GUIHelpers::Padding& getPadding() const; + const GUIHelpers::Size& getContentSize() const; + const cString& getName() const; + + cWindow* getParent(); + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + virtual void RePos(); + virtual void RebuildPos(); + + protected: + std::vector& getChildren(); + + private: + void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout ); + + void AddSize(int x, int y, GUIHelpers::Size& mySize) const; + + private: + GUIHelpers::eOrientation m_orientation;// = GUIHelper::eOrientation::NONE; + GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER; + GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT; + GUIHelpers::Position m_pos;// = POSITION; + GUIHelpers::Size m_size;// = SIZE; + GUIHelpers::Padding m_padding;// = PADDING; + GUIHelpers::Size m_content;// = m_size; + cString m_name;// = NAME; + + std::vector m_children; + cWindow* mp_parent;// = nullptr; + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ diff --git a/.svn/pristine/44/442e0bb2d6ada0a182adf8f937c90e8cc8e9dab0.svn-base b/.svn/pristine/44/442e0bb2d6ada0a182adf8f937c90e8cc8e9dab0.svn-base new file mode 100644 index 0000000..0caa85e --- /dev/null +++ b/.svn/pristine/44/442e0bb2d6ada0a182adf8f937c90e8cc8e9dab0.svn-base @@ -0,0 +1,39 @@ +#ifndef _IVECTOR4_HPP_ +#define _IVECTOR4_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "iVector3.hpp" + +namespace MathEngine { + struct Vector4; + + struct EXPORT_FROM_MYDLL iVector4 : public iVector3 + { + iVector4( const int X = 0, const int Y = 0, const int Z = 0, const int W = 0 ); + + iVector4( const iVector2& copy ); + + iVector4( const iVector3& copy ); + + iVector4( const SDL_Rect& copy ); + + iVector4& operator=( const SDL_Rect& copy ); + + bool operator==( const SDL_Rect& other ) const; + + iVector4( const Vector4& copy ); + + iVector4& operator=( const Vector4& copy ); + + bool operator==( const iVector4& other ) const; + + int w; + };/// END STRUCT DEFINITION iVector4 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _IVECTOR4_HPP_ \ No newline at end of file diff --git a/.svn/pristine/44/44ed4fcd8d98ecb44af9ca1e0b8366d86e1c6d80.svn-base b/.svn/pristine/44/44ed4fcd8d98ecb44af9ca1e0b8366d86e1c6d80.svn-base new file mode 100644 index 0000000..e08f83d --- /dev/null +++ b/.svn/pristine/44/44ed4fcd8d98ecb44af9ca1e0b8366d86e1c6d80.svn-base @@ -0,0 +1,393 @@ +#include "cString.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +#ifdef _MSC_VER +// disable _s warnings +# define _CRT_SECURE_NO_WARNINGS +// disable pragma warnings +# pragma warning( disable : 4068 ) +# pragma warning( disable : 4996 ) +# include "MSUNIX/msunix.hpp" +#endif + +using UtilityEngine::cString; + +cString::cString() +{ + clear(); +} + +cString::cString(const char* s) +{ + copy_str(s); +} + +cString::cString(const cString& copy) +{ + copy_str(copy); +} + + +cString::~cString() +{ + clear(); +} + +const char* cString::alloc_str(size_t sz) +{ + if (mp_str) + clear(); + m_len = (sz > __cString__MAX_LEN) ? __cString__MAX_LEN : sz; + mp_str = (char *)calloc(1, m_len + 1); + return mp_str; +} + +void cString::clear() +{ + if (mp_str) + free((void *)mp_str); + mp_str = nullptr; + m_len = 0; +} + +const char* cString::c_str() const +{ + return mp_str; +} + +const char* cString::copy_str(const char* copy) +{ + if (copy) { + size_t len = strnlen(copy, __cString__MAX_LEN); + alloc_str(len); + strncpy((char *)mp_str, copy, len); + m_len = len; + } + return mp_str; +} + +bool cString::have_value() const +{ + if (mp_str) + return true; + else + return false; +} + +size_t cString::length() const +{ + return m_len; +} + +size_t cString::size() const +{ + return m_len; +} + +// string format +cString& cString::format(const char* format, ...) +{ + char * buffer; + + va_list args; + va_start(args, format); + + vasprintf(&buffer, format, args); + copy_str(buffer); + free(buffer); + return *this; +} + +// trim leading and trailing spaces +cString& cString::trim() +{ + const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a"; + + if (!have_value()) + return *this; // make sure we have a string + + size_t begin = 0; + size_t end = length() - 1; + + for (begin = 0; begin <= end; ++begin) { + if (strchr(whitespace, mp_str[begin]) == nullptr) { + break; + } + } + + for (; end > begin; --end) { + if (strchr(whitespace, mp_str[end]) == nullptr) { + break; + } + else { + mp_str[end] = '\0'; + } + } + + if (begin) { + for (size_t i = 0; mp_str[i]; ++i) { + mp_str[i] = mp_str[begin++]; + } + } + + m_len = strlen(mp_str); + return *this; +} + +cString cString::lower() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)tolower(rs.mp_str[i]); + } + return rs; +} + +cString cString::upper() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)toupper(rs.mp_str[i]); + } + return rs; +} + +const char & cString::last_char() const +{ + return mp_str[length() - 1]; +} + +// non-destructive split +const std::vector cString::split(const char match) const +{ + const char match_s[2] = { match, 0 }; + return split(match_s, -1); +} + +const std::vector cString::split(const char* match) const +{ + return split(match, -1); +} + +const std::vector cString::split(const char* match, int max_split) const +{ + std::vector rv; + if (length() < 1) + return rv; + size_t match_len = strnlen(match, __cString__MAX_LEN); + if (match_len >= __cString__MAX_LEN) + return rv; + + char * mi; // match index + char * pstr = mp_str; // string pointer + mi = strstr(pstr, match); + while ((mi) && (max_split < 0 || --max_split)) { + if (mi != pstr) { + size_t lhsz = mi - pstr; + char * cslhs = (char *)malloc(lhsz + 1); + cslhs[lhsz] = '\0'; // strncpy doesn't terminate it + rv.emplace_back(strncpy(cslhs, pstr, lhsz)); // calls BWString copy ctor + pstr += lhsz; + free(cslhs); + } + pstr += match_len; + } + + if (*pstr != '\0') { + rv.emplace_back(pstr); + } + + return rv; +} + +const cString& cString::char_repl(const char& match, const char& repl) +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) mp_str[i] = repl; + } + return *this; +} + +long int cString::char_find(const char& match) const +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) + return i; + } + return -1; +} + +cString cString::substr(size_t start, size_t length) const +{ + cString rs; + char * buf; + if ((length + 1) > __cString__MAX_LEN) + return rs; + if ((start + length) > __cString__MAX_LEN) + return rs; + if (length > m_len - start) + return rs; + if (!mp_str) + return rs; + + buf = (char *)calloc(sizeof(char), length + 1); + memcpy(buf, mp_str + start, length); + rs = buf; + return rs; +} + +long int cString::find(const cString& match) +{ + char * pos = strstr(mp_str, match.c_str()); + if (pos) + return (long)(pos - mp_str); + else + return -1; +} + +const cString cString::replace(const cString& match, const cString& repl) +{ + cString rs; + long f1 = find(match); + if (f1 >= 0) { + size_t pos1 = (size_t)f1; + size_t pos2 = pos1 + match.length(); + cString s1 = pos1 > 0 ? substr(0, pos1) : ""; + cString s2 = substr(pos2, length() - pos2); + rs = s1 + repl + s2; + } + return rs; +} + +const long int cString::ToInt() const +{ + return strtol(mp_str, NULL, 10); +} + +cString& cString::operator = (const char* rhs) +{ + copy_str(rhs); + return *this; +} + +cString& cString::operator = (const cString& rhs) +{ + copy_str(rhs.c_str()); + return *this; +} + +cString& cString::operator += (const char rhs) +{ + operator+=(&rhs); + return *this; +} + +cString& cString::operator += (const char* rhs) +{ + if (rhs) { + size_t newlen = m_len + strnlen(rhs, __cString__MAX_LEN); + if (newlen > __cString__MAX_LEN) + newlen = __cString__MAX_LEN; + char * buf = (char *)calloc(1, newlen + 1); + if (!buf) + return *this; + + if (mp_str && m_len) + strncpy(buf, mp_str, m_len); + strncpy(buf + m_len, rhs, newlen - m_len); + + buf[newlen] = '\0'; + copy_str(buf); + free(buf); + } + return *this; +} + +cString& cString::operator += (const cString& rhs) +{ + operator+=(rhs.c_str()); + return *this; +} + +bool cString::operator == (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator == (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator != (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator != (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator > (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) > 0) + return true; + else + return false; +} + +bool cString::operator < (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) < 0) + return true; + else + return false; +} + +bool cString::operator >= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) >= 0) + return true; + else + return false; +} + +bool cString::operator <= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) <= 0) + return true; + else return false; +} + +cString::operator const char* () const +{ + return c_str(); +} + +cString::operator std::string () const +{ + return std::string(c_str()); +} + +cString operator + (const cString& lhs, const cString& rhs) +{ + cString rs = lhs; + rs += rhs; + return rs; +} + diff --git a/.svn/pristine/45/457407e5c0f66120f20fda6ccc85c77339b842e3.svn-base b/.svn/pristine/45/457407e5c0f66120f20fda6ccc85c77339b842e3.svn-base new file mode 100644 index 0000000..2aca9c8 --- /dev/null +++ b/.svn/pristine/45/457407e5c0f66120f20fda6ccc85c77339b842e3.svn-base @@ -0,0 +1,325 @@ +#include "GUIXMLTest.hpp" + +void GUIXMLTest() +{ + // cString + printf("\nTesting GUI XML Test -----\n\n"); + + GUIXMLDefaultTest(); + + GUIXMLPositionTest(); + + GUIXMLAlignTest(); + +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::LEFT); +// +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER); +// GUIXMLAlignTest(GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::RIGHT); +// +// ////////////////////////////////////////////////////////////////////////// +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::CENTER); +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::RIGHT); +// +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::LEFT); +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER); +// GUIXMLAlignTest(GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::RIGHT, GUIHelpers::eAlign::RIGHT); + + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::BOTTOM, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::BOTTOM, GUIHelpers::eAlign::BOTTOM, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::CENTER, GUIHelpers::CENTER, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::BOTTOM, GUIHelpers::eAlign::BOTTOM, GUIHelpers::BOTTOM, GUIHelpers::eOrientation::HORIZONTAL); + + ////////////////////////////////////////////////////////////////////////// + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::CENTER, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::BOTTOM, GUIHelpers::eOrientation::HORIZONTAL); + + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::TOP, GUIHelpers::TOP, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::CENTER, GUIHelpers::CENTER, GUIHelpers::eOrientation::HORIZONTAL); + GUIXMLAlignTest(GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::BOTTOM, GUIHelpers::BOTTOM, GUIHelpers::eOrientation::HORIZONTAL); + +} + +void GUIXMLDefaultTest() +{ + UTest u("GUI XML Default"); + + LoadFile("GUIXMLDefaultTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 100, 100 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 5, 5 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + + sets.pos = { 56, 96 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLPositionTest() +{ + UTest u("GUI XML Position"); + + LoadFile("GUIXMLPositionTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 20, 20 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 120, 120 }; + + cWindowTest("Panel", u, panel, sets); + + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 25, 25 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + sets.pos = { 76, 116 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLAlignTest( const GUIHelpers::eAlign one /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, const GUIHelpers::eAlign two /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, + const GUIHelpers::eAlign three /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, const GUIHelpers::eOrientation orientation /*= GUIHelpers::eOrientation::DEFAULT_ORIENTATION*/ ) +{ + UTest u("GUI XML Align"); + + LoadFile("GUIXMLAlignTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 400, 400 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 200, 200 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + if (orientation != GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + layout->setOrientation(orientation); + + sets.pos = { 5, 5 }; + sets.size = { 390, 390 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + cString msg = ""; + + if (one != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(one); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 10, 10 }; + sets.center = { 74, 14}; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 10, 382 }; + sets.center = { 74, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 178 }; + sets.center = { 74, 182 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 136, 178 }; + sets.center = { 200, 182 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 10, 196 }; + sets.center = { 74, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 262, 178 }; + sets.center = { 326, 182 }; + break; + } + + sets.size = { 128, 8 }; + + cWindowTest("Label 'Hello world One' " + msg, u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[1]; + + if (two != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(two); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 128, 10 }; + sets.center = { 200, 14 }; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 128, 382 }; + sets.center = { 200, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 196 }; + sets.center = { 82, 200 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 128, 196 }; + sets.center = { 200, 200 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 128, 196 }; + sets.center = { 200, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 246, 196 }; + sets.center = { 318, 200 }; + break; + } + + sets.size = { 144, 8 }; + + cWindowTest("Label 'Hello world Two' " + msg, u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[2]; + + if (three != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(three); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 254, 10 }; + sets.center = { 322, 14 }; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 254, 382 }; + sets.center = { 322, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 214 }; + sets.center = { 78, 218 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 132, 214 }; + sets.center = { 200, 218 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 254, 196 }; + sets.center = { 322, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 254, 214 }; + sets.center = { 322, 218 }; + break; + } + sets.size = { 136, 8 }; + + cWindowTest("Label 'Hello world Three' " + msg, u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Display(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void LoadFile( const cString& filename, const bool show /*= false*/ ) +{ + GUIEngine::cGUI::Inst().Delete(); + GUIEngine::cGUI::Inst().Initialize(filename, "xml/"); + printf(cString("\nUsing " + filename + " file.\n").c_str()); + + if (show == true) + GUIEngine::cGUI::Inst().Display(); +} + +void cWindowTest(const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets) +{ + cWindowTest(msg, u, win, sets.pos, sets.size, sets.pad, sets.center); +} + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center) +{ + u.test(msg + " Position", win->getPosition() == pos); + + u.test(msg + " Size", win->getSize(false) == size); + + u.test(msg + " Padding", win->getPadding() == pad); + + u.test(msg + " Center", win->getCenter() == center); +} \ No newline at end of file diff --git a/.svn/pristine/46/463f02010e3a396d023a2ca58d7dde9f9a0f5081.svn-base b/.svn/pristine/46/463f02010e3a396d023a2ca58d7dde9f9a0f5081.svn-base new file mode 100644 index 0000000..f2df3b4 --- /dev/null +++ b/.svn/pristine/46/463f02010e3a396d023a2ca58d7dde9f9a0f5081.svn-base @@ -0,0 +1,63 @@ +#ifndef _CBUTTON_HPP_ +#define _CBUTTON_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" +#include "../VideoEngine/cSprite.hpp" +#include "../VideoEngine/cImage.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +#include "cPanel.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cButton : public cWindow, public VideoEngine::cSprite + { + 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 ); + virtual ~cButton(); + + ///Functions + void Create( 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 ); + + virtual void Press(); + + //Sets + + ///Gets + virtual const GUIHelpers::eType getType() const; + + private: + void CreateLabel(); + void GenerateImage(); + void GenerateTexture(); + + private: + VideoEngine::cImage* mp_texture;// = nullptr + VideoEngine::cImage* mp_texturePress;// = nullptr + + //Pointer to the image that will be displayed on the button. + VideoEngine::cImage** mpp_image;// = nullptr + };/// END CLASS DEFINITION cButton +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBUTTON_HPP_ \ No newline at end of file diff --git a/.svn/pristine/46/46f68f33c633523dea26ebfbdb3ae144a9b39c9e.svn-base b/.svn/pristine/46/46f68f33c633523dea26ebfbdb3ae144a9b39c9e.svn-base new file mode 100644 index 0000000..6311162 --- /dev/null +++ b/.svn/pristine/46/46f68f33c633523dea26ebfbdb3ae144a9b39c9e.svn-base @@ -0,0 +1,88 @@ +#include "cGFX.hpp" + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using FXEngine::cGFX; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cGFX* cGFX::sp_inst = nullptr; + +//private: +cGFX::cGFX() +{} + +cGFX::~cGFX() +{} + +//public: +///Functions +/*static*/ cGFX& cGFX::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGFX(); + return *sp_inst; +} + +/*static*/ void cGFX::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const +{ + if (stringRGBA(cRenderer::Inst().getRenderer(), (Sint16)pos.x, (Sint16)pos.y, text.c_str(), colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + StringDefault(text, pos, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const +{ + if (roundedBoxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, (Sint16)rad, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. roundedRectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + RoundedRectangle(rect, rad, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour) const +{ + if (pixelRGBA(cRenderer::Inst().getRenderer(), (Sint16)x, (Sint16)y, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. pixelRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Pixel(x, y, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour) const +{ + if (rectangleRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. rectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Rectangle(rect, colour); + cRenderer::Inst().ResetRenderTarget(); +} \ No newline at end of file diff --git a/.svn/pristine/47/471b4d7e6658f6bc7b551ec9a99e4b19e6c0f766.svn-base b/.svn/pristine/47/471b4d7e6658f6bc7b551ec9a99e4b19e6c0f766.svn-base new file mode 100644 index 0000000..49fa237 --- /dev/null +++ b/.svn/pristine/47/471b4d7e6658f6bc7b551ec9a99e4b19e6c0f766.svn-base @@ -0,0 +1,129 @@ + + + + + {813fe0d0-021e-4a7a-81f6-8c257531e86f} + + + {b1e548f9-e924-4aeb-b70c-45e0149e8ff3} + + + {7010506c-0310-40f7-a3ea-6e9e99ecdb81} + + + {9e5916e8-437a-4c0d-800a-5ea486c57b97} + + + {d393f48f-a4c2-4a35-a524-e78235977f9e} + + + {cf62df37-481f-445c-834d-74549b98aaa4} + + + {d381fec8-ab66-45a6-b6b9-96e5d5a4bfdb} + + + + + Main + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + \ No newline at end of file diff --git a/.svn/pristine/47/4781031fb0bd5f0941417c397fc43504243cbbf9.svn-base b/.svn/pristine/47/4781031fb0bd5f0941417c397fc43504243cbbf9.svn-base new file mode 100644 index 0000000..52fb866 --- /dev/null +++ b/.svn/pristine/47/4781031fb0bd5f0941417c397fc43504243cbbf9.svn-base @@ -0,0 +1,43 @@ +#ifndef _CBOXSIZER_HPP_ +#define _CBOXSIZER_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cPanel.hpp" +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cBoxSizer : public cWindow + { + public: + static const cString sNAME; /*= "boxsizer";*/ + + cBoxSizer( 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 ); + virtual ~cBoxSizer(); + + ///Functions + void Create( 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 ); + + virtual const GUIHelpers::eType getType() const; + private: + private: + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ \ No newline at end of file diff --git a/.svn/pristine/48/486e850c889a101fcd18db02859e6dcf311c57b3.svn-base b/.svn/pristine/48/486e850c889a101fcd18db02859e6dcf311c57b3.svn-base new file mode 100644 index 0000000..af41a65 --- /dev/null +++ b/.svn/pristine/48/486e850c889a101fcd18db02859e6dcf311c57b3.svn-base @@ -0,0 +1,226 @@ +#include "cMainMenu.hpp" + +using MainMenu::cMainMenu; +using MainMenu::eOptions; +using MainMenu::operator ++; +using MainMenu::operator --; + +cMainMenu::cMainMenu() + : mp_camera(nullptr), mp_font(nullptr), mp_titleText(nullptr), mp_singleText(nullptr), mp_headText(nullptr), mp_quitText(nullptr), m_option(Start), m_run(true) +{ + mp_camera = new VideoEngine::cCamera(); + + m_titleSprite.setCamera(&mp_camera); + m_singleSprite.setCamera(&mp_camera); + m_headSprite.setCamera(&mp_camera); + m_quitSprite.setCamera(&mp_camera); + + m_colour.r = 255; + m_colour.g = 0; + m_colour.b = 0; + + m_selectColour.r = 0; + m_selectColour.g = 0; + m_selectColour.b = 255; + + m_titleColour.r = 255; + m_titleColour.g = 255; + m_titleColour.b = 255; +} + +cMainMenu::~cMainMenu() +{ + delete mp_camera; + mp_camera = nullptr; + + delete mp_font; + mp_font = nullptr; + + +} + +const eOptions cMainMenu::ShowMenu() +{ + SingleSelect(); + while (m_run == true) { + Display(); + Input(); + } + + return m_option; +} + +void cMainMenu::OptionUp() +{ + --m_option; + PlaySound(); + switch (m_option) + { + case Start: + SingleSelect(); + break; + case Head: + HeadSelect(); + break; + case Quit: + QuitSelect(); + break; + } +} + +void cMainMenu::OptionDown() +{ + ++m_option; + PlaySound(); + switch (m_option) + { + case Start: + SingleSelect(); + break; + case Head: + HeadSelect(); + break; + case Quit: + QuitSelect(); + break; + } +} + +void cMainMenu::OptionSelect() +{ + m_run = false; +} + +void cMainMenu::setOption( const eOptions option /*= eOptions::Start*/ ) +{ + m_option = option; +} + +void cMainMenu::setSound( const cString dir, const cString filename ) +{ + m_menuSound.setFileNameandDir(filename, dir); + m_menuSound.setLoops(0); +} + +void cMainMenu::setColour( const SDL_Colour colour ) +{ + m_colour = colour; +} + +void cMainMenu::setSelectColour( const SDL_Colour selectcolour ) +{ + m_selectColour = selectcolour; +} + +void cMainMenu::setTitleColour( const SDL_Colour titlecolour ) +{ + m_titleColour = titlecolour; +} + +void cMainMenu::setFont( const cString dir, const cString filename ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont(dir, filename); +} + +void cMainMenu::setTitleText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_titleText = new TextTypeEngine::cText(m_titleColour, &mp_font, text, size); + + m_titleSprite.setPosition(x, y); + m_titleSprite.setImage((VideoEngine::cImage**)(&mp_titleText)); + m_titleSprite.setImageArea(); +} + +void cMainMenu::setSingleText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_singleText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_singleSprite.setPosition(x, y); + m_singleSprite.setImage((VideoEngine::cImage**)(&mp_singleText)); + m_singleSprite.setImageArea(); +} + +void cMainMenu::setHeadText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_headText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_headSprite.setPosition(x, y); + m_headSprite.setImage((VideoEngine::cImage**)(&mp_headText)); + m_headSprite.setImageArea(); +} + +void cMainMenu::setQuitText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_quitText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_quitSprite.setPosition(x, y); + m_quitSprite.setImage((VideoEngine::cImage**)(&mp_quitText)); + m_quitSprite.setImageArea(); +} + +///Private +void cMainMenu::ResetTextColour() +{ + if (mp_singleText != nullptr) + mp_singleText->setColour(m_colour); + + if (mp_headText != nullptr) + mp_headText->setColour(m_colour); + + if (mp_quitText != nullptr) + mp_quitText->setColour(m_colour); +} + +void cMainMenu::Display() +{ + mp_camera->Draw(); + VideoEngine::cVideo::Inst().Display(); +} + +void cMainMenu::Redraw() +{ + m_titleSprite.CameraDraw(); + m_singleSprite.CameraDraw(); + m_headSprite.CameraDraw(); + m_quitSprite.CameraDraw(); +} + +void cMainMenu::PlaySound() +{ + m_menuSound.PlaySound(); +} + +void cMainMenu::Input() +{ + EventEngine::cEvent::Inst().CheckEvents(); +} + +void cMainMenu::SingleSelect() +{ + if (mp_singleText == nullptr) + return; + ResetTextColour(); + mp_singleText->setColour(m_selectColour); + Redraw(); +} + +void cMainMenu::HeadSelect() +{ + if (mp_headText == nullptr) + return; + ResetTextColour(); + mp_headText->setColour(m_selectColour); + Redraw(); +} + +void cMainMenu::QuitSelect() +{ + if (mp_quitText == nullptr) + return; + ResetTextColour(); + mp_quitText->setColour(m_selectColour); + Redraw(); +} \ No newline at end of file diff --git a/.svn/pristine/4b/4b4f82ac519470659e4df0412ea444af9e647b24.svn-base b/.svn/pristine/4b/4b4f82ac519470659e4df0412ea444af9e647b24.svn-base new file mode 100644 index 0000000..ff7188a --- /dev/null +++ b/.svn/pristine/4b/4b4f82ac519470659e4df0412ea444af9e647b24.svn-base @@ -0,0 +1,132 @@ +#include "cLabel.hpp" + +using GUIEngine::cLabel; + +/*static*/ const cString cLabel::sNAME = "label"; +/*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; + +cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + mp_text = new TextTypeEngine::cText(label); + Create(parent, id, label, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLabel::~cLabel() +{ + delete mp_text; + mp_text = nullptr; +} + +///Functions +void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setText(label); +} + +/*virtual*/ void cLabel::Display() +{ + GenerateTexture(); + + m_sprite.setPosition(cWindow::getPosition()); + m_sprite.Draw(); + //cSprite::SaveImage("test.bmp", "xml/"); + cWindow::Display(); +} + +void cLabel::GenerateTexture() +{ + m_sprite.setImage((VideoEngine::cImage**)(&mp_text)); + + m_sprite.setImageArea(mp_text->getWH()); + + + + //this->setTransparent(); + //this->setPosition() +} + +//Sets +void cLabel::setFontColour(const GUIHelpers::RGBA& colour) +{ + mp_text->setColour(colour); +} + +void cLabel::setFontSize(const unsigned long int size) +{ + mp_text->setSize(size); +} + +void cLabel::setText(const cString& text) +{ + mp_text->setText(text); +} + +void cLabel::setFont(const TextTypeEngine::cFont* font) +{ + mp_text->setFont((TextTypeEngine::cFont**)(&font)); +} + +///Gets +const GUIHelpers::RGBA& cLabel::getFontColour() const +{ + return mp_text->getColour(); +} + +const unsigned long int cLabel::getFontSize() const +{ + return mp_text->getSize(); +} + +const TextTypeEngine::cFont* cLabel::getFont() const +{ + return mp_text->getFont(); +} + +const cString& cLabel::getText() const +{ + return mp_text->getText(); +} + +/*virtual*/ const GUIHelpers::eType cLabel::getType() const +{ + return GUIHelpers::eType::CLABEL; +} + +/*virtual*/ const GUIHelpers::RGBA cLabel::getDebugColour() const +{ + return GUIHelpers::GREEN; +} + +// /*virtual*/ void cLabel::Resize() +// { +// RebuildLayout(this->getLayout()); +// cWindow::RePos(); +// } + +/*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + switch (layout) + { + default: + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + //break; + case GUIHelpers::eLayout::WRAP_CONTENT: + long int y = mp_text->getSize(); + long int x = (mp_text->getText().length() * y); + + GUIHelpers::Size size = { x, y }; +// size.x += this->getPadding().x + this->getPadding().w; +// size.y += this->getPadding().y + this->getPadding().z; + this->setSize(size); + break; + } +} \ No newline at end of file diff --git a/.svn/pristine/4c/4ce42deff5af8a6a7a044cbfa351e0ccc205d008.svn-base b/.svn/pristine/4c/4ce42deff5af8a6a7a044cbfa351e0ccc205d008.svn-base new file mode 100644 index 0000000..80752ed --- /dev/null +++ b/.svn/pristine/4c/4ce42deff5af8a6a7a044cbfa351e0ccc205d008.svn-base @@ -0,0 +1,46 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +/*virtual*/ void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + cWindow::Create(parent, id, orientation, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set + +///Get + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} + +/*virtual*/ const GUIHelpers::RGBA cLayout::getDebugColour() const +{ + return GUIHelpers::RED; +} \ No newline at end of file diff --git a/.svn/pristine/4d/4d344723c7b30e18383c064a70ba9aae56b68cbb.svn-base b/.svn/pristine/4d/4d344723c7b30e18383c064a70ba9aae56b68cbb.svn-base new file mode 100644 index 0000000..1741859 --- /dev/null +++ b/.svn/pristine/4d/4d344723c7b30e18383c064a70ba9aae56b68cbb.svn-base @@ -0,0 +1,83 @@ +#ifndef _CSTRING_HPP_ +#define _CSTRING_HPP_ + +/*** C++ STL Files ***/ +#include +#include + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string; +/*#pragma warning (default : 4231)*/ + +#define __cString__MAX_LEN 65535 + +namespace UtilityEngine { + class EXPORT_FROM_MYDLL cString + { + public: + cString(); // default constructor + cString(const char* s); + cString(const cString& copy); // copy constructor + ~cString(); + + const char * alloc_str(size_t sz); // smart alloc string + void clear(); // frees the string + const char * c_str() const; // getter + const char * copy_str(const char* copy); // alloc & copy + + // utility methods + bool have_value() const; + size_t length() const; + size_t size() const; + cString & format(const char * format, ...); + cString & trim(); + cString lower() const; + cString upper() const; + const char & last_char() const; + const std::vector split(const char match) const; + const std::vector split(const char * match) const; + const std::vector split(const char * match, int max_split) const; + long int char_find(const char& match) const; + const cString & char_repl(const char & match, const char & repl); + cString substr(size_t start, size_t length) const; + long int find(const cString & match); + const cString replace(const cString & match, const cString & repl); + + const long int ToInt() const; + + // operators + cString& operator = (const char* rhs); // assignment operator + cString& operator = (const cString& rhs); // assignment operator + cString& operator += (const char rhs); + cString& operator += (const char* rhs); // concatenation operator + cString& operator += (const cString& rhs); // concatenation operator + + bool operator == (const char* rhs) const; // comparisons + bool operator == (const cString& rhs) const; + bool operator != (const char* rhs) const; + bool operator != (const cString& rhs) const; + bool operator > (const cString& rhs) const; + bool operator < (const cString& rhs) const; + bool operator >= (const cString& rhs) const; + bool operator <= (const cString& rhs) const; + + // conversion operators + operator const char * () const; // c-string type + operator std::string () const; // c++ string class + + private: + char * mp_str = nullptr; + size_t m_len = 0; + + };/// END CLASS DEFINITION cString + // function overloads +}/// END NAMESPACE DEFINITION UtilityEngine +UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs); +#endif/// END IFNDEF _CSTRING_HPP_ diff --git a/.svn/pristine/4f/4f10f7dcae343326e52cdbd3385b68fe7136f565.svn-base b/.svn/pristine/4f/4f10f7dcae343326e52cdbd3385b68fe7136f565.svn-base new file mode 100644 index 0000000..67ef978 --- /dev/null +++ b/.svn/pristine/4f/4f10f7dcae343326e52cdbd3385b68fe7136f565.svn-base @@ -0,0 +1,7 @@ + + + + + + diff --git a/.svn/pristine/50/501034360567fdf4dde52646d1bd1c9f911d072c.svn-base b/.svn/pristine/50/501034360567fdf4dde52646d1bd1c9f911d072c.svn-base new file mode 100644 index 0000000..1a21d06 --- /dev/null +++ b/.svn/pristine/50/501034360567fdf4dde52646d1bd1c9f911d072c.svn-base @@ -0,0 +1,269 @@ +#include "cVideo.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cVideo; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cVideo* cVideo::sp_inst = nullptr; + +cVideo::cVideo() +: m_xPos(100), m_yPos(100), m_width(640), m_height(480), m_colour(32), + m_hardwareVideo(false), m_fullscreen(false), m_vsync(false), + m_videoSettings(SDL_RENDERER_SOFTWARE), mp_window(nullptr), +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + m_rmask(0xff000000), + m_gmask(0x00ff0000), + m_bmask(0x0000ff00), + m_amask(0x000000ff) +#else + m_rmask(0x000000ff), + m_gmask(0x0000ff00), + m_bmask(0x00ff0000), + m_amask(0xff000000) +#endif +{} + +cVideo::~cVideo() +{ + CleanUp(); +} + +///Functions +/*static*/ cVideo& cVideo::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cVideo(); + return *sp_inst; +} + +/*static*/ void cVideo::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cVideo::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) { + cUtility::Inst().Message("Video Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Video. SDL_InitSubSystem():", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +const bool cVideo::Setup() +{ + bool rtn = false; + CleanUp(); + VideoSettings(); + + mp_window = SDL_CreateWindow("Hello World!", 100, 100, m_width, m_height, SDL_WINDOW_SHOWN); + if (mp_window == nullptr) + cUtility::Inst().Message("Unable to set Window. SDL_CreateWindow():", __AT__, cUtility::eTypeSDL::SDL); + else + rtn = true; + return rtn; +} + +void cVideo::CleanUp() +{ + SDL_DestroyWindow(mp_window); + mp_window = nullptr; +} + +void cVideo::Display() +{ + SDL_RenderPresent(cRenderer::Inst().getRenderer()); +} + +void cVideo::ScreenShot( const cString& filename, const cString& dir /*= ""*/ ) +{ + VideoEngine::cRenderer::Inst().ScreenShot(filename, dir); +} + +SDL_Renderer* cVideo::CreateRender() +{ + SDL_Renderer* rtn = nullptr; + if (mp_window != nullptr) + rtn = SDL_CreateRenderer(mp_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to set Renderer. SDL_CreateRenderer():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + + +void cVideo::VideoSettings() +{ + m_videoSettings = 0; + + if (m_hardwareVideo == true) + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_ACCELERATED); + if (m_vsync == true) + m_videoSettings = (m_videoSettings | SDL_RENDERER_PRESENTVSYNC); + } + else + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_SOFTWARE); + m_vsync = false; + } + + if (m_fullscreen == true) + m_videoSettings = (m_videoSettings | SDL_WINDOW_FULLSCREEN); +} + +///Set's +void cVideo::setWidth( const unsigned long int width /*= 640*/ ) +{ + m_width = width; +} + +void cVideo::setHeight( const unsigned long int height /*= 480*/ ) +{ + m_height = height; +} + +void cVideo::setColour( const unsigned long int colour /*= 32*/ ) +{ + m_colour = colour; +} + +void cVideo::setCaption( const cString& caption /*= ""*/ ) +{ + if (mp_window != nullptr) + SDL_SetWindowTitle(mp_window, caption.c_str()); + else + cUtility::Inst().Message("No window to set caption to."); +} + +void cVideo::setHardwareVideo( const bool hardware /*= false*/ ) +{ + m_hardwareVideo = hardware; + VideoSettings(); +} + +void cVideo::setFullScreen( const bool fullscreen /*= false*/ ) +{ + m_fullscreen = fullscreen; + VideoSettings(); +} + +void cVideo::setVSync( const bool vsync /*= false*/ ) +{ + m_vsync = vsync; + VideoSettings(); +} + +void cVideo::setDisplayMode( const SDL_DisplayMode& mode ) +{ + if (SDL_SetWindowDisplayMode(mp_window, &mode) < 0) + cUtility::Inst().Message("Unable to set display mode. SDL_SetWindowDisplayMode()", __AT__, cUtility::eTypeSDL::SDL); +} + +///Gets +const bool cVideo::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_VIDEO) != 0) { + cUtility::Inst().Message("Video is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Video is not initialized."); + + return rtn; +} + +const unsigned long int cVideo::getWidth() const +{ + return m_width; +} + +const unsigned long int cVideo::getHeight() const +{ + return m_height; +} + +const unsigned long int cVideo::getColour() const +{ + return m_colour; +} + +const cString cVideo::getCaption() const +{ + cString rtn = ""; + + if (mp_window != nullptr) + rtn = SDL_GetWindowTitle(mp_window); + else + cUtility::Inst().Message("No window to get caption from."); + + return rtn; +} + +const bool cVideo::getHardwareVideo() const +{ + return m_hardwareVideo; +} + +const bool cVideo::getFullScreen() const +{ + return m_fullscreen; +} + +const bool cVideo::getVSync() const +{ + return m_vsync; +} + +const unsigned long int cVideo::getVideoSettings() const +{ + return m_videoSettings; +} + +SDL_Window* cVideo::getWindow() +{ + return mp_window; +} + +SDL_DisplayMode cVideo::getDisplayMode() const +{ + SDL_DisplayMode display; + + if (SDL_GetWindowDisplayMode(mp_window, &display) < 0 ) + cUtility::Inst().Message("Could not get display mode. SDL_GetWindowDisplayMode():", __AT__, cUtility::eTypeSDL::SDL); + + return display; +} + +const unsigned long int cVideo::getRmask() const +{ + return m_rmask; +} + +const unsigned long int cVideo::getGmask() const +{ + return m_gmask; +} + +const unsigned long int cVideo::getBmask() const +{ + return m_bmask; +} + +const unsigned long int cVideo::getAmask() const +{ + return m_amask; +} diff --git a/.svn/pristine/50/50a74d79be463c47f9454792158575f3bf4aeb77.svn-base b/.svn/pristine/50/50a74d79be463c47f9454792158575f3bf4aeb77.svn-base new file mode 100644 index 0000000..5c08087 --- /dev/null +++ b/.svn/pristine/50/50a74d79be463c47f9454792158575f3bf4aeb77.svn-base @@ -0,0 +1,123 @@ +#include "cLabel.hpp" + +using GUIEngine::cLabel; + +/*static*/ const cString cLabel::sNAME = "label"; +/*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; + +cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + mp_text = new TextTypeEngine::cText(label); + Create(parent, id, label, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLabel::~cLabel() +{ + delete mp_text; + mp_text = nullptr; +} + +///Functions +void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setText(label); +} + +/*virtual*/ void cLabel::Display() +{ + GenerateTexture(); + + cSprite::setPosition(cWindow::getPosition()); + cSprite::Draw(); + cSprite::SaveImage("test.bmp", "xml/"); +} + +void cLabel::GenerateTexture() +{ + this->setImage((VideoEngine::cImage**)(&mp_text)); + + this->setImageArea(mp_text->getWH()); + + + + //this->setTransparent(); + //this->setPosition() +} + +//Sets +void cLabel::setFontColour(const GUIHelpers::RBGA& colour) +{ + mp_text->setColour(colour); +} + +void cLabel::setFontSize(const unsigned long int size) +{ + mp_text->setSize(size); +} + +void cLabel::setText(const cString& text) +{ + mp_text->setText(text); +} + +void cLabel::setFont(const TextTypeEngine::cFont* font) +{ + mp_text->setFont((TextTypeEngine::cFont**)(&font)); +} + +///Gets +const GUIHelpers::RBGA& cLabel::getFontColour() const +{ + return mp_text->getColour(); +} + +const unsigned long int cLabel::getFontSize() const +{ + return mp_text->getSize(); +} + +const TextTypeEngine::cFont* cLabel::getFont() const +{ + return mp_text->getFont(); +} + +const cString& cLabel::getText() const +{ + return mp_text->getText(); +} + +/*virtual*/ const GUIHelpers::eType cLabel::getType() const +{ + return GUIHelpers::eType::CLABEL; +} + +/*virtual*/ void cLabel::Resize() +{ + RebuildLayout(this->getLayout()); + cWindow::Resize(); +} + +/*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + //break; + case GUIHelpers::eLayout::WRAP_CONTENT: + long int x = (mp_text->getText().length() * mp_text->getSize()); + GUIHelpers::Size size = { x, 8 }; +// size.x += this->getPadding().x + this->getPadding().w; +// size.y += this->getPadding().y + this->getPadding().z; + this->setSize(size); + break; + } +} \ No newline at end of file diff --git a/.svn/pristine/51/518ae357bf512e9018d0cbd2c5830c0f48dd0287.svn-base b/.svn/pristine/51/518ae357bf512e9018d0cbd2c5830c0f48dd0287.svn-base new file mode 100644 index 0000000..98e84be --- /dev/null +++ b/.svn/pristine/51/518ae357bf512e9018d0cbd2c5830c0f48dd0287.svn-base @@ -0,0 +1,72 @@ +#include "cKeyboard.hpp" + +using InputEngine::cKeyboard; + +cKeyboard::cKeyboard( const cString& label ) + : m_label(label) +{} + +cKeyboard::cKeyboard( const cKeyboard& copy ) + :m_label(copy.getLabel()) +{} + +/*virtual*/ cKeyboard::~cKeyboard() +{ + DeleteAllKeys(); +} + +///Functions +/*virtual*/ void cKeyboard::KeyboardCheck( const SDL_Event& event ) +{ + SDL_Keycode key = event.key.keysym.sym; + + std::vector::iterator it; + + for ( it = m_keys.begin() ; it < m_keys.end(); it++ ) { + if (key == (*it)->getKey()) { + switch( event.type ) + { + case SDL_KEYUP: + (*it)->KeyUP(); + break; + case SDL_KEYDOWN: + (*it)->KeyDown(); + break; + } + //break out of the for loop + break; + } + } +} + +void cKeyboard::AddKey( InputEngine::cKey* key ) +{ + m_keys.push_back(key); +} + +void cKeyboard::DeleteKey( const SDL_Keycode& key ) +{ + std::vector::iterator it; + + for ( it = m_keys.begin() ; it < m_keys.end(); it++ ) { + if (key == (*it)->getKey()) { + InputEngine::cKey* temp = (*it); + delete temp; + temp = nullptr; + m_keys.erase(it); + //break out of the for loop + break; + } + } +} + +void cKeyboard::DeleteAllKeys() +{ + m_keys.clear(); +} + +///Sets +const cString& cKeyboard::getLabel() const +{ + return m_label; +} \ No newline at end of file diff --git a/.svn/pristine/51/51c3de1be07cecc60d182b7ab8586044a684d2cd.svn-base b/.svn/pristine/51/51c3de1be07cecc60d182b7ab8586044a684d2cd.svn-base new file mode 100644 index 0000000..08ee256 --- /dev/null +++ b/.svn/pristine/51/51c3de1be07cecc60d182b7ab8586044a684d2cd.svn-base @@ -0,0 +1,70 @@ +#ifndef _CRENDERER_HPP_ +#define _CRENDERER_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cRenderer + { + private: + cRenderer(); + ~cRenderer(); + + public: + static cRenderer& Inst(); + static void Delete(); + + /* Creates the Renderer */ + const bool Setup(); + /* Uses */ + void CleanUp(); + + void Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ); + + void RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ); + + void RenderDrawColor( const SDL_Colour& colour ); + void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr ); + + void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" ); + void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" ); + + SDL_Texture* SurfaceToTexture( SDL_Surface* surface ); + SDL_Surface* TextureToSurface( SDL_Texture* texture ); + + void CopyTexture( SDL_Texture* src, SDL_Texture* dst ); + + SDL_Surface* CopySurface( SDL_Surface* src ); + + SDL_Surface* NewSurface( const unsigned long int width, const unsigned long int height ) const; + SDL_Texture* NewTexture( const unsigned long int width, const unsigned long int height, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const; + + void SetRenderTarget( SDL_Texture* target = nullptr ); + void ResetRenderTarget(); + + ///Sets + + ///Gets + SDL_Renderer* getRenderer(); + + private: + SDL_Renderer* mp_renderer; + + static cRenderer* sp_inst;// = nullptr + };/// END CLASS DEFINITION cRenderer +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CRENDERER_HPP_ \ No newline at end of file diff --git a/.svn/pristine/52/529aab7d2c573a22108865b1df953afce85ac8ea.svn-base b/.svn/pristine/52/529aab7d2c573a22108865b1df953afce85ac8ea.svn-base new file mode 100644 index 0000000..20ff42f --- /dev/null +++ b/.svn/pristine/52/529aab7d2c573a22108865b1df953afce85ac8ea.svn-base @@ -0,0 +1,33 @@ +#ifndef _CPLAYERDOWN_HPP_ +#define _CPLAYERDOWN_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cPaddle.hpp" + +namespace Input { + class cPlayerDown : public InputEngine::cKey + { + public: + cPlayerDown( SDL_Keycode key, Equipment::cPaddle** player ); + ~cPlayerDown(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cPaddle** mpp_player; + };/// END CLASS DEFINITION cPlayerDown +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CPLAYERDOWN_HPP_ \ No newline at end of file diff --git a/.svn/pristine/53/531e9cd118298720b16e4b009232740a6e44806e.svn-base b/.svn/pristine/53/531e9cd118298720b16e4b009232740a6e44806e.svn-base new file mode 100644 index 0000000..2621b05 --- /dev/null +++ b/.svn/pristine/53/531e9cd118298720b16e4b009232740a6e44806e.svn-base @@ -0,0 +1,130 @@ +#include "cBuildMainMenu.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +using MainMenu::cBuildMainMenu; +using MainMenu::cMainMenu; +using UtilityEngine::cUtility; + +using tinyxml2::XMLDocument; +using tinyxml2::XMLNode; +using tinyxml2::XMLVisitor; +using tinyxml2::XMLElement; + +cBuildMainMenu::cBuildMainMenu() + : m_ttf(""), m_dir(""), m_lang(""), m_langSettings(""), mp_mainMenu(new cMainMenu()) +{} + +cBuildMainMenu::~cBuildMainMenu() +{} + +///Functions +cMainMenu* cBuildMainMenu::ReadXML() +{ + cString file = "xml/SDLPongCPP.xml"; + XMLDocument doc; + + if ( doc.LoadFile(file.c_str()) == false ) { + //cUtility::Inst().Message("Could not load file." + file + " Error='" + doc.GetErrorStr1 + "'."); + } else { + XMLNode* node = doc.FirstChildElement( "SDLPongCPP" ); + + if (node == nullptr) { + cUtility::Inst().Message("No FirstChildElement( "Settings" ); + if (settingsElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_langSettings = GetAttribute(settingsElement, "lang"); + } + XMLElement* mainmenuElement = node->FirstChildElement( "MainMenu" ); + while (m_langSettings != m_lang) { + if (mainmenuElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_lang = GetAttribute(mainmenuElement, "lang"); + /* if the language is the same as the one specified in the settings we read the menu settings */ + if (m_lang == m_langSettings) { + const char* colour = GetAttribute(mainmenuElement, "colour"); + mp_mainMenu->setColour(IntToSDLColour(HexToInt(colour))); + + const char* selectcolour = GetAttribute(mainmenuElement, "selectcolour"); + mp_mainMenu->setSelectColour(IntToSDLColour(HexToInt(selectcolour))); + + const char* titlecolour = GetAttribute(mainmenuElement, "titlecolour"); + mp_mainMenu->setTitleColour(IntToSDLColour(HexToInt(titlecolour))); + + m_ttf = GetAttribute(mainmenuElement, "ttf"); + + const char* soundeffect = GetAttribute(mainmenuElement, "soundeffect"); + + m_dir = GetAttribute(mainmenuElement, "dir"); + + if (m_ttf != "") + mp_mainMenu->setFont(m_dir + "ttf/", m_ttf); + + mp_mainMenu->setSound(m_dir + "snd/", cString(soundeffect)); + + GetOptions( mainmenuElement, "Title" ); + GetOptions( mainmenuElement, "SinglePlayer" ); + GetOptions( mainmenuElement, "HeadToHead" ); + GetOptions( mainmenuElement, "Quit" ); + } else { + mainmenuElement = mainmenuElement->NextSiblingElement(); + } + }/* end else */ + }/* end while */ + } + } + return mp_mainMenu; +} + +void cBuildMainMenu::GetOptions( const XMLElement* element, const cString name ) +{ + const XMLElement* titleElement = element->FirstChildElement( name.c_str() ); + if (titleElement == nullptr) { + cUtility::Inst().Message("Error no tag <" + name + "> found."); + } else { + const char* x = GetAttribute(titleElement, "x"); + const char* y = GetAttribute(titleElement, "y"); + const char* size = GetAttribute(titleElement, "size"); + const char* text = titleElement->GetText(); + + if (name == "Title") + mp_mainMenu->setTitleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "SinglePlayer") + mp_mainMenu->setSingleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "HeadToHead") + mp_mainMenu->setHeadText(text, atoi(size), atoi(x), atoi(y)); + if (name == "Quit") + mp_mainMenu->setQuitText(text, atoi(size), atoi(x), atoi(y)); + } +} + +const char* cBuildMainMenu::GetAttribute( const XMLElement* element, const cString attribute ) const +{ + const char* rtn = element->Attribute(attribute.c_str()); + if (rtn == nullptr) { + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element->Value() + ">"); + rtn = ""; + } + return rtn; +} + +const unsigned long int cBuildMainMenu::HexToInt( const cString str ) const +{ + return strtol(str.c_str(), NULL, 10); +} + +const SDL_Colour cBuildMainMenu::IntToSDLColour( const unsigned long int colour ) const +{ + SDL_Colour rtn = {255, 255, 255}; + + rtn.r = Uint8(colour >> 16); + rtn.g = Uint8(colour >> 8); + rtn.b = Uint8(colour); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/59/594cace1cd0995149aef0be5d9cbcebfa7d0c268.svn-base b/.svn/pristine/59/594cace1cd0995149aef0be5d9cbcebfa7d0c268.svn-base new file mode 100644 index 0000000..4b8825a --- /dev/null +++ b/.svn/pristine/59/594cace1cd0995149aef0be5d9cbcebfa7d0c268.svn-base @@ -0,0 +1,42 @@ +#ifndef _ENUMS_HPP_ +#define _ENUMS_HPP_ + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + enum EXPORT_FROM_MYDLL eLayout: unsigned int + { + FILL_PARENT = 0, + MATCH_PARENT, + WRAP_CONTENT + };/// END enum DEFINITION eLayout + + enum EXPORT_FROM_MYDLL eType: unsigned int + { + COBJECT = 0, + CWINDOW, + CLAYOUT, + CBOXSIZER, + CBUTTON, + CTEXTBUTTON, + CLABEL, + CPANEL + };/// END enum DEFINITION eType + + enum EXPORT_FROM_MYDLL eOrientation: unsigned int + { + VERTICAL = 0, + HORIZONTAL + };/// END enum DEFINITION eOrientation + + enum EXPORT_FROM_MYDLL eAlign: unsigned int + { + CENTER = 0, + TOP, + RIGHT, + BOTTOM, + LEFT + };/// END enum DEFINITION eAlign +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _ENUMS_HPP_ \ No newline at end of file diff --git a/.svn/pristine/59/597144a95810363788809cdcca3ad662c4122e8c.svn-base b/.svn/pristine/59/597144a95810363788809cdcca3ad662c4122e8c.svn-base new file mode 100644 index 0000000..f6910d1 --- /dev/null +++ b/.svn/pristine/59/597144a95810363788809cdcca3ad662c4122e8c.svn-base @@ -0,0 +1,46 @@ +#ifndef _ENUMS_HPP_ +#define _ENUMS_HPP_ + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + enum EXPORT_FROM_MYDLL eLayout: unsigned int + { + DEFAULT_LAYOUT = 0, + FILL_PARENT, + MATCH_PARENT, + WRAP_CONTENT + };/// END enum DEFINITION eLayout + + enum EXPORT_FROM_MYDLL eType: unsigned int + { + COBJECT, + CWINDOW, + CLAYOUT, + CBOXSIZER, + CBUTTON, + CTEXTBUTTON, + CLABEL, + CPANEL + };/// END enum DEFINITION eType + + enum EXPORT_FROM_MYDLL eOrientation: unsigned int + { + DEFAULT_ORIENTATION = 0, + NONE, + VERTICAL, + HORIZONTAL + };/// END enum DEFINITION eOrientation + + enum EXPORT_FROM_MYDLL eAlign: unsigned int + { + DEFAULT_ALIGN = 0, + CENTER, + TOP, + RIGHT, + BOTTOM, + LEFT + };/// END enum DEFINITION eAlign +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _ENUMS_HPP_ \ No newline at end of file diff --git a/.svn/pristine/59/59868a496a3a4645e3985825708ffcd678c81e93.svn-base b/.svn/pristine/59/59868a496a3a4645e3985825708ffcd678c81e93.svn-base new file mode 100644 index 0000000..d937779 --- /dev/null +++ b/.svn/pristine/59/59868a496a3a4645e3985825708ffcd678c81e93.svn-base @@ -0,0 +1,31 @@ +#ifndef _CMENUDOWN_HPP_ +#define _CMENUDOWN_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuDown : public InputEngine::cKey + { + public: + cMenuDown( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuDown& copy ); + ~cMenuDown(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuDown +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUDOWN_HPP_ diff --git a/.svn/pristine/59/59a3103b28462ec0414520c24685218af89612e8.svn-base b/.svn/pristine/59/59a3103b28462ec0414520c24685218af89612e8.svn-base new file mode 100644 index 0000000..17925b8 --- /dev/null +++ b/.svn/pristine/59/59a3103b28462ec0414520c24685218af89612e8.svn-base @@ -0,0 +1,162 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + UTest + Win32 + + + UTest + x64 + + + + {9225E043-EE77-43AA-A140-C9C2F85B1013} + TrooperEngineTest + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + v140 + + + v140 + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + true + $(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + true + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2)\VisualC\Win32\Release;$(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + Console + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/5d/5d73a7fb460a70d00bf1a79d031dd095fc9dae71.svn-base b/.svn/pristine/5d/5d73a7fb460a70d00bf1a79d031dd095fc9dae71.svn-base new file mode 100644 index 0000000..4b0a4a5 --- /dev/null +++ b/.svn/pristine/5d/5d73a7fb460a70d00bf1a79d031dd095fc9dae71.svn-base @@ -0,0 +1,78 @@ +#ifndef _CMAINMENU_HPP_ +#define _CMAINMENU_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "eOptions.hpp" + +using UtilityEngine::cString; + +namespace MainMenu { + class cMainMenu + { + public: + cMainMenu(); + ~cMainMenu(); + + const eOptions ShowMenu(); + + void OptionUp(); + void OptionDown(); + void OptionSelect(); + + //Sets + void setOption( const eOptions option = eOptions::Start ); + + void setSound( const cString dir, const cString filename ); + + void setColour( const SDL_Colour colour ); + void setSelectColour( const SDL_Colour selectcolour ); + void setTitleColour( const SDL_Colour titlecolour ); + + void setFont( const cString dir, const cString filename ); + + void setTitleText( const cString text, const long int size, const long int x, const long int y ); + void setSingleText( const cString text, const long int size, const long int x, const long int y ); + void setHeadText( const cString text, const long int size, const long int x, const long int y ); + void setQuitText( const cString text, const long int size, const long int x, const long int y ); + + private: + void ResetTextColour(); + + void Display(); + void Redraw(); + void PlaySound(); + void Input(); + + void SingleSelect(); + void HeadSelect(); + void QuitSelect(); + + private: + VideoEngine::cCamera* mp_camera;// = nullptr + + VideoEngine::cSprite m_titleSprite; + VideoEngine::cSprite m_singleSprite; + VideoEngine::cSprite m_headSprite; + VideoEngine::cSprite m_quitSprite; + + AudioEngine::cSound m_menuSound; + + SDL_Colour m_colour;// = {255, 0, 0} + SDL_Colour m_selectColour;// = {0, 0, 255} + SDL_Colour m_titleColour;// = {255, 255, 255} + + TextTypeEngine::cFont* mp_font;// = nullptr + + TextTypeEngine::cText* mp_titleText;// = nullptr; + TextTypeEngine::cText* mp_singleText;// = nullptr; + TextTypeEngine::cText* mp_headText;// = nullptr; + TextTypeEngine::cText* mp_quitText;// = nullptr; + + eOptions m_option;// = Start; + bool m_run;// = true; + };/// END CLASS DEFINITION cMainMenu +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _CMAINMENU_HPP_ \ No newline at end of file diff --git a/.svn/pristine/5d/5d784672c5983050437ae8443a3a245626d66aa8.svn-base b/.svn/pristine/5d/5d784672c5983050437ae8443a3a245626d66aa8.svn-base new file mode 100644 index 0000000..a65c96e --- /dev/null +++ b/.svn/pristine/5d/5d784672c5983050437ae8443a3a245626d66aa8.svn-base @@ -0,0 +1,46 @@ +#ifndef _ENUMS_HPP_ +#define _ENUMS_HPP_ + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + enum EXPORT_FROM_MYDLL eLayout: unsigned int + { + DEFAULT_LAYOUT = 0, + FILL_PARENT, + MATCH_PARENT, + WRAP_CONTENT + };/// END enum DEFINITION eLayout + + enum EXPORT_FROM_MYDLL eType: unsigned int + { + COBJECT, + CWINDOW, + CPANEL, + CLAYOUT, + CBOXSIZER, + CBUTTON, + CTEXTBUTTON, + CLABEL, + };/// END enum DEFINITION eType + + enum EXPORT_FROM_MYDLL eOrientation: unsigned int + { + DEFAULT_ORIENTATION = 0, + NONE, + VERTICAL, + HORIZONTAL + };/// END enum DEFINITION eOrientation + + enum EXPORT_FROM_MYDLL eAlign: unsigned int + { + DEFAULT_ALIGN = 0, + CENTER, + TOP, + RIGHT, + BOTTOM, + LEFT + };/// END enum DEFINITION eAlign +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _ENUMS_HPP_ \ No newline at end of file diff --git a/.svn/pristine/60/605a790cc55726974fef7a43ca61e9e6069dd0ba.svn-base b/.svn/pristine/60/605a790cc55726974fef7a43ca61e9e6069dd0ba.svn-base new file mode 100644 index 0000000..2997526 --- /dev/null +++ b/.svn/pristine/60/605a790cc55726974fef7a43ca61e9e6069dd0ba.svn-base @@ -0,0 +1,169 @@ +#include "cPongStart.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../MainMenu/Input/cMenuUp.hpp" +#include "../MainMenu/Input/cMenuDown.hpp" +#include "../MainMenu/Input/cMenuSelect.hpp" +#include "../MainMenu/Input/cEsc.hpp" +#include "../MainMenu/cBuildMainMenu.hpp" + + +#include "../Equipment/cCourt.hpp" +#include "../Equipment/cPaddle.hpp" + +#include "../Equipment/Input/cPlayerUp.hpp" +#include "../Equipment/Input/cPlayerDown.hpp" +#include "../Equipment/Input/cQuitButton.hpp" + +using PongStart::cPongStart; + +cPongStart::cPongStart() +: mp_menu(nullptr), m_option(MainMenu::Start) +{ + TrooperEngineCore::cTrooperEngineCore& core = TrooperEngineCore::cTrooperEngineCore::Inst(); + core.TimerInit(); + core.VideoInit(); + core.AudioInit(); + core.TextTypeInit(); + + if (core.getVideo()) + VideoEngine::cVideo::Inst().Setup(); + if (core.getAudio()) + AudioEngine::cAudio::Inst().Setup(); + if (core.getTimer()) + TimingEngine::cTiming::Inst().Setup(); + if (core.getText()) + TextTypeEngine::cTextType::Inst().Setup(); + + TrooperEngineCore::cTrooperEngineCore::Inst().PrintSDLVersion(); +} + +cPongStart::~cPongStart() +{ + TrooperEngineCore::cTrooperEngineCore::Inst().Delete(); +} + +void cPongStart::Main() +{ + //GUIHelpers::cTexture* temp = new GUIHelpers::cTexture(); + //SDL_Rect rec = {0,0,25,25}; + //temp->GenerateTexture(rec); + //TextTypeEngine::cText* txt = new TextTypeEngine::cText("Hello akjfdklajfdlkjfkljdfalkajdlkfjakljflkjafdlkjflkajdlkfjalkdjflkajdlkfajlkfdjafkljdfkljasdfalk"); + //VideoEngine::cSprite* sprt = new VideoEngine::cSprite((VideoEngine::cImage**)(&txt)); + //sprt->Draw(); +// GUIEngine::cButton* but = new GUIEngine::cButton(0, "button2"); +// but->Draw(); + + //GUIEngine::cWindow* win = new GUIEngine::cWindow(); + GUIEngine::cLayout* lay = new GUIEngine::cLayout(); + GUIEngine::cLabel* lbl = new GUIEngine::cLabel(lay, 22, "Hello world"); + + + lay->Resize(); + lay->Display(); + + + //GUIEngine::cGUI::Inst().AddObject(win); + + //GUIEngine::cGUI::Inst().Display(); + + //while (true) { + EventEngine::cEvent::Inst().CheckEvents(); + /*SDL_Colour col = { 255, 255, 255, 255}; + SDL_Rect re= { 0, 0, 100, 100}; + FXEngine::cGFX::Inst().RoundedRectangle(re, 4, col);*/ + VideoEngine::cVideo::Inst().Display(); + //break; + //} + system("pause"); + /*MainMenu(); + switch (m_option) + { + case MainMenu::Start: + Start(); + break; + case MainMenu::Head: + HeadtoHead(); + break; + case MainMenu::Quit: + default: + Quit(); + break; + }*/ +} + +///private +void cPongStart::MainMenu() +{ + MainMenu::cBuildMainMenu temp; + mp_menu = temp.ReadXML(); + + Input::cMenuUp* menuup = new Input::cMenuUp(SDLK_a, &mp_menu); + Input::cMenuDown* menudown = new Input::cMenuDown(SDLK_z, &mp_menu); + Input::cMenuSelect* menuselect = new Input::cMenuSelect(SDLK_x, &mp_menu); + Input::cEsc* esc = new Input::cEsc(SDLK_ESCAPE, &mp_menu); + + InputEngine::cKeyboard* menukeyboard = new InputEngine::cKeyboard("MenuKeyboard"); + + menukeyboard->AddKey(menuup); + menukeyboard->AddKey(menudown); + menukeyboard->AddKey(menuselect); + menukeyboard->AddKey(esc); + + InputEngine::cInput::Inst().AddKeyboard(menukeyboard); + + m_option = mp_menu->ShowMenu(); +} + +void cPongStart::Start() +{ + VideoEngine::cImage* p_image = new VideoEngine::cImage("img/", "Equipment.png", true, 0, 0, 0); + VideoEngine::cImage* p_court = new VideoEngine::cImage("img/", "Court.png"); + + Equipment::cBall* ball = new Equipment::cBall(400, 400, 17, 65, 12, 12, &p_image); + Equipment::cPaddle* paddle = new Equipment::cPaddle(0, 0, 0, 0, 16, 77, &p_image); + Equipment::cPaddle* paddle2 = new Equipment::cPaddle(0, 200, 29, 0, 16, 77, &p_image); + + Equipment::cCourt* court = new Equipment::cCourt(ball, paddle, paddle2, &p_court); + + InputEngine::cTextInput text;// = new InputEngine::cTextInput(); + + TimingEngine::cTiming::Inst().setFTP(30); + + while (court->isPause() == false) { + ball->Move(); + paddle->Move(); + paddle2->Move(); + + court->CheckCollision(); + + court->Draw(); + + ball->Draw(); + paddle->Draw(); + paddle2->Draw(); + + TimingEngine::cTiming::Inst().Time(); + VideoEngine::cVideo::Inst().Display(); + } + + delete p_image; + p_image = nullptr; + + delete p_court; + p_court; + + delete court; + court = nullptr; +} + +void cPongStart::HeadtoHead() +{ +} + +void cPongStart::Quit() +{ +} \ No newline at end of file diff --git a/.svn/pristine/60/6099533f4dc1eb0dd1d3193847b39f79eb4eff4b.svn-base b/.svn/pristine/60/6099533f4dc1eb0dd1d3193847b39f79eb4eff4b.svn-base new file mode 100644 index 0000000..d6b4954 --- /dev/null +++ b/.svn/pristine/60/6099533f4dc1eb0dd1d3193847b39f79eb4eff4b.svn-base @@ -0,0 +1,60 @@ + + + + + {549e0f16-9635-455e-b19a-4a887771cf5d} + + + {50a06b19-0711-478a-a15e-df325d10bebc} + + + {3305ea52-bd3f-4a02-a012-eb2923a77dbf} + + + {510356f7-3573-4526-b0a4-73d691ecba95} + + + {380e8810-ed24-4a4d-b569-b7c37e3647c6} + + + + + UTest + + + UtitlityEngineTest + + + GUIEngineTest + + + + + UTest + + + + UtitlityEngineTest + + + GUIEngineTest + + + + + xml + + + xml + + + xml + + + xml + + + xml + + + \ No newline at end of file diff --git a/.svn/pristine/61/61e79c4f3149bd2a190dab48d3aac9f4f2d2eb88.svn-base b/.svn/pristine/61/61e79c4f3149bd2a190dab48d3aac9f4f2d2eb88.svn-base new file mode 100644 index 0000000..a26147a --- /dev/null +++ b/.svn/pristine/61/61e79c4f3149bd2a190dab48d3aac9f4f2d2eb88.svn-base @@ -0,0 +1,81 @@ +#include "cTexture.hpp" + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cRenderer.hpp" +#include "../../FXEngine/cGFX.hpp" +#include "GUIUtility.hpp" + +using GUIHelpers::cTexture; + +cTexture::cTexture() +{} + +cTexture::~cTexture() +{} + +///Functions + +//private +SDL_Texture* cTexture::GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text /*= nullptr*/ ) +{ + SDL_Rect t = text->getWH(); + SDL_Rect centerText = { 0, 0, 0, 0 }; + SDL_Rect centerButton = { 0, 0, 0, 0 }; + SDL_Rect dim = dimensions; + + ///Find the min padding around the text. +// if (dim.w < (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w) ) +// dim.w += (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w); +// +// if (dim.h < (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z) ) +// dim.h += (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z); + + ///Find the center of the button + centerButton.x = dim.w / 2; + centerButton.y = dim.h / 2; + + ///Find the center of the text + centerText.x = t.w / 2; + centerText.y = t.h / 2; + + if (centerText.x < centerButton.x) + t.x = centerButton.x - centerText.x; + + if (centerText.y < centerButton.y) + t.y = centerButton.y - centerText.y; + + SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); + + GUIHelpers::RBGA colour = { 100, 100, 100, 255 }; + + FXEngine::cGFX::Inst().RoundedRectangle(dim, 0, colour, temptext); + + + VideoEngine::cRenderer::Inst().RenderToTexture(text->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + + setImage(temptext); + + return temptext; +} \ No newline at end of file diff --git a/.svn/pristine/62/62c2c0e9a27da234121ec6c979ed09943fbf316e.svn-base b/.svn/pristine/62/62c2c0e9a27da234121ec6c979ed09943fbf316e.svn-base new file mode 100644 index 0000000..0f4904a --- /dev/null +++ b/.svn/pristine/62/62c2c0e9a27da234121ec6c979ed09943fbf316e.svn-base @@ -0,0 +1,33 @@ +#ifndef _CPLAYERUP_HPP_ +#define _CPLAYERUP_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cPaddle.hpp" + +namespace Input { + class cPlayerUp : public InputEngine::cKey + { + public: + cPlayerUp( SDL_Keycode key, Equipment::cPaddle** player ); + ~cPlayerUp(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cPaddle** mpp_player; + };/// END CLASS DEFINITION cPlayerUp +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CPLAYERUP_HPP_ \ No newline at end of file diff --git a/.svn/pristine/63/632816d97fbe6195af23ef3d457ba1a8254fd681.svn-base b/.svn/pristine/63/632816d97fbe6195af23ef3d457ba1a8254fd681.svn-base new file mode 100644 index 0000000..a2b71cf --- /dev/null +++ b/.svn/pristine/63/632816d97fbe6195af23ef3d457ba1a8254fd681.svn-base @@ -0,0 +1,34 @@ +#include "cMenuDown.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuDown; + +cMenuDown::cMenuDown( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuDown::cMenuDown( const cMenuDown& copy ) +{}*/ + +cMenuDown::~cMenuDown() +{} + +///Funtions +void cMenuDown::KeyPress() +{ +} + +void cMenuDown::KeyUP() +{ +} + +void cMenuDown::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionDown(); +} \ No newline at end of file diff --git a/.svn/pristine/65/65663064b6706a20d7f38e461b30a97cb45e4d51.svn-base b/.svn/pristine/65/65663064b6706a20d7f38e461b30a97cb45e4d51.svn-base new file mode 100644 index 0000000..4b3aed1 --- /dev/null +++ b/.svn/pristine/65/65663064b6706a20d7f38e461b30a97cb45e4d51.svn-base @@ -0,0 +1,96 @@ +#include "cBall.hpp" + +using Equipment::cBall; + +cBall::cBall( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: cSprite(xpos, ypos, xarea, yarea, warea, harea, image, camera), + m_pause(false), m_ballState(Serve), m_speed(-10.0, -10.0), m_maxSpeed(10), m_minSpeed(5), m_boucedAllReady(false) +{} + +cBall::~cBall() +{} + +///Functions +void cBall::Move() +{ + if (m_pause == false) + { + float frameTime = TimingEngine::cTiming::Inst().getFrameTime(); + + AddPosX(long int(m_speed.x * frameTime)); + AddPosY(long int(m_speed.y * frameTime)); + + m_boucedAllReady = false; + } +} + +const bool cBall::isPaused() +{ + return m_pause; +} + +void cBall::Pause() +{ + m_pause = !m_pause; +} + +void cBall::BounceX() +{ + float rand = MathEngine::cRandom::Inst().Rand(m_maxSpeed, m_minSpeed); + + m_speed.x = -m_speed.x; + m_speed.y = rand; + + AddPosX((long)m_speed.x); +} + +void cBall::BounceY() +{ + float rand = MathEngine::cRandom::Inst().Rand(m_maxSpeed, m_minSpeed); + + m_speed.x = rand; + m_speed.y = -m_speed.y; + + AddPosY((long)m_speed.y); +} + +void cBall::Reset( const int delay ) +{ + delay; + m_ballState = Serve; +} + +///Sets +void cBall::setSpeed( const float x /*= -10*/, const float y /*= -10*/ ) +{ + m_speed.x = x; + m_speed.y = y; +} + +void cBall::setMaxSpeed( const float max /*= 10*/ ) +{ + m_maxSpeed = max; +} + +void cBall::setMinSpeed( const float min /*= 5*/ ) +{ + m_minSpeed = min; +} + +///Gets +const MathEngine::Vector2 cBall::getSpeed() const +{ + return m_speed; +} + +const float cBall::getMaxSpeed() const +{ + return m_maxSpeed; +} + +const float cBall::getMinSpeed() const +{ + return m_minSpeed; +} \ No newline at end of file diff --git a/.svn/pristine/66/664d6d0379b8bb39c6244af7690e035bd08d9540.svn-base b/.svn/pristine/66/664d6d0379b8bb39c6244af7690e035bd08d9540.svn-base new file mode 100644 index 0000000..55ac022 --- /dev/null +++ b/.svn/pristine/66/664d6d0379b8bb39c6244af7690e035bd08d9540.svn-base @@ -0,0 +1,6 @@ +#ifndef __STRINGTEST__ +#define __STRINGTEST__ + +void StringTest(); + +#endif // __STRINGTEST__ diff --git a/.svn/pristine/66/6650873b234fec5b69f0008b92008e1d4f163606.svn-base b/.svn/pristine/66/6650873b234fec5b69f0008b92008e1d4f163606.svn-base new file mode 100644 index 0000000..346a8fd --- /dev/null +++ b/.svn/pristine/66/6650873b234fec5b69f0008b92008e1d4f163606.svn-base @@ -0,0 +1,90 @@ +#include "cTextInput.hpp" + +using InputEngine::cTextInput; + +cTextInput::cTextInput() +: cKeyboard("TextInput"), m_text(""), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F) +{ + /*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) { + SDL_EnableUNICODE(SDL_ENABLE); + }*/ +} + +cTextInput::cTextInput( const cTextInput& copy ) + : cKeyboard(copy), m_text(copy.getText()), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F) +{ + /*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) { + SDL_EnableUNICODE(SDL_ENABLE); + }*/ +} + +/*virtual*/ cTextInput::~cTextInput() +{} + +///Functions +/* */ +/*virtual*/ void cTextInput::KeyboardCheck( const SDL_Event& event ) +{ + switch(event.key.keysym.sym) + { + case SDLK_BACKSPACE: + case SDLK_DELETE: + if(m_text.size() == 0) + //m_text.erase(m_text.end() - 1); + break; + default: + { + char key = UnicodeValue(event); + + if(key != 0) + m_text += key; + } + break; + } +} + +/* Clears out the Text */ +void cTextInput::ClearText() +{ + m_text = ""; +} + +///Sets +void cTextInput::setText( const cString& text ) +{ + m_text = text; +} + +///Gets +const cString& cTextInput::getText() const +{ + return m_text; +} + +//Private +const char cTextInput::UnicodeValue( const SDL_Event& event ) +{ + event; +/* if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) + return 0; + + unsigned long int uni = event.key.keysym.unicode; + + if( uni == 0 ) // not translatable key (like up or down arrows) + { + // probably not useful as string input + // we could optionally use this to get some value + // for it: SDL_GetKeyName( key ); + return 0; + } + else if( ( uni & INTERNATIONAL_MASK ) == 0 ) + { + return static_cast(uni & UNICODE_MASK); + } + else // we have a funky international character. one we can't read :( + { + // we could do nothing, or we can just show some sign of input, like so: + return 0; + }*/ + return 0; +} \ No newline at end of file diff --git a/.svn/pristine/66/6694e0856afe05792f63b43b437645c7603f877d.svn-base b/.svn/pristine/66/6694e0856afe05792f63b43b437645c7603f877d.svn-base new file mode 100644 index 0000000..2c205d4 --- /dev/null +++ b/.svn/pristine/66/6694e0856afe05792f63b43b437645c7603f877d.svn-base @@ -0,0 +1,66 @@ +#include "cPaddle.hpp" + +using Equipment::cPaddle; + +cPaddle::cPaddle( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: cSprite( xpos, ypos, xarea, yarea, warea, harea, image, camera ), m_speed(0.0), m_pause(false), m_state(Still) +{} + +cPaddle::~cPaddle() +{} + +///Functions +void cPaddle::Move() +{ + if (m_pause == false) + { + float frameTime = TimingEngine::cTiming::Inst().getFrameTime(); + + AddPosY((signed long int)(m_speed * frameTime)); + } +} + +void cPaddle::Pause() +{ + m_pause = !m_pause; +} + +const bool cPaddle::isPaused() +{ + return m_pause; +} + +void cPaddle::Reset() +{} + +///Sets +void cPaddle::setSpeed( const double speed /*= 0.0*/ ) +{ + m_speed = speed; +} + +void cPaddle::setState( const eState state /*= eState::Still*/ ) +{ + m_state = state; + switch (m_state) + { + case Up: + m_speed = -25.0; + break; + case Still: + m_speed = 0.0; + break; + case Down: + m_speed = 25.0; + break; + default: + break; + } +} + +const cPaddle::eState cPaddle::getState() const +{ + return m_state; +} \ No newline at end of file diff --git a/.svn/pristine/66/66b29469b1718cf46bf8d4f4f97c1cf0edbd22e2.svn-base b/.svn/pristine/66/66b29469b1718cf46bf8d4f4f97c1cf0edbd22e2.svn-base new file mode 100644 index 0000000..9a3b11a --- /dev/null +++ b/.svn/pristine/66/66b29469b1718cf46bf8d4f4f97c1cf0edbd22e2.svn-base @@ -0,0 +1,37 @@ +#ifndef _CGFX_HPP_ +#define _CGFX_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace EXPORT_FROM_MYDLL FXEngine { + /* Singleton */ + class cGFX + { + private: + cGFX(); + ~cGFX(); + + public: + static cGFX& Inst(); + static void Delete(); + + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const; + void RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const; + + private: + static cGFX* sp_inst;// = nullptr + };/// END CLASS DEFINITION cGFX +}/// END NAMESPACE DEFINITION FXEngine +#endif/// END IFNDEF _CGFX_HPP_ \ No newline at end of file diff --git a/.svn/pristine/66/66c6be85bbe839c979f73e613ac1c71568e23867.svn-base b/.svn/pristine/66/66c6be85bbe839c979f73e613ac1c71568e23867.svn-base new file mode 100644 index 0000000..0ba513a --- /dev/null +++ b/.svn/pristine/66/66c6be85bbe839c979f73e613ac1c71568e23867.svn-base @@ -0,0 +1,55 @@ +#ifndef _CKEYBOARD_HPP_ +#define _CKEYBOARD_HPP_ + +/*** C++ STL Files ***/ +#include + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKey.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector >; +/*#pragma warning (default : 4231)*/ + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cKeyboard + { + public: + cKeyboard( const cString& label ); + cKeyboard( const cKeyboard& copy ); + virtual ~cKeyboard(); + + ///Funtions + + //Used when looking for keys that have been add to the check list + virtual void KeyboardCheck( const SDL_Event& event ); + + void AddKey( InputEngine::cKey* key ); + void DeleteKey( const SDL_Keycode& key ); + + void DeleteAllKeys(); + + ///Sets + ///Gets + const cString& getLabel() const; + + private: + cString m_label;// = "" + + std::vector m_keys; + };/// END CLASS DEFINITION cKeyboard +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CKEYBOARD_HPP_ \ No newline at end of file diff --git a/.svn/pristine/66/66f33a3091c1dea276544b828927f24315c8ed21.svn-base b/.svn/pristine/66/66f33a3091c1dea276544b828927f24315c8ed21.svn-base new file mode 100644 index 0000000..2cd3d1d --- /dev/null +++ b/.svn/pristine/66/66f33a3091c1dea276544b828927f24315c8ed21.svn-base @@ -0,0 +1,62 @@ +#include "cGFX.hpp" + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using FXEngine::cGFX; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cGFX* cGFX::sp_inst = nullptr; + +//private: +cGFX::cGFX() +{} + +cGFX::~cGFX() +{} + +//public: +///Functions +/*static*/ cGFX& cGFX::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGFX(); + return *sp_inst; +} + +/*static*/ void cGFX::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const +{ + if (stringRGBA(cRenderer::Inst().getRenderer(), (Sint16)pos.x, (Sint16)pos.y, text.c_str(), colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + StringDefault(text, pos, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const +{ + if (roundedBoxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, (Sint16)rad, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. roundedRectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + RoundedRectangle(rect, rad, colour); + cRenderer::Inst().ResetRenderTarget(); +} diff --git a/.svn/pristine/68/6885c88197da61a7a1c2323c5367a4331ba297cb.svn-base b/.svn/pristine/68/6885c88197da61a7a1c2323c5367a4331ba297cb.svn-base new file mode 100644 index 0000000..c662291 Binary files /dev/null and b/.svn/pristine/68/6885c88197da61a7a1c2323c5367a4331ba297cb.svn-base differ diff --git a/.svn/pristine/68/68ee8afc0f511397e49a8b81f0b6e7d48fb9a79a.svn-base b/.svn/pristine/68/68ee8afc0f511397e49a8b81f0b6e7d48fb9a79a.svn-base new file mode 100644 index 0000000..abdb293 --- /dev/null +++ b/.svn/pristine/68/68ee8afc0f511397e49a8b81f0b6e7d48fb9a79a.svn-base @@ -0,0 +1,516 @@ +#include "cWindow.hpp" + + +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RGBA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; +/*static*/ GUIHelpers::eOrientation cWindow::sORIENTATION = GUIHelpers::eOrientation::NONE; + +cWindow::cWindow( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) + : cObject(id) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cWindow::~cWindow() +{ + for (unsigned int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +/*virtual*/ void cWindow::Create( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) +{ + mp_parent = parent; + cObject::setID(id); + setOrientation(orientation); + setAlign(align); + setLayout(layout); + setPosition(pos); + setSize(size); + setPadding(padding); + m_name = name; +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } + + DebugDisplay(); +} + +///Functions +const bool cWindow::Inside( const MathEngine::iVector2& location ) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild( cWindow* obj ) +{ + m_children.push_back(obj); +} + +void cWindow::RemoveChild( cWindow* obj ) +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + //break out of the for loop + break; + } + } +} + +///Sets +/*static*/ void cWindow::PositionDefault( const GUIHelpers::Position& pos ) +{ + if (pos.x >= 0) + sPOSITION = pos; +} + +/*static*/ void cWindow::SizeDefault( const GUIHelpers::Size& size ) +{ + if (size.x >= 0) + sSIZE = size; +} + +/*static*/ void cWindow::PaddingDefault( const GUIHelpers::Padding& pad ) +{ + if (pad.x >= 0) + sPADDING = pad; +} + +/*static*/ void cWindow::AlignDefault( const GUIHelpers::eAlign& align ) +{ + if (align != GUIHelpers::eAlign::DEFAULT_ALIGN) + sALIGN = align; +} + +/*static*/ void cWindow::LayoutDefault( const GUIHelpers::eLayout& layout ) +{ + if (layout != GUIHelpers::eLayout::DEFAULT_LAYOUT) + sLAYOUT = layout; +} + +/*static*/ void cWindow::OrientationDefault( const GUIHelpers::eOrientation& orientation ) +{ + if (orientation != GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + sORIENTATION = orientation; +} + +void cWindow::setOrientation( const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/ ) +{ + if (orientation == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + m_orientation = cWindow::sORIENTATION; + else + m_orientation = orientation; +} + +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= sALIGN*/ ) +{ + if (align == GUIHelpers::eAlign::DEFAULT_ALIGN) + m_align = cWindow::sALIGN; + else + m_align = align; + RebuildPos(); +} + +void cWindow::setLayout( const GUIHelpers::eLayout& layout /*= sLAYOUT*/ ) +{ + if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT) + m_layout = cWindow::sLAYOUT; + else + m_layout = layout; +} + +void cWindow::setPosition( const GUIHelpers::Position& pos /*= POSITION*/ ) +{ + if (pos.x < 0) + m_pos = cWindow::sPOSITION; + else + m_pos = pos; +} + +void cWindow::setSize( const GUIHelpers::Size& size /*= sSIZE*/ ) +{ + if (size.x < 0) + m_size = cWindow::sSIZE; + else + m_size = size; +} + +void cWindow::setPadding( const GUIHelpers::Padding& padding /*= PADDING*/ ) +{ + if (padding.x < 0) + m_padding = cWindow::sPADDING; + else + m_padding = padding; +} + +void cWindow::setContentSize( const GUIHelpers::Size& content ) +{ + m_content = content; +} + +void cWindow::setName( const cString& name /*= NAME*/ ) +{ + m_name = name; +} + +void cWindow::setParent( cWindow* parent ) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::Position cWindow::getCenter( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = { 0, 0 }; + rtn.x = (m_size.x / 2) + m_pos.x; + rtn.y = (m_size.y / 2) + m_pos.y; + if (pad == true) { + rtn.x += (m_padding.x - m_padding.w); + rtn.y += (m_padding.y - m_padding.z); + } + return rtn; +} + +const GUIHelpers::eOrientation& cWindow::getOrientation() const +{ + return m_orientation; +} + +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position cWindow::getPosition( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = m_pos; + + if (pad == false) { + rtn.x -= m_padding.x; + rtn.y -= m_padding.y; + } + + return rtn; +} + +const GUIHelpers::Size cWindow::getSize( const bool pad /*= true*/ ) const +{ + GUIHelpers::Size rtn = m_size; + + if (pad == true) { + rtn.x += m_padding.x + m_padding.w; + rtn.y += m_padding.y + m_padding.z; + } + + return rtn; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout( const GUIHelpers::eLayout& layout ) +{ + GUIHelpers::Size mySize = { 0, 0 }; + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + GUIHelpers::Position myPos = mp_parent->getPosition(false); + myPos.x += m_padding.x; + myPos.y += m_padding.y; + mySize = mp_parent->getSize(false); + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + m_pos = myPos; + m_size = mySize; + } + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + if (m_children.size() > 0) { + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + AddSize(size.x, size.y, mySize); + } + } + else { + if (mp_parent != nullptr) + m_pos = mp_parent->getCenter(); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } + + if (this->getType() == GUIHelpers::eType::CLAYOUT) { + GUIHelpers::Position prtCenter = getCenter(); + GUIHelpers::Position ourSet = prtCenter; + GUIHelpers::Size totalSize = { 0, 0 }; + GUIHelpers::Position totalCenter = { 0, 0 }; + + for (it = m_children.begin(); it < m_children.end(); it++) { + totalSize += (*it)->getSize(); + } + totalCenter.x = totalSize.x / 2; + totalCenter.y = totalSize.y / 2; + + ourSet.x -= totalCenter.x; + ourSet.y -= totalCenter.y; + + + GUIHelpers::Position posSet = ourSet; + GUIHelpers::Position posNext = posSet; + for (it = m_children.begin(); it < m_children.end(); it++) { + posSet = posNext; + GUIHelpers::Padding pad = (*it)->getPadding(); + GUIHelpers::Size size = (*it)->getSize(false); + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + posSet.x += pad.x; + posSet.y = (pad.y - pad.z - (size.y / 2)) + prtCenter.y; + + posNext = posSet; + + posNext.x += size.x + pad.w; + //posNext.y = ourSet.y; + } + else { + posSet.x = (pad.x - pad.w - (size.x / 2)) + prtCenter.x; + posSet.y += pad.y; + + posNext = posSet; + + //posNext.x = ourSet.x; + posNext.y += size.y + pad.z; + } + + (*it)->setPosition(posSet); + (*it)->RebuildPos(); + } + } +} + +/*virtual*/ void cWindow::RebuildPos() +{ + if ((mp_parent != nullptr) && (mp_parent->getOrientation() != GUIHelpers::eOrientation::NONE)) { + GUIHelpers::Position prtPos = mp_parent->getPosition(); + GUIHelpers::Size prtSize = mp_parent->getSize(); + + GUIHelpers::Position pos = this->getPosition(); + GUIHelpers::Size size = this->getSize(); + + GUIHelpers::Padding pad = this->getPadding(); + + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + switch (this->getAlign()) { + default: + case GUIHelpers::eAlign::CENTER: + pos.y = mp_parent->getCenter().y - (this->getSize(false).y / 2); + break; + case GUIHelpers::eAlign::BOTTOM: + pos.y = prtSize.y - size.y; + break; + case GUIHelpers::eAlign::TOP: + pos.y = prtPos.y + pad.y; + break; + } + } + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::VERTICAL) { + switch (this->getAlign()) { + default: + case GUIHelpers::eAlign::CENTER: + pos.x = mp_parent->getCenter().x - (this->getSize(false).x / 2); + break; + case GUIHelpers::eAlign::RIGHT: + pos.x = prtSize.x - size.x; + break; + case GUIHelpers::eAlign::LEFT: + pos.x = prtPos.x + pad.x; + break; + } + } + this->setPosition(pos); + } +} + +/*virtual*/ const GUIHelpers::RGBA cWindow::getDebugColour() const +{ + return GUIHelpers::WHITE; +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} + +//private +void cWindow::AddSize( int x, int y, GUIHelpers::Size& mySize ) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo < largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} + +void cWindow::DebugDisplay() const +{ + unsigned long int debugLvl = GUIEngine::cGUI::Inst().getDebugLevel(); + if (debugLvl > 0) { + SDL_Rect rect; + rect.x = m_pos.x; + rect.y = m_pos.y; + rect.w = m_pos.x + m_size.x; + rect.h = m_pos.y + m_size.y; + + GUIHelpers::Position strPos = getCenter(); + + GUIHelpers::RGBA colour = getDebugColour(); + FXEngine::cGFX::Inst().Pixel(strPos.x, strPos.y, colour); + + cString str = ""; + str.format("X: %d Y: %d", strPos.x, strPos.y); + FXEngine::cGFX::Inst().StringDefault(str, { strPos.x + 2, strPos.y + 2, 0, 0 }, colour); + + if (debugLvl > 1) { + SDL_Rect typePos = { 2, 2, 0, 0 }; + cString type = ""; + switch (getType()) { + case GUIHelpers::eType::CPANEL: + type = "Panel"; + break; + case GUIHelpers::eType::CLAYOUT: + type = "Layout"; + break; + case GUIHelpers::eType::CLABEL: + typePos = { -10, -10, 0, 0 }; + type = "Label"; + break; + default: + type = ""; + } + + typePos.x += m_pos.x; + typePos.y += m_pos.y; + + FXEngine::cGFX::Inst().StringDefault(type, typePos, colour); + +// if (debugLvl > 2) { +// GUIHelpers::Position pos = getPosPPad(); +// //GUIHelpers::Size size = getSizePPad(); +// SDL_Rect box{ 0, 0, 0, 0 }; +// box.x += pos.x; +// box.y += pos.y; +// box.h += pos.y + m_size.y + m_padding.y + m_padding.z; +// box.w += pos.x + m_padding.x; +// +// FXEngine::cGFX::Inst().Box(box, colour); +// } + } + + FXEngine::cGFX::Inst().Rectangle(rect, colour); + } +} \ No newline at end of file diff --git a/.svn/pristine/69/690b6eee7b5d779a6f91599caf16ffde624b4b7f.svn-base b/.svn/pristine/69/690b6eee7b5d779a6f91599caf16ffde624b4b7f.svn-base new file mode 100644 index 0000000..a178ad1 --- /dev/null +++ b/.svn/pristine/69/690b6eee7b5d779a6f91599caf16ffde624b4b7f.svn-base @@ -0,0 +1,31 @@ +#ifndef _COBJECT_HPP_ +#define _COBJECT_HPP_ + +/*** Custom Header Files ***/ +#include "Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cObject + { + public: + cObject( const signed int id ); + virtual ~cObject(); + + bool operator == (const cObject& other); + + ///Functions + + ///Sets + + ///Gets + const signed int getID() const; + virtual const GUIHelpers::eType getType() const; + + private: + signed int m_id;// = 0 + };/// END CLASS DEFINITION cObject +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _COBJECT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/69/694d8c8d25ed3099ff9a482abd448f0d841b1369.svn-base b/.svn/pristine/69/694d8c8d25ed3099ff9a482abd448f0d841b1369.svn-base new file mode 100644 index 0000000..ace49ab --- /dev/null +++ b/.svn/pristine/69/694d8c8d25ed3099ff9a482abd448f0d841b1369.svn-base @@ -0,0 +1,223 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + TrooperEngineDLL + + + + DynamicLibrary + MultiByte + true + v140 + + + StaticLibrary + MultiByte + false + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + /MP %(AdditionalOptions) + Disabled + $(TINYXML);$(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + NotUsing + %(PreprocessorDefinitions) + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + ../Debug;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.11\lib;$(SDL)\SDL_image-1.2.10\lib;$(SDL)\SDL-1.2.14\lib;%(AdditionalLibraryDirectories) + true + NotSet + false + + + + + MachineX86 + + + + + Full + ../LinkListDLLProject/dllExportFiles;dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level4 + true + ProgramDatabase + true + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;LinkList.lib;%(AdditionalDependencies) + $(OutDir)TrooperEngine.dll + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + true + true + false + + + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/69/69829b534e57c0532af2cce24401073f37c00a00.svn-base b/.svn/pristine/69/69829b534e57c0532af2cce24401073f37c00a00.svn-base new file mode 100644 index 0000000..4fcd614 --- /dev/null +++ b/.svn/pristine/69/69829b534e57c0532af2cce24401073f37c00a00.svn-base @@ -0,0 +1,88 @@ +/* Copyright (C) 2016 Richard W. Allen +Program Name: SDL Pong C++ +Author: Richard W. Allen +Version: V1.0 +Date Started: August 24, 2016 +Date End: +Webpage: http://www.richardallenonline.com +IDE: Visual Studio 2015 +Compiler: C\C++ 2014 +Langage: C++ +License: GNU GENERAL PUBLIC LICENSE Version 2 +see license.txt for details + +*/ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "UTest/UTest.hpp" + +#include "UtilityEngineTest/StringTest.hpp" + +using UtilityEngine::cString; + +int main(int argc, char *argv[]) +{ + argc, argv; + + printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n"); + + + UTest u("cVideo"); + + printf("\nTesting cVideo\n"); + + //TrooperEngineCore::cTrooperEngineCore& core = TrooperEngineCore::cTrooperEngineCore::Inst(); + VideoEngine::cVideo& video = VideoEngine::cVideo::Inst(); + video.Initialize(); + //core.VideoInit(); + + if (!video.Setup()) { + printf("database failed to open.\n"); + return 1; + } + + u.test("Video Initialize open", !video.IsInit()); + + StringTest(); + + GUIEngine::cGUI::Inst().Initialize("GUI.xml", "xml/"); + GUIEngine::cGUI::Inst().Display(); + + SDL_Event event; + bool run = true; + while (run) { + VideoEngine::cVideo::Inst().Display(); + while (SDL_PollEvent(&event)) { + /* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */ + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_SPACE: + run = false; + break; + + default: + break; + } + break; + + case SDL_KEYUP: + printf("Key release detected\n"); + break; + + default: + break; + } + } + } + + + //system("pause"); + + return 0; +} \ No newline at end of file diff --git a/.svn/pristine/69/69cacf9f5ed8d6e1a8e25ebfdf4145fbef374f33.svn-base b/.svn/pristine/69/69cacf9f5ed8d6e1a8e25ebfdf4145fbef374f33.svn-base new file mode 100644 index 0000000..b68f632 --- /dev/null +++ b/.svn/pristine/69/69cacf9f5ed8d6e1a8e25ebfdf4145fbef374f33.svn-base @@ -0,0 +1,91 @@ +#ifndef _CSOUND_HPP_ +#define _CSOUND_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace AudioEngine { + class EXPORT_FROM_MYDLL cSound + { + public: + cSound( const cString& dir = "", const cString& filename = "", const unsigned char volume = 255, + const unsigned char distance = 100, const short int angle = 0, const long int channel = -1, + const long int loops = -1 ); + /* Copy constructor */ + cSound( const cSound& copy ); + ~cSound(); + + ///Functions + /* Plays the sound if loaded */ + void PlaySound(); + /* Fades in the sound for time */ + void FadeIn( const unsigned int time = 1000 ) const; + /* Fades out the sound for time */ + void FadeOut( const unsigned int time = 1000 ) const; + + ///Sets + /* Sets the directory of the sound */ + void setDir( const cString& dir ); + /* Sets the file name of the sound */ + void setFileName( const cString& filename ); + /* Sets the file name and the directory of the sound */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + /* Sets the Volume of the sound */ + void setVolume( const unsigned char volume = 255 ); + /* Sets the Distance of the sound */ + void setDistance( const unsigned char distance = 100 ); + /* Sets the Angle of the sound */ + void setAngle( const short int angle = 0 ); + /* Sets the Channel of the sound */ + void setChannel( const long int channel = -1); + /* Sets how many times the sound loops */ + void setLoops( const long int loops = -1 ); + + + ///Gets + /* Gets the directory of the sound */ + const cString getDir() const; + /* Gets the file name of the sound */ + const cString getFileName() const; + /* Gets the Volume of the sound */ + const unsigned char getVolume() const; + /* Gets the Distance of the sound */ + const unsigned char getDistance() const; + /* Gets the Angle of the sound */ + const short int getAngle() const; + /* Gets the Channel of the sound */ + const long int getChannel() const; + /* Gets how many times the sound loops */ + const long int getLoops() const; + + private: + ///Functions + void LoadSound(); + void UnloadSound(); + + private: + ///Variables + Mix_Chunk* mp_sound;// = nullptr + + cString m_dir;// = "" + cString m_fileName;// = "" + + + unsigned char m_volume;// = 255 + unsigned char m_distance;// = 100 + + short int m_angle;// = 0 + long int m_channel;// = -1 + long int m_loops;// = 0 + };/// END CLASS DEFINITION cSound +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CSOUND_HPP_ diff --git a/.svn/pristine/6b/6b126809025692804177c816ede29e85c455e09e.svn-base b/.svn/pristine/6b/6b126809025692804177c816ede29e85c455e09e.svn-base new file mode 100644 index 0000000..a86dfe6 --- /dev/null +++ b/.svn/pristine/6b/6b126809025692804177c816ede29e85c455e09e.svn-base @@ -0,0 +1,35 @@ +#ifndef _CPLAYER_HPP_ +#define _CPLAYER_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ + +using UtilityEngine::cString; + +namespace Equipment { + class cPlayer + { + public: + cPlayer( const cString name ); + ~cPlayer(); + + ///Functions + void Score( const unsigned long int score = 1 ); + + ///Sets + void setName( const cString name ); + + ///Gets + const unsigned long int getScore() const; + const cString getName() const; + + private: + private: + unsigned long int m_score;// = 0 + + cString m_name; + };/// END CLASS DEFINITION cPlayer +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CPLAYER_HPP_ \ No newline at end of file diff --git a/.svn/pristine/6b/6bc520d3a4b7985266cf07e98e955062fe9328a4.svn-base b/.svn/pristine/6b/6bc520d3a4b7985266cf07e98e955062fe9328a4.svn-base new file mode 100644 index 0000000..c0c70f3 --- /dev/null +++ b/.svn/pristine/6b/6bc520d3a4b7985266cf07e98e955062fe9328a4.svn-base @@ -0,0 +1,100 @@ +#ifndef _CWINDOW_HPP_ +#define _CWINDOW_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject + { + public: + static const UtilityEngine::cString sNAME; /*= "windows";*/ + static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/ + static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/ + static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/ + static GUIHelpers::RBGA sCOLOUR; /*= { 100, 100, 100, 255 };*/ + + static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/ + static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/ + + protected: + cWindow( cWindow* parent = nullptr, const signed int id = -1, 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 ); + virtual ~cWindow(); + + public: + ///Functions + virtual void Display(); + + const bool Inside( const MathEngine::iVector2& location ) const; + + void AddChild(cWindow* obj); + + void RemoveChild(cWindow* obj); + + void AddSizeX( const unsigned long int x ); + void AddSizeY( const unsigned long int y ); + + ///Sets + void setAlign( const GUIHelpers::eAlign& align = GUIHelpers::eAlign::CENTER ); + void setLayout( const GUIHelpers::eLayout& layout = GUIHelpers::eLayout::FILL_PARENT ); + void setPosition( const GUIHelpers::Position& pos = sPOSITION ); + void setSize( const GUIHelpers::Size& size = sSIZE ); + void setPadding(const GUIHelpers::Padding& padding = sPADDING); + void setContentSize( const GUIHelpers::Size& content ); + void setName( const cString& name = sNAME ); + + void setParent( cWindow* parent ); + + ///Gets + const GUIHelpers::eAlign& getAlign() const; + const GUIHelpers::eLayout& getLayout() const; + const GUIHelpers::Position& getPosition() const; + const GUIHelpers::Size& getSize() const; + const GUIHelpers::Padding& getPadding() const; + const GUIHelpers::Size& getContentSize() const; + const cString& getName() const; + + cWindow* getParent(); + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + virtual void RePos(); + virtual void RebuildPos(); + + protected: + std::vector& getChildren(); + + private: + void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout ); + + private: + GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER; + GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT; + GUIHelpers::Position m_pos;// = POSITION; + GUIHelpers::Size m_size;// = SIZE; + GUIHelpers::Padding m_padding;// = PADDING; + GUIHelpers::Size m_content;// = m_size; + cString m_name;// = NAME; + + std::vector m_children; + cWindow* mp_parent;// = nullptr; + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ diff --git a/.svn/pristine/6c/6cbff43c49b7bde2d310b71269e6f0bf17282215.svn-base b/.svn/pristine/6c/6cbff43c49b7bde2d310b71269e6f0bf17282215.svn-base new file mode 100644 index 0000000..f6d3606 --- /dev/null +++ b/.svn/pristine/6c/6cbff43c49b7bde2d310b71269e6f0bf17282215.svn-base @@ -0,0 +1,11 @@ +#include "cMouse.hpp" + +using InputEngine::cMouse; + +cMouse::cMouse() +{} + +cMouse::~cMouse() +{} + + diff --git a/.svn/pristine/6d/6d359aba55a7fb00cd3782ff30b593b8e82a4f55.svn-base b/.svn/pristine/6d/6d359aba55a7fb00cd3782ff30b593b8e82a4f55.svn-base new file mode 100644 index 0000000..baa257f --- /dev/null +++ b/.svn/pristine/6d/6d359aba55a7fb00cd3782ff30b593b8e82a4f55.svn-base @@ -0,0 +1,385 @@ +#include "cString.hpp" + +#ifdef _MSC_VER +// disable _s warnings +# define _CRT_SECURE_NO_WARNINGS +// disable pragma warnings +# pragma warning( disable : 4068 ) +# pragma warning( disable : 4996 ) +# include "MSUNIX/msunix.hpp" +#endif + +using UtilityEngine::cString; + +cString::cString() +{ + clear(); +} + +cString::cString(const char* s) +{ + copy_str(s); +} + +cString::cString(const cString& copy) +{ + copy_str(copy); +} + + +cString::~cString() +{ + clear(); +} + +const char* cString::alloc_str(size_t sz) +{ + if (mp_str) + clear(); + m_len = (sz > __cString__MAX_LEN) ? __cString__MAX_LEN : sz; + mp_str = (char *)calloc(1, m_len + 1); + return mp_str; +} + +void cString::clear() +{ + if (mp_str) + free((void *)mp_str); + mp_str = nullptr; + m_len = 0; +} + +const char* cString::c_str() const +{ + return mp_str; +} + +const char* cString::copy_str(const char* copy) +{ + if (copy) { + size_t len = strnlen(copy, __cString__MAX_LEN); + alloc_str(len); + strncpy((char *)mp_str, copy, len); + m_len = len; + } + return mp_str; +} + +bool cString::have_value() const +{ + if (mp_str) + return true; + else + return false; +} + +size_t cString::length() const +{ + return m_len; +} + +size_t cString::size() const +{ + return m_len; +} + +// string format +cString& cString::format(const char* format, ...) +{ + char * buffer; + + va_list args; + va_start(args, format); + + vasprintf(&buffer, format, args); + copy_str(buffer); + free(buffer); + return *this; +} + +// trim leading and trailing spaces +cString& cString::trim() +{ + const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a"; + + if (!have_value()) + return *this; // make sure we have a string + + size_t begin = 0; + size_t end = length() - 1; + + for (begin = 0; begin <= end; ++begin) { + if (strchr(whitespace, mp_str[begin]) == nullptr) { + break; + } + } + + for (; end > begin; --end) { + if (strchr(whitespace, mp_str[end]) == nullptr) { + break; + } + else { + mp_str[end] = '\0'; + } + } + + if (begin) { + for (size_t i = 0; mp_str[i]; ++i) { + mp_str[i] = mp_str[begin++]; + } + } + + m_len = strlen(mp_str); + return *this; +} + +cString cString::lower() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)tolower(rs.mp_str[i]); + } + return rs; +} + +cString cString::upper() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)toupper(rs.mp_str[i]); + } + return rs; +} + +const char & cString::last_char() const +{ + return mp_str[length() - 1]; +} + +// non-destructive split +const std::vector cString::split(const char match) const +{ + const char match_s[2] = { match, 0 }; + return split(match_s, -1); +} + +const std::vector cString::split(const char* match) const +{ + return split(match, -1); +} + +const std::vector cString::split(const char* match, int max_split) const +{ + std::vector rv; + if (length() < 1) + return rv; + size_t match_len = strnlen(match, __cString__MAX_LEN); + if (match_len >= __cString__MAX_LEN) + return rv; + + char * mi; // match index + char * pstr = mp_str; // string pointer + mi = strstr(pstr, match); + while ((mi) && (max_split < 0 || --max_split)) { + if (mi != pstr) { + size_t lhsz = mi - pstr; + char * cslhs = (char *)malloc(lhsz + 1); + cslhs[lhsz] = '\0'; // strncpy doesn't terminate it + rv.emplace_back(strncpy(cslhs, pstr, lhsz)); // calls BWString copy ctor + pstr += lhsz; + free(cslhs); + } + pstr += match_len; + } + + if (*pstr != '\0') { + rv.emplace_back(pstr); + } + + return rv; +} + +const cString& cString::char_repl(const char& match, const char& repl) +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) mp_str[i] = repl; + } + return *this; +} + +long int cString::char_find(const char& match) const +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) + return i; + } + return -1; +} + +cString cString::substr(size_t start, size_t length) const +{ + cString rs; + char * buf; + if ((length + 1) > __cString__MAX_LEN) + return rs; + if ((start + length) > __cString__MAX_LEN) + return rs; + if (length > m_len - start) + return rs; + if (!mp_str) + return rs; + + buf = (char *)calloc(sizeof(char), length + 1); + memcpy(buf, mp_str + start, length); + rs = buf; + return rs; +} + +long int cString::find(const cString& match) +{ + char * pos = strstr(mp_str, match.c_str()); + if (pos) + return (long)(pos - mp_str); + else + return -1; +} + +const cString cString::replace(const cString& match, const cString& repl) +{ + cString rs; + long f1 = find(match); + if (f1 >= 0) { + size_t pos1 = (size_t)f1; + size_t pos2 = pos1 + match.length(); + cString s1 = pos1 > 0 ? substr(0, pos1) : ""; + cString s2 = substr(pos2, length() - pos2); + rs = s1 + repl + s2; + } + return rs; +} + +cString& cString::operator = (const char* rhs) +{ + copy_str(rhs); + return *this; +} + +cString& cString::operator = (const cString& rhs) +{ + copy_str(rhs.c_str()); + return *this; +} + +cString& cString::operator += (const char rhs) +{ + operator+=(&rhs); + return *this; +} + +cString& cString::operator += (const char* rhs) +{ + if (rhs) { + size_t newlen = m_len + strnlen(rhs, __cString__MAX_LEN); + if (newlen > __cString__MAX_LEN) + newlen = __cString__MAX_LEN; + char * buf = (char *)calloc(1, newlen + 1); + if (!buf) + return *this; + + if (mp_str && m_len) + strncpy(buf, mp_str, m_len); + strncpy(buf + m_len, rhs, newlen - m_len); + + buf[newlen] = '\0'; + copy_str(buf); + free(buf); + } + return *this; +} + +cString& cString::operator += (const cString& rhs) +{ + operator+=(rhs.c_str()); + return *this; +} + +bool cString::operator == (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator == (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator != (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator != (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator > (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) > 0) + return true; + else + return false; +} + +bool cString::operator < (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) < 0) + return true; + else + return false; +} + +bool cString::operator >= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) >= 0) + return true; + else + return false; +} + +bool cString::operator <= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) <= 0) + return true; + else return false; +} + +cString::operator const char* () const +{ + return c_str(); +} + +cString::operator std::string () const +{ + return std::string(c_str()); +} + +cString operator + (const cString& lhs, const cString& rhs) +{ + cString rs = lhs; + rs += rhs; + return rs; +} + diff --git a/.svn/pristine/73/73442109029d1aa902990ebfca3466ceb43bfe3c.svn-base b/.svn/pristine/73/73442109029d1aa902990ebfca3466ceb43bfe3c.svn-base new file mode 100644 index 0000000..74872a1 Binary files /dev/null and b/.svn/pristine/73/73442109029d1aa902990ebfca3466ceb43bfe3c.svn-base differ diff --git a/.svn/pristine/73/73ba4527e007fcaf8be90a1d9ab713e97c9e6fe8.svn-base b/.svn/pristine/73/73ba4527e007fcaf8be90a1d9ab713e97c9e6fe8.svn-base new file mode 100644 index 0000000..3bd4cc7 Binary files /dev/null and b/.svn/pristine/73/73ba4527e007fcaf8be90a1d9ab713e97c9e6fe8.svn-base differ diff --git a/.svn/pristine/73/73f4f4dc6946388d5bbf9e1177ca631f65d51912.svn-base b/.svn/pristine/73/73f4f4dc6946388d5bbf9e1177ca631f65d51912.svn-base new file mode 100644 index 0000000..7848688 --- /dev/null +++ b/.svn/pristine/73/73f4f4dc6946388d5bbf9e1177ca631f65d51912.svn-base @@ -0,0 +1,37 @@ +#ifndef _CKEY_HPP_ +#define _CKEY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cKey + { + public: + cKey( const SDL_Keycode& key ); + cKey( const cKey& copy ); + virtual ~cKey(); + + ///Funtions + /* Call to check if the key is pressed */ + virtual void KeyPress(); + /* Call to check if the key is released */ + virtual void KeyUP(); + /* Call to check if the key is pressed */ + virtual void KeyDown(); + + ///Sets + void setKey( const SDL_Keycode& key ); + + ///Gets + const SDL_Keycode& getKey() const; + + private: + private: + SDL_Keycode m_key; + };/// END CLASS DEFINITION cKey +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CKEY_HPP_ \ No newline at end of file diff --git a/.svn/pristine/74/74c3382f797d9533e208771c7c2c2b43096c675a.svn-base b/.svn/pristine/74/74c3382f797d9533e208771c7c2c2b43096c675a.svn-base new file mode 100644 index 0000000..b63bbea --- /dev/null +++ b/.svn/pristine/74/74c3382f797d9533e208771c7c2c2b43096c675a.svn-base @@ -0,0 +1,86 @@ +#include "cTextType.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cTextType; +using UtilityEngine::cUtility; + +/*static*/ cTextType* cTextType::sp_inst = nullptr; + +//private +cTextType::cTextType() +{ +} + +cTextType::~cTextType() +{ + CleanUp(); + TTF_Quit(); +} + +//public: +///Functions +/*static*/ cTextType& cTextType::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTextType(); + return *sp_inst; +} + +/*static*/ void cTextType::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTextType::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if (TTF_Init() == 0) { + cUtility::Inst().Message("True Type Font Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize True Type Font. TTF_Init():", __AT__, cUtility::eTypeSDL::TTF); + } + return rtn; +} + +/* Creates the cTextType's*/ +const bool cTextType::Setup() +{ + /*bool rtn = false; + + CleanUp(); + + rtn = Init(); + + return rtn;*/ + return true; +} + +void cTextType::CleanUp() +{ +} + +void cTextType::PrintVersion() const +{ + cUtility::Inst().PrintVersion(cUtility::eTypeSDL::TTF); +} + +///Sets +///Gets +const bool cTextType::IsInit() const +{ + bool rtn = false; + + if (TTF_WasInit() != 0) { + cUtility::Inst().Message("True Type Font is initialized."); + rtn = true; + } else + cUtility::Inst().Message("True Type Font is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/74/74c8a6271c17349a4ce148a51536912b20f2488d.svn-base b/.svn/pristine/74/74c8a6271c17349a4ce148a51536912b20f2488d.svn-base new file mode 100644 index 0000000..0f271f3 --- /dev/null +++ b/.svn/pristine/74/74c8a6271c17349a4ce148a51536912b20f2488d.svn-base @@ -0,0 +1,170 @@ +#include "cButton.hpp" + +/*** Custom Header Files ***/ +#include "GUIHelpers/Enums.hpp" +#include "../VideoEngine/cRenderer.hpp" +#include "../FXEngine/cGFX.hpp" + +using GUIEngine::cButton; + +using MathEngine::iVector2; +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*/ ) + : cWindow(parent, id, sORIENTATION, align, layout, pos, size, padding, name) +{ + //Create(parent, id, align, layout, pos, size, padding, name, image); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ cButton::~cButton() +{ + delete mp_texture; + mp_texture = nullptr; + + delete mp_texturePress; + mp_texturePress = nullptr; + +} + +///Functions +void cButton::Create( 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*/ ) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ void cButton::Press() +{ + mp_texture->SaveImage("hello.bmp"); +} + +// void cButton::setLabel( const cString& label ) +// { +// if (label.size() > 0) { +// if (mp_label == nullptr) +// mp_label = new TextTypeEngine::cText(label); +// else +// mp_label->setText(label); +// } +// } + +///Gets +// const cString cButton::getLabel() const +// { +// cString rtn = ""; +// if (mp_label != nullptr) +// rtn = mp_label->getText(); +// return rtn; +// } + +/*virtual*/ const GUIHelpers::eType cButton::getType() const +{ + return GUIHelpers::eType::CBUTTON; +} + + +//private +void cButton::GenerateImage() +{ + GenerateTexture(); + //GenerateTexture( mp_texturePress ); + + this->setImage((VideoEngine::cImage**)(&mp_texture)); + + this->setImageArea(mp_texture->getWH()); +} + +void cButton::GenerateTexture() +{ +// SDL_Rect t = { 0, 0, 0, 0 }; +// if (mp_label != nullptr) +// t = mp_label->getWH(); +// SDL_Rect centerText = { 0, 0, 0, 0 }; +// SDL_Rect centerButton = { 0, 0, 0, 0 }; +// SDL_Rect dim = this->getImageArea(); +// +// GUIHelpers::Padding TXTPADDING = PADDING; +// ///Find the min padding around the text. +// if (dim.w < (t.w + TXTPADDING.x + TXTPADDING.w) ) +// dim.w += (t.w + TXTPADDING.x + TXTPADDING.w); +// +// if (dim.h < (t.h + TXTPADDING.y + TXTPADDING.z) ) +// dim.h += (t.h + TXTPADDING.y + TXTPADDING.z); +// +// ///Find the center of the button +// centerButton.x = dim.w / 2; +// centerButton.y = dim.h / 2; +// +// ///Find the center of the text +// centerText.x = t.w / 2; +// centerText.y = t.h / 2; +// +// if (centerText.x < centerButton.x) +// t.x = centerButton.x - centerText.x; +// +// if (centerText.y < centerButton.y) +// t.y = centerButton.y - centerText.y; +// +// SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); +// +// GUIHelpers::RBGA colour = { 100, 100, 100, 255 }; +// +// FXEngine::cGFX::Inst().RoundedRectangle(dim, 4, colour, temptext); +// +// +// if (mp_label != nullptr) +// VideoEngine::cRenderer::Inst().RenderToTexture(mp_label->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + +// delete mp_texture; +// mp_texture = nullptr; +// +// mp_texture = new VideoEngine::cImage(temptext); +// +// GUIHelpers::Size size = { 0, 0 }; +// mp_texture->getWH((unsigned long&)size.x, (unsigned long&)size.y); +// cWindow::setSize(size); +// image->setImage(temptext); + //image->setImage(temptext); +} diff --git a/.svn/pristine/75/7523737f7e816893b4f6beafac6af42286574e6f.svn-base b/.svn/pristine/75/7523737f7e816893b4f6beafac6af42286574e6f.svn-base new file mode 100644 index 0000000..274928f --- /dev/null +++ b/.svn/pristine/75/7523737f7e816893b4f6beafac6af42286574e6f.svn-base @@ -0,0 +1,49 @@ +#ifndef _CPADDLE_HPP_ +#define _CPADDLE_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "eBallState.hpp" + +namespace Equipment { + class cPaddle : public VideoEngine::cSprite + { + public: + enum eState { + Up = 0, + Still, + Down + }; + + cPaddle( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + ~cPaddle(); + + ///Functions + void Move(); + const bool isPaused(); + void Pause(); + + void Reset(); + + ///Sets + void setSpeed( const double speed = 0.0 ); + void setState( const eState state = eState::Still ); + + ///Gets + const eState getState() const; + + private: + + private: + double m_speed; + + bool m_pause;// = false + + eState m_state;// = Still + };/// END CLASS DEFINITION cPaddle +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CPADDLE_HPP_ \ No newline at end of file diff --git a/.svn/pristine/75/75d4922687a8a5d4b0c9def9f83f86f716ff7b8d.svn-base b/.svn/pristine/75/75d4922687a8a5d4b0c9def9f83f86f716ff7b8d.svn-base new file mode 100644 index 0000000..ba38417 --- /dev/null +++ b/.svn/pristine/75/75d4922687a8a5d4b0c9def9f83f86f716ff7b8d.svn-base @@ -0,0 +1,135 @@ +#ifndef _CVIDEO_HPP_ +#define _CVIDEO_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cVideo + { + private: + cVideo(); + ~cVideo(); + + public: + ///Functions + static cVideo& Inst(); + static void Delete(); + + const bool Initialize() const; + + /* Creates the cVideo's mp_buff and mp_screen surfaces */ + const bool Setup(); + /* Uses SDL_Freesurface to delete cVideo's mp_buff and mp_screen surfaces */ + void CleanUp(); + + /* Used to Display the new frame */ + void Display(); + + SDL_Renderer* CreateRender(); + + ///Sets + /* Sets the videos width resolution */ + void setWidth( const unsigned long int width = 640 ); + /* Sets the videos height resolution */ + void setHeight( const unsigned long int height = 480 ); + /* Sets the videos colour depth in bits */ + void setColour( const unsigned long int colour = 32 ); + /* Sets the caption on the displayed window */ + void setCaption( const cString& caption = "" ); + + /* Sets video to use hardware surfaces if true other wise software surfaces are used */ + void setHardwareVideo( const bool hardware = false ); + /* Sets the video to full screen if true other wise a window is used */ + void setFullScreen( const bool fullscreen = false ); + /* Sets the video to use double buffering other wise no buffering is used */ + void setVSync( const bool vsync = false ); + + void setDisplayMode( const SDL_DisplayMode& mode ); + + ///Gets + /* Gets return true if video was initialized */ + const bool IsInit() const; + /* Gets the videos width resolution */ + const unsigned long int getWidth() const; + /* Gets the videos height resolution */ + const unsigned long int getHeight() const; + /* Gets the videos colour depth in bits */ + const unsigned long int getColour() const; + /* Gets the caption displayed on the window */ + const cString getCaption() const; + + /* Gets returns true if hardware surfaces are being used other wise false is return */ + const bool getHardwareVideo() const; + /* Gets returns true if full screen is being used other wise false is return */ + const bool getFullScreen() const; + /* Gets returns true if Double Buffering is being used other wise false is return */ + const bool getVSync() const; + + /* Gets returns the SDL video flags */ + const unsigned long int getVideoSettings() const; + + /* Gets returns the SDL_Window pointer */ + SDL_Window* getWindow(); + + /* Gets returns the Display Mode */ + SDL_DisplayMode getDisplayMode() const; + + /* Gets returns the Red mask value */ + const unsigned long int getRmask() const; + /* Gets returns the Green mask value */ + const unsigned long int getGmask() const; + /* Gets returns the Blue mask value */ + const unsigned long int getBmask() const; + /* Gets returns the Alpha mask value */ + const unsigned long int getAmask() const; + + private: + ///Functions + void VideoSettings(); + + private: + ///Variables + SDL_Window* mp_window;// = nullptr + //SDL_Renderer* mp_rend;// = nullptr + + unsigned long int m_xPos;// = 100 + unsigned long int m_yPos;// = 100 + unsigned long int m_width;// = 640 + unsigned long int m_height;// = 480 + unsigned long int m_colour;// = 32 + + bool m_hardwareVideo;// = false + bool m_fullscreen;// = false + bool m_vsync;// = false + + unsigned long int m_videoSettings;// = SDL_RENDERER_SOFTWARE + + static cVideo* sp_inst;// = nullptr + + /*SDL interprets each pixel as a 32-bit number, so our masks must depend + on the endianness (byte order) of the machine */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + const unsigned long int m_rmask;// = 0xff000000; + const unsigned long int m_gmask;// = 0x00ff0000; + const unsigned long int m_bmask;// = 0x0000ff00; + const unsigned long int m_amask;// = 0x000000ff; +#else + const unsigned long int m_rmask;// = 0x000000ff; + const unsigned long int m_gmask;// = 0x0000ff00; + const unsigned long int m_bmask;// = 0x00ff0000; + const unsigned long int m_amask;// = 0xff000000; +#endif + };/// END CLASS DEFINITION cVideo +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CVIDEO_HPP_ diff --git a/.svn/pristine/78/7818126d8b47b16d907bca8a06e15e3de95d2a61.svn-base b/.svn/pristine/78/7818126d8b47b16d907bca8a06e15e3de95d2a61.svn-base new file mode 100644 index 0000000..613b329 --- /dev/null +++ b/.svn/pristine/78/7818126d8b47b16d907bca8a06e15e3de95d2a61.svn-base @@ -0,0 +1,71 @@ +#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; +} + +void CreateLabel() +{} + +void GenerateImage() +{} + +void GenerateTexture() +{} \ No newline at end of file diff --git a/.svn/pristine/78/7887d9ed85471b16dd36e56c081123f6331b5c9d.svn-base b/.svn/pristine/78/7887d9ed85471b16dd36e56c081123f6331b5c9d.svn-base new file mode 100644 index 0000000..16c0434 --- /dev/null +++ b/.svn/pristine/78/7887d9ed85471b16dd36e56c081123f6331b5c9d.svn-base @@ -0,0 +1,154 @@ +#include "cSound.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using AudioEngine::cSound; +using UtilityEngine::cUtility; + +cSound::cSound( const cString& dir /*= ""*/, const cString& filename /*= ""*/, const unsigned char volume /*= 255*/, + const unsigned char distance /*= 100*/, const short int angle /*= 0*/, const long int channel /*= -1*/, + const long int loops /*= -1*/ ) +: mp_sound(nullptr), m_dir(dir), m_fileName(filename), m_volume(volume), m_distance(distance), + m_angle(angle), m_channel(channel), m_loops(loops) +{ + if (m_fileName != "") + LoadSound(); +} + +cSound::cSound( const cSound& copy ) +: mp_sound(nullptr), m_dir(copy.getDir()), m_fileName(copy.getFileName()), m_volume(copy.getVolume()), + m_distance(copy.getDistance()), m_angle(copy.getAngle()), m_channel(copy.getChannel()), + m_loops(copy.getLoops()) +{ + if (m_fileName != "") + LoadSound(); +} + +cSound::~cSound() +{ + UnloadSound(); +} + +void cSound::PlaySound() +{ + if (mp_sound != nullptr) { + if (Mix_Volume(m_channel, m_volume) < 0) + cUtility::Inst().Message("Unable to set volume. Mix_Volume():", __AT__, cUtility::eTypeSDL::MIXER); + if (Mix_SetPosition(m_channel, m_angle, m_distance) < 0) + cUtility::Inst().Message("Unable to set position. Mix_SetPosition():", __AT__, cUtility::eTypeSDL::MIXER); + if (Mix_PlayChannel(m_channel, mp_sound, m_loops) < 0) + cUtility::Inst().Message("Unable to set channel. Mix_PlayChannel():", __AT__, cUtility::eTypeSDL::MIXER); + } +} + +void cSound::FadeIn( const unsigned int time /*= 1000*/ ) const +{ + if (Mix_FadeInChannel(m_channel, mp_sound, m_loops, time) < 0) + cUtility::Inst().Message("Unable to fade in channel. Mix_FadeInChannel():", __AT__, cUtility::eTypeSDL::MIXER); +} + +void cSound::FadeOut( const unsigned int time /*= 1000*/ ) const +{ + if (Mix_FadeOutChannel(m_channel, time) < 0) + cUtility::Inst().Message("Unable to fade out channel. Mix_FadeOutChannel():", __AT__, cUtility::eTypeSDL::MIXER); +} + +///Sets +void cSound::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cSound::setFileName( const cString& filename ) +{ + m_fileName = filename; + LoadSound(); +} + +void cSound::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cSound::setVolume( const unsigned char volume /*= 255*/ ) +{ + m_volume = volume; +} + +void cSound::setDistance( const unsigned char distance /*= 100*/ ) +{ + m_distance = distance; +} + +void cSound::setAngle( const short int angle /*= 0*/ ) +{ + m_angle = angle; +} + +void cSound::setChannel( const long int channel /*= -1*/ ) +{ + m_channel = channel; +} + +void cSound::setLoops( const long int loops /*= -1*/ ) +{ + m_loops = loops; +} + +///Gets +const cString cSound::getDir() const +{ + return m_dir; +} + +const cString cSound::getFileName() const +{ + return m_fileName; +} + +const unsigned char cSound::getVolume() const +{ + return m_volume; +} + +const unsigned char cSound::getDistance() const +{ + return m_distance; +} + +const short int cSound::getAngle() const +{ + return m_angle; +} + +const long int cSound::getChannel() const +{ + return m_channel; +} + +const long int cSound::getLoops() const +{ + return m_loops; +} + +///Private +///Functions +void cSound::LoadSound() +{ + UnloadSound(); + if (m_fileName != "") + if (mp_sound == nullptr) + if ((mp_sound = Mix_LoadWAV(((cString)(m_dir + m_fileName)).c_str())) == nullptr) + cUtility::Inst().Message("Unable to load file. " + m_dir + m_fileName, "", cUtility::eTypeSDL::MIXER); +} + +void cSound::UnloadSound() +{ + if (mp_sound != nullptr) + { + Mix_FreeChunk(mp_sound); + mp_sound = nullptr; + } +} \ No newline at end of file diff --git a/.svn/pristine/7b/7b2c3cfa7c5a72938a7184249a649faa7a93c3d3.svn-base b/.svn/pristine/7b/7b2c3cfa7c5a72938a7184249a649faa7a93c3d3.svn-base new file mode 100644 index 0000000..8bc90dc --- /dev/null +++ b/.svn/pristine/7b/7b2c3cfa7c5a72938a7184249a649faa7a93c3d3.svn-base @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/.svn/pristine/7c/7c8d4d4e13852014987bb996a76fc27e50fb4b7c.svn-base b/.svn/pristine/7c/7c8d4d4e13852014987bb996a76fc27e50fb4b7c.svn-base new file mode 100644 index 0000000..0f49840 Binary files /dev/null and b/.svn/pristine/7c/7c8d4d4e13852014987bb996a76fc27e50fb4b7c.svn-base differ diff --git a/.svn/pristine/7d/7d64dff76dcc87c1045762529a443732df19f8e0.svn-base b/.svn/pristine/7d/7d64dff76dcc87c1045762529a443732df19f8e0.svn-base new file mode 100644 index 0000000..b2b2cc3 --- /dev/null +++ b/.svn/pristine/7d/7d64dff76dcc87c1045762529a443732df19f8e0.svn-base @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/.svn/pristine/7d/7d9914aa86aa24ef14cf989dbab30134fb4dcf77.svn-base b/.svn/pristine/7d/7d9914aa86aa24ef14cf989dbab30134fb4dcf77.svn-base new file mode 100644 index 0000000..8b1d8de --- /dev/null +++ b/.svn/pristine/7d/7d9914aa86aa24ef14cf989dbab30134fb4dcf77.svn-base @@ -0,0 +1,81 @@ +#ifndef _CSTRING_HPP_ +#define _CSTRING_HPP_ + +/*** C++ STL Files ***/ +#include +#include + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string; +/*#pragma warning (default : 4231)*/ + +#define __cString__MAX_LEN 65535 + +namespace UtilityEngine { + class EXPORT_FROM_MYDLL cString + { + public: + cString(); // default constructor + cString(const char* s); + cString(const cString& copy); // copy constructor + ~cString(); + + const char * alloc_str(size_t sz); // smart alloc string + void clear(); // frees the string + const char * c_str() const; // getter + const char * copy_str(const char* copy); // alloc & copy + + // utility methods + bool have_value() const; + size_t length() const; + size_t size() const; + cString & format(const char * format, ...); + cString & trim(); + cString lower() const; + cString upper() const; + const char & last_char() const; + const std::vector split(const char match) const; + const std::vector split(const char * match) const; + const std::vector split(const char * match, int max_split) const; + long int char_find(const char& match) const; + const cString & char_repl(const char & match, const char & repl); + cString substr(size_t start, size_t length) const; + long int find(const cString & match); + const cString replace(const cString & match, const cString & repl); + + // operators + cString& operator = (const char* rhs); // assignment operator + cString& operator = (const cString& rhs); // assignment operator + cString& operator += (const char rhs); + cString& operator += (const char* rhs); // concatenation operator + cString& operator += (const cString& rhs); // concatenation operator + + bool operator == (const char* rhs) const; // comparisons + bool operator == (const cString& rhs) const; + bool operator != (const char* rhs) const; + bool operator != (const cString& rhs) const; + bool operator > (const cString& rhs) const; + bool operator < (const cString& rhs) const; + bool operator >= (const cString& rhs) const; + bool operator <= (const cString& rhs) const; + + // conversion operators + operator const char * () const; // c-string type + operator std::string () const; // c++ string class + + private: + char * mp_str = nullptr; + size_t m_len = 0; + + };/// END CLASS DEFINITION cString + // function overloads +}/// END NAMESPACE DEFINITION UtilityEngine +UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs); +#endif/// END IFNDEF _CSTRING_HPP_ diff --git a/.svn/pristine/80/80c5cf0e5b6d096b18971fd110966d32571ebd2f.svn-base b/.svn/pristine/80/80c5cf0e5b6d096b18971fd110966d32571ebd2f.svn-base new file mode 100644 index 0000000..580de46 --- /dev/null +++ b/.svn/pristine/80/80c5cf0e5b6d096b18971fd110966d32571ebd2f.svn-base @@ -0,0 +1,77 @@ +#include "iVector4.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector4.hpp" + +using MathEngine::iVector4; +using MathEngine::Vector4; + +iVector4::iVector4( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/, const int W /*= 0*/ ) + : iVector3(X, Y, Z), w(W) +{} + +iVector4::iVector4( const iVector2& copy ) + : iVector3(copy.x, copy.y, 0), w(0) +{} + +iVector4::iVector4( const iVector3& copy ) + : iVector3(copy), w(0) +{} + +iVector4::iVector4( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + w = int(copy.h); +} + +iVector4& iVector4::operator=( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + w = int(copy.h); + + return *this; +} + +bool iVector4::operator==( const SDL_Rect& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.w ) + if ( w == other.h ) + rtn = true; + return rtn; +} + +iVector4::iVector4( const Vector4& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + w = int(copy.w); +} + +iVector4& iVector4::operator=( const Vector4& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + w = int(copy.w); + + return *this; +} + +bool iVector4::operator==( const iVector4& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.z ) + if ( w == other.w ) + rtn = true; + return rtn; +} diff --git a/.svn/pristine/82/82ac021484ae7dbe0373820a73953ab489287f61.svn-base b/.svn/pristine/82/82ac021484ae7dbe0373820a73953ab489287f61.svn-base new file mode 100644 index 0000000..ed552f2 --- /dev/null +++ b/.svn/pristine/82/82ac021484ae7dbe0373820a73953ab489287f61.svn-base @@ -0,0 +1,30 @@ +#include "UTest.hpp" + +const /*static*/ char * UTest::sp_pstr = "pass"; +const /*static*/ char * UTest::sp_fstr = "fail"; + +UTest::UTest( const char * tstr ) { + init(tstr); +} + +void UTest::init( const char * tstr ) { + mp_tstr = tstr; + m_pass = m_fail = 0; +} + +void UTest::test ( const char * description, const int flag ) { + const char * pf = nullptr; + if (flag) { + pf = sp_pstr; + ++m_pass; + } else { + pf = sp_fstr; + ++m_fail; + } + printf("%s: %s -> %s\n", mp_tstr, description, pf); +} + +void UTest::report() const { + printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail); +} + diff --git a/.svn/pristine/83/8316ecefb45774d64eac1a19df91c8cf4be6763d.svn-base b/.svn/pristine/83/8316ecefb45774d64eac1a19df91c8cf4be6763d.svn-base new file mode 100644 index 0000000..34ad34d --- /dev/null +++ b/.svn/pristine/83/8316ecefb45774d64eac1a19df91c8cf4be6763d.svn-base @@ -0,0 +1,124 @@ +#ifndef _CWINDOW_HPP_ +#define _CWINDOW_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject + { + protected: + static const UtilityEngine::cString sNAME; /*= "windows";*/ + static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/ + static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/ + static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/ + static GUIHelpers::RGBA sCOLOUR; /*= { 100, 100, 100, 255 };*/ + + static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/ + static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/ + static GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::NONE;*/ + + protected: + cWindow( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + public: + virtual ~cWindow(); + + protected: + virtual void Create( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + public: + ///Functions + virtual void Display(); + + const bool Inside( const MathEngine::iVector2& location ) const; + + void AddChild( cWindow* obj ); + + void RemoveChild( cWindow* obj ); + + ///Sets + static void PositionDefault( const GUIHelpers::Position& pos ); + static void SizeDefault( const GUIHelpers::Size& size ); + static void PaddingDefault( const GUIHelpers::Padding& pad ); + static void AlignDefault( const GUIHelpers::eAlign& align ); + static void LayoutDefault( const GUIHelpers::eLayout& layout ); + static void OrientationDefault( const GUIHelpers::eOrientation& orientation ); + + void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION ); + void setAlign( const GUIHelpers::eAlign& align = sALIGN ); + void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT ); + void setPosition( const GUIHelpers::Position& pos = sPOSITION ); + void setSize( const GUIHelpers::Size& size = sSIZE ); + void setPadding( const GUIHelpers::Padding& padding = sPADDING ); + void setContentSize( const GUIHelpers::Size& content ); + void setName( const cString& name = sNAME ); + + void setParent( cWindow* parent ); + + ///Gets + const GUIHelpers::Position getCenter( const bool pad = true ) const; + + const GUIHelpers::eOrientation& getOrientation() const; + const GUIHelpers::eAlign& getAlign() const; + 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::Padding& getPadding() const; + const GUIHelpers::Size& getContentSize() const; + const cString& getName() const; + + cWindow* getParent(); + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout( const GUIHelpers::eLayout& layout ); + + virtual void RePos(); + virtual void RebuildPos(); + + virtual const GUIHelpers::RGBA getDebugColour() const; + + /*protected:*/ + std::vector& getChildren(); + + private: + void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout ); + + void AddSize( int x, int y, GUIHelpers::Size& mySize ) const; + + void DebugDisplay() const; + + private: + GUIHelpers::eOrientation m_orientation;// = GUIHelper::eOrientation::NONE; + GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER; + GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT; + GUIHelpers::Position m_pos;// = POSITION; + GUIHelpers::Size m_size;// = SIZE; + GUIHelpers::Padding m_padding;// = PADDING; + GUIHelpers::Size m_content;// = m_size; + cString m_name;// = NAME; + + std::vector m_children; + cWindow* mp_parent;// = nullptr; + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ diff --git a/.svn/pristine/83/8341ba96c7d0bc1885cab71b1e78150dee41d128.svn-base b/.svn/pristine/83/8341ba96c7d0bc1885cab71b1e78150dee41d128.svn-base new file mode 100644 index 0000000..b4d2aff --- /dev/null +++ b/.svn/pristine/83/8341ba96c7d0bc1885cab71b1e78150dee41d128.svn-base @@ -0,0 +1,170 @@ +#include "cButton.hpp" + +/*** Custom Header Files ***/ +#include "GUIHelpers/Enums.hpp" +#include "../VideoEngine/cRenderer.hpp" +#include "../FXEngine/cGFX.hpp" + +using GUIEngine::cButton; + +using MathEngine::iVector2; +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*/ ) + : cWindow(parent, id, align, layout, pos, size, padding, name) +{ + //Create(parent, id, align, layout, pos, size, padding, name, image); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ cButton::~cButton() +{ + delete mp_texture; + mp_texture = nullptr; + + delete mp_texturePress; + mp_texturePress = nullptr; + +} + +///Functions +void cButton::Create( 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*/ ) +{ + //cWindow(parent, id, align, layout, pos, size, padding, name); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ void cButton::Press() +{ + mp_texture->SaveImage("hello.bmp"); +} + +// void cButton::setLabel( const cString& label ) +// { +// if (label.size() > 0) { +// if (mp_label == nullptr) +// mp_label = new TextTypeEngine::cText(label); +// else +// mp_label->setText(label); +// } +// } + +///Gets +// const cString cButton::getLabel() const +// { +// cString rtn = ""; +// if (mp_label != nullptr) +// rtn = mp_label->getText(); +// return rtn; +// } + +/*virtual*/ const GUIHelpers::eType cButton::getType() const +{ + return GUIHelpers::eType::CBUTTON; +} + + +//private +void cButton::GenerateImage() +{ + GenerateTexture(); + //GenerateTexture( mp_texturePress ); + + this->setImage((VideoEngine::cImage**)(&mp_texture)); + + this->setImageArea(mp_texture->getWH()); +} + +void cButton::GenerateTexture() +{ +// SDL_Rect t = { 0, 0, 0, 0 }; +// if (mp_label != nullptr) +// t = mp_label->getWH(); +// SDL_Rect centerText = { 0, 0, 0, 0 }; +// SDL_Rect centerButton = { 0, 0, 0, 0 }; +// SDL_Rect dim = this->getImageArea(); +// +// GUIHelpers::Padding TXTPADDING = PADDING; +// ///Find the min padding around the text. +// if (dim.w < (t.w + TXTPADDING.x + TXTPADDING.w) ) +// dim.w += (t.w + TXTPADDING.x + TXTPADDING.w); +// +// if (dim.h < (t.h + TXTPADDING.y + TXTPADDING.z) ) +// dim.h += (t.h + TXTPADDING.y + TXTPADDING.z); +// +// ///Find the center of the button +// centerButton.x = dim.w / 2; +// centerButton.y = dim.h / 2; +// +// ///Find the center of the text +// centerText.x = t.w / 2; +// centerText.y = t.h / 2; +// +// if (centerText.x < centerButton.x) +// t.x = centerButton.x - centerText.x; +// +// if (centerText.y < centerButton.y) +// t.y = centerButton.y - centerText.y; +// +// SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); +// +// GUIHelpers::RBGA colour = { 100, 100, 100, 255 }; +// +// FXEngine::cGFX::Inst().RoundedRectangle(dim, 4, colour, temptext); +// +// +// if (mp_label != nullptr) +// VideoEngine::cRenderer::Inst().RenderToTexture(mp_label->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + +// delete mp_texture; +// mp_texture = nullptr; +// +// mp_texture = new VideoEngine::cImage(temptext); +// +// GUIHelpers::Size size = { 0, 0 }; +// mp_texture->getWH((unsigned long&)size.x, (unsigned long&)size.y); +// cWindow::setSize(size); +// image->setImage(temptext); + //image->setImage(temptext); +} diff --git a/.svn/pristine/83/83bf24ecb933c9c34b1f558939df828b079bc885.svn-base b/.svn/pristine/83/83bf24ecb933c9c34b1f558939df828b079bc885.svn-base new file mode 100644 index 0000000..31db831 --- /dev/null +++ b/.svn/pristine/83/83bf24ecb933c9c34b1f558939df828b079bc885.svn-base @@ -0,0 +1,50 @@ +#ifndef _CTEXTINPUT_HPP_ +#define _CTEXTINPUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTextInput : public cKeyboard + { + public: + cTextInput(); + cTextInput( const cTextInput& copy ); + virtual ~cTextInput(); + + ///Functions + /* */ + virtual void KeyboardCheck( const SDL_Event& event ); + /* Clears out the Text */ + void ClearText(); + ///Sets + void setText( const cString& text ); + ///Gets + const cString& getText() const; + + private: + const char UnicodeValue( const SDL_Event& event ); + + private: + cString m_text;// = "" + bool m_caps;// = false + bool m_shift;// = false + + // magic numbers courtesy of SDL docs + const unsigned long int INTERNATIONAL_MASK;// = 0xFF80 + const unsigned long int UNICODE_MASK;// = 0x7F + };/// END CLASS DEFINITION cTextInput +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CTEXTINPUT_HPP_ diff --git a/.svn/pristine/84/8452caaa1235977e20f89d52a619a36799b3a813.svn-base b/.svn/pristine/84/8452caaa1235977e20f89d52a619a36799b3a813.svn-base new file mode 100644 index 0000000..10fc219 --- /dev/null +++ b/.svn/pristine/84/8452caaa1235977e20f89d52a619a36799b3a813.svn-base @@ -0,0 +1,25 @@ +#ifndef _GUIUTILITY_HPP_ +#define _GUIUTILITY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../MathEngine/iVector/iVector2.hpp" +#include "../../MathEngine/iVector/iVector4.hpp" + +namespace GUIHelpers { + typedef struct MathEngine::iVector2 Size, Position; + typedef struct MathEngine::iVector4 Padding; + typedef struct SDL_Colour RGBA; + typedef struct SDL_Rect Area; + + static const RGBA WHITE = { 255,255,255,255 }; + static const RGBA RED = { 255, 0, 0, 255 }; + static const RGBA GREEN = { 0, 255, 0, 255 }; + static const RGBA BLUE = { 0, 0, 255, 255 }; + + +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _GUIUTILITY_HPP_ + diff --git a/.svn/pristine/85/85a61fc38eb6c560b90c4bcaca7e29be160fbd13.svn-base b/.svn/pristine/85/85a61fc38eb6c560b90c4bcaca7e29be160fbd13.svn-base new file mode 100644 index 0000000..8cead49 --- /dev/null +++ b/.svn/pristine/85/85a61fc38eb6c560b90c4bcaca7e29be160fbd13.svn-base @@ -0,0 +1,58 @@ +#ifndef _CXMLOADER_HPP_ +#define _CXMLOADER_HPP_ + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "GUIUtility.hpp" + +#include "../cWindow.hpp" +#include "../cLayout.hpp" +#include "../cLabel.hpp" + +#include "../../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cXMLoader + { + private: + cXMLoader(); + ~cXMLoader(); + + public: + ///Functions + static cXMLoader& Inst(); + static void Delete(); + + void Load( const cString& filename, const cString& dir = "" ) const; + + private: + void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const; + const cString GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const; + + + void GUISetup( const tinyxml2::XMLElement& element ) const; + GUIEngine::cLayout* LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + + const unsigned long int getDebug( const tinyxml2::XMLElement& element ) const; + const signed long int getID( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eOrientation getOrientation( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eAlign getAlign( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eLayout getLayout( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Position getPosition( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Size getSize( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Padding getPadding( const tinyxml2::XMLElement& element ) const; + const cString getText( const tinyxml2::XMLElement& element ) const; + + private: + static cXMLoader* sp_inst;// = nullptr + };/// END CLASS DEFINITION cObject +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _CXMLOADER_HPP_ diff --git a/.svn/pristine/86/86962cd22f38ace1c89dd6bc911475c17ba11fa6.svn-base b/.svn/pristine/86/86962cd22f38ace1c89dd6bc911475c17ba11fa6.svn-base new file mode 100644 index 0000000..238e1e8 --- /dev/null +++ b/.svn/pristine/86/86962cd22f38ace1c89dd6bc911475c17ba11fa6.svn-base @@ -0,0 +1,202 @@ +#include "cText.hpp" + +/*** SDL Header Files ***/ +#include +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cText; +using VideoEngine::cRenderer; +using FXEngine::cGFX; +using UtilityEngine::cUtility; + +cText::cText( const cString& text, const unsigned long int size /*= 16*/ ) + : mpp_font(nullptr), m_text(text), m_size(size), m_render(eRender::Solid) +{ + White(); +} + +cText::cText( SDL_Colour& colour, TextTypeEngine::cFont** font /*= nullptr*/, const cString& text /*= ""*/, const unsigned long int size /*= 16*/, const eRender& render /*= eRender::Solid*/ ) + : mpp_font(font), m_text(text), m_size(size), m_render(render) +{ + setColour(colour); +} + +cText::cText( TextTypeEngine::cFont** font /*= nullptr*/, const cString& text /*= ""*/, const unsigned long int size /*= 16*/, + const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/, const eRender& render /*= eRender::Solid*/ ) + : mpp_font(font), m_text(text), m_size(size), m_render(render) +{ + setColour(red, green, blue); +} + +cText::cText( const cText& copy ) + : mpp_font(nullptr), m_text(copy.getText()), m_render(copy.getRender()) +{ + setColour(copy.getColour()); +} + +cText::~cText() +{} + +///Function +void cText::White() +{ + setColour(255, 255, 255); +} + +void cText::Black() +{ + setColour(); +} + +void cText::Blue() +{ + setColour(0, 0, 255); +} + +void cText::Green() +{ + setColour(0, 255); +} + +void cText::Red() +{ + setColour(255); +} + +///Sets +void cText::setSize(const unsigned long int size /*= 16*/) +{ + (*mpp_font)->setSize(size); +} + +void cText::setFont( TextTypeEngine::cFont** font ) +{ + mpp_font = font; + Text(); +} + +void cText::setText( const cString& text ) +{ + if (m_text != text) { + m_text = text; + Text(); + } +} + +void cText::setColour( const SDL_Colour& colour ) +{ + m_colour = colour; + Text(); +} + +void cText::setColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/, unsigned long int alpha /*= 255*/ ) +{ + SDL_Colour colour = {Uint8(red), Uint8(green), Uint8(blue), Uint8(alpha)}; + setColour(colour); +} + +void cText::setRender( const eRender& render /*= eRender::Solid*/ ) +{ + m_render = render; + Text(); +} + +///Gets +const unsigned long int cText::getSize() const +{ + unsigned long int rtn = 8; + if ((mpp_font != nullptr) && ((*mpp_font) != nullptr)) + return (*mpp_font)->getSize(); + return rtn; +} + +TextTypeEngine::cFont* cText::getFont() const +{ + return (*mpp_font); +} + +const cString& cText::getText() const +{ + return m_text; +} + +const SDL_Colour& cText::getColour() const +{ + return m_colour; +} + +void cText::getColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue, unsigned long int& alpha ) const +{ + red = m_colour.r; + green = m_colour.g; + blue = m_colour.b; + alpha = m_colour.a; +} + +const cText::eRender& cText::getRender() const +{ + return m_render; +} + +//Private +void cText::Text() +{ + if((mpp_font != nullptr) && (*mpp_font != nullptr)) { + SDL_Surface* sur = nullptr; + switch (m_render) + { + case Solid: + if ((sur = TTF_RenderText_Solid((*mpp_font)->getFont(m_size), m_text.c_str(), m_colour) ) == nullptr) + cUtility::Inst().Message("Unable to render text. TTF_RenderText_Solid():", __AT__, cUtility::eTypeSDL::TTF); + break; + case Shaded: + //sur = TTF_RenderText_Shaded(mp_font, text.c_str(), m_colour, + break; + case Blended: + if ((sur = TTF_RenderText_Blended((*mpp_font)->getFont(m_size), m_text.c_str(), m_colour) ) == nullptr) + cUtility::Inst().Message("Unable to render text. TTF_RenderText_Blended():", __AT__, cUtility::eTypeSDL::TTF); + break; + } + setImage(sur); + } else { + SDL_Rect pos = { 0, 0, 0, 0 }; + //m_size == 25; + SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, SDL_TEXTUREACCESS_TARGET); + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + + //int t = SDL_SetTextureColorMod(texture, 0, 255, 0); + + // 376840196 + + + + //t = SDL_SetTextureAlphaMod(texture, 0); + //SDL_fill + //cRenderer::Inst().SetRenderTarget(texture); + //SDL_Colour col = { 0, 255, 255, 255}; + //SDL_Rect re= { 0, 0, 100, 100}; + //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); + //cRenderer::Inst().RenderDrawColor(col); + //cRenderer::Inst().RenderDrawRect(re, texture); + + //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); + + //cRenderer::Inst().Render( texture, nullptr, nullptr); + //SDL_RenderCopy(cRenderer::Inst().getRenderer(), texture, nullptr, nullptr); + + //cRenderer::Inst().Render(texture, nullptr, nullptr); + //cRenderer::Inst().ResetRenderTarget(); + + if (texture != nullptr) { + + //cGFX::Inst().StringDefault(m_text, pos, m_colour); + cGFX::Inst().StringDefault(m_text, pos, m_colour, texture); + setImage(texture); + } + } +} diff --git a/.svn/pristine/86/86a65bf842932100c67ee4168d87957f37405791.svn-base b/.svn/pristine/86/86a65bf842932100c67ee4168d87957f37405791.svn-base new file mode 100644 index 0000000..7a0d69a --- /dev/null +++ b/.svn/pristine/86/86a65bf842932100c67ee4168d87957f37405791.svn-base @@ -0,0 +1,39 @@ +#include "cPanel.hpp" + + +using GUIEngine::cPanel; + +/*static*/ const UtilityEngine::cString cPanel::sNAME = "panel"; + +cPanel::cPanel( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) +{ + Create( parent, id, orientation, align, layout, pos, size, padding, name ); +} + +/*virtual*/ cPanel::~cPanel() +{} + +///Functions +/*virtual*/ void cPanel::Create(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + cLayout::Create( parent, id, orientation, align, layout, pos, size, { 0,0,0,0 }, name ); +} + +/*virtual*/ void cPanel::Display() +{ + cLayout::Display(); +} + +/*virtual*/ const GUIHelpers::eType cPanel::getType() const +{ + return GUIHelpers::eType::CPANEL; +} + +/*virtual*/ const GUIHelpers::RGBA cPanel::getDebugColour() const +{ + return GUIHelpers::RED; +} \ No newline at end of file diff --git a/.svn/pristine/86/86e07f115620aaea997f3cd3a751182f52434bee.svn-base b/.svn/pristine/86/86e07f115620aaea997f3cd3a751182f52434bee.svn-base new file mode 100644 index 0000000..b548e0d --- /dev/null +++ b/.svn/pristine/86/86e07f115620aaea997f3cd3a751182f52434bee.svn-base @@ -0,0 +1,145 @@ +#include "cCourt.hpp" + +using Equipment::cCourt; +using Equipment::cBall; +using Equipment::cPaddle; + +using MathEngine::cCollision; +using MathEngine::Vector4; +using MathEngine::Vector2; + +cCourt::cCourt( cBall* ball /*= nullptr*/, cPaddle* player1 /*= nullptr*/, cPaddle* player2 /*= nullptr*/, VideoEngine::cImage** image /*= nullptr*/ ) +: cSprite( 0, 0, 0, 0, 640, 480, image), mp_ball(ball), m_pause(false) +{ + m_topWall.x = 0.0f; + m_topWall.y = 0.0f; + m_topWall.z = 640.0f; + m_topWall.w = 14.0f; + + m_bottomWall.x = 0.0f; + m_bottomWall.y = 464.0f; + m_bottomWall.z = 640.0f; + m_bottomWall.w = 14.0f; + + m_leftOff.x = 0.0f; + m_leftOff.y = 0.0f; + m_leftOff.z = 480.0f; + m_leftOff.w = 1.0f; + + m_rightOff.x = 640.0f; + m_rightOff.y = 0.0f; + m_rightOff.z = 480.0f; + m_rightOff.w = 1.0f; + + m_court.x = 0.0f; + m_court.y = 15.0f; + m_court.z = 640.0f; + m_court.w = 450.0f; + + mp_player[0] = player1; + mp_player[1] = player2; + + setImageArea(); +} + +cCourt::~cCourt() +{} + +///Functions +void cCourt::CheckCollision() +{ + if (m_pause == false) + { + CheckPaddles(); + CheckWalls(); + CheckOffCourt(); + } +} + +void cCourt::Quit() +{ +} + +const bool cCourt::isPause() const +{ + return m_pause; +} + +void cCourt::Pause() +{ + m_pause = !m_pause; + + mp_ball->Pause(); + mp_player[0]->Pause(); + mp_player[1]->Pause(); +} + +//private: +//Checks to see if the ball has hit a paddles and then if the paddles have hit a wall. +void cCourt::CheckPaddles() +{ + for (int count = 0; count <= 1; ++count) + { + //Check to see if the ball hit the Paddles. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), mp_ball->getPosition()) == true) + mp_ball->BounceX(); + + //Check to see if the Paddles hit the top wall. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), m_topWall) == true) + mp_player[count]->setPosY((long)m_topWall.w + 1); + + //Check to see if the Paddles hit the bottom wall. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), m_bottomWall) == true) + mp_player[count]->setPosY((long)m_bottomWall.y - 1); + } +} + +//Cheaks to see if the ball has hit the provide wall. +void cCourt::CheckWall(const Vector4& wall) +{ + if (cCollision::BoundingBox(mp_ball->getPosition(), wall) == true) + mp_ball->BounceY(); +} + +//Cheaks to see if the ball has hit the wall. +void cCourt::CheckWalls() +{ + CheckWall(m_topWall); + CheckWall(m_bottomWall); +} + +//Checks to see if the ball is off the provide side of the court. +const bool cCourt::CheckOffCourt(const Vector4& offside) +{ + bool rtn = false; + + if (cCollision::BoundingBox(mp_ball->getPosition(), offside) == true) + { + mp_ball->setSpeed(0,0); + rtn = true; + } + + return rtn; +} + +//Checks to see if the ball is off the court +void cCourt::CheckOffCourt() +{ + MathEngine::Vector2 mov = cCollision::Inside(m_court, mp_ball->getPosition()); + + if (mov.x != 0.0f) + { +// if (mov.x > 0.0f); +// //point to player 1 +// if (mov.x < 0.0f); +// //point to player 2 + } + + if (mov.y != 0.0f) + mp_ball->AddPosY((long)mov.y); + + //if (CheckOffCourt(m_leftOff) == true) + // ; + //if (CheckOffCourt(m_rightOff) == true) + // ; +} \ No newline at end of file diff --git a/.svn/pristine/88/88ce6dc17db14f39bc1a8aa791add21f32574203.svn-base b/.svn/pristine/88/88ce6dc17db14f39bc1a8aa791add21f32574203.svn-base new file mode 100644 index 0000000..458123e --- /dev/null +++ b/.svn/pristine/88/88ce6dc17db14f39bc1a8aa791add21f32574203.svn-base @@ -0,0 +1,392 @@ +#include "cString.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +#ifdef _MSC_VER +// disable _s warnings +# define _CRT_SECURE_NO_WARNINGS +// disable pragma warnings +# pragma warning( disable : 4068 ) +# pragma warning( disable : 4996 ) +# include "MSUNIX/msunix.hpp" +#endif + +using UtilityEngine::cString; + +cString::cString() +{ + clear(); +} + +cString::cString(const char* s) +{ + copy_str(s); +} + +cString::cString(const cString& copy) +{ + copy_str(copy); +} + + +cString::~cString() +{ + clear(); +} + +const char* cString::alloc_str(size_t sz) +{ + if (mp_str) + clear(); + m_len = (sz > __cString__MAX_LEN) ? __cString__MAX_LEN : sz; + mp_str = (char *)calloc(1, m_len + 1); + return mp_str; +} + +void cString::clear() +{ + if (mp_str) + free((void *)mp_str); + mp_str = nullptr; + m_len = 0; +} + +const char* cString::c_str() const +{ + return mp_str; +} + +const char* cString::copy_str(const char* copy) +{ + if (copy) { + size_t len = strnlen(copy, __cString__MAX_LEN); + alloc_str(len); + strncpy((char *)mp_str, copy, len); + m_len = len; + } + return mp_str; +} + +bool cString::have_value() const +{ + if (mp_str) + return true; + else + return false; +} + +size_t cString::length() const +{ + return m_len; +} + +size_t cString::size() const +{ + return m_len; +} + +// string format +cString& cString::format(const char* format, ...) +{ + char * buffer; + + va_list args; + va_start(args, format); + + vasprintf(&buffer, format, args); + copy_str(buffer); + free(buffer); + return *this; +} + +// trim leading and trailing spaces +cString& cString::trim() +{ + const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a"; + + if (!have_value()) + return *this; // make sure we have a string + + size_t begin = 0; + size_t end = length() - 1; + + for (begin = 0; begin <= end; ++begin) { + if (strchr(whitespace, mp_str[begin]) == nullptr) { + break; + } + } + + for (; end > begin; --end) { + if (strchr(whitespace, mp_str[end]) == nullptr) { + break; + } + else { + mp_str[end] = '\0'; + } + } + + if (begin) { + for (size_t i = 0; mp_str[i]; ++i) { + mp_str[i] = mp_str[begin++]; + } + } + + m_len = strlen(mp_str); + return *this; +} + +cString cString::lower() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)tolower(rs.mp_str[i]); + } + return rs; +} + +cString cString::upper() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)toupper(rs.mp_str[i]); + } + return rs; +} + +const char & cString::last_char() const +{ + return mp_str[length() - 1]; +} + +// non-destructive split +const std::vector cString::split(const char match) const +{ + const char match_s[2] = { match, 0 }; + return split(match_s, -1); +} + +const std::vector cString::split(const char* match) const +{ + return split(match, -1); +} + +const std::vector cString::split(const char* match, int max_split) const +{ + std::vector rtn; + if (length() < 1) + return rtn; + size_t match_len = strnlen(match, __cString__MAX_LEN); + if (match_len >= __cString__MAX_LEN) + return rtn; + + char * mi; // match index + char * pstr = mp_str; // string pointer + while ((mi = strstr(pstr, match)) && (max_split < 0 || --max_split)) { + if (mi != pstr) { + size_t lhsz = mi - pstr; + char * cslhs = (char *)malloc(lhsz + 1); + cslhs[lhsz] = '\0'; // strncpy doesn't terminate it + rtn.emplace_back(strncpy(cslhs, pstr, lhsz)); // calls BWString copy ctor + pstr += lhsz; + free(cslhs); + } + pstr += match_len; + } + + if (*pstr != '\0') { + rtn.emplace_back(pstr); + } + + return rtn; +} + +const cString& cString::char_repl(const char& match, const char& repl) +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) mp_str[i] = repl; + } + return *this; +} + +long int cString::char_find(const char& match) const +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) + return i; + } + return -1; +} + +cString cString::substr(size_t start, size_t length) const +{ + cString rs; + char * buf; + if ((length + 1) > __cString__MAX_LEN) + return rs; + if ((start + length) > __cString__MAX_LEN) + return rs; + if (length > m_len - start) + return rs; + if (!mp_str) + return rs; + + buf = (char *)calloc(sizeof(char), length + 1); + memcpy(buf, mp_str + start, length); + rs = buf; + return rs; +} + +long int cString::find(const cString& match) +{ + char * pos = strstr(mp_str, match.c_str()); + if (pos) + return (long)(pos - mp_str); + else + return -1; +} + +const cString cString::replace(const cString& match, const cString& repl) +{ + cString rs; + long f1 = find(match); + if (f1 >= 0) { + size_t pos1 = (size_t)f1; + size_t pos2 = pos1 + match.length(); + cString s1 = pos1 > 0 ? substr(0, pos1) : ""; + cString s2 = substr(pos2, length() - pos2); + rs = s1 + repl + s2; + } + return rs; +} + +const long int cString::ToInt() const +{ + return strtol(mp_str, NULL, 10); +} + +cString& cString::operator = (const char* rhs) +{ + copy_str(rhs); + return *this; +} + +cString& cString::operator = (const cString& rhs) +{ + copy_str(rhs.c_str()); + return *this; +} + +cString& cString::operator += (const char rhs) +{ + operator+=(&rhs); + return *this; +} + +cString& cString::operator += (const char* rhs) +{ + if (rhs) { + size_t newlen = m_len + strnlen(rhs, __cString__MAX_LEN); + if (newlen > __cString__MAX_LEN) + newlen = __cString__MAX_LEN; + char * buf = (char *)calloc(1, newlen + 1); + if (!buf) + return *this; + + if (mp_str && m_len) + strncpy(buf, mp_str, m_len); + strncpy(buf + m_len, rhs, newlen - m_len); + + buf[newlen] = '\0'; + copy_str(buf); + free(buf); + } + return *this; +} + +cString& cString::operator += (const cString& rhs) +{ + operator+=(rhs.c_str()); + return *this; +} + +bool cString::operator == (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator == (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator != (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator != (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator > (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) > 0) + return true; + else + return false; +} + +bool cString::operator < (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) < 0) + return true; + else + return false; +} + +bool cString::operator >= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) >= 0) + return true; + else + return false; +} + +bool cString::operator <= (const cString & rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) <= 0) + return true; + else return false; +} + +cString::operator const char* () const +{ + return c_str(); +} + +cString::operator std::string () const +{ + return std::string(c_str()); +} + +cString operator + (const cString& lhs, const cString& rhs) +{ + cString rs = lhs; + rs += rhs; + return rs; +} + diff --git a/.svn/pristine/8b/8b0c9cd5debe46379cd611df311707b2b3b4f98c.svn-base b/.svn/pristine/8b/8b0c9cd5debe46379cd611df311707b2b3b4f98c.svn-base new file mode 100644 index 0000000..4401105 --- /dev/null +++ b/.svn/pristine/8b/8b0c9cd5debe46379cd611df311707b2b3b4f98c.svn-base @@ -0,0 +1,40 @@ +#include "cMusic.hpp" + +using AudioEngine::cMusic; + +cMusic::cMusic() +{} + +/* Copy constructor */ +cMusic::cMusic(const cMusic& copy) +{ + copy; +} + +cMusic::~cMusic() +{} + +///Functions +/* Plays the music if loaded */ +void cMusic::PlayMusic() +{} + +/* Fades in the music for time */ +void cMusic::FadeIn(const unsigned int time /*= 1000*/) const +{ + time; +} + +/* Fades out the music for time */ +void cMusic::FideOut(const unsigned int time /*= 1000*/) const +{ + time; +} + +/* private:*/ +///Functions +void cMusic::LoadMusic() +{} + +void cMusic::UnloadMusic() +{} \ No newline at end of file diff --git a/.svn/pristine/8b/8b51d7e936879536169d5c07e7e1a0423ce6081f.svn-base b/.svn/pristine/8b/8b51d7e936879536169d5c07e7e1a0423ce6081f.svn-base new file mode 100644 index 0000000..84016ef --- /dev/null +++ b/.svn/pristine/8b/8b51d7e936879536169d5c07e7e1a0423ce6081f.svn-base @@ -0,0 +1,47 @@ +#ifndef _CMUSIC_HPP_ +#define _CMUSIC_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** Custom Header Files ***/ +//#include "cAudio.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +#include "cSound.hpp" + +namespace AudioEngine { + class EXPORT_FROM_MYDLL cMusic + { + public: + cMusic(); + /* Copy constructor */ + cMusic( const cMusic& copy ); + ~cMusic(); + + ///Functions + /* Plays the music if loaded */ + void PlayMusic(); + /* Fades in the music for time */ + void FadeIn( const unsigned int time = 1000 ) const; + /* Fades out the music for time */ + void FideOut( const unsigned int time = 1000 ) const; + + private: + ///Functions + void LoadMusic(); + void UnloadMusic(); + + private: + ///Variables + Mix_Music* mp_music; + + unsigned char m_volume;// = 255 + + + };/// END CLASS DEFINITION cMusic +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CMUSIC_HPP_ \ No newline at end of file diff --git a/.svn/pristine/8b/8b9431df35d6dcb4226344a0bf0b27307bf018f0.svn-base b/.svn/pristine/8b/8b9431df35d6dcb4226344a0bf0b27307bf018f0.svn-base new file mode 100644 index 0000000..2686327 --- /dev/null +++ b/.svn/pristine/8b/8b9431df35d6dcb4226344a0bf0b27307bf018f0.svn-base @@ -0,0 +1,132 @@ +#include "cUtility.hpp" + +/*** SDL Header Files ***/ +#include +#include +#include +#include +#include + +using UtilityEngine::cUtility; + +/*static*/ cUtility* cUtility::sp_inst = nullptr; + +//private: +cUtility::cUtility() +{} + +cUtility::~cUtility() +{} + +//public: +// cUtility& cUtility::operator=( const cUtility& copy ) +// { +// if (this != ©) +// { +// } +// +// return *this; +// } + +///Functions +/*static*/ cUtility& cUtility::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cUtility(); + return *sp_inst; +} + +/*static*/ void cUtility::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cUtility::Message( const cString& msg, const cString& debugInfo /*= ""*/, const eTypeSDL typeSDL /*= eTypeSDL::None*/ ) const +{ + cString sdlerror; + switch (typeSDL) + { + case NONE: + break; + case SDL: + sdlerror = SDL_GetError(); + break; + case TTF: + sdlerror = TTF_GetError(); + break; + case IMAGE: + sdlerror = IMG_GetError(); + break; + case MIXER: + sdlerror = Mix_GetError(); + break; + case NET: + sdlerror = SDLNet_GetError(); + break; + case GFX: + sdlerror = SDL_GetError(); + break; + default: + break; + } + SDL_ClearError(); + if (debugInfo.size() > 0) + fprintf(stderr, "Error in %s %s %s \n", debugInfo.substr((1 + debugInfo.char_find('\\')), debugInfo.length()).c_str(), msg.c_str(), sdlerror.c_str()); + else + fprintf(stderr, "%s\n", msg.c_str()); +} + +void cUtility::PrintVersion( const eTypeSDL typeSDL /*= eTypeSDL::ALL*/ ) const +{ + SDL_version compiled_version; + SDL_version running_version; + + cString type = ""; + + switch (typeSDL) + { + case ALL: + for ( int num = SDL; num <= NET; num++) + PrintVersion((eTypeSDL)num); + break; + case SDL: + SDL_VERSION(&compiled_version); + SDL_GetVersion(&running_version); + type = "SDL"; + break; + case TTF: + SDL_TTF_VERSION(&compiled_version); + running_version = *TTF_Linked_Version(); + type = "SDL_TTF"; + break; + case IMAGE: + SDL_IMAGE_VERSION(&compiled_version); + running_version = *IMG_Linked_Version(); + type = "SDL_IMAGE"; + break; + case MIXER: + SDL_MIXER_VERSION(&compiled_version); + running_version = *Mix_Linked_Version(); + type = "SDL_MIXER"; + break; + case NET: + SDL_NET_VERSION(&compiled_version); + running_version = *SDLNet_Linked_Version(); + type = "SDL_NET"; + break; + default: + break; + } + if (typeSDL != ALL) { + VersionParser("Compiled", compiled_version, type); + VersionParser("Running", running_version, type); + } +} + +///Private: +///Functions +void cUtility::VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const +{ + fprintf(stderr, "%s with %s version: %u.%u.%u \n", runCompiled.c_str(), type.c_str(), version.major, version.minor, version.patch); +} \ No newline at end of file diff --git a/.svn/pristine/8d/8d50b480b2e02ab0fa7415acb3ac0251e0d25de0.svn-base b/.svn/pristine/8d/8d50b480b2e02ab0fa7415acb3ac0251e0d25de0.svn-base new file mode 100644 index 0000000..b5c035a --- /dev/null +++ b/.svn/pristine/8d/8d50b480b2e02ab0fa7415acb3ac0251e0d25de0.svn-base @@ -0,0 +1,67 @@ +#ifndef _CUTILITY_HPP_ +#define _CUTILITY_HPP_ + +/*** ANSI C Header Files ***/ +#include //for __FUNCTION__ + +#ifndef __FUNCTION__ +# define __FUNCTION__ __func__ +#endif + +#define __STRINGIFY__(x) #x +#define __TOSTRING__(x) __STRINGIFY__(x) +#define __AT__ __FILE__ ":" __TOSTRING__(__LINE__) ":(" __FUNCTION__ ")" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "cString.hpp" + +using UtilityEngine::cString; + + + +namespace UtilityEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cUtility + { + public: + enum eTypeSDL : unsigned int + { + NONE = 0, + ALL = 0, + SDL, + TTF, + IMAGE, + MIXER, + GFX, + NET, + }; + + private: + cUtility(); + ~cUtility(); + + public: + ///Functions + static cUtility& Inst(); + static void Delete(); + + void Message( const cString& msg, const cString& funcName = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const; + + void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const; + + + private: + ///Functions + void VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const; + + + private: + ///Variables + static cUtility* sp_inst;// = nullptr + + };/// END CLASS DEFINITION cUtility +}/// END NAMESPACE DEFINITION UtilityEngine +#endif/// END IFNDEF _CUTILITY_HPP_ \ No newline at end of file diff --git a/.svn/pristine/8e/8e8aa78a343d3771478ff8db7c155eadcd3afe36.svn-base b/.svn/pristine/8e/8e8aa78a343d3771478ff8db7c155eadcd3afe36.svn-base new file mode 100644 index 0000000..82927f9 --- /dev/null +++ b/.svn/pristine/8e/8e8aa78a343d3771478ff8db7c155eadcd3afe36.svn-base @@ -0,0 +1,71 @@ +#ifndef _CINPUT_HPP_ +#define _CINPUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cInput + { + private: + cInput(); + ~cInput(); + + public: + static cInput& Inst(); + static void Delete(); + + //Functions + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + /* Checks all inputs */ + void CheckInputs( const SDL_Event& event ); + /* Checks all keyboards */ + void CheckKeyboards(); + /* Checks all Joysticks */ + void CheckJoysticks(); + + /* Adds a keyboard to cInput interneal list to be called when CheckInputs is called */ + void AddKeyboard( InputEngine::cKeyboard* keyboard ); + /* Deletes a keyboard in cInput internal list */ + void DeletesKeyboard( const cString& label ); + /* Deletes all keyboards in cInput internal list */ + void DeleteAllKeyboards(); + /* Removes the keyboard from cInput internal list */ + void RemoveKeyboard( const cString& label ); + /* Removes all keyboards from cInput internal list. */ + void RemoveAllKeyboards(); + + void DeleteAllInputs(); + void RemoveAllInputs(); + + ///Sets + + ///Gets + /* Gets return true if Input was initialized */ + const bool IsInit() const; + + private: + std::vector m_keyboards; + + SDL_Event m_event; + + static cInput* sp_inst;// = nullptr + };/// END CLASS DEFINITION cInput +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CINPUT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/90/9090a6d5fe657d65ff4e083119e398366690d49e.svn-base b/.svn/pristine/90/9090a6d5fe657d65ff4e083119e398366690d49e.svn-base new file mode 100644 index 0000000..15ca5e2 --- /dev/null +++ b/.svn/pristine/90/9090a6d5fe657d65ff4e083119e398366690d49e.svn-base @@ -0,0 +1,37 @@ +#ifndef _GUIUTILITY_HPP_ +#define _GUIUTILITY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../MathEngine/iVector/iVector2.hpp" +#include "../../MathEngine/iVector/iVector4.hpp" + +namespace GUIHelpers { + typedef struct MathEngine::iVector2 Size, Position; + typedef struct MathEngine::iVector4 Padding; + typedef struct SDL_Colour RGBA; + typedef struct SDL_Rect Area; + + static const RGBA WHITE = { 255, 255, 255, 255 }; + + static const RGBA RED = { 255, 0, 0, 255 }; + + static const RGBA ORANGE = { 255, 128, 0, 255 }; + static const RGBA YELLOW = { 255, 255, 0, 255 }; + + static const RGBA GREEN = { 0, 255, 0, 255 }; + + static const RGBA CYAN = { 0, 255, 255, 255 }; + + static const RGBA BLUE = { 0, 0, 255, 255 }; + + static const RGBA VIOLET = { 128, 0, 255, 255 }; + static const RGBA MAGENTA = { 255, 0, 255, 255 }; + static const RGBA ROSE = { 255, 0, 128, 255 }; + + +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _GUIUTILITY_HPP_ + diff --git a/.svn/pristine/91/911e07d28798cce3836f2a2bf8167ad9526dbcac.svn-base b/.svn/pristine/91/911e07d28798cce3836f2a2bf8167ad9526dbcac.svn-base new file mode 100644 index 0000000..eceda4a --- /dev/null +++ b/.svn/pristine/91/911e07d28798cce3836f2a2bf8167ad9526dbcac.svn-base @@ -0,0 +1,50 @@ +#include "StringTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using UtilityEngine::cString; + +void StringTest() +{ + // cString + printf("\nTesting cString -----\n\n"); + + UTest u("cString"); + + const char * _ctest = " \tfoo \r\n"; + cString ttest = _ctest; + u.test("cstring ctor", ttest.length() == 12); + ttest.trim(); + u.test("trim", ttest.length() == 3); + + cString x = "foo"; + cString y = "bar"; + cString z = x + "baz" + y; + + u.test("concat", z.length() == 9 && memcmp(z.c_str(), "foobazbar", 10) == 0); + + x = y = "foo"; + u.test("foo == foo", (x == y)); + u.test("foo > foo", !(x > y)); + u.test("foo >= foo", (x >= y)); + u.test("foo < foo", !(x < y)); + u.test("foo <= foo", (x <= y)); + + x = "bar"; + u.test("bar == foo", !(x == y)); + u.test("bar > foo", !(x > y)); + u.test("bar >= foo", !(x >= y)); + u.test("bar < foo", (x < y)); + u.test("bar <= foo", (x <= y)); + + u.test("foo == bar", !(y == x)); + u.test("foo > bar", (y > x)); + u.test("foo >= bar", (y >= x)); + u.test("foo < bar", !(y < x)); + u.test("foo <= bar", !(y <= x)); + + u.report(); +} \ No newline at end of file diff --git a/.svn/pristine/92/9298c9ff8b117fdf16d6fd77872c51f68e728eb2.svn-base b/.svn/pristine/92/9298c9ff8b117fdf16d6fd77872c51f68e728eb2.svn-base new file mode 100644 index 0000000..07b6e37 --- /dev/null +++ b/.svn/pristine/92/9298c9ff8b117fdf16d6fd77872c51f68e728eb2.svn-base @@ -0,0 +1,158 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {D0670630-6CBB-4894-BAC6-35FD775E8D8E} + SDLPongCPP + SDLPongCPP + + + + Application + MultiByte + true + v140 + + + Application + MultiByte + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + $(TINYXML);$(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2)\VisualC\Win32\Release;$(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + + + Full + false + ../LinkListDLLProject/dllExportFiles;../TrooperEngineDLLProject/dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + false + Level3 + true + ProgramDatabase + true + + + odbc32.lib;odbccp32.lib;sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;TrooperEngine.lib;LinkList.lib;%(AdditionalDependencies) + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + Windows + true + true + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b6513faa-8bde-45aa-9f1e-326bcbe5d2e8} + false + + + + + + \ No newline at end of file diff --git a/.svn/pristine/95/958c2cf18dd27a33a972c5778f5f8a654908cd53.svn-base b/.svn/pristine/95/958c2cf18dd27a33a972c5778f5f8a654908cd53.svn-base new file mode 100644 index 0000000..ae8ea6b --- /dev/null +++ b/.svn/pristine/95/958c2cf18dd27a33a972c5778f5f8a654908cd53.svn-base @@ -0,0 +1,190 @@ +#include "cGUI.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" + +#include "../UtilityEngine/cUtility.hpp" +#include "GUIHelpers/Enums.hpp" +#include "cButton.hpp" + +using GUIEngine::cGUI; +using GUIEngine::cWindow; +using UtilityEngine::cUtility; + +/*static*/ cGUI* cGUI::sp_inst = nullptr; + +//private +cGUI::cGUI() + : mp_font(nullptr), m_inited(false) +{ + setTextColour(); + setPadding(); +} + +cGUI::~cGUI() +{ + delete mp_font; + mp_font = nullptr; + + m_guiObjects.clear(); +} + +//public: +///Functions +/*static*/ cGUI& cGUI::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGUI(); + return *sp_inst; +} + +/*static*/ void cGUI::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cGUI::Initialize( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +{ + bool rtn = IsInit(); + + if (rtn == false) { + setFont( filename, dir, size ); + cUtility::Inst().Message("GUI initialized."); + } + + return rtn; +} + +void cGUI::Event(const MathEngine::iVector2& location, const eGUIEventType& type) +{ + location; + type; +// std::vector::iterator it; +// +// for (it = m_objects.begin(); it < m_objects.end(); it++) { +// switch ((*it)->getType()) { +// case GUIHelpers::eType::CBUTTON: +// cButton* tmp = (cButton*)(*it); +// if (tmp->InSide(location) == true) +// cUtility::Inst().Message("Button Inside!"); +// break; +// } +// } +} + +const MathEngine::iVector2 cGUI::DisplayArea() const +{ + MathEngine::iVector2 rtn = { 0, 0 }; + rtn.x = VideoEngine::cVideo::Inst().getWidth(); + rtn.y = VideoEngine::cVideo::Inst().getHeight(); + + return rtn; +} + +void cGUI::AddObject(cWindow* obj) +{ + //this->m_obj = obj; + m_guiObjects.push_back(obj); +} + +void cGUI::Display() +{ + //m_obj->Display(); + std::vector::iterator it; + + for (it = m_guiObjects.begin(); it < m_guiObjects.end(); it++) { + (*it)->Display(); + } +} + +///Sets +void cGUI::setFont( TextTypeEngine::cFont* font ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = font; +} + +void cGUI::setFont( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont( dir, filename, size ); +} + +void cGUI::setTextColour( const GUIHelpers::RBGA& colour ) +{ + cWindow::sCOLOUR = colour; +} + +void cGUI::setTextColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/ ) +{ + GUIHelpers::RBGA colour = {Uint8(red), Uint8(green), Uint8(blue)}; + setTextColour(colour); +} + +void cGUI::setPadding( const GUIHelpers::Padding& padding ) +{ + cWindow::sPADDING = padding; +} + +void cGUI::setPadding( const unsigned int top /*= 5*/, const unsigned int right /*= 5*/, const unsigned int bottom /*= 5*/, const unsigned int left /*= 5*/ ) +{ + setPadding(GUIHelpers::Padding(top, right, bottom, left)); +} + +void cGUI::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/ ) +{ + cWindow::sALIGN = align; +} + +///Gets +TextTypeEngine::cFont* cGUI::getFont() +{ + return mp_font; +} + +const GUIHelpers::RBGA& cGUI::getTextColour() const +{ + return cWindow::sCOLOUR; +} + +void cGUI::getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const +{ + red = cWindow::sCOLOUR.r; + green = cWindow::sCOLOUR.g; + blue = cWindow::sCOLOUR.b; +} + +const GUIHelpers::Padding& cGUI::getPadding() const +{ + return cWindow::sPADDING; +} + +void cGUI::getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const +{ + top = cWindow::sPADDING.x; + right = cWindow::sPADDING.y; + bottom = cWindow::sPADDING.z; + left = cWindow::sPADDING.w; +} + +const GUIHelpers::eAlign& cGUI::getAlign() const +{ + return cWindow::sALIGN; +} + +const bool cGUI::IsInit() const +{ + bool rtn = m_inited; + + if (rtn == true) + cUtility::Inst().Message("GUI is initialized."); + else + cUtility::Inst().Message("GUI is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/97/97f68e84c6314d717c25ce554ed4c5d92c208c5b.svn-base b/.svn/pristine/97/97f68e84c6314d717c25ce554ed4c5d92c208c5b.svn-base new file mode 100644 index 0000000..5874fc2 --- /dev/null +++ b/.svn/pristine/97/97f68e84c6314d717c25ce554ed4c5d92c208c5b.svn-base @@ -0,0 +1,354 @@ + + + + + {785f0a83-5f26-4f52-8607-42d79ef7e4a0} + + + {ce87c954-26c7-497c-a5c1-ca307fa85446} + + + {9447735f-408f-4a4c-896b-3cb056516952} + + + {78ca6e8e-15cd-4c35-a4c7-f718c6f2e517} + + + {a48949b4-948d-4bdb-a48d-a2bb08c05f43} + + + {fb99b84e-7997-4ebd-b3ea-dd0240ce62f6} + + + {98b7ca98-2ed4-4a41-84f2-abcb3fb384aa} + + + {aef9e043-2065-4d89-acae-33d6f5f55958} + + + {59e0e88b-7be3-4b1d-b3ac-6477daa761c8} + + + {4aa00373-6815-4cd3-a1c7-470f34bfa3d9} + + + {74c65105-2ee7-4bb9-8d44-ca75c80e8b9e} + + + {5a07ee53-1695-400c-86b3-c493e8e34417} + + + {839730ba-b9b8-40bc-a0e0-bcb2b16b83f7} + + + {2b72b3ea-71a4-4c02-988e-603172b3eda3} + + + {4a09c4e8-7d59-490d-8049-7a52f0aed3c8} + + + {6d0af3ff-4b2b-4b9c-85a2-c7db41550092} + + + {db4ff7f3-2b38-4f9d-9a92-aed4cb51f0ac} + + + {f6fc613b-8e1a-4df1-aee7-f37382d38981} + + + + + dllExportFiles + + + dllExportFiles + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + dllExportFiles + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + \ No newline at end of file diff --git a/.svn/pristine/98/982b42a96430224c2a1d79f2f03dd363adac09b9.svn-base b/.svn/pristine/98/982b42a96430224c2a1d79f2f03dd363adac09b9.svn-base new file mode 100644 index 0000000..2c549d9 --- /dev/null +++ b/.svn/pristine/98/982b42a96430224c2a1d79f2f03dd363adac09b9.svn-base @@ -0,0 +1,46 @@ +#include "Vector4.hpp" + +#include "../iVector/iVector4.hpp" + +using MathEngine::Vector4; +using MathEngine::iVector4; + +Vector4::Vector4( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/, const float W /*= 0.0f*/) + : Vector3( X, Y, Z ), w(W) +{} + +Vector4::Vector4( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + w = float(copy.h); +} + +Vector4& Vector4::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + w = float(copy.h); + + return *this; +} + +Vector4::Vector4( const iVector4& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + w = float(copy.w); +} + +Vector4& Vector4::operator=( const iVector4& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + w = float(copy.w); + + return *this; +} \ No newline at end of file diff --git a/.svn/pristine/9a/9ab27441ba0058f5ed0acb6f6af83786416fc4cb.svn-base b/.svn/pristine/9a/9ab27441ba0058f5ed0acb6f6af83786416fc4cb.svn-base new file mode 100644 index 0000000..e0f3e85 --- /dev/null +++ b/.svn/pristine/9a/9ab27441ba0058f5ed0acb6f6af83786416fc4cb.svn-base @@ -0,0 +1,52 @@ +#ifndef _CLAYOUT_HPP_ +#define _CLAYOUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/GUIUtility.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLayout : public cWindow + { + public: + static const cString sNAME; /*= "layout";*/ + static const GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::VERTICAL;*/ + + cLayout( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cLayout(); + + ///Functions + virtual void Create( cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + ///Set + + ///Get + + virtual const GUIHelpers::eType getType() const; + + virtual const GUIHelpers::RGBA getDebugColour() const; + + private: + GUIHelpers::eOrientation m_orientation; + };/// END CLASS DEFINITION cLayout +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLAYOUT_HPP_ diff --git a/.svn/pristine/9b/9b89fc83abda560168b01d4320e7f3eaa221fc67.svn-base b/.svn/pristine/9b/9b89fc83abda560168b01d4320e7f3eaa221fc67.svn-base new file mode 100644 index 0000000..4073274 --- /dev/null +++ b/.svn/pristine/9b/9b89fc83abda560168b01d4320e7f3eaa221fc67.svn-base @@ -0,0 +1,63 @@ +#ifndef _CLABEL_HPP_ +#define _CLABEL_HPP_ +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../VideoEngine/cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLabel : public cWindow + { + public: + static const cString sNAME; /*= "label";*/ + static const GUIHelpers::eLayout sLAYOUT;/* = GUIHelpers::eLayout::WRAP_CONTENT;*/ + + cLabel(cWindow* parent, const signed int id, const cString& label = "", 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); + virtual ~cLabel(); + + ///Functions + void Create(cWindow* parent, const signed int id, const cString& label = "", 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); + + virtual void Display(); + + void GenerateTexture(); + + //Sets + void setFontColour( const GUIHelpers::RGBA& colour ); + void setFontSize( const unsigned long int size ); + void setText( const cString& text ); + void setFont( const TextTypeEngine::cFont* font ); + + ///Gets + const GUIHelpers::RGBA& getFontColour() const; + const unsigned long int getFontSize() const; + const TextTypeEngine::cFont* getFont() const; + const cString& getText() const; + virtual const GUIHelpers::eType getType() const; + virtual const GUIHelpers::RGBA getDebugColour() const; + + + //virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + private: + + + + private: + VideoEngine::cSprite m_sprite; + TextTypeEngine::cText* mp_text;// = nullptr + };/// END CLASS DEFINITION cLabel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLABEL_HPP_ diff --git a/.svn/pristine/9d/9d2bdc30786c25f136adef31df27c541528baa74.svn-base b/.svn/pristine/9d/9d2bdc30786c25f136adef31df27c541528baa74.svn-base new file mode 100644 index 0000000..335b701 --- /dev/null +++ b/.svn/pristine/9d/9d2bdc30786c25f136adef31df27c541528baa74.svn-base @@ -0,0 +1,27 @@ +#ifndef _CJOYSTICK_HPP_ +#define _CJOYSTICK_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cInput.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cJoystick + { + public: + cJoystick(); + ~cJoystick(); + + ///Functions + + //Used when looking for keys that have been add to the check list + void JoystickCheck(); + + };/// END CLASS DEFINITION cJoystick +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CJOYSTICK_HPP_ diff --git a/.svn/pristine/a0/a015d7a6b7690d911d920034e3ae43f271f77214.svn-base b/.svn/pristine/a0/a015d7a6b7690d911d920034e3ae43f271f77214.svn-base new file mode 100644 index 0000000..7693fc9 --- /dev/null +++ b/.svn/pristine/a0/a015d7a6b7690d911d920034e3ae43f271f77214.svn-base @@ -0,0 +1,75 @@ +#ifndef _CFONT_HPP_ +#define _CFONT_HPP_ + +/*** ANSI C++ Header Files ***/ +#include + +/*** SDL Header Files ***/ +#include +#include + +/*** TextTypeHelpers ***/ +#include "TextTypeHelpers/cFontHolder.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector >; +/*#pragma warning (default : 4231)*/ + +namespace TextTypeEngine { + class EXPORT_FROM_MYDLL cFont + { + public: + cFont(const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 ); + cFont( const cFont& copy ); + ~cFont(); + + ///Functions + + + ///Sets + /* Sets the Directory of the TTF file */ + void setDir( const cString& dir ); + /* Sets the Filename of the TTF file */ + void setFileName( const cString& filename ); + /* Sets the Filename and Directory of the TTF file */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + /* Sets the size of the TTF. Default is 16 */ + void setSize( const unsigned long int size = 16 ); + + ///Gets + /* Gets the Directory of the TTF file */ + const cString& getDir() const; + /* Gets the Filename of the TTF file */ + const cString& getFileName() const; + /* Gets the size of the TTF file. */ + const unsigned long int getSize() const; + /* Gets the TTF_Font. */ + TTF_Font* getFont(); + /* Gets the TTF_Font. */ + TTF_Font* getFont( const unsigned long int size ); + + private: + TTF_Font* LoadFont( const unsigned long int size ); + TextTypeHelpers::cFontHolder* getFontHolder( const unsigned long int size ); + void UnloadFont(); + + private: + std::vector m_fonts; + //cFontHolder m_fonts; + //cFont::cFontHolder m_fonts; + TextTypeHelpers::cFontHolder** mpp_default; + cString m_dir;// = "" + cString m_fileName;// = "" + + };/// END CLASS DEFINITION cFont +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CFONT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/a1/a10f1b92e1dbc9aaf635557a418d786fb06eb2b0.svn-base b/.svn/pristine/a1/a10f1b92e1dbc9aaf635557a418d786fb06eb2b0.svn-base new file mode 100644 index 0000000..682b053 --- /dev/null +++ b/.svn/pristine/a1/a10f1b92e1dbc9aaf635557a418d786fb06eb2b0.svn-base @@ -0,0 +1,28 @@ +#ifndef _CFONTHOLDER_HPP_ +#define _CFONTHOLDER_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace TextTypeHelpers { + class EXPORT_FROM_MYDLL cFontHolder + { + public: + cFontHolder( TTF_Font* font, const unsigned long int size ); + ~cFontHolder(); + ///Sets + + ///Gets + TTF_Font* getFont() const; + const unsigned long int getSize() const; + + private: + TTF_Font* mp_font;// = nullptr + unsigned long int m_size;// = 16 + };/// END CLASS DEFINITION cFontHolder +}/// END NAMESPACE DEFINITION TextTypeHelpers +#endif/// END IFNDEF _CFONTHOLDER_HPP_ \ No newline at end of file diff --git a/.svn/pristine/a2/a215af417d504f9787e5f009d85dfd27d265f233.svn-base b/.svn/pristine/a2/a215af417d504f9787e5f009d85dfd27d265f233.svn-base new file mode 100644 index 0000000..e0a6bd4 --- /dev/null +++ b/.svn/pristine/a2/a215af417d504f9787e5f009d85dfd27d265f233.svn-base @@ -0,0 +1,30 @@ +#ifndef __UTEST__ +#define __UTEST__ + +#include + +#define __UTest_VERSION "1.0.0" + +class UTest { +private: + UTest( UTest & ); // no copy constructor + UTest operator = ( UTest & ); // no assignment operator + UTest(){} // no default constructor +public: + static const char * version() { return __UTest_VERSION; } + + UTest( const char * ); + void init ( const char * ); + void test ( const char * description, const int flag ); + void report() const; +private: + unsigned long int m_pass = 0; + unsigned long int m_fail = 0; + + const char * mp_tstr = nullptr; + + const static char * sp_pstr; /*= "pass";*/ + const static char * sp_fstr; /*= "fail";*/ +}; + +#endif // __UTEST__ diff --git a/.svn/pristine/a3/a30a2fc862c93305d37d82f840d7d5424ae2e1d7.svn-base b/.svn/pristine/a3/a30a2fc862c93305d37d82f840d7d5424ae2e1d7.svn-base new file mode 100644 index 0000000..ef5dded --- /dev/null +++ b/.svn/pristine/a3/a30a2fc862c93305d37d82f840d7d5424ae2e1d7.svn-base @@ -0,0 +1,68 @@ +#ifndef _CTIMING_HPP_ +#define _CTIMING_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include + +#define MAXIMUM_FRAME_RATE 120 +#define MINIMUM_FRAME_RATE 15 +#define UPDATE_INTERVAL (1.0 / MAXIMUM_FRAME_RATE) +#define MAX_CYCLES_PER_FRAME (MAXIMUM_FRAME_RATE / MINIMUM_FRAME_RATE) + +namespace TimingEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTiming + { + private: + cTiming( const unsigned long int ftp = 30 ); + ~cTiming(); + + public: + cTiming& operator=( const cTiming& copy ); + + ///Functions + static cTiming& Inst(); + static void Delete(); + + const bool Initialize() const; + /* Sets up timing */ + void Setup(); + void CleanUp(); + /* Sleeps if need */ + void Time(); + + ///Sets + void setFTP( const unsigned long int ftp = 30 ); + ///Gets + const unsigned long int getFTP() const; + /* Gets return true if Timer was initialized */ + const bool IsInit() const; + + const float getFrameTime() const; + + + private: + const unsigned long int TimeLeft(); + void AddTimeandRate(); + + const float FrameTime(); + + private: + ///Variables + unsigned long int m_nextTime;// = 0 + + unsigned long int m_rate;// = (1000 / m_ftp) + + unsigned long int m_ftp;// = 30 + + static cTiming* sp_inst;// = nullptr + + unsigned long int m_start;// = 0 + float m_lastTime;// = 0.0 + float m_frameTime;// = 0.0 + };/// END CLASS DEFINITION cTiming +}/// END NAMESPACE DEFINITION TimingEngine +#endif/// END IFNDEF _CTIMING_HPP_ diff --git a/.svn/pristine/a3/a3fe2c25a9bb6570bf906dd249d852d45cb4e5ba.svn-base b/.svn/pristine/a3/a3fe2c25a9bb6570bf906dd249d852d45cb4e5ba.svn-base new file mode 100644 index 0000000..10c1ae7 --- /dev/null +++ b/.svn/pristine/a3/a3fe2c25a9bb6570bf906dd249d852d45cb4e5ba.svn-base @@ -0,0 +1,39 @@ +#include "Vector2.hpp" + +/*** Custom Header File ***/ +#include "../iVector/iVector2.hpp" + +using MathEngine::Vector2; +using MathEngine::iVector2; + +Vector2::Vector2( const float X /*= 0.0f*/, const float Y /*= 0.0f*/ ) + : x(X), y(Y) +{}; + +Vector2::Vector2( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); +} + +Vector2& Vector2::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + + return *this; +} + +Vector2::Vector2( const iVector2& copy ) +{ + x = float(copy.x); + y = float(copy.y); +} + +Vector2& Vector2::operator=( const iVector2& copy ) +{ + x = float(copy.x); + y = float(copy.y); + + return *this; +} \ No newline at end of file diff --git a/.svn/pristine/a5/a527221820f785e80663f427b1781b3f2216f1cf.svn-base b/.svn/pristine/a5/a527221820f785e80663f427b1781b3f2216f1cf.svn-base new file mode 100644 index 0000000..f88e47f --- /dev/null +++ b/.svn/pristine/a5/a527221820f785e80663f427b1781b3f2216f1cf.svn-base @@ -0,0 +1,257 @@ +#include "cImage.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cImage; +using UtilityEngine::cUtility; + +cImage::cImage( const cString& dir /*= ""*/, const cString& filename /*= ""*/, const bool transparent /*= false*/, + const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/, + const unsigned char translevel /*= 255*/) +: mp_texture(nullptr), m_dir(dir), m_fileName(filename), m_transparent(transparent), +m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel) +{ + if (m_fileName != (char*)"") + LoadImage(); + if (mp_texture != nullptr) + TransparentSetup(); +} + +cImage::cImage( SDL_Surface* surface ) +: mp_texture(nullptr), m_dir(""), m_fileName(""), m_transparent(false), +m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255) +{ + setImage(surface); +} + +cImage::cImage( SDL_Texture* texture ) + : mp_texture(nullptr), m_dir(""), m_fileName(""), m_transparent(false), + m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255) +{ + setImage(texture); +} + +cImage::cImage( const cImage& copy, const bool surfaceCopy /*= true*/) +: mp_texture(nullptr), m_dir(copy.getDir()), +m_fileName(copy.getFileName()), m_transparent(copy.getTransparent()), m_transRed(copy.getRedTrans()), +m_transBlue(copy.getBlueTrans()), m_transGreen(copy.getGreenTrans()), m_transLevel(copy.getLevelTrans()) +{ + if (surfaceCopy == true) + mp_texture = copy.getImage(); +} + +cImage::~cImage() +{ + UnloadImage(); +} + +///Functions +void cImage::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + cRenderer::Inst().SaveTexture( mp_texture, fileName, dir ); +} + +const cImage* cImage::NewImage( SDL_Rect& area ) const +{ + cImage* rtn = new cImage(*this, false); + + SDL_Texture* tempTexture = cRenderer::Inst().NewTexture(area.w, area.h, SDL_TEXTUREACCESS_TARGET); + + if (tempTexture != nullptr) { + cRenderer::Inst().RenderToTexture(tempTexture, nullptr, mp_texture, &area); + rtn->setImage(tempTexture); + } else + cUtility::Inst().Message("No texture created.", __AT__); + + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Instance().getVideoSettings(), area.w, area.h, cVideo::Instance().getColour(), + mp_texture->format->Rmask, mp_texture->format->Gmask, mp_texture->format->Bmask, mp_texture->format->Amask); + cVideo::Instance().Render(tempsurface, nullptr, mp_texture, &area); + rtn->setImage(tempsurface);*/ + + return rtn; +} + +///Sets +void cImage::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cImage::setFileName( const cString& filename ) +{ + m_fileName = filename; + LoadImage(); +} + +void cImage::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cImage::setTransparent( const bool transparent /*= true*/ ) +{ + m_transparent = transparent; + TransparentSetup(); +} + +void cImage::setColourTrans( const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/ ) +{ + m_transRed = red; + m_transBlue = blue; + m_transGreen = green; + TransparentSetup(); +} + +void cImage::setLevelTrans( const unsigned char translevel /*= 255*/ ) +{ + m_transLevel = translevel; +} + +///Gets +SDL_Surface* cImage::getSurface() const +{ + return cRenderer::Inst().TextureToSurface(mp_texture); +} + +SDL_Texture* cImage::getImage() const +{ + return mp_texture; +} + +const unsigned long int cImage::getWidth() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + return w; +} + +const unsigned long int cImage::getHeight() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + return h; +} + +const SDL_Rect cImage::getWH() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + SDL_Rect rtn = { 0, 0, (int)w, (int)h}; + return rtn; +} + +void cImage::getWH( unsigned long int& w, unsigned long int& h ) const +{ + int width = 0; + int height = 0; + if (mp_texture != nullptr) + if (SDL_QueryTexture(mp_texture, nullptr, nullptr, &width, &height) < 0) + cUtility::Inst().Message("Unable to get Width or Height. SDL_QueryTexture:", __AT__, cUtility::eTypeSDL::SDL); + w = width; + h = height; +} + +const cString cImage::getDir() const +{ + return m_dir; +} + +const cString cImage::getFileName() const +{ + return m_fileName; +} + +const bool cImage::getTransparent() const +{ + return m_transparent; +} + +void cImage::getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const +{ + red = m_transRed; + blue = m_transBlue; + green = m_transGreen; +} + +const unsigned char cImage::getRedTrans() const +{ + return m_transRed; +} + +const unsigned char cImage::getBlueTrans() const +{ + return m_transBlue; +} + +const unsigned char cImage::getGreenTrans() const +{ + return m_transGreen; +} + +const unsigned char cImage::getLevelTrans() const +{ + return m_transLevel; +} + +//protected: +void cImage::setImage( SDL_Surface* surface ) +{ + UnloadImage(); + + mp_texture = cRenderer::Inst().SurfaceToTexture(surface); + + SDL_FreeSurface(surface); +} + +void cImage::setImage( SDL_Texture* texture ) +{ + UnloadImage(); + mp_texture = texture; +} + +///private +///Functions +void cImage::TransparentSetup() +{ + if( (m_transparent == true) && (mp_texture != nullptr) ) { + if ((SDL_SetTextureColorMod(mp_texture, m_transRed, m_transGreen, m_transBlue) | SDL_SetTextureAlphaMod(mp_texture, m_transLevel)) < 0) + cUtility::Inst().Message("Unable to set Transparent. SDL_SetTextureColorMod:", __AT__, cUtility::eTypeSDL::SDL); + } + //LoadImage(); +} + +void cImage::LoadImage() +{ + UnloadImage(); + + SDL_Texture* tempText = nullptr; + + if (m_fileName != "") + { + cString temp = m_dir + m_fileName; + + if ((tempText = IMG_LoadTexture( cRenderer::Inst().getRenderer(), temp.c_str() )) == nullptr) + cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_LoadTexture():", __AT__, cUtility::eTypeSDL::IMAGE); + } +} + +void cImage::UnloadImage() +{ + if (mp_texture != nullptr) + { + SDL_DestroyTexture(mp_texture); + mp_texture = nullptr; + } +} + + diff --git a/.svn/pristine/a6/a694ced213594b764c37dd158081b5dd6f275640.svn-base b/.svn/pristine/a6/a694ced213594b764c37dd158081b5dd6f275640.svn-base new file mode 100644 index 0000000..f4b2908 --- /dev/null +++ b/.svn/pristine/a6/a694ced213594b764c37dd158081b5dd6f275640.svn-base @@ -0,0 +1,55 @@ +#ifndef _CCOURT_HPP_ +#define _CCOURT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "cBall.hpp" +#include "cPaddle.hpp" + +namespace Equipment { + class cCourt : public VideoEngine::cSprite + { + public: + cCourt( cBall* ball = nullptr, cPaddle* player1 = nullptr, cPaddle* player2 = nullptr, VideoEngine::cImage** image = nullptr ); + ~cCourt(); + + ///Functions + void CheckCollision(); + void Quit(); + + const bool isPause() const; + void Pause(); + + void Reset(); + + private: + void CheckPaddles(); + + void CheckWall(const MathEngine::Vector4& wall); + void CheckWalls(); + + const bool CheckOffCourt(const MathEngine::Vector4& offside); + void CheckOffCourt(); + + private: + MathEngine::Vector4 m_topWall; + MathEngine::Vector4 m_bottomWall; + + MathEngine::Vector4 m_leftOff; + MathEngine::Vector4 m_rightOff; + + MathEngine::Vector4 m_court; + + cBall* mp_ball;// = nullptr; + cPaddle* mp_player[2];// = nullptr; + //cPaddle* mp_player2;// = nullptr; + + bool m_pause;// = false + };/// END CLASS DEFINITION cCourt +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CCOURT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/a6/a6f188a5dadeb8eb1edb1b6ff7e6cc894e46c608.svn-base b/.svn/pristine/a6/a6f188a5dadeb8eb1edb1b6ff7e6cc894e46c608.svn-base new file mode 100644 index 0000000..8d9d6af --- /dev/null +++ b/.svn/pristine/a6/a6f188a5dadeb8eb1edb1b6ff7e6cc894e46c608.svn-base @@ -0,0 +1,31 @@ +#ifndef _CMENUUP_HPP_ +#define _CMENUUP_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuUp : public InputEngine::cKey + { + public: + cMenuUp( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuUp& copy ); + ~cMenuUp(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuUp +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUUP_HPP_ \ No newline at end of file diff --git a/.svn/pristine/a8/a8ed844806b91a5213054c025fcf806aeae1b71d.svn-base b/.svn/pristine/a8/a8ed844806b91a5213054c025fcf806aeae1b71d.svn-base new file mode 100644 index 0000000..d30e91b --- /dev/null +++ b/.svn/pristine/a8/a8ed844806b91a5213054c025fcf806aeae1b71d.svn-base @@ -0,0 +1,39 @@ +#include "cKey.hpp" + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +using InputEngine::cKey; + +cKey::cKey( const SDL_Keycode& key ) +: m_key(key) +{} + +cKey::cKey( const cKey& copy ) +: m_key(copy.getKey()) +{} + +/*virtual*/ cKey::~cKey() +{} + +///Funtions +/*virtual*/ void cKey::KeyPress() +{} + +/*virtual*/ void cKey::KeyUP() +{} + +/*virtual*/ void cKey::KeyDown() +{} + +///Sets +void cKey::setKey( const SDL_Keycode& key ) +{ + m_key = key; +} + +///Gets +const SDL_Keycode& cKey::getKey() const +{ + return m_key; +} \ No newline at end of file diff --git a/.svn/pristine/a9/a92c322d7dd422615be7c1e2e5987db378f8bcec.svn-base b/.svn/pristine/a9/a92c322d7dd422615be7c1e2e5987db378f8bcec.svn-base new file mode 100644 index 0000000..5666773 --- /dev/null +++ b/.svn/pristine/a9/a92c322d7dd422615be7c1e2e5987db378f8bcec.svn-base @@ -0,0 +1,114 @@ +#ifndef _CWINDOW_HPP_ +#define _CWINDOW_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject + { + public: + static const UtilityEngine::cString sNAME; /*= "windows";*/ + static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/ + static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/ + static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/ + static GUIHelpers::RGBA sCOLOUR; /*= { 100, 100, 100, 255 };*/ + + static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/ + static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/ + static GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::NONE;*/ + + static unsigned long int sDebug; /*= 0;*/ + + protected: + cWindow( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cWindow(); + + virtual void Create(cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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); + + public: + ///Functions + virtual void Display(); + + const bool Inside( const MathEngine::iVector2& location ) const; + + void AddChild( cWindow* obj ); + + void RemoveChild( cWindow* obj ); + + ///Sets + void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION ); + void setAlign( const GUIHelpers::eAlign& align = sALIGN ); + void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT ); + void setPosition( const GUIHelpers::Position& pos = sPOSITION ); + void setSize( const GUIHelpers::Size& size = sSIZE ); + void setPadding(const GUIHelpers::Padding& padding = sPADDING); + void setContentSize( const GUIHelpers::Size& content ); + void setName( const cString& name = sNAME ); + + void setParent( cWindow* parent ); + + ///Gets + const GUIHelpers::eOrientation& getOrientation() const; + const GUIHelpers::eAlign& getAlign() const; + const GUIHelpers::eLayout& getLayout() const; + const GUIHelpers::Position& getPosition() const; + const GUIHelpers::Size& getSize() const; + const GUIHelpers::Padding& getPadding() const; + const GUIHelpers::Size& getContentSize() const; + const cString& getName() const; + + cWindow* getParent(); + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + virtual void RePos(); + virtual void RebuildPos(); + + virtual const GUIHelpers::RGBA getDebugColour() const; + + protected: + std::vector& getChildren(); + + private: + void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout ); + + void AddSize(int x, int y, GUIHelpers::Size& mySize) const; + + void DebugDisplay() const; + + private: + GUIHelpers::eOrientation m_orientation;// = GUIHelper::eOrientation::NONE; + GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER; + GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT; + GUIHelpers::Position m_pos;// = POSITION; + GUIHelpers::Size m_size;// = SIZE; + GUIHelpers::Padding m_padding;// = PADDING; + GUIHelpers::Size m_content;// = m_size; + cString m_name;// = NAME; + + std::vector m_children; + cWindow* mp_parent;// = nullptr; + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ diff --git a/.svn/pristine/ab/abf0f69eec5e8fa3bc557daa3d2d1a1719ce4c74.svn-base b/.svn/pristine/ab/abf0f69eec5e8fa3bc557daa3d2d1a1719ce4c74.svn-base new file mode 100644 index 0000000..a5acbad --- /dev/null +++ b/.svn/pristine/ab/abf0f69eec5e8fa3bc557daa3d2d1a1719ce4c74.svn-base @@ -0,0 +1,96 @@ +#ifndef _CGUI_HPP_ +#define _CGUI_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../TextTypeEngine/cFont.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "cWindow.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cGUI + { + private: + cGUI(); + ~cGUI(); + + public: + enum EXPORT_FROM_MYDLL eGUIEventType: unsigned int + { + MouseButton1 = 0, + MouseButton2, + MouseButton3, + Keyboard + }; + ///Functions + static cGUI& Inst(); + static void Delete(); + + const bool Initialize( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void Event(const MathEngine::iVector2& location, const eGUIEventType& type); + const MathEngine::iVector2 DisplayArea() const; + + void AddObject(cWindow* obj); + + void Display(); + + ///Sets + void setFont( TextTypeEngine::cFont* font ); + void setFont( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void setTextColour( const GUIHelpers::RGBA& colour ); + void setTextColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0 ); + + void setPadding( const GUIHelpers::Padding& padding ); + void setPadding( const unsigned int top = 5, const unsigned int right = 5, const unsigned int bottom = 5, const unsigned int left = 5 ); + + void setAlign( const GUIHelpers::eAlign& align = GUIHelpers::eAlign::CENTER ); + + ///Gets + TextTypeEngine::cFont* getFont(); + + const GUIHelpers::RGBA& getTextColour() const; + void getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const; + + const GUIHelpers::Padding& getPadding() const; + void getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const; + + const GUIHelpers::eAlign& getAlign() const; + + const bool IsInit() const; + + private: + static cGUI* sp_inst;// = nullptr + + bool m_inited;// = false + + /* default GUI font */ + TextTypeEngine::cFont* mp_font;// = nullptr + + /* default GUI text colour black*/ + //GUIHelpers::RBGA m_textColour;// = { 0, 0, 0 } + + /* default GUI padding */ + //GUIHelpers::Padding m_padding;// = { 5, 5, 5, 5 } + + /* default GUI align */ + //GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::CENTER + + std::vector m_guiObjects; + };/// END CLASS DEFINITION cGUI +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CGUI_HPP_ diff --git a/.svn/pristine/ae/ae5c8375d6460bfe6a9e6f63723022a4b9efa739.svn-base b/.svn/pristine/ae/ae5c8375d6460bfe6a9e6f63723022a4b9efa739.svn-base new file mode 100644 index 0000000..4c9140a --- /dev/null +++ b/.svn/pristine/ae/ae5c8375d6460bfe6a9e6f63723022a4b9efa739.svn-base @@ -0,0 +1,40 @@ +#include "UTest.hpp" + +const /*static*/ char * UTest::sp_pstr = "pass"; +const /*static*/ char * UTest::sp_fstr = "fail"; + +/*static*/ unsigned long int UTest::s_pass = 0; +/*static*/ unsigned long int UTest::s_fail = 0; + +UTest::UTest( const char * tstr ) { + init(tstr); +} + +void UTest::init( const char * tstr ) { + mp_tstr = tstr; + m_pass = m_fail = 0; +} + +void UTest::test( const char * description, const int flag ) { + const char * pf = nullptr; + if (flag) { + pf = sp_pstr; + ++m_pass; + ++s_pass; + } else { + pf = sp_fstr; + ++m_fail; + ++s_fail; + } + printf("%s: %s -> %s\n", mp_tstr, description, pf); +} + +void UTest::report() const { + printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail); +} + +/*static*/ void UTest::OverAllReport() +{ + printf("\nOver All pass: %ld, fail: %ld\n", s_pass, s_fail); +} + diff --git a/.svn/pristine/af/af33854f5624f5392dda9d041cd81013f8c5d20a.svn-base b/.svn/pristine/af/af33854f5624f5392dda9d041cd81013f8c5d20a.svn-base new file mode 100644 index 0000000..dbeced6 --- /dev/null +++ b/.svn/pristine/af/af33854f5624f5392dda9d041cd81013f8c5d20a.svn-base @@ -0,0 +1,68 @@ +#ifndef _CTROOPERENGINECORE_HPP_ +#define _CTROOPERENGINECORE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +#define __TROOPERENGINE__VERSION "1.0.0" + +namespace TrooperEngineCore { + /* Singleton */ + class EXPORT_FROM_MYDLL cTrooperEngineCore + { + private: + cTrooperEngineCore(); + ~cTrooperEngineCore(); + + public: + ///Functions + static const char* Version(); + static cTrooperEngineCore& Inst(); + static void Delete(); + + /* Initiates the video */ + const bool VideoInit(); + /* Initiates the audio */ + const bool AudioInit(); + /* Initiates the input (Keyboard Mouse Joystick)*/ + const bool InputInit(); + /* Initiates the joystick */ + const bool JoystickInit(); + /* Initiates the timer */ + const bool TimerInit(); + /* Initiates the text */ + const bool TextTypeInit(); + /* Initiates the event */ + const bool EventInit(); + + /* Print lib versions */ + void PrintSDLVersion() const; + + /* Cleans up */ + void CleanUp(); + + ///Gets + /* Gets returns true if Video was initiated other wise it returns false */ + const bool getVideo() const; + /* Gets returns true if Audio was initiated other wise it returns false */ + const bool getAudio() const; + /* Gets returns true if Input was initiated other wise it returns false */ + const bool getInput() const; + /* Gets returns true if Joystick was initiated other wise it returns false */ + const bool getJoystick() const; + /* Gets returns true if Timer was initiated other wise it returns false */ + const bool getTimer() const; + /* Gets returns true if Text was initiated other wise it returns false */ + const bool getText() const; + /* Gets returns true if Event was initiated other wise it returns false */ + const bool getEvent() const; + + private: + ///Variables + static cTrooperEngineCore* sp_inst;// = nullptr + };/// END CLASS DEFINITION cTrooperEngineCore +}/// END NAMESPACE DEFINITION TroopperENgineCore +#endif/// END IFNDEF _CTROOPERENGINECORE_HPP_ diff --git a/.svn/pristine/af/af908bd7dd29938225fc3f569bc25dfe31908456.svn-base b/.svn/pristine/af/af908bd7dd29938225fc3f569bc25dfe31908456.svn-base new file mode 100644 index 0000000..e63dede --- /dev/null +++ b/.svn/pristine/af/af908bd7dd29938225fc3f569bc25dfe31908456.svn-base @@ -0,0 +1,61 @@ +#ifndef _CLABEL_HPP_ +#define _CLABEL_HPP_ +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../VideoEngine/cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLabel : public cWindow, public VideoEngine::cSprite + { + public: + static const cString sNAME; /*= "label";*/ + static const GUIHelpers::eLayout sLAYOUT;/* = GUIHelpers::eLayout::WRAP_CONTENT;*/ + + cLabel(cWindow* parent, const signed int id, const cString& label = "", 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); + virtual ~cLabel(); + + ///Functions + void Create(cWindow* parent, const signed int id, const cString& label = "", 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); + + virtual void Display(); + + void GenerateTexture(); + + //Sets + void setFontColour( const GUIHelpers::RBGA& colour ); + void setFontSize( const unsigned long int size ); + void setText( const cString& text ); + void setFont( const TextTypeEngine::cFont* font ); + + ///Gets + const GUIHelpers::RBGA& getFontColour() const; + const unsigned long int getFontSize() const; + const TextTypeEngine::cFont* getFont() const; + const cString& getText() const; + virtual const GUIHelpers::eType getType() const; + + + virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + private: + + + + private: + TextTypeEngine::cText* mp_text;// = nullptr + };/// END CLASS DEFINITION cLabel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLABEL_HPP_ diff --git a/.svn/pristine/af/afd83879b6ad7773d62dac30e778b4d7dee80552.svn-base b/.svn/pristine/af/afd83879b6ad7773d62dac30e778b4d7dee80552.svn-base new file mode 100644 index 0000000..ff245fe --- /dev/null +++ b/.svn/pristine/af/afd83879b6ad7773d62dac30e778b4d7dee80552.svn-base @@ -0,0 +1,251 @@ +#include "cXMLoader.hpp" + +/*** Custom Header Files ***/ +#include "../../UtilityEngine/cUtility.hpp" + +#include "../cGUI.hpp" +#include "../cLayout.hpp" + +using GUIHelpers::cXMLoader; + +using UtilityEngine::cUtility; + +/*static*/ cXMLoader* cXMLoader::sp_inst = nullptr; + +cXMLoader::cXMLoader() +{} + +cXMLoader::~cXMLoader() +{} + +//PUBLIC +///Functions +/*static*/ cXMLoader& cXMLoader::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cXMLoader(); + return *sp_inst; +} + +/*static*/ void cXMLoader::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cXMLoader::Load( const cString& filename, const cString& dir /*= ""*/ ) const +{ + cString file = dir + filename; + tinyxml2::XMLDocument doc; + + if (doc.LoadFile(file.c_str()) != tinyxml2::XMLError::XML_NO_ERROR) + cUtility::Inst().Message("Could not load file. " + file + " Error='" + doc.ErrorName() + "'."); + else { + tinyxml2::XMLNode* node = doc.FirstChildElement("GUI"); + + if (node == nullptr) + cUtility::Inst().Message("No GUI tag found."); + else + GetElement(*node->ToElement()); + } + +} + +void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent /*= nullptr*/ ) const +{ + cString name = element.Name(); + GUIEngine::cWindow* tmp = nullptr; + if (name == "GUI") + GUISetup(element); + if (name == "Layout") + tmp = LayoutBuild(element, parent); + if (name == "Label") + tmp = LabelBuild(element, parent); + tinyxml2::XMLElement* child = element.FirstChildElement(); + if (child != nullptr) + GetElement(*child, tmp); + + tinyxml2::XMLElement* sibling = element.NextSiblingElement(); + if (sibling != nullptr) + GetElement(*sibling, parent); + + if ((parent == nullptr) && (tmp != nullptr)) + tmp->Resize(); +} + +const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const +{ + cString rtn = ""; + const char* str = element.Attribute(attribute.c_str()); + if (str == nullptr) + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element.Value() + ">"); + else + rtn = str; + return rtn; +} + +void cXMLoader::GUISetup( const tinyxml2::XMLElement& element ) const +{ + unsigned long int debug = getDebug(element); + + GUIEngine::cWindow::sDebug = debug; +} + +GUIEngine::cLayout* cXMLoader::LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + + GUIEngine::cLayout* rtn = new GUIEngine::cLayout(parent, id, orientation, align, layout, pos, size, pad); + + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLabel* cXMLoader::LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + //GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + cString txt = getText(element); + + GUIEngine::cLabel* rtn = new GUIEngine::cLabel(parent, id, txt, align, layout, pos, size, pad); + + return rtn; +} + +const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element ) const +{ + unsigned long int rtn = 0; + cString str = GetAttribute(element, "debug").lower(); + + if ((str != "") && (str != "false")) { + if (str == "true") + rtn = 1; + else + rtn = str.ToInt(); + } + + return rtn; +} + +const signed long int cXMLoader::getID( const tinyxml2::XMLElement& element ) const +{ + cString rtn = GetAttribute(element, "id"); + return rtn.ToInt(); +} + +const GUIHelpers::eOrientation cXMLoader::getOrientation( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eOrientation rtn = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + + cString str = GetAttribute(element, "orientation").lower(); + + if (str == "none") + rtn = GUIHelpers::eOrientation::NONE; + if (str == "horizontal") + rtn = GUIHelpers::eOrientation::HORIZONTAL; + if (str == "vertical") + rtn = GUIHelpers::eOrientation::VERTICAL; + + return rtn; +} + +const GUIHelpers::eAlign cXMLoader::getAlign( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eAlign rtn = GUIHelpers::eAlign::DEFAULT_ALIGN; + + cString str = GetAttribute(element, "align").lower(); + + if (str == "center") + rtn = GUIHelpers::eAlign::CENTER; + if (str == "top") + rtn = GUIHelpers::eAlign::TOP; + if (str == "right") + rtn = GUIHelpers::eAlign::RIGHT; + if (str == "bottom") + rtn = GUIHelpers::eAlign::BOTTOM; + if (str == "left") + rtn = GUIHelpers::eAlign::LEFT; + + return rtn; +} + +const GUIHelpers::eLayout cXMLoader::getLayout( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eLayout rtn = GUIHelpers::eLayout::DEFAULT_LAYOUT; + + cString str = GetAttribute(element, "layout").lower(); + + if (str == "fill_parent") + rtn = GUIHelpers::eLayout::FILL_PARENT; + if (str == "match_parent") + rtn = GUIHelpers::eLayout::MATCH_PARENT; + if (str == "wrap_content") + rtn = GUIHelpers::eLayout::WRAP_CONTENT; + + return rtn; +} + +const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Position rtn = { 0, 0 }; + + /*cString str = GetAttribute(element, "position");*/ + + return rtn; +} + +const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Size rtn = { 0, 0 }; + + /*cString str = GetAttribute(element, "position");*/ + + return rtn; +} + +const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Padding rtn = { -1, -1, -1, -1 }; + + cString str = GetAttribute(element, "padding"); + + if (str != "") { + rtn = { 0, 0, 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 4: + rtn.z = strV[3].ToInt(); + case 3: + rtn.w = strV[2].ToInt(); + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const cString cXMLoader::getText( const tinyxml2::XMLElement& element ) const +{ + return GetAttribute(element, "text"); +} \ No newline at end of file diff --git a/.svn/pristine/b0/b0dd09af48777f108d7fad3d48329446fe5eb5ce.svn-base b/.svn/pristine/b0/b0dd09af48777f108d7fad3d48329446fe5eb5ce.svn-base new file mode 100644 index 0000000..285f22a --- /dev/null +++ b/.svn/pristine/b0/b0dd09af48777f108d7fad3d48329446fe5eb5ce.svn-base @@ -0,0 +1,63 @@ +#ifndef _CLABEL_HPP_ +#define _CLABEL_HPP_ +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../VideoEngine/cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLabel : public cWindow + { + public: + static const cString sNAME; /*= "label";*/ + static const GUIHelpers::eLayout sLAYOUT;/* = GUIHelpers::eLayout::WRAP_CONTENT;*/ + + cLabel(cWindow* parent, const signed int id, const cString& label = "", 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); + virtual ~cLabel(); + + ///Functions + void Create(cWindow* parent, const signed int id, const cString& label = "", 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); + + virtual void Display(); + + void GenerateTexture(); + + //Sets + void setFontColour( const GUIHelpers::RGBA& colour ); + void setFontSize( const unsigned long int size ); + void setText( const cString& text ); + void setFont( const TextTypeEngine::cFont* font ); + + ///Gets + const GUIHelpers::RGBA& getFontColour() const; + const unsigned long int getFontSize() const; + const TextTypeEngine::cFont* getFont() const; + const cString& getText() const; + virtual const GUIHelpers::eType getType() const; + virtual const GUIHelpers::RGBA getDebugColour() const; + + + virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + private: + + + + private: + VideoEngine::cSprite m_sprite; + TextTypeEngine::cText* mp_text;// = nullptr + };/// END CLASS DEFINITION cLabel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLABEL_HPP_ diff --git a/.svn/pristine/b1/b1abe23b48550a1e6ec145293e8bf803ba56f7d2.svn-base b/.svn/pristine/b1/b1abe23b48550a1e6ec145293e8bf803ba56f7d2.svn-base new file mode 100644 index 0000000..72f45a5 --- /dev/null +++ b/.svn/pristine/b1/b1abe23b48550a1e6ec145293e8bf803ba56f7d2.svn-base @@ -0,0 +1,29 @@ +#ifndef _VECTOR2_HPP_ +#define _VECTOR2_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + struct iVector2; + + struct EXPORT_FROM_MYDLL Vector2 + { + Vector2( const float X = 0.0f, const float Y = 0.0f ); + + Vector2( const SDL_Rect& copy ); + + Vector2& operator=( const SDL_Rect& copy ); + + Vector2( const iVector2& copy ); + + Vector2& operator=( const iVector2& copy ); + + float x; + float y; + };/// END STRUCT DEFINITION Vector2 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR2_HPP_ \ No newline at end of file diff --git a/.svn/pristine/b1/b1e0023179d4bfd9cbb8b7ecec121d7534131c8a.svn-base b/.svn/pristine/b1/b1e0023179d4bfd9cbb8b7ecec121d7534131c8a.svn-base new file mode 100644 index 0000000..f4e97e2 --- /dev/null +++ b/.svn/pristine/b1/b1e0023179d4bfd9cbb8b7ecec121d7534131c8a.svn-base @@ -0,0 +1,3 @@ +#include "GUIUtility.hpp" + +using namespace GUIHelpers; \ No newline at end of file diff --git a/.svn/pristine/b2/b2d98f8128cf1418fa63b6845b036dbab6ca2ae9.svn-base b/.svn/pristine/b2/b2d98f8128cf1418fa63b6845b036dbab6ca2ae9.svn-base new file mode 100644 index 0000000..45d63e3 --- /dev/null +++ b/.svn/pristine/b2/b2d98f8128cf1418fa63b6845b036dbab6ca2ae9.svn-base @@ -0,0 +1,60 @@ +#ifndef _CLAYOUT_HPP_ +#define _CLAYOUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/GUIUtility.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLayout : public cWindow + { + public: + static const cString sNAME; /*= "layout";*/ + static const GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::VERTICAL;*/ + + cLayout( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cLayout(); + + ///Functions + void Create( cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + ///Set + void setOrientation( const GUIHelpers::eOrientation& orientation = GUIHelpers::eOrientation::VERTICAL ); + + ///Get + const GUIHelpers::eOrientation& getOrientation() const; + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout( const GUIHelpers::eLayout& layout); + + /*virtual void RebuildPos();*/ + + private: + /*virtual*/ void AddSize(int x, int y, GUIHelpers::Size& mySize) const; + + private: + GUIHelpers::eOrientation m_orientation; + };/// END CLASS DEFINITION cLayout +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLAYOUT_HPP_ diff --git a/.svn/pristine/b3/b336f34c0b20703ed8f267ddf04c063169d4f9fd.svn-base b/.svn/pristine/b3/b336f34c0b20703ed8f267ddf04c063169d4f9fd.svn-base new file mode 100644 index 0000000..23224a7 --- /dev/null +++ b/.svn/pristine/b3/b336f34c0b20703ed8f267ddf04c063169d4f9fd.svn-base @@ -0,0 +1,28 @@ +#ifndef _CTEXTURE_HPP_ +#define _CTEXTURE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cImage.hpp" +#include "../../TextTypeEngine/cText.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cTexture : public VideoEngine::cImage + { + public: + cTexture(); + ~cTexture(); + + ///Functions + SDL_Texture* GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text = nullptr ); + + private: + + };/// END CLASS DEFINITION cTexture +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CTEXTURE_HPP_ \ No newline at end of file diff --git a/.svn/pristine/b4/b4e586e9641c23aa42dc2ee6b61647444ff32133.svn-base b/.svn/pristine/b4/b4e586e9641c23aa42dc2ee6b61647444ff32133.svn-base new file mode 100644 index 0000000..7d4ed56 --- /dev/null +++ b/.svn/pristine/b4/b4e586e9641c23aa42dc2ee6b61647444ff32133.svn-base @@ -0,0 +1,375 @@ +#include "cXMLoader.hpp" + +/*** Custom Header Files ***/ +#include "../../UtilityEngine/cUtility.hpp" + +#include "../cGUI.hpp" +#include "../cLayout.hpp" + +using GUIHelpers::cXMLoader; + +using UtilityEngine::cUtility; + + +cXMLoader::cXMLoader() +{ + m_loadDef = false; + m_orientation = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + m_align = GUIHelpers::eAlign::DEFAULT_ALIGN; + m_layout = GUIHelpers::eLayout::DEFAULT_LAYOUT; + m_pos = { -1, -1 }; + m_size = { -1, -1 }; + m_pad = { -1, -1, -1, -1 }; +} + +cXMLoader::~cXMLoader() +{} + +///Functions + +void cXMLoader::Load( const cString& filename, const cString& dir /*= ""*/, GUIEngine::cWindow* parent /*= nullptr*/ ) +{ + cString file = dir + filename; + tinyxml2::XMLDocument doc; + + if (doc.LoadFile(file.c_str()) != tinyxml2::XMLError::XML_NO_ERROR) + cUtility::Inst().Message("Could not load file. " + file + " Error='" + doc.ErrorName() + "'."); + else { + tinyxml2::XMLElement* element = doc.FirstChildElement(); + + if (element == nullptr) + cUtility::Inst().Message("No tag found."); + else { + //OK check for defaults + tinyxml2::XMLElement* defaultEl = element->FirstChildElement("default"); + if (defaultEl != nullptr) + Default(*defaultEl); + tinyxml2::XMLElement* debugEl = element->FirstChildElement("debug"); + if (debugEl != nullptr) + Debug(*debugEl); + GetElement(*element, parent); + } + } + +} + +void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent /*= nullptr*/ ) const +{ + cString name = element.Name(); + name = name.lower(); + GUIEngine::cWindow* tmp = nullptr; + if (name == "include") + Include(element, parent); + if (name == "gui") + GUISetup(element); + if (name == "panel") + tmp = PanelBuild(element, parent); + if (name == "layout") + tmp = LayoutBuild(element, parent); + if (name == "label") + tmp = LabelBuild(element, parent); + tinyxml2::XMLElement* child = element.FirstChildElement(); + if (child != nullptr) + GetElement(*child, tmp); + + tinyxml2::XMLElement* sibling = element.NextSiblingElement(); + if (sibling != nullptr) + GetElement(*sibling, parent); + + if ((parent == nullptr) && (tmp != nullptr)) + tmp->Resize(); +} + +const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const +{ + cString rtn = ""; + const char* str = element.Attribute(attribute.c_str()); + if ((str == nullptr) && (m_debugXML == true)) + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element.Value() + ">"); + else + rtn = str; + return rtn; +} + +void cXMLoader::Include(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const +{ + cString dir = getDir(element); + cString filename = getFileName(element); + + cXMLoader include; + include.Load(filename, dir, parent); + + LoadDefault(); +} + +void cXMLoader::GUISetup( const tinyxml2::XMLElement& element ) const +{ + unsigned long int debug = getDebug(element); + + GUIEngine::cGUI::Inst().setDebugLevel(debug); +} + +void cXMLoader::Default( const tinyxml2::XMLElement& element ) +{ + m_orientation = getOrientation(element); + m_align = getAlign(element); + m_layout = getLayout(element); + m_pos = getPosition(element); + m_size = getSize(element); + m_pos = getPadding(element); + + m_loadDef = true; + + LoadDefault(); +} + +void cXMLoader::Debug(const tinyxml2::XMLElement& element) +{ + unsigned long int debug = getDebug(element); + m_debugXML = getDebugXML(element); + + GUIEngine::cGUI::Inst().setDebugLevel(debug); +} + +GUIEngine::cPanel* cXMLoader::PanelBuild(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + GUIEngine::cPanel* rtn = new GUIEngine::cPanel(parent, id, orientation, align, layout, pos, size, pad); + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLayout* cXMLoader::LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + + GUIEngine::cLayout* rtn = new GUIEngine::cLayout(parent, id, orientation, align, layout, pos, size, pad); + + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLabel* cXMLoader::LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + //GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + cString txt = getText(element); + + GUIEngine::cLabel* rtn = new GUIEngine::cLabel(parent, id, txt, align, layout, pos, size, pad); + + return rtn; +} + +const cString cXMLoader::getDir(const tinyxml2::XMLElement& element) const +{ + cString rtn = GetAttribute(element, "dir"); + return rtn; +} + +const cString cXMLoader::getFileName(const tinyxml2::XMLElement& element) const +{ + cString rtn = GetAttribute(element, "filename"); + return rtn; +} + +const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element ) const +{ + unsigned long int rtn = 99; + cString str = GetAttribute(element, "level").lower(); + + if ((str != "") && (str != "false")) { + if (str == "true") + rtn = 1; + else + rtn = str.ToInt(); + } + + return rtn; +} + +const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const +{ + bool rtn = false; + cString str = GetAttribute(element, "xml").lower(); + + if ((str != "") && (str != "false")) { + if (str == "true") + rtn = true; + else { + if (str.ToInt() > 0) + rtn = true; + } + } + return rtn; +} + +const signed long int cXMLoader::getID( const tinyxml2::XMLElement& element ) const +{ + cString rtn = GetAttribute(element, "id"); + return rtn.ToInt(); +} + +const GUIHelpers::eOrientation cXMLoader::getOrientation( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eOrientation rtn = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + + cString str = GetAttribute(element, "orientation").lower(); + + if (str == "none") + rtn = GUIHelpers::eOrientation::NONE; + if (str == "horizontal") + rtn = GUIHelpers::eOrientation::HORIZONTAL; + if (str == "vertical") + rtn = GUIHelpers::eOrientation::VERTICAL; + + return rtn; +} + +const GUIHelpers::eAlign cXMLoader::getAlign( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eAlign rtn = GUIHelpers::eAlign::DEFAULT_ALIGN; + + cString str = GetAttribute(element, "align").lower(); + + if (str == "center") + rtn = GUIHelpers::eAlign::CENTER; + if (str == "top") + rtn = GUIHelpers::eAlign::TOP; + if (str == "right") + rtn = GUIHelpers::eAlign::RIGHT; + if (str == "bottom") + rtn = GUIHelpers::eAlign::BOTTOM; + if (str == "left") + rtn = GUIHelpers::eAlign::LEFT; + + return rtn; +} + +const GUIHelpers::eLayout cXMLoader::getLayout( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eLayout rtn = GUIHelpers::eLayout::DEFAULT_LAYOUT; + + cString str = GetAttribute(element, "layout").lower(); + + if (str == "fill_parent") + rtn = GUIHelpers::eLayout::FILL_PARENT; + if (str == "match_parent") + rtn = GUIHelpers::eLayout::MATCH_PARENT; + if (str == "wrap_content") + rtn = GUIHelpers::eLayout::WRAP_CONTENT; + + return rtn; +} + +const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Position rtn = { -1, -1 }; + + cString str = GetAttribute(element, "position"); + + if (str != "") { + rtn = { 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Size rtn = { -1, -1 }; + + cString str = GetAttribute(element, "size"); + + if (str != "") { + rtn = { 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Padding rtn = { -1, -1, -1, -1 }; + + cString str = GetAttribute(element, "padding"); + + if (str != "") { + rtn = { 0, 0, 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 4: + rtn.z = strV[3].ToInt(); + case 3: + rtn.w = strV[2].ToInt(); + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const cString cXMLoader::getText( const tinyxml2::XMLElement& element ) const +{ + return GetAttribute(element, "text"); +} + +void cXMLoader::LoadDefault() const +{ + if (m_loadDef == false) + return; + GUIEngine::cWindow::OrientationDefault(m_orientation); + GUIEngine::cWindow::AlignDefault(m_align); + GUIEngine::cWindow::LayoutDefault(m_layout); + GUIEngine::cWindow::PositionDefault(m_pos); + GUIEngine::cWindow::SizeDefault(m_size); + GUIEngine::cWindow::PaddingDefault(m_pad); +} \ No newline at end of file diff --git a/.svn/pristine/b5/b56d266fc5ea4c64d546691aca9cb7a11db42d9e.svn-base b/.svn/pristine/b5/b56d266fc5ea4c64d546691aca9cb7a11db42d9e.svn-base new file mode 100644 index 0000000..6fa0ff7 --- /dev/null +++ b/.svn/pristine/b5/b56d266fc5ea4c64d546691aca9cb7a11db42d9e.svn-base @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + UTest + Win32 + + + UTest + x64 + + + + {9225E043-EE77-43AA-A140-C9C2F85B1013} + TrooperEngineTest + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + v140 + + + v140 + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + true + $(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + true + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2)\VisualC\Win32\Release;$(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + Console + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + Designer + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/b5/b5c9f88ddc083248cfe07bd7e1179b87916ca97b.svn-base b/.svn/pristine/b5/b5c9f88ddc083248cfe07bd7e1179b87916ca97b.svn-base new file mode 100644 index 0000000..7e515b1 --- /dev/null +++ b/.svn/pristine/b5/b5c9f88ddc083248cfe07bd7e1179b87916ca97b.svn-base @@ -0,0 +1,62 @@ +#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: + 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/.svn/pristine/b5/b5e13dac5827120b9bb8b482b74e119440b2b567.svn-base b/.svn/pristine/b5/b5e13dac5827120b9bb8b482b74e119440b2b567.svn-base new file mode 100644 index 0000000..750fab2 --- /dev/null +++ b/.svn/pristine/b5/b5e13dac5827120b9bb8b482b74e119440b2b567.svn-base @@ -0,0 +1,96 @@ +#ifndef _CGUI_HPP_ +#define _CGUI_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../TextTypeEngine/cFont.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "cWindow.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cGUI + { + private: + cGUI(); + ~cGUI(); + + public: + enum EXPORT_FROM_MYDLL eGUIEventType: unsigned int + { + MouseButton1 = 0, + MouseButton2, + MouseButton3, + Keyboard + }; + ///Functions + static cGUI& Inst(); + static void Delete(); + + const bool Initialize( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void Event(const MathEngine::iVector2& location, const eGUIEventType& type); + const MathEngine::iVector2 DisplayArea() const; + + void AddObject(cWindow* obj); + + void Display(); + + ///Sets + void setFont( TextTypeEngine::cFont* font ); + void setFont( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void setTextColour( const GUIHelpers::RBGA& colour ); + void setTextColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0 ); + + void setPadding( const GUIHelpers::Padding& padding ); + void setPadding( const unsigned int top = 5, const unsigned int right = 5, const unsigned int bottom = 5, const unsigned int left = 5 ); + + void setAlign( const GUIHelpers::eAlign& align = GUIHelpers::eAlign::CENTER ); + + ///Gets + TextTypeEngine::cFont* getFont(); + + const GUIHelpers::RBGA& getTextColour() const; + void getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const; + + const GUIHelpers::Padding& getPadding() const; + void getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const; + + const GUIHelpers::eAlign& getAlign() const; + + const bool IsInit() const; + + private: + static cGUI* sp_inst;// = nullptr + + bool m_inited;// = false + + /* default GUI font */ + TextTypeEngine::cFont* mp_font;// = nullptr + + /* default GUI text colour black*/ + //GUIHelpers::RBGA m_textColour;// = { 0, 0, 0 } + + /* default GUI padding */ + //GUIHelpers::Padding m_padding;// = { 5, 5, 5, 5 } + + /* default GUI align */ + //GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::CENTER + + std::vector m_guiObjects; + };/// END CLASS DEFINITION cGUI +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CGUI_HPP_ diff --git a/.svn/pristine/b6/b6af1c96b170d4ce4a2d7dccce891612ca7b09a4.svn-base b/.svn/pristine/b6/b6af1c96b170d4ce4a2d7dccce891612ca7b09a4.svn-base new file mode 100644 index 0000000..407b574 --- /dev/null +++ b/.svn/pristine/b6/b6af1c96b170d4ce4a2d7dccce891612ca7b09a4.svn-base @@ -0,0 +1,60 @@ +#ifndef _CBALL_HPP_ +#define _CBALL_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace Equipment { + class cBall : public VideoEngine::cSprite + { + public: + enum eBallState + { + OnCourt, + LeftOffCourt, + RightOffCourt, + Serve + }; + + cBall( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + ~cBall(); + + ///Functions + void Move(); + const bool isPaused(); + void Pause(); + + void BounceX(); + void BounceY(); + + void Reset( const int delay ); + + ///Sets + void setSpeed( const float x = -10, const float y = -10 ); + void setMaxSpeed( const float max = 10 ); + void setMinSpeed( const float min = 5 ); + + ///Gets + const MathEngine::Vector2 getSpeed() const; + const float getMaxSpeed() const; + const float getMinSpeed() const; + + private: + + + private: + float m_maxSpeed; + float m_minSpeed; + + bool m_boucedAllReady;// = false; + + MathEngine::Vector2 m_speed; + + eBallState m_ballState; + + bool m_pause;// = false + };/// END CLASS DEFINITION cBall +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CBALL_HPP_ \ No newline at end of file diff --git a/.svn/pristine/b7/b77731e6dc548980148f41e860dc93ae29e4e69e.svn-base b/.svn/pristine/b7/b77731e6dc548980148f41e860dc93ae29e4e69e.svn-base new file mode 100644 index 0000000..f09ac1d --- /dev/null +++ b/.svn/pristine/b7/b77731e6dc548980148f41e860dc93ae29e4e69e.svn-base @@ -0,0 +1,220 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + TrooperEngineDLL + + + + DynamicLibrary + MultiByte + true + v140 + + + StaticLibrary + MultiByte + false + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + /MP %(AdditionalOptions) + Disabled + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + NotUsing + %(PreprocessorDefinitions) + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + ../Debug;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.11\lib;$(SDL)\SDL_image-1.2.10\lib;$(SDL)\SDL-1.2.14\lib;%(AdditionalLibraryDirectories) + true + NotSet + false + + + + + MachineX86 + + + + + Full + ../LinkListDLLProject/dllExportFiles;dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level4 + true + ProgramDatabase + true + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;LinkList.lib;%(AdditionalDependencies) + $(OutDir)TrooperEngine.dll + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + true + true + false + + + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/b9/b93f82fb6ebaaeaf68df4066d8907376235e2e72.svn-base b/.svn/pristine/b9/b93f82fb6ebaaeaf68df4066d8907376235e2e72.svn-base new file mode 100644 index 0000000..74c2632 --- /dev/null +++ b/.svn/pristine/b9/b93f82fb6ebaaeaf68df4066d8907376235e2e72.svn-base @@ -0,0 +1,36 @@ +#ifndef _IVECTOR2_HPP_ +#define _IVECTOR2_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + struct Vector2; + + struct EXPORT_FROM_MYDLL iVector2 + { + iVector2( const int X = 0, const int Y = 0 ); + iVector2( const Vector2& copy ); + iVector2( const SDL_Rect& copy ); + + iVector2& operator = ( const Vector2& copy ); + iVector2& operator = ( const SDL_Rect& copy ); + + bool operator == ( const iVector2& other ) const; + bool operator == ( const SDL_Rect& other ) const; + + iVector2& operator += ( const iVector2& other ); + iVector2& operator += ( const SDL_Rect& other ); + + iVector2& operator + ( const iVector2& other ); + iVector2& operator + ( const SDL_Rect& other ); + + int x; + int y; + };/// END STRUCT DEFINITION iVector2 +}/// END NAMESPACE DEFINITION MathEngine +MathEngine::iVector2 operator + (const MathEngine::iVector2& lhs, const MathEngine::iVector2& rhs); +#endif/// END IFNDEF _IVECTOR2_HPP_ \ No newline at end of file diff --git a/.svn/pristine/ba/bac1571a7058ea8dd3cecd72b559e1922cdf9934.svn-base b/.svn/pristine/ba/bac1571a7058ea8dd3cecd72b559e1922cdf9934.svn-base new file mode 100644 index 0000000..87e5048 --- /dev/null +++ b/.svn/pristine/ba/bac1571a7058ea8dd3cecd72b559e1922cdf9934.svn-base @@ -0,0 +1,39 @@ +#ifndef _CPANEL_HPP_ +#define _CPANEL_HPP_ + +/** C++ Header Files **/ +#include + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector >; +/*#pragma warning (default : 4231)*/ + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cPanel : public GUIHelpers::cObject + { + public: + cPanel(); + ~cPanel(); + + ///Functions + void Draw(); + + private: + + + private: + std::vector m_guiObjects; + + };/// END CLASS DEFINITION cPanel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CPANEL_HPP_ \ No newline at end of file diff --git a/.svn/pristine/bc/bcfecf6dc05dbb4f654dd269ebff56319d4bf62e.svn-base b/.svn/pristine/bc/bcfecf6dc05dbb4f654dd269ebff56319d4bf62e.svn-base new file mode 100644 index 0000000..7fbafc4 --- /dev/null +++ b/.svn/pristine/bc/bcfecf6dc05dbb4f654dd269ebff56319d4bf62e.svn-base @@ -0,0 +1,7 @@ + + + + + + diff --git a/.svn/pristine/be/be5239385fec8e1675a017667c9d437c1e05b2a7.svn-base b/.svn/pristine/be/be5239385fec8e1675a017667c9d437c1e05b2a7.svn-base new file mode 100644 index 0000000..b66cf73 --- /dev/null +++ b/.svn/pristine/be/be5239385fec8e1675a017667c9d437c1e05b2a7.svn-base @@ -0,0 +1,40 @@ +#ifndef _CTEXTTYPE_HPP_ +#define _CTEXTTYPE_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace TextTypeEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTextType + { + private: + cTextType(); + ~cTextType(); + + public: + ///Functions + static cTextType& Inst(); + static void Delete(); + + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + void PrintVersion() const; + + ///Sets + ///Gets + /* Gets return true if Text was initialized */ + const bool IsInit() const; + + private: + static cTextType* sp_inst;// = nullptr + };/// END CLASS DEFINITION cTextType +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CTEXTTYPE_HPP_ diff --git a/.svn/pristine/be/bea8de15ba93afa8100dcf2bded408210d68ee2c.svn-base b/.svn/pristine/be/bea8de15ba93afa8100dcf2bded408210d68ee2c.svn-base new file mode 100644 index 0000000..d0b22dc --- /dev/null +++ b/.svn/pristine/be/bea8de15ba93afa8100dcf2bded408210d68ee2c.svn-base @@ -0,0 +1,43 @@ +#include "Vector3.hpp" + +/*** Custom Header File ***/ +#include "../iVector/iVector3.hpp" + +using MathEngine::Vector3; +using MathEngine::iVector3; + +Vector3::Vector3( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/ ) + : Vector2( X, Y ), z(Z) +{} + +Vector3::Vector3( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); +} + +Vector3& Vector3::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + + return *this; +} + +Vector3::Vector3( const iVector3& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); +} + +Vector3& Vector3::operator=( const iVector3& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + + return *this; +} \ No newline at end of file diff --git a/.svn/pristine/be/bede0adc0f93cabbae76158cac7fab8c4f81f447.svn-base b/.svn/pristine/be/bede0adc0f93cabbae76158cac7fab8c4f81f447.svn-base new file mode 100644 index 0000000..19f79aa --- /dev/null +++ b/.svn/pristine/be/bede0adc0f93cabbae76158cac7fab8c4f81f447.svn-base @@ -0,0 +1,129 @@ +#include "cLabel.hpp" + +using GUIEngine::cLabel; + +/*static*/ const cString cLabel::sNAME = "label"; +/*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; + +cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + mp_text = new TextTypeEngine::cText(label); + Create(parent, id, label, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLabel::~cLabel() +{ + delete mp_text; + mp_text = nullptr; +} + +///Functions +void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setText(label); +} + +/*virtual*/ void cLabel::Display() +{ + GenerateTexture(); + + m_sprite.setPosition(cWindow::getPosition()); + m_sprite.Draw(); + //cSprite::SaveImage("test.bmp", "xml/"); + cWindow::Display(); +} + +void cLabel::GenerateTexture() +{ + m_sprite.setImage((VideoEngine::cImage**)(&mp_text)); + + m_sprite.setImageArea(mp_text->getWH()); + + + + //this->setTransparent(); + //this->setPosition() +} + +//Sets +void cLabel::setFontColour(const GUIHelpers::RGBA& colour) +{ + mp_text->setColour(colour); +} + +void cLabel::setFontSize(const unsigned long int size) +{ + mp_text->setSize(size); +} + +void cLabel::setText(const cString& text) +{ + mp_text->setText(text); +} + +void cLabel::setFont(const TextTypeEngine::cFont* font) +{ + mp_text->setFont((TextTypeEngine::cFont**)(&font)); +} + +///Gets +const GUIHelpers::RGBA& cLabel::getFontColour() const +{ + return mp_text->getColour(); +} + +const unsigned long int cLabel::getFontSize() const +{ + return mp_text->getSize(); +} + +const TextTypeEngine::cFont* cLabel::getFont() const +{ + return mp_text->getFont(); +} + +const cString& cLabel::getText() const +{ + return mp_text->getText(); +} + +/*virtual*/ const GUIHelpers::eType cLabel::getType() const +{ + return GUIHelpers::eType::CLABEL; +} + +/*virtual*/ const GUIHelpers::RGBA cLabel::getDebugColour() const +{ + return GUIHelpers::GREEN; +} + +/*virtual*/ void cLabel::Resize() +{ + RebuildLayout(this->getLayout()); + cWindow::Resize(); +} + +/*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + //break; + case GUIHelpers::eLayout::WRAP_CONTENT: + long int x = (mp_text->getText().length() * mp_text->getSize()); + GUIHelpers::Size size = { x, 8 }; +// size.x += this->getPadding().x + this->getPadding().w; +// size.y += this->getPadding().y + this->getPadding().z; + this->setSize(size); + break; + } +} \ No newline at end of file diff --git a/.svn/pristine/c4/c48d4bc196222098123a138afe162ac0cfc28f4d.svn-base b/.svn/pristine/c4/c48d4bc196222098123a138afe162ac0cfc28f4d.svn-base new file mode 100644 index 0000000..c605349 --- /dev/null +++ b/.svn/pristine/c4/c48d4bc196222098123a138afe162ac0cfc28f4d.svn-base @@ -0,0 +1,35 @@ +#include "eOptions.hpp" + +using MainMenu::eOptions; + +void MainMenu::operator++(eOptions& option) +{ + switch (option) + { + case Start: + option = Head; + break; + case Head: + option = Quit; + break; + case Quit: + option = Start; + break; + } +} + +void MainMenu::operator--(eOptions& option) +{ + switch (option) + { + case Start: + option = Quit; + break; + case Head: + option = Start; + break; + case Quit: + option = Head; + break; + } +} \ No newline at end of file diff --git a/.svn/pristine/c4/c4dd8681d5a08bf67995a45ca79832612f084467.svn-base b/.svn/pristine/c4/c4dd8681d5a08bf67995a45ca79832612f084467.svn-base new file mode 100644 index 0000000..804b43b --- /dev/null +++ b/.svn/pristine/c4/c4dd8681d5a08bf67995a45ca79832612f084467.svn-base @@ -0,0 +1,144 @@ +#include "cTiming.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TimingEngine::cTiming; +using UtilityEngine::cUtility; + +/*static*/ cTiming* cTiming::sp_inst = nullptr; + +cTiming::cTiming( const unsigned long int ftp /*= 30*/ ) +: m_ftp(ftp), m_rate(1000 / ftp), m_nextTime(0), m_start(SDL_GetTicks()), m_lastTime(0.0f), m_frameTime(0.0f) +{ + Setup(); +} + +cTiming::~cTiming() +{ + CleanUp(); +} + +cTiming& cTiming::operator=( const cTiming& copy ) +{ + if (this != ©) + setFTP(copy.getFTP()); + + return *this; +} + +///Functions +/*static*/ cTiming& cTiming::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTiming(); + return *sp_inst; +} + +/*static*/ void cTiming::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTiming::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if( SDL_Init( SDL_INIT_TIMER ) == 0 ) { + cUtility::Inst().Message("Timer Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize timer. SDL_Init(SDL_INIT_TIMER):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +void cTiming::Setup() +{ + m_nextTime = SDL_GetTicks(); + AddTimeandRate(); +} + +void cTiming::CleanUp() +{} + +void cTiming::Time() +{ + SDL_Delay(TimeLeft()); + AddTimeandRate(); + m_frameTime = FrameTime(); + //m_start = SDL_GetTicks(); +} + +const float/*unsigned long int*/ cTiming::FrameTime() +{ + /*unsigned long int rtn = 0; + unsigned long int end = SDL_GetTicks(); + + rtn = end - m_start; + + m_start = end; + + return rtn;*/ + + /* for keeping track of timing */ + unsigned long int thisTime = SDL_GetTicks(); + + m_lastTime = (float)thisTime - 30; + + + thisTime = SDL_GetTicks(); + return (float)(thisTime - m_lastTime) / m_ftp; +} + +///Sets +void cTiming::setFTP( const unsigned long int ftp /*= 30*/ ) +{ + m_ftp = ftp; + m_rate = 1000 / m_ftp; + Setup(); +} + +///Gets +const unsigned long int cTiming::getFTP() const +{ + return m_ftp; +} + +const bool cTiming::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_TIMER) != 0) { + cUtility::Inst().Message("Timer is initialized"); + rtn = true; + } else + cUtility::Inst().Message("Timer is not initialized."); + + return rtn; +} + +const float cTiming::getFrameTime() const +{ + return m_frameTime; +} + +///Private +///Functions +const unsigned long int cTiming::TimeLeft() +{ + unsigned long int now = SDL_GetTicks(); + + if(m_nextTime <= now) + return 0; + else + return m_nextTime - now; +} + +void cTiming::AddTimeandRate() +{ + m_nextTime += m_rate; +} diff --git a/.svn/pristine/c5/c581a652e6148e534f8754830e1b5d90835a6622.svn-base b/.svn/pristine/c5/c581a652e6148e534f8754830e1b5d90835a6622.svn-base new file mode 100644 index 0000000..f0b69bf --- /dev/null +++ b/.svn/pristine/c5/c581a652e6148e534f8754830e1b5d90835a6622.svn-base @@ -0,0 +1,46 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +/*virtual*/ void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + cWindow::Create(parent, id, orientation, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set + +///Get + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} + +/*virtual*/ const GUIHelpers::RGBA cLayout::getDebugColour() const +{ + return GUIHelpers::BLUE; +} \ No newline at end of file diff --git a/.svn/pristine/c5/c599a8033394c7c958268b557c66b92989672b42.svn-base b/.svn/pristine/c5/c599a8033394c7c958268b557c66b92989672b42.svn-base new file mode 100644 index 0000000..5ed76bd --- /dev/null +++ b/.svn/pristine/c5/c599a8033394c7c958268b557c66b92989672b42.svn-base @@ -0,0 +1,277 @@ +#include "cSprite.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" + +using VideoEngine::cSprite; +using MathEngine::iVector2; +using MathEngine::iVector4; + +cSprite::cSprite( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: mpp_image(image), mpp_camera(camera) +{ + setPosition(Sint16(xpos), Sint16(ypos)); + + setStartImageArea(Sint16(xarea), Sint16(yarea)); + setEndImageArea(Uint16(warea), Uint16(harea)); +} + +cSprite::cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera /*= nullptr*/ ) +: mpp_image(image), mpp_camera(camera) +{ + setPosition(0, 0); + + setStartImageArea(0, 0); + setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight())); +} + +//cSprite::cSprite( TextTypeEngine::cText** image, VideoEngine::cCamera** camera /*= nullptr*/ ) +/*: mpp_camera(camera) +{ + image; + //VideoEngine::cImage* im = VideoEngine::cImage(*image); + setPosition(0, 0); + + setStartImageArea(0, 0); + setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight())); +}*/ + +cSprite& cSprite::operator=( const cSprite& copy ) +{ + if (this != ©) + { + mpp_image = nullptr; + mpp_camera = nullptr; + + signed long int x = 0; + signed long int y = 0; + + unsigned long int h = 0; + unsigned long int w = 0; + + copy.getPosition(x, y); + setPosition(x, y); + + copy.getStartImageArea(x, y); + copy.getEndImageArea(w, h); + + setStartImageArea(x, y); + setEndImageArea(w, h); + + *mpp_image = copy.getImage(); + *mpp_camera = copy.getCamera(); + } + + return *this; +} + +cSprite::~cSprite() +{ + mpp_image = nullptr; + mpp_camera = nullptr; +} + +///Functions +void cSprite::Draw() +{ + SDL_Texture* texture = (*mpp_image)->getImage(); + + if (mpp_camera != nullptr && *mpp_camera != nullptr) { + CameraDraw(); + //surface = (*mpp_camera)->getCameraView(); + } + + if (mpp_image != nullptr && *mpp_image != nullptr) + cRenderer::Inst().Render( texture, &m_imageArea, &m_position); +} + +void cSprite::CameraDraw() +{ + if ((mpp_image != nullptr) && (mpp_camera != nullptr) && (*mpp_image != nullptr) && (*mpp_camera != nullptr)) + cRenderer::Inst().RenderToTexture((*mpp_image)->getImage(), &m_imageArea, (*mpp_camera)->getCameraView(), &m_position); + //RendererDraw( (*mpp_camera)->getCameraView() ); +} +// +// void cSprite::RendererDraw( SDL_Renderer* rend ) +// { +// cVideo::Instance().RenderToTexture() +// if ((rend != nullptr) && (mpp_image != nullptr) && (*mpp_image != nullptr)) +// Video::Instance().Render((*mpp_image)->getImage(), &m_imageArea, rend, &m_position); +// } + +void cSprite::DefaltDraw() +{ + if (mpp_image != nullptr && *mpp_image != nullptr) + cRenderer::Inst().Render( (*mpp_image)->getImage(), nullptr, nullptr); +} + +void cSprite::AddPosX( const signed long int x ) +{ + m_position.x += Sint16(x); +} + +void cSprite::AddPosY( const signed long int y ) +{ + m_position.y += Sint16(y); +} + +void cSprite::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + if (mpp_image != nullptr && *mpp_image != nullptr) { + SDL_Texture* temp = (*mpp_image)->getImage();//(*mpp_image)->NewImage(this->getImageArea())->getImage(); + + cRenderer::Inst().SaveTexture( temp, fileName, dir ); + } +} + +///Sets +void cSprite::setPosX( const signed long int x ) +{ + setPosition( x, getPosY()); +} + +void cSprite::setPosY( const signed long int y ) +{ + setPosition( getPosX(), y ); +} + +void cSprite::setPosition( const signed long int x, const signed long int y ) +{ + m_position.x = (signed short int)x; + m_position.y = (signed short int)y; + setPositionEnd(); +} + +void cSprite::setPosition( const MathEngine::iVector2& position /*= MathEngine::iVector2(0,0)*/ ) +{ + setPosition(position.x, position.y); +} + +void cSprite::setImageArea( const MathEngine::iVector4& area /*= MathEngine::iVector4(0,0,0,0)*/) +{ + if (area == iVector4(0,0,0,0)) { + setStartImageArea(0,0); + if ((mpp_image != nullptr) && (*mpp_image != nullptr)) + setEndImageArea((*mpp_image)->getWidth(), (*mpp_image)->getHeight()); + } else { + setStartImageArea( area.x, area.y ); + setEndImageArea( area.z, area.w ); + } +} + +/// Top left starting area. +void cSprite::setStartImageArea( const signed long int x, const signed long int y ) +{ + m_imageArea.x = (signed short int)x; + m_imageArea.y = (signed short int)y; +} + +/// Bottom right image ends. +void cSprite::setEndImageArea( const unsigned long int w, const unsigned long int h ) +{ + m_imageArea.w = (unsigned short int)w; + m_imageArea.h = (unsigned short int)h; + + setPositionEnd(); +} + +void cSprite::setImage( VideoEngine::cImage** image ) +{ + mpp_image = image; +} + +void cSprite::setCamera( VideoEngine::cCamera** camera ) +{ + mpp_camera = camera; +} + +///Get's +const signed long int cSprite::getPosX() const +{ + return m_position.x; +} + +const signed long int cSprite::getPosY() const +{ + return m_position.y; +} + +void cSprite::getPosition( signed long int& x, signed long int& y ) const +{ + x = m_position.x; + y = m_position.y; +} + +const MathEngine::iVector4 cSprite::getPosition() const +{ + return iVector4(m_position); +} + +void cSprite::getStartImageArea( signed long int& x, signed long int& y ) const +{ + x = m_imageArea.x; + y = m_imageArea.y; +} + +void cSprite::getEndImageArea( unsigned long int& w, unsigned long int& h ) const +{ + w = m_imageArea.w; + h = m_imageArea.h; +} + +const SDL_Rect& cSprite::getImageArea() const +{ + return m_imageArea; +} + +const unsigned long int cSprite::getWidth() const +{ + return m_imageArea.w; +} + +const unsigned long int cSprite::getHeight() const +{ + return m_imageArea.h; +} + +VideoEngine::cImage* cSprite::getImage() const +{ + if (mpp_image == nullptr) + return nullptr; + else + return (*mpp_image); +} + +VideoEngine::cCamera* cSprite::getCamera() const +{ + if (mpp_camera == nullptr) + return nullptr; + else + return (*mpp_camera); +} + +const bool cSprite::getImageSetup() const +{ + bool rtn = false; + if ((mpp_image != nullptr) && (*mpp_image != nullptr)) + rtn = true; + + return rtn; +} + +const bool cSprite::getCameraSetup() const +{ + bool rtn = false; + if ((mpp_camera != nullptr) && (*mpp_camera != nullptr)) + rtn = true; + + return rtn; +} + +void cSprite::setPositionEnd() +{ + m_position.w = m_imageArea.w; + m_position.h = m_imageArea.h; +} \ No newline at end of file diff --git a/.svn/pristine/c6/c611e78d7eb27cd241c872feffb680813bd9b108.svn-base b/.svn/pristine/c6/c611e78d7eb27cd241c872feffb680813bd9b108.svn-base new file mode 100644 index 0000000..545f6ab --- /dev/null +++ b/.svn/pristine/c6/c611e78d7eb27cd241c872feffb680813bd9b108.svn-base @@ -0,0 +1,56 @@ +/* Copyright (C) 2016 Richard W. Allen +Program Name: SDL Pong C++ +Author: Richard W. Allen +Version: V1.0 +Date Started: August 24, 2016 +Date End: +Webpage: http://www.richardallenonline.com +IDE: Visual Studio 2015 +Compiler: C\C++ 2014 +Langage: C++ +License: GNU GENERAL PUBLIC LICENSE Version 2 +see license.txt for details + +*/ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "UTest/UTest.hpp" + +#include "UtilityEngineTest/StringTest.hpp" + +using UtilityEngine::cString; + +int main(int argc, char *argv[]) +{ + argc, argv; + + printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n"); + + + UTest u("cVideo"); + + printf("\nTesting cVideo\n"); + + //TrooperEngineCore::cTrooperEngineCore& core = TrooperEngineCore::cTrooperEngineCore::Inst(); + VideoEngine::cVideo& video = VideoEngine::cVideo::Inst(); + //core.VideoInit(); + + if (!video.Setup()) { + printf("database failed to open.\n"); + return 1; + } + + u.test("Video Initialize open", !video.IsInit()); + + StringTest(); + + + system("pause"); + + return 0; +} \ No newline at end of file diff --git a/.svn/pristine/c8/c805968f4ce54cf4fb0f91d9fca629a063b74aa9.svn-base b/.svn/pristine/c8/c805968f4ce54cf4fb0f91d9fca629a063b74aa9.svn-base new file mode 100644 index 0000000..b69db20 --- /dev/null +++ b/.svn/pristine/c8/c805968f4ce54cf4fb0f91d9fca629a063b74aa9.svn-base @@ -0,0 +1,219 @@ +#include "GUIXMLTest.hpp" + +void GUIXMLTest() +{ + // cString + printf("\nTesting GUI XML Test -----\n\n"); + + GUIXMLDefaultTest(); + + GUIXMLPositionTest(); + + GUIXMLAlignTest(); +} + +void GUIXMLDefaultTest() +{ + UTest u("GUI XML Default"); + + LoadFile("GUIXMLDefaultTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 100, 100 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 5, 5 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + + sets.pos = { 56, 96 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLPositionTest() +{ + UTest u("GUI XML Position"); + + LoadFile("GUIXMLPositionTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 20, 20 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 120, 120 }; + + cWindowTest("Panel", u, panel, sets); + + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 25, 25 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + sets.pos = { 76, 116 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLAlignTest() +{ + UTest u("GUI XML Default"); + + LoadFile("GUIXMLAlignTest.xml", true); + + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 400, 400 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 200, 200 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 5, 5 }; + sets.size = { 390, 390 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + switch (label->getAlign()) { + case GUIHelpers::eAlign::LEFT: + sets.pos = { 10, 178 }; + sets.center = { 74, 182 }; + break; + case GUIHelpers::eAlign::CENTER: + sets.pos = { 136, 178 }; + sets.center = { 200, 182 }; + break; + case GUIHelpers::eAlign::RIGHT: + sets.pos = { 262, 178 }; + sets.center = { 326, 182 }; + break; + } + + sets.size = { 128, 8 }; + + + cWindowTest("Label 'Hello world One'", u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[1]; + + + switch (label->getAlign()) { + case GUIHelpers::eAlign::LEFT: + sets.pos = { 10, 196 }; + sets.center = { 74, 200 }; + break; + case GUIHelpers::eAlign::CENTER: + sets.pos = { 128, 196 }; + sets.center = { 200, 200 }; + break; + case GUIHelpers::eAlign::RIGHT: + sets.pos = { 246, 196 }; + sets.center = { 318, 200 }; + break; + } + + sets.size = { 144, 8 }; + + cWindowTest("Label 'Hello world Two'", u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[2]; + + + /*sets.pos = { 132, 214 };*/ + switch (label->getAlign()) { + case GUIHelpers::eAlign::LEFT: + sets.pos = { 10, 214 }; + sets.center = { 78, 218 }; + break; + case GUIHelpers::eAlign::CENTER: + sets.pos = { 136, 178 }; + sets.center = { 200, 218 }; + break; + case GUIHelpers::eAlign::RIGHT: + sets.pos = { 254, 214 }; + sets.center = { 322, 218 }; + break; + } + sets.size = { 136, 8 }; + + cWindowTest("Label 'Hello world Three'", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void LoadFile( const cString& filename, const bool show /*= false*/ ) +{ + GUIEngine::cGUI::Inst().Delete(); + GUIEngine::cGUI::Inst().Initialize(filename, "xml/"); + printf(cString("\nUsing " + filename + " file.\n").c_str()); + + if (show == true) + GUIEngine::cGUI::Inst().Display(); +} + +void cWindowTest(const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets) +{ + cWindowTest(msg, u, win, sets.pos, sets.size, sets.pad, sets.center); +} + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center) +{ + u.test(msg + " Position", win->getPosition() == pos); + + u.test(msg + " Size", win->getSize(false) == size); + + u.test(msg + " Padding", win->getPadding() == pad); + + u.test(msg + " Center", win->getCenter() == center); +} \ No newline at end of file diff --git a/.svn/pristine/c8/c88b2b6245f6a3d0514806d6790a42ceadab1357.svn-base b/.svn/pristine/c8/c88b2b6245f6a3d0514806d6790a42ceadab1357.svn-base new file mode 100644 index 0000000..167b497 --- /dev/null +++ b/.svn/pristine/c8/c88b2b6245f6a3d0514806d6790a42ceadab1357.svn-base @@ -0,0 +1,46 @@ +#ifndef _CGFX_HPP_ +#define _CGFX_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace EXPORT_FROM_MYDLL FXEngine { + /* Singleton */ + class cGFX + { + private: + cGFX(); + ~cGFX(); + + public: + static cGFX& Inst(); + static void Delete(); + + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Box( const SDL_Rect& rect, const SDL_Colour& colour ) const; + void Box( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const; + void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const; + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const; + void Rectangle (const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + + private: + static cGFX* sp_inst;// = nullptr + };/// END CLASS DEFINITION cGFX +}/// END NAMESPACE DEFINITION FXEngine +#endif/// END IFNDEF _CGFX_HPP_ \ No newline at end of file diff --git a/.svn/pristine/ca/caf92073b86f9e79c7879be7250a1bf0e6cb485c.svn-base b/.svn/pristine/ca/caf92073b86f9e79c7879be7250a1bf0e6cb485c.svn-base new file mode 100644 index 0000000..3047bfe --- /dev/null +++ b/.svn/pristine/ca/caf92073b86f9e79c7879be7250a1bf0e6cb485c.svn-base @@ -0,0 +1,97 @@ +/* Copyright (C) 2016 Richard W. Allen +Program Name: SDL Pong C++ +Author: Richard W. Allen +Version: V1.0 +Date Started: August 24, 2016 +Date End: +Webpage: http://www.richardallenonline.com +IDE: Visual Studio 2015 +Compiler: C\C++ 2014 +Langage: C++ +License: GNU GENERAL PUBLIC LICENSE Version 2 +see license.txt for details + +*/ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "UTest/UTest.hpp" + +#include "UtilityEngineTest/StringTest.hpp" +#include "GUIEngineTest/GUIXMLTest.hpp" + +using UtilityEngine::cString; + +void CleanUp() +{ + TrooperEngineCore::cTrooperEngineCore::Delete(); +} + +int main(int argc, char *argv[]) +{ + argc, argv; + + printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n"); + + + UTest u("cVideo"); + + printf("\nTesting cVideo\n"); + + TrooperEngineCore::cTrooperEngineCore::Inst(); + VideoEngine::cVideo& video = VideoEngine::cVideo::Inst(); + video.Initialize(); + //core.VideoInit(); + + if (!video.Setup()) { + printf("database failed to open.\n"); + return 1; + } + + u.test("Video Initialize open", video.IsInit()); + + StringTest(); + + GUIXMLTest(); + + + UTest::OverAllReport(); + SDL_Event event; + bool run = true; + while (run) { + VideoEngine::cVideo::Inst().Display(); + while (SDL_PollEvent(&event)) { + /* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */ + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_SPACE: + run = false; + break; + case SDLK_RETURN: + VideoEngine::cVideo::Inst().ScreenShot("test.bmp"); + default: + break; + } + break; + + case SDL_KEYUP: + printf("Key release detected\n"); + break; + + default: + break; + } + } + } + + CleanUp(); + + //system("pause"); + + return 0; +} \ No newline at end of file diff --git a/.svn/pristine/cb/cb8694e4cfe1aace4b79c4334b5a55502cedadf4.svn-base b/.svn/pristine/cb/cb8694e4cfe1aace4b79c4334b5a55502cedadf4.svn-base new file mode 100644 index 0000000..c8442a6 --- /dev/null +++ b/.svn/pristine/cb/cb8694e4cfe1aace4b79c4334b5a55502cedadf4.svn-base @@ -0,0 +1,126 @@ +#include "cAudio.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using AudioEngine::cAudio; +using UtilityEngine::cUtility; + +/*static*/ cAudio* cAudio::sp_inst = nullptr; + +cAudio::cAudio() +: m_rate(22050), m_format(AUDIO_S16), m_channels(2), m_buffers(4096) +{} + +cAudio::~cAudio() +{ + CleanUp(); +} + +//Functions +/*static*/ cAudio& cAudio::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cAudio(); + return *sp_inst; +} + +/*static*/ void cAudio::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cAudio::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) { + cUtility::Inst().Message("Audio initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Audio. SDL_InitSubSystem(SDL_INIT_AUDIO):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +void cAudio::Setup() +{ + CleanUp(); + + if (Mix_OpenAudio(m_rate, Uint16(m_format), m_channels, m_buffers) < 0) + cUtility::Inst().Message("Could not setup mixer. Mix_OpenAudio():", __AT__, cUtility::eTypeSDL::MIXER); + + //Mix_AllocateChannels(number_of_mixing_channels); +} + +void cAudio::CleanUp() +{ + Mix_CloseAudio(); +} + +void cAudio::SoundPlay() +{ + +} +void cAudio::MusicPlay() +{ + +} + +///Sets +void cAudio::setRate( const unsigned long int rate /*= 22050*/ ) +{ + m_rate = rate; +} + +void cAudio::setFormat( const unsigned long int format /*= AUDIO_S16*/ ) +{ + m_format = format; +} + +void cAudio::setChannels( const unsigned long int channels /*= 2*/ ) +{ + m_channels = channels; +} + +void cAudio::setBuffers( const unsigned long int buffers /*= 4096*/ ) +{ + m_buffers = buffers; +} + +///Gets +const bool cAudio::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_AUDIO) != 0) { + cUtility::Inst().Message("Audio is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Audio is not initialized."); + + return rtn; +} + +const unsigned long int cAudio::getRate() const +{ + return m_rate; +} + +const unsigned long int cAudio::getFormat() const +{ + return m_format; +} + +const unsigned long int cAudio::getChannels() const +{ + return m_channels; +} + +const unsigned long int cAudio::getBuffers() const +{ + return m_buffers; +} \ No newline at end of file diff --git a/.svn/pristine/cc/cc923539b3a5970ad8b2d819d6bb3026bd60df17.svn-base b/.svn/pristine/cc/cc923539b3a5970ad8b2d819d6bb3026bd60df17.svn-base new file mode 100644 index 0000000..66f2d34 --- /dev/null +++ b/.svn/pristine/cc/cc923539b3a5970ad8b2d819d6bb3026bd60df17.svn-base @@ -0,0 +1,34 @@ +#ifndef __GUIXMLTEST__ +#define __GUIXMLTEST__ + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using UtilityEngine::cString; + +struct Settings +{ + GUIHelpers::Position pos; + GUIHelpers::Size size; + GUIHelpers::Padding pad; + GUIHelpers::Position center; +}; + +void GUIXMLTest(); + +void GUIXMLDefaultTest(); + +void GUIXMLPositionTest(); + +void GUIXMLAlignTest(); + +void LoadFile( const cString& filename, const bool show = false ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center ); + +#endif // __GUIXMLTEST__ diff --git a/.svn/pristine/cd/cd391b7a80c7347df016a491eaec766d605ac881.svn-base b/.svn/pristine/cd/cd391b7a80c7347df016a491eaec766d605ac881.svn-base new file mode 100644 index 0000000..9cf188f --- /dev/null +++ b/.svn/pristine/cd/cd391b7a80c7347df016a491eaec766d605ac881.svn-base @@ -0,0 +1,41 @@ +#include "cObject.hpp" + +#include "../cGUI.hpp" + +using GUIHelpers::cObject; + +cObject::cObject( const signed int id ) + : m_id(id) +{ + //GUIEngine::cGUI::Inst().AddObject(this); +} + +/*virtual*/ cObject::~cObject() +{} + +bool cObject::operator == (const cObject& other) +{ + if (m_id == other.getID()) + return true; + else + return false; +} + +///Functions + +///Sets +const void cObject::setID( const signed int id ) +{ + m_id = id; +} + +///Gets +const signed int cObject::getID() const +{ + return m_id; +} + +/*virtual*/ const GUIHelpers::eType cObject::getType() const +{ + return GUIHelpers::eType::COBJECT; +} \ No newline at end of file diff --git a/.svn/pristine/cd/cd9d6fad8984aa9a4a73df39e500e1b1bfc7d07f.svn-base b/.svn/pristine/cd/cd9d6fad8984aa9a4a73df39e500e1b1bfc7d07f.svn-base new file mode 100644 index 0000000..dcba3c3 --- /dev/null +++ b/.svn/pristine/cd/cd9d6fad8984aa9a4a73df39e500e1b1bfc7d07f.svn-base @@ -0,0 +1,71 @@ +#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::RBGA& 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::RBGA 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; +} + +void CreateLabel() +{} + +void GenerateImage() +{} + +void GenerateTexture() +{} \ No newline at end of file diff --git a/.svn/pristine/ce/ce3341442e6b38454cba452256b19ec8d4f325ca.svn-base b/.svn/pristine/ce/ce3341442e6b38454cba452256b19ec8d4f325ca.svn-base new file mode 100644 index 0000000..0b92b76 --- /dev/null +++ b/.svn/pristine/ce/ce3341442e6b38454cba452256b19ec8d4f325ca.svn-base @@ -0,0 +1,34 @@ +#include "cMenuUp.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuUp; + +cMenuUp::cMenuUp( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuUp::cMenuUp( const cMenuUp& copy ) +{}*/ + +cMenuUp::~cMenuUp() +{} + +///Funtions +void cMenuUp::KeyPress() +{ +} + +void cMenuUp::KeyUP() +{ +} + +void cMenuUp::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionUp(); +} \ No newline at end of file diff --git a/.svn/pristine/d1/d1799740cc5d19d2223361ac54ddf6369340f5a4.svn-base b/.svn/pristine/d1/d1799740cc5d19d2223361ac54ddf6369340f5a4.svn-base new file mode 100644 index 0000000..837060c --- /dev/null +++ b/.svn/pristine/d1/d1799740cc5d19d2223361ac54ddf6369340f5a4.svn-base @@ -0,0 +1,112 @@ +#ifndef _CIMAGE_HPP_ +#define _CIMAGE_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cImage + { + public: + cImage( const cString& dir = "", const cString& filename = "", const bool transparent = false, + const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255, + const unsigned char translevel = 255); + cImage( SDL_Surface* surface ); + cImage( SDL_Texture* texture ); + /* Copy constructor */ + cImage( const cImage& copy, const bool surfaceCopy = true ); + ~cImage(); + + /* Saves the Image to a BMP file */ + void SaveImage( const cString& fileName, const cString& dir = "" ); + /* Creates a New Image based on input */ + const cImage* NewImage( SDL_Rect& area ) const; + + ///Sets + /* Sets the Directory of the image */ + void setDir( const cString& dir ); + /* Sets the File Name of the image */ + void setFileName( const cString& filename ); + /* Sets the File Name and the Directory of the image */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + + /* Sets Transparent on if set to true */ + void setTransparent( const bool transparent = true ); + /* Sets the colour to be made transparent */ + void setColourTrans( const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255 ); + /* Sets the level of the transparent 255 = clear, 0 = solid */ + void setLevelTrans( const unsigned char translevel = 255 ); + + ///Gets + /* Gets a pointer to the SDL_Surface */ + SDL_Surface* getSurface() const; + /* Gets a pointer to the SDL_Texture */ + SDL_Texture* getImage() const; + /* Gets the width of the image */ + const unsigned long int getWidth() const; + /* Gets the Height of the image */ + const unsigned long int getHeight() const; + /* Gets the Width and Height of the image */ + const SDL_Rect getWH() const; + /* Gets the Width and Height of the image */ + void getWH( unsigned long int& w, unsigned long int& h ) const; + + /* Gets the Directory of the image */ + const cString getDir() const; + /* Gets the File Name of the image */ + const cString getFileName() const; + + /* Gets return true if transparent on false if off */ + const bool getTransparent() const; + /* Gets return the colour to be made transparent */ + void getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const; + /* Gets the transparent red colour */ + const unsigned char getRedTrans() const; + /* Gets the transparent blue colour */ + const unsigned char getBlueTrans() const; + /* Gets the transparent green colour */ + const unsigned char getGreenTrans() const; + /* Gets the transparent level 255 = clear, 0 = solid */ + const unsigned char getLevelTrans() const; + + protected: + /* Protected so only derived class can access. *. + /* Sets the image to surface */ + void setImage( SDL_Surface* surface ); + void setImage( SDL_Texture* texture ); + + private: + ///Functions + void TransparentSetup(); + virtual void LoadImage(); //cFont over rides this + void UnloadImage(); + + private: + ///Variables + SDL_Texture* mp_texture;// = nullptr + + cString m_dir;// = "" + cString m_fileName;// = "" + + //char m_dir[255]; + //char m_fileName[255]; + + bool m_transparent;// = false + + unsigned char m_transRed;// = 0 + unsigned char m_transBlue;// = 0 + unsigned char m_transGreen;// = 255 + + unsigned char m_transLevel;// = 255 + };/// END CLASS DEFINITION cImage +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CIMAGE_HPP_ diff --git a/.svn/pristine/d3/d3138726ec8c6cd86d49a03e6279cf5f8253f57b.svn-base b/.svn/pristine/d3/d3138726ec8c6cd86d49a03e6279cf5f8253f57b.svn-base new file mode 100644 index 0000000..0585838 --- /dev/null +++ b/.svn/pristine/d3/d3138726ec8c6cd86d49a03e6279cf5f8253f57b.svn-base @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/d4/d4382f5fe23ed241791d0e13293060acba930785.svn-base b/.svn/pristine/d4/d4382f5fe23ed241791d0e13293060acba930785.svn-base new file mode 100644 index 0000000..3fe5950 --- /dev/null +++ b/.svn/pristine/d4/d4382f5fe23ed241791d0e13293060acba930785.svn-base @@ -0,0 +1,147 @@ +#include "cTrooperEngineCore.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" +#include "../AudioEngine/cAudio.hpp" +#include "../InputEngine/cInput.hpp" + +#include "../TimingEngine/cTiming.hpp" + +#include "../TextTypeEngine/cTextType.hpp" + +#include "../MathEngine/cRandom.hpp" + +#include "../EventEngine/cEvent.hpp" + +#include "../UtilityEngine/cUtility.hpp" + +using TrooperEngineCore::cTrooperEngineCore; + +/*static*/ cTrooperEngineCore* cTrooperEngineCore::sp_inst = nullptr; + +cTrooperEngineCore::cTrooperEngineCore() +{ +} + +cTrooperEngineCore::~cTrooperEngineCore() +{ + CleanUp(); + VideoEngine::cVideo::Delete(); + AudioEngine::cAudio::Delete(); + InputEngine::cInput::Delete(); + TimingEngine::cTiming::Delete(); + + TextTypeEngine::cTextType::Delete(); + MathEngine::cRandom::Delete(); + EventEngine::cEvent::Delete(); + SDL_Quit(); + UtilityEngine::cUtility::Inst().Message("SDL shut down!"); + UtilityEngine::cUtility::Delete(); +} + +///Functions +/*static*/ const char* cTrooperEngineCore::Version() +{ + return __TROOPERENGINE__VERSION; +} + +/*static*/ cTrooperEngineCore& cTrooperEngineCore::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTrooperEngineCore(); + return *sp_inst; +} + +/*static*/ void cTrooperEngineCore::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTrooperEngineCore::VideoInit() +{ + return VideoEngine::cVideo::Inst().Initialize(); +} + +const bool cTrooperEngineCore::AudioInit() +{ + return AudioEngine::cAudio::Inst().Initialize(); +} + +const bool cTrooperEngineCore::InputInit() +{ + return true; +} + +const bool cTrooperEngineCore::JoystickInit() +{ + return InputEngine::cInput::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TimerInit() +{ + return TimingEngine::cTiming::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TextTypeInit() +{ + return TextTypeEngine::cTextType::Inst().Initialize(); +} + +const bool cTrooperEngineCore::EventInit() +{ + return EventEngine::cEvent::Inst().Initialize(); +} + +/* Print lib versions */ +void cTrooperEngineCore::PrintSDLVersion() const +{ + UtilityEngine::cUtility::Inst().PrintVersion(); +} + +void cTrooperEngineCore::CleanUp() +{ + VideoEngine::cVideo::Inst().CleanUp(); + AudioEngine::cAudio::Inst().CleanUp(); + TimingEngine::cTiming::Inst().CleanUp(); + TextTypeEngine::cTextType::Inst().CleanUp(); + InputEngine::cInput::Inst().CleanUp(); + EventEngine::cEvent::Inst().CleanUp(); +} + +///Gets +const bool cTrooperEngineCore::getVideo() const +{ + return VideoEngine::cVideo::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getAudio() const +{ + return AudioEngine::cAudio::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getInput() const +{ + return InputEngine::cInput::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getJoystick() const +{ + return false; +} + +const bool cTrooperEngineCore::getTimer() const +{ + return TimingEngine::cTiming::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getText() const +{ + return TextTypeEngine::cTextType::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getEvent() const +{ + return EventEngine::cEvent::Inst().IsInit(); +} + diff --git a/.svn/pristine/d4/d4fdde78461d12c99b5a9b8c8bc302ccfbb20d39.svn-base b/.svn/pristine/d4/d4fdde78461d12c99b5a9b8c8bc302ccfbb20d39.svn-base new file mode 100644 index 0000000..6b56716 --- /dev/null +++ b/.svn/pristine/d4/d4fdde78461d12c99b5a9b8c8bc302ccfbb20d39.svn-base @@ -0,0 +1,32 @@ +/* Copyright (C) 2010 Richard W. Allen + Program Name: SDL Pong C++ + Author: Richard W. Allen + Version: V1.0 + Date Started: August 24, 2009 + Date End: + Webpage: http://www.richardallenonline.com + IDE: Visual Studio 2010 + Compiler: C\C++ 2010 + Langage: C++ + License: GNU GENERAL PUBLIC LICENSE Version 2 + see license.txt for details + + SDL Pong C++ Copyright (C) 2010 Richard W. Allen DEATH VALLEY + Comes with ABSOLUTELY NO WARRANTY; + SDL Pong C++ is licensed under the GNU GENERAL PUBLIC LICENSE Version 2. + for details see the license.txt include with this program. +*/ + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "../Game/PongStart/cPongStart.hpp" + +int main(int argc, char *argv[]) +{ + argc, argv; + + PongStart::cPongStart pong; + pong.Main(); + return 0; +} \ No newline at end of file diff --git a/.svn/pristine/d5/d50e6b1b7367fb2e0365274fdaa7960062c3f6d5.svn-base b/.svn/pristine/d5/d50e6b1b7367fb2e0365274fdaa7960062c3f6d5.svn-base new file mode 100644 index 0000000..35ab0e7 --- /dev/null +++ b/.svn/pristine/d5/d50e6b1b7367fb2e0365274fdaa7960062c3f6d5.svn-base @@ -0,0 +1,159 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + UTest + Win32 + + + UTest + x64 + + + + {9225E043-EE77-43AA-A140-C9C2F85B1013} + TrooperEngineTest + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + v140 + + + v140 + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + true + $(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + true + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + Console + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.svn/pristine/d7/d77100a265b09e43652658864f083d017a5a460e.svn-base b/.svn/pristine/d7/d77100a265b09e43652658864f083d017a5a460e.svn-base new file mode 100644 index 0000000..14daae4 --- /dev/null +++ b/.svn/pristine/d7/d77100a265b09e43652658864f083d017a5a460e.svn-base @@ -0,0 +1,233 @@ +#include "cXMLoader.hpp" + + +/*** Custom Header Files ***/ +#include "../../UtilityEngine/cUtility.hpp" + +#include "../cGUI.hpp" +#include "../cLayout.hpp" + +using GUIHelpers::cXMLoader; + +using UtilityEngine::cUtility; + +using tinyxml2::XMLDocument; +using tinyxml2::XMLNode; +using tinyxml2::XMLVisitor; +using tinyxml2::XMLElement; + +using tinyxml2::XMLError; + +/*static*/ cXMLoader* cXMLoader::sp_inst = nullptr; + +cXMLoader::cXMLoader() +{ + +} + +cXMLoader::~cXMLoader() +{ + +} + +//PUBLIC +///Functions +/*static*/ cXMLoader& cXMLoader::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cXMLoader(); + return *sp_inst; +} + +/*static*/ void cXMLoader::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cXMLoader::Load( const cString& filename, const cString& dir /*= ""*/ ) +{ + cString file = dir + filename; + XMLDocument doc; + + if (doc.LoadFile(file.c_str()) != XMLError::XML_NO_ERROR) { + cUtility::Inst().Message("Could not load file. " + file + " Error='" + doc.ErrorName() + "'."); + } else { + XMLNode* node = doc.FirstChildElement("GUI"); + + if (node == nullptr) { + cUtility::Inst().Message("No GUI tag found."); + } else { + GetNode(node->ToElement()); + } + } + +} + +void cXMLoader::GetNode( tinyxml2::XMLElement* element, GUIEngine::cWindow* parent /*= nullptr*/) +{ + if (element != nullptr){ + cString name = element->Name(); + GUIEngine::cWindow* tmp = nullptr; + if (name == "Layout") + tmp = LayoutBuild(element, parent); + if (name == "Label") + tmp = LabelBuild(element, parent); + tinyxml2::XMLElement* child = element->FirstChildElement(); + if (child != nullptr) + GetNode(child, tmp); + + tinyxml2::XMLElement* sibling = element->NextSiblingElement(); + if (sibling != nullptr) + GetNode(sibling, parent); + + if ((parent == nullptr) && (tmp != nullptr)) + tmp->Resize(); + } +} + +const char* cXMLoader::GetAttribute(const tinyxml2::XMLElement* element, const cString& attribute) const +{ + const char* rtn = element->Attribute(attribute.c_str()); + if (rtn == nullptr) { + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element->Value() + ">"); + rtn = ""; + } + return rtn; +} + +GUIEngine::cLayout* cXMLoader::LayoutBuild( tinyxml2::XMLElement* element, GUIEngine::cWindow* parent) +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + + GUIEngine::cLayout* rtn = new GUIEngine::cLayout(parent, id, orientation, align, layout, pos, size, pad); + + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLabel* cXMLoader::LabelBuild(tinyxml2::XMLElement* element, GUIEngine::cWindow* parent) +{ + signed long int id = getID(element); + //GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + cString txt = getText(element); + + GUIEngine::cLabel* rtn = new GUIEngine::cLabel(parent, id, txt, align, layout, pos, size, pad); + + return rtn; +} + +const signed long int cXMLoader::getID(tinyxml2::XMLElement* element) +{ + cString rtn = GetAttribute(element, "id"); + return rtn.ToInt(); +} + +const GUIHelpers::eOrientation cXMLoader::getOrientation( tinyxml2::XMLElement* element ) +{ + GUIHelpers::eOrientation rtn = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + + cString str = GetAttribute(element, "orientation"); + + if (str == "none") + rtn = GUIHelpers::eOrientation::NONE; + if (str == "horizontal") + rtn = GUIHelpers::eOrientation::HORIZONTAL; + if (str == "vertical") + rtn = GUIHelpers::eOrientation::VERTICAL; + + return rtn; +} + +const GUIHelpers::eAlign cXMLoader::getAlign(tinyxml2::XMLElement* element) +{ + GUIHelpers::eAlign rtn = GUIHelpers::eAlign::DEFAULT_ALIGN; + + cString str = GetAttribute(element, "align"); + + if (str == "center") + rtn = GUIHelpers::eAlign::CENTER; + if (str == "top") + rtn = GUIHelpers::eAlign::TOP; + if (str == "right") + rtn = GUIHelpers::eAlign::RIGHT; + if (str == "bottom") + rtn = GUIHelpers::eAlign::BOTTOM; + if (str == "left") + rtn = GUIHelpers::eAlign::LEFT; + + return rtn; +} + +const GUIHelpers::eLayout cXMLoader::getLayout(tinyxml2::XMLElement* element) +{ + GUIHelpers::eLayout rtn = GUIHelpers::eLayout::DEFAULT_LAYOUT; + + cString str = GetAttribute(element, "layout"); + + if (str == "fill_parent") + rtn = GUIHelpers::eLayout::FILL_PARENT; + if (str == "match_parent") + rtn = GUIHelpers::eLayout::MATCH_PARENT; + if (str == "wrap_content") + rtn = GUIHelpers::eLayout::WRAP_CONTENT; + + return rtn; +} + +const GUIHelpers::Position cXMLoader::getPosition(tinyxml2::XMLElement* element) +{ + GUIHelpers::Position rtn = { 0, 0 }; + + /*cString str = GetAttribute(element, "position");*/ + + return rtn; +} + +const GUIHelpers::Size cXMLoader::getSize(tinyxml2::XMLElement* element) +{ + GUIHelpers::Size rtn = { 0, 0 }; + + /*cString str = GetAttribute(element, "position");*/ + + return rtn; +} + +const GUIHelpers::Padding cXMLoader::getPadding(tinyxml2::XMLElement* element) +{ + GUIHelpers::Padding rtn = { -1, -1, -1, -1 }; + + cString str = GetAttribute(element, "padding"); + + if (str != "") { + std::vector strV = str.split(","); + + rtn.x = strV[0].ToInt(); + rtn.y = strV[1].ToInt(); + rtn.w = strV[2].ToInt(); + rtn.z = strV[3].ToInt(); + } + + return rtn; +} + +const cString cXMLoader::getText(tinyxml2::XMLElement* element) +{ + return GetAttribute(element, "text"); +} \ No newline at end of file diff --git a/.svn/pristine/d8/d80ef86b188cfe2f5dbe8346ff8793673a6688f1.svn-base b/.svn/pristine/d8/d80ef86b188cfe2f5dbe8346ff8793673a6688f1.svn-base new file mode 100644 index 0000000..445331a --- /dev/null +++ b/.svn/pristine/d8/d80ef86b188cfe2f5dbe8346ff8793673a6688f1.svn-base @@ -0,0 +1,32 @@ +#ifndef _CRANDOM_HPP_ +#define _CRANDOM_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cRandom + { + private: + cRandom(); + ~cRandom(); + + public: + ///Functions + static cRandom& Inst(); + static void Delete(); + + const bool Setup() const; + + const unsigned long int Rand( const unsigned long int max, const unsigned long int min = 0 ) const; + const float Rand( const float max, const float min = 0.0f ) const; + + private: + static cRandom* sp_inst;// = nullptr + };/// END CLASS DEFINITION cRandom +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _CRANDOM_HPP_ \ No newline at end of file diff --git a/.svn/pristine/d8/d83732d4d8ea60cfa445678a1c1722b1b9bf5db1.svn-base b/.svn/pristine/d8/d83732d4d8ea60cfa445678a1c1722b1b9bf5db1.svn-base new file mode 100644 index 0000000..cb3e0fb --- /dev/null +++ b/.svn/pristine/d8/d83732d4d8ea60cfa445678a1c1722b1b9bf5db1.svn-base @@ -0,0 +1,10 @@ +#include "cJoystick.hpp" + +using InputEngine::cJoystick; + +cJoystick::cJoystick() +{} + +cJoystick::~cJoystick() +{} + diff --git a/.svn/pristine/d9/d9bc1959b0e8bca44548d589712515ddb57eed06.svn-base b/.svn/pristine/d9/d9bc1959b0e8bca44548d589712515ddb57eed06.svn-base new file mode 100644 index 0000000..af19498 --- /dev/null +++ b/.svn/pristine/d9/d9bc1959b0e8bca44548d589712515ddb57eed06.svn-base @@ -0,0 +1,47 @@ +#include "cRandom.hpp" + +/*** ANSI C Header Files ***/ +#include +#include + +using MathEngine::cRandom; + +/*static*/ cRandom* cRandom::sp_inst = nullptr; + +cRandom::cRandom() +{ + Setup(); +} + +cRandom::~cRandom() +{} + +/*static*/ cRandom& cRandom::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cRandom(); + return *sp_inst; +} + +/*static*/ void cRandom::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cRandom::Setup() const +{ + bool rtn = false; + srand((unsigned int)time(nullptr)); + return rtn = true; +} + +const unsigned long int cRandom::Rand( const unsigned long int max, const unsigned long int min /*= 0*/ ) const +{ + return (unsigned long int)rand() % max + min; +} + +const float cRandom::Rand( const float max, const float min /*= 0.0f*/ ) const +{ + return (float)((max - min) * rand()/(float)RAND_MAX + min); +} \ No newline at end of file diff --git a/.svn/pristine/d9/d9fc002a0c0d52f1594afe9008daf10fae5a84e7.svn-base b/.svn/pristine/d9/d9fc002a0c0d52f1594afe9008daf10fae5a84e7.svn-base new file mode 100644 index 0000000..e2a196e Binary files /dev/null and b/.svn/pristine/d9/d9fc002a0c0d52f1594afe9008daf10fae5a84e7.svn-base differ diff --git a/.svn/pristine/db/db457793665e5b356ef30b681e5482a8b7cb2f39.svn-base b/.svn/pristine/db/db457793665e5b356ef30b681e5482a8b7cb2f39.svn-base new file mode 100644 index 0000000..1103008 --- /dev/null +++ b/.svn/pristine/db/db457793665e5b356ef30b681e5482a8b7cb2f39.svn-base @@ -0,0 +1,432 @@ +#include "cWindow.hpp" + + +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RGBA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; +/*static*/ GUIHelpers::eOrientation cWindow::sORIENTATION = GUIHelpers::eOrientation::NONE; + +/*static*/ unsigned long int cWindow::sDebug = 0; + +cWindow::cWindow(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) + : cObject(id) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cWindow::~cWindow() +{ + m_children.clear(); +} + +/*virtual*/ void cWindow::Create(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + mp_parent = parent; + cObject::setID(id); + setOrientation(orientation); + setAlign(align); + setLayout(layout); + m_pos = pos; + m_size = size; + setPadding(padding); + m_name = name; +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } + + DebugDisplay(); +} + +///Functions +const bool cWindow::Inside(const MathEngine::iVector2& location) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild( cWindow* obj ) +{ + m_children.push_back(obj); +} + +void cWindow::RemoveChild( cWindow* obj ) +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + //break out of the for loop + break; + } + } +} + +///Sets +void cWindow::setOrientation( const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/ ) +{ + if (orientation == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + m_orientation = cWindow::sORIENTATION; + else + m_orientation = orientation; +} + +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= sALIGN*/ ) +{ + if (align == GUIHelpers::eAlign::DEFAULT_ALIGN) + m_align = cWindow::sALIGN; + else + m_align = align; +} + +void cWindow::setLayout( const GUIHelpers::eLayout& layout /*= sLAYOUT*/ ) +{ + if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT) + m_layout = cWindow::sLAYOUT; + else + m_layout = layout; +} + +void cWindow::setPosition( const GUIHelpers::Position& pos /*= POSITION*/ ) +{ + m_pos = pos; +} + +void cWindow::setSize( const GUIHelpers::Size& size /*= SIZE*/ ) +{ + m_size = size; +} + +void cWindow::setPadding( const GUIHelpers::Padding& padding /*= PADDING*/ ) +{ + if (padding.x < 0) + m_padding = cWindow::sPADDING; + else + m_padding = padding; +} + +void cWindow::setContentSize( const GUIHelpers::Size& content ) +{ + m_content = content; +} + +void cWindow::setName( const cString& name /*= NAME*/ ) +{ + m_name = name; +} + +void cWindow::setParent( cWindow* parent ) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::eOrientation& cWindow::getOrientation() const +{ + return m_orientation; +} + +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position& cWindow::getPosition() const +{ + return m_pos; +} + +const GUIHelpers::Size& cWindow::getSize() const +{ + return m_size; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + GUIHelpers::Size mySize = { 0, 0 }; + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + mySize = mp_parent->getSize(); + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + } else { + mySize = GUIEngine::cGUI::Inst().DisplayArea(); + } + + m_size = mySize; + + for (it = m_children.begin(); it < m_children.end(); it++) { + //if ((*it)->getLayout() != GUIHelpers::eLayout::WRAP_CONTENT) + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + GUIHelpers::Padding pad = { 0, 0, 0, 0 }; + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + pad = (*it)->getPadding(); + size.x += pad.x + pad.w; + size.y += pad.y + pad.z; + //mySize += size; + AddSize(size.x, size.y, mySize); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ +// if (mp_parent != nullptr) +// RebuildPos(); + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } + + if (this->getType() == GUIHelpers::eType::CLAYOUT) { + GUIHelpers::Position ourSet = { 0, 0 }; + GUIHelpers::Size totalSize = { 0, 0 }; + GUIHelpers::Position totalCenter = { 0, 0 }; + GUIHelpers::Position prtCenter = { (m_size.x / 2), (m_size.y / 2) }; + for (it = m_children.begin(); it < m_children.end(); it++) { + GUIHelpers::Size size = (*it)->getSize(); + GUIHelpers::Padding pad = (*it)->getPadding(); + + totalSize += size; + totalSize.x += pad.x + pad.w; + totalSize.y += pad.y + pad.z; + } + totalCenter.x = totalSize.x / 2; + totalCenter.y = totalSize.y / 2; + + ourSet.x = prtCenter.x - totalCenter.x; + ourSet.y = prtCenter.y - totalCenter.y; + + GUIHelpers::Position posSet = ourSet; + GUIHelpers::Position posNext = posSet; + for (it = m_children.begin(); it < m_children.end(); it++) { + posSet = posNext; + GUIHelpers::Padding pad = (*it)->getPadding(); + GUIHelpers::Size size = (*it)->getSize(); + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + posSet.x += pad.x; + posSet.y = (pad.y - pad.z - (size.y / 2)) + prtCenter.y; + + posNext = posSet; + + posNext.x += size.x + pad.w; + //posNext.y = ourSet.y; + } else { + posSet.x = (pad.x - pad.w - (size.x / 2)) + prtCenter.x; + posSet.y += pad.y; + + posNext = posSet; + + //posNext.x = ourSet.x; + posNext.y += size.y + pad.z; + } + + (*it)->setPosition(posSet); + } + + } + +} + +/*virtual*/ void cWindow::RebuildPos() +{ + GUIHelpers::Position prtPos = mp_parent->getPosition(); + GUIHelpers::Size prtSize = mp_parent->getSize(); + GUIHelpers::Position prtCenter = { (prtSize.x / 2), (prtSize.y / 2) }; + + GUIHelpers::Size ourSize = this->getSize(); + GUIHelpers::Position ourCenter = { (ourSize.x / 2), (ourSize.y / 2) }; + + GUIHelpers::Position ourSet = { 0, 0 }; + + ourSet.x = prtCenter.x - ourCenter.x; + ourSet.y = prtCenter.y - ourCenter.y; +// +// switch (this->getAlign()) { +// case GUIHelpers::eAlign::CENTER: +// ourSet.x = prtCenter.x - ourCenter.x; +// ourSet.y = prtCenter.y - ourCenter.y; +// break; +// case GUIHelpers::eAlign::TOP: +// ourSet.x = prtCenter.x - ourCenter.x; +// ourSet.y = prtPos.y + m_padding.y; +// break; +// case GUIHelpers::eAlign::RIGHT: +// ourSet.x = prtSize.x - ourSize.x - m_padding.w; +// ourSet.y = prtCenter.y - ourCenter.y; +// break; +// case GUIHelpers::eAlign::BOTTOM: +// ourSet.x = prtCenter.x - ourCenter.x; +// ourSet.y = prtSize.y - ourSize.y - m_padding.z; +// break; +// case GUIHelpers::eAlign::LEFT: +// ourSet.x = prtPos.x + m_padding.x; +// ourSet.y = prtCenter.y - ourCenter.y; +// break; +// } + this->setPosition(ourSet); +} + +/*virtual*/ const GUIHelpers::RGBA cWindow::getDebugColour() const +{ + return GUIHelpers::WHITE; +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} + +//private +void cWindow::AddSize(int x, int y, GUIHelpers::Size& mySize) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo > largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} + +void cWindow::DebugDisplay() const +{ + if (sDebug > 0) { + SDL_Rect rect; + rect.x = m_pos.x; + rect.y = m_pos.y; + rect.w = m_pos.x + m_size.x; + rect.h = m_pos.y + m_size.y; + + SDL_Rect strPos = rect; + strPos.x += (m_size.x / 2); + strPos.y += (m_size.y / 2); + + + GUIHelpers::RGBA colour = getDebugColour(); + FXEngine::cGFX::Inst().Pixel(strPos.x, strPos.y, colour); + + cString str = ""; + str.format("X: %d Y: %d", strPos.x, strPos.y); + FXEngine::cGFX::Inst().StringDefault(str, { strPos.x + 2, strPos.y + 2, 0, 0 }, colour); + + if (sDebug > 1) { + SDL_Rect typePos = { 2, 2, 0, 0 }; + cString type; + switch (getType()) { + case GUIHelpers::eType::CLAYOUT: + type = "Layout"; + break; + case GUIHelpers::eType::CLABEL: + typePos = { -10, -10, 0, 0 }; + type = "Label"; + break; + } + + typePos.x += m_pos.x; + typePos.y += m_pos.y; + + FXEngine::cGFX::Inst().StringDefault(type, typePos, colour); + } + + FXEngine::cGFX::Inst().Rectangle(rect, colour); + } +} \ No newline at end of file diff --git a/.svn/pristine/dc/dc0defac9896bf963b6770feed8f2df868b0f951.svn-base b/.svn/pristine/dc/dc0defac9896bf963b6770feed8f2df868b0f951.svn-base new file mode 100644 index 0000000..6649ebd --- /dev/null +++ b/.svn/pristine/dc/dc0defac9896bf963b6770feed8f2df868b0f951.svn-base @@ -0,0 +1,37 @@ +#include "msunix.hpp" + +int vasprintf(char ** ret, const char * format, va_list ap) +{ + int len; + char *buffer; + + len = _vscprintf(format, ap) + 1; + buffer = (char *) malloc(len * sizeof(char)); + if (!buffer) return 0; + vsprintf_s(buffer, len, format, ap); + *ret = buffer; + return len -1; +} + +/*int snprintf(char * str, size_t size, const char * format, ...) +{ + va_list args; + size_t len; + + va_start(args, format); + len = _vscprintf(format, args) + 1; + if (len > size) len = size; + vsprintf_s(str, len, format, args); + return len - 1; +}*/ + +int setenv(const char *name, const char *value, int overwrite) +{ + int errcode = 0; + if(!overwrite) { + size_t envsize = 0; + errcode = getenv_s(&envsize, NULL, 0, name); + if(errcode || envsize) return errcode; + } + return _putenv_s(name, value); +} diff --git a/.svn/pristine/dc/dceb22c4fc2c40d0c6f43754c575e5a65d001f34.svn-base b/.svn/pristine/dc/dceb22c4fc2c40d0c6f43754c575e5a65d001f34.svn-base new file mode 100644 index 0000000..5928b77 --- /dev/null +++ b/.svn/pristine/dc/dceb22c4fc2c40d0c6f43754c575e5a65d001f34.svn-base @@ -0,0 +1,172 @@ +#include "cPongStart.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../MainMenu/Input/cMenuUp.hpp" +#include "../MainMenu/Input/cMenuDown.hpp" +#include "../MainMenu/Input/cMenuSelect.hpp" +#include "../MainMenu/Input/cEsc.hpp" +#include "../MainMenu/cBuildMainMenu.hpp" + + +#include "../Equipment/cCourt.hpp" +#include "../Equipment/cPaddle.hpp" + +#include "../Equipment/Input/cPlayerUp.hpp" +#include "../Equipment/Input/cPlayerDown.hpp" +#include "../Equipment/Input/cQuitButton.hpp" + +using PongStart::cPongStart; + +cPongStart::cPongStart() +: mp_menu(nullptr), m_option(MainMenu::Start) +{ + TrooperEngineCore::cTrooperEngineCore& core = TrooperEngineCore::cTrooperEngineCore::Inst(); + core.TimerInit(); + core.VideoInit(); + core.AudioInit(); + core.TextTypeInit(); + + if (core.getVideo()) + VideoEngine::cVideo::Inst().Setup(); + if (core.getAudio()) + AudioEngine::cAudio::Inst().Setup(); + if (core.getTimer()) + TimingEngine::cTiming::Inst().Setup(); + if (core.getText()) + TextTypeEngine::cTextType::Inst().Setup(); + + TrooperEngineCore::cTrooperEngineCore::Inst().PrintSDLVersion(); +} + +cPongStart::~cPongStart() +{ + TrooperEngineCore::cTrooperEngineCore::Inst().Delete(); +} + +void cPongStart::Main() +{ + //GUIHelpers::cTexture* temp = new GUIHelpers::cTexture(); + //SDL_Rect rec = {0,0,25,25}; + //temp->GenerateTexture(rec); + //TextTypeEngine::cText* txt = new TextTypeEngine::cText("Hello akjfdklajfdlkjfkljdfalkajdlkfjakljflkjafdlkjflkajdlkfjalkdjflkajdlkfajlkfdjafkljdfkljasdfalk"); + //VideoEngine::cSprite* sprt = new VideoEngine::cSprite((VideoEngine::cImage**)(&txt)); + //sprt->Draw(); +// GUIEngine::cButton* but = new GUIEngine::cButton(0, "button2"); +// but->Draw(); + + //GUIEngine::cWindow* win = new GUIEngine::cWindow(); + GUIEngine::cGUI::Inst().Initialize("GUI.xml", "xml/"); + GUIEngine::cGUI::Inst().Display(); +// GUIEngine::cLayout* lay = new GUIEngine::cLayout(); +// GUIEngine::cLabel* lbl = new GUIEngine::cLabel(lay, 22, "Hello world"); +// +// lbl->setAlign(GUIHelpers::eAlign::RIGHT); +// //lbl->Resize(); +// lay->Resize(); +// lay->Display(); + + + //GUIEngine::cGUI::Inst().AddObject(win); + + //GUIEngine::cGUI::Inst().Display(); + + //while (true) { + EventEngine::cEvent::Inst().CheckEvents(); + /*SDL_Colour col = { 255, 255, 255, 255}; + SDL_Rect re= { 0, 0, 100, 100}; + FXEngine::cGFX::Inst().RoundedRectangle(re, 4, col);*/ + VideoEngine::cVideo::Inst().Display(); + //break; + //} + system("pause"); + /*MainMenu(); + switch (m_option) + { + case MainMenu::Start: + Start(); + break; + case MainMenu::Head: + HeadtoHead(); + break; + case MainMenu::Quit: + default: + Quit(); + break; + }*/ +} + +///private +void cPongStart::MainMenu() +{ + MainMenu::cBuildMainMenu temp; + mp_menu = temp.ReadXML(); + + Input::cMenuUp* menuup = new Input::cMenuUp(SDLK_a, &mp_menu); + Input::cMenuDown* menudown = new Input::cMenuDown(SDLK_z, &mp_menu); + Input::cMenuSelect* menuselect = new Input::cMenuSelect(SDLK_x, &mp_menu); + Input::cEsc* esc = new Input::cEsc(SDLK_ESCAPE, &mp_menu); + + InputEngine::cKeyboard* menukeyboard = new InputEngine::cKeyboard("MenuKeyboard"); + + menukeyboard->AddKey(menuup); + menukeyboard->AddKey(menudown); + menukeyboard->AddKey(menuselect); + menukeyboard->AddKey(esc); + + InputEngine::cInput::Inst().AddKeyboard(menukeyboard); + + m_option = mp_menu->ShowMenu(); +} + +void cPongStart::Start() +{ + VideoEngine::cImage* p_image = new VideoEngine::cImage("img/", "Equipment.png", true, 0, 0, 0); + VideoEngine::cImage* p_court = new VideoEngine::cImage("img/", "Court.png"); + + Equipment::cBall* ball = new Equipment::cBall(400, 400, 17, 65, 12, 12, &p_image); + Equipment::cPaddle* paddle = new Equipment::cPaddle(0, 0, 0, 0, 16, 77, &p_image); + Equipment::cPaddle* paddle2 = new Equipment::cPaddle(0, 200, 29, 0, 16, 77, &p_image); + + Equipment::cCourt* court = new Equipment::cCourt(ball, paddle, paddle2, &p_court); + + InputEngine::cTextInput text;// = new InputEngine::cTextInput(); + + TimingEngine::cTiming::Inst().setFTP(30); + + while (court->isPause() == false) { + ball->Move(); + paddle->Move(); + paddle2->Move(); + + court->CheckCollision(); + + court->Draw(); + + ball->Draw(); + paddle->Draw(); + paddle2->Draw(); + + TimingEngine::cTiming::Inst().Time(); + VideoEngine::cVideo::Inst().Display(); + } + + delete p_image; + p_image = nullptr; + + delete p_court; + p_court; + + delete court; + court = nullptr; +} + +void cPongStart::HeadtoHead() +{ +} + +void cPongStart::Quit() +{ +} \ No newline at end of file diff --git a/.svn/pristine/dd/dd782d6ce8d2c027ee84ad3a48ccb0efb448fcb7.svn-base b/.svn/pristine/dd/dd782d6ce8d2c027ee84ad3a48ccb0efb448fcb7.svn-base new file mode 100644 index 0000000..3447c0c --- /dev/null +++ b/.svn/pristine/dd/dd782d6ce8d2c027ee84ad3a48ccb0efb448fcb7.svn-base @@ -0,0 +1,9 @@ + + + + + + diff --git a/.svn/pristine/dd/ddf39ad2bc4d715b049c3c77af03061e56ab723f.svn-base b/.svn/pristine/dd/ddf39ad2bc4d715b049c3c77af03061e56ab723f.svn-base new file mode 100644 index 0000000..c3a83a3 --- /dev/null +++ b/.svn/pristine/dd/ddf39ad2bc4d715b049c3c77af03061e56ab723f.svn-base @@ -0,0 +1,23 @@ +#include "cQuitButton.hpp" + +using Input::cQuitButton; + +cQuitButton::cQuitButton( SDL_Keycode key, Equipment::cCourt** court ) +: cKey( key ), mpp_court(court) +{} + +cQuitButton::~cQuitButton() +{} + +///Funtions +void cQuitButton::KeyPress() +{} + +void cQuitButton::KeyUP() +{} + +void cQuitButton::KeyDown() +{ + if (mpp_court != nullptr && *mpp_court != nullptr) + (*mpp_court)->Quit(); +} \ No newline at end of file diff --git a/.svn/pristine/de/de1167ba7403d259f972409a9df69e884a592612.svn-base b/.svn/pristine/de/de1167ba7403d259f972409a9df69e884a592612.svn-base new file mode 100644 index 0000000..76f25a2 --- /dev/null +++ b/.svn/pristine/de/de1167ba7403d259f972409a9df69e884a592612.svn-base @@ -0,0 +1,245 @@ +#include "cRenderer.hpp" + +/*** Custom Header Files ***/ +#include "cVideo.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cRenderer; +using VideoEngine::cVideo; +using UtilityEngine::cUtility; + +/*static*/ cRenderer* cRenderer::sp_inst = nullptr; + +//private: +cRenderer::cRenderer() +{ + Setup(); +} + +cRenderer::~cRenderer() +{ + CleanUp(); +} + +//public: +///Functions +/*static*/ cRenderer& cRenderer::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cRenderer(); + return *sp_inst; +} + +/*static*/ void cRenderer::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cRenderer::Setup() +{ + bool rtn = false; + if (cVideo::Inst().IsInit() == false) + cUtility::Inst().Message("Unable to setup until SDL_Video is initialized."); + else { + mp_renderer = cVideo::Inst().CreateRender(); + if (mp_renderer != nullptr) + rtn = true; + } + return rtn; +} + +void cRenderer::CleanUp() +{ + SDL_DestroyRenderer(mp_renderer); + mp_renderer = nullptr; +} + +void cRenderer::Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + cRenderer::Render(texture, srcrect, mp_renderer, dstrect); +} + +void cRenderer::Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + SDL_Texture* texture = SurfaceToTexture(surface); + Render( texture, srcrect, dstrect ); + SDL_DestroyTexture(texture); +} + +void cRenderer::Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + if (SDL_BlitSurface(src, srcrect, dst, dstrect) < 0) + cUtility::Inst().Message("Unable to BlitSurface. SDL_BlitSurface():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + src; + srcrect; + dst; + dstrect; + //??????? +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ) +{ + if (SDL_RenderCopy(dst, src, srcrect, dstrect) < 0) + cUtility::Inst().Message("Unable to copy Texture to Renderer. SDL_RenderCopy():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ) +{ + SetRenderTarget(dst); + Render( src, srcrect, dstrect ); + ResetRenderTarget(); +} + +void cRenderer::RenderDrawColor( const SDL_Colour& colour ) +{ + if (SDL_SetRenderDrawColor(mp_renderer, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to set render draw colour. SDL_SetRenderDrawColor():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst /*= nullptr */ ) +{ + SetRenderTarget(dst); + if (SDL_RenderFillRect(mp_renderer, &rect) < 0) + cUtility::Inst().Message("Unable to draw rectangle. SDL_RenderFillRect():", __AT__, cUtility::eTypeSDL::SDL); + ResetRenderTarget(); +} + + +void cRenderer::SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir /*= ""*/ ) +{ + cString temp = dir + fileName; + if (SDL_SaveBMP(surface, temp.c_str()) < 0) + cUtility::Inst().Message("Unable to save Surface. SDL_SaveBMP()", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir /*= ""*/ ) +{ + SDL_Surface* surface = TextureToSurface(texture); + + if (surface != nullptr) + SaveSurface(surface, fileName, dir); + else + cUtility::Inst().Message("Unable to create Surface from Texture. TextureToSurface():", __AT__); + + SDL_FreeSurface(surface); +} + +SDL_Texture* cRenderer::SurfaceToTexture( SDL_Surface* surface ) +{ + SDL_Texture* rtn = nullptr; + rtn = SDL_CreateTextureFromSurface( mp_renderer, surface ); + if ( rtn == nullptr) + cUtility::Inst().Message("Unable to create Texture. SDL_CreateTextureFromSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture ) +{ + SDL_Surface* rtn = nullptr; + + int w = 0; + int h = 0; + + if (SDL_QueryTexture(texture, nullptr, nullptr, &w, &h) < 0) + cUtility::Inst().Message("Unable to Query Texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + rtn = NewSurface(w, h); + + void* srcPixels = nullptr; + int srcPitch = 0; + + //Lock texture for manipulation + if (SDL_LockTexture( texture, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockSurface(rtn)) + cUtility::Inst().Message("Unable to lock surface rtn. SDL_LockSurface():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( rtn->pixels, srcPixels, srcPitch * h ); + + //Unlock texture to update + SDL_UnlockSurface(rtn); + SDL_UnlockTexture( texture ); + + srcPixels = nullptr; + + return rtn; +} + +void cRenderer::CopyTexture( SDL_Texture* src, SDL_Texture* dst ) +{ + void* srcPixels = nullptr; + int srcPitch = 0; + + void* dstPixels = nullptr; + int dstPitch = 0; + + int height = 0; + + if (SDL_QueryTexture( src, nullptr, nullptr, nullptr, &height ) < 0) + cUtility::Inst().Message("Unable to query texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Lock texture for manipulation + if (SDL_LockTexture( src, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture src. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockTexture( dst, nullptr, &dstPixels, &dstPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture dst. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( dstPixels, srcPixels, srcPitch * height ); + + //Unlock texture to update + SDL_UnlockTexture( dst ); + SDL_UnlockTexture( src ); + srcPixels = nullptr; + dstPixels = nullptr; + +} + +SDL_Surface* cRenderer::CopySurface( SDL_Surface* src ) +{ + return SDL_ConvertSurface( src, src->format, src->flags ); +} + +SDL_Surface* cRenderer::NewSurface( const unsigned long int width, const unsigned long int height ) const +{ + SDL_Surface* rtn = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), width, height, cVideo::Inst().getColour(), cVideo::Inst().getRmask(), cVideo::Inst().getGmask(), cVideo::Inst().getBmask(), cVideo::Inst().getAmask()); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create surface. SDL_CreateRGBSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Texture* cRenderer::NewTexture( const unsigned long int width, const unsigned long int height, const unsigned long int access /*= SDL_TEXTUREACCESS_TARGET*/ ) const +{ + SDL_Texture* rtn = SDL_CreateTexture(mp_renderer, SDL_PIXELFORMAT_ABGR8888, access, width, height); + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create texture. SDL_CreateTexture:", __AT__, cUtility::eTypeSDL::SDL); + return rtn; +} + +void cRenderer::SetRenderTarget( SDL_Texture* target /*= nullptr*/ ) +{ + if (SDL_SetRenderTarget(mp_renderer, target) < 0) + cUtility::Inst().Message("Unable to set render target to dst. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::ResetRenderTarget() +{ + if (SDL_SetRenderTarget(mp_renderer, nullptr) < 0) + cUtility::Inst().Message("Unable to set render target to mp_rend. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +SDL_Renderer* cRenderer::getRenderer() +{ + return mp_renderer; +} diff --git a/.svn/pristine/de/deb05994cefcb34f88067c5f20d012ee07ae6689.svn-base b/.svn/pristine/de/deb05994cefcb34f88067c5f20d012ee07ae6689.svn-base new file mode 100644 index 0000000..f8c8776 --- /dev/null +++ b/.svn/pristine/de/deb05994cefcb34f88067c5f20d012ee07ae6689.svn-base @@ -0,0 +1,33 @@ +#ifndef _CPONGSTART_HPP_ +#define _CPONGSTART_HPP_ + +/*** Custom Header Files ***/ +#include "../MainMenu/cMainMenu.hpp" +#include "../MainMenu/eOptions.hpp" + +namespace PongStart { + class cPongStart + { + public: + cPongStart(); + ~cPongStart(); + + ///Functions + /* main loop of the game */ + void Main(); + + private: + void MainMenu(); + + void Start(); + void HeadtoHead(); + void Quit(); + + void MenuKeyboard(); + + private: + MainMenu::cMainMenu* mp_menu; + MainMenu::eOptions m_option; + };/// END CLASS DEFINITION cPongStart +}/// END NAMESPACE DEFINITION PongStart +#endif/// END IFNDEF _CPONGSTART_HPP_ \ No newline at end of file diff --git a/.svn/pristine/df/dfa1c848aab122749331cccffce15fd79ce3500e.svn-base b/.svn/pristine/df/dfa1c848aab122749331cccffce15fd79ce3500e.svn-base new file mode 100644 index 0000000..952421a --- /dev/null +++ b/.svn/pristine/df/dfa1c848aab122749331cccffce15fd79ce3500e.svn-base @@ -0,0 +1,118 @@ +#include "cCamera.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cCamera; +using UtilityEngine::cUtility; + +cCamera::cCamera( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/, + const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ ) +: mp_texture(nullptr) +{ + m_position.x = Sint16(xPos); + m_position.y = Sint16(yPos); + + m_position.w = Uint16(reswidth); + m_position.h = Uint16(reshight); + + CreateCamera(); +} + +cCamera::cCamera( const cCamera& copy ) +{ + m_position.x = Sint16(copy.getXPos()); + m_position.y = Sint16(copy.getYPos()); + + m_position.w = Uint16(copy.getWidthRes()); + m_position.h = Uint16(copy.getHeightRes()); + + setTexture(copy.getTexture()); +} + +cCamera::~cCamera() +{ + DeleteCamera(); +} + +void cCamera::Draw() +{ + cRenderer::Inst().Render(mp_texture, nullptr, &m_position); +} + +void cCamera::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + cRenderer::Inst().SaveTexture(mp_texture, fileName, dir); +} + +///Sets +void cCamera::setXPosandYPos( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/ ) +{ + m_position.x = Sint16(xPos); + m_position.y = Sint16(yPos); + + CreateCamera(); +} + +void cCamera::setResWidthandResHeight( const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ ) +{ + m_position.w = Uint16(reswidth); + m_position.h = Uint16(reshight); + + CreateCamera(); +} + +void cCamera::setTexture( SDL_Texture* texture ) +{ + DeleteCamera(); + CreateCamera(); + + cRenderer::Inst().CopyTexture(texture, mp_texture); +} + +///Gets +const unsigned long int cCamera::getXPos() const +{ + return m_position.x; +} + +const unsigned long int cCamera::getYPos() const +{ + return m_position.y; +} + +const unsigned long int cCamera::getWidthRes() const +{ + return m_position.w; +} + +const unsigned long int cCamera::getHeightRes() const +{ + return m_position.h; +} + +SDL_Texture* cCamera::getCameraView() const +{ + return mp_texture; +} + +SDL_Texture* cCamera::getTexture() const +{ + return mp_texture; +} + +void cCamera::CreateCamera() +{ + DeleteCamera(); + mp_texture = cRenderer::Inst().NewTexture(m_position.w, m_position.h, SDL_TEXTUREACCESS_TARGET); + + if (mp_texture == nullptr) + cUtility::Inst().Message("Unable to create camera.", __AT__); +} + +void cCamera::DeleteCamera() +{ + if (mp_texture != nullptr) + SDL_DestroyTexture(mp_texture); +} \ No newline at end of file diff --git a/.svn/pristine/df/dfa4e36707882c2860bfbb34ce9063fe78c79fdc.svn-base b/.svn/pristine/df/dfa4e36707882c2860bfbb34ce9063fe78c79fdc.svn-base new file mode 100644 index 0000000..31f1ca7 --- /dev/null +++ b/.svn/pristine/df/dfa4e36707882c2860bfbb34ce9063fe78c79fdc.svn-base @@ -0,0 +1,71 @@ +#ifndef _CRENDERER_HPP_ +#define _CRENDERER_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cRenderer + { + private: + cRenderer(); + ~cRenderer(); + + public: + static cRenderer& Inst(); + static void Delete(); + + /* Creates the Renderer */ + const bool Setup(); + /* Uses */ + void CleanUp(); + + void Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ); + + void RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ); + + void RenderDrawColor( const SDL_Colour& colour ); + void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr ); + + void ScreenShot(const cString& filename, const cString& dir = ""); + void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" ); + void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" ); + + SDL_Texture* SurfaceToTexture( SDL_Surface* surface ); + SDL_Surface* TextureToSurface( SDL_Texture* texture ); + + void CopyTexture( SDL_Texture* src, SDL_Texture* dst ); + + SDL_Surface* CopySurface( SDL_Surface* src ); + + SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) const; + SDL_Texture* NewTexture( long int width = -1, long int height = -1, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const; + + void SetRenderTarget( SDL_Texture* target = nullptr ); + void ResetRenderTarget(); + + ///Sets + + ///Gets + SDL_Renderer* getRenderer(); + + private: + SDL_Renderer* mp_renderer; + + static cRenderer* sp_inst;// = nullptr + };/// END CLASS DEFINITION cRenderer +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CRENDERER_HPP_ \ No newline at end of file diff --git a/.svn/pristine/e1/e138bf50de676deac41f320ce4f08abcf6aa9c3f.svn-base b/.svn/pristine/e1/e138bf50de676deac41f320ce4f08abcf6aa9c3f.svn-base new file mode 100644 index 0000000..58bd62b --- /dev/null +++ b/.svn/pristine/e1/e138bf50de676deac41f320ce4f08abcf6aa9c3f.svn-base @@ -0,0 +1,49 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +/*virtual*/ void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + GUIHelpers::eOrientation ori = orientation; + if (ori == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + ori = sORIENTATION; + cWindow::Create(parent, id, ori, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set + +///Get + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} + +/*virtual*/ const GUIHelpers::RGBA cLayout::getDebugColour() const +{ + return GUIHelpers::BLUE; +} \ No newline at end of file diff --git a/.svn/pristine/e1/e1573b039da72679536db2f9a3656fe43a07514f.svn-base b/.svn/pristine/e1/e1573b039da72679536db2f9a3656fe43a07514f.svn-base new file mode 100644 index 0000000..88a0ba2 --- /dev/null +++ b/.svn/pristine/e1/e1573b039da72679536db2f9a3656fe43a07514f.svn-base @@ -0,0 +1,357 @@ + + + + + {785f0a83-5f26-4f52-8607-42d79ef7e4a0} + + + {ce87c954-26c7-497c-a5c1-ca307fa85446} + + + {9447735f-408f-4a4c-896b-3cb056516952} + + + {78ca6e8e-15cd-4c35-a4c7-f718c6f2e517} + + + {a48949b4-948d-4bdb-a48d-a2bb08c05f43} + + + {fb99b84e-7997-4ebd-b3ea-dd0240ce62f6} + + + {98b7ca98-2ed4-4a41-84f2-abcb3fb384aa} + + + {aef9e043-2065-4d89-acae-33d6f5f55958} + + + {59e0e88b-7be3-4b1d-b3ac-6477daa761c8} + + + {4aa00373-6815-4cd3-a1c7-470f34bfa3d9} + + + {74c65105-2ee7-4bb9-8d44-ca75c80e8b9e} + + + {5a07ee53-1695-400c-86b3-c493e8e34417} + + + {839730ba-b9b8-40bc-a0e0-bcb2b16b83f7} + + + {2b72b3ea-71a4-4c02-988e-603172b3eda3} + + + {4a09c4e8-7d59-490d-8049-7a52f0aed3c8} + + + {6d0af3ff-4b2b-4b9c-85a2-c7db41550092} + + + {db4ff7f3-2b38-4f9d-9a92-aed4cb51f0ac} + + + {f6fc613b-8e1a-4df1-aee7-f37382d38981} + + + + + dllExportFiles + + + dllExportFiles + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + dllExportFiles + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\MathEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + \ No newline at end of file diff --git a/.svn/pristine/e1/e1d37f394a269b90d4658836a9533e4461309c32.svn-base b/.svn/pristine/e1/e1d37f394a269b90d4658836a9533e4461309c32.svn-base new file mode 100644 index 0000000..7fea60a --- /dev/null +++ b/.svn/pristine/e1/e1d37f394a269b90d4658836a9533e4461309c32.svn-base @@ -0,0 +1,16 @@ +#ifndef _EBALLSTATE_HPP_ +#define _EBALLSTATE_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace Equipment { + enum eBallState + { + OnCourt, + LeftOffCourt, + RightOffCourt, + Serve + };/// END ENUM DEFINITION eBallState +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _EBALLSTATE_HPP_ \ No newline at end of file diff --git a/.svn/pristine/e2/e2785afa97167625fa5bbfe5058df5fd2e6b6ce9.svn-base b/.svn/pristine/e2/e2785afa97167625fa5bbfe5058df5fd2e6b6ce9.svn-base new file mode 100644 index 0000000..32bd1d0 --- /dev/null +++ b/.svn/pristine/e2/e2785afa97167625fa5bbfe5058df5fd2e6b6ce9.svn-base @@ -0,0 +1,32 @@ +#ifndef _COBJECT_HPP_ +#define _COBJECT_HPP_ + +/*** Custom Header Files ***/ +#include "Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cObject + { + public: + cObject( const signed int id ); + virtual ~cObject(); + + bool operator == (const cObject& other); + + ///Functions + + ///Sets + const void setID( const signed int id ); + + ///Gets + const signed int getID() const; + virtual const GUIHelpers::eType getType() const; + + private: + signed int m_id;// = 0 + };/// END CLASS DEFINITION cObject +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _COBJECT_HPP_ \ No newline at end of file diff --git a/.svn/pristine/e3/e3ccc4a9af6badaac845123ac00530c3371d604b.svn-base b/.svn/pristine/e3/e3ccc4a9af6badaac845123ac00530c3371d604b.svn-base new file mode 100644 index 0000000..7c15178 --- /dev/null +++ b/.svn/pristine/e3/e3ccc4a9af6badaac845123ac00530c3371d604b.svn-base @@ -0,0 +1,37 @@ +#include "cObject.hpp" + +#include "../cGUI.hpp" + +using GUIHelpers::cObject; + +cObject::cObject( const signed int id ) + : m_id(id) +{ + //GUIEngine::cGUI::Inst().AddObject(this); +} + +/*virtual*/ cObject::~cObject() +{} + +bool cObject::operator == (const cObject& other) +{ + if (m_id == other.getID()) + return true; + else + return false; +} + +///Functions + +///Sets + +///Gets +const signed int cObject::getID() const +{ + return m_id; +} + +/*virtual*/ const GUIHelpers::eType cObject::getType() const +{ + return GUIHelpers::eType::COBJECT; +} \ No newline at end of file diff --git a/.svn/pristine/e3/e3e51ceebcf4250344503d04a1777c2dd632c595.svn-base b/.svn/pristine/e3/e3e51ceebcf4250344503d04a1777c2dd632c595.svn-base new file mode 100644 index 0000000..84dfc60 --- /dev/null +++ b/.svn/pristine/e3/e3e51ceebcf4250344503d04a1777c2dd632c595.svn-base @@ -0,0 +1,264 @@ +#include "cVideo.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cVideo; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cVideo* cVideo::sp_inst = nullptr; + +cVideo::cVideo() +: m_xPos(100), m_yPos(100), m_width(640), m_height(480), m_colour(32), + m_hardwareVideo(false), m_fullscreen(false), m_vsync(false), + m_videoSettings(SDL_RENDERER_SOFTWARE), mp_window(nullptr), +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + m_rmask(0xff000000), + m_gmask(0x00ff0000), + m_bmask(0x0000ff00), + m_amask(0x000000ff) +#else + m_rmask(0x000000ff), + m_gmask(0x0000ff00), + m_bmask(0x00ff0000), + m_amask(0xff000000) +#endif +{} + +cVideo::~cVideo() +{ + CleanUp(); +} + +///Functions +/*static*/ cVideo& cVideo::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cVideo(); + return *sp_inst; +} + +/*static*/ void cVideo::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cVideo::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) { + cUtility::Inst().Message("Video Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Video. SDL_InitSubSystem():", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +const bool cVideo::Setup() +{ + bool rtn = false; + CleanUp(); + VideoSettings(); + + mp_window = SDL_CreateWindow("Hello World!", 100, 100, m_width, m_height, SDL_WINDOW_SHOWN); + if (mp_window == nullptr) + cUtility::Inst().Message("Unable to set Window. SDL_CreateWindow():", __AT__, cUtility::eTypeSDL::SDL); + else + rtn = true; + return rtn; +} + +void cVideo::CleanUp() +{ + SDL_DestroyWindow(mp_window); + mp_window = nullptr; +} + +void cVideo::Display() +{ + SDL_RenderPresent(cRenderer::Inst().getRenderer()); +} + +SDL_Renderer* cVideo::CreateRender() +{ + SDL_Renderer* rtn = nullptr; + if (mp_window != nullptr) + rtn = SDL_CreateRenderer(mp_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to set Renderer. SDL_CreateRenderer():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + + +void cVideo::VideoSettings() +{ + m_videoSettings = 0; + + if (m_hardwareVideo == true) + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_ACCELERATED); + if (m_vsync == true) + m_videoSettings = (m_videoSettings | SDL_RENDERER_PRESENTVSYNC); + } + else + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_SOFTWARE); + m_vsync = false; + } + + if (m_fullscreen == true) + m_videoSettings = (m_videoSettings | SDL_WINDOW_FULLSCREEN); +} + +///Set's +void cVideo::setWidth( const unsigned long int width /*= 640*/ ) +{ + m_width = width; +} + +void cVideo::setHeight( const unsigned long int height /*= 480*/ ) +{ + m_height = height; +} + +void cVideo::setColour( const unsigned long int colour /*= 32*/ ) +{ + m_colour = colour; +} + +void cVideo::setCaption( const cString& caption /*= ""*/ ) +{ + if (mp_window != nullptr) + SDL_SetWindowTitle(mp_window, caption.c_str()); + else + cUtility::Inst().Message("No window to set caption to."); +} + +void cVideo::setHardwareVideo( const bool hardware /*= false*/ ) +{ + m_hardwareVideo = hardware; + VideoSettings(); +} + +void cVideo::setFullScreen( const bool fullscreen /*= false*/ ) +{ + m_fullscreen = fullscreen; + VideoSettings(); +} + +void cVideo::setVSync( const bool vsync /*= false*/ ) +{ + m_vsync = vsync; + VideoSettings(); +} + +void cVideo::setDisplayMode( const SDL_DisplayMode& mode ) +{ + if (SDL_SetWindowDisplayMode(mp_window, &mode) < 0) + cUtility::Inst().Message("Unable to set display mode. SDL_SetWindowDisplayMode()", __AT__, cUtility::eTypeSDL::SDL); +} + +///Gets +const bool cVideo::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_VIDEO) != 0) { + cUtility::Inst().Message("Video is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Video is not initialized."); + + return rtn; +} + +const unsigned long int cVideo::getWidth() const +{ + return m_width; +} + +const unsigned long int cVideo::getHeight() const +{ + return m_height; +} + +const unsigned long int cVideo::getColour() const +{ + return m_colour; +} + +const cString cVideo::getCaption() const +{ + cString rtn = ""; + + if (mp_window != nullptr) + rtn = SDL_GetWindowTitle(mp_window); + else + cUtility::Inst().Message("No window to get caption from."); + + return rtn; +} + +const bool cVideo::getHardwareVideo() const +{ + return m_hardwareVideo; +} + +const bool cVideo::getFullScreen() const +{ + return m_fullscreen; +} + +const bool cVideo::getVSync() const +{ + return m_vsync; +} + +const unsigned long int cVideo::getVideoSettings() const +{ + return m_videoSettings; +} + +SDL_Window* cVideo::getWindow() +{ + return mp_window; +} + +SDL_DisplayMode cVideo::getDisplayMode() const +{ + SDL_DisplayMode display; + + if (SDL_GetWindowDisplayMode(mp_window, &display) < 0 ) + cUtility::Inst().Message("Could not get display mode. SDL_GetWindowDisplayMode():", __AT__, cUtility::eTypeSDL::SDL); + + return display; +} + +const unsigned long int cVideo::getRmask() const +{ + return m_rmask; +} + +const unsigned long int cVideo::getGmask() const +{ + return m_gmask; +} + +const unsigned long int cVideo::getBmask() const +{ + return m_bmask; +} + +const unsigned long int cVideo::getAmask() const +{ + return m_amask; +} diff --git a/.svn/pristine/e5/e55ed53e24b76284b8b3bc873ae19f677558e3eb.svn-base b/.svn/pristine/e5/e55ed53e24b76284b8b3bc873ae19f677558e3eb.svn-base new file mode 100644 index 0000000..252477e --- /dev/null +++ b/.svn/pristine/e5/e55ed53e24b76284b8b3bc873ae19f677558e3eb.svn-base @@ -0,0 +1,71 @@ +#ifndef _CCAMERA_HPP_ +#define _CCAMERA_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cCamera + { + public: + cCamera( const signed long int xPos = 0, const signed long int yPos = 0, + const unsigned long int reswidth = 640, const unsigned long int reshight = 480 ); + /* Copy constructor */ + cCamera( const cCamera& copy ); + ~cCamera(); + + /* Draws the camera on the video buffer */ + void Draw(); + + /* Saves the Camera Image to a BMP file */ + void SaveImage( const cString& fileName, const cString& dir = "" ); + + ///Sets + /* Sets the x and y position on the video buffer */ + void setXPosandYPos( const signed long int xPos = 0, const signed long int yPos = 0 ); + /* Sets the width and height the camera should be */ + void setResWidthandResHeight( const unsigned long int reswidth = 640, const unsigned long int reshight = 480 ); + /* Sets the Surface */ + void setTexture( SDL_Texture* texture ); + + ///Gets + /* Gets the x position of the camera */ + const unsigned long int getXPos() const; + /* Gets the y position of the camera */ + const unsigned long int getYPos() const; + + /* Gets the width of the camera */ + const unsigned long int getWidthRes() const; + /* Gets the height of the camera */ + const unsigned long int getHeightRes() const; + + /* Gets the SDL_Renderer of the camera */ + SDL_Texture* getCameraView() const; + + /* Gets the Surface of the camera */ + SDL_Texture* getTexture() const; + + private: + ///Functions + void CreateCamera(); + void DeleteCamera(); + + private: + ///Variables + SDL_Rect m_position; + + SDL_Texture* mp_texture;// = nullptr + + //std::vector m_sprites; + //LinkList::cLList m_sprites; + };/// END CLASS DEFINITION cCamera +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CCAMERA_HPP_ diff --git a/.svn/pristine/e5/e5e06ccc04fcca878717eb620425bd4a4857f9af.svn-base b/.svn/pristine/e5/e5e06ccc04fcca878717eb620425bd4a4857f9af.svn-base new file mode 100644 index 0000000..c55bb6b --- /dev/null +++ b/.svn/pristine/e5/e5e06ccc04fcca878717eb620425bd4a4857f9af.svn-base @@ -0,0 +1,35 @@ +#ifndef __GUIXMLTEST__ +#define __GUIXMLTEST__ + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using UtilityEngine::cString; + +struct Settings +{ + GUIHelpers::Position pos; + GUIHelpers::Size size; + GUIHelpers::Padding pad; + GUIHelpers::Position center; +}; + +void GUIXMLTest(); + +void GUIXMLDefaultTest(); + +void GUIXMLPositionTest(); + +void GUIXMLAlignTest( const GUIHelpers::eAlign one = GUIHelpers::eAlign::DEFAULT_ALIGN, const GUIHelpers::eAlign two = GUIHelpers::eAlign::DEFAULT_ALIGN, + const GUIHelpers::eAlign three = GUIHelpers::eAlign::DEFAULT_ALIGN, const GUIHelpers::eOrientation orientation = GUIHelpers::eOrientation::DEFAULT_ORIENTATION); + +void LoadFile( const cString& filename, const bool show = false ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center ); + +#endif // __GUIXMLTEST__ diff --git a/.svn/pristine/e6/e62d92d991fff7938d0e45a8b3e1312149d52ef6.svn-base b/.svn/pristine/e6/e62d92d991fff7938d0e45a8b3e1312149d52ef6.svn-base new file mode 100644 index 0000000..a01f57d --- /dev/null +++ b/.svn/pristine/e6/e62d92d991fff7938d0e45a8b3e1312149d52ef6.svn-base @@ -0,0 +1,31 @@ +#ifndef _VECTOR3_HPP_ +#define _VECTOR3_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "Vector2.hpp" + +namespace MathEngine { + struct iVector3; + + struct EXPORT_FROM_MYDLL Vector3 : public Vector2 + { + Vector3( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f ); + + Vector3( const SDL_Rect& copy ); + + Vector3& operator=( const SDL_Rect& copy ); + + Vector3( const iVector3& copy ); + + Vector3& operator=( const iVector3& copy ); + + float z; + };/// END STRUCT DEFINITION Vector3 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR3_HPP_ \ No newline at end of file diff --git a/.svn/pristine/e6/e66ae26c9a930a205f18e3f3bccae4c70a1e3ccf.svn-base b/.svn/pristine/e6/e66ae26c9a930a205f18e3f3bccae4c70a1e3ccf.svn-base new file mode 100644 index 0000000..2b539bc --- /dev/null +++ b/.svn/pristine/e6/e66ae26c9a930a205f18e3f3bccae4c70a1e3ccf.svn-base @@ -0,0 +1,71 @@ +#ifndef _CXMLOADER_HPP_ +#define _CXMLOADER_HPP_ + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "GUIUtility.hpp" + +#include "../cWindow.hpp" +#include "../cPanel.hpp" +#include "../cLayout.hpp" +#include "../cLabel.hpp" + +#include "../../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cXMLoader + { + public: + cXMLoader(); + ~cXMLoader(); + + void Load( const cString& filename, const cString& dir = "", GUIEngine::cWindow* parent = nullptr ); + + private: + void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const; + const cString GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const; + + void Include( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + void GUISetup( const tinyxml2::XMLElement& element ) const; + void Default( const tinyxml2::XMLElement& element ); + void Debug( const tinyxml2::XMLElement& element ); + + GUIEngine::cPanel* PanelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cLayout* LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + + const cString getDir( const tinyxml2::XMLElement& element ) const; + const cString getFileName( const tinyxml2::XMLElement& element ) const; + const unsigned long int getDebug( const tinyxml2::XMLElement& element ) const; + const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const; + const signed long int getID( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eOrientation getOrientation( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eAlign getAlign( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eLayout getLayout( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Position getPosition( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Size getSize( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Padding getPadding( const tinyxml2::XMLElement& element ) const; + const cString getText( const tinyxml2::XMLElement& element ) const; + + void LoadDefault() const; + + private: + bool m_loadDef;// = false; + bool m_debugXML; + + GUIHelpers::eOrientation m_orientation;// = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::DEFAULT_ALIGN; + GUIHelpers::eLayout m_layout;// = GUIHelpers::eLayout::DEFAULT_LAYOUT; + GUIHelpers::Position m_pos;// = { -1, -1 }; + GUIHelpers::Size m_size;// = { -1, -1 }; + GUIHelpers::Padding m_pad;// = { -1, -1, -1, -1 }; + };/// END CLASS DEFINITION cXMLoader +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _CXMLOADER_HPP_ diff --git a/.svn/pristine/e7/e7455f0c1c9fe5fb63ff7aa130f78a7af6726737.svn-base b/.svn/pristine/e7/e7455f0c1c9fe5fb63ff7aa130f78a7af6726737.svn-base new file mode 100644 index 0000000..cadbcf4 --- /dev/null +++ b/.svn/pristine/e7/e7455f0c1c9fe5fb63ff7aa130f78a7af6726737.svn-base @@ -0,0 +1,138 @@ +#ifndef _CVIDEO_HPP_ +#define _CVIDEO_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cVideo + { + private: + cVideo(); + ~cVideo(); + + public: + ///Functions + static cVideo& Inst(); + static void Delete(); + + const bool Initialize() const; + + /* Creates the cVideo's mp_buff and mp_screen surfaces */ + const bool Setup(); + /* Uses SDL_Freesurface to delete cVideo's mp_buff and mp_screen surfaces */ + void CleanUp(); + + /* Used to Display the new frame */ + void Display(); + + /* ScreenShot */ + void ScreenShot( const cString& filename, const cString& dir = "" ); + + SDL_Renderer* CreateRender(); + + ///Sets + /* Sets the videos width resolution */ + void setWidth( const unsigned long int width = 640 ); + /* Sets the videos height resolution */ + void setHeight( const unsigned long int height = 480 ); + /* Sets the videos colour depth in bits */ + void setColour( const unsigned long int colour = 32 ); + /* Sets the caption on the displayed window */ + void setCaption( const cString& caption = "" ); + + /* Sets video to use hardware surfaces if true other wise software surfaces are used */ + void setHardwareVideo( const bool hardware = false ); + /* Sets the video to full screen if true other wise a window is used */ + void setFullScreen( const bool fullscreen = false ); + /* Sets the video to use double buffering other wise no buffering is used */ + void setVSync( const bool vsync = false ); + + void setDisplayMode( const SDL_DisplayMode& mode ); + + ///Gets + /* Gets return true if video was initialized */ + const bool IsInit() const; + /* Gets the videos width resolution */ + const unsigned long int getWidth() const; + /* Gets the videos height resolution */ + const unsigned long int getHeight() const; + /* Gets the videos colour depth in bits */ + const unsigned long int getColour() const; + /* Gets the caption displayed on the window */ + const cString getCaption() const; + + /* Gets returns true if hardware surfaces are being used other wise false is return */ + const bool getHardwareVideo() const; + /* Gets returns true if full screen is being used other wise false is return */ + const bool getFullScreen() const; + /* Gets returns true if Double Buffering is being used other wise false is return */ + const bool getVSync() const; + + /* Gets returns the SDL video flags */ + const unsigned long int getVideoSettings() const; + + /* Gets returns the SDL_Window pointer */ + SDL_Window* getWindow(); + + /* Gets returns the Display Mode */ + SDL_DisplayMode getDisplayMode() const; + + /* Gets returns the Red mask value */ + const unsigned long int getRmask() const; + /* Gets returns the Green mask value */ + const unsigned long int getGmask() const; + /* Gets returns the Blue mask value */ + const unsigned long int getBmask() const; + /* Gets returns the Alpha mask value */ + const unsigned long int getAmask() const; + + private: + ///Functions + void VideoSettings(); + + private: + ///Variables + SDL_Window* mp_window;// = nullptr + //SDL_Renderer* mp_rend;// = nullptr + + unsigned long int m_xPos;// = 100 + unsigned long int m_yPos;// = 100 + unsigned long int m_width;// = 640 + unsigned long int m_height;// = 480 + unsigned long int m_colour;// = 32 + + bool m_hardwareVideo;// = false + bool m_fullscreen;// = false + bool m_vsync;// = false + + unsigned long int m_videoSettings;// = SDL_RENDERER_SOFTWARE + + static cVideo* sp_inst;// = nullptr + + /*SDL interprets each pixel as a 32-bit number, so our masks must depend + on the endianness (byte order) of the machine */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + const unsigned long int m_rmask;// = 0xff000000; + const unsigned long int m_gmask;// = 0x00ff0000; + const unsigned long int m_bmask;// = 0x0000ff00; + const unsigned long int m_amask;// = 0x000000ff; +#else + const unsigned long int m_rmask;// = 0x000000ff; + const unsigned long int m_gmask;// = 0x0000ff00; + const unsigned long int m_bmask;// = 0x00ff0000; + const unsigned long int m_amask;// = 0xff000000; +#endif + };/// END CLASS DEFINITION cVideo +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CVIDEO_HPP_ diff --git a/.svn/pristine/e7/e7f4515c2f7a8cfda2cd0063d7f010511279c224.svn-base b/.svn/pristine/e7/e7f4515c2f7a8cfda2cd0063d7f010511279c224.svn-base new file mode 100644 index 0000000..52c2730 --- /dev/null +++ b/.svn/pristine/e7/e7f4515c2f7a8cfda2cd0063d7f010511279c224.svn-base @@ -0,0 +1,130 @@ +#include "cBuildMainMenu.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +using MainMenu::cBuildMainMenu; +using MainMenu::cMainMenu; +using UtilityEngine::cUtility; + +using tinyxml2::XMLDocument; +using tinyxml2::XMLNode; +using tinyxml2::XMLVisitor; +using tinyxml2::XMLElement; + +cBuildMainMenu::cBuildMainMenu() + : m_ttf(""), m_dir(""), m_lang(""), m_langSettings(""), mp_mainMenu(new cMainMenu()) +{} + +cBuildMainMenu::~cBuildMainMenu() +{} + +///Functions +cMainMenu* cBuildMainMenu::ReadXML() +{ + cString file = "xml/SDLPongCPP.xml"; + XMLDocument doc; + + if ( doc.LoadFile(file.c_str()) == false ) { + //cUtility::Inst().Message("Could not load file." + file + " Error='" + doc.GetErrorStr1 + "'."); + } else { + XMLNode* node = doc.FirstChildElement( "SDLPongCPP" ); + + if (node == nullptr) { + cUtility::Inst().Message("No FirstChildElement( "Settings" ); + if (settingsElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_langSettings = GetAttribute(settingsElement, "lang"); + } + XMLElement* mainmenuElement = node->FirstChildElement( "MainMenu" ); + while (m_langSettings != m_lang) { + if (mainmenuElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_lang = GetAttribute(mainmenuElement, "lang"); + /* if the language is the same as the one specified in the settings we read the menu settings */ + if (m_lang == m_langSettings) { + const char* colour = GetAttribute(mainmenuElement, "colour"); + mp_mainMenu->setColour(IntToSDLColour(HexToInt(colour))); + + const char* selectcolour = GetAttribute(mainmenuElement, "selectcolour"); + mp_mainMenu->setSelectColour(IntToSDLColour(HexToInt(selectcolour))); + + const char* titlecolour = GetAttribute(mainmenuElement, "titlecolour"); + mp_mainMenu->setTitleColour(IntToSDLColour(HexToInt(titlecolour))); + + m_ttf = GetAttribute(mainmenuElement, "ttf"); + + const char* soundeffect = GetAttribute(mainmenuElement, "soundeffect"); + + m_dir = GetAttribute(mainmenuElement, "dir"); + + if (m_ttf != "") + mp_mainMenu->setFont(m_dir + "ttf/", m_ttf); + + mp_mainMenu->setSound(m_dir + "snd/", cString(soundeffect)); + + GetOptions( mainmenuElement, "Title" ); + GetOptions( mainmenuElement, "SinglePlayer" ); + GetOptions( mainmenuElement, "HeadToHead" ); + GetOptions( mainmenuElement, "Quit" ); + } else { + mainmenuElement = mainmenuElement->NextSiblingElement(); + } + }/* end else */ + }/* end while */ + } + } + return mp_mainMenu; +} + +void cBuildMainMenu::GetOptions( const XMLElement* element, const cString name ) +{ + const XMLElement* titleElement = element->FirstChildElement( name.c_str() ); + if (titleElement == nullptr) { + cUtility::Inst().Message("Error no tag <" + name + "> found."); + } else { + const char* x = GetAttribute(titleElement, "x"); + const char* y = GetAttribute(titleElement, "y"); + const char* size = GetAttribute(titleElement, "size"); + const char* text = titleElement->GetText(); + + if (name == "Title") + mp_mainMenu->setTitleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "SinglePlayer") + mp_mainMenu->setSingleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "HeadToHead") + mp_mainMenu->setHeadText(text, atoi(size), atoi(x), atoi(y)); + if (name == "Quit") + mp_mainMenu->setQuitText(text, atoi(size), atoi(x), atoi(y)); + } +} + +const char* cBuildMainMenu::GetAttribute( const XMLElement* element, const cString attribute ) const +{ + const char* rtn = element->Attribute(attribute.c_str()); + if (rtn == nullptr) { + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element->Value() + ">"); + rtn = ""; + } + return rtn; +} + +const unsigned long int cBuildMainMenu::HexToInt( const cString str ) const +{ + return strtol(str.c_str(), NULL, 10);; +} + +const SDL_Colour cBuildMainMenu::IntToSDLColour( const unsigned long int colour ) const +{ + SDL_Colour rtn = {255, 255, 255}; + + rtn.r = Uint8(colour >> 16); + rtn.g = Uint8(colour >> 8); + rtn.b = Uint8(colour); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/e9/e956d7091d23bc06b521111b61f53d16c5a2ea2a.svn-base b/.svn/pristine/e9/e956d7091d23bc06b521111b61f53d16c5a2ea2a.svn-base new file mode 100644 index 0000000..4efadd6 --- /dev/null +++ b/.svn/pristine/e9/e956d7091d23bc06b521111b61f53d16c5a2ea2a.svn-base @@ -0,0 +1,67 @@ +#include "iVector3.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector3.hpp" + +using MathEngine::iVector3; +using MathEngine::Vector3; + +iVector3::iVector3( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/ ) + : iVector2(X, Y), z(Z) +{} + +iVector3::iVector3( const iVector2& copy ) + : iVector2(copy), z(0) +{} + +iVector3::iVector3( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); +} + +iVector3& iVector3::operator=( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + + return *this; +} + +bool iVector3::operator==( const SDL_Rect& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.w ) + rtn = true; + return rtn; +} + +iVector3::iVector3( const Vector3& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); +} + +iVector3& iVector3::operator=( const Vector3& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + + return *this; +} + +bool iVector3::operator==( const iVector3& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.z ) + rtn = true; + return rtn; +} diff --git a/.svn/pristine/e9/e9adc24ca228fe4227695726aafa3f28fda11e60.svn-base b/.svn/pristine/e9/e9adc24ca228fe4227695726aafa3f28fda11e60.svn-base new file mode 100644 index 0000000..81527c3 --- /dev/null +++ b/.svn/pristine/e9/e9adc24ca228fe4227695726aafa3f28fda11e60.svn-base @@ -0,0 +1,200 @@ +#include "cCollision.hpp" + +using MathEngine::cCollision; +using MathEngine::Vector4; +using MathEngine::Vector2; +using MathEngine::iVector4; +using MathEngine::iVector2; + +cCollision::cCollision() +{ +} + +cCollision::~cCollision() +{ +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const SDL_Rect& b ) +{ + if ((b.x + b.w) < a.x) + return false; //just checking if their + if ((a.x + a.w) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.h) < a.y) + return false; + if ((a.y + a.h) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const Vector4& b ) +{ + if ((b.x + b.z) < a.x) + return false; //just checking if their + if ((a.x + a.z) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.w) < a.y) + return false; + if ((a.y + a.w) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::BoundingBox(temp, b); +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const SDL_Rect& b ) +{ + return cCollision::BoundingBox(b, a); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const iVector4& b ) +{ + if ((b.x + b.z) < a.x) + return false; //just checking if their + if ((a.x + a.z) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.w) < a.y) + return false; + if ((a.y + a.w) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const iVector4& b ) +{ + iVector4 temp = a; + + return cCollision::BoundingBox(temp, b); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const SDL_Rect& b ) +{ + return cCollision::BoundingBox(b, a); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::BoundingBox( temp, b ); +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const iVector4& b ) +{ + return cCollision::BoundingBox( b, a ); +} + +/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const SDL_Rect& 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 = (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 botton 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 Vector2 cCollision::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 botton 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 cCollision::Inside( const SDL_Rect& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::Inside(temp, b); +} + +/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const SDL_Rect& b ) +{ + Vector4 temp = b; + + return cCollision::Inside(a, temp); +} + +/*static*/ const iVector2 cCollision::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 botton 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 cCollision::Inside( const SDL_Rect& a, const iVector4& b ) +{ + iVector4 temp = a; + + return cCollision::Inside( temp, b ); +} + +/*static*/ const iVector2 cCollision::Inside( const iVector4& a, const SDL_Rect& b ) +{ + return cCollision::Inside( b, a ); +} + +/*static*/ const Vector2 cCollision::Inside( const iVector4& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::Inside( temp, b ); +} + +/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const iVector4& b ) +{ + return cCollision::Inside( b, a ); +} \ No newline at end of file diff --git a/.svn/pristine/ea/ea28cb2bfd0b13ec93ddbd1656556dc11eafec19.svn-base b/.svn/pristine/ea/ea28cb2bfd0b13ec93ddbd1656556dc11eafec19.svn-base new file mode 100644 index 0000000..32f619b Binary files /dev/null and b/.svn/pristine/ea/ea28cb2bfd0b13ec93ddbd1656556dc11eafec19.svn-base differ diff --git a/.svn/pristine/ea/ea55318d25d68e1970bdd649ab1139f810dc4aba.svn-base b/.svn/pristine/ea/ea55318d25d68e1970bdd649ab1139f810dc4aba.svn-base new file mode 100644 index 0000000..86bff9f --- /dev/null +++ b/.svn/pristine/ea/ea55318d25d68e1970bdd649ab1139f810dc4aba.svn-base @@ -0,0 +1,81 @@ +#include "cTexture.hpp" + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cRenderer.hpp" +#include "../../FXEngine/cGFX.hpp" +#include "GUIUtility.hpp" + +using GUIHelpers::cTexture; + +cTexture::cTexture() +{} + +cTexture::~cTexture() +{} + +///Functions + +//private +SDL_Texture* cTexture::GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text /*= nullptr*/ ) +{ + SDL_Rect t = text->getWH(); + SDL_Rect centerText = { 0, 0, 0, 0 }; + SDL_Rect centerButton = { 0, 0, 0, 0 }; + SDL_Rect dim = dimensions; + + ///Find the min padding around the text. +// if (dim.w < (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w) ) +// dim.w += (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w); +// +// if (dim.h < (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z) ) +// dim.h += (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z); + + ///Find the center of the button + centerButton.x = dim.w / 2; + centerButton.y = dim.h / 2; + + ///Find the center of the text + centerText.x = t.w / 2; + centerText.y = t.h / 2; + + if (centerText.x < centerButton.x) + t.x = centerButton.x - centerText.x; + + if (centerText.y < centerButton.y) + t.y = centerButton.y - centerText.y; + + SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); + + GUIHelpers::RGBA colour = { 100, 100, 100, 255 }; + + FXEngine::cGFX::Inst().RoundedRectangle(dim, 0, colour, temptext); + + + VideoEngine::cRenderer::Inst().RenderToTexture(text->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + + setImage(temptext); + + return temptext; +} \ No newline at end of file diff --git a/.svn/pristine/eb/eb7a45d0c68c3e017d6e175ed41c5e8bb8ba0366.svn-base b/.svn/pristine/eb/eb7a45d0c68c3e017d6e175ed41c5e8bb8ba0366.svn-base new file mode 100644 index 0000000..8e3c103 --- /dev/null +++ b/.svn/pristine/eb/eb7a45d0c68c3e017d6e175ed41c5e8bb8ba0366.svn-base @@ -0,0 +1,132 @@ + + + + + {813fe0d0-021e-4a7a-81f6-8c257531e86f} + + + {b1e548f9-e924-4aeb-b70c-45e0149e8ff3} + + + {7010506c-0310-40f7-a3ea-6e9e99ecdb81} + + + {9e5916e8-437a-4c0d-800a-5ea486c57b97} + + + {d393f48f-a4c2-4a35-a524-e78235977f9e} + + + {cf62df37-481f-445c-834d-74549b98aaa4} + + + {d381fec8-ab66-45a6-b6b9-96e5d5a4bfdb} + + + + + Main + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + \ No newline at end of file diff --git a/.svn/pristine/eb/ebf84379be8fbe6aadba7c60f3de91205e15dccf.svn-base b/.svn/pristine/eb/ebf84379be8fbe6aadba7c60f3de91205e15dccf.svn-base new file mode 100644 index 0000000..f1478ff --- /dev/null +++ b/.svn/pristine/eb/ebf84379be8fbe6aadba7c60f3de91205e15dccf.svn-base @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {D0670630-6CBB-4894-BAC6-35FD775E8D8E} + SDLPongCPP + SDLPongCPP + + + + Application + MultiByte + true + v140 + + + Application + MultiByte + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + $(TINYXML);$(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + + + Full + false + ../LinkListDLLProject/dllExportFiles;../TrooperEngineDLLProject/dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + false + Level3 + true + ProgramDatabase + true + + + odbc32.lib;odbccp32.lib;sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;TrooperEngine.lib;LinkList.lib;%(AdditionalDependencies) + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + Windows + true + true + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b6513faa-8bde-45aa-9f1e-326bcbe5d2e8} + false + + + + + + \ No newline at end of file diff --git a/.svn/pristine/ed/ed275249a0c25218ce592a28d550045c557f230f.svn-base b/.svn/pristine/ed/ed275249a0c25218ce592a28d550045c557f230f.svn-base new file mode 100644 index 0000000..5e03c18 --- /dev/null +++ b/.svn/pristine/ed/ed275249a0c25218ce592a28d550045c557f230f.svn-base @@ -0,0 +1,158 @@ +#include "cAnimatedSprite.hpp" + +using VideoEngine::cAnimatedSprite; + +cAnimatedSprite::cAnimatedSprite( const unsigned long int x /*= 0*/, const unsigned long int y /*= 0*/, + const unsigned long int fps /*= 16*/ ) +: m_nextTime(0), m_RATE(0) +{ + setFPS(fps); + setIncrement(x, y); +} + +cAnimatedSprite::cAnimatedSprite( const cAnimatedSprite& copy ) +: m_nextTime(0), m_RATE(0) +{ + setFPS(copy.getFPS()); + setIncrement(copy.getXIncrement(), copy.getYIncrement()); +} + +cAnimatedSprite::~cAnimatedSprite() +{ +} + +///Functions +void cAnimatedSprite::UptoDown() +{ + //if (TimeLeft() == 0) + //{ + signed long int x = 0; + signed long int y = 0; + getStartImageArea(x, y); + y += m_yIncrement; + if (y >= signed(getImage()->getHeight())) + y = 1; + setStartImageArea(x, y); + //} + Draw(); +} + +void cAnimatedSprite::DowntoUp() +{ + //if (TimeLeft() == 0) + //{ + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + y -= m_yIncrement; + if (y < 1) + y = getImage()->getHeight() - m_yIncrement; + setStartImageArea(x, y); + //} + Draw(); +} + +void cAnimatedSprite::LefttoRight() +{ + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + if (x >= signed(getImage()->getWidth())) + setStartImageArea(1,y); + if (TimeLeft() == 0) + { + x = 0; + y = 0; + + getStartImageArea(x, y); + x += m_xIncrement; + if (x >= signed(getImage()->getWidth())) + x = 1; + setStartImageArea(x, y); + } + Draw(); +} + +void cAnimatedSprite::RighttoLeft() +{ + if (TimeLeft() == 0) + { + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + x -= m_xIncrement; + if (x <= 1) + x = getImage()->getWidth() - m_xIncrement; + setStartImageArea(x, y); + } + Draw(); +} + +///Sets +void cAnimatedSprite::setXIncrement( const unsigned long int x ) +{ + m_xIncrement = x; +} + +void cAnimatedSprite::setYIncrement( const unsigned long int y ) +{ + m_yIncrement = y; +} + +void cAnimatedSprite::setIncrement( const unsigned long int y, const unsigned long int x ) +{ + m_xIncrement = x; + m_yIncrement = y; +} + +void cAnimatedSprite::setFPS( const unsigned long int fps /*= 16*/ ) +{ + m_fps = fps; + m_RATE = (1000 / m_fps); + m_nextTime = ((unsigned long int)SDL_GetTicks()) + m_RATE; +} + +///Gets +const unsigned long int cAnimatedSprite::getXIncrement() const +{ + return m_xIncrement; +} + +const unsigned long int cAnimatedSprite::getYIncrement() const +{ + return m_yIncrement; +} + +void cAnimatedSprite::getIncrement( unsigned long int& x, unsigned long int& y ) const +{ + x = m_xIncrement; + y = m_yIncrement; +} + +const unsigned long int cAnimatedSprite::getFPS() const +{ + return m_fps; +} + +const unsigned long int cAnimatedSprite::TimeLeft() +{ + unsigned long int now = (unsigned long int)SDL_GetTicks(); + + if(m_nextTime <= now) + { + AddTimeandRate(); + return 0; + } + else + return 1; +} + +void cAnimatedSprite::AddTimeandRate() +{ + m_nextTime += m_RATE; +} + + diff --git a/.svn/pristine/ed/ed464b94501633067c19451ae1ef61ca8a2192ee.svn-base b/.svn/pristine/ed/ed464b94501633067c19451ae1ef61ca8a2192ee.svn-base new file mode 100644 index 0000000..91297bc --- /dev/null +++ b/.svn/pristine/ed/ed464b94501633067c19451ae1ef61ca8a2192ee.svn-base @@ -0,0 +1,16 @@ +#include "cPlayer.hpp" + +using Equipment::cPlayer; + +cPlayer::cPlayer( const cString name ) + : m_name(name) +{} + +cPlayer::~cPlayer() +{} + +///Functions +void cPlayer::Score( const unsigned long int score /*= 1*/ ) +{ + m_score += score; +} \ No newline at end of file diff --git a/.svn/pristine/ed/edf04749010be4cb8488814f6b81fb00db11bf3b.svn-base b/.svn/pristine/ed/edf04749010be4cb8488814f6b81fb00db11bf3b.svn-base new file mode 100644 index 0000000..6c23ba3 --- /dev/null +++ b/.svn/pristine/ed/edf04749010be4cb8488814f6b81fb00db11bf3b.svn-base @@ -0,0 +1,50 @@ +#ifndef _CLAYOUT_HPP_ +#define _CLAYOUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/GUIUtility.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLayout : public cWindow + { + public: + static const cString sNAME; /*= "layout";*/ + static const GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::VERTICAL;*/ + + cLayout( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cLayout(); + + ///Functions + virtual void Create( cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + ///Set + + ///Get + + virtual const GUIHelpers::eType getType() const; + + private: + GUIHelpers::eOrientation m_orientation; + };/// END CLASS DEFINITION cLayout +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLAYOUT_HPP_ diff --git a/.svn/pristine/ed/edfb74828e22350bcf1b9103e2a808850f4b598b.svn-base b/.svn/pristine/ed/edfb74828e22350bcf1b9103e2a808850f4b598b.svn-base new file mode 100644 index 0000000..cde4614 --- /dev/null +++ b/.svn/pristine/ed/edfb74828e22350bcf1b9103e2a808850f4b598b.svn-base @@ -0,0 +1,82 @@ +#include "iVector2.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector2.hpp" + +using MathEngine::iVector2; +using MathEngine::Vector2; + +iVector2::iVector2( const int X /*= 0*/, const int Y /*= 0*/ ) + : x(X), y(Y) +{} + +iVector2::iVector2( const Vector2& copy ) +{ + x = int(copy.x); + y = int(copy.y); +} + +iVector2::iVector2( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); +} + +iVector2& iVector2::operator = ( const Vector2& copy ) +{ + x = int(copy.x); + y = int(copy.y); + + return *this; +} + +iVector2& iVector2::operator = ( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + + return *this; +} + +bool iVector2::operator == ( const iVector2& other ) const +{ + bool rtn = false; + if (x == other.x) + if (y == other.y) + rtn = true; + + return rtn; +} + +bool iVector2::operator == ( const SDL_Rect& other ) const +{ + bool rtn = false; + if (x == other.x) + if (y == other.y) + rtn = true; + + return rtn; +} + +iVector2& iVector2::operator += ( const iVector2& other ) +{ + x += int(other.x); + y += int(other.y); + + return *this; +} + +iVector2& iVector2::operator += ( const SDL_Rect& other ) +{ + x += int(other.x); + y += int(other.y); + + return *this; +} + +iVector2 operator + (const iVector2& lhs, const iVector2& rhs) +{ + iVector2 rs = lhs; + rs += rhs; + return rs; +} \ No newline at end of file diff --git a/.svn/pristine/ee/ee2fe33cc03a781b135705a6037a5512a3d9774a.svn-base b/.svn/pristine/ee/ee2fe33cc03a781b135705a6037a5512a3d9774a.svn-base new file mode 100644 index 0000000..eae78cc Binary files /dev/null and b/.svn/pristine/ee/ee2fe33cc03a781b135705a6037a5512a3d9774a.svn-base differ diff --git a/.svn/pristine/f1/f14509d0b22e7182edf7d6139b7f55a3f3d9ccdf.svn-base b/.svn/pristine/f1/f14509d0b22e7182edf7d6139b7f55a3f3d9ccdf.svn-base new file mode 100644 index 0000000..6c68d00 --- /dev/null +++ b/.svn/pristine/f1/f14509d0b22e7182edf7d6139b7f55a3f3d9ccdf.svn-base @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {D0670630-6CBB-4894-BAC6-35FD775E8D8E} + SDLPongCPP + SDLPongCPP + + + + Application + MultiByte + true + v140 + + + Application + MultiByte + v140 + + + v140 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + $(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + + + Full + false + ../LinkListDLLProject/dllExportFiles;../TrooperEngineDLLProject/dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + false + Level3 + true + ProgramDatabase + true + + + odbc32.lib;odbccp32.lib;sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;TrooperEngine.lib;LinkList.lib;%(AdditionalDependencies) + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + Windows + true + true + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b6513faa-8bde-45aa-9f1e-326bcbe5d2e8} + false + + + + + + \ No newline at end of file diff --git a/.svn/pristine/f2/f21da0d30e193893c054c36027c745f0e067b469.svn-base b/.svn/pristine/f2/f21da0d30e193893c054c36027c745f0e067b469.svn-base new file mode 100644 index 0000000..87cb486 --- /dev/null +++ b/.svn/pristine/f2/f21da0d30e193893c054c36027c745f0e067b469.svn-base @@ -0,0 +1,7 @@ +#!/bin/sh +wget -c http://www.machinaesupremacy.com/downloads/machinae_supremacy_-_masquerade.ogg +ln -s machinae_supremacy_-_masquerade.ogg game-music.ogg +wget -c http://www.machinaesupremacy.com/downloads/machinae_supremacy_-_arcade.ogg +ln -s machinae_supremacy_-_arcade.ogg menu-music.ogg +clear +echo The music is now downloaded. diff --git a/.svn/pristine/f2/f2223e5f46e9c0dbab2354a1da6680f3cab31b7e.svn-base b/.svn/pristine/f2/f2223e5f46e9c0dbab2354a1da6680f3cab31b7e.svn-base new file mode 100644 index 0000000..a96f754 --- /dev/null +++ b/.svn/pristine/f2/f2223e5f46e9c0dbab2354a1da6680f3cab31b7e.svn-base @@ -0,0 +1,167 @@ +#include "cInput.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using InputEngine::cInput; +using UtilityEngine::cUtility; + +/*static*/ cInput* cInput::sp_inst = nullptr; + +//Private +cInput::cInput() +{} + +cInput::~cInput() +{ + CleanUp(); +} + +//Public +/*static*/ cInput& cInput::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cInput(); + return *sp_inst; +} + +/*static*/ void cInput::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +//Functions +const bool cInput::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0) { + cUtility::Inst().Message("Input initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Input.hpp SDL_InitSubSystem(SDL_INIT_JOYSTICK):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +const bool cInput::Setup() +{ + return true; +} + +void cInput::CleanUp() +{ + DeleteAllInputs(); +} + +void cInput::CheckInputs( const SDL_Event& event ) +{ + m_event = event; + switch(m_event.type) + { + case SDL_KEYUP: + case SDL_KEYDOWN: + CheckKeyboards(); + break; + case SDL_JOYAXISMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + CheckJoysticks(); + break; + } +} + +void cInput::CheckKeyboards() +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + InputEngine::cKeyboard* temp = (*it); + temp->KeyboardCheck(m_event); + } +} + +void cInput::CheckJoysticks() +{ + +} + +/* Adds a keyboard to cInput internal list to be called when CheckInputs is called */ +void cInput::AddKeyboard( InputEngine::cKeyboard* keyboard ) +{ + m_keyboards.push_back(keyboard); +} + +/* Deletes a keyboard in cInput internal list */ +void cInput::DeletesKeyboard( const cString& label ) +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + if (label == (*it)->getLabel()) { + InputEngine::cKeyboard* temp = (*it); + delete temp; + temp = nullptr; + m_keyboards.erase(it); + //break out of the for loop + break; + } + } +} + +/* Deletes all keyboards in cInput internal list */ +void cInput::DeleteAllKeyboards() +{ + m_keyboards.clear(); +} + +/* Removes the keyboard from cInput internal list */ +void cInput::RemoveKeyboard( const cString& label ) +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + if (label == (*it)->getLabel()) { + m_keyboards.erase(it); + //break out of the for loop + break; + } + } +} + +/* Removes all keyboards from cInput internal list. */ +void cInput::RemoveAllKeyboards() +{ + m_keyboards.erase(m_keyboards.begin(), m_keyboards.end()); +} + +void cInput::DeleteAllInputs() +{ + DeleteAllKeyboards(); +} + +void cInput::RemoveAllInputs() +{ + RemoveAllKeyboards(); +} + +///Sets + +///Gets +/* Gets return true if Input was initialized */ +const bool cInput::IsInit() const +{ + bool rtn = false; + if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0) { + cUtility::Inst().Message("Input is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Input is not initialized."); + return rtn; +} + diff --git a/.svn/pristine/f4/f4b0eacb29904e2c1fb7e2f0565c979c9ceef10a.svn-base b/.svn/pristine/f4/f4b0eacb29904e2c1fb7e2f0565c979c9ceef10a.svn-base new file mode 100644 index 0000000..ce34587 --- /dev/null +++ b/.svn/pristine/f4/f4b0eacb29904e2c1fb7e2f0565c979c9ceef10a.svn-base @@ -0,0 +1,42 @@ +#ifndef _CPANEL_HPP_ +#define _CPANEL_HPP_ + +/** C++ Header Files **/ +#include + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cLayout.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cPanel : public GUIEngine::cLayout + { + public: + static const UtilityEngine::cString sNAME; /*= "panel";*/ + + public: + cPanel( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cPanel(); + + ///Functions + virtual void Create( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + virtual const GUIHelpers::eType getType() const; + + virtual const GUIHelpers::RGBA getDebugColour() const; + + private: + };/// END CLASS DEFINITION cPanel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CPANEL_HPP_ \ No newline at end of file diff --git a/.svn/pristine/f5/f53a380ef05d626f46697d2e4b75353eb7c631f1.svn-base b/.svn/pristine/f5/f53a380ef05d626f46697d2e4b75353eb7c631f1.svn-base new file mode 100644 index 0000000..53dbaf6 --- /dev/null +++ b/.svn/pristine/f5/f53a380ef05d626f46697d2e4b75353eb7c631f1.svn-base @@ -0,0 +1,29 @@ +#include "cPlayerUp.hpp" + +using Input::cPlayerUp; + +cPlayerUp::cPlayerUp( SDL_Keycode key, Equipment::cPaddle** player ) +: cKey( key ), mpp_player(player) +{} + +cPlayerUp::~cPlayerUp() +{} + +///Funtions +void cPlayerUp::KeyPress() +{} + +void cPlayerUp::KeyUP() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + { + if ((*mpp_player)->getState() == Equipment::cPaddle::Up) + (*mpp_player)->setState(Equipment::cPaddle::Still); + } +} + +void cPlayerUp::KeyDown() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + (*mpp_player)->setState(Equipment::cPaddle::Up); +} \ No newline at end of file diff --git a/.svn/pristine/f5/f55ed7b8fe03bb9034319fb94e0061eeeb463e34.svn-base b/.svn/pristine/f5/f55ed7b8fe03bb9034319fb94e0061eeeb463e34.svn-base new file mode 100644 index 0000000..e6da9ff --- /dev/null +++ b/.svn/pristine/f5/f55ed7b8fe03bb9034319fb94e0061eeeb463e34.svn-base @@ -0,0 +1,25 @@ +#include "cFontHolder.hpp" + +using TextTypeHelpers::cFontHolder; + +cFontHolder::cFontHolder( TTF_Font* font, const unsigned long int size ) + : mp_font(font), m_size(size) +{} + +cFontHolder::~cFontHolder() +{ + if (mp_font != nullptr) { + TTF_CloseFont(mp_font); + mp_font = nullptr; + } +} + +TTF_Font* cFontHolder::getFont() const +{ + return mp_font; +} + +const unsigned long int cFontHolder::getSize() const +{ + return m_size; +} \ No newline at end of file diff --git a/.svn/pristine/f6/f67267463a9e0483b17c4b2f00c1cb95cf026c1a.svn-base b/.svn/pristine/f6/f67267463a9e0483b17c4b2f00c1cb95cf026c1a.svn-base new file mode 100644 index 0000000..8e45540 --- /dev/null +++ b/.svn/pristine/f6/f67267463a9e0483b17c4b2f00c1cb95cf026c1a.svn-base @@ -0,0 +1,35 @@ +#ifndef _VECTOR4_HPP_ +#define _VECTOR4_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "Vector3.hpp" + +namespace MathEngine { + struct iVector4; + + struct EXPORT_FROM_MYDLL Vector4 : public Vector3 + { + Vector4( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f, const float W = 0.0f ); + + Vector4( const SDL_Rect& copy ); + + Vector4& operator=( const SDL_Rect& copy ); + + bool operator==(const SDL_Rect& other) const; + + Vector4( const iVector4& copy ); + + Vector4& operator=( const iVector4& copy ); + + bool operator==(const Vector4& other) const; + + float w; + };/// END STRUCT DEFINITION Vector4 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR4_HPP_ \ No newline at end of file diff --git a/.svn/pristine/f8/f8014e1e5dc4fd2874248536bd6866d5953f22bc.svn-base b/.svn/pristine/f8/f8014e1e5dc4fd2874248536bd6866d5953f22bc.svn-base new file mode 100644 index 0000000..04a59b2 --- /dev/null +++ b/.svn/pristine/f8/f8014e1e5dc4fd2874248536bd6866d5953f22bc.svn-base @@ -0,0 +1,20 @@ +#ifndef _GUIUTILITY_HPP_ +#define _GUIUTILITY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../MathEngine/iVector/iVector2.hpp" +#include "../../MathEngine/iVector/iVector4.hpp" + +namespace GUIHelpers { + typedef struct MathEngine::iVector2 Size, Position; + typedef struct MathEngine::iVector4 Padding; + typedef struct SDL_Colour RBGA; + typedef struct SDL_Rect Area; + + +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _GUIUTILITY_HPP_ + diff --git a/.svn/pristine/fa/fa94bc82b7f066ff189ec0efccb11ec672d84130.svn-base b/.svn/pristine/fa/fa94bc82b7f066ff189ec0efccb11ec672d84130.svn-base new file mode 100644 index 0000000..3976f02 --- /dev/null +++ b/.svn/pristine/fa/fa94bc82b7f066ff189ec0efccb11ec672d84130.svn-base @@ -0,0 +1,193 @@ +#include "cGUI.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" + +#include "../UtilityEngine/cUtility.hpp" +#include "GUIHelpers/Enums.hpp" +#include "cButton.hpp" + +#include "GUIHelpers/cXMLoader.hpp" + +using GUIEngine::cGUI; +using GUIEngine::cWindow; +using UtilityEngine::cUtility; + +/*static*/ cGUI* cGUI::sp_inst = nullptr; + +//private +cGUI::cGUI() + : mp_font(nullptr), m_inited(false) +{ + setTextColour(); + setPadding(); +} + +cGUI::~cGUI() +{ + delete mp_font; + mp_font = nullptr; + + m_guiObjects.clear(); +} + +//public: +///Functions +/*static*/ cGUI& cGUI::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGUI(); + return *sp_inst; +} + +/*static*/ void cGUI::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cGUI::Initialize( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +{ + bool rtn = IsInit(); + + GUIHelpers::cXMLoader::Inst().Load(filename, dir); +// if (rtn == false) { +// setFont( filename, dir, size ); +// cUtility::Inst().Message("GUI initialized."); +// } + + return rtn; +} + +void cGUI::Event(const MathEngine::iVector2& location, const eGUIEventType& type) +{ + location; + type; +// std::vector::iterator it; +// +// for (it = m_objects.begin(); it < m_objects.end(); it++) { +// switch ((*it)->getType()) { +// case GUIHelpers::eType::CBUTTON: +// cButton* tmp = (cButton*)(*it); +// if (tmp->InSide(location) == true) +// cUtility::Inst().Message("Button Inside!"); +// break; +// } +// } +} + +const MathEngine::iVector2 cGUI::DisplayArea() const +{ + MathEngine::iVector2 rtn = { 0, 0 }; + rtn.x = VideoEngine::cVideo::Inst().getWidth(); + rtn.y = VideoEngine::cVideo::Inst().getHeight(); + + return rtn; +} + +void cGUI::AddObject(cWindow* obj) +{ + //this->m_obj = obj; + m_guiObjects.push_back(obj); +} + +void cGUI::Display() +{ + //m_obj->Display(); + std::vector::iterator it; + + for (it = m_guiObjects.begin(); it < m_guiObjects.end(); it++) { + (*it)->Display(); + } +} + +///Sets +void cGUI::setFont( TextTypeEngine::cFont* font ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = font; +} + +void cGUI::setFont( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont( dir, filename, size ); +} + +void cGUI::setTextColour( const GUIHelpers::RBGA& colour ) +{ + cWindow::sCOLOUR = colour; +} + +void cGUI::setTextColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/ ) +{ + GUIHelpers::RBGA colour = {Uint8(red), Uint8(green), Uint8(blue)}; + setTextColour(colour); +} + +void cGUI::setPadding( const GUIHelpers::Padding& padding ) +{ + cWindow::sPADDING = padding; +} + +void cGUI::setPadding( const unsigned int top /*= 5*/, const unsigned int right /*= 5*/, const unsigned int bottom /*= 5*/, const unsigned int left /*= 5*/ ) +{ + setPadding(GUIHelpers::Padding(top, right, bottom, left)); +} + +void cGUI::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/ ) +{ + cWindow::sALIGN = align; +} + +///Gets +TextTypeEngine::cFont* cGUI::getFont() +{ + return mp_font; +} + +const GUIHelpers::RBGA& cGUI::getTextColour() const +{ + return cWindow::sCOLOUR; +} + +void cGUI::getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const +{ + red = cWindow::sCOLOUR.r; + green = cWindow::sCOLOUR.g; + blue = cWindow::sCOLOUR.b; +} + +const GUIHelpers::Padding& cGUI::getPadding() const +{ + return cWindow::sPADDING; +} + +void cGUI::getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const +{ + top = cWindow::sPADDING.x; + right = cWindow::sPADDING.y; + bottom = cWindow::sPADDING.z; + left = cWindow::sPADDING.w; +} + +const GUIHelpers::eAlign& cGUI::getAlign() const +{ + return cWindow::sALIGN; +} + +const bool cGUI::IsInit() const +{ + bool rtn = m_inited; + + if (rtn == true) + cUtility::Inst().Message("GUI is initialized."); + else + cUtility::Inst().Message("GUI is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/.svn/pristine/fa/faa872f63dad01dab04cfdcb396e653c7a02d743.svn-base b/.svn/pristine/fa/faa872f63dad01dab04cfdcb396e653c7a02d743.svn-base new file mode 100644 index 0000000..c1887b7 --- /dev/null +++ b/.svn/pristine/fa/faa872f63dad01dab04cfdcb396e653c7a02d743.svn-base @@ -0,0 +1,19 @@ +#ifndef _CNETWORK_HPP_ +#define _CNETWORK_HPP_ + +/*** SDL Header Files ***/ +#include +///#include ///For networking + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace NetworkEngine { + class EXPORT_FROM_MYDLL cNetwork + { + public: + cNetwork(); + ~cNetwork(); + };/// END CLASS DEFINITION cNetwork +}/// END NAMESPACE NetworkEngine +#endif /// END IFNDEF _CNETWORK_HPP_ diff --git a/.svn/pristine/fa/faacf7bc09ac0b3c0ecd857c60c98bfc0d7320ef.svn-base b/.svn/pristine/fa/faacf7bc09ac0b3c0ecd857c60c98bfc0d7320ef.svn-base new file mode 100644 index 0000000..8853eeb --- /dev/null +++ b/.svn/pristine/fa/faacf7bc09ac0b3c0ecd857c60c98bfc0d7320ef.svn-base @@ -0,0 +1,322 @@ +#include "cWindow.hpp" + +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RBGA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; +/*static*/ GUIHelpers::eOrientation cWindow::sORIENTATION = GUIHelpers::eOrientation::NONE; + +cWindow::cWindow(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) + : cObject(id) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cWindow::~cWindow() +{ + m_children.clear(); +} + +/*virtual*/ void cWindow::Create(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + mp_parent = parent; + cObject::setID(id); + setOrientation(orientation); + setAlign(align); + setLayout(layout); + m_pos = pos; + m_size = size; + m_padding = padding; + m_name = name; +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } +} + +///Functions +const bool cWindow::Inside(const MathEngine::iVector2& location) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild( cWindow* obj ) +{ + m_children.push_back(obj); +} + +void cWindow::RemoveChild( cWindow* obj ) +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + //break out of the for loop + break; + } + } +} + +///Sets +void cWindow::setOrientation( const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/ ) +{ + if (orientation == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + m_orientation = cWindow::sORIENTATION; + else + m_orientation = orientation; +} + +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= sALIGN*/ ) +{ + if (align == GUIHelpers::eAlign::DEFAULT_ALIGN) + m_align = cWindow::sALIGN; + else + m_align = align; +} + +void cWindow::setLayout( const GUIHelpers::eLayout& layout /*= sLAYOUT*/ ) +{ + if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT) + m_layout = cWindow::sLAYOUT; + else + m_layout = layout; +} + +void cWindow::setPosition( const GUIHelpers::Position& pos /*= POSITION*/ ) +{ + m_pos = pos; +} + +void cWindow::setSize( const GUIHelpers::Size& size /*= SIZE*/ ) +{ + m_size = size; +} + +void cWindow::setPadding( const GUIHelpers::Padding& padding /*= PADDING*/ ) +{ + m_padding = padding; +} + +void cWindow::setContentSize( const GUIHelpers::Size& content ) +{ + m_content = content; +} + +void cWindow::setName( const cString& name /*= NAME*/ ) +{ + m_name = name; +} + +void cWindow::setParent( cWindow* parent ) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::eOrientation& cWindow::getOrientation() const +{ + return m_orientation; +} + +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position& cWindow::getPosition() const +{ + return m_pos; +} + +const GUIHelpers::Size& cWindow::getSize() const +{ + return m_size; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + GUIHelpers::Size mySize = { 0, 0 }; + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + mySize = mp_parent->getSize(); + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + } else { + mySize = GUIEngine::cGUI::Inst().DisplayArea(); + } + + m_size = mySize; + + for (it = m_children.begin(); it < m_children.end(); it++) { + //if ((*it)->getLayout() != GUIHelpers::eLayout::WRAP_CONTENT) + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + GUIHelpers::Padding pad = { 0, 0, 0, 0 }; + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + pad = (*it)->getPadding(); + size.x += pad.x + pad.w; + size.y += pad.y + pad.z; + //mySize += size; + AddSize(size.x, size.y, mySize); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ + if (mp_parent != nullptr) + RebuildPos(); + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } +} + +/*virtual*/ void cWindow::RebuildPos() +{ + GUIHelpers::Position prtPos = mp_parent->getPosition(); + GUIHelpers::Size prtSize = mp_parent->getSize(); + GUIHelpers::Position prtCenter = { (prtSize.x / 2), (prtSize.y / 2) }; + + GUIHelpers::Size ourSize = this->getSize(); + GUIHelpers::Position ourCenter = { (ourSize.x / 2), (ourSize.y / 2) }; + + GUIHelpers::Position ourSet = { 0, 0 }; + + switch (this->getAlign()) { + case GUIHelpers::eAlign::CENTER: + ourSet.x = prtCenter.x - ourCenter.x; + ourSet.y = prtCenter.y - ourCenter.y; + break; + case GUIHelpers::eAlign::TOP: + ourSet.x = prtCenter.x - ourCenter.x; + ourSet.y = prtPos.y + m_padding.y; + break; + case GUIHelpers::eAlign::RIGHT: + ourSet.x = prtSize.x - ourSize.x - m_padding.w; + ourSet.y = prtCenter.y - ourCenter.y; + break; + case GUIHelpers::eAlign::BOTTOM: + ourSet.x = prtCenter.x - ourCenter.x; + ourSet.y = prtSize.y - ourSize.y - m_padding.z; + break; + case GUIHelpers::eAlign::LEFT: + ourSet.x = prtPos.x + m_padding.x; + ourSet.y = prtCenter.y - ourCenter.y; + break; + } + this->setPosition(ourSet); +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} + +//private +void cWindow::AddSize(int x, int y, GUIHelpers::Size& mySize) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo > largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} \ No newline at end of file diff --git a/.svn/pristine/fe/fe7bb051b43b5d5c4e0fba29f52843d1d196c513.svn-base b/.svn/pristine/fe/fe7bb051b43b5d5c4e0fba29f52843d1d196c513.svn-base new file mode 100644 index 0000000..6e8b394 --- /dev/null +++ b/.svn/pristine/fe/fe7bb051b43b5d5c4e0fba29f52843d1d196c513.svn-base @@ -0,0 +1,216 @@ +#include "cGUI.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" + +#include "../UtilityEngine/cUtility.hpp" +#include "GUIHelpers/Enums.hpp" +#include "cButton.hpp" + +#include "GUIHelpers/cXMLoader.hpp" + +using GUIEngine::cGUI; + +using UtilityEngine::cUtility; + +/*static*/ cGUI* cGUI::sp_inst = nullptr; + +//private +cGUI::cGUI() + : m_debugLevel(0), mp_font(nullptr), m_inited(false) +{ + setTextColour(); + setPadding(); +} + +cGUI::~cGUI() +{ + delete mp_font; + mp_font = nullptr; + + for (int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +//public: +///Functions +/*static*/ cGUI& cGUI::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGUI(); + return *sp_inst; +} + +/*static*/ void cGUI::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cGUI::Initialize( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +{ + bool rtn = IsInit(); + + GUIHelpers::cXMLoader xml; + xml.Load(filename, dir); + //GUIHelpers::cXMLoader::Inst().Load(filename, dir); +// if (rtn == false) { +// setFont( filename, dir, size ); +// cUtility::Inst().Message("GUI initialized."); +// } + + return rtn; +} + +void cGUI::Event(const MathEngine::iVector2& location, const eGUIEventType& type) +{ + location; + type; +// std::vector::iterator it; +// +// for (it = m_objects.begin(); it < m_objects.end(); it++) { +// switch ((*it)->getType()) { +// case GUIHelpers::eType::CBUTTON: +// cButton* tmp = (cButton*)(*it); +// if (tmp->InSide(location) == true) +// cUtility::Inst().Message("Button Inside!"); +// break; +// } +// } +} + +const MathEngine::iVector2 cGUI::DisplayArea() const +{ + MathEngine::iVector2 rtn = { 0, 0 }; + rtn.x = VideoEngine::cVideo::Inst().getWidth(); + rtn.y = VideoEngine::cVideo::Inst().getHeight(); + + return rtn; +} + +void cGUI::AddObject( GUIEngine::cWindow* obj ) +{ + //this->m_obj = obj; + m_children.push_back(obj); +} + +std::vector& cGUI::GetObjects() +{ + return m_children; +} + +void cGUI::Display() +{ + //m_obj->Display(); + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } +} + +///Sets +void cGUI::setDebugLevel(const unsigned long int debugLevel) +{ + m_debugLevel = debugLevel; +} + +void cGUI::setFont( TextTypeEngine::cFont* font ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = font; +} + +void cGUI::setFont( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont( dir, filename, size ); +} + +void cGUI::setTextColour( const GUIHelpers::RGBA& colour ) +{ + //cWindow::sCOLOUR = colour; +} + +void cGUI::setTextColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/ ) +{ + GUIHelpers::RGBA colour = {Uint8(red), Uint8(green), Uint8(blue)}; + setTextColour(colour); +} + +void cGUI::setPadding( const GUIHelpers::Padding& padding ) +{ + //cWindow::sPADDING = padding; +} + +void cGUI::setPadding( const unsigned int top /*= 5*/, const unsigned int right /*= 5*/, const unsigned int bottom /*= 5*/, const unsigned int left /*= 5*/ ) +{ + setPadding(GUIHelpers::Padding(top, right, bottom, left)); +} + +void cGUI::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/ ) +{ + //cWindow::sALIGN = align; +} + +///Gets +const unsigned long int cGUI::getDebugLevel() const +{ + return m_debugLevel; +} + +TextTypeEngine::cFont* cGUI::getFont() +{ + return mp_font; +} + +const GUIHelpers::RGBA& cGUI::getTextColour() const +{ + return {};//cWindow::sCOLOUR; +} + +void cGUI::getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const +{ +// red = cWindow::sCOLOUR.r; +// green = cWindow::sCOLOUR.g; +// blue = cWindow::sCOLOUR.b; +} + +const GUIHelpers::Padding& cGUI::getPadding() const +{ + /*return cWindow::sPADDING;*/ + return{}; +} + +void cGUI::getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const +{ +// top = cWindow::sPADDING.x; +// right = cWindow::sPADDING.y; +// bottom = cWindow::sPADDING.z; +// left = cWindow::sPADDING.w; +} + +const GUIHelpers::eAlign& cGUI::getAlign() const +{ + /*return cWindow::sALIGN;*/ + return GUIHelpers::eAlign::CENTER; +} + +const bool cGUI::IsInit() const +{ + bool rtn = m_inited; + + if (rtn == true) + cUtility::Inst().Message("GUI is initialized."); + else + cUtility::Inst().Message("GUI is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/.svn/wc.db b/.svn/wc.db new file mode 100644 index 0000000..fadf222 Binary files /dev/null and b/.svn/wc.db differ diff --git a/.svn/wc.db-journal b/.svn/wc.db-journal new file mode 100644 index 0000000..e69de29 diff --git a/SDLPongCPP.sln b/SDLPongCPP.sln new file mode 100644 index 0000000..e5502ea --- /dev/null +++ b/SDLPongCPP.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineDLL", "TrooperEngineDLL\TrooperEngineDLL.vcxproj", "{B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrooperEngineTest", "TrooperEngineTest\TrooperEngineTest.vcxproj", "{9225E043-EE77-43AA-A140-C9C2F85B1013}" + ProjectSection(ProjectDependencies) = postProject + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} = {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPongCPP", "SDLPongCPP\SDLPongCPP.vcxproj", "{D0670630-6CBB-4894-BAC6-35FD775E8D8E}" +EndProject +Global + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|Win32.Build.0 = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Debug|x64.ActiveCfg = Debug|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.ActiveCfg = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|Win32.Build.0 = Release|Win32 + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}.Release|x64.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.ActiveCfg = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|Win32.Build.0 = Debug|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.ActiveCfg = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Debug|x64.Build.0 = Debug|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.ActiveCfg = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|Win32.Build.0 = Release|Win32 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.ActiveCfg = Release|x64 + {9225E043-EE77-43AA-A140-C9C2F85B1013}.Release|x64.Build.0 = Release|x64 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|Win32.Build.0 = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Debug|x64.ActiveCfg = Debug|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.ActiveCfg = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|Win32.Build.0 = Release|Win32 + {D0670630-6CBB-4894-BAC6-35FD775E8D8E}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SDLPongCPP/Game/Equipment/Input/cPlayerDown.cpp b/SDLPongCPP/Game/Equipment/Input/cPlayerDown.cpp new file mode 100644 index 0000000..9060457 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cPlayerDown.cpp @@ -0,0 +1,30 @@ +#include "cPlayerDown.hpp" + +using Input::cPlayerDown; + +cPlayerDown::cPlayerDown( SDL_Keycode key, Equipment::cPaddle** player ) +: cKey( key ), mpp_player(player) +{} + +cPlayerDown::~cPlayerDown() +{} + +///Funtions +void cPlayerDown::KeyPress() +{} + +void cPlayerDown::KeyUP() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + { + if ((*mpp_player)->getState() == Equipment::cPaddle::Down) + (*mpp_player)->setState(Equipment::cPaddle::Still); + } + +} + +void cPlayerDown::KeyDown() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + (*mpp_player)->setState(Equipment::cPaddle::Down); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/Input/cPlayerDown.hpp b/SDLPongCPP/Game/Equipment/Input/cPlayerDown.hpp new file mode 100644 index 0000000..20ff42f --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cPlayerDown.hpp @@ -0,0 +1,33 @@ +#ifndef _CPLAYERDOWN_HPP_ +#define _CPLAYERDOWN_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cPaddle.hpp" + +namespace Input { + class cPlayerDown : public InputEngine::cKey + { + public: + cPlayerDown( SDL_Keycode key, Equipment::cPaddle** player ); + ~cPlayerDown(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cPaddle** mpp_player; + };/// END CLASS DEFINITION cPlayerDown +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CPLAYERDOWN_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/Input/cPlayerUp.cpp b/SDLPongCPP/Game/Equipment/Input/cPlayerUp.cpp new file mode 100644 index 0000000..53dbaf6 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cPlayerUp.cpp @@ -0,0 +1,29 @@ +#include "cPlayerUp.hpp" + +using Input::cPlayerUp; + +cPlayerUp::cPlayerUp( SDL_Keycode key, Equipment::cPaddle** player ) +: cKey( key ), mpp_player(player) +{} + +cPlayerUp::~cPlayerUp() +{} + +///Funtions +void cPlayerUp::KeyPress() +{} + +void cPlayerUp::KeyUP() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + { + if ((*mpp_player)->getState() == Equipment::cPaddle::Up) + (*mpp_player)->setState(Equipment::cPaddle::Still); + } +} + +void cPlayerUp::KeyDown() +{ + if (mpp_player != nullptr && *mpp_player != nullptr) + (*mpp_player)->setState(Equipment::cPaddle::Up); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/Input/cPlayerUp.hpp b/SDLPongCPP/Game/Equipment/Input/cPlayerUp.hpp new file mode 100644 index 0000000..0f4904a --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cPlayerUp.hpp @@ -0,0 +1,33 @@ +#ifndef _CPLAYERUP_HPP_ +#define _CPLAYERUP_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cPaddle.hpp" + +namespace Input { + class cPlayerUp : public InputEngine::cKey + { + public: + cPlayerUp( SDL_Keycode key, Equipment::cPaddle** player ); + ~cPlayerUp(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cPaddle** mpp_player; + };/// END CLASS DEFINITION cPlayerUp +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CPLAYERUP_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/Input/cQuitButton.cpp b/SDLPongCPP/Game/Equipment/Input/cQuitButton.cpp new file mode 100644 index 0000000..c3a83a3 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cQuitButton.cpp @@ -0,0 +1,23 @@ +#include "cQuitButton.hpp" + +using Input::cQuitButton; + +cQuitButton::cQuitButton( SDL_Keycode key, Equipment::cCourt** court ) +: cKey( key ), mpp_court(court) +{} + +cQuitButton::~cQuitButton() +{} + +///Funtions +void cQuitButton::KeyPress() +{} + +void cQuitButton::KeyUP() +{} + +void cQuitButton::KeyDown() +{ + if (mpp_court != nullptr && *mpp_court != nullptr) + (*mpp_court)->Quit(); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/Input/cQuitButton.hpp b/SDLPongCPP/Game/Equipment/Input/cQuitButton.hpp new file mode 100644 index 0000000..a918a00 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/Input/cQuitButton.hpp @@ -0,0 +1,33 @@ +#ifndef _CQUITBUTTON_HPP_ +#define _CQUITBUTTON_HPP_ + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cCourt.hpp" + +namespace Input { + class cQuitButton : public InputEngine::cKey + { + public: + cQuitButton( SDL_Keycode key, Equipment::cCourt** court); + virtual ~cQuitButton(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + Equipment::cCourt** mpp_court;// + };/// END CLASS DEFINITION cQuitButton +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CQUITBUTTON_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cBall.cpp b/SDLPongCPP/Game/Equipment/cBall.cpp new file mode 100644 index 0000000..4b3aed1 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cBall.cpp @@ -0,0 +1,96 @@ +#include "cBall.hpp" + +using Equipment::cBall; + +cBall::cBall( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: cSprite(xpos, ypos, xarea, yarea, warea, harea, image, camera), + m_pause(false), m_ballState(Serve), m_speed(-10.0, -10.0), m_maxSpeed(10), m_minSpeed(5), m_boucedAllReady(false) +{} + +cBall::~cBall() +{} + +///Functions +void cBall::Move() +{ + if (m_pause == false) + { + float frameTime = TimingEngine::cTiming::Inst().getFrameTime(); + + AddPosX(long int(m_speed.x * frameTime)); + AddPosY(long int(m_speed.y * frameTime)); + + m_boucedAllReady = false; + } +} + +const bool cBall::isPaused() +{ + return m_pause; +} + +void cBall::Pause() +{ + m_pause = !m_pause; +} + +void cBall::BounceX() +{ + float rand = MathEngine::cRandom::Inst().Rand(m_maxSpeed, m_minSpeed); + + m_speed.x = -m_speed.x; + m_speed.y = rand; + + AddPosX((long)m_speed.x); +} + +void cBall::BounceY() +{ + float rand = MathEngine::cRandom::Inst().Rand(m_maxSpeed, m_minSpeed); + + m_speed.x = rand; + m_speed.y = -m_speed.y; + + AddPosY((long)m_speed.y); +} + +void cBall::Reset( const int delay ) +{ + delay; + m_ballState = Serve; +} + +///Sets +void cBall::setSpeed( const float x /*= -10*/, const float y /*= -10*/ ) +{ + m_speed.x = x; + m_speed.y = y; +} + +void cBall::setMaxSpeed( const float max /*= 10*/ ) +{ + m_maxSpeed = max; +} + +void cBall::setMinSpeed( const float min /*= 5*/ ) +{ + m_minSpeed = min; +} + +///Gets +const MathEngine::Vector2 cBall::getSpeed() const +{ + return m_speed; +} + +const float cBall::getMaxSpeed() const +{ + return m_maxSpeed; +} + +const float cBall::getMinSpeed() const +{ + return m_minSpeed; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cBall.hpp b/SDLPongCPP/Game/Equipment/cBall.hpp new file mode 100644 index 0000000..407b574 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cBall.hpp @@ -0,0 +1,60 @@ +#ifndef _CBALL_HPP_ +#define _CBALL_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace Equipment { + class cBall : public VideoEngine::cSprite + { + public: + enum eBallState + { + OnCourt, + LeftOffCourt, + RightOffCourt, + Serve + }; + + cBall( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + ~cBall(); + + ///Functions + void Move(); + const bool isPaused(); + void Pause(); + + void BounceX(); + void BounceY(); + + void Reset( const int delay ); + + ///Sets + void setSpeed( const float x = -10, const float y = -10 ); + void setMaxSpeed( const float max = 10 ); + void setMinSpeed( const float min = 5 ); + + ///Gets + const MathEngine::Vector2 getSpeed() const; + const float getMaxSpeed() const; + const float getMinSpeed() const; + + private: + + + private: + float m_maxSpeed; + float m_minSpeed; + + bool m_boucedAllReady;// = false; + + MathEngine::Vector2 m_speed; + + eBallState m_ballState; + + bool m_pause;// = false + };/// END CLASS DEFINITION cBall +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CBALL_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cCourt.cpp b/SDLPongCPP/Game/Equipment/cCourt.cpp new file mode 100644 index 0000000..b548e0d --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cCourt.cpp @@ -0,0 +1,145 @@ +#include "cCourt.hpp" + +using Equipment::cCourt; +using Equipment::cBall; +using Equipment::cPaddle; + +using MathEngine::cCollision; +using MathEngine::Vector4; +using MathEngine::Vector2; + +cCourt::cCourt( cBall* ball /*= nullptr*/, cPaddle* player1 /*= nullptr*/, cPaddle* player2 /*= nullptr*/, VideoEngine::cImage** image /*= nullptr*/ ) +: cSprite( 0, 0, 0, 0, 640, 480, image), mp_ball(ball), m_pause(false) +{ + m_topWall.x = 0.0f; + m_topWall.y = 0.0f; + m_topWall.z = 640.0f; + m_topWall.w = 14.0f; + + m_bottomWall.x = 0.0f; + m_bottomWall.y = 464.0f; + m_bottomWall.z = 640.0f; + m_bottomWall.w = 14.0f; + + m_leftOff.x = 0.0f; + m_leftOff.y = 0.0f; + m_leftOff.z = 480.0f; + m_leftOff.w = 1.0f; + + m_rightOff.x = 640.0f; + m_rightOff.y = 0.0f; + m_rightOff.z = 480.0f; + m_rightOff.w = 1.0f; + + m_court.x = 0.0f; + m_court.y = 15.0f; + m_court.z = 640.0f; + m_court.w = 450.0f; + + mp_player[0] = player1; + mp_player[1] = player2; + + setImageArea(); +} + +cCourt::~cCourt() +{} + +///Functions +void cCourt::CheckCollision() +{ + if (m_pause == false) + { + CheckPaddles(); + CheckWalls(); + CheckOffCourt(); + } +} + +void cCourt::Quit() +{ +} + +const bool cCourt::isPause() const +{ + return m_pause; +} + +void cCourt::Pause() +{ + m_pause = !m_pause; + + mp_ball->Pause(); + mp_player[0]->Pause(); + mp_player[1]->Pause(); +} + +//private: +//Checks to see if the ball has hit a paddles and then if the paddles have hit a wall. +void cCourt::CheckPaddles() +{ + for (int count = 0; count <= 1; ++count) + { + //Check to see if the ball hit the Paddles. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), mp_ball->getPosition()) == true) + mp_ball->BounceX(); + + //Check to see if the Paddles hit the top wall. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), m_topWall) == true) + mp_player[count]->setPosY((long)m_topWall.w + 1); + + //Check to see if the Paddles hit the bottom wall. + if (cCollision::BoundingBox(mp_player[count]->getPosition(), m_bottomWall) == true) + mp_player[count]->setPosY((long)m_bottomWall.y - 1); + } +} + +//Cheaks to see if the ball has hit the provide wall. +void cCourt::CheckWall(const Vector4& wall) +{ + if (cCollision::BoundingBox(mp_ball->getPosition(), wall) == true) + mp_ball->BounceY(); +} + +//Cheaks to see if the ball has hit the wall. +void cCourt::CheckWalls() +{ + CheckWall(m_topWall); + CheckWall(m_bottomWall); +} + +//Checks to see if the ball is off the provide side of the court. +const bool cCourt::CheckOffCourt(const Vector4& offside) +{ + bool rtn = false; + + if (cCollision::BoundingBox(mp_ball->getPosition(), offside) == true) + { + mp_ball->setSpeed(0,0); + rtn = true; + } + + return rtn; +} + +//Checks to see if the ball is off the court +void cCourt::CheckOffCourt() +{ + MathEngine::Vector2 mov = cCollision::Inside(m_court, mp_ball->getPosition()); + + if (mov.x != 0.0f) + { +// if (mov.x > 0.0f); +// //point to player 1 +// if (mov.x < 0.0f); +// //point to player 2 + } + + if (mov.y != 0.0f) + mp_ball->AddPosY((long)mov.y); + + //if (CheckOffCourt(m_leftOff) == true) + // ; + //if (CheckOffCourt(m_rightOff) == true) + // ; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cCourt.hpp b/SDLPongCPP/Game/Equipment/cCourt.hpp new file mode 100644 index 0000000..f4b2908 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cCourt.hpp @@ -0,0 +1,55 @@ +#ifndef _CCOURT_HPP_ +#define _CCOURT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "cBall.hpp" +#include "cPaddle.hpp" + +namespace Equipment { + class cCourt : public VideoEngine::cSprite + { + public: + cCourt( cBall* ball = nullptr, cPaddle* player1 = nullptr, cPaddle* player2 = nullptr, VideoEngine::cImage** image = nullptr ); + ~cCourt(); + + ///Functions + void CheckCollision(); + void Quit(); + + const bool isPause() const; + void Pause(); + + void Reset(); + + private: + void CheckPaddles(); + + void CheckWall(const MathEngine::Vector4& wall); + void CheckWalls(); + + const bool CheckOffCourt(const MathEngine::Vector4& offside); + void CheckOffCourt(); + + private: + MathEngine::Vector4 m_topWall; + MathEngine::Vector4 m_bottomWall; + + MathEngine::Vector4 m_leftOff; + MathEngine::Vector4 m_rightOff; + + MathEngine::Vector4 m_court; + + cBall* mp_ball;// = nullptr; + cPaddle* mp_player[2];// = nullptr; + //cPaddle* mp_player2;// = nullptr; + + bool m_pause;// = false + };/// END CLASS DEFINITION cCourt +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CCOURT_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cPaddle.cpp b/SDLPongCPP/Game/Equipment/cPaddle.cpp new file mode 100644 index 0000000..2c205d4 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cPaddle.cpp @@ -0,0 +1,66 @@ +#include "cPaddle.hpp" + +using Equipment::cPaddle; + +cPaddle::cPaddle( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: cSprite( xpos, ypos, xarea, yarea, warea, harea, image, camera ), m_speed(0.0), m_pause(false), m_state(Still) +{} + +cPaddle::~cPaddle() +{} + +///Functions +void cPaddle::Move() +{ + if (m_pause == false) + { + float frameTime = TimingEngine::cTiming::Inst().getFrameTime(); + + AddPosY((signed long int)(m_speed * frameTime)); + } +} + +void cPaddle::Pause() +{ + m_pause = !m_pause; +} + +const bool cPaddle::isPaused() +{ + return m_pause; +} + +void cPaddle::Reset() +{} + +///Sets +void cPaddle::setSpeed( const double speed /*= 0.0*/ ) +{ + m_speed = speed; +} + +void cPaddle::setState( const eState state /*= eState::Still*/ ) +{ + m_state = state; + switch (m_state) + { + case Up: + m_speed = -25.0; + break; + case Still: + m_speed = 0.0; + break; + case Down: + m_speed = 25.0; + break; + default: + break; + } +} + +const cPaddle::eState cPaddle::getState() const +{ + return m_state; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cPaddle.hpp b/SDLPongCPP/Game/Equipment/cPaddle.hpp new file mode 100644 index 0000000..274928f --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cPaddle.hpp @@ -0,0 +1,49 @@ +#ifndef _CPADDLE_HPP_ +#define _CPADDLE_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "eBallState.hpp" + +namespace Equipment { + class cPaddle : public VideoEngine::cSprite + { + public: + enum eState { + Up = 0, + Still, + Down + }; + + cPaddle( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + ~cPaddle(); + + ///Functions + void Move(); + const bool isPaused(); + void Pause(); + + void Reset(); + + ///Sets + void setSpeed( const double speed = 0.0 ); + void setState( const eState state = eState::Still ); + + ///Gets + const eState getState() const; + + private: + + private: + double m_speed; + + bool m_pause;// = false + + eState m_state;// = Still + };/// END CLASS DEFINITION cPaddle +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CPADDLE_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cPlayer.cpp b/SDLPongCPP/Game/Equipment/cPlayer.cpp new file mode 100644 index 0000000..91297bc --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cPlayer.cpp @@ -0,0 +1,16 @@ +#include "cPlayer.hpp" + +using Equipment::cPlayer; + +cPlayer::cPlayer( const cString name ) + : m_name(name) +{} + +cPlayer::~cPlayer() +{} + +///Functions +void cPlayer::Score( const unsigned long int score /*= 1*/ ) +{ + m_score += score; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cPlayer.hpp b/SDLPongCPP/Game/Equipment/cPlayer.hpp new file mode 100644 index 0000000..a86dfe6 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cPlayer.hpp @@ -0,0 +1,35 @@ +#ifndef _CPLAYER_HPP_ +#define _CPLAYER_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ + +using UtilityEngine::cString; + +namespace Equipment { + class cPlayer + { + public: + cPlayer( const cString name ); + ~cPlayer(); + + ///Functions + void Score( const unsigned long int score = 1 ); + + ///Sets + void setName( const cString name ); + + ///Gets + const unsigned long int getScore() const; + const cString getName() const; + + private: + private: + unsigned long int m_score;// = 0 + + cString m_name; + };/// END CLASS DEFINITION cPlayer +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CPLAYER_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cScoreBoard.cpp b/SDLPongCPP/Game/Equipment/cScoreBoard.cpp new file mode 100644 index 0000000..85a35b1 --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cScoreBoard.cpp @@ -0,0 +1,19 @@ +#include "cScoreBoard.hpp" + +using Equipment::cScoreBoard; + +cScoreBoard::cScoreBoard() + : m_player1Score(0), m_player2Score(0) +{} + +cScoreBoard::~cScoreBoard() +{} + +///Functions +void cScoreBoard::Score( const unsigned long int player /*= 1*/ ) +{ + if (player == 1) + ++m_player1Score; + if (player == 2) + ++m_player2Score; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/cScoreBoard.hpp b/SDLPongCPP/Game/Equipment/cScoreBoard.hpp new file mode 100644 index 0000000..92ea09d --- /dev/null +++ b/SDLPongCPP/Game/Equipment/cScoreBoard.hpp @@ -0,0 +1,27 @@ +#ifndef _CSCOREBOARD_HPP_ +#define _CSCOREBOARD_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ + +using UtilityEngine::cString; + +namespace Equipment { + class cScoreBoard + { + public: + cScoreBoard(); + ~cScoreBoard(); + + ///Functions + void Score( const unsigned long int player = 1 ); + + private: + private: + unsigned long int m_player1Score;// = 0 + unsigned long int m_player2Score;// = 0 + };/// END CLASS DEFINITION cScoreBoard +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _CSCOREBOARD_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/Equipment/eBallState.hpp b/SDLPongCPP/Game/Equipment/eBallState.hpp new file mode 100644 index 0000000..7fea60a --- /dev/null +++ b/SDLPongCPP/Game/Equipment/eBallState.hpp @@ -0,0 +1,16 @@ +#ifndef _EBALLSTATE_HPP_ +#define _EBALLSTATE_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace Equipment { + enum eBallState + { + OnCourt, + LeftOffCourt, + RightOffCourt, + Serve + };/// END ENUM DEFINITION eBallState +}/// END NAMESPACE DEFINITION Equipment +#endif/// END IFNDEF _EBALLSTATE_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cEsc.cpp b/SDLPongCPP/Game/MainMenu/Input/cEsc.cpp new file mode 100644 index 0000000..e3a4c97 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cEsc.cpp @@ -0,0 +1,40 @@ +#include "cEsc.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" +#include "../eOptions.hpp" + +using Input::cEsc; + +using MainMenu::eOptions; + +cEsc::cEsc( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cEsc::cEsc( const cEsc& copy ) +{}*/ + +cEsc::~cEsc() +{} + +///Funtions +void cEsc::KeyPress() +{ +} + +void cEsc::KeyUP() +{ +} + +void cEsc::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + { + (*mpp_menu)->setOption(eOptions::Quit); + (*mpp_menu)->OptionSelect(); + } +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cEsc.hpp b/SDLPongCPP/Game/MainMenu/Input/cEsc.hpp new file mode 100644 index 0000000..6f2a6d0 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cEsc.hpp @@ -0,0 +1,31 @@ +#ifndef _CESC_HPP_ +#define _CESC_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cEsc : public InputEngine::cKey + { + public: + cEsc( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuUp& copy ); + ~cEsc(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cEsc +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CESC_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuDown.cpp b/SDLPongCPP/Game/MainMenu/Input/cMenuDown.cpp new file mode 100644 index 0000000..a2b71cf --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuDown.cpp @@ -0,0 +1,34 @@ +#include "cMenuDown.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuDown; + +cMenuDown::cMenuDown( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuDown::cMenuDown( const cMenuDown& copy ) +{}*/ + +cMenuDown::~cMenuDown() +{} + +///Funtions +void cMenuDown::KeyPress() +{ +} + +void cMenuDown::KeyUP() +{ +} + +void cMenuDown::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionDown(); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuDown.hpp b/SDLPongCPP/Game/MainMenu/Input/cMenuDown.hpp new file mode 100644 index 0000000..d937779 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuDown.hpp @@ -0,0 +1,31 @@ +#ifndef _CMENUDOWN_HPP_ +#define _CMENUDOWN_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuDown : public InputEngine::cKey + { + public: + cMenuDown( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuDown& copy ); + ~cMenuDown(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuDown +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUDOWN_HPP_ diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.cpp b/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.cpp new file mode 100644 index 0000000..3008cf8 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.cpp @@ -0,0 +1,34 @@ +#include "cMenuSelect.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuSelect; + +cMenuSelect::cMenuSelect( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuSelect::cMenuSelect( const cMenuSelect& copy ) +{}*/ + +cMenuSelect::~cMenuSelect() +{} + +///Funtions +void cMenuSelect::KeyPress() +{ +} + +void cMenuSelect::KeyUP() +{ +} + +void cMenuSelect::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionSelect(); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.hpp b/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.hpp new file mode 100644 index 0000000..f1b0e05 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuSelect.hpp @@ -0,0 +1,31 @@ +#ifndef _CMENUSELECT_HPP_ +#define _CMENUSELECT_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuSelect : public InputEngine::cKey + { + public: + cMenuSelect( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuSelect( const cMenuSelect& copy ); + ~cMenuSelect(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuSelect +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUSELECT_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuUp.cpp b/SDLPongCPP/Game/MainMenu/Input/cMenuUp.cpp new file mode 100644 index 0000000..0b92b76 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuUp.cpp @@ -0,0 +1,34 @@ +#include "cMenuUp.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +using Input::cMenuUp; + +cMenuUp::cMenuUp( SDL_Keycode key, MainMenu::cMainMenu** menu ) +: cKey(key), mpp_menu(menu) +{} + +/*cMenuUp::cMenuUp( const cMenuUp& copy ) +{}*/ + +cMenuUp::~cMenuUp() +{} + +///Funtions +void cMenuUp::KeyPress() +{ +} + +void cMenuUp::KeyUP() +{ +} + +void cMenuUp::KeyDown() +{ + if (mpp_menu != nullptr && *mpp_menu != nullptr) + (*mpp_menu)->OptionUp(); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/Input/cMenuUp.hpp b/SDLPongCPP/Game/MainMenu/Input/cMenuUp.hpp new file mode 100644 index 0000000..8d9d6af --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/Input/cMenuUp.hpp @@ -0,0 +1,31 @@ +#ifndef _CMENUUP_HPP_ +#define _CMENUUP_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../cMainMenu.hpp" + +namespace Input { + class cMenuUp : public InputEngine::cKey + { + public: + cMenuUp( SDL_Keycode key, MainMenu::cMainMenu** menu ); + //cMenuUp( const cMenuUp& copy ); + ~cMenuUp(); + + ///Funtions + /* Call if the key is pressed */ + void KeyPress(); + /* Call if the key is up */ + void KeyUP(); + /* Call if the key is down */ + void KeyDown(); + + private: + private: + MainMenu::cMainMenu** mpp_menu; + };/// END CLASS DEFINITION cMenuUp +}/// END NAMESPACE DEFINITION Input +#endif/// END IFNDEF _CMENUUP_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/cBuildMainMenu.cpp b/SDLPongCPP/Game/MainMenu/cBuildMainMenu.cpp new file mode 100644 index 0000000..2621b05 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/cBuildMainMenu.cpp @@ -0,0 +1,130 @@ +#include "cBuildMainMenu.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +using MainMenu::cBuildMainMenu; +using MainMenu::cMainMenu; +using UtilityEngine::cUtility; + +using tinyxml2::XMLDocument; +using tinyxml2::XMLNode; +using tinyxml2::XMLVisitor; +using tinyxml2::XMLElement; + +cBuildMainMenu::cBuildMainMenu() + : m_ttf(""), m_dir(""), m_lang(""), m_langSettings(""), mp_mainMenu(new cMainMenu()) +{} + +cBuildMainMenu::~cBuildMainMenu() +{} + +///Functions +cMainMenu* cBuildMainMenu::ReadXML() +{ + cString file = "xml/SDLPongCPP.xml"; + XMLDocument doc; + + if ( doc.LoadFile(file.c_str()) == false ) { + //cUtility::Inst().Message("Could not load file." + file + " Error='" + doc.GetErrorStr1 + "'."); + } else { + XMLNode* node = doc.FirstChildElement( "SDLPongCPP" ); + + if (node == nullptr) { + cUtility::Inst().Message("No FirstChildElement( "Settings" ); + if (settingsElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_langSettings = GetAttribute(settingsElement, "lang"); + } + XMLElement* mainmenuElement = node->FirstChildElement( "MainMenu" ); + while (m_langSettings != m_lang) { + if (mainmenuElement == nullptr) { + cUtility::Inst().Message("No tag found."); + } else { + m_lang = GetAttribute(mainmenuElement, "lang"); + /* if the language is the same as the one specified in the settings we read the menu settings */ + if (m_lang == m_langSettings) { + const char* colour = GetAttribute(mainmenuElement, "colour"); + mp_mainMenu->setColour(IntToSDLColour(HexToInt(colour))); + + const char* selectcolour = GetAttribute(mainmenuElement, "selectcolour"); + mp_mainMenu->setSelectColour(IntToSDLColour(HexToInt(selectcolour))); + + const char* titlecolour = GetAttribute(mainmenuElement, "titlecolour"); + mp_mainMenu->setTitleColour(IntToSDLColour(HexToInt(titlecolour))); + + m_ttf = GetAttribute(mainmenuElement, "ttf"); + + const char* soundeffect = GetAttribute(mainmenuElement, "soundeffect"); + + m_dir = GetAttribute(mainmenuElement, "dir"); + + if (m_ttf != "") + mp_mainMenu->setFont(m_dir + "ttf/", m_ttf); + + mp_mainMenu->setSound(m_dir + "snd/", cString(soundeffect)); + + GetOptions( mainmenuElement, "Title" ); + GetOptions( mainmenuElement, "SinglePlayer" ); + GetOptions( mainmenuElement, "HeadToHead" ); + GetOptions( mainmenuElement, "Quit" ); + } else { + mainmenuElement = mainmenuElement->NextSiblingElement(); + } + }/* end else */ + }/* end while */ + } + } + return mp_mainMenu; +} + +void cBuildMainMenu::GetOptions( const XMLElement* element, const cString name ) +{ + const XMLElement* titleElement = element->FirstChildElement( name.c_str() ); + if (titleElement == nullptr) { + cUtility::Inst().Message("Error no tag <" + name + "> found."); + } else { + const char* x = GetAttribute(titleElement, "x"); + const char* y = GetAttribute(titleElement, "y"); + const char* size = GetAttribute(titleElement, "size"); + const char* text = titleElement->GetText(); + + if (name == "Title") + mp_mainMenu->setTitleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "SinglePlayer") + mp_mainMenu->setSingleText(text, atoi(size), atoi(x), atoi(y)); + if (name == "HeadToHead") + mp_mainMenu->setHeadText(text, atoi(size), atoi(x), atoi(y)); + if (name == "Quit") + mp_mainMenu->setQuitText(text, atoi(size), atoi(x), atoi(y)); + } +} + +const char* cBuildMainMenu::GetAttribute( const XMLElement* element, const cString attribute ) const +{ + const char* rtn = element->Attribute(attribute.c_str()); + if (rtn == nullptr) { + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element->Value() + ">"); + rtn = ""; + } + return rtn; +} + +const unsigned long int cBuildMainMenu::HexToInt( const cString str ) const +{ + return strtol(str.c_str(), NULL, 10); +} + +const SDL_Colour cBuildMainMenu::IntToSDLColour( const unsigned long int colour ) const +{ + SDL_Colour rtn = {255, 255, 255}; + + rtn.r = Uint8(colour >> 16); + rtn.g = Uint8(colour >> 8); + rtn.b = Uint8(colour); + + return rtn; +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/cBuildMainMenu.hpp b/SDLPongCPP/Game/MainMenu/cBuildMainMenu.hpp new file mode 100644 index 0000000..c8652fc --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/cBuildMainMenu.hpp @@ -0,0 +1,45 @@ +#ifndef _CBUILDMAINMENU_HPP_ +#define _CBUILDMAINMENU_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** Custom Header Files ***/ +#include "cMainMenu.hpp" + +using UtilityEngine::cString; +using tinyxml2::XMLElement; + +namespace MainMenu { + class cBuildMainMenu + { + public: + cBuildMainMenu(); + ~cBuildMainMenu(); + + ///Functions + cMainMenu* ReadXML(); + + ///Sets + ///Gets + + private: + void GetOptions( const XMLElement* element, const cString name ); + const char* GetAttribute( const XMLElement* element, const cString attribute ) const; + const unsigned long int HexToInt( const cString str ) const; + const SDL_Colour IntToSDLColour( const unsigned long int colour ) const; + + private: + cString m_langSettings;// = "" + cString m_lang;// = "" + + cString m_ttf;// = "" + cString m_dir;// = "" + + cMainMenu* mp_mainMenu;// = new cMainMenu() + };/// END CLASS DEFINITION cBuildMainMenu +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _CBUILDMAINMENU_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/cMainMenu.cpp b/SDLPongCPP/Game/MainMenu/cMainMenu.cpp new file mode 100644 index 0000000..c9a6f43 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/cMainMenu.cpp @@ -0,0 +1,226 @@ +#include "cMainMenu.hpp" + +using MainMenu::cMainMenu; +using MainMenu::eOptions; +using MainMenu::operator ++; +using MainMenu::operator --; + +cMainMenu::cMainMenu() + : mp_camera(nullptr), mp_font(nullptr), mp_titleText(nullptr), mp_singleText(nullptr), mp_headText(nullptr), mp_quitText(nullptr), m_option(Start), m_run(true) +{ + mp_camera = new VideoEngine::cCamera(); + + m_titleSprite.setCamera(&mp_camera); + m_singleSprite.setCamera(&mp_camera); + m_headSprite.setCamera(&mp_camera); + m_quitSprite.setCamera(&mp_camera); + + m_colour.r = 255; + m_colour.g = 0; + m_colour.b = 0; + + m_selectColour.r = 0; + m_selectColour.g = 0; + m_selectColour.b = 255; + + m_titleColour.r = 255; + m_titleColour.g = 255; + m_titleColour.b = 255; +} + +cMainMenu::~cMainMenu() +{ + delete mp_camera; + mp_camera = nullptr; + + delete mp_font; + mp_font = nullptr; + + +} + +const eOptions cMainMenu::ShowMenu() +{ + SingleSelect(); + while (m_run == true) { + Display(); + Input(); + } + + return m_option; +} + +void cMainMenu::OptionUp() +{ + --m_option; + PlaySound(); + switch (m_option) + { + case Start: + SingleSelect(); + break; + case Head: + HeadSelect(); + break; + case Quit: + QuitSelect(); + break; + } +} + +void cMainMenu::OptionDown() +{ + ++m_option; + PlaySound(); + switch (m_option) + { + case Start: + SingleSelect(); + break; + case Head: + HeadSelect(); + break; + case Quit: + QuitSelect(); + break; + } +} + +void cMainMenu::OptionSelect() +{ + m_run = false; +} + +void cMainMenu::setOption( const eOptions option /*= eOptions::Start*/ ) +{ + m_option = option; +} + +void cMainMenu::setSound( const cString dir, const cString filename ) +{ + m_menuSound.setFileNameandDir(filename, dir); + m_menuSound.setLoops(0); +} + +void cMainMenu::setColour( const SDL_Colour colour ) +{ + m_colour = colour; +} + +void cMainMenu::setSelectColour( const SDL_Colour selectcolour ) +{ + m_selectColour = selectcolour; +} + +void cMainMenu::setTitleColour( const SDL_Colour titlecolour ) +{ + m_titleColour = titlecolour; +} + +void cMainMenu::setFont( const cString dir, const cString filename ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont(dir, filename); +} + +void cMainMenu::setTitleText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_titleText = new TextTypeEngine::cText(m_titleColour, &mp_font, text, size); + + m_titleSprite.setPosition(x, y); + m_titleSprite.setImage((VideoEngine::cImage**)(&mp_titleText)); + m_titleSprite.setImageArea(); +} + +void cMainMenu::setSingleText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_singleText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_singleSprite.setPosition(x, y); + m_singleSprite.setImage((VideoEngine::cImage**)(&mp_singleText)); + m_singleSprite.setImageArea(); +} + +void cMainMenu::setHeadText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_headText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_headSprite.setPosition(x, y); + m_headSprite.setImage((VideoEngine::cImage**)(&mp_headText)); + m_headSprite.setImageArea(); +} + +void cMainMenu::setQuitText( const cString text, const long int size, const long int x, const long int y ) +{ + mp_quitText = new TextTypeEngine::cText(m_colour, &mp_font, text, size); + + m_quitSprite.setPosition(x, y); + m_quitSprite.setImage((VideoEngine::cImage**)(&mp_quitText)); + m_quitSprite.setImageArea(); +} + +///Private +void cMainMenu::ResetTextColour() +{ + if (mp_singleText != nullptr) + mp_singleText->setColour(m_colour); + + if (mp_headText != nullptr) + mp_headText->setColour(m_colour); + + if (mp_quitText != nullptr) + mp_quitText->setColour(m_colour); +} + +void cMainMenu::Display() +{ + mp_camera->Draw(); + VideoEngine::cVideo::Inst().Display(); +} + +void cMainMenu::Redraw() +{ + m_titleSprite.CameraDraw(); + m_singleSprite.CameraDraw(); + m_headSprite.CameraDraw(); + m_quitSprite.CameraDraw(); +} + +void cMainMenu::PlaySound() +{ + m_menuSound.PlaySound(); +} + +void cMainMenu::Input() +{ + EventEngine::cEventControl::Inst().CheckEvents(); +} + +void cMainMenu::SingleSelect() +{ + if (mp_singleText == nullptr) + return; + ResetTextColour(); + mp_singleText->setColour(m_selectColour); + Redraw(); +} + +void cMainMenu::HeadSelect() +{ + if (mp_headText == nullptr) + return; + ResetTextColour(); + mp_headText->setColour(m_selectColour); + Redraw(); +} + +void cMainMenu::QuitSelect() +{ + if (mp_quitText == nullptr) + return; + ResetTextColour(); + mp_quitText->setColour(m_selectColour); + Redraw(); +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/cMainMenu.hpp b/SDLPongCPP/Game/MainMenu/cMainMenu.hpp new file mode 100644 index 0000000..4b0a4a5 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/cMainMenu.hpp @@ -0,0 +1,78 @@ +#ifndef _CMAINMENU_HPP_ +#define _CMAINMENU_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "eOptions.hpp" + +using UtilityEngine::cString; + +namespace MainMenu { + class cMainMenu + { + public: + cMainMenu(); + ~cMainMenu(); + + const eOptions ShowMenu(); + + void OptionUp(); + void OptionDown(); + void OptionSelect(); + + //Sets + void setOption( const eOptions option = eOptions::Start ); + + void setSound( const cString dir, const cString filename ); + + void setColour( const SDL_Colour colour ); + void setSelectColour( const SDL_Colour selectcolour ); + void setTitleColour( const SDL_Colour titlecolour ); + + void setFont( const cString dir, const cString filename ); + + void setTitleText( const cString text, const long int size, const long int x, const long int y ); + void setSingleText( const cString text, const long int size, const long int x, const long int y ); + void setHeadText( const cString text, const long int size, const long int x, const long int y ); + void setQuitText( const cString text, const long int size, const long int x, const long int y ); + + private: + void ResetTextColour(); + + void Display(); + void Redraw(); + void PlaySound(); + void Input(); + + void SingleSelect(); + void HeadSelect(); + void QuitSelect(); + + private: + VideoEngine::cCamera* mp_camera;// = nullptr + + VideoEngine::cSprite m_titleSprite; + VideoEngine::cSprite m_singleSprite; + VideoEngine::cSprite m_headSprite; + VideoEngine::cSprite m_quitSprite; + + AudioEngine::cSound m_menuSound; + + SDL_Colour m_colour;// = {255, 0, 0} + SDL_Colour m_selectColour;// = {0, 0, 255} + SDL_Colour m_titleColour;// = {255, 255, 255} + + TextTypeEngine::cFont* mp_font;// = nullptr + + TextTypeEngine::cText* mp_titleText;// = nullptr; + TextTypeEngine::cText* mp_singleText;// = nullptr; + TextTypeEngine::cText* mp_headText;// = nullptr; + TextTypeEngine::cText* mp_quitText;// = nullptr; + + eOptions m_option;// = Start; + bool m_run;// = true; + };/// END CLASS DEFINITION cMainMenu +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _CMAINMENU_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/eOptions.cpp b/SDLPongCPP/Game/MainMenu/eOptions.cpp new file mode 100644 index 0000000..c605349 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/eOptions.cpp @@ -0,0 +1,35 @@ +#include "eOptions.hpp" + +using MainMenu::eOptions; + +void MainMenu::operator++(eOptions& option) +{ + switch (option) + { + case Start: + option = Head; + break; + case Head: + option = Quit; + break; + case Quit: + option = Start; + break; + } +} + +void MainMenu::operator--(eOptions& option) +{ + switch (option) + { + case Start: + option = Quit; + break; + case Head: + option = Start; + break; + case Quit: + option = Head; + break; + } +} \ No newline at end of file diff --git a/SDLPongCPP/Game/MainMenu/eOptions.hpp b/SDLPongCPP/Game/MainMenu/eOptions.hpp new file mode 100644 index 0000000..1783d14 --- /dev/null +++ b/SDLPongCPP/Game/MainMenu/eOptions.hpp @@ -0,0 +1,18 @@ +#ifndef _EOPTIONS_HPP_ +#define _EOPTIONS_HPP_ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +namespace MainMenu { + enum eOptions + { + Start, + Head, + Quit + };/// END ENUM DEFINITION eOptions + + void operator++(eOptions& option); + void operator--(eOptions& option); +}/// END NAMESPACE DEFINITION MainMenu +#endif/// END IFNDEF _EOPTIONS_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Game/PongStart/cPongStart.cpp b/SDLPongCPP/Game/PongStart/cPongStart.cpp new file mode 100644 index 0000000..bd8bf6e --- /dev/null +++ b/SDLPongCPP/Game/PongStart/cPongStart.cpp @@ -0,0 +1,172 @@ +#include "cPongStart.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** Custom Header Files ***/ +#include "../MainMenu/Input/cMenuUp.hpp" +#include "../MainMenu/Input/cMenuDown.hpp" +#include "../MainMenu/Input/cMenuSelect.hpp" +#include "../MainMenu/Input/cEsc.hpp" +#include "../MainMenu/cBuildMainMenu.hpp" + + +#include "../Equipment/cCourt.hpp" +#include "../Equipment/cPaddle.hpp" + +#include "../Equipment/Input/cPlayerUp.hpp" +#include "../Equipment/Input/cPlayerDown.hpp" +#include "../Equipment/Input/cQuitButton.hpp" + +using PongStart::cPongStart; + +cPongStart::cPongStart() +: mp_menu(nullptr), m_option(MainMenu::Start) +{ + TrooperEngineCore::cTrooperEngineCore& core = TrooperEngineCore::cTrooperEngineCore::Inst(); + core.TimerInit(); + core.VideoInit(); + core.AudioInit(); + core.TextTypeInit(); + + if (core.getVideo()) + VideoEngine::cVideo::Inst().Setup(); + if (core.getAudio()) + AudioEngine::cAudio::Inst().Setup(); + if (core.getTimer()) + TimingEngine::cTiming::Inst().Setup(); + if (core.getText()) + TextTypeEngine::cTextType::Inst().Setup(); + + TrooperEngineCore::cTrooperEngineCore::Inst().PrintSDLVersion(); +} + +cPongStart::~cPongStart() +{ + TrooperEngineCore::cTrooperEngineCore::Inst().Delete(); +} + +void cPongStart::Main() +{ + //GUIHelpers::cTexture* temp = new GUIHelpers::cTexture(); + //SDL_Rect rec = {0,0,25,25}; + //temp->GenerateTexture(rec); + //TextTypeEngine::cText* txt = new TextTypeEngine::cText("Hello akjfdklajfdlkjfkljdfalkajdlkfjakljflkjafdlkjflkajdlkfjalkdjflkajdlkfajlkfdjafkljdfkljasdfalk"); + //VideoEngine::cSprite* sprt = new VideoEngine::cSprite((VideoEngine::cImage**)(&txt)); + //sprt->Draw(); +// GUIEngine::cButton* but = new GUIEngine::cButton(0, "button2"); +// but->Draw(); + + //GUIEngine::cWindow* win = new GUIEngine::cWindow(); + GUIEngine::cGUI::Inst().Initialize("GUI.xml", "xml/"); + GUIEngine::cGUI::Inst().Display(); +// GUIEngine::cLayout* lay = new GUIEngine::cLayout(); +// GUIEngine::cLabel* lbl = new GUIEngine::cLabel(lay, 22, "Hello world"); +// +// lbl->setAlign(GUIHelpers::eAlign::RIGHT); +// //lbl->Resize(); +// lay->Resize(); +// lay->Display(); + + + //GUIEngine::cGUI::Inst().AddObject(win); + + //GUIEngine::cGUI::Inst().Display(); + + //while (true) { + EventEngine::cEventControl::Inst().CheckEvents(); + /*SDL_Colour col = { 255, 255, 255, 255}; + SDL_Rect re= { 0, 0, 100, 100}; + FXEngine::cGFX::Inst().RoundedRectangle(re, 4, col);*/ + VideoEngine::cVideo::Inst().Display(); + //break; + //} + system("pause"); + /*MainMenu(); + switch (m_option) + { + case MainMenu::Start: + Start(); + break; + case MainMenu::Head: + HeadtoHead(); + break; + case MainMenu::Quit: + default: + Quit(); + break; + }*/ +} + +///private +void cPongStart::MainMenu() +{ + MainMenu::cBuildMainMenu temp; + mp_menu = temp.ReadXML(); + + Input::cMenuUp* menuup = new Input::cMenuUp(SDLK_a, &mp_menu); + Input::cMenuDown* menudown = new Input::cMenuDown(SDLK_z, &mp_menu); + Input::cMenuSelect* menuselect = new Input::cMenuSelect(SDLK_x, &mp_menu); + Input::cEsc* esc = new Input::cEsc(SDLK_ESCAPE, &mp_menu); + + InputEngine::cKeyboard* menukeyboard = new InputEngine::cKeyboard("MenuKeyboard"); + + menukeyboard->AddKey(menuup); + menukeyboard->AddKey(menudown); + menukeyboard->AddKey(menuselect); + menukeyboard->AddKey(esc); + + InputEngine::cInput::Inst().AddKeyboard(menukeyboard); + + m_option = mp_menu->ShowMenu(); +} + +void cPongStart::Start() +{ + VideoEngine::cImage* p_image = new VideoEngine::cImage("img/", "Equipment.png", true, 0, 0, 0); + VideoEngine::cImage* p_court = new VideoEngine::cImage("img/", "Court.png"); + + Equipment::cBall* ball = new Equipment::cBall(400, 400, 17, 65, 12, 12, &p_image); + Equipment::cPaddle* paddle = new Equipment::cPaddle(0, 0, 0, 0, 16, 77, &p_image); + Equipment::cPaddle* paddle2 = new Equipment::cPaddle(0, 200, 29, 0, 16, 77, &p_image); + + Equipment::cCourt* court = new Equipment::cCourt(ball, paddle, paddle2, &p_court); + + InputEngine::cTextInput text;// = new InputEngine::cTextInput(); + + TimingEngine::cTiming::Inst().setFTP(30); + + while (court->isPause() == false) { + ball->Move(); + paddle->Move(); + paddle2->Move(); + + court->CheckCollision(); + + court->Draw(); + + ball->Draw(); + paddle->Draw(); + paddle2->Draw(); + + TimingEngine::cTiming::Inst().Time(); + VideoEngine::cVideo::Inst().Display(); + } + + delete p_image; + p_image = nullptr; + + delete p_court; + p_court; + + delete court; + court = nullptr; +} + +void cPongStart::HeadtoHead() +{ +} + +void cPongStart::Quit() +{ +} \ No newline at end of file diff --git a/SDLPongCPP/Game/PongStart/cPongStart.hpp b/SDLPongCPP/Game/PongStart/cPongStart.hpp new file mode 100644 index 0000000..f8c8776 --- /dev/null +++ b/SDLPongCPP/Game/PongStart/cPongStart.hpp @@ -0,0 +1,33 @@ +#ifndef _CPONGSTART_HPP_ +#define _CPONGSTART_HPP_ + +/*** Custom Header Files ***/ +#include "../MainMenu/cMainMenu.hpp" +#include "../MainMenu/eOptions.hpp" + +namespace PongStart { + class cPongStart + { + public: + cPongStart(); + ~cPongStart(); + + ///Functions + /* main loop of the game */ + void Main(); + + private: + void MainMenu(); + + void Start(); + void HeadtoHead(); + void Quit(); + + void MenuKeyboard(); + + private: + MainMenu::cMainMenu* mp_menu; + MainMenu::eOptions m_option; + };/// END CLASS DEFINITION cPongStart +}/// END NAMESPACE DEFINITION PongStart +#endif/// END IFNDEF _CPONGSTART_HPP_ \ No newline at end of file diff --git a/SDLPongCPP/Main/main.cpp b/SDLPongCPP/Main/main.cpp new file mode 100644 index 0000000..6b56716 --- /dev/null +++ b/SDLPongCPP/Main/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (C) 2010 Richard W. Allen + Program Name: SDL Pong C++ + Author: Richard W. Allen + Version: V1.0 + Date Started: August 24, 2009 + Date End: + Webpage: http://www.richardallenonline.com + IDE: Visual Studio 2010 + Compiler: C\C++ 2010 + Langage: C++ + License: GNU GENERAL PUBLIC LICENSE Version 2 + see license.txt for details + + SDL Pong C++ Copyright (C) 2010 Richard W. Allen DEATH VALLEY + Comes with ABSOLUTELY NO WARRANTY; + SDL Pong C++ is licensed under the GNU GENERAL PUBLIC LICENSE Version 2. + for details see the license.txt include with this program. +*/ + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "../Game/PongStart/cPongStart.hpp" + +int main(int argc, char *argv[]) +{ + argc, argv; + + PongStart::cPongStart pong; + pong.Main(); + return 0; +} \ No newline at end of file diff --git a/SDLPongCPP/SDLPongCPP.vcxproj b/SDLPongCPP/SDLPongCPP.vcxproj new file mode 100644 index 0000000..61990da --- /dev/null +++ b/SDLPongCPP/SDLPongCPP.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {D0670630-6CBB-4894-BAC6-35FD775E8D8E} + SDLPongCPP + SDLPongCPP + 10.0.15063.0 + + + + Application + MultiByte + true + v141 + + + Application + MultiByte + v141 + + + v141 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + $(TINYXML);$(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2)\VisualC\Win32\Debug;$(SDL2_gfx)\Win32\Debug;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + + + Full + false + ../LinkListDLLProject/dllExportFiles;../TrooperEngineDLLProject/dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + false + Level3 + true + ProgramDatabase + true + + + odbc32.lib;odbccp32.lib;sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;TrooperEngine.lib;LinkList.lib;%(AdditionalDependencies) + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + Windows + true + true + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b6513faa-8bde-45aa-9f1e-326bcbe5d2e8} + false + + + + + + + + + + + \ No newline at end of file diff --git a/SDLPongCPP/SDLPongCPP.vcxproj.filters b/SDLPongCPP/SDLPongCPP.vcxproj.filters new file mode 100644 index 0000000..9b282f6 --- /dev/null +++ b/SDLPongCPP/SDLPongCPP.vcxproj.filters @@ -0,0 +1,146 @@ + + + + + {813fe0d0-021e-4a7a-81f6-8c257531e86f} + + + {b1e548f9-e924-4aeb-b70c-45e0149e8ff3} + + + {7010506c-0310-40f7-a3ea-6e9e99ecdb81} + + + {9e5916e8-437a-4c0d-800a-5ea486c57b97} + + + {d393f48f-a4c2-4a35-a524-e78235977f9e} + + + {cf62df37-481f-445c-834d-74549b98aaa4} + + + {d381fec8-ab66-45a6-b6b9-96e5d5a4bfdb} + + + {7e2b44c1-a033-4c62-92cc-9a03f5cffda9} + + + + + Main + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\Equipment\Input + + + Game\MainMenu + + + Game\MainMenu + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\MainMenu\Input + + + Game\PongStart + + + Game\MainMenu\Input + + + Game\MainMenu + + + Game\Equipment + + + Game\Equipment + + + Game\Equipment + + + + + xml + + + xml + + + xml + + + \ No newline at end of file diff --git a/SDLPongCPP/img/Court.png b/SDLPongCPP/img/Court.png new file mode 100644 index 0000000..3bd4cc7 Binary files /dev/null and b/SDLPongCPP/img/Court.png differ diff --git a/SDLPongCPP/img/Equipment.png b/SDLPongCPP/img/Equipment.png new file mode 100644 index 0000000..c662291 Binary files /dev/null and b/SDLPongCPP/img/Equipment.png differ diff --git a/SDLPongCPP/img/FreeSansBold.ttf b/SDLPongCPP/img/FreeSansBold.ttf new file mode 100644 index 0000000..e75685b Binary files /dev/null and b/SDLPongCPP/img/FreeSansBold.ttf differ diff --git a/SDLPongCPP/img/Thumbs.db b/SDLPongCPP/img/Thumbs.db new file mode 100644 index 0000000..d95f953 Binary files /dev/null and b/SDLPongCPP/img/Thumbs.db differ diff --git a/SDLPongCPP/img/game-sprites.png b/SDLPongCPP/img/game-sprites.png new file mode 100644 index 0000000..eae78cc Binary files /dev/null and b/SDLPongCPP/img/game-sprites.png differ diff --git a/SDLPongCPP/img/game.png b/SDLPongCPP/img/game.png new file mode 100644 index 0000000..74872a1 Binary files /dev/null and b/SDLPongCPP/img/game.png differ diff --git a/SDLPongCPP/img/hyperfont.ttf b/SDLPongCPP/img/hyperfont.ttf new file mode 100644 index 0000000..9b2fcaa Binary files /dev/null and b/SDLPongCPP/img/hyperfont.ttf differ diff --git a/SDLPongCPP/img/menu-opts.png b/SDLPongCPP/img/menu-opts.png new file mode 100644 index 0000000..32f619b Binary files /dev/null and b/SDLPongCPP/img/menu-opts.png differ diff --git a/SDLPongCPP/img/menu.png b/SDLPongCPP/img/menu.png new file mode 100644 index 0000000..0f49840 Binary files /dev/null and b/SDLPongCPP/img/menu.png differ diff --git a/SDLPongCPP/snd/bounce.wav b/SDLPongCPP/snd/bounce.wav new file mode 100644 index 0000000..e2a196e Binary files /dev/null and b/SDLPongCPP/snd/bounce.wav differ diff --git a/SDLPongCPP/snd/game-music.ogg b/SDLPongCPP/snd/game-music.ogg new file mode 100644 index 0000000..c3702c8 Binary files /dev/null and b/SDLPongCPP/snd/game-music.ogg differ diff --git a/SDLPongCPP/snd/getmusic.sh b/SDLPongCPP/snd/getmusic.sh new file mode 100644 index 0000000..87cb486 --- /dev/null +++ b/SDLPongCPP/snd/getmusic.sh @@ -0,0 +1,7 @@ +#!/bin/sh +wget -c http://www.machinaesupremacy.com/downloads/machinae_supremacy_-_masquerade.ogg +ln -s machinae_supremacy_-_masquerade.ogg game-music.ogg +wget -c http://www.machinaesupremacy.com/downloads/machinae_supremacy_-_arcade.ogg +ln -s machinae_supremacy_-_arcade.ogg menu-music.ogg +clear +echo The music is now downloaded. diff --git a/SDLPongCPP/snd/menu-music.ogg b/SDLPongCPP/snd/menu-music.ogg new file mode 100644 index 0000000..1829f41 Binary files /dev/null and b/SDLPongCPP/snd/menu-music.ogg differ diff --git a/SDLPongCPP/snd/menu-opt.wav b/SDLPongCPP/snd/menu-opt.wav new file mode 100644 index 0000000..bad9577 Binary files /dev/null and b/SDLPongCPP/snd/menu-opt.wav differ diff --git a/SDLPongCPP/ttf/FreeSansBold.ttf b/SDLPongCPP/ttf/FreeSansBold.ttf new file mode 100644 index 0000000..e75685b Binary files /dev/null and b/SDLPongCPP/ttf/FreeSansBold.ttf differ diff --git a/SDLPongCPP/xml/GUI.xml b/SDLPongCPP/xml/GUI.xml new file mode 100644 index 0000000..c15422d --- /dev/null +++ b/SDLPongCPP/xml/GUI.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/SDLPongCPP/xml/SDLPongCPP - Copy.xml b/SDLPongCPP/xml/SDLPongCPP - Copy.xml new file mode 100644 index 0000000..4e78dda --- /dev/null +++ b/SDLPongCPP/xml/SDLPongCPP - Copy.xml @@ -0,0 +1,32 @@ + + + + + + SDL Pong C + + + Single Player + + + Head to Head + + + Options + + + Language + + English + + + French + + + + + + Quit + + + \ No newline at end of file diff --git a/SDLPongCPP/xml/SDLPongCPP.xml b/SDLPongCPP/xml/SDLPongCPP.xml new file mode 100644 index 0000000..4e78dda --- /dev/null +++ b/SDLPongCPP/xml/SDLPongCPP.xml @@ -0,0 +1,32 @@ + + + + + + SDL Pong C + + + Single Player + + + Head to Head + + + Options + + + Language + + English + + + French + + + + + + Quit + + + \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.cpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.cpp new file mode 100644 index 0000000..c8442a6 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.cpp @@ -0,0 +1,126 @@ +#include "cAudio.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using AudioEngine::cAudio; +using UtilityEngine::cUtility; + +/*static*/ cAudio* cAudio::sp_inst = nullptr; + +cAudio::cAudio() +: m_rate(22050), m_format(AUDIO_S16), m_channels(2), m_buffers(4096) +{} + +cAudio::~cAudio() +{ + CleanUp(); +} + +//Functions +/*static*/ cAudio& cAudio::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cAudio(); + return *sp_inst; +} + +/*static*/ void cAudio::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cAudio::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) { + cUtility::Inst().Message("Audio initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Audio. SDL_InitSubSystem(SDL_INIT_AUDIO):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +void cAudio::Setup() +{ + CleanUp(); + + if (Mix_OpenAudio(m_rate, Uint16(m_format), m_channels, m_buffers) < 0) + cUtility::Inst().Message("Could not setup mixer. Mix_OpenAudio():", __AT__, cUtility::eTypeSDL::MIXER); + + //Mix_AllocateChannels(number_of_mixing_channels); +} + +void cAudio::CleanUp() +{ + Mix_CloseAudio(); +} + +void cAudio::SoundPlay() +{ + +} +void cAudio::MusicPlay() +{ + +} + +///Sets +void cAudio::setRate( const unsigned long int rate /*= 22050*/ ) +{ + m_rate = rate; +} + +void cAudio::setFormat( const unsigned long int format /*= AUDIO_S16*/ ) +{ + m_format = format; +} + +void cAudio::setChannels( const unsigned long int channels /*= 2*/ ) +{ + m_channels = channels; +} + +void cAudio::setBuffers( const unsigned long int buffers /*= 4096*/ ) +{ + m_buffers = buffers; +} + +///Gets +const bool cAudio::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_AUDIO) != 0) { + cUtility::Inst().Message("Audio is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Audio is not initialized."); + + return rtn; +} + +const unsigned long int cAudio::getRate() const +{ + return m_rate; +} + +const unsigned long int cAudio::getFormat() const +{ + return m_format; +} + +const unsigned long int cAudio::getChannels() const +{ + return m_channels; +} + +const unsigned long int cAudio::getBuffers() const +{ + return m_buffers; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp new file mode 100644 index 0000000..4364d62 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp @@ -0,0 +1,72 @@ +#ifndef _CAUDIO_HPP_ +#define _CAUDIO_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace AudioEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cAudio + { + private: + cAudio(); + ~cAudio(); + + public: + //Functions + static cAudio& Inst(); + static void Delete(); + + const bool Initialize() const; + + /* Sets up the audio */ + void Setup(); + /* Cleans up */ + void CleanUp(); + + /* Plays the sounds */ + void SoundPlay(); + /* Plays the music */ + void MusicPlay(); + + + ///Set + /* Sets the rate */ + void setRate( const unsigned long int rate = 22050 ); + /* Sets the audio format */ + void setFormat( const unsigned long int format = AUDIO_S16 ); + /* Sets the channels */ + void setChannels( const unsigned long int channels = 2 ); + + /* Sets the buffer */ + void setBuffers( const unsigned long int buffers = 4096 ); + + ///Get + /* Gets return true if Audio was initialized */ + const bool IsInit() const; + /* Gets the rate */ + const unsigned long int getRate() const; + /* Gets the format */ + const unsigned long int getFormat() const; + /* Gets the channels */ + const unsigned long int getChannels() const; + + /* Gets the buffers */ + const unsigned long int getBuffers() const; + + private: + private: + ///Variables + unsigned long int m_rate;// = 22050; + unsigned long int m_format;// = AUDIO_S16; + unsigned long int m_channels;// = 2; + unsigned long int m_buffers;// = 4096; + + static cAudio* sp_inst;// = nullptr; + };/// END CLASS DEFINITION cAudio +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CAUDIO_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.cpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.cpp new file mode 100644 index 0000000..4401105 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.cpp @@ -0,0 +1,40 @@ +#include "cMusic.hpp" + +using AudioEngine::cMusic; + +cMusic::cMusic() +{} + +/* Copy constructor */ +cMusic::cMusic(const cMusic& copy) +{ + copy; +} + +cMusic::~cMusic() +{} + +///Functions +/* Plays the music if loaded */ +void cMusic::PlayMusic() +{} + +/* Fades in the music for time */ +void cMusic::FadeIn(const unsigned int time /*= 1000*/) const +{ + time; +} + +/* Fades out the music for time */ +void cMusic::FideOut(const unsigned int time /*= 1000*/) const +{ + time; +} + +/* private:*/ +///Functions +void cMusic::LoadMusic() +{} + +void cMusic::UnloadMusic() +{} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp new file mode 100644 index 0000000..84016ef --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp @@ -0,0 +1,47 @@ +#ifndef _CMUSIC_HPP_ +#define _CMUSIC_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** Custom Header Files ***/ +//#include "cAudio.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +#include "cSound.hpp" + +namespace AudioEngine { + class EXPORT_FROM_MYDLL cMusic + { + public: + cMusic(); + /* Copy constructor */ + cMusic( const cMusic& copy ); + ~cMusic(); + + ///Functions + /* Plays the music if loaded */ + void PlayMusic(); + /* Fades in the music for time */ + void FadeIn( const unsigned int time = 1000 ) const; + /* Fades out the music for time */ + void FideOut( const unsigned int time = 1000 ) const; + + private: + ///Functions + void LoadMusic(); + void UnloadMusic(); + + private: + ///Variables + Mix_Music* mp_music; + + unsigned char m_volume;// = 255 + + + };/// END CLASS DEFINITION cMusic +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CMUSIC_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.cpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.cpp new file mode 100644 index 0000000..16c0434 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.cpp @@ -0,0 +1,154 @@ +#include "cSound.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using AudioEngine::cSound; +using UtilityEngine::cUtility; + +cSound::cSound( const cString& dir /*= ""*/, const cString& filename /*= ""*/, const unsigned char volume /*= 255*/, + const unsigned char distance /*= 100*/, const short int angle /*= 0*/, const long int channel /*= -1*/, + const long int loops /*= -1*/ ) +: mp_sound(nullptr), m_dir(dir), m_fileName(filename), m_volume(volume), m_distance(distance), + m_angle(angle), m_channel(channel), m_loops(loops) +{ + if (m_fileName != "") + LoadSound(); +} + +cSound::cSound( const cSound& copy ) +: mp_sound(nullptr), m_dir(copy.getDir()), m_fileName(copy.getFileName()), m_volume(copy.getVolume()), + m_distance(copy.getDistance()), m_angle(copy.getAngle()), m_channel(copy.getChannel()), + m_loops(copy.getLoops()) +{ + if (m_fileName != "") + LoadSound(); +} + +cSound::~cSound() +{ + UnloadSound(); +} + +void cSound::PlaySound() +{ + if (mp_sound != nullptr) { + if (Mix_Volume(m_channel, m_volume) < 0) + cUtility::Inst().Message("Unable to set volume. Mix_Volume():", __AT__, cUtility::eTypeSDL::MIXER); + if (Mix_SetPosition(m_channel, m_angle, m_distance) < 0) + cUtility::Inst().Message("Unable to set position. Mix_SetPosition():", __AT__, cUtility::eTypeSDL::MIXER); + if (Mix_PlayChannel(m_channel, mp_sound, m_loops) < 0) + cUtility::Inst().Message("Unable to set channel. Mix_PlayChannel():", __AT__, cUtility::eTypeSDL::MIXER); + } +} + +void cSound::FadeIn( const unsigned int time /*= 1000*/ ) const +{ + if (Mix_FadeInChannel(m_channel, mp_sound, m_loops, time) < 0) + cUtility::Inst().Message("Unable to fade in channel. Mix_FadeInChannel():", __AT__, cUtility::eTypeSDL::MIXER); +} + +void cSound::FadeOut( const unsigned int time /*= 1000*/ ) const +{ + if (Mix_FadeOutChannel(m_channel, time) < 0) + cUtility::Inst().Message("Unable to fade out channel. Mix_FadeOutChannel():", __AT__, cUtility::eTypeSDL::MIXER); +} + +///Sets +void cSound::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cSound::setFileName( const cString& filename ) +{ + m_fileName = filename; + LoadSound(); +} + +void cSound::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cSound::setVolume( const unsigned char volume /*= 255*/ ) +{ + m_volume = volume; +} + +void cSound::setDistance( const unsigned char distance /*= 100*/ ) +{ + m_distance = distance; +} + +void cSound::setAngle( const short int angle /*= 0*/ ) +{ + m_angle = angle; +} + +void cSound::setChannel( const long int channel /*= -1*/ ) +{ + m_channel = channel; +} + +void cSound::setLoops( const long int loops /*= -1*/ ) +{ + m_loops = loops; +} + +///Gets +const cString cSound::getDir() const +{ + return m_dir; +} + +const cString cSound::getFileName() const +{ + return m_fileName; +} + +const unsigned char cSound::getVolume() const +{ + return m_volume; +} + +const unsigned char cSound::getDistance() const +{ + return m_distance; +} + +const short int cSound::getAngle() const +{ + return m_angle; +} + +const long int cSound::getChannel() const +{ + return m_channel; +} + +const long int cSound::getLoops() const +{ + return m_loops; +} + +///Private +///Functions +void cSound::LoadSound() +{ + UnloadSound(); + if (m_fileName != "") + if (mp_sound == nullptr) + if ((mp_sound = Mix_LoadWAV(((cString)(m_dir + m_fileName)).c_str())) == nullptr) + cUtility::Inst().Message("Unable to load file. " + m_dir + m_fileName, "", cUtility::eTypeSDL::MIXER); +} + +void cSound::UnloadSound() +{ + if (mp_sound != nullptr) + { + Mix_FreeChunk(mp_sound); + mp_sound = nullptr; + } +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp new file mode 100644 index 0000000..b68f632 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp @@ -0,0 +1,91 @@ +#ifndef _CSOUND_HPP_ +#define _CSOUND_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace AudioEngine { + class EXPORT_FROM_MYDLL cSound + { + public: + cSound( const cString& dir = "", const cString& filename = "", const unsigned char volume = 255, + const unsigned char distance = 100, const short int angle = 0, const long int channel = -1, + const long int loops = -1 ); + /* Copy constructor */ + cSound( const cSound& copy ); + ~cSound(); + + ///Functions + /* Plays the sound if loaded */ + void PlaySound(); + /* Fades in the sound for time */ + void FadeIn( const unsigned int time = 1000 ) const; + /* Fades out the sound for time */ + void FadeOut( const unsigned int time = 1000 ) const; + + ///Sets + /* Sets the directory of the sound */ + void setDir( const cString& dir ); + /* Sets the file name of the sound */ + void setFileName( const cString& filename ); + /* Sets the file name and the directory of the sound */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + /* Sets the Volume of the sound */ + void setVolume( const unsigned char volume = 255 ); + /* Sets the Distance of the sound */ + void setDistance( const unsigned char distance = 100 ); + /* Sets the Angle of the sound */ + void setAngle( const short int angle = 0 ); + /* Sets the Channel of the sound */ + void setChannel( const long int channel = -1); + /* Sets how many times the sound loops */ + void setLoops( const long int loops = -1 ); + + + ///Gets + /* Gets the directory of the sound */ + const cString getDir() const; + /* Gets the file name of the sound */ + const cString getFileName() const; + /* Gets the Volume of the sound */ + const unsigned char getVolume() const; + /* Gets the Distance of the sound */ + const unsigned char getDistance() const; + /* Gets the Angle of the sound */ + const short int getAngle() const; + /* Gets the Channel of the sound */ + const long int getChannel() const; + /* Gets how many times the sound loops */ + const long int getLoops() const; + + private: + ///Functions + void LoadSound(); + void UnloadSound(); + + private: + ///Variables + Mix_Chunk* mp_sound;// = nullptr + + cString m_dir;// = "" + cString m_fileName;// = "" + + + unsigned char m_volume;// = 255 + unsigned char m_distance;// = 100 + + short int m_angle;// = 0 + long int m_channel;// = -1 + long int m_loops;// = 0 + };/// END CLASS DEFINITION cSound +}/// END NAMESPACE DEFINITION AudioEngine +#endif/// END IFNDEF _CSOUND_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp new file mode 100644 index 0000000..c5c7b1f --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp @@ -0,0 +1,297 @@ + +#include "cEvent.hpp" + +using EventEngine::cEvent; + +cEvent::cEvent() +{} + +/*virtual*/ cEvent::~cEvent() +{ + //Do nothing +} + +/*virtual*/ void cEvent::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: + OnMouseButtonUp(event); + break; + case SDL_MOUSEBUTTONUP: + OnMouseButtonDown(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 cEvent::OnInputFocus() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnInputBlur() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnKeyDown(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode) +{ + sym, mod; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnKeyUp(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode) +{ + sym, mod; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnMouseFocus() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnMouseBlur() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::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 cEvent::OnMouseWheel(bool Up, bool Down) +{ + Up, Down; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnLButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnLButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnRButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnRButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnMButtonDown(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnMButtonUp(int mX, int mY) +{ + mX, mY; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value) +{ + which, axis, value; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnJoyButtonDown(SDL_JoystickID which, Uint8 button) +{ + which, button; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnJoyButtonUp(SDL_JoystickID which, Uint8 button) +{ + which, button; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value) +{ + which, hat, value; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel) +{ + which, ball, xrel, yrel; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnMinimize() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnRestore() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnResize(int w, int h) +{ + w, h; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnExpose() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnExit() +{ + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::OnUser(Uint32 type, int code, void* data1, void* data2) +{ + type, code, data1, data2; + //Pure virtual, do nothing +} + +/*virtual*/ void cEvent::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 cEvent::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 cEvent::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/EventEngine/cEvent.hpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp new file mode 100644 index 0000000..e2ac13d --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp @@ -0,0 +1,76 @@ +#ifndef _CEVENT_HPP_ +#define _CEVENT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace EventEngine { + class EXPORT_FROM_MYDLL cEvent + { + public: + public: + cEvent(); + + virtual ~cEvent(); + + 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 ); + };/// END CLASS DEFINITION cEvent +}/// END NAMESPACE DEFINITION EventEngine +#endif/// END IFNDEF _CEVENT_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp new file mode 100644 index 0000000..e536f97 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.cpp @@ -0,0 +1,123 @@ +#include "cEventControl.hpp" + +/*** Custom Header Files ***/ +#include "../InputEngine/cInput.hpp" +#include "../MathEngine/iVector/iVector2.hpp" +#include "../GUIEngine/cGUI.hpp" + +using EventEngine::cEventControl; +using MathEngine::iVector2; + +/*static*/ cEventControl* cEventControl::sp_inst = nullptr; + +//Private +cEventControl::cEventControl() +{} + +cEventControl::~cEventControl() +{ + CleanUp(); + for (unsigned int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +//Public +/*static*/ cEventControl& cEventControl::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cEventControl(); + return *sp_inst; +} + +/*static*/ void cEventControl::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +//Functions +const bool cEventControl::Initialize() const +{ + return true; +} + +const bool cEventControl::Setup() +{ + return true; +} + +void cEventControl::CleanUp() +{ +} + +/* Checks for Events */ +void cEventControl::CheckEvents() +{ + SDL_Event event; + while ( SDL_PollEvent(&event)) { + std::vector::iterator it; + + 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; +// } + } +} + +void cEventControl::AddEvent(EventEngine::cEvent* event) +{ + m_children.push_back(event); +} + +const bool cEventControl::RemoveEvent(EventEngine::cEvent* event) +{ + bool rtn = false; + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (event == (*it)) { + m_children.erase(it); + rtn = true; + //break out of the for loop + break; + } + } + return rtn; +} + +std::vector& cEventControl::GetEvents() +{ + return m_children; +} + + +///Sets + +///Gets +/* Gets return true if Event was initialized */ +const bool cEventControl::IsInit() const +{ + return true; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp new file mode 100644 index 0000000..4eb12cd --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp @@ -0,0 +1,53 @@ +#ifndef _CEVENTCONTROL_HPP_ +#define _CEVENTCONTROL_HPP_ + +/*** C++ STL Files ***/ +#include + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +#include "cEvent.hpp" + +namespace EventEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cEventControl + { + private: + cEventControl(); + ~cEventControl(); + + public: + static cEventControl& Inst(); + static void Delete(); + + //Functions + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + /* Checks for Events */ + void CheckEvents(); + + void AddEvent(EventEngine::cEvent* event); + const bool RemoveEvent(EventEngine::cEvent* event); + + std::vector& GetEvents(); + + + ///Sets + + ///Gets + /* Gets return true if Event was initialized */ + const bool IsInit() const; + + private: + std::vector m_children; + static cEventControl* sp_inst;// = nullptr + };/// END CLASS DEFINITION cEventControl +}/// END NAMESPACE DEFINITION EventEngine +#endif/// END IFNDEF _CEVENTCONTROL_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp new file mode 100644 index 0000000..75f0b51 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp @@ -0,0 +1,116 @@ +#include "cGFX.hpp" + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using FXEngine::cGFX; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cGFX* cGFX::sp_inst = nullptr; + +//private: +cGFX::cGFX() +{} + +cGFX::~cGFX() +{} + +//public: +///Functions +/*static*/ cGFX& cGFX::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGFX(); + return *sp_inst; +} + +/*static*/ void cGFX::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const +{ + if (stringRGBA(cRenderer::Inst().getRenderer(), (Sint16)pos.x, (Sint16)pos.y, text.c_str(), colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + StringDefault(text, pos, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Box(const SDL_Rect& rect, const SDL_Colour& colour) const +{ + if (boxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. boxRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Box(const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Box(rect, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const +{ + if (roundedBoxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, (Sint16)rad, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make Rounded Rectangle. roundedBoxRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const +{ + cRenderer::Inst().SetRenderTarget(texture); + RoundedBox(rect, rad, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour) const +{ + if (pixelRGBA(cRenderer::Inst().getRenderer(), (Sint16)x, (Sint16)y, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. pixelRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Pixel(const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Pixel(x, y, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour) const +{ + if (rectangleRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to make pixel. rectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX); +} + +void cGFX::Rectangle(const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture) const +{ + cRenderer::Inst().SetRenderTarget(texture); + Rectangle(rect, colour); + cRenderer::Inst().ResetRenderTarget(); +} + +void cGFX::ZoomIn(SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/) const +{ + SDL_Surface* surface = cRenderer::Inst().TextureToSurface(texture); + + SDL_DestroyTexture(texture); + texture = nullptr; + + zoomSurface(surface, zoomx, zoomy, smooth); + + texture = cRenderer::Inst().SurfaceToTexture(surface); + + SDL_FreeSurface(surface); + surface = nullptr; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp new file mode 100644 index 0000000..f7149a3 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp @@ -0,0 +1,49 @@ +#ifndef _CGFX_HPP_ +#define _CGFX_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace EXPORT_FROM_MYDLL FXEngine { + /* Singleton */ + class cGFX + { + private: + cGFX(); + ~cGFX(); + + public: + static cGFX& Inst(); + static void Delete(); + + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Box( const SDL_Rect& rect, const SDL_Colour& colour ) const; + void Box( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const; + void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const; + void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const; + void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + + void ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const; + + private: + static cGFX* sp_inst;// = nullptr + };/// END CLASS DEFINITION cGFX +}/// END NAMESPACE DEFINITION FXEngine +#endif/// END IFNDEF _CGFX_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp new file mode 100644 index 0000000..a65c96e --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp @@ -0,0 +1,46 @@ +#ifndef _ENUMS_HPP_ +#define _ENUMS_HPP_ + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + enum EXPORT_FROM_MYDLL eLayout: unsigned int + { + DEFAULT_LAYOUT = 0, + FILL_PARENT, + MATCH_PARENT, + WRAP_CONTENT + };/// END enum DEFINITION eLayout + + enum EXPORT_FROM_MYDLL eType: unsigned int + { + COBJECT, + CWINDOW, + CPANEL, + CLAYOUT, + CBOXSIZER, + CBUTTON, + CTEXTBUTTON, + CLABEL, + };/// END enum DEFINITION eType + + enum EXPORT_FROM_MYDLL eOrientation: unsigned int + { + DEFAULT_ORIENTATION = 0, + NONE, + VERTICAL, + HORIZONTAL + };/// END enum DEFINITION eOrientation + + enum EXPORT_FROM_MYDLL eAlign: unsigned int + { + DEFAULT_ALIGN = 0, + CENTER, + TOP, + RIGHT, + BOTTOM, + LEFT + };/// END enum DEFINITION eAlign +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _ENUMS_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.cpp new file mode 100644 index 0000000..79d0983 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.cpp @@ -0,0 +1,33 @@ +#include "GUIUtility.hpp" + +using namespace GUIHelpers; + +const RGBA GUIHelpers::StringtoRGBA( const cString& colour ) +{ + RGBA rtn = DEFAULT; + cString check = colour.upper(); + if (check == "WHITE") + rtn = WHITE; + if (check == "BLACK") + rtn = BLACK; + if (check == "RED") + rtn = RED; + if (check == "ORANGE") + rtn = ORANGE; + if (check == "YELLOW") + rtn = YELLOW; + if (check == "GREEN") + rtn = GREEN; + if (check == "CYAN") + rtn = CYAN; + if (check == "BLUE") + rtn = BLUE; + if (check == "VIOLET") + rtn = VIOLET; + if (check == "MAGENTA") + rtn = MAGENTA; + if (check == "ROSE") + rtn = ROSE; + + return rtn; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp new file mode 100644 index 0000000..4586251 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp @@ -0,0 +1,47 @@ +#ifndef _GUIUTILITY_HPP_ +#define _GUIUTILITY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../MathEngine/iVector/iVector2.hpp" +#include "../../MathEngine/iVector/iVector4.hpp" + +#include "../../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIHelpers { + typedef struct MathEngine::iVector2 Size, Position; + typedef struct MathEngine::iVector4 Padding; + typedef struct SDL_Colour RGBA; + typedef struct SDL_Rect Area; + + static const RGBA DEFAULT = { 0, 0, 0, 0 }; + + static const RGBA WHITE = { 255, 255, 255, 255 }; + static const RGBA BLACK = { 0, 0, 0, 255 }; + + static const RGBA RED = { 255, 0, 0, 255 }; + + static const RGBA ORANGE = { 255, 128, 0, 255 }; + static const RGBA YELLOW = { 255, 255, 0, 255 }; + + static const RGBA GREEN = { 0, 255, 0, 255 }; + + static const RGBA CYAN = { 0, 255, 255, 255 }; + + static const RGBA BLUE = { 0, 0, 255, 255 }; + + static const RGBA VIOLET = { 128, 0, 255, 255 }; + static const RGBA MAGENTA = { 255, 0, 255, 255 }; + static const RGBA ROSE = { 255, 0, 128, 255 }; + + + const RGBA StringtoRGBA(const cString& colour); + + +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _GUIUTILITY_HPP_ + diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.cpp new file mode 100644 index 0000000..9cf188f --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.cpp @@ -0,0 +1,41 @@ +#include "cObject.hpp" + +#include "../cGUI.hpp" + +using GUIHelpers::cObject; + +cObject::cObject( const signed int id ) + : m_id(id) +{ + //GUIEngine::cGUI::Inst().AddObject(this); +} + +/*virtual*/ cObject::~cObject() +{} + +bool cObject::operator == (const cObject& other) +{ + if (m_id == other.getID()) + return true; + else + return false; +} + +///Functions + +///Sets +const void cObject::setID( const signed int id ) +{ + m_id = id; +} + +///Gets +const signed int cObject::getID() const +{ + return m_id; +} + +/*virtual*/ const GUIHelpers::eType cObject::getType() const +{ + return GUIHelpers::eType::COBJECT; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp new file mode 100644 index 0000000..32bd1d0 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp @@ -0,0 +1,32 @@ +#ifndef _COBJECT_HPP_ +#define _COBJECT_HPP_ + +/*** Custom Header Files ***/ +#include "Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cObject + { + public: + cObject( const signed int id ); + virtual ~cObject(); + + bool operator == (const cObject& other); + + ///Functions + + ///Sets + const void setID( const signed int id ); + + ///Gets + const signed int getID() const; + virtual const GUIHelpers::eType getType() const; + + private: + signed int m_id;// = 0 + };/// END CLASS DEFINITION cObject +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _COBJECT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.cpp new file mode 100644 index 0000000..fcc74e1 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.cpp @@ -0,0 +1,81 @@ +#include "cTexture.hpp" + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cRenderer.hpp" +#include "../../FXEngine/cGFX.hpp" +#include "GUIUtility.hpp" + +using GUIHelpers::cTexture; + +cTexture::cTexture() +{} + +cTexture::~cTexture() +{} + +///Functions + +//private +SDL_Texture* cTexture::GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text /*= nullptr*/ ) +{ + SDL_Rect t = text->getWH(); + SDL_Rect centerText = { 0, 0, 0, 0 }; + SDL_Rect centerButton = { 0, 0, 0, 0 }; + SDL_Rect dim = dimensions; + + ///Find the min padding around the text. +// if (dim.w < (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w) ) +// dim.w += (t.w + GUIHelpers::default::text::PADDING.x + GUIHelpers::default::text::PADDING.w); +// +// if (dim.h < (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z) ) +// dim.h += (t.h + GUIHelpers::default::text::PADDING.y + GUIHelpers::default::text::PADDING.z); + + ///Find the center of the button + centerButton.x = dim.w / 2; + centerButton.y = dim.h / 2; + + ///Find the center of the text + centerText.x = t.w / 2; + centerText.y = t.h / 2; + + if (centerText.x < centerButton.x) + t.x = centerButton.x - centerText.x; + + if (centerText.y < centerButton.y) + t.y = centerButton.y - centerText.y; + + SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); + + GUIHelpers::RGBA colour = { 100, 100, 100, 255 }; + + FXEngine::cGFX::Inst().RoundedBox(dim, 0, colour, temptext); + + + VideoEngine::cRenderer::Inst().RenderToTexture(text->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + + setImage(temptext); + + return temptext; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.hpp new file mode 100644 index 0000000..23224a7 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cTexture.hpp @@ -0,0 +1,28 @@ +#ifndef _CTEXTURE_HPP_ +#define _CTEXTURE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../../VideoEngine/cImage.hpp" +#include "../../TextTypeEngine/cText.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cTexture : public VideoEngine::cImage + { + public: + cTexture(); + ~cTexture(); + + ///Functions + SDL_Texture* GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text = nullptr ); + + private: + + };/// END CLASS DEFINITION cTexture +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CTEXTURE_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.cpp new file mode 100644 index 0000000..e90a1c1 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.cpp @@ -0,0 +1,451 @@ +#include "cXMLoader.hpp" + +/*** Custom Header Files ***/ +#include "../../UtilityEngine/cUtility.hpp" + +#include "../cGUI.hpp" +#include "../cLayout.hpp" + +using GUIHelpers::cXMLoader; + +using UtilityEngine::cUtility; + + +cXMLoader::cXMLoader() +{ + m_loadDef = false; + m_orientation = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + m_align = GUIHelpers::eAlign::DEFAULT_ALIGN; + m_layout = GUIHelpers::eLayout::DEFAULT_LAYOUT; + m_pos = { -1, -1 }; + m_size = { -1, -1 }; + m_pad = { -1, -1, -1, -1 }; +} + +cXMLoader::~cXMLoader() +{} + +///Functions + +void cXMLoader::Load( const cString& filename, const cString& dir /*= ""*/, GUIEngine::cWindow* parent /*= nullptr*/ ) +{ + cString file = dir + filename; + tinyxml2::XMLDocument doc; + + if (doc.LoadFile(file.c_str()) != tinyxml2::XMLError::XML_NO_ERROR) + cUtility::Inst().Message("Could not load file. " + file + " Error='" + doc.ErrorName() + "'."); + else { + tinyxml2::XMLElement* element = doc.FirstChildElement(); + + if (element == nullptr) + cUtility::Inst().Message("No tag found."); + else { + //OK check for defaults + tinyxml2::XMLElement* defaultEl = element->FirstChildElement("default"); + if (defaultEl != nullptr) + Default(*defaultEl); + tinyxml2::XMLElement* debugEl = element->FirstChildElement("debug"); + if (debugEl != nullptr) + Debug(*debugEl); + GetElement(*element, parent); + } + } + +} + +void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent /*= nullptr*/ ) const +{ + cString name = element.Name(); + name = name.lower(); + GUIEngine::cWindow* tmp = nullptr; + if (name == "include") + Include(element, parent); + if (name == "gui") + GUISetup(element); + if (name == "panel") + tmp = PanelBuild(element, parent); + if (name == "layout") + tmp = LayoutBuild(element, parent); + if (name == "label") + tmp = LabelBuild(element, parent); + if (name == "boxsizer") + tmp = BoxSizerBuild(element, parent); + + tinyxml2::XMLElement* child = element.FirstChildElement(); + if (child != nullptr) + GetElement(*child, tmp); + + tinyxml2::XMLElement* sibling = element.NextSiblingElement(); + if (sibling != nullptr) + GetElement(*sibling, parent); + + if ((parent == nullptr) && (tmp != nullptr)) + tmp->Resize(); +} + +const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const +{ + cString rtn = ""; + const char* str = element.Attribute(attribute.c_str()); + if ((str == nullptr) && (m_debugXML == true)) + cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element.Value() + ">"); + else + rtn = str; + return rtn; +} + +void cXMLoader::Include(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const +{ + cString dir = getDir(element); + cString filename = getFileName(element); + + cXMLoader include; + include.Load(filename, dir, parent); + + LoadDefault(); +} + +void cXMLoader::GUISetup( const tinyxml2::XMLElement& element ) const +{ + unsigned long int debug = getDebug(element); + + GUIEngine::cGUI::Inst().setDebugLevel(debug); +} + +void cXMLoader::Default( const tinyxml2::XMLElement& element ) +{ + m_orientation = getOrientation(element); + m_align = getAlign(element); + m_layout = getLayout(element); + m_pos = getPosition(element); + m_size = getSize(element); + m_pos = getPadding(element); + + m_loadDef = true; + + LoadDefault(); +} + +void cXMLoader::Debug(const tinyxml2::XMLElement& element) +{ + unsigned long int debug = getDebug(element); + m_debugXML = getDebugXML(element); + + GUIEngine::cGUI::Inst().setDebugLevel(debug); +} + +GUIEngine::cPanel* cXMLoader::PanelBuild(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + GUIEngine::cPanel* rtn = new GUIEngine::cPanel(parent, id, orientation, align, layout, pos, size, pad); + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLayout* cXMLoader::LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = { -1, -1 };// getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + + GUIEngine::cLayout* rtn = new GUIEngine::cLayout(parent, id, orientation, align, layout, pos, size, pad); + + + if (parent == nullptr) + GUIEngine::cGUI::Inst().AddObject(rtn); + + return rtn; +} + +GUIEngine::cLabel* cXMLoader::LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const +{ + signed long int id = getID(element); + //GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = { -1, -1 };//getSize(element); + GUIHelpers::Padding pad = getPadding(element); + GUIHelpers::RGBA colour = getColour(element); + signed long int fontSize = getFontSize(element); + + cString txt = getText(element); + + GUIEngine::cLabel* rtn = new GUIEngine::cLabel(parent, id, txt, align, layout, pos, size, pad); + rtn->setFontColour(colour); + if (fontSize > 0) + rtn->setFontSize((unsigned long int)fontSize); + + return rtn; +} + +GUIEngine::cBoxSizer* cXMLoader::BoxSizerBuild(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const +{ + signed long int id = getID(element); + //GUIHelpers::eOrientation orientation = getOrientation(element); + GUIHelpers::eAlign align = getAlign(element); + GUIHelpers::eLayout layout = getLayout(element); + GUIHelpers::Position pos = getPosition(element); + GUIHelpers::Size size = getSize(element); + GUIHelpers::Padding pad = getPadding(element); + + cString txt = getText(element); + + GUIEngine::cBoxSizer* rtn = new GUIEngine::cBoxSizer(parent, id, align, layout, pos, size, pad); + + return rtn; +} + +const cString cXMLoader::getDir(const tinyxml2::XMLElement& element) const +{ + cString rtn = GetAttribute(element, "dir"); + return rtn; +} + +const cString cXMLoader::getFileName(const tinyxml2::XMLElement& element) const +{ + cString rtn = GetAttribute(element, "filename"); + return rtn; +} + +const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element ) const +{ + unsigned long int rtn = 99; + cString str = GetAttribute(element, "level").lower(); + + if (str != "") { + if (str == "true") + rtn = 1; + else { + if (str != "false") + rtn = 0; + else + rtn = str.ToInt(); + } + } + + return rtn; +} + +const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const +{ + bool rtn = false; + cString str = GetAttribute(element, "xml").lower(); + + if ((str != "") && (str != "false")) { + if (str == "true") + rtn = true; + else { + if (str.ToInt() > 0) + rtn = true; + } + } + return rtn; +} + +const signed long int cXMLoader::getID( const tinyxml2::XMLElement& element ) const +{ + cString rtn = GetAttribute(element, "id"); + return rtn.ToInt(); +} + +const GUIHelpers::eOrientation cXMLoader::getOrientation( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eOrientation rtn = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + + cString str = GetAttribute(element, "orientation").lower(); + + if (str == "none") + rtn = GUIHelpers::eOrientation::NONE; + if (str == "horizontal") + rtn = GUIHelpers::eOrientation::HORIZONTAL; + if (str == "vertical") + rtn = GUIHelpers::eOrientation::VERTICAL; + + return rtn; +} + +const GUIHelpers::eAlign cXMLoader::getAlign( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eAlign rtn = GUIHelpers::eAlign::DEFAULT_ALIGN; + + cString str = GetAttribute(element, "align").lower(); + + if (str == "center") + rtn = GUIHelpers::eAlign::CENTER; + if (str == "top") + rtn = GUIHelpers::eAlign::TOP; + if (str == "right") + rtn = GUIHelpers::eAlign::RIGHT; + if (str == "bottom") + rtn = GUIHelpers::eAlign::BOTTOM; + if (str == "left") + rtn = GUIHelpers::eAlign::LEFT; + + return rtn; +} + +const GUIHelpers::eLayout cXMLoader::getLayout( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::eLayout rtn = GUIHelpers::eLayout::DEFAULT_LAYOUT; + + cString str = GetAttribute(element, "layout").lower(); + + if (str == "fill_parent") + rtn = GUIHelpers::eLayout::FILL_PARENT; + if (str == "match_parent") + rtn = GUIHelpers::eLayout::MATCH_PARENT; + if (str == "wrap_content") + rtn = GUIHelpers::eLayout::WRAP_CONTENT; + + return rtn; +} + +const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Position rtn = { -1, -1 }; + + cString str = GetAttribute(element, "position"); + + if (str != "") { + rtn = { 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Size rtn = { -1, -1 }; + + cString str = GetAttribute(element, "size"); + + if (str != "") { + rtn = { 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::Padding rtn = { -1, -1, -1, -1 }; + + cString str = GetAttribute(element, "padding"); + + if (str != "") { + rtn = { 0, 0, 0, 0 }; + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 4: + rtn.z = strV[3].ToInt(); + case 3: + rtn.w = strV[2].ToInt(); + case 2: + rtn.y = strV[1].ToInt(); + case 1: + rtn.x = strV[0].ToInt(); + } + } + + return rtn; +} + +const cString cXMLoader::getText( const tinyxml2::XMLElement& element ) const +{ + return GetAttribute(element, "text"); +} + +const GUIHelpers::RGBA cXMLoader::getColour( const tinyxml2::XMLElement& element ) const +{ + GUIHelpers::RGBA rtn = GUIHelpers::DEFAULT; + cString str = GetAttribute(element, "colour"); + + if (str == "") + str = GetAttribute(element, "color"); + + if (str != "") { + std::vector strV = str.split(","); + + switch (strV.size()) + { + case 4: + rtn.a = strV[3].ToInt(); + case 3: + rtn.b = strV[2].ToInt(); + case 2: + rtn.g = strV[1].ToInt(); + case 1: + if (strV[0].IsInt() == true) { + rtn.r = strV[0].ToInt(); + if (strV.size() < 4) + rtn.a = 255; + } + else + rtn = GUIHelpers::StringtoRGBA(str); + break; + default: + + break; + } + } + return rtn; +} + +const signed long int cXMLoader::getFontSize( const tinyxml2::XMLElement& element ) const +{ + signed long int rtn = -1; + cString str = GetAttribute(element, "fontsize"); + + if (str != "") + rtn = str.ToInt(); + + return rtn; +} + +void cXMLoader::LoadDefault() const +{ + if (m_loadDef == false) + return; + GUIEngine::cWindow::OrientationDefault(m_orientation); + GUIEngine::cWindow::AlignDefault(m_align); + GUIEngine::cWindow::LayoutDefault(m_layout); + GUIEngine::cWindow::PositionDefault(m_pos); + GUIEngine::cWindow::SizeDefault(m_size); + GUIEngine::cWindow::PaddingDefault(m_pad); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp new file mode 100644 index 0000000..82ca75f --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp @@ -0,0 +1,76 @@ +#ifndef _CXMLOADER_HPP_ +#define _CXMLOADER_HPP_ + +/*** TinyXML Header File ***/ +#include "tinyxml2.h" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "GUIUtility.hpp" + +#include "../cWindow.hpp" +#include "../cPanel.hpp" +#include "../cLayout.hpp" +#include "../cLabel.hpp" +#include "../cBoxSizer.hpp" + +#include "../../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIHelpers { + class EXPORT_FROM_MYDLL cXMLoader + { + public: + cXMLoader(); + ~cXMLoader(); + + void Load( const cString& filename, const cString& dir = "", GUIEngine::cWindow* parent = nullptr ); + + private: + void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const; + const cString GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const; + + void Include( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + void GUISetup( const tinyxml2::XMLElement& element ) const; + void Default( const tinyxml2::XMLElement& element ); + void Debug( const tinyxml2::XMLElement& element ); + + GUIEngine::cPanel* PanelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cLayout* LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + GUIEngine::cBoxSizer* BoxSizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const; + + const cString getDir( const tinyxml2::XMLElement& element ) const; + const cString getFileName( const tinyxml2::XMLElement& element ) const; + const unsigned long int getDebug( const tinyxml2::XMLElement& element ) const; + const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const; + const signed long int getID( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eOrientation getOrientation( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eAlign getAlign( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::eLayout getLayout( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Position getPosition( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Size getSize( const tinyxml2::XMLElement& element ) const; + const GUIHelpers::Padding getPadding( const tinyxml2::XMLElement& element ) const; + const cString getText( const tinyxml2::XMLElement& element ) const; + + const GUIHelpers::RGBA getColour( const tinyxml2::XMLElement& element ) const; + const signed long int getFontSize( const tinyxml2::XMLElement& element ) const; + + void LoadDefault() const; + + private: + bool m_loadDef;// = false; + bool m_debugXML; + + GUIHelpers::eOrientation m_orientation;// = GUIHelpers::eOrientation::DEFAULT_ORIENTATION; + GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::DEFAULT_ALIGN; + GUIHelpers::eLayout m_layout;// = GUIHelpers::eLayout::DEFAULT_LAYOUT; + GUIHelpers::Position m_pos;// = { -1, -1 }; + GUIHelpers::Size m_size;// = { -1, -1 }; + GUIHelpers::Padding m_pad;// = { -1, -1, -1, -1 }; + };/// END CLASS DEFINITION cXMLoader +}/// END NAMESPACE DEFINITION GUIHelpers +#endif/// END IFNDEF _CXMLOADER_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.cpp new file mode 100644 index 0000000..ef71732 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.cpp @@ -0,0 +1,40 @@ +#include "cBoxSizer.hpp" + +using GUIEngine::cBoxSizer; + +/*static*/ const cString cBoxSizer::sNAME = "boxsizer"; +/*static*/ GUIHelpers::Size cBoxSizer::sSIZE = { 5, 5 }; + +cBoxSizer::cBoxSizer( 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*/ ) +{ + Create(parent, id, align, layout, pos, size, padding, name); +} + +/*virtual*/ cBoxSizer::~cBoxSizer() +{} + +///Functions +void cBoxSizer::Create( 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*/ ) +{ + GUIHelpers::Size sz = size; + if (size.x < 0) + sz = sSIZE; + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, sz, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ const GUIHelpers::eType cBoxSizer::getType() const +{ + return GUIHelpers::eType::CBOXSIZER; +} + +/*virtual*/ const GUIHelpers::RGBA cBoxSizer::getDebugColour() const +{ + return GUIHelpers::CYAN; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.hpp new file mode 100644 index 0000000..182e1e4 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cBoxSizer.hpp @@ -0,0 +1,45 @@ +#ifndef _CBOXSIZER_HPP_ +#define _CBOXSIZER_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cPanel.hpp" +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cBoxSizer : public cWindow + { + public: + static const cString sNAME; /*= "boxsizer";*/ + static GUIHelpers::Size sSIZE; /*= { 5, 5 }*/ + + cBoxSizer( 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 ); + virtual ~cBoxSizer(); + + ///Functions + void Create( 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 ); + + virtual const GUIHelpers::eType getType() const; + virtual const GUIHelpers::RGBA getDebugColour() const; + private: + private: + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp new file mode 100644 index 0000000..0f271f3 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.cpp @@ -0,0 +1,170 @@ +#include "cButton.hpp" + +/*** Custom Header Files ***/ +#include "GUIHelpers/Enums.hpp" +#include "../VideoEngine/cRenderer.hpp" +#include "../FXEngine/cGFX.hpp" + +using GUIEngine::cButton; + +using MathEngine::iVector2; +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*/ ) + : cWindow(parent, id, sORIENTATION, align, layout, pos, size, padding, name) +{ + //Create(parent, id, align, layout, pos, size, padding, name, image); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ cButton::~cButton() +{ + delete mp_texture; + mp_texture = nullptr; + + delete mp_texturePress; + mp_texturePress = nullptr; + +} + +///Functions +void cButton::Create( 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*/ ) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + mp_texture = nullptr; + mp_texturePress = nullptr; + + mpp_image = image; + + GenerateImage(); +} + +/*virtual*/ void cButton::Press() +{ + mp_texture->SaveImage("hello.bmp"); +} + +// void cButton::setLabel( const cString& label ) +// { +// if (label.size() > 0) { +// if (mp_label == nullptr) +// mp_label = new TextTypeEngine::cText(label); +// else +// mp_label->setText(label); +// } +// } + +///Gets +// const cString cButton::getLabel() const +// { +// cString rtn = ""; +// if (mp_label != nullptr) +// rtn = mp_label->getText(); +// return rtn; +// } + +/*virtual*/ const GUIHelpers::eType cButton::getType() const +{ + return GUIHelpers::eType::CBUTTON; +} + + +//private +void cButton::GenerateImage() +{ + GenerateTexture(); + //GenerateTexture( mp_texturePress ); + + this->setImage((VideoEngine::cImage**)(&mp_texture)); + + this->setImageArea(mp_texture->getWH()); +} + +void cButton::GenerateTexture() +{ +// SDL_Rect t = { 0, 0, 0, 0 }; +// if (mp_label != nullptr) +// t = mp_label->getWH(); +// SDL_Rect centerText = { 0, 0, 0, 0 }; +// SDL_Rect centerButton = { 0, 0, 0, 0 }; +// SDL_Rect dim = this->getImageArea(); +// +// GUIHelpers::Padding TXTPADDING = PADDING; +// ///Find the min padding around the text. +// if (dim.w < (t.w + TXTPADDING.x + TXTPADDING.w) ) +// dim.w += (t.w + TXTPADDING.x + TXTPADDING.w); +// +// if (dim.h < (t.h + TXTPADDING.y + TXTPADDING.z) ) +// dim.h += (t.h + TXTPADDING.y + TXTPADDING.z); +// +// ///Find the center of the button +// centerButton.x = dim.w / 2; +// centerButton.y = dim.h / 2; +// +// ///Find the center of the text +// centerText.x = t.w / 2; +// centerText.y = t.h / 2; +// +// if (centerText.x < centerButton.x) +// t.x = centerButton.x - centerText.x; +// +// if (centerText.y < centerButton.y) +// t.y = centerButton.y - centerText.y; +// +// SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET ); +// +// GUIHelpers::RBGA colour = { 100, 100, 100, 255 }; +// +// FXEngine::cGFX::Inst().RoundedRectangle(dim, 4, colour, temptext); +// +// +// if (mp_label != nullptr) +// VideoEngine::cRenderer::Inst().RenderToTexture(mp_label->getImage(), nullptr, temptext, &t); + + + //cRenderer::Inst().Render(temptext, nullptr, nullptr); + + //cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr); + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(), + 0, 0, 0, 0); + + SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0)); + + /*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0) + cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/ + + + /*if (text != nullptr) { + SDL_Rect srcrect, dstrect = dimensions; + cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect); + } + + this->setImage(temptext); + this->setTransparent();*/ + +// delete mp_texture; +// mp_texture = nullptr; +// +// mp_texture = new VideoEngine::cImage(temptext); +// +// GUIHelpers::Size size = { 0, 0 }; +// mp_texture->getWH((unsigned long&)size.x, (unsigned long&)size.y); +// cWindow::setSize(size); +// image->setImage(temptext); + //image->setImage(temptext); +} diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp new file mode 100644 index 0000000..f2df3b4 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp @@ -0,0 +1,63 @@ +#ifndef _CBUTTON_HPP_ +#define _CBUTTON_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" +#include "../VideoEngine/cSprite.hpp" +#include "../VideoEngine/cImage.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +#include "cPanel.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cButton : public cWindow, public VideoEngine::cSprite + { + 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 ); + virtual ~cButton(); + + ///Functions + void Create( 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 ); + + virtual void Press(); + + //Sets + + ///Gets + virtual const GUIHelpers::eType getType() const; + + private: + void CreateLabel(); + void GenerateImage(); + void GenerateTexture(); + + private: + VideoEngine::cImage* mp_texture;// = nullptr + VideoEngine::cImage* mp_texturePress;// = nullptr + + //Pointer to the image that will be displayed on the button. + VideoEngine::cImage** mpp_image;// = 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/cGUI.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp new file mode 100644 index 0000000..afe0eac --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.cpp @@ -0,0 +1,215 @@ +#include "cGUI.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" + +#include "../UtilityEngine/cUtility.hpp" +#include "GUIHelpers/Enums.hpp" +#include "cButton.hpp" + +#include "GUIHelpers/cXMLoader.hpp" + +using GUIEngine::cGUI; + +using UtilityEngine::cUtility; + +/*static*/ cGUI* cGUI::sp_inst = nullptr; + +//private +cGUI::cGUI() + : m_debugLevel(0), mp_font(nullptr), m_inited(false) +{ + setTextColour(); + setPadding(); +} + +cGUI::~cGUI() +{ + delete mp_font; + mp_font = nullptr; + + for (int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +//public: +///Functions +/*static*/ cGUI& cGUI::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cGUI(); + return *sp_inst; +} + +/*static*/ void cGUI::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cGUI::Initialize( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +{ + bool rtn = IsInit(); + + GUIHelpers::cXMLoader xml; + xml.Load(filename, dir); + //GUIHelpers::cXMLoader::Inst().Load(filename, dir); +// if (rtn == false) { +// setFont( filename, dir, size ); +// cUtility::Inst().Message("GUI initialized."); +// } + + return rtn; +} + +void cGUI::Event(const MathEngine::iVector2& location, const eGUIEventType& type) +{ + location; + type; +// std::vector::iterator it; +// +// for (it = m_objects.begin(); it < m_objects.end(); it++) { +// switch ((*it)->getType()) { +// case GUIHelpers::eType::CBUTTON: +// cButton* tmp = (cButton*)(*it); +// if (tmp->InSide(location) == true) +// cUtility::Inst().Message("Button Inside!"); +// break; +// } +// } +} + +const MathEngine::iVector2 cGUI::DisplayArea() const +{ + MathEngine::iVector2 rtn = { 0, 0 }; + rtn.x = VideoEngine::cVideo::Inst().getWidth(); + rtn.y = VideoEngine::cVideo::Inst().getHeight(); + + return rtn; +} + +void cGUI::AddObject( GUIEngine::cWindow* obj ) +{ + m_children.push_back(obj); +} + +std::vector& cGUI::GetObjects() +{ + return m_children; +} + +void cGUI::Display() +{ + //m_obj->Display(); + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } +} + +///Sets +void cGUI::setDebugLevel(const unsigned long int debugLevel) +{ + m_debugLevel = debugLevel; +} + +void cGUI::setFont( TextTypeEngine::cFont* font ) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = font; +} + +void cGUI::setFont( const cString& filename, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/) +{ + delete mp_font; + mp_font = nullptr; + + mp_font = new TextTypeEngine::cFont( dir, filename, size ); +} + +void cGUI::setTextColour( const GUIHelpers::RGBA& colour ) +{ + //cWindow::sCOLOUR = colour; +} + +void cGUI::setTextColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/ ) +{ + GUIHelpers::RGBA colour = {Uint8(red), Uint8(green), Uint8(blue)}; + setTextColour(colour); +} + +void cGUI::setPadding( const GUIHelpers::Padding& padding ) +{ + //cWindow::sPADDING = padding; +} + +void cGUI::setPadding( const unsigned int top /*= 5*/, const unsigned int right /*= 5*/, const unsigned int bottom /*= 5*/, const unsigned int left /*= 5*/ ) +{ + setPadding(GUIHelpers::Padding(top, right, bottom, left)); +} + +void cGUI::setAlign( const GUIHelpers::eAlign& align /*= GUIHelpers::eAlign::CENTER*/ ) +{ + //cWindow::sALIGN = align; +} + +///Gets +const unsigned long int cGUI::getDebugLevel() const +{ + return m_debugLevel; +} + +TextTypeEngine::cFont* cGUI::getFont() +{ + return mp_font; +} + +const GUIHelpers::RGBA& cGUI::getTextColour() const +{ + return {};//cWindow::sCOLOUR; +} + +void cGUI::getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const +{ +// red = cWindow::sCOLOUR.r; +// green = cWindow::sCOLOUR.g; +// blue = cWindow::sCOLOUR.b; +} + +const GUIHelpers::Padding& cGUI::getPadding() const +{ + /*return cWindow::sPADDING;*/ + return{}; +} + +void cGUI::getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const +{ +// top = cWindow::sPADDING.x; +// right = cWindow::sPADDING.y; +// bottom = cWindow::sPADDING.z; +// left = cWindow::sPADDING.w; +} + +const GUIHelpers::eAlign& cGUI::getAlign() const +{ + /*return cWindow::sALIGN;*/ + return GUIHelpers::eAlign::CENTER; +} + +const bool cGUI::IsInit() const +{ + bool rtn = m_inited; + + if (rtn == true) + cUtility::Inst().Message("GUI is initialized."); + else + cUtility::Inst().Message("GUI is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp new file mode 100644 index 0000000..9c147ef --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp @@ -0,0 +1,105 @@ +#ifndef _CGUI_HPP_ +#define _CGUI_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../TextTypeEngine/cFont.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "cWindow.hpp" +//#include "cPanel.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cGUI + { + private: + cGUI(); + ~cGUI(); + + public: + enum EXPORT_FROM_MYDLL eGUIEventType: unsigned int + { + MouseButton1 = 0, + MouseButton2, + MouseButton3, + Keyboard + }; + ///Functions + static cGUI& Inst(); + static void Delete(); + + const bool Initialize( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void Event( const MathEngine::iVector2& location, const eGUIEventType& type ); + const MathEngine::iVector2 DisplayArea() const; + + void AddObject( GUIEngine::cWindow* obj ); + + std::vector& GetObjects(); + + void Display(); + + ///Sets + void setDebugLevel( const unsigned long int debugLevel ); + + void setFont( TextTypeEngine::cFont* font ); + void setFont( const cString& filename, const cString& dir = "", const unsigned long int size = 16 ); + + void setTextColour( const GUIHelpers::RGBA& colour ); + void setTextColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0 ); + + void setPadding( const GUIHelpers::Padding& padding ); + void setPadding( const unsigned int top = 5, const unsigned int right = 5, const unsigned int bottom = 5, const unsigned int left = 5 ); + + void setAlign( const GUIHelpers::eAlign& align = GUIHelpers::eAlign::CENTER ); + + ///Gets + const unsigned long int getDebugLevel() const; + + TextTypeEngine::cFont* getFont(); + + const GUIHelpers::RGBA& getTextColour() const; + void getTextColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue ) const; + + const GUIHelpers::Padding& getPadding() const; + void getPadding( unsigned int& top, unsigned int& right, unsigned int& bottom, unsigned int& left ) const; + + const GUIHelpers::eAlign& getAlign() const; + + const bool IsInit() const; + + private: + static cGUI* sp_inst;// = nullptr + + unsigned long int m_debugLevel;// = 0 + + bool m_inited;// = false + + /* default GUI font */ + TextTypeEngine::cFont* mp_font;// = nullptr + + /* default GUI text colour black*/ + //GUIHelpers::RBGA m_textColour;// = { 0, 0, 0 } + + /* default GUI padding */ + //GUIHelpers::Padding m_padding;// = { 5, 5, 5, 5 } + + /* default GUI align */ + //GUIHelpers::eAlign m_align;// = GUIHelpers::eAlign::CENTER + + std::vector m_children; + };/// END CLASS DEFINITION cGUI +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CGUI_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.cpp new file mode 100644 index 0000000..a903919 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.cpp @@ -0,0 +1,132 @@ +#include "cLabel.hpp" + +using GUIEngine::cLabel; + +/*static*/ const cString cLabel::sNAME = "label"; +/*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; + +cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + mp_text = new TextTypeEngine::cText(label); + Create(parent, id, label, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLabel::~cLabel() +{ + delete mp_text; + mp_text = nullptr; +} + +///Functions +void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, 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*/) +{ + cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } + setText(label); +} + +/*virtual*/ void cLabel::Display() +{ + GenerateTexture(); + + m_sprite.setPosition(cWindow::getPosition()); + m_sprite.Draw(); + //cSprite::SaveImage("test.bmp", "xml/"); + cWindow::Display(); +} + +void cLabel::GenerateTexture() +{ + m_sprite.setImage((VideoEngine::cImage**)(&mp_text)); + + m_sprite.setImageArea(mp_text->getWH()); + + + + //this->setTransparent(); + //this->setPosition() +} + +//Sets +void cLabel::setFontColour(const GUIHelpers::RGBA& colour) +{ + mp_text->setColour(colour); +} + +void cLabel::setFontSize(const unsigned long int size) +{ + mp_text->setSize(size); + SetSize(); +} + +void cLabel::setText(const cString& text) +{ + mp_text->setText(text); + SetSize(); +} + +void cLabel::setFont(const TextTypeEngine::cFont* font) +{ + mp_text->setFont((TextTypeEngine::cFont**)(&font)); +} + +///Gets +const GUIHelpers::RGBA& cLabel::getFontColour() const +{ + return mp_text->getColour(); +} + +const unsigned long int cLabel::getFontSize() const +{ + return mp_text->getSize(); +} + +const TextTypeEngine::cFont* cLabel::getFont() const +{ + return mp_text->getFont(); +} + +const cString& cLabel::getText() const +{ + return mp_text->getText(); +} + +/*virtual*/ const GUIHelpers::eType cLabel::getType() const +{ + return GUIHelpers::eType::CLABEL; +} + +/*virtual*/ const GUIHelpers::RGBA cLabel::getDebugColour() const +{ + return GUIHelpers::GREEN; +} + +// /*virtual*/ void cLabel::Resize() +// { +// RebuildLayout(this->getLayout()); +// cWindow::RePos(); +// } + +/*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) +{ + SetSize(); +} + +void cLabel::SetSize() +{ + if (mp_text != nullptr) { + long int y = mp_text->getSize(); + long int x = (mp_text->getText().length() * y); + + GUIHelpers::Size size = { x, y }; + // size.x += this->getPadding().x + this->getPadding().w; + // size.y += this->getPadding().y + this->getPadding().z; + this->setSize(size); + } +} diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp new file mode 100644 index 0000000..d8e7445 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp @@ -0,0 +1,64 @@ +#ifndef _CLABEL_HPP_ +#define _CLABEL_HPP_ +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../VideoEngine/cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLabel : public cWindow + { + public: + static const cString sNAME; /*= "label";*/ + static const GUIHelpers::eLayout sLAYOUT;/* = GUIHelpers::eLayout::WRAP_CONTENT;*/ + + cLabel(cWindow* parent, const signed int id, const cString& label = "", 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); + virtual ~cLabel(); + + ///Functions + void Create(cWindow* parent, const signed int id, const cString& label = "", 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); + + virtual void Display(); + + void GenerateTexture(); + + //Sets + void setFontColour( const GUIHelpers::RGBA& colour ); + void setFontSize( const unsigned long int size ); + void setText( const cString& text ); + void setFont( const TextTypeEngine::cFont* font ); + + ///Gets + const GUIHelpers::RGBA& getFontColour() const; + const unsigned long int getFontSize() const; + const TextTypeEngine::cFont* getFont() const; + const cString& getText() const; + virtual const GUIHelpers::eType getType() const; + virtual const GUIHelpers::RGBA getDebugColour() const; + + + //virtual void Resize(); + virtual void RebuildLayout(const GUIHelpers::eLayout& layout); + + private: + void SetSize(); + + + + private: + VideoEngine::cSprite m_sprite; + TextTypeEngine::cText* mp_text;// = nullptr + };/// END CLASS DEFINITION cLabel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLABEL_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.cpp new file mode 100644 index 0000000..58bd62b --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.cpp @@ -0,0 +1,49 @@ +#include "cLayout.hpp" + +using GUIEngine::cLayout; + +/*static*/ const cString cLayout::sNAME = "layout"; +/*static*/ const GUIHelpers::eOrientation cLayout::sORIENTATION = GUIHelpers::eOrientation::VERTICAL; + +cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cLayout::~cLayout() +{} + +///Functions +/*virtual*/ void cLayout::Create(cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + GUIHelpers::eOrientation ori = orientation; + if (ori == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + ori = sORIENTATION; + cWindow::Create(parent, id, ori, align, layout, pos, size, padding, name); + if (this->getParent() != nullptr) { + this->getParent()->AddChild(this); + } +} + +/*virtual*/ void cLayout::Display() +{ + cWindow::Display(); +} + +///Set + +///Get + +/*virtual*/ const GUIHelpers::eType cLayout::getType() const +{ + return GUIHelpers::eType::CLAYOUT; +} + +/*virtual*/ const GUIHelpers::RGBA cLayout::getDebugColour() const +{ + return GUIHelpers::BLUE; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp new file mode 100644 index 0000000..e0f3e85 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp @@ -0,0 +1,52 @@ +#ifndef _CLAYOUT_HPP_ +#define _CLAYOUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cWindow.hpp" + +#include "GUIHelpers/GUIUtility.hpp" +#include "GUIHelpers/Enums.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cLayout : public cWindow + { + public: + static const cString sNAME; /*= "layout";*/ + static const GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::VERTICAL;*/ + + cLayout( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cLayout(); + + ///Functions + virtual void Create( cWindow* parent, const signed int id, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + ///Set + + ///Get + + virtual const GUIHelpers::eType getType() const; + + virtual const GUIHelpers::RGBA getDebugColour() const; + + private: + GUIHelpers::eOrientation m_orientation; + };/// END CLASS DEFINITION cLayout +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CLAYOUT_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.cpp new file mode 100644 index 0000000..3676d7d --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.cpp @@ -0,0 +1,40 @@ +#include "cPanel.hpp" + + +using GUIEngine::cPanel; + +/*static*/ const UtilityEngine::cString cPanel::sNAME = "panel"; + +cPanel::cPanel( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) +{ + Create( parent, id, orientation, align, layout, pos, size, padding, name ); +} + +/*virtual*/ cPanel::~cPanel() +{} + +///Functions +/*virtual*/ void cPanel::Create(cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/) +{ + padding; + cLayout::Create( parent, id, orientation, align, layout, pos, size, { 0,0,0,0 }, name ); +} + +/*virtual*/ void cPanel::Display() +{ + cLayout::Display(); +} + +/*virtual*/ const GUIHelpers::eType cPanel::getType() const +{ + return GUIHelpers::eType::CPANEL; +} + +/*virtual*/ const GUIHelpers::RGBA cPanel::getDebugColour() const +{ + return GUIHelpers::RED; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp new file mode 100644 index 0000000..ce34587 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp @@ -0,0 +1,42 @@ +#ifndef _CPANEL_HPP_ +#define _CPANEL_HPP_ + +/** C++ Header Files **/ +#include + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cLayout.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cPanel : public GUIEngine::cLayout + { + public: + static const UtilityEngine::cString sNAME; /*= "panel";*/ + + public: + cPanel( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + virtual ~cPanel(); + + ///Functions + virtual void Create( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + virtual void Display(); + + virtual const GUIHelpers::eType getType() const; + + virtual const GUIHelpers::RGBA getDebugColour() const; + + private: + };/// END CLASS DEFINITION cPanel +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CPANEL_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp new file mode 100644 index 0000000..613b329 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.cpp @@ -0,0 +1,71 @@ +#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; +} + +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 new file mode 100644 index 0000000..7e515b1 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp @@ -0,0 +1,62 @@ +#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: + 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 new file mode 100644 index 0000000..50e14a9 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.cpp @@ -0,0 +1,546 @@ +#include "cWindow.hpp" + + +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +#include "cGUI.hpp" +#include "cLabel.hpp" +#include "cLayout.hpp" + +using GUIEngine::cWindow; + +/*static*/ const UtilityEngine::cString cWindow::sNAME = "windows"; +/*static*/ GUIHelpers::Position cWindow::sPOSITION = { 0, 0 }; +/*static*/ GUIHelpers::Size cWindow::sSIZE = { 0, 0 }; +/*static*/ GUIHelpers::Padding cWindow::sPADDING = { 5, 5, 5, 5 }; +/*static*/ GUIHelpers::RGBA cWindow::sCOLOUR = { 100, 100, 100, 255 }; + +/*static*/ GUIHelpers::eAlign cWindow::sALIGN = GUIHelpers::eAlign::CENTER; +/*static*/ GUIHelpers::eLayout cWindow::sLAYOUT = GUIHelpers::eLayout::FILL_PARENT; +/*static*/ GUIHelpers::eOrientation cWindow::sORIENTATION = GUIHelpers::eOrientation::NONE; + +cWindow::cWindow( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) + : cObject(id) +{ + Create(parent, id, orientation, align, layout, pos, size, padding, name); +} + +/*virtual*/ cWindow::~cWindow() +{ + for (unsigned int i = 0; i < m_children.size(); ++i) { + delete m_children[i]; + m_children[i] = nullptr; + } + m_children.clear(); +} + +/*virtual*/ void cWindow::Create( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/, 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*/ ) +{ + mp_parent = parent; + cObject::setID(id); + setOrientation(orientation); + setAlign(align); + setLayout(layout); + setPosition(pos); + setSize(size); + setPadding(padding); + m_name = name; +} + +/*virtual*/ void cWindow::Display() { + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Display(); + } + + DebugDisplay(); +} + +///Functions +const bool cWindow::Inside( const MathEngine::iVector2& location ) const +{ + bool rtn = false; + + if ((location.x >= m_pos.x) && (location.y >= m_pos.y)) { + if ((location.x <= (m_pos.x + m_size.x)) && (location.y <= (m_pos.y + m_size.y))) + rtn = true; + } + return rtn; +} + +void cWindow::AddChild( cWindow* obj ) +{ + m_children.push_back(obj); +} + +const bool cWindow::RemoveChild( cWindow* obj ) +{ + bool rtn = false; + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if (obj == (*it)) { + m_children.erase(it); + rtn = true; + //break out of the for loop + break; + } + } + return rtn; +} + +///Sets +/*static*/ void cWindow::PositionDefault( const GUIHelpers::Position& pos ) +{ + if (pos.x >= 0) + sPOSITION = pos; +} + +/*static*/ void cWindow::SizeDefault( const GUIHelpers::Size& size ) +{ + if (size.x >= 0) + sSIZE = size; +} + +/*static*/ void cWindow::PaddingDefault( const GUIHelpers::Padding& pad ) +{ + if (pad.x >= 0) + sPADDING = pad; +} + +/*static*/ void cWindow::AlignDefault( const GUIHelpers::eAlign& align ) +{ + if (align != GUIHelpers::eAlign::DEFAULT_ALIGN) + sALIGN = align; +} + +/*static*/ void cWindow::LayoutDefault( const GUIHelpers::eLayout& layout ) +{ + if (layout != GUIHelpers::eLayout::DEFAULT_LAYOUT) + sLAYOUT = layout; +} + +/*static*/ void cWindow::OrientationDefault( const GUIHelpers::eOrientation& orientation ) +{ + if (orientation != GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + sORIENTATION = orientation; +} + +void cWindow::setOrientation( const GUIHelpers::eOrientation& orientation /*= sORIENTATION*/ ) +{ + if (orientation == GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + m_orientation = cWindow::sORIENTATION; + else + m_orientation = orientation; +} + +void cWindow::setAlign( const GUIHelpers::eAlign& align /*= sALIGN*/ ) +{ + if (align == GUIHelpers::eAlign::DEFAULT_ALIGN) + m_align = cWindow::sALIGN; + else + m_align = align; + RebuildPos(); +} + +void cWindow::setLayout( const GUIHelpers::eLayout& layout /*= sLAYOUT*/ ) +{ + if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT) + m_layout = cWindow::sLAYOUT; + else + m_layout = layout; +} + +void cWindow::setPosition( const GUIHelpers::Position& pos /*= POSITION*/ ) +{ + if (pos.x < 0) + m_pos = cWindow::sPOSITION; + else + m_pos = pos; +} + +void cWindow::setSize( const GUIHelpers::Size& size /*= sSIZE*/ ) +{ + if (size.x < 0) + m_size = cWindow::sSIZE; + else + m_size = size; +} + +void cWindow::setPadding( const GUIHelpers::Padding& padding /*= PADDING*/ ) +{ + if (padding.x < 0) + m_padding = cWindow::sPADDING; + else + m_padding = padding; +} + +void cWindow::setContentSize( const GUIHelpers::Size& content ) +{ + m_content = content; +} + +void cWindow::setName( const cString& name /*= NAME*/ ) +{ + m_name = name; +} + +void cWindow::setParent( cWindow* parent ) +{ + mp_parent = parent; +} + +///Gets +const GUIHelpers::Position cWindow::getCenter( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = { 0, 0 }; + rtn.x = (m_size.x / 2) + m_pos.x; + rtn.y = (m_size.y / 2) + m_pos.y; + if (pad == true) { + rtn.x += (m_padding.x - m_padding.w); + rtn.y += (m_padding.y - m_padding.z); + } + return rtn; +} + +const GUIHelpers::eOrientation& cWindow::getOrientation() const +{ + return m_orientation; +} + +const GUIHelpers::eAlign& cWindow::getAlign() const +{ + return m_align; +} + +const GUIHelpers::eLayout& cWindow::getLayout() const +{ + if (m_layout == GUIHelpers::eLayout::MATCH_PARENT) { + if (mp_parent != nullptr) + return mp_parent->getLayout(); + } + return m_layout; +} + +const GUIHelpers::Position cWindow::getPosition( const bool pad /*= true*/ ) const +{ + GUIHelpers::Position rtn = m_pos; + + if (pad == false) { + rtn.x -= m_padding.x; + rtn.y -= m_padding.y; + } + + return rtn; +} + +const GUIHelpers::Size cWindow::getSize( const bool pad /*= true*/ ) const +{ + GUIHelpers::Size rtn = m_size; + + if (pad == true) { + rtn.x += m_padding.x + m_padding.w; + rtn.y += m_padding.y + m_padding.z; + } + + return rtn; +} + +const GUIHelpers::Padding& cWindow::getPadding() const +{ + return m_padding; +} + +const GUIHelpers::Size& cWindow::getContentSize() const +{ + return m_content; +} + +const cString& cWindow::getName() const +{ + return m_name; +} + +const GUIHelpers::Size cWindow::getChildrenSize( const cWindow* ignore /*= nullptr*/ ) +{ + GUIHelpers::Size rtn = { 0, 0 }; + + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + if ((ignore == nullptr) || ((*it) != ignore)) + rtn += (*it)->getSize(); + } + + return rtn; +} + +cWindow* cWindow::getParent() +{ + return mp_parent; +} + +/*virtual*/ const GUIHelpers::eType cWindow::getType() const +{ + return GUIHelpers::eType::CWINDOW; +} + +///Protected + +/*virtual*/ void cWindow::Resize() +{ + RebuildLayout(this->getLayout()); + RePos(); +} + +/*virtual*/ void cWindow::RebuildLayout( const GUIHelpers::eLayout& layout ) +{ + GUIHelpers::Size mySize = { 0, 0 }; + std::vector::iterator it; + + switch (layout) + { + case GUIHelpers::eLayout::MATCH_PARENT: + case GUIHelpers::eLayout::FILL_PARENT: + if (mp_parent != nullptr) { + GUIHelpers::Position myPos = mp_parent->getPosition(false); + myPos.x += m_padding.x; + myPos.y += m_padding.y; + mySize = mp_parent->getSize(false); + + if (mp_parent->getType() == GUIHelpers::eType::CLAYOUT) { + if (mp_parent->getChildren().size() > 1) + mySize -= mp_parent->getChildrenSize(this); + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::VERTICAL) + mySize.x = m_size.x; + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) + mySize.y = m_size.y; + } + + mySize.x -= m_padding.x + m_padding.w; + mySize.y -= m_padding.y + m_padding.z; + m_pos = myPos; + m_size = mySize; + } + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + } + break; + case GUIHelpers::eLayout::WRAP_CONTENT: + GUIHelpers::Size size = { 0, 0 }; + if (m_children.size() > 0) { + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->Resize(); + size = (*it)->getSize(); + AddSize(size.x, size.y, mySize); + } + } + else { + if (mp_parent != nullptr) + m_pos = mp_parent->getCenter(); + } + m_size = mySize; + break; + } +} + +/*virtual*/ void cWindow::RePos() +{ + std::vector::iterator it; + + for (it = m_children.begin(); it < m_children.end(); it++) { + (*it)->RePos(); + } + + if (this->getType() == GUIHelpers::eType::CLAYOUT) { + GUIHelpers::Position prtCenter = getCenter(); + GUIHelpers::Position ourSet = prtCenter; + GUIHelpers::Size totalSize = { 0, 0 }; + GUIHelpers::Position totalCenter = { 0, 0 }; + + for (it = m_children.begin(); it < m_children.end(); it++) { + totalSize += (*it)->getSize(); + } + + totalCenter.x = totalSize.x / 2; + totalCenter.y = totalSize.y / 2; + + ourSet.x -= totalCenter.x; + ourSet.y -= totalCenter.y; + + GUIHelpers::Position posSet = ourSet; + GUIHelpers::Position posNext = posSet; + for (it = m_children.begin(); it < m_children.end(); it++) { + posSet = posNext; + GUIHelpers::Padding pad = (*it)->getPadding(); + GUIHelpers::Size size = (*it)->getSize(false); + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + posSet.x += pad.x; + posSet.y = (pad.y - pad.z - (size.y / 2)) + prtCenter.y; + + posNext = posSet; + + posNext.x += size.x + pad.w; + //posNext.y = ourSet.y; + } + else { + posSet.x = (pad.x - pad.w - (size.x / 2)) + prtCenter.x; + posSet.y += pad.y; + + posNext = posSet; + + //posNext.x = ourSet.x; + posNext.y += size.y + pad.z; + } + + (*it)->setPosition(posSet); + (*it)->RebuildPos(); + } + } +} + +/*virtual*/ void cWindow::RebuildPos() +{ + if ((mp_parent != nullptr) && (mp_parent->getOrientation() != GUIHelpers::eOrientation::NONE)) { + GUIHelpers::Position prtPos = mp_parent->getPosition(); + GUIHelpers::Size prtSize = mp_parent->getSize(); + + GUIHelpers::Position pos = this->getPosition(); + GUIHelpers::Size size = this->getSize(); + + GUIHelpers::Padding pad = this->getPadding(); + + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + switch (this->getAlign()) { + default: + case GUIHelpers::eAlign::CENTER: + pos.y = mp_parent->getCenter().y - (this->getSize(false).y / 2); + break; + case GUIHelpers::eAlign::BOTTOM: + pos.y = prtSize.y - size.y; + break; + case GUIHelpers::eAlign::TOP: + pos.y = prtPos.y + pad.y; + break; + } + } + if (mp_parent->getOrientation() == GUIHelpers::eOrientation::VERTICAL) { + switch (this->getAlign()) { + default: + case GUIHelpers::eAlign::CENTER: + pos.x = mp_parent->getCenter().x - (this->getSize(false).x / 2); + break; + case GUIHelpers::eAlign::RIGHT: + pos.x = prtSize.x - size.x; + break; + case GUIHelpers::eAlign::LEFT: + pos.x = prtPos.x + pad.x; + break; + } + } + this->setPosition(pos); + } +} + +/*virtual*/ const GUIHelpers::RGBA cWindow::getDebugColour() const +{ + return GUIHelpers::WHITE; +} + +std::vector& cWindow::getChildren() +{ + return m_children; +} + +//private +void cWindow::AddSize( int x, int y, GUIHelpers::Size& mySize ) const +{ + int& addFrom = x; + int& largestFrom = y; + + int& addTo = mySize.x; + int& largestTo = mySize.y; + + if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) { + addFrom = y; + largestFrom = x; + + addTo = mySize.y; + largestTo = mySize.x; + } + + /*We do the real work here.*/ + if (largestTo < largestFrom) + largestTo = largestFrom; + + addTo += addFrom; +} + +void cWindow::DebugDisplay() const +{ + // Debug Level 0 display nothing + // Debug Level 1 display a coloured rectangle and center pixel for each GUI element. + // Debug Level 2 display the type of GUI element + unsigned long int debugLvl = GUIEngine::cGUI::Inst().getDebugLevel(); + if (debugLvl >= 1) { + SDL_Rect rect; + rect.x = m_pos.x; + rect.y = m_pos.y; + rect.w = m_pos.x + m_size.x; + rect.h = m_pos.y + m_size.y; + + GUIHelpers::Position strPos = getCenter(); + + GUIHelpers::RGBA colour = getDebugColour(); + FXEngine::cGFX::Inst().Pixel(strPos.x, strPos.y, colour); + + cString str = ""; + str.format("X: %d Y: %d", strPos.x, strPos.y); + FXEngine::cGFX::Inst().StringDefault(str, { strPos.x + 2, strPos.y + 2, 0, 0 }, colour); + + if (debugLvl >= 2) { + SDL_Rect typePos = { 2, 2, 0, 0 }; + cString type = ""; + switch (getType()) { + case GUIHelpers::eType::CPANEL: + type = "Panel"; + break; + case GUIHelpers::eType::CLAYOUT: + type = "Layout"; + break; + case GUIHelpers::eType::CLABEL: + typePos = { -10, -10, 0, 0 }; + type = "Label"; + break; + default: + type = ""; + } + + typePos.x += m_pos.x; + typePos.y += m_pos.y; + + FXEngine::cGFX::Inst().StringDefault(type, typePos, colour); + +// if (debugLvl >= 3) { +// GUIHelpers::Position pos = getPosPPad(); +// //GUIHelpers::Size size = getSizePPad(); +// SDL_Rect box{ 0, 0, 0, 0 }; +// box.x += pos.x; +// box.y += pos.y; +// box.h += pos.y + m_size.y + m_padding.y + m_padding.z; +// box.w += pos.x + m_padding.x; +// +// FXEngine::cGFX::Inst().Box(box, colour); +// } + } + + FXEngine::cGFX::Inst().Rectangle(rect, colour); + } +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp new file mode 100644 index 0000000..0b58fdf --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp @@ -0,0 +1,126 @@ +#ifndef _CWINDOW_HPP_ +#define _CWINDOW_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "GUIHelpers/cObject.hpp" +#include "GUIHelpers/Enums.hpp" +#include "GUIHelpers/GUIUtility.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace GUIEngine { + class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject + { + protected: + static const UtilityEngine::cString sNAME; /*= "windows";*/ + static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/ + static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/ + static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/ + static GUIHelpers::RGBA sCOLOUR; /*= { 100, 100, 100, 255 };*/ + + static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/ + static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/ + static GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::NONE;*/ + + protected: + cWindow( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + public: + virtual ~cWindow(); + + protected: + virtual void Create( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, 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 ); + + public: + ///Functions + virtual void Display(); + + const bool Inside( const MathEngine::iVector2& location ) const; + + void AddChild( cWindow* obj ); + + const bool RemoveChild( cWindow* obj ); + + ///Sets + static void PositionDefault( const GUIHelpers::Position& pos ); + static void SizeDefault( const GUIHelpers::Size& size ); + static void PaddingDefault( const GUIHelpers::Padding& pad ); + static void AlignDefault( const GUIHelpers::eAlign& align ); + static void LayoutDefault( const GUIHelpers::eLayout& layout ); + static void OrientationDefault( const GUIHelpers::eOrientation& orientation ); + + void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION ); + void setAlign( const GUIHelpers::eAlign& align = sALIGN ); + void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT ); + void setPosition( const GUIHelpers::Position& pos = sPOSITION ); + void setSize( const GUIHelpers::Size& size = sSIZE ); + void setPadding( const GUIHelpers::Padding& padding = sPADDING ); + void setContentSize( const GUIHelpers::Size& content ); + void setName( const cString& name = sNAME ); + + void setParent( cWindow* parent ); + + ///Gets + const GUIHelpers::Position getCenter( const bool pad = true ) const; + + const GUIHelpers::eOrientation& getOrientation() const; + const GUIHelpers::eAlign& getAlign() const; + 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::Padding& getPadding() const; + const GUIHelpers::Size& getContentSize() const; + const cString& getName() const; + + const GUIHelpers::Size getChildrenSize( const cWindow* ignore = nullptr ); + + cWindow* getParent(); + + virtual const GUIHelpers::eType getType() const; + + virtual void Resize(); + virtual void RebuildLayout( const GUIHelpers::eLayout& layout ); + + virtual void RePos(); + virtual void RebuildPos(); + + virtual const GUIHelpers::RGBA getDebugColour() const; + + /*protected:*/ + std::vector& getChildren(); + + private: + void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout ); + + void AddSize( int x, int y, GUIHelpers::Size& mySize ) const; + + void DebugDisplay() const; + + private: + GUIHelpers::eOrientation m_orientation;// = GUIHelper::eOrientation::NONE; + GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER; + GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT; + GUIHelpers::Position m_pos;// = POSITION; + GUIHelpers::Size m_size;// = SIZE; + GUIHelpers::Padding m_padding;// = PADDING; + GUIHelpers::Size m_content;// = m_size; + cString m_name;// = NAME; + + std::vector m_children; + cWindow* mp_parent;// = nullptr; + };/// END CLASS DEFINITION cBoxSizer +}/// END NAMESPACE DEFINITION GUIEngine +#endif/// END IFNDEF _CBOXSIZER_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.cpp new file mode 100644 index 0000000..a96f754 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.cpp @@ -0,0 +1,167 @@ +#include "cInput.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using InputEngine::cInput; +using UtilityEngine::cUtility; + +/*static*/ cInput* cInput::sp_inst = nullptr; + +//Private +cInput::cInput() +{} + +cInput::~cInput() +{ + CleanUp(); +} + +//Public +/*static*/ cInput& cInput::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cInput(); + return *sp_inst; +} + +/*static*/ void cInput::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +//Functions +const bool cInput::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0) { + cUtility::Inst().Message("Input initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Input.hpp SDL_InitSubSystem(SDL_INIT_JOYSTICK):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +const bool cInput::Setup() +{ + return true; +} + +void cInput::CleanUp() +{ + DeleteAllInputs(); +} + +void cInput::CheckInputs( const SDL_Event& event ) +{ + m_event = event; + switch(m_event.type) + { + case SDL_KEYUP: + case SDL_KEYDOWN: + CheckKeyboards(); + break; + case SDL_JOYAXISMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + CheckJoysticks(); + break; + } +} + +void cInput::CheckKeyboards() +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + InputEngine::cKeyboard* temp = (*it); + temp->KeyboardCheck(m_event); + } +} + +void cInput::CheckJoysticks() +{ + +} + +/* Adds a keyboard to cInput internal list to be called when CheckInputs is called */ +void cInput::AddKeyboard( InputEngine::cKeyboard* keyboard ) +{ + m_keyboards.push_back(keyboard); +} + +/* Deletes a keyboard in cInput internal list */ +void cInput::DeletesKeyboard( const cString& label ) +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + if (label == (*it)->getLabel()) { + InputEngine::cKeyboard* temp = (*it); + delete temp; + temp = nullptr; + m_keyboards.erase(it); + //break out of the for loop + break; + } + } +} + +/* Deletes all keyboards in cInput internal list */ +void cInput::DeleteAllKeyboards() +{ + m_keyboards.clear(); +} + +/* Removes the keyboard from cInput internal list */ +void cInput::RemoveKeyboard( const cString& label ) +{ + std::vector::iterator it; + + for ( it = m_keyboards.begin() ; it < m_keyboards.end(); it++ ) { + if (label == (*it)->getLabel()) { + m_keyboards.erase(it); + //break out of the for loop + break; + } + } +} + +/* Removes all keyboards from cInput internal list. */ +void cInput::RemoveAllKeyboards() +{ + m_keyboards.erase(m_keyboards.begin(), m_keyboards.end()); +} + +void cInput::DeleteAllInputs() +{ + DeleteAllKeyboards(); +} + +void cInput::RemoveAllInputs() +{ + RemoveAllKeyboards(); +} + +///Sets + +///Gets +/* Gets return true if Input was initialized */ +const bool cInput::IsInit() const +{ + bool rtn = false; + if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0) { + cUtility::Inst().Message("Input is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Input is not initialized."); + return rtn; +} + diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp new file mode 100644 index 0000000..82927f9 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp @@ -0,0 +1,71 @@ +#ifndef _CINPUT_HPP_ +#define _CINPUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cInput + { + private: + cInput(); + ~cInput(); + + public: + static cInput& Inst(); + static void Delete(); + + //Functions + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + /* Checks all inputs */ + void CheckInputs( const SDL_Event& event ); + /* Checks all keyboards */ + void CheckKeyboards(); + /* Checks all Joysticks */ + void CheckJoysticks(); + + /* Adds a keyboard to cInput interneal list to be called when CheckInputs is called */ + void AddKeyboard( InputEngine::cKeyboard* keyboard ); + /* Deletes a keyboard in cInput internal list */ + void DeletesKeyboard( const cString& label ); + /* Deletes all keyboards in cInput internal list */ + void DeleteAllKeyboards(); + /* Removes the keyboard from cInput internal list */ + void RemoveKeyboard( const cString& label ); + /* Removes all keyboards from cInput internal list. */ + void RemoveAllKeyboards(); + + void DeleteAllInputs(); + void RemoveAllInputs(); + + ///Sets + + ///Gets + /* Gets return true if Input was initialized */ + const bool IsInit() const; + + private: + std::vector m_keyboards; + + SDL_Event m_event; + + static cInput* sp_inst;// = nullptr + };/// END CLASS DEFINITION cInput +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CINPUT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.cpp new file mode 100644 index 0000000..0b54efd --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.cpp @@ -0,0 +1,10 @@ +#include "cJoystick.hpp" + +using InputEngine::cJoystick; + +cJoystick::cJoystick() +{} + +/*virtual*/ cJoystick::~cJoystick() +{} + diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp new file mode 100644 index 0000000..c7a3f3c --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp @@ -0,0 +1,38 @@ +#ifndef _CJOYSTICK_HPP_ +#define _CJOYSTICK_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "../EventEngine/cEvent.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cJoystick : public EventEngine::cEvent + { + public: + cJoystick(); + virtual ~cJoystick(); + + ///Functions + virtual void OnEvent(const SDL_Event& event); + + 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); + + //Used when looking for keys that have been add to the check list + void JoystickCheck(); + + };/// END CLASS DEFINITION cJoystick +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CJOYSTICK_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.cpp new file mode 100644 index 0000000..d30e91b --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.cpp @@ -0,0 +1,39 @@ +#include "cKey.hpp" + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +using InputEngine::cKey; + +cKey::cKey( const SDL_Keycode& key ) +: m_key(key) +{} + +cKey::cKey( const cKey& copy ) +: m_key(copy.getKey()) +{} + +/*virtual*/ cKey::~cKey() +{} + +///Funtions +/*virtual*/ void cKey::KeyPress() +{} + +/*virtual*/ void cKey::KeyUP() +{} + +/*virtual*/ void cKey::KeyDown() +{} + +///Sets +void cKey::setKey( const SDL_Keycode& key ) +{ + m_key = key; +} + +///Gets +const SDL_Keycode& cKey::getKey() const +{ + return m_key; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp new file mode 100644 index 0000000..7848688 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp @@ -0,0 +1,37 @@ +#ifndef _CKEY_HPP_ +#define _CKEY_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cKey + { + public: + cKey( const SDL_Keycode& key ); + cKey( const cKey& copy ); + virtual ~cKey(); + + ///Funtions + /* Call to check if the key is pressed */ + virtual void KeyPress(); + /* Call to check if the key is released */ + virtual void KeyUP(); + /* Call to check if the key is pressed */ + virtual void KeyDown(); + + ///Sets + void setKey( const SDL_Keycode& key ); + + ///Gets + const SDL_Keycode& getKey() const; + + private: + private: + SDL_Keycode m_key; + };/// END CLASS DEFINITION cKey +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CKEY_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.cpp new file mode 100644 index 0000000..98e84be --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.cpp @@ -0,0 +1,72 @@ +#include "cKeyboard.hpp" + +using InputEngine::cKeyboard; + +cKeyboard::cKeyboard( const cString& label ) + : m_label(label) +{} + +cKeyboard::cKeyboard( const cKeyboard& copy ) + :m_label(copy.getLabel()) +{} + +/*virtual*/ cKeyboard::~cKeyboard() +{ + DeleteAllKeys(); +} + +///Functions +/*virtual*/ void cKeyboard::KeyboardCheck( const SDL_Event& event ) +{ + SDL_Keycode key = event.key.keysym.sym; + + std::vector::iterator it; + + for ( it = m_keys.begin() ; it < m_keys.end(); it++ ) { + if (key == (*it)->getKey()) { + switch( event.type ) + { + case SDL_KEYUP: + (*it)->KeyUP(); + break; + case SDL_KEYDOWN: + (*it)->KeyDown(); + break; + } + //break out of the for loop + break; + } + } +} + +void cKeyboard::AddKey( InputEngine::cKey* key ) +{ + m_keys.push_back(key); +} + +void cKeyboard::DeleteKey( const SDL_Keycode& key ) +{ + std::vector::iterator it; + + for ( it = m_keys.begin() ; it < m_keys.end(); it++ ) { + if (key == (*it)->getKey()) { + InputEngine::cKey* temp = (*it); + delete temp; + temp = nullptr; + m_keys.erase(it); + //break out of the for loop + break; + } + } +} + +void cKeyboard::DeleteAllKeys() +{ + m_keys.clear(); +} + +///Sets +const cString& cKeyboard::getLabel() const +{ + return m_label; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp new file mode 100644 index 0000000..0ba513a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp @@ -0,0 +1,55 @@ +#ifndef _CKEYBOARD_HPP_ +#define _CKEYBOARD_HPP_ + +/*** C++ STL Files ***/ +#include + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKey.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector >; +/*#pragma warning (default : 4231)*/ + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cKeyboard + { + public: + cKeyboard( const cString& label ); + cKeyboard( const cKeyboard& copy ); + virtual ~cKeyboard(); + + ///Funtions + + //Used when looking for keys that have been add to the check list + virtual void KeyboardCheck( const SDL_Event& event ); + + void AddKey( InputEngine::cKey* key ); + void DeleteKey( const SDL_Keycode& key ); + + void DeleteAllKeys(); + + ///Sets + ///Gets + const cString& getLabel() const; + + private: + cString m_label;// = "" + + std::vector m_keys; + };/// END CLASS DEFINITION cKeyboard +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CKEYBOARD_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.cpp new file mode 100644 index 0000000..f6d3606 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.cpp @@ -0,0 +1,11 @@ +#include "cMouse.hpp" + +using InputEngine::cMouse; + +cMouse::cMouse() +{} + +cMouse::~cMouse() +{} + + diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.hpp new file mode 100644 index 0000000..fa48e02 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cMouse.hpp @@ -0,0 +1,21 @@ +#ifndef _CMOUSE_HPP_ +#define _CMOUSE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cInput.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace InputEngine { + class EXPORT_FROM_MYDLL cMouse + { + public: + cMouse(); + ~cMouse(); + };/// END CLASS DEFINITION cMouse +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CMOUSE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.cpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.cpp new file mode 100644 index 0000000..346a8fd --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.cpp @@ -0,0 +1,90 @@ +#include "cTextInput.hpp" + +using InputEngine::cTextInput; + +cTextInput::cTextInput() +: cKeyboard("TextInput"), m_text(""), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F) +{ + /*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) { + SDL_EnableUNICODE(SDL_ENABLE); + }*/ +} + +cTextInput::cTextInput( const cTextInput& copy ) + : cKeyboard(copy), m_text(copy.getText()), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F) +{ + /*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) { + SDL_EnableUNICODE(SDL_ENABLE); + }*/ +} + +/*virtual*/ cTextInput::~cTextInput() +{} + +///Functions +/* */ +/*virtual*/ void cTextInput::KeyboardCheck( const SDL_Event& event ) +{ + switch(event.key.keysym.sym) + { + case SDLK_BACKSPACE: + case SDLK_DELETE: + if(m_text.size() == 0) + //m_text.erase(m_text.end() - 1); + break; + default: + { + char key = UnicodeValue(event); + + if(key != 0) + m_text += key; + } + break; + } +} + +/* Clears out the Text */ +void cTextInput::ClearText() +{ + m_text = ""; +} + +///Sets +void cTextInput::setText( const cString& text ) +{ + m_text = text; +} + +///Gets +const cString& cTextInput::getText() const +{ + return m_text; +} + +//Private +const char cTextInput::UnicodeValue( const SDL_Event& event ) +{ + event; +/* if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) + return 0; + + unsigned long int uni = event.key.keysym.unicode; + + if( uni == 0 ) // not translatable key (like up or down arrows) + { + // probably not useful as string input + // we could optionally use this to get some value + // for it: SDL_GetKeyName( key ); + return 0; + } + else if( ( uni & INTERNATIONAL_MASK ) == 0 ) + { + return static_cast(uni & UNICODE_MASK); + } + else // we have a funky international character. one we can't read :( + { + // we could do nothing, or we can just show some sign of input, like so: + return 0; + }*/ + return 0; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp new file mode 100644 index 0000000..31db831 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp @@ -0,0 +1,50 @@ +#ifndef _CTEXTINPUT_HPP_ +#define _CTEXTINPUT_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cKeyboard.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace InputEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTextInput : public cKeyboard + { + public: + cTextInput(); + cTextInput( const cTextInput& copy ); + virtual ~cTextInput(); + + ///Functions + /* */ + virtual void KeyboardCheck( const SDL_Event& event ); + /* Clears out the Text */ + void ClearText(); + ///Sets + void setText( const cString& text ); + ///Gets + const cString& getText() const; + + private: + const char UnicodeValue( const SDL_Event& event ); + + private: + cString m_text;// = "" + bool m_caps;// = false + bool m_shift;// = false + + // magic numbers courtesy of SDL docs + const unsigned long int INTERNATIONAL_MASK;// = 0xFF80 + const unsigned long int UNICODE_MASK;// = 0x7F + };/// END CLASS DEFINITION cTextInput +}/// END NAMESPACE DEFINITION InputEngine +#endif/// END IFNDEF _CTEXTINPUT_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.cpp new file mode 100644 index 0000000..10c1ae7 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.cpp @@ -0,0 +1,39 @@ +#include "Vector2.hpp" + +/*** Custom Header File ***/ +#include "../iVector/iVector2.hpp" + +using MathEngine::Vector2; +using MathEngine::iVector2; + +Vector2::Vector2( const float X /*= 0.0f*/, const float Y /*= 0.0f*/ ) + : x(X), y(Y) +{}; + +Vector2::Vector2( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); +} + +Vector2& Vector2::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + + return *this; +} + +Vector2::Vector2( const iVector2& copy ) +{ + x = float(copy.x); + y = float(copy.y); +} + +Vector2& Vector2::operator=( const iVector2& copy ) +{ + x = float(copy.x); + y = float(copy.y); + + return *this; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.hpp new file mode 100644 index 0000000..72f45a5 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector2.hpp @@ -0,0 +1,29 @@ +#ifndef _VECTOR2_HPP_ +#define _VECTOR2_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + struct iVector2; + + struct EXPORT_FROM_MYDLL Vector2 + { + Vector2( const float X = 0.0f, const float Y = 0.0f ); + + Vector2( const SDL_Rect& copy ); + + Vector2& operator=( const SDL_Rect& copy ); + + Vector2( const iVector2& copy ); + + Vector2& operator=( const iVector2& copy ); + + float x; + float y; + };/// END STRUCT DEFINITION Vector2 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR2_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.cpp new file mode 100644 index 0000000..d0b22dc --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.cpp @@ -0,0 +1,43 @@ +#include "Vector3.hpp" + +/*** Custom Header File ***/ +#include "../iVector/iVector3.hpp" + +using MathEngine::Vector3; +using MathEngine::iVector3; + +Vector3::Vector3( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/ ) + : Vector2( X, Y ), z(Z) +{} + +Vector3::Vector3( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); +} + +Vector3& Vector3::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + + return *this; +} + +Vector3::Vector3( const iVector3& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); +} + +Vector3& Vector3::operator=( const iVector3& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + + return *this; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.hpp new file mode 100644 index 0000000..a01f57d --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector3.hpp @@ -0,0 +1,31 @@ +#ifndef _VECTOR3_HPP_ +#define _VECTOR3_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "Vector2.hpp" + +namespace MathEngine { + struct iVector3; + + struct EXPORT_FROM_MYDLL Vector3 : public Vector2 + { + Vector3( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f ); + + Vector3( const SDL_Rect& copy ); + + Vector3& operator=( const SDL_Rect& copy ); + + Vector3( const iVector3& copy ); + + Vector3& operator=( const iVector3& copy ); + + float z; + };/// END STRUCT DEFINITION Vector3 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR3_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.cpp new file mode 100644 index 0000000..2c549d9 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.cpp @@ -0,0 +1,46 @@ +#include "Vector4.hpp" + +#include "../iVector/iVector4.hpp" + +using MathEngine::Vector4; +using MathEngine::iVector4; + +Vector4::Vector4( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/, const float W /*= 0.0f*/) + : Vector3( X, Y, Z ), w(W) +{} + +Vector4::Vector4( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + w = float(copy.h); +} + +Vector4& Vector4::operator=( const SDL_Rect& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.w); + w = float(copy.h); + + return *this; +} + +Vector4::Vector4( const iVector4& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + w = float(copy.w); +} + +Vector4& Vector4::operator=( const iVector4& copy ) +{ + x = float(copy.x); + y = float(copy.y); + z = float(copy.z); + w = float(copy.w); + + return *this; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.hpp new file mode 100644 index 0000000..8e45540 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/Vector/Vector4.hpp @@ -0,0 +1,35 @@ +#ifndef _VECTOR4_HPP_ +#define _VECTOR4_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "Vector3.hpp" + +namespace MathEngine { + struct iVector4; + + struct EXPORT_FROM_MYDLL Vector4 : public Vector3 + { + Vector4( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f, const float W = 0.0f ); + + Vector4( const SDL_Rect& copy ); + + Vector4& operator=( const SDL_Rect& copy ); + + bool operator==(const SDL_Rect& other) const; + + Vector4( const iVector4& copy ); + + Vector4& operator=( const iVector4& copy ); + + bool operator==(const Vector4& other) const; + + float w; + };/// END STRUCT DEFINITION Vector4 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _VECTOR4_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp new file mode 100644 index 0000000..81527c3 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp @@ -0,0 +1,200 @@ +#include "cCollision.hpp" + +using MathEngine::cCollision; +using MathEngine::Vector4; +using MathEngine::Vector2; +using MathEngine::iVector4; +using MathEngine::iVector2; + +cCollision::cCollision() +{ +} + +cCollision::~cCollision() +{ +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const SDL_Rect& b ) +{ + if ((b.x + b.w) < a.x) + return false; //just checking if their + if ((a.x + a.w) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.h) < a.y) + return false; + if ((a.y + a.h) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const Vector4& b ) +{ + if ((b.x + b.z) < a.x) + return false; //just checking if their + if ((a.x + a.z) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.w) < a.y) + return false; + if ((a.y + a.w) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::BoundingBox(temp, b); +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const SDL_Rect& b ) +{ + return cCollision::BoundingBox(b, a); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const iVector4& b ) +{ + if ((b.x + b.z) < a.x) + return false; //just checking if their + if ((a.x + a.z) < b.x ) + return false; //bounding boxes even touch + + if ((b.y + b.w) < a.y) + return false; + if ((a.y + a.w) < b.y) + return false; + + return true; //bounding boxes intersect +} + +/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const iVector4& b ) +{ + iVector4 temp = a; + + return cCollision::BoundingBox(temp, b); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const SDL_Rect& b ) +{ + return cCollision::BoundingBox(b, a); +} + +/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::BoundingBox( temp, b ); +} + +/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const iVector4& b ) +{ + return cCollision::BoundingBox( b, a ); +} + +/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const SDL_Rect& 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 = (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 botton 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 Vector2 cCollision::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 botton 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 cCollision::Inside( const SDL_Rect& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::Inside(temp, b); +} + +/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const SDL_Rect& b ) +{ + Vector4 temp = b; + + return cCollision::Inside(a, temp); +} + +/*static*/ const iVector2 cCollision::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 botton 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 cCollision::Inside( const SDL_Rect& a, const iVector4& b ) +{ + iVector4 temp = a; + + return cCollision::Inside( temp, b ); +} + +/*static*/ const iVector2 cCollision::Inside( const iVector4& a, const SDL_Rect& b ) +{ + return cCollision::Inside( b, a ); +} + +/*static*/ const Vector2 cCollision::Inside( const iVector4& a, const Vector4& b ) +{ + Vector4 temp = a; + + return cCollision::Inside( temp, b ); +} + +/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const iVector4& b ) +{ + return cCollision::Inside( b, a ); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp new file mode 100644 index 0000000..c48b3d3 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp @@ -0,0 +1,50 @@ +#ifndef _CCOLLISION_HPP_ +#define _CCOLLISION_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 cCollision + { + private: + cCollision(); + ~cCollision(); + public: + ///Functions + static const bool BoundingBox( const SDL_Rect& a, const SDL_Rect& b ); + static const bool BoundingBox( const Vector4& a, const Vector4& b ); + static const bool BoundingBox( const SDL_Rect& a, const Vector4& b ); + static const bool BoundingBox( const Vector4& a, const SDL_Rect& b ); + + static const bool BoundingBox( const iVector4& a, const iVector4& b ); + static const bool BoundingBox( const SDL_Rect& a, const iVector4& b ); + static const bool BoundingBox( const iVector4& a, const SDL_Rect& b ); + static const bool BoundingBox( const iVector4& a, const Vector4& b ); + static const bool BoundingBox( const Vector4& a, const iVector4& b ); + + + static const Vector2 Inside( const SDL_Rect& a, const SDL_Rect& b ); + static const Vector2 Inside( const Vector4& a, const Vector4& b ); + static const Vector2 Inside( const SDL_Rect& a, const Vector4& b ); + static const Vector2 Inside( const Vector4& a, const SDL_Rect& b ); + + static const iVector2 Inside( const iVector4& a, const iVector4& b ); + static const iVector2 Inside( const SDL_Rect& a, const iVector4& 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 cCollision +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _CCOLLISION_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.cpp new file mode 100644 index 0000000..af19498 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.cpp @@ -0,0 +1,47 @@ +#include "cRandom.hpp" + +/*** ANSI C Header Files ***/ +#include +#include + +using MathEngine::cRandom; + +/*static*/ cRandom* cRandom::sp_inst = nullptr; + +cRandom::cRandom() +{ + Setup(); +} + +cRandom::~cRandom() +{} + +/*static*/ cRandom& cRandom::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cRandom(); + return *sp_inst; +} + +/*static*/ void cRandom::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cRandom::Setup() const +{ + bool rtn = false; + srand((unsigned int)time(nullptr)); + return rtn = true; +} + +const unsigned long int cRandom::Rand( const unsigned long int max, const unsigned long int min /*= 0*/ ) const +{ + return (unsigned long int)rand() % max + min; +} + +const float cRandom::Rand( const float max, const float min /*= 0.0f*/ ) const +{ + return (float)((max - min) * rand()/(float)RAND_MAX + min); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp new file mode 100644 index 0000000..445331a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp @@ -0,0 +1,32 @@ +#ifndef _CRANDOM_HPP_ +#define _CRANDOM_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cRandom + { + private: + cRandom(); + ~cRandom(); + + public: + ///Functions + static cRandom& Inst(); + static void Delete(); + + const bool Setup() const; + + const unsigned long int Rand( const unsigned long int max, const unsigned long int min = 0 ) const; + const float Rand( const float max, const float min = 0.0f ) const; + + private: + static cRandom* sp_inst;// = nullptr + };/// END CLASS DEFINITION cRandom +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _CRANDOM_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.cpp new file mode 100644 index 0000000..cf96bc9 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.cpp @@ -0,0 +1,98 @@ +#include "iVector2.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector2.hpp" + +using MathEngine::iVector2; +using MathEngine::Vector2; + +iVector2::iVector2( const int X /*= 0*/, const int Y /*= 0*/ ) + : x(X), y(Y) +{} + +iVector2::iVector2( const Vector2& copy ) +{ + x = int(copy.x); + y = int(copy.y); +} + +iVector2::iVector2( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); +} + +iVector2& iVector2::operator = ( const Vector2& copy ) +{ + x = int(copy.x); + y = int(copy.y); + + return *this; +} + +iVector2& iVector2::operator = ( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + + return *this; +} + +bool iVector2::operator == ( const iVector2& other ) const +{ + bool rtn = false; + if (x == other.x) + if (y == other.y) + rtn = true; + + return rtn; +} + +bool iVector2::operator == ( const SDL_Rect& other ) const +{ + bool rtn = false; + if (x == other.x) + if (y == other.y) + rtn = true; + + return rtn; +} + +iVector2& iVector2::operator += ( const iVector2& other ) +{ + x += int(other.x); + y += int(other.y); + + return *this; +} + +iVector2& iVector2::operator += ( const SDL_Rect& other ) +{ + x += int(other.x); + y += int(other.y); + + return *this; +} + +iVector2& iVector2::operator -= (const iVector2& other) +{ + x -= int(other.x); + y -= int(other.y); + + return *this; +} + +iVector2& iVector2::operator -= (const SDL_Rect& other) +{ + x -= int(other.x); + y -= int(other.y); + + return *this; +} + +iVector2 operator + (const iVector2& lhs, const iVector2& rhs) +{ + iVector2 rs = lhs; + rs += rhs; + return rs; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.hpp new file mode 100644 index 0000000..2e9453d --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector2.hpp @@ -0,0 +1,39 @@ +#ifndef _IVECTOR2_HPP_ +#define _IVECTOR2_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace MathEngine { + struct Vector2; + + struct EXPORT_FROM_MYDLL iVector2 + { + iVector2( const int X = 0, const int Y = 0 ); + iVector2( const Vector2& copy ); + iVector2( const SDL_Rect& copy ); + + iVector2& operator = ( const Vector2& copy ); + iVector2& operator = ( const SDL_Rect& copy ); + + bool operator == ( const iVector2& other ) const; + bool operator == ( const SDL_Rect& other ) const; + + iVector2& operator += ( const iVector2& other ); + iVector2& operator += ( const SDL_Rect& other ); + + iVector2& operator -= (const iVector2& other); + iVector2& operator -= (const SDL_Rect& other); + + iVector2& operator + ( const iVector2& other ); + iVector2& operator + ( const SDL_Rect& other ); + + int x; + int y; + };/// END STRUCT DEFINITION iVector2 +}/// END NAMESPACE DEFINITION MathEngine +MathEngine::iVector2 operator + (const MathEngine::iVector2& lhs, const MathEngine::iVector2& rhs); +#endif/// END IFNDEF _IVECTOR2_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.cpp new file mode 100644 index 0000000..4efadd6 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.cpp @@ -0,0 +1,67 @@ +#include "iVector3.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector3.hpp" + +using MathEngine::iVector3; +using MathEngine::Vector3; + +iVector3::iVector3( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/ ) + : iVector2(X, Y), z(Z) +{} + +iVector3::iVector3( const iVector2& copy ) + : iVector2(copy), z(0) +{} + +iVector3::iVector3( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); +} + +iVector3& iVector3::operator=( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + + return *this; +} + +bool iVector3::operator==( const SDL_Rect& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.w ) + rtn = true; + return rtn; +} + +iVector3::iVector3( const Vector3& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); +} + +iVector3& iVector3::operator=( const Vector3& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + + return *this; +} + +bool iVector3::operator==( const iVector3& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.z ) + rtn = true; + return rtn; +} diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.hpp new file mode 100644 index 0000000..94576fa --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector3.hpp @@ -0,0 +1,37 @@ +#ifndef _IVECTOR3_HPP_ +#define _IVECTOR3_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "iVector2.hpp" + +namespace MathEngine { + struct Vector3; + + struct EXPORT_FROM_MYDLL iVector3 : public iVector2 + { + iVector3( const int X = 0, const int Y = 0, const int Z = 0); + + iVector3( const iVector2& copy ); + + iVector3( const SDL_Rect& copy ); + + iVector3& operator=( const SDL_Rect& copy ); + + bool operator==( const SDL_Rect& other ) const; + + iVector3( const Vector3& copy ); + + iVector3& operator=( const Vector3& copy ); + + bool operator==( const iVector3& other ) const; + + int z; + };/// END STRUCT DEFINITION iVector3 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _IVECTOR3_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.cpp new file mode 100644 index 0000000..580de46 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.cpp @@ -0,0 +1,77 @@ +#include "iVector4.hpp" + +/*** Custom Header File ***/ +#include "../Vector/Vector4.hpp" + +using MathEngine::iVector4; +using MathEngine::Vector4; + +iVector4::iVector4( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/, const int W /*= 0*/ ) + : iVector3(X, Y, Z), w(W) +{} + +iVector4::iVector4( const iVector2& copy ) + : iVector3(copy.x, copy.y, 0), w(0) +{} + +iVector4::iVector4( const iVector3& copy ) + : iVector3(copy), w(0) +{} + +iVector4::iVector4( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + w = int(copy.h); +} + +iVector4& iVector4::operator=( const SDL_Rect& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.w); + w = int(copy.h); + + return *this; +} + +bool iVector4::operator==( const SDL_Rect& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.w ) + if ( w == other.h ) + rtn = true; + return rtn; +} + +iVector4::iVector4( const Vector4& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + w = int(copy.w); +} + +iVector4& iVector4::operator=( const Vector4& copy ) +{ + x = int(copy.x); + y = int(copy.y); + z = int(copy.z); + w = int(copy.w); + + return *this; +} + +bool iVector4::operator==( const iVector4& other ) const +{ + bool rtn = false; + if ( x == other.x ) + if ( y == other.y ) + if ( z == other.z ) + if ( w == other.w ) + rtn = true; + return rtn; +} diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.hpp new file mode 100644 index 0000000..0caa85e --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/iVector/iVector4.hpp @@ -0,0 +1,39 @@ +#ifndef _IVECTOR4_HPP_ +#define _IVECTOR4_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header File ***/ +#include "iVector3.hpp" + +namespace MathEngine { + struct Vector4; + + struct EXPORT_FROM_MYDLL iVector4 : public iVector3 + { + iVector4( const int X = 0, const int Y = 0, const int Z = 0, const int W = 0 ); + + iVector4( const iVector2& copy ); + + iVector4( const iVector3& copy ); + + iVector4( const SDL_Rect& copy ); + + iVector4& operator=( const SDL_Rect& copy ); + + bool operator==( const SDL_Rect& other ) const; + + iVector4( const Vector4& copy ); + + iVector4& operator=( const Vector4& copy ); + + bool operator==( const iVector4& other ) const; + + int w; + };/// END STRUCT DEFINITION iVector4 +}/// END NAMESPACE DEFINITION MathEngine +#endif/// END IFNDEF _IVECTOR4_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.cpp b/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.cpp new file mode 100644 index 0000000..31be607 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.cpp @@ -0,0 +1,11 @@ +// Static Model +#include "cNetwork.hpp" + +using NetworkEngine::cNetwork; + +cNetwork::cNetwork() +{} + +cNetwork::~cNetwork() +{} + diff --git a/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.hpp b/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.hpp new file mode 100644 index 0000000..c1887b7 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/NetworkEngine/cNetwork.hpp @@ -0,0 +1,19 @@ +#ifndef _CNETWORK_HPP_ +#define _CNETWORK_HPP_ + +/*** SDL Header Files ***/ +#include +///#include ///For networking + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace NetworkEngine { + class EXPORT_FROM_MYDLL cNetwork + { + public: + cNetwork(); + ~cNetwork(); + };/// END CLASS DEFINITION cNetwork +}/// END NAMESPACE NetworkEngine +#endif /// END IFNDEF _CNETWORK_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.cpp new file mode 100644 index 0000000..e6da9ff --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.cpp @@ -0,0 +1,25 @@ +#include "cFontHolder.hpp" + +using TextTypeHelpers::cFontHolder; + +cFontHolder::cFontHolder( TTF_Font* font, const unsigned long int size ) + : mp_font(font), m_size(size) +{} + +cFontHolder::~cFontHolder() +{ + if (mp_font != nullptr) { + TTF_CloseFont(mp_font); + mp_font = nullptr; + } +} + +TTF_Font* cFontHolder::getFont() const +{ + return mp_font; +} + +const unsigned long int cFontHolder::getSize() const +{ + return m_size; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp new file mode 100644 index 0000000..682b053 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp @@ -0,0 +1,28 @@ +#ifndef _CFONTHOLDER_HPP_ +#define _CFONTHOLDER_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace TextTypeHelpers { + class EXPORT_FROM_MYDLL cFontHolder + { + public: + cFontHolder( TTF_Font* font, const unsigned long int size ); + ~cFontHolder(); + ///Sets + + ///Gets + TTF_Font* getFont() const; + const unsigned long int getSize() const; + + private: + TTF_Font* mp_font;// = nullptr + unsigned long int m_size;// = 16 + };/// END CLASS DEFINITION cFontHolder +}/// END NAMESPACE DEFINITION TextTypeHelpers +#endif/// END IFNDEF _CFONTHOLDER_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp new file mode 100644 index 0000000..ac63673 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp @@ -0,0 +1,121 @@ +#include "cFont.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cFont; +using TextTypeHelpers::cFontHolder; +using UtilityEngine::cUtility; + +cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +: m_dir(dir), m_fileName(filename), mpp_default(nullptr) +{ + setSize(size); +} + +cFont::cFont( const cFont& copy ) +: m_dir(copy.getDir()), m_fileName(copy.getFileName()), mpp_default(nullptr) +{ + setSize(copy.getSize()); +} + +cFont::~cFont() +{ + UnloadFont(); +} + +///Functions +///Sets +void cFont::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cFont::setFileName( const cString& filename ) +{ + m_fileName = filename; +} + +void cFont::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cFont::setSize( const unsigned long int size /*= 16*/ ) +{ + while ((mpp_default == nullptr) || ((*mpp_default) == nullptr)) { + getFont(size); + mpp_default = (cFontHolder**)getFontHolder(size); + } +} + +///Gets +const cString& cFont::getDir() const +{ + return m_dir; +} + +const cString& cFont::getFileName() const +{ + return m_fileName; +} + +const unsigned long int cFont::getSize() const +{ + return (*mpp_default)->getSize(); +} + +TTF_Font* cFont::getFont() +{ + return (*mpp_default)->getFont(); +} + +TTF_Font* cFont::getFont( const unsigned long int size ) +{ + TTF_Font* rtn = nullptr; + + rtn = getFontHolder(size)->getFont(); + //We Can't find the Font in that size so we make a new one + if (rtn == nullptr) { + rtn = LoadFont(size); + } + + return rtn; +} + +//private: +TTF_Font* cFont::LoadFont( const unsigned long int size ) +{ + TTF_Font* rtn = nullptr; + if (m_fileName != "") { + cString temp = m_dir + m_fileName; + if ((rtn = TTF_OpenFont(temp.c_str(), size)) == nullptr) + cUtility::Inst().Message("Unable to load necessary TTF file. " + temp + " TTF_OpenFont():", "", cUtility::eTypeSDL::TTF); + else { + cFontHolder* holder = new cFontHolder(rtn, size); + m_fonts.push_back(holder); + } + } + return rtn; +} + +TextTypeHelpers::cFontHolder* cFont::getFontHolder(const unsigned long int size) +{ + cFontHolder* rtn = nullptr; + std::vector::iterator it; + + for (it = m_fonts.begin(); it < m_fonts.end(); it++) { + if (size == (*it)->getSize()) { + rtn = (*it); + //break out of the for loop + break; + } + } + return rtn; +} + +void cFont::UnloadFont() +{ + m_fonts.clear(); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp new file mode 100644 index 0000000..7693fc9 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp @@ -0,0 +1,75 @@ +#ifndef _CFONT_HPP_ +#define _CFONT_HPP_ + +/*** ANSI C++ Header Files ***/ +#include + +/*** SDL Header Files ***/ +#include +#include + +/*** TextTypeHelpers ***/ +#include "TextTypeHelpers/cFontHolder.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector >; +/*#pragma warning (default : 4231)*/ + +namespace TextTypeEngine { + class EXPORT_FROM_MYDLL cFont + { + public: + cFont(const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 ); + cFont( const cFont& copy ); + ~cFont(); + + ///Functions + + + ///Sets + /* Sets the Directory of the TTF file */ + void setDir( const cString& dir ); + /* Sets the Filename of the TTF file */ + void setFileName( const cString& filename ); + /* Sets the Filename and Directory of the TTF file */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + /* Sets the size of the TTF. Default is 16 */ + void setSize( const unsigned long int size = 16 ); + + ///Gets + /* Gets the Directory of the TTF file */ + const cString& getDir() const; + /* Gets the Filename of the TTF file */ + const cString& getFileName() const; + /* Gets the size of the TTF file. */ + const unsigned long int getSize() const; + /* Gets the TTF_Font. */ + TTF_Font* getFont(); + /* Gets the TTF_Font. */ + TTF_Font* getFont( const unsigned long int size ); + + private: + TTF_Font* LoadFont( const unsigned long int size ); + TextTypeHelpers::cFontHolder* getFontHolder( const unsigned long int size ); + void UnloadFont(); + + private: + std::vector m_fonts; + //cFontHolder m_fonts; + //cFont::cFontHolder m_fonts; + TextTypeHelpers::cFontHolder** mpp_default; + cString m_dir;// = "" + cString m_fileName;// = "" + + };/// END CLASS DEFINITION cFont +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CFONT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp new file mode 100644 index 0000000..7bc18a6 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp @@ -0,0 +1,206 @@ +#include "cText.hpp" + +/*** SDL Header Files ***/ +#include +#include +#include + +/*** Custom Header Files ***/ +#include "../VideoEngine/cRenderer.hpp" +#include "../FXEngine/cGFX.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cText; +using VideoEngine::cRenderer; +using FXEngine::cGFX; +using UtilityEngine::cUtility; + +cText::cText( const cString& text, const unsigned long int size /*= 8*/ ) + : mpp_font(nullptr), m_text(text), m_size(size), m_render(eRender::Solid) +{ + White(); +} + +cText::cText( SDL_Colour& colour, TextTypeEngine::cFont** font /*= nullptr*/, const cString& text /*= ""*/, const unsigned long int size /*= 8*/, const eRender& render /*= eRender::Solid*/ ) + : mpp_font(font), m_text(text), m_size(size), m_render(render) +{ + setColour(colour); +} + +cText::cText( TextTypeEngine::cFont** font /*= nullptr*/, const cString& text /*= ""*/, const unsigned long int size /*= 8*/, + const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/, const eRender& render /*= eRender::Solid*/ ) + : mpp_font(font), m_text(text), m_size(size), m_render(render) +{ + setColour(red, green, blue); +} + +cText::cText( const cText& copy ) + : mpp_font(nullptr), m_text(copy.getText()), m_render(copy.getRender()) +{ + setColour(copy.getColour()); +} + +cText::~cText() +{} + +///Function +void cText::White() +{ + setColour(255, 255, 255); +} + +void cText::Black() +{ + setColour(); +} + +void cText::Blue() +{ + setColour(0, 0, 255); +} + +void cText::Green() +{ + setColour(0, 255); +} + +void cText::Red() +{ + setColour(255); +} + +///Sets +void cText::setSize(const unsigned long int size /*= 8*/) +{ + m_size = size; + if ((mpp_font != nullptr) && ((*mpp_font) != nullptr)) + (*mpp_font)->setSize(size); +} + +void cText::setFont( TextTypeEngine::cFont** font ) +{ + mpp_font = font; + Text(); +} + +void cText::setText( const cString& text ) +{ + if (m_text != text) { + m_text = text; + Text(); + } +} + +void cText::setColour( const SDL_Colour& colour ) +{ + m_colour = colour; + Text(); +} + +void cText::setColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/, unsigned long int alpha /*= 255*/ ) +{ + SDL_Colour colour = {Uint8(red), Uint8(green), Uint8(blue), Uint8(alpha)}; + setColour(colour); +} + +void cText::setRender( const eRender& render /*= eRender::Solid*/ ) +{ + m_render = render; + Text(); +} + +///Gets +const unsigned long int cText::getSize() const +{ + unsigned long int rtn = m_size; + if ((mpp_font != nullptr) && ((*mpp_font) != nullptr)) + return (*mpp_font)->getSize(); + return rtn; +} + +TextTypeEngine::cFont* cText::getFont() const +{ + return (*mpp_font); +} + +const cString& cText::getText() const +{ + return m_text; +} + +const SDL_Colour& cText::getColour() const +{ + return m_colour; +} + +void cText::getColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue, unsigned long int& alpha ) const +{ + red = m_colour.r; + green = m_colour.g; + blue = m_colour.b; + alpha = m_colour.a; +} + +const cText::eRender& cText::getRender() const +{ + return m_render; +} + +//Private +void cText::Text() +{ + if((mpp_font != nullptr) && (*mpp_font != nullptr)) { + SDL_Surface* sur = nullptr; + switch (m_render) + { + case Solid: + if ((sur = TTF_RenderText_Solid((*mpp_font)->getFont(m_size), m_text.c_str(), m_colour) ) == nullptr) + cUtility::Inst().Message("Unable to render text. TTF_RenderText_Solid():", __AT__, cUtility::eTypeSDL::TTF); + break; + case Shaded: + //sur = TTF_RenderText_Shaded(mp_font, text.c_str(), m_colour, + break; + case Blended: + if ((sur = TTF_RenderText_Blended((*mpp_font)->getFont(m_size), m_text.c_str(), m_colour) ) == nullptr) + cUtility::Inst().Message("Unable to render text. TTF_RenderText_Blended():", __AT__, cUtility::eTypeSDL::TTF); + break; + } + setImage(sur); + } else { + SDL_Rect pos = { 0, 0, 0, 0 }; + //m_size == 25; + SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, SDL_TEXTUREACCESS_TARGET); + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + + //int t = SDL_SetTextureColorMod(texture, 0, 255, 0); + + // 376840196 + + + + //t = SDL_SetTextureAlphaMod(texture, 0); + //SDL_fill + //cRenderer::Inst().SetRenderTarget(texture); + //SDL_Colour col = { 0, 255, 255, 255}; + //SDL_Rect re= { 0, 0, 100, 100}; + //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); + //cRenderer::Inst().RenderDrawColor(col); + //cRenderer::Inst().RenderDrawRect(re, texture); + + //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); + + //cRenderer::Inst().Render( texture, nullptr, nullptr); + //SDL_RenderCopy(cRenderer::Inst().getRenderer(), texture, nullptr, nullptr); + + //cRenderer::Inst().Render(texture, nullptr, nullptr); + //cRenderer::Inst().ResetRenderTarget(); + + if (texture != nullptr) { + + //cGFX::Inst().StringDefault(m_text, pos, m_colour); + cGFX::Inst().StringDefault(m_text, pos, m_colour, texture); + //cGFX::Inst().ZoomIn(texture, m_size * m_text.length(), m_size, SMOOTHING_ON); + setImage(texture); + } + } +} diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp new file mode 100644 index 0000000..dec5b52 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp @@ -0,0 +1,92 @@ +#ifndef _CTEXT_HPP_ +#define _CTEXT_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** VideoEngine ***/ +#include "../VideoEngine/cImage.hpp" + +/*** TextTypeEngine ***/ +#include "cFont.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace TextTypeEngine { + class EXPORT_FROM_MYDLL cText : public VideoEngine::cImage + { + public: + enum eRender: unsigned int + { + Solid = 0, + Shaded, + Blended + }; + public: + cText( const cString& text, const unsigned long int size = 8 ); + cText( SDL_Colour& colour, TextTypeEngine::cFont** font = nullptr, const cString& text = "", const unsigned long int size = 8, const eRender& render = eRender::Solid ); + cText( TextTypeEngine::cFont** font = nullptr, const cString& text = "", const unsigned long int size = 8, + const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0, const eRender& render = eRender::Solid ); + cText( const cText& copy ); + ~cText(); + + + ///Function + + /* Change the colour of the text to White */ + void White(); + /* Change the colour of the text to Black */ + void Black(); + /* Change the colour of the text to Blue */ + void Blue(); + /* Change the colour of the text to Green */ + void Green(); + /* Change the colour of the text to Red */ + void Red(); + + ///Sets + /* Sets the Size */ + void setSize( const unsigned long int size = 8 ); + void setFont( cFont** font ); + /* Sets the text to be printed */ + void setText( const cString& text ); + /* Sets the colour of the text via SDL_Colour. */ + void setColour( const SDL_Colour& colour ); + /* Sets the colour of the text via RGB. Default is Black */ + void setColour( const unsigned long int red = 0, const unsigned long int green = 0, const unsigned long int blue = 0, unsigned long int alpha = 255 ); + /* Sets the render of the text. Default is Solid */ + void setRender( const eRender& render = eRender::Solid ); + + ///Gets + /* Gets the Size */ + const unsigned long int getSize() const; + cFont* getFont() const; + /* Gets the text to be printed. */ + const cString& getText() const; + /* Gets the SDL_Colour of the text */ + const SDL_Colour& getColour() const; + /* Gets the RGB of the text. */ + void getColour( unsigned long int& red, unsigned long int& green, unsigned long int& blue, unsigned long int& alpha ) const; + /* Gets the render of the text. */ + const eRender& getRender() const; + + private: + void Text(); + + private: + TextTypeEngine::cFont** mpp_font; + cString m_text;// = "" + + unsigned long int m_size;// = 16 + SDL_Colour m_colour;// = nullptr + eRender m_render;// = Solid + };/// END CLASS DEFINITION cText +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CTEXT_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.cpp new file mode 100644 index 0000000..b63bbea --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.cpp @@ -0,0 +1,86 @@ +#include "cTextType.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TextTypeEngine::cTextType; +using UtilityEngine::cUtility; + +/*static*/ cTextType* cTextType::sp_inst = nullptr; + +//private +cTextType::cTextType() +{ +} + +cTextType::~cTextType() +{ + CleanUp(); + TTF_Quit(); +} + +//public: +///Functions +/*static*/ cTextType& cTextType::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTextType(); + return *sp_inst; +} + +/*static*/ void cTextType::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTextType::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if (TTF_Init() == 0) { + cUtility::Inst().Message("True Type Font Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize True Type Font. TTF_Init():", __AT__, cUtility::eTypeSDL::TTF); + } + return rtn; +} + +/* Creates the cTextType's*/ +const bool cTextType::Setup() +{ + /*bool rtn = false; + + CleanUp(); + + rtn = Init(); + + return rtn;*/ + return true; +} + +void cTextType::CleanUp() +{ +} + +void cTextType::PrintVersion() const +{ + cUtility::Inst().PrintVersion(cUtility::eTypeSDL::TTF); +} + +///Sets +///Gets +const bool cTextType::IsInit() const +{ + bool rtn = false; + + if (TTF_WasInit() != 0) { + cUtility::Inst().Message("True Type Font is initialized."); + rtn = true; + } else + cUtility::Inst().Message("True Type Font is not initialized."); + + return rtn; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp new file mode 100644 index 0000000..b66cf73 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp @@ -0,0 +1,40 @@ +#ifndef _CTEXTTYPE_HPP_ +#define _CTEXTTYPE_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace TextTypeEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTextType + { + private: + cTextType(); + ~cTextType(); + + public: + ///Functions + static cTextType& Inst(); + static void Delete(); + + const bool Initialize() const; + + const bool Setup(); + void CleanUp(); + + void PrintVersion() const; + + ///Sets + ///Gets + /* Gets return true if Text was initialized */ + const bool IsInit() const; + + private: + static cTextType* sp_inst;// = nullptr + };/// END CLASS DEFINITION cTextType +}/// END NAMESPACE DEFINITION TextTypeEngine +#endif/// END IFNDEF _CTEXTTYPE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.cpp b/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.cpp new file mode 100644 index 0000000..804b43b --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.cpp @@ -0,0 +1,144 @@ +#include "cTiming.hpp" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cUtility.hpp" + +using TimingEngine::cTiming; +using UtilityEngine::cUtility; + +/*static*/ cTiming* cTiming::sp_inst = nullptr; + +cTiming::cTiming( const unsigned long int ftp /*= 30*/ ) +: m_ftp(ftp), m_rate(1000 / ftp), m_nextTime(0), m_start(SDL_GetTicks()), m_lastTime(0.0f), m_frameTime(0.0f) +{ + Setup(); +} + +cTiming::~cTiming() +{ + CleanUp(); +} + +cTiming& cTiming::operator=( const cTiming& copy ) +{ + if (this != ©) + setFTP(copy.getFTP()); + + return *this; +} + +///Functions +/*static*/ cTiming& cTiming::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTiming(); + return *sp_inst; +} + +/*static*/ void cTiming::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTiming::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if( SDL_Init( SDL_INIT_TIMER ) == 0 ) { + cUtility::Inst().Message("Timer Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize timer. SDL_Init(SDL_INIT_TIMER):", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +void cTiming::Setup() +{ + m_nextTime = SDL_GetTicks(); + AddTimeandRate(); +} + +void cTiming::CleanUp() +{} + +void cTiming::Time() +{ + SDL_Delay(TimeLeft()); + AddTimeandRate(); + m_frameTime = FrameTime(); + //m_start = SDL_GetTicks(); +} + +const float/*unsigned long int*/ cTiming::FrameTime() +{ + /*unsigned long int rtn = 0; + unsigned long int end = SDL_GetTicks(); + + rtn = end - m_start; + + m_start = end; + + return rtn;*/ + + /* for keeping track of timing */ + unsigned long int thisTime = SDL_GetTicks(); + + m_lastTime = (float)thisTime - 30; + + + thisTime = SDL_GetTicks(); + return (float)(thisTime - m_lastTime) / m_ftp; +} + +///Sets +void cTiming::setFTP( const unsigned long int ftp /*= 30*/ ) +{ + m_ftp = ftp; + m_rate = 1000 / m_ftp; + Setup(); +} + +///Gets +const unsigned long int cTiming::getFTP() const +{ + return m_ftp; +} + +const bool cTiming::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_TIMER) != 0) { + cUtility::Inst().Message("Timer is initialized"); + rtn = true; + } else + cUtility::Inst().Message("Timer is not initialized."); + + return rtn; +} + +const float cTiming::getFrameTime() const +{ + return m_frameTime; +} + +///Private +///Functions +const unsigned long int cTiming::TimeLeft() +{ + unsigned long int now = SDL_GetTicks(); + + if(m_nextTime <= now) + return 0; + else + return m_nextTime - now; +} + +void cTiming::AddTimeandRate() +{ + m_nextTime += m_rate; +} diff --git a/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.hpp b/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.hpp new file mode 100644 index 0000000..ef5dded --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TimingEngine/cTiming.hpp @@ -0,0 +1,68 @@ +#ifndef _CTIMING_HPP_ +#define _CTIMING_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include + +#define MAXIMUM_FRAME_RATE 120 +#define MINIMUM_FRAME_RATE 15 +#define UPDATE_INTERVAL (1.0 / MAXIMUM_FRAME_RATE) +#define MAX_CYCLES_PER_FRAME (MAXIMUM_FRAME_RATE / MINIMUM_FRAME_RATE) + +namespace TimingEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cTiming + { + private: + cTiming( const unsigned long int ftp = 30 ); + ~cTiming(); + + public: + cTiming& operator=( const cTiming& copy ); + + ///Functions + static cTiming& Inst(); + static void Delete(); + + const bool Initialize() const; + /* Sets up timing */ + void Setup(); + void CleanUp(); + /* Sleeps if need */ + void Time(); + + ///Sets + void setFTP( const unsigned long int ftp = 30 ); + ///Gets + const unsigned long int getFTP() const; + /* Gets return true if Timer was initialized */ + const bool IsInit() const; + + const float getFrameTime() const; + + + private: + const unsigned long int TimeLeft(); + void AddTimeandRate(); + + const float FrameTime(); + + private: + ///Variables + unsigned long int m_nextTime;// = 0 + + unsigned long int m_rate;// = (1000 / m_ftp) + + unsigned long int m_ftp;// = 30 + + static cTiming* sp_inst;// = nullptr + + unsigned long int m_start;// = 0 + float m_lastTime;// = 0.0 + float m_frameTime;// = 0.0 + };/// END CLASS DEFINITION cTiming +}/// END NAMESPACE DEFINITION TimingEngine +#endif/// END IFNDEF _CTIMING_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.cpp b/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.cpp new file mode 100644 index 0000000..2f58cd2 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.cpp @@ -0,0 +1,151 @@ +#include "cTrooperEngineCore.hpp" + +/*** Custom Header Files ***/ +#include "../VideoEngine/cVideo.hpp" +#include "../AudioEngine/cAudio.hpp" +#include "../InputEngine/cInput.hpp" + +#include "../TimingEngine/cTiming.hpp" + +#include "../TextTypeEngine/cTextType.hpp" + +#include "../MathEngine/cRandom.hpp" + +#include "../EventEngine/cEventControl.hpp" + +#include "../UtilityEngine/cUtility.hpp" + +#include "../GUIEngine/cGUI.hpp" + +using TrooperEngineCore::cTrooperEngineCore; + +/*static*/ cTrooperEngineCore* cTrooperEngineCore::sp_inst = nullptr; + +cTrooperEngineCore::cTrooperEngineCore() +{ +} + +cTrooperEngineCore::~cTrooperEngineCore() +{ + CleanUp(); + VideoEngine::cVideo::Delete(); + AudioEngine::cAudio::Delete(); + InputEngine::cInput::Delete(); + TimingEngine::cTiming::Delete(); + + TextTypeEngine::cTextType::Delete(); + MathEngine::cRandom::Delete(); + EventEngine::cEventControl::Delete(); + SDL_Quit(); + UtilityEngine::cUtility::Inst().Message("SDL shut down!"); + UtilityEngine::cUtility::Delete(); + + GUIEngine::cGUI::Delete(); +} + +///Functions +/*static*/ const char* cTrooperEngineCore::Version() +{ + return __TROOPERENGINE__VERSION; +} + +/*static*/ cTrooperEngineCore& cTrooperEngineCore::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cTrooperEngineCore(); + return *sp_inst; +} + +/*static*/ void cTrooperEngineCore::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cTrooperEngineCore::VideoInit() +{ + return VideoEngine::cVideo::Inst().Initialize(); +} + +const bool cTrooperEngineCore::AudioInit() +{ + return AudioEngine::cAudio::Inst().Initialize(); +} + +const bool cTrooperEngineCore::InputInit() +{ + return true; +} + +const bool cTrooperEngineCore::JoystickInit() +{ + return InputEngine::cInput::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TimerInit() +{ + return TimingEngine::cTiming::Inst().Initialize(); +} + +const bool cTrooperEngineCore::TextTypeInit() +{ + return TextTypeEngine::cTextType::Inst().Initialize(); +} + +const bool cTrooperEngineCore::EventInit() +{ + return EventEngine::cEventControl::Inst().Initialize(); +} + +/* Print lib versions */ +void cTrooperEngineCore::PrintSDLVersion() const +{ + UtilityEngine::cUtility::Inst().PrintVersion(); +} + +void cTrooperEngineCore::CleanUp() +{ + VideoEngine::cVideo::Inst().CleanUp(); + AudioEngine::cAudio::Inst().CleanUp(); + TimingEngine::cTiming::Inst().CleanUp(); + TextTypeEngine::cTextType::Inst().CleanUp(); + InputEngine::cInput::Inst().CleanUp(); + EventEngine::cEventControl::Inst().CleanUp(); +} + +///Gets +const bool cTrooperEngineCore::getVideo() const +{ + return VideoEngine::cVideo::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getAudio() const +{ + return AudioEngine::cAudio::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getInput() const +{ + return InputEngine::cInput::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getJoystick() const +{ + return false; +} + +const bool cTrooperEngineCore::getTimer() const +{ + return TimingEngine::cTiming::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getText() const +{ + return TextTypeEngine::cTextType::Inst().IsInit(); +} + +const bool cTrooperEngineCore::getEvent() const +{ + return EventEngine::cEventControl::Inst().IsInit(); +} + diff --git a/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.hpp b/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.hpp new file mode 100644 index 0000000..dbeced6 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/TrooperEngineCore/cTrooperEngineCore.hpp @@ -0,0 +1,68 @@ +#ifndef _CTROOPERENGINECORE_HPP_ +#define _CTROOPERENGINECORE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +#define __TROOPERENGINE__VERSION "1.0.0" + +namespace TrooperEngineCore { + /* Singleton */ + class EXPORT_FROM_MYDLL cTrooperEngineCore + { + private: + cTrooperEngineCore(); + ~cTrooperEngineCore(); + + public: + ///Functions + static const char* Version(); + static cTrooperEngineCore& Inst(); + static void Delete(); + + /* Initiates the video */ + const bool VideoInit(); + /* Initiates the audio */ + const bool AudioInit(); + /* Initiates the input (Keyboard Mouse Joystick)*/ + const bool InputInit(); + /* Initiates the joystick */ + const bool JoystickInit(); + /* Initiates the timer */ + const bool TimerInit(); + /* Initiates the text */ + const bool TextTypeInit(); + /* Initiates the event */ + const bool EventInit(); + + /* Print lib versions */ + void PrintSDLVersion() const; + + /* Cleans up */ + void CleanUp(); + + ///Gets + /* Gets returns true if Video was initiated other wise it returns false */ + const bool getVideo() const; + /* Gets returns true if Audio was initiated other wise it returns false */ + const bool getAudio() const; + /* Gets returns true if Input was initiated other wise it returns false */ + const bool getInput() const; + /* Gets returns true if Joystick was initiated other wise it returns false */ + const bool getJoystick() const; + /* Gets returns true if Timer was initiated other wise it returns false */ + const bool getTimer() const; + /* Gets returns true if Text was initiated other wise it returns false */ + const bool getText() const; + /* Gets returns true if Event was initiated other wise it returns false */ + const bool getEvent() const; + + private: + ///Variables + static cTrooperEngineCore* sp_inst;// = nullptr + };/// END CLASS DEFINITION cTrooperEngineCore +}/// END NAMESPACE DEFINITION TroopperENgineCore +#endif/// END IFNDEF _CTROOPERENGINECORE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.cpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.cpp new file mode 100644 index 0000000..6649ebd --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.cpp @@ -0,0 +1,37 @@ +#include "msunix.hpp" + +int vasprintf(char ** ret, const char * format, va_list ap) +{ + int len; + char *buffer; + + len = _vscprintf(format, ap) + 1; + buffer = (char *) malloc(len * sizeof(char)); + if (!buffer) return 0; + vsprintf_s(buffer, len, format, ap); + *ret = buffer; + return len -1; +} + +/*int snprintf(char * str, size_t size, const char * format, ...) +{ + va_list args; + size_t len; + + va_start(args, format); + len = _vscprintf(format, args) + 1; + if (len > size) len = size; + vsprintf_s(str, len, format, args); + return len - 1; +}*/ + +int setenv(const char *name, const char *value, int overwrite) +{ + int errcode = 0; + if(!overwrite) { + size_t envsize = 0; + errcode = getenv_s(&envsize, NULL, 0, name); + if(errcode || envsize) return errcode; + } + return _putenv_s(name, value); +} diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.hpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.hpp new file mode 100644 index 0000000..fff4124 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/MSUNIX/msunix.hpp @@ -0,0 +1,14 @@ +#ifndef __MSUNIX__ +#define __MSUNIX__ + +#define _MSUNIX_VERSION "1.0.0" + +#include +#include +#include + +int vasprintf(char ** ret, const char * format, va_list ap); +//int snprintf(char * str, size_t size, const char * format, ...); +int setenv(const char *name, const char *value, int overwrite); + +#endif // __MSUNIX__ diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.cpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.cpp new file mode 100644 index 0000000..37bad66 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.cpp @@ -0,0 +1,423 @@ +#include "cString.hpp" + +/*** ANSI C Header Files ***/ +#include /* strtol */ + +#ifdef _MSC_VER +// disable _s warnings +# define _CRT_SECURE_NO_WARNINGS +// disable pragma warnings +# pragma warning( disable : 4068 ) +# pragma warning( disable : 4996 ) +# include "MSUNIX/msunix.hpp" +#endif + +using UtilityEngine::cString; + +cString::cString() +{ + clear(); +} + +cString::cString(const char* s) +{ + copy_str(s); +} + +cString::cString(const cString& copy) +{ + copy_str(copy); +} + + +cString::~cString() +{ + clear(); +} + +const char* cString::alloc_str(size_t sz) +{ + if (mp_str) + clear(); + m_len = (sz > __cString__MAX_LEN) ? __cString__MAX_LEN : sz; + mp_str = (char *)calloc(1, m_len + 1); + return mp_str; +} + +void cString::clear() +{ + if (mp_str) + free((void *)mp_str); + mp_str = nullptr; + m_len = 0; +} + +const char* cString::c_str() const +{ + return mp_str; +} + +const char* cString::copy_str(const char* copy) +{ + if (copy) { + size_t len = strnlen(copy, __cString__MAX_LEN); + alloc_str(len); + strncpy((char *)mp_str, copy, len); + m_len = len; + } + return mp_str; +} + +bool cString::have_value() const +{ + if (mp_str) + return true; + else + return false; +} + +size_t cString::length() const +{ + return m_len; +} + +size_t cString::size() const +{ + return m_len; +} + +// string format +cString& cString::format(const char* format, ...) +{ + char * buffer; + + va_list args; + va_start(args, format); + + vasprintf(&buffer, format, args); + copy_str(buffer); + free(buffer); + return *this; +} + +// trim leading and trailing spaces +cString& cString::trim() +{ + const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a"; + + if (!have_value()) + return *this; // make sure we have a string + + size_t begin = 0; + size_t end = length() - 1; + + for (begin = 0; begin <= end; ++begin) { + if (strchr(whitespace, mp_str[begin]) == nullptr) { + break; + } + } + + for (; end > begin; --end) { + if (strchr(whitespace, mp_str[end]) == nullptr) { + break; + } + else { + mp_str[end] = '\0'; + } + } + + if (begin) { + for (size_t i = 0; mp_str[i]; ++i) { + mp_str[i] = mp_str[begin++]; + } + } + + m_len = strlen(mp_str); + return *this; +} + +cString cString::lower() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)tolower(rs.mp_str[i]); + } + return rs; +} + +cString cString::upper() const +{ + cString rs = *this; + for (size_t i = 0; rs.mp_str[i]; ++i) { + rs.mp_str[i] = (char)toupper(rs.mp_str[i]); + } + return rs; +} + +const char& cString::first_char() const +{ + return mp_str[0]; +} + +const char& cString::last_char() const +{ + return mp_str[length() - 1]; +} + +// non-destructive split +const std::vector cString::split(const char match) const +{ + const char match_s[2] = { match, 0 }; + return split(match_s, -1); +} + +const std::vector cString::split(const char* match) const +{ + return split(match, -1); +} + +const std::vector cString::split(const char* match, int max_split) const +{ + std::vector rtn; + if (length() < 1) + return rtn; + size_t match_len = strnlen(match, __cString__MAX_LEN); + if (match_len >= __cString__MAX_LEN) + return rtn; + + char* mi; // match index + char* pstr = mp_str; // string pointer + while ((mi = strstr(pstr, match)) && (max_split < 0 || --max_split)) { + if (mi != pstr) { + size_t lhsz = mi - pstr; + char* cslhs = (char *)malloc(lhsz + 1); + cslhs[lhsz] = '\0'; // strncpy doesn't terminate it + rtn.emplace_back(strncpy(cslhs, pstr, lhsz)); // calls cString copy ctor + pstr += lhsz; + free(cslhs); + } + pstr += match_len; + } + + if (*pstr != '\0') { + rtn.emplace_back(pstr); + } + + return rtn; +} + +const cString& cString::char_repl(const char& match, const char& repl) +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) mp_str[i] = repl; + } + return *this; +} + +long int cString::char_find(const char& match) const +{ + for (size_t i = 0; mp_str[i]; ++i) { + if (mp_str[i] == match) + return i; + } + return -1; +} + +cString cString::substr(size_t start, size_t length) const +{ + cString rs; + char * buf; + if ((length + 1) > __cString__MAX_LEN) + return rs; + if ((start + length) > __cString__MAX_LEN) + return rs; + if (length > m_len - start) + return rs; + if (!mp_str) + return rs; + + buf = (char *)calloc(sizeof(char), length + 1); + memcpy(buf, mp_str + start, length); + rs = buf; + return rs; +} + +long int cString::find(const cString& match) +{ + char * pos = strstr(mp_str, match.c_str()); + if (pos) + return (long)(pos - mp_str); + else + return -1; +} + +const cString cString::replace(const cString& match, const cString& repl) +{ + cString rs; + long f1 = find(match); + if (f1 >= 0) { + size_t pos1 = (size_t)f1; + size_t pos2 = pos1 + match.length(); + cString s1 = pos1 > 0 ? substr(0, pos1) : ""; + cString s2 = substr(pos2, length() - pos2); + rs = s1 + repl + s2; + } + return rs; +} + +const bool cString::IsInt() const +{ + bool rtn = false; + cString tmp = c_str(); + tmp.trim(); + switch (tmp.first_char()) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + rtn = true; + break; + default: + rtn = false; + break; + } + return rtn; +} + +const long int cString::ToInt() const +{ + return strtol(mp_str, NULL, 10); +} + +cString& cString::operator = (const char* rhs) +{ + copy_str(rhs); + return *this; +} + +cString& cString::operator = (const cString& rhs) +{ + copy_str(rhs.c_str()); + return *this; +} + +cString& cString::operator += (const char rhs) +{ + operator+=(&rhs); + return *this; +} + +cString& cString::operator += (const char* rhs) +{ + if (rhs) { + size_t newlen = m_len + strnlen(rhs, __cString__MAX_LEN); + if (newlen > __cString__MAX_LEN) + newlen = __cString__MAX_LEN; + char * buf = (char *)calloc(1, newlen + 1); + if (!buf) + return *this; + + if (mp_str && m_len) + strncpy(buf, mp_str, m_len); + strncpy(buf + m_len, rhs, newlen - m_len); + + buf[newlen] = '\0'; + copy_str(buf); + free(buf); + } + return *this; +} + +cString& cString::operator += (const cString& rhs) +{ + operator+=(rhs.c_str()); + return *this; +} + +bool cString::operator == (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator == (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) == 0) + return true; + else + return false; +} + +bool cString::operator != (const char* rhs) const +{ + if (std::strncmp(this->c_str(), rhs, __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator != (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) != 0) + return true; + else + return false; +} + +bool cString::operator > (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) > 0) + return true; + else + return false; +} + +bool cString::operator < (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) < 0) + return true; + else + return false; +} + +bool cString::operator >= (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) >= 0) + return true; + else + return false; +} + +bool cString::operator <= (const cString& rhs) const +{ + if (std::strncmp(this->c_str(), rhs.c_str(), __cString__MAX_LEN) <= 0) + return true; + else return false; +} + +cString::operator const char* () const +{ + return c_str(); +} + +cString::operator std::string () const +{ + return std::string(c_str()); +} + +cString operator + (const cString& lhs, const cString& rhs) +{ + cString rs = lhs; + rs += rhs; + return rs; +} + diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp new file mode 100644 index 0000000..db35f6c --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp @@ -0,0 +1,85 @@ +#ifndef _CSTRING_HPP_ +#define _CSTRING_HPP_ + +/*** C++ STL Files ***/ +#include +#include + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*#pragma warning (disable : 4231)*/ +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator; +EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string; +/*#pragma warning (default : 4231)*/ + +#define __cString__MAX_LEN 65535 + +namespace UtilityEngine { + class EXPORT_FROM_MYDLL cString + { + public: + cString(); // default constructor + cString(const char* s); + cString(const cString& copy); // copy constructor + ~cString(); + + const char* alloc_str(size_t sz); // smart alloc string + void clear(); // frees the string + const char* c_str() const; // getter + const char* copy_str(const char* copy); // alloc & copy + + // utility methods + bool have_value() const; + size_t length() const; + size_t size() const; + cString& format(const char* format, ...); + cString& trim(); + cString lower() const; + cString upper() const; + const char& first_char() const; + const char& last_char() const; + const std::vector split(const char match) const; + const std::vector split(const char* match) const; + const std::vector split(const char* match, int max_split) const; + long int char_find(const char& match) const; + const cString& char_repl(const char& match, const char& repl); + cString substr(size_t start, size_t length) const; + long int find(const cString& match); + const cString replace(const cString& match, const cString& repl); + + const bool IsInt() const; + const long int ToInt() const; + + // operators + cString& operator = (const char* rhs); // assignment operator + cString& operator = (const cString& rhs); // assignment operator + cString& operator += (const char rhs); + cString& operator += (const char* rhs); // concatenation operator + cString& operator += (const cString& rhs); // concatenation operator + + bool operator == (const char* rhs) const; // comparisons + bool operator == (const cString& rhs) const; + bool operator != (const char* rhs) const; + bool operator != (const cString& rhs) const; + bool operator > (const cString& rhs) const; + bool operator < (const cString& rhs) const; + bool operator >= (const cString& rhs) const; + bool operator <= (const cString& rhs) const; + + // conversion operators + operator const char* () const; // c-string type + operator std::string () const; // c++ string class + + private: + char* mp_str = nullptr; + size_t m_len = 0; + + };/// END CLASS DEFINITION cString + // function overloads +}/// END NAMESPACE DEFINITION UtilityEngine +UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs); +#endif/// END IFNDEF _CSTRING_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.cpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.cpp new file mode 100644 index 0000000..2686327 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.cpp @@ -0,0 +1,132 @@ +#include "cUtility.hpp" + +/*** SDL Header Files ***/ +#include +#include +#include +#include +#include + +using UtilityEngine::cUtility; + +/*static*/ cUtility* cUtility::sp_inst = nullptr; + +//private: +cUtility::cUtility() +{} + +cUtility::~cUtility() +{} + +//public: +// cUtility& cUtility::operator=( const cUtility& copy ) +// { +// if (this != ©) +// { +// } +// +// return *this; +// } + +///Functions +/*static*/ cUtility& cUtility::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cUtility(); + return *sp_inst; +} + +/*static*/ void cUtility::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +void cUtility::Message( const cString& msg, const cString& debugInfo /*= ""*/, const eTypeSDL typeSDL /*= eTypeSDL::None*/ ) const +{ + cString sdlerror; + switch (typeSDL) + { + case NONE: + break; + case SDL: + sdlerror = SDL_GetError(); + break; + case TTF: + sdlerror = TTF_GetError(); + break; + case IMAGE: + sdlerror = IMG_GetError(); + break; + case MIXER: + sdlerror = Mix_GetError(); + break; + case NET: + sdlerror = SDLNet_GetError(); + break; + case GFX: + sdlerror = SDL_GetError(); + break; + default: + break; + } + SDL_ClearError(); + if (debugInfo.size() > 0) + fprintf(stderr, "Error in %s %s %s \n", debugInfo.substr((1 + debugInfo.char_find('\\')), debugInfo.length()).c_str(), msg.c_str(), sdlerror.c_str()); + else + fprintf(stderr, "%s\n", msg.c_str()); +} + +void cUtility::PrintVersion( const eTypeSDL typeSDL /*= eTypeSDL::ALL*/ ) const +{ + SDL_version compiled_version; + SDL_version running_version; + + cString type = ""; + + switch (typeSDL) + { + case ALL: + for ( int num = SDL; num <= NET; num++) + PrintVersion((eTypeSDL)num); + break; + case SDL: + SDL_VERSION(&compiled_version); + SDL_GetVersion(&running_version); + type = "SDL"; + break; + case TTF: + SDL_TTF_VERSION(&compiled_version); + running_version = *TTF_Linked_Version(); + type = "SDL_TTF"; + break; + case IMAGE: + SDL_IMAGE_VERSION(&compiled_version); + running_version = *IMG_Linked_Version(); + type = "SDL_IMAGE"; + break; + case MIXER: + SDL_MIXER_VERSION(&compiled_version); + running_version = *Mix_Linked_Version(); + type = "SDL_MIXER"; + break; + case NET: + SDL_NET_VERSION(&compiled_version); + running_version = *SDLNet_Linked_Version(); + type = "SDL_NET"; + break; + default: + break; + } + if (typeSDL != ALL) { + VersionParser("Compiled", compiled_version, type); + VersionParser("Running", running_version, type); + } +} + +///Private: +///Functions +void cUtility::VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const +{ + fprintf(stderr, "%s with %s version: %u.%u.%u \n", runCompiled.c_str(), type.c_str(), version.major, version.minor, version.patch); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp new file mode 100644 index 0000000..b5c035a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp @@ -0,0 +1,67 @@ +#ifndef _CUTILITY_HPP_ +#define _CUTILITY_HPP_ + +/*** ANSI C Header Files ***/ +#include //for __FUNCTION__ + +#ifndef __FUNCTION__ +# define __FUNCTION__ __func__ +#endif + +#define __STRINGIFY__(x) #x +#define __TOSTRING__(x) __STRINGIFY__(x) +#define __AT__ __FILE__ ":" __TOSTRING__(__LINE__) ":(" __FUNCTION__ ")" + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "cString.hpp" + +using UtilityEngine::cString; + + + +namespace UtilityEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cUtility + { + public: + enum eTypeSDL : unsigned int + { + NONE = 0, + ALL = 0, + SDL, + TTF, + IMAGE, + MIXER, + GFX, + NET, + }; + + private: + cUtility(); + ~cUtility(); + + public: + ///Functions + static cUtility& Inst(); + static void Delete(); + + void Message( const cString& msg, const cString& funcName = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const; + + void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const; + + + private: + ///Functions + void VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const; + + + private: + ///Variables + static cUtility* sp_inst;// = nullptr + + };/// END CLASS DEFINITION cUtility +}/// END NAMESPACE DEFINITION UtilityEngine +#endif/// END IFNDEF _CUTILITY_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.cpp new file mode 100644 index 0000000..5e03c18 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.cpp @@ -0,0 +1,158 @@ +#include "cAnimatedSprite.hpp" + +using VideoEngine::cAnimatedSprite; + +cAnimatedSprite::cAnimatedSprite( const unsigned long int x /*= 0*/, const unsigned long int y /*= 0*/, + const unsigned long int fps /*= 16*/ ) +: m_nextTime(0), m_RATE(0) +{ + setFPS(fps); + setIncrement(x, y); +} + +cAnimatedSprite::cAnimatedSprite( const cAnimatedSprite& copy ) +: m_nextTime(0), m_RATE(0) +{ + setFPS(copy.getFPS()); + setIncrement(copy.getXIncrement(), copy.getYIncrement()); +} + +cAnimatedSprite::~cAnimatedSprite() +{ +} + +///Functions +void cAnimatedSprite::UptoDown() +{ + //if (TimeLeft() == 0) + //{ + signed long int x = 0; + signed long int y = 0; + getStartImageArea(x, y); + y += m_yIncrement; + if (y >= signed(getImage()->getHeight())) + y = 1; + setStartImageArea(x, y); + //} + Draw(); +} + +void cAnimatedSprite::DowntoUp() +{ + //if (TimeLeft() == 0) + //{ + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + y -= m_yIncrement; + if (y < 1) + y = getImage()->getHeight() - m_yIncrement; + setStartImageArea(x, y); + //} + Draw(); +} + +void cAnimatedSprite::LefttoRight() +{ + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + if (x >= signed(getImage()->getWidth())) + setStartImageArea(1,y); + if (TimeLeft() == 0) + { + x = 0; + y = 0; + + getStartImageArea(x, y); + x += m_xIncrement; + if (x >= signed(getImage()->getWidth())) + x = 1; + setStartImageArea(x, y); + } + Draw(); +} + +void cAnimatedSprite::RighttoLeft() +{ + if (TimeLeft() == 0) + { + signed long int x = 0; + signed long int y = 0; + + getStartImageArea(x, y); + x -= m_xIncrement; + if (x <= 1) + x = getImage()->getWidth() - m_xIncrement; + setStartImageArea(x, y); + } + Draw(); +} + +///Sets +void cAnimatedSprite::setXIncrement( const unsigned long int x ) +{ + m_xIncrement = x; +} + +void cAnimatedSprite::setYIncrement( const unsigned long int y ) +{ + m_yIncrement = y; +} + +void cAnimatedSprite::setIncrement( const unsigned long int y, const unsigned long int x ) +{ + m_xIncrement = x; + m_yIncrement = y; +} + +void cAnimatedSprite::setFPS( const unsigned long int fps /*= 16*/ ) +{ + m_fps = fps; + m_RATE = (1000 / m_fps); + m_nextTime = ((unsigned long int)SDL_GetTicks()) + m_RATE; +} + +///Gets +const unsigned long int cAnimatedSprite::getXIncrement() const +{ + return m_xIncrement; +} + +const unsigned long int cAnimatedSprite::getYIncrement() const +{ + return m_yIncrement; +} + +void cAnimatedSprite::getIncrement( unsigned long int& x, unsigned long int& y ) const +{ + x = m_xIncrement; + y = m_yIncrement; +} + +const unsigned long int cAnimatedSprite::getFPS() const +{ + return m_fps; +} + +const unsigned long int cAnimatedSprite::TimeLeft() +{ + unsigned long int now = (unsigned long int)SDL_GetTicks(); + + if(m_nextTime <= now) + { + AddTimeandRate(); + return 0; + } + else + return 1; +} + +void cAnimatedSprite::AddTimeandRate() +{ + m_nextTime += m_RATE; +} + + diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.hpp new file mode 100644 index 0000000..6eca16e --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cAnimatedSprite.hpp @@ -0,0 +1,70 @@ +#ifndef _CANIMATEDSPRITE_HPP_ +#define _CANIMATEDSPRITE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cSprite.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cAnimatedSprite : public cSprite + { + public: + cAnimatedSprite( const unsigned long int x = 0, const unsigned long int y = 0, const unsigned long int fps = 16 ); + /* Copy constructor */ + cAnimatedSprite( const cAnimatedSprite& copy ); + ~cAnimatedSprite(); + + ///Functions + /* Runs down the image */ + void UptoDown(); + /* Runs up the image */ + void DowntoUp(); + /* Runs right of the image */ + void LefttoRight(); + /* Runs Left of the image */ + void RighttoLeft(); + + ///Sets + /* Sets the x increment */ + void setXIncrement( const unsigned long int x ); + /* Sets the y increment */ + void setYIncrement( const unsigned long int y ); + /* Sets the how fare the sprite should move along the image */ + void setIncrement( const unsigned long int x, const unsigned long int y ); + /* Sets the speed of going from one frame to the next */ + void setFPS( const unsigned long int fps = 16 ); + + ///Gets + /* Gets the x increment */ + const unsigned long int getXIncrement() const; + /* Gets the y increment */ + const unsigned long int getYIncrement() const; + /* Gets how fare the sprite should move along the image */ + void getIncrement( unsigned long int& x, unsigned long int& y ) const; + + /* Gets the speed of going from one frame to the next */ + const unsigned long int getFPS() const; + + private: + const unsigned long int TimeLeft(); + void AddTimeandRate(); + + private: + ///Variables + unsigned long int m_xIncrement;// = 0 + unsigned long int m_yIncrement;// = 0 + + unsigned long int m_fps;// = 16 + + unsigned long int m_nextTime;// = 0 + + unsigned long int m_RATE;// = 0 + + };/// END CLASS DEFINITION cAnimatedSprite +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CANIMATEDSPRITE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.cpp new file mode 100644 index 0000000..952421a --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.cpp @@ -0,0 +1,118 @@ +#include "cCamera.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cCamera; +using UtilityEngine::cUtility; + +cCamera::cCamera( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/, + const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ ) +: mp_texture(nullptr) +{ + m_position.x = Sint16(xPos); + m_position.y = Sint16(yPos); + + m_position.w = Uint16(reswidth); + m_position.h = Uint16(reshight); + + CreateCamera(); +} + +cCamera::cCamera( const cCamera& copy ) +{ + m_position.x = Sint16(copy.getXPos()); + m_position.y = Sint16(copy.getYPos()); + + m_position.w = Uint16(copy.getWidthRes()); + m_position.h = Uint16(copy.getHeightRes()); + + setTexture(copy.getTexture()); +} + +cCamera::~cCamera() +{ + DeleteCamera(); +} + +void cCamera::Draw() +{ + cRenderer::Inst().Render(mp_texture, nullptr, &m_position); +} + +void cCamera::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + cRenderer::Inst().SaveTexture(mp_texture, fileName, dir); +} + +///Sets +void cCamera::setXPosandYPos( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/ ) +{ + m_position.x = Sint16(xPos); + m_position.y = Sint16(yPos); + + CreateCamera(); +} + +void cCamera::setResWidthandResHeight( const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ ) +{ + m_position.w = Uint16(reswidth); + m_position.h = Uint16(reshight); + + CreateCamera(); +} + +void cCamera::setTexture( SDL_Texture* texture ) +{ + DeleteCamera(); + CreateCamera(); + + cRenderer::Inst().CopyTexture(texture, mp_texture); +} + +///Gets +const unsigned long int cCamera::getXPos() const +{ + return m_position.x; +} + +const unsigned long int cCamera::getYPos() const +{ + return m_position.y; +} + +const unsigned long int cCamera::getWidthRes() const +{ + return m_position.w; +} + +const unsigned long int cCamera::getHeightRes() const +{ + return m_position.h; +} + +SDL_Texture* cCamera::getCameraView() const +{ + return mp_texture; +} + +SDL_Texture* cCamera::getTexture() const +{ + return mp_texture; +} + +void cCamera::CreateCamera() +{ + DeleteCamera(); + mp_texture = cRenderer::Inst().NewTexture(m_position.w, m_position.h, SDL_TEXTUREACCESS_TARGET); + + if (mp_texture == nullptr) + cUtility::Inst().Message("Unable to create camera.", __AT__); +} + +void cCamera::DeleteCamera() +{ + if (mp_texture != nullptr) + SDL_DestroyTexture(mp_texture); +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.hpp new file mode 100644 index 0000000..252477e --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cCamera.hpp @@ -0,0 +1,71 @@ +#ifndef _CCAMERA_HPP_ +#define _CCAMERA_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cCamera + { + public: + cCamera( const signed long int xPos = 0, const signed long int yPos = 0, + const unsigned long int reswidth = 640, const unsigned long int reshight = 480 ); + /* Copy constructor */ + cCamera( const cCamera& copy ); + ~cCamera(); + + /* Draws the camera on the video buffer */ + void Draw(); + + /* Saves the Camera Image to a BMP file */ + void SaveImage( const cString& fileName, const cString& dir = "" ); + + ///Sets + /* Sets the x and y position on the video buffer */ + void setXPosandYPos( const signed long int xPos = 0, const signed long int yPos = 0 ); + /* Sets the width and height the camera should be */ + void setResWidthandResHeight( const unsigned long int reswidth = 640, const unsigned long int reshight = 480 ); + /* Sets the Surface */ + void setTexture( SDL_Texture* texture ); + + ///Gets + /* Gets the x position of the camera */ + const unsigned long int getXPos() const; + /* Gets the y position of the camera */ + const unsigned long int getYPos() const; + + /* Gets the width of the camera */ + const unsigned long int getWidthRes() const; + /* Gets the height of the camera */ + const unsigned long int getHeightRes() const; + + /* Gets the SDL_Renderer of the camera */ + SDL_Texture* getCameraView() const; + + /* Gets the Surface of the camera */ + SDL_Texture* getTexture() const; + + private: + ///Functions + void CreateCamera(); + void DeleteCamera(); + + private: + ///Variables + SDL_Rect m_position; + + SDL_Texture* mp_texture;// = nullptr + + //std::vector m_sprites; + //LinkList::cLList m_sprites; + };/// END CLASS DEFINITION cCamera +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CCAMERA_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.cpp new file mode 100644 index 0000000..f88e47f --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.cpp @@ -0,0 +1,257 @@ +#include "cImage.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cImage; +using UtilityEngine::cUtility; + +cImage::cImage( const cString& dir /*= ""*/, const cString& filename /*= ""*/, const bool transparent /*= false*/, + const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/, + const unsigned char translevel /*= 255*/) +: mp_texture(nullptr), m_dir(dir), m_fileName(filename), m_transparent(transparent), +m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel) +{ + if (m_fileName != (char*)"") + LoadImage(); + if (mp_texture != nullptr) + TransparentSetup(); +} + +cImage::cImage( SDL_Surface* surface ) +: mp_texture(nullptr), m_dir(""), m_fileName(""), m_transparent(false), +m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255) +{ + setImage(surface); +} + +cImage::cImage( SDL_Texture* texture ) + : mp_texture(nullptr), m_dir(""), m_fileName(""), m_transparent(false), + m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255) +{ + setImage(texture); +} + +cImage::cImage( const cImage& copy, const bool surfaceCopy /*= true*/) +: mp_texture(nullptr), m_dir(copy.getDir()), +m_fileName(copy.getFileName()), m_transparent(copy.getTransparent()), m_transRed(copy.getRedTrans()), +m_transBlue(copy.getBlueTrans()), m_transGreen(copy.getGreenTrans()), m_transLevel(copy.getLevelTrans()) +{ + if (surfaceCopy == true) + mp_texture = copy.getImage(); +} + +cImage::~cImage() +{ + UnloadImage(); +} + +///Functions +void cImage::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + cRenderer::Inst().SaveTexture( mp_texture, fileName, dir ); +} + +const cImage* cImage::NewImage( SDL_Rect& area ) const +{ + cImage* rtn = new cImage(*this, false); + + SDL_Texture* tempTexture = cRenderer::Inst().NewTexture(area.w, area.h, SDL_TEXTUREACCESS_TARGET); + + if (tempTexture != nullptr) { + cRenderer::Inst().RenderToTexture(tempTexture, nullptr, mp_texture, &area); + rtn->setImage(tempTexture); + } else + cUtility::Inst().Message("No texture created.", __AT__); + + + /*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Instance().getVideoSettings(), area.w, area.h, cVideo::Instance().getColour(), + mp_texture->format->Rmask, mp_texture->format->Gmask, mp_texture->format->Bmask, mp_texture->format->Amask); + cVideo::Instance().Render(tempsurface, nullptr, mp_texture, &area); + rtn->setImage(tempsurface);*/ + + return rtn; +} + +///Sets +void cImage::setDir( const cString& dir ) +{ + m_dir = dir; +} + +void cImage::setFileName( const cString& filename ) +{ + m_fileName = filename; + LoadImage(); +} + +void cImage::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ ) +{ + setDir(dir); + setFileName(filename); +} + +void cImage::setTransparent( const bool transparent /*= true*/ ) +{ + m_transparent = transparent; + TransparentSetup(); +} + +void cImage::setColourTrans( const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/ ) +{ + m_transRed = red; + m_transBlue = blue; + m_transGreen = green; + TransparentSetup(); +} + +void cImage::setLevelTrans( const unsigned char translevel /*= 255*/ ) +{ + m_transLevel = translevel; +} + +///Gets +SDL_Surface* cImage::getSurface() const +{ + return cRenderer::Inst().TextureToSurface(mp_texture); +} + +SDL_Texture* cImage::getImage() const +{ + return mp_texture; +} + +const unsigned long int cImage::getWidth() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + return w; +} + +const unsigned long int cImage::getHeight() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + return h; +} + +const SDL_Rect cImage::getWH() const +{ + unsigned long int w = 0; + unsigned long int h = 0; + + getWH(w, h); + SDL_Rect rtn = { 0, 0, (int)w, (int)h}; + return rtn; +} + +void cImage::getWH( unsigned long int& w, unsigned long int& h ) const +{ + int width = 0; + int height = 0; + if (mp_texture != nullptr) + if (SDL_QueryTexture(mp_texture, nullptr, nullptr, &width, &height) < 0) + cUtility::Inst().Message("Unable to get Width or Height. SDL_QueryTexture:", __AT__, cUtility::eTypeSDL::SDL); + w = width; + h = height; +} + +const cString cImage::getDir() const +{ + return m_dir; +} + +const cString cImage::getFileName() const +{ + return m_fileName; +} + +const bool cImage::getTransparent() const +{ + return m_transparent; +} + +void cImage::getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const +{ + red = m_transRed; + blue = m_transBlue; + green = m_transGreen; +} + +const unsigned char cImage::getRedTrans() const +{ + return m_transRed; +} + +const unsigned char cImage::getBlueTrans() const +{ + return m_transBlue; +} + +const unsigned char cImage::getGreenTrans() const +{ + return m_transGreen; +} + +const unsigned char cImage::getLevelTrans() const +{ + return m_transLevel; +} + +//protected: +void cImage::setImage( SDL_Surface* surface ) +{ + UnloadImage(); + + mp_texture = cRenderer::Inst().SurfaceToTexture(surface); + + SDL_FreeSurface(surface); +} + +void cImage::setImage( SDL_Texture* texture ) +{ + UnloadImage(); + mp_texture = texture; +} + +///private +///Functions +void cImage::TransparentSetup() +{ + if( (m_transparent == true) && (mp_texture != nullptr) ) { + if ((SDL_SetTextureColorMod(mp_texture, m_transRed, m_transGreen, m_transBlue) | SDL_SetTextureAlphaMod(mp_texture, m_transLevel)) < 0) + cUtility::Inst().Message("Unable to set Transparent. SDL_SetTextureColorMod:", __AT__, cUtility::eTypeSDL::SDL); + } + //LoadImage(); +} + +void cImage::LoadImage() +{ + UnloadImage(); + + SDL_Texture* tempText = nullptr; + + if (m_fileName != "") + { + cString temp = m_dir + m_fileName; + + if ((tempText = IMG_LoadTexture( cRenderer::Inst().getRenderer(), temp.c_str() )) == nullptr) + cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_LoadTexture():", __AT__, cUtility::eTypeSDL::IMAGE); + } +} + +void cImage::UnloadImage() +{ + if (mp_texture != nullptr) + { + SDL_DestroyTexture(mp_texture); + mp_texture = nullptr; + } +} + + diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp new file mode 100644 index 0000000..837060c --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp @@ -0,0 +1,112 @@ +#ifndef _CIMAGE_HPP_ +#define _CIMAGE_HPP_ + +/*** SDL Header Files ***/ +#include +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cImage + { + public: + cImage( const cString& dir = "", const cString& filename = "", const bool transparent = false, + const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255, + const unsigned char translevel = 255); + cImage( SDL_Surface* surface ); + cImage( SDL_Texture* texture ); + /* Copy constructor */ + cImage( const cImage& copy, const bool surfaceCopy = true ); + ~cImage(); + + /* Saves the Image to a BMP file */ + void SaveImage( const cString& fileName, const cString& dir = "" ); + /* Creates a New Image based on input */ + const cImage* NewImage( SDL_Rect& area ) const; + + ///Sets + /* Sets the Directory of the image */ + void setDir( const cString& dir ); + /* Sets the File Name of the image */ + void setFileName( const cString& filename ); + /* Sets the File Name and the Directory of the image */ + void setFileNameandDir( const cString& filename, const cString& dir = "" ); + + /* Sets Transparent on if set to true */ + void setTransparent( const bool transparent = true ); + /* Sets the colour to be made transparent */ + void setColourTrans( const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255 ); + /* Sets the level of the transparent 255 = clear, 0 = solid */ + void setLevelTrans( const unsigned char translevel = 255 ); + + ///Gets + /* Gets a pointer to the SDL_Surface */ + SDL_Surface* getSurface() const; + /* Gets a pointer to the SDL_Texture */ + SDL_Texture* getImage() const; + /* Gets the width of the image */ + const unsigned long int getWidth() const; + /* Gets the Height of the image */ + const unsigned long int getHeight() const; + /* Gets the Width and Height of the image */ + const SDL_Rect getWH() const; + /* Gets the Width and Height of the image */ + void getWH( unsigned long int& w, unsigned long int& h ) const; + + /* Gets the Directory of the image */ + const cString getDir() const; + /* Gets the File Name of the image */ + const cString getFileName() const; + + /* Gets return true if transparent on false if off */ + const bool getTransparent() const; + /* Gets return the colour to be made transparent */ + void getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const; + /* Gets the transparent red colour */ + const unsigned char getRedTrans() const; + /* Gets the transparent blue colour */ + const unsigned char getBlueTrans() const; + /* Gets the transparent green colour */ + const unsigned char getGreenTrans() const; + /* Gets the transparent level 255 = clear, 0 = solid */ + const unsigned char getLevelTrans() const; + + protected: + /* Protected so only derived class can access. *. + /* Sets the image to surface */ + void setImage( SDL_Surface* surface ); + void setImage( SDL_Texture* texture ); + + private: + ///Functions + void TransparentSetup(); + virtual void LoadImage(); //cFont over rides this + void UnloadImage(); + + private: + ///Variables + SDL_Texture* mp_texture;// = nullptr + + cString m_dir;// = "" + cString m_fileName;// = "" + + //char m_dir[255]; + //char m_fileName[255]; + + bool m_transparent;// = false + + unsigned char m_transRed;// = 0 + unsigned char m_transBlue;// = 0 + unsigned char m_transGreen;// = 255 + + unsigned char m_transLevel;// = 255 + };/// END CLASS DEFINITION cImage +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CIMAGE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp new file mode 100644 index 0000000..56b0832 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp @@ -0,0 +1,274 @@ +#include "cRenderer.hpp" + +/*** Custom Header Files ***/ +#include "cVideo.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cRenderer; +using VideoEngine::cVideo; +using UtilityEngine::cUtility; + +/*static*/ cRenderer* cRenderer::sp_inst = nullptr; + +//private: +cRenderer::cRenderer() +{ + Setup(); +} + +cRenderer::~cRenderer() +{ + CleanUp(); +} + +//public: +///Functions +/*static*/ cRenderer& cRenderer::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cRenderer(); + return *sp_inst; +} + +/*static*/ void cRenderer::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cRenderer::Setup() +{ + bool rtn = false; + if (cVideo::Inst().IsInit() == false) + cUtility::Inst().Message("Unable to setup until SDL_Video is initialized."); + else { + mp_renderer = cVideo::Inst().CreateRender(); + if (mp_renderer != nullptr) + rtn = true; + } + return rtn; +} + +void cRenderer::CleanUp() +{ + SDL_DestroyRenderer(mp_renderer); + mp_renderer = nullptr; +} + +void cRenderer::Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + cRenderer::Render(texture, srcrect, mp_renderer, dstrect); +} + +void cRenderer::Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ) +{ + SDL_Texture* texture = SurfaceToTexture(surface); + Render( texture, srcrect, dstrect ); + SDL_DestroyTexture(texture); +} + +void cRenderer::Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + if (SDL_BlitSurface(src, srcrect, dst, dstrect) < 0) + cUtility::Inst().Message("Unable to BlitSurface. SDL_BlitSurface():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ) +{ + src; + srcrect; + dst; + dstrect; + //??????? +} + +void cRenderer::Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ) +{ + if (SDL_RenderCopy(dst, src, srcrect, dstrect) < 0) + cUtility::Inst().Message("Unable to copy Texture to Renderer. SDL_RenderCopy():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ) +{ + SetRenderTarget(dst); + Render( src, srcrect, dstrect ); + ResetRenderTarget(); +} + +void cRenderer::RenderDrawColor( const SDL_Colour& colour ) +{ + if (SDL_SetRenderDrawColor(mp_renderer, colour.r, colour.g, colour.b, colour.a) < 0) + cUtility::Inst().Message("Unable to set render draw colour. SDL_SetRenderDrawColor():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst /*= nullptr */ ) +{ + SetRenderTarget(dst); + if (SDL_RenderFillRect(mp_renderer, &rect) < 0) + cUtility::Inst().Message("Unable to draw rectangle. SDL_RenderFillRect():", __AT__, cUtility::eTypeSDL::SDL); + ResetRenderTarget(); +} + +void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/ ) +{ + SDL_Surface* infoSurface = SDL_GetWindowSurface(VideoEngine::cVideo::Inst().getWindow()); + SDL_Surface* saveSurface = NewSurface(); + + if (infoSurface == NULL) { + cUtility::Inst().Message("Failed to create info surface from window.\n", __AT__, cUtility::eTypeSDL::SDL); + } else { + if (SDL_RenderReadPixels(mp_renderer, &infoSurface->clip_rect, infoSurface->format->format, saveSurface->pixels, infoSurface->w * infoSurface->format->BytesPerPixel) != 0) + cUtility::Inst().Message("Failed to read pixel data from SDL_Renderer object.\n", __AT__, cUtility::eTypeSDL::SDL); + else + SaveSurface(saveSurface, filename, dir); + SDL_FreeSurface(infoSurface); + infoSurface = NULL; + } + SDL_FreeSurface(saveSurface); + saveSurface = NULL; +} + + +void cRenderer::SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir /*= ""*/ ) +{ + cString temp = dir + fileName; + if (SDL_SaveBMP(surface, temp.c_str()) < 0) + cUtility::Inst().Message("Unable to save Surface. SDL_SaveBMP()", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir /*= ""*/ ) +{ + SDL_Surface* surface = TextureToSurface(texture); + + if (surface != nullptr) + SaveSurface(surface, fileName, dir); + else + cUtility::Inst().Message("Unable to create Surface from Texture. TextureToSurface():", __AT__); + + SDL_FreeSurface(surface); +} + +SDL_Texture* cRenderer::SurfaceToTexture( SDL_Surface* surface ) +{ + SDL_Texture* rtn = nullptr; + rtn = SDL_CreateTextureFromSurface( mp_renderer, surface ); + if ( rtn == nullptr) + cUtility::Inst().Message("Unable to create Texture. SDL_CreateTextureFromSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture ) +{ + SDL_Surface* rtn = nullptr; + + int w = 0; + int h = 0; + + if (SDL_QueryTexture(texture, nullptr, nullptr, &w, &h) < 0) + cUtility::Inst().Message("Unable to Query Texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + rtn = NewSurface(w, h); + + void* srcPixels = nullptr; + int srcPitch = 0; + + //Lock texture for manipulation + if (SDL_LockTexture( texture, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockSurface(rtn)) + cUtility::Inst().Message("Unable to lock surface rtn. SDL_LockSurface():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( rtn->pixels, srcPixels, srcPitch * h ); + + //Unlock texture to update + SDL_UnlockSurface(rtn); + SDL_UnlockTexture( texture ); + + srcPixels = nullptr; + + return rtn; +} + +void cRenderer::CopyTexture( SDL_Texture* src, SDL_Texture* dst ) +{ + void* srcPixels = nullptr; + int srcPitch = 0; + + void* dstPixels = nullptr; + int dstPitch = 0; + + int height = 0; + + if (SDL_QueryTexture( src, nullptr, nullptr, nullptr, &height ) < 0) + cUtility::Inst().Message("Unable to query texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Lock texture for manipulation + if (SDL_LockTexture( src, nullptr, &srcPixels, &srcPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture src. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + if (SDL_LockTexture( dst, nullptr, &dstPixels, &dstPitch ) < 0) + cUtility::Inst().Message("Unable to lock texture dst. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL); + + //Copy loaded/formatted surface pixels + memcpy( dstPixels, srcPixels, srcPitch * height ); + + //Unlock texture to update + SDL_UnlockTexture( dst ); + SDL_UnlockTexture( src ); + srcPixels = nullptr; + dstPixels = nullptr; + +} + +SDL_Surface* cRenderer::CopySurface( SDL_Surface* src ) +{ + return SDL_ConvertSurface( src, src->format, src->flags ); +} + +SDL_Surface* cRenderer::NewSurface( long int width /*= -1*/, long int height /*= -1*/ ) const +{ + if (width < 0) + width = cVideo::Inst().getWidth(); + if (height < 0) + height = cVideo::Inst().getHeight(); + + SDL_Surface* rtn = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), width, height, cVideo::Inst().getColour(), cVideo::Inst().getRmask(), cVideo::Inst().getGmask(), cVideo::Inst().getBmask(), cVideo::Inst().getAmask()); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create surface. SDL_CreateRGBSurface():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + +SDL_Texture* cRenderer::NewTexture( long int width, long int height, const unsigned long int access /*= SDL_TEXTUREACCESS_TARGET*/ ) const +{ + if (width < 0) + width = cVideo::Inst().getWidth(); + if (height < 0) + height = cVideo::Inst().getHeight(); + + SDL_Texture* rtn = SDL_CreateTexture(mp_renderer, SDL_PIXELFORMAT_ABGR8888, access, width, height); + if (rtn == nullptr) + cUtility::Inst().Message("Unable to create texture. SDL_CreateTexture:", __AT__, cUtility::eTypeSDL::SDL); + return rtn; +} + +void cRenderer::SetRenderTarget( SDL_Texture* target /*= nullptr*/ ) +{ + if (SDL_SetRenderTarget(mp_renderer, target) < 0) + cUtility::Inst().Message("Unable to set render target to dst. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +void cRenderer::ResetRenderTarget() +{ + if (SDL_SetRenderTarget(mp_renderer, nullptr) < 0) + cUtility::Inst().Message("Unable to set render target to mp_rend. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL); +} + +SDL_Renderer* cRenderer::getRenderer() +{ + return mp_renderer; +} diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp new file mode 100644 index 0000000..31f1ca7 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp @@ -0,0 +1,71 @@ +#ifndef _CRENDERER_HPP_ +#define _CRENDERER_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cRenderer + { + private: + cRenderer(); + ~cRenderer(); + + public: + static cRenderer& Inst(); + static void Delete(); + + /* Creates the Renderer */ + const bool Setup(); + /* Uses */ + void CleanUp(); + + void Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect ); + void Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect ); + void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect ); + + void RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect ); + + void RenderDrawColor( const SDL_Colour& colour ); + void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr ); + + void ScreenShot(const cString& filename, const cString& dir = ""); + void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" ); + void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" ); + + SDL_Texture* SurfaceToTexture( SDL_Surface* surface ); + SDL_Surface* TextureToSurface( SDL_Texture* texture ); + + void CopyTexture( SDL_Texture* src, SDL_Texture* dst ); + + SDL_Surface* CopySurface( SDL_Surface* src ); + + SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) const; + SDL_Texture* NewTexture( long int width = -1, long int height = -1, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const; + + void SetRenderTarget( SDL_Texture* target = nullptr ); + void ResetRenderTarget(); + + ///Sets + + ///Gets + SDL_Renderer* getRenderer(); + + private: + SDL_Renderer* mp_renderer; + + static cRenderer* sp_inst;// = nullptr + };/// END CLASS DEFINITION cRenderer +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CRENDERER_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp new file mode 100644 index 0000000..5ed76bd --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp @@ -0,0 +1,277 @@ +#include "cSprite.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" + +using VideoEngine::cSprite; +using MathEngine::iVector2; +using MathEngine::iVector4; + +cSprite::cSprite( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/, + const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/, + VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ ) +: mpp_image(image), mpp_camera(camera) +{ + setPosition(Sint16(xpos), Sint16(ypos)); + + setStartImageArea(Sint16(xarea), Sint16(yarea)); + setEndImageArea(Uint16(warea), Uint16(harea)); +} + +cSprite::cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera /*= nullptr*/ ) +: mpp_image(image), mpp_camera(camera) +{ + setPosition(0, 0); + + setStartImageArea(0, 0); + setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight())); +} + +//cSprite::cSprite( TextTypeEngine::cText** image, VideoEngine::cCamera** camera /*= nullptr*/ ) +/*: mpp_camera(camera) +{ + image; + //VideoEngine::cImage* im = VideoEngine::cImage(*image); + setPosition(0, 0); + + setStartImageArea(0, 0); + setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight())); +}*/ + +cSprite& cSprite::operator=( const cSprite& copy ) +{ + if (this != ©) + { + mpp_image = nullptr; + mpp_camera = nullptr; + + signed long int x = 0; + signed long int y = 0; + + unsigned long int h = 0; + unsigned long int w = 0; + + copy.getPosition(x, y); + setPosition(x, y); + + copy.getStartImageArea(x, y); + copy.getEndImageArea(w, h); + + setStartImageArea(x, y); + setEndImageArea(w, h); + + *mpp_image = copy.getImage(); + *mpp_camera = copy.getCamera(); + } + + return *this; +} + +cSprite::~cSprite() +{ + mpp_image = nullptr; + mpp_camera = nullptr; +} + +///Functions +void cSprite::Draw() +{ + SDL_Texture* texture = (*mpp_image)->getImage(); + + if (mpp_camera != nullptr && *mpp_camera != nullptr) { + CameraDraw(); + //surface = (*mpp_camera)->getCameraView(); + } + + if (mpp_image != nullptr && *mpp_image != nullptr) + cRenderer::Inst().Render( texture, &m_imageArea, &m_position); +} + +void cSprite::CameraDraw() +{ + if ((mpp_image != nullptr) && (mpp_camera != nullptr) && (*mpp_image != nullptr) && (*mpp_camera != nullptr)) + cRenderer::Inst().RenderToTexture((*mpp_image)->getImage(), &m_imageArea, (*mpp_camera)->getCameraView(), &m_position); + //RendererDraw( (*mpp_camera)->getCameraView() ); +} +// +// void cSprite::RendererDraw( SDL_Renderer* rend ) +// { +// cVideo::Instance().RenderToTexture() +// if ((rend != nullptr) && (mpp_image != nullptr) && (*mpp_image != nullptr)) +// Video::Instance().Render((*mpp_image)->getImage(), &m_imageArea, rend, &m_position); +// } + +void cSprite::DefaltDraw() +{ + if (mpp_image != nullptr && *mpp_image != nullptr) + cRenderer::Inst().Render( (*mpp_image)->getImage(), nullptr, nullptr); +} + +void cSprite::AddPosX( const signed long int x ) +{ + m_position.x += Sint16(x); +} + +void cSprite::AddPosY( const signed long int y ) +{ + m_position.y += Sint16(y); +} + +void cSprite::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) +{ + if (mpp_image != nullptr && *mpp_image != nullptr) { + SDL_Texture* temp = (*mpp_image)->getImage();//(*mpp_image)->NewImage(this->getImageArea())->getImage(); + + cRenderer::Inst().SaveTexture( temp, fileName, dir ); + } +} + +///Sets +void cSprite::setPosX( const signed long int x ) +{ + setPosition( x, getPosY()); +} + +void cSprite::setPosY( const signed long int y ) +{ + setPosition( getPosX(), y ); +} + +void cSprite::setPosition( const signed long int x, const signed long int y ) +{ + m_position.x = (signed short int)x; + m_position.y = (signed short int)y; + setPositionEnd(); +} + +void cSprite::setPosition( const MathEngine::iVector2& position /*= MathEngine::iVector2(0,0)*/ ) +{ + setPosition(position.x, position.y); +} + +void cSprite::setImageArea( const MathEngine::iVector4& area /*= MathEngine::iVector4(0,0,0,0)*/) +{ + if (area == iVector4(0,0,0,0)) { + setStartImageArea(0,0); + if ((mpp_image != nullptr) && (*mpp_image != nullptr)) + setEndImageArea((*mpp_image)->getWidth(), (*mpp_image)->getHeight()); + } else { + setStartImageArea( area.x, area.y ); + setEndImageArea( area.z, area.w ); + } +} + +/// Top left starting area. +void cSprite::setStartImageArea( const signed long int x, const signed long int y ) +{ + m_imageArea.x = (signed short int)x; + m_imageArea.y = (signed short int)y; +} + +/// Bottom right image ends. +void cSprite::setEndImageArea( const unsigned long int w, const unsigned long int h ) +{ + m_imageArea.w = (unsigned short int)w; + m_imageArea.h = (unsigned short int)h; + + setPositionEnd(); +} + +void cSprite::setImage( VideoEngine::cImage** image ) +{ + mpp_image = image; +} + +void cSprite::setCamera( VideoEngine::cCamera** camera ) +{ + mpp_camera = camera; +} + +///Get's +const signed long int cSprite::getPosX() const +{ + return m_position.x; +} + +const signed long int cSprite::getPosY() const +{ + return m_position.y; +} + +void cSprite::getPosition( signed long int& x, signed long int& y ) const +{ + x = m_position.x; + y = m_position.y; +} + +const MathEngine::iVector4 cSprite::getPosition() const +{ + return iVector4(m_position); +} + +void cSprite::getStartImageArea( signed long int& x, signed long int& y ) const +{ + x = m_imageArea.x; + y = m_imageArea.y; +} + +void cSprite::getEndImageArea( unsigned long int& w, unsigned long int& h ) const +{ + w = m_imageArea.w; + h = m_imageArea.h; +} + +const SDL_Rect& cSprite::getImageArea() const +{ + return m_imageArea; +} + +const unsigned long int cSprite::getWidth() const +{ + return m_imageArea.w; +} + +const unsigned long int cSprite::getHeight() const +{ + return m_imageArea.h; +} + +VideoEngine::cImage* cSprite::getImage() const +{ + if (mpp_image == nullptr) + return nullptr; + else + return (*mpp_image); +} + +VideoEngine::cCamera* cSprite::getCamera() const +{ + if (mpp_camera == nullptr) + return nullptr; + else + return (*mpp_camera); +} + +const bool cSprite::getImageSetup() const +{ + bool rtn = false; + if ((mpp_image != nullptr) && (*mpp_image != nullptr)) + rtn = true; + + return rtn; +} + +const bool cSprite::getCameraSetup() const +{ + bool rtn = false; + if ((mpp_camera != nullptr) && (*mpp_camera != nullptr)) + rtn = true; + + return rtn; +} + +void cSprite::setPositionEnd() +{ + m_position.w = m_imageArea.w; + m_position.h = m_imageArea.h; +} \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp new file mode 100644 index 0000000..3543bd2 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp @@ -0,0 +1,116 @@ +#ifndef _CSPRITE_HPP_ +#define _CSPRITE_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** Custom Header Files ***/ +#include "cImage.hpp" +#include "cCamera.hpp" + +#include "../TextTypeEngine/cText.hpp" +#include "../MathEngine/iVector/iVector2.hpp" +#include "../MathEngine/iVector/iVector4.hpp" + +#include "../UtilityEngine/cString.hpp" + +/*** DLL Header File ***/ +#include "dllExport.h" + +using UtilityEngine::cString; + +namespace VideoEngine { + class EXPORT_FROM_MYDLL cSprite + { + public: + cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera = nullptr ); + cSprite( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0, + const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0, + VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr ); + + cSprite& operator=( const cSprite& copy ); + ~cSprite(); + + ///Functions + /* Draws the sprite to the video buffer */ + void Draw(); + /* Draws the sprite to the camera */ + void CameraDraw(); + /* Draws the sprite to a SDL_Renderer */ + /*void RendererDraw( SDL_Renderer* rend );*/ + /* Draws the sprite to the video buffer with out positioning it */ + void DefaltDraw(); + + void AddPosX( const signed long int x ); + void AddPosY( const signed long int y ); + + void SaveImage( const cString& fileName, const cString& dir = "" ); + + ///Sets + /* Sets the X position of the sprite on the surface, camera or video buffer */ + void setPosX( const signed long int x ); + /* Sets the Y position of the sprite on the surface, camera or video buffer */ + void setPosY( const signed long int y ); + /* Sets the position of the sprite on the surface, camera or video buffer */ + void setPosition( const signed long int x, const signed long int y ); + /* Sets the position of the sprite on the surface, camera or video buffer */ + void setPosition( const MathEngine::iVector2& position = MathEngine::iVector2(0,0) ); + + /* Sets the start and end of the image area */ + void setImageArea( const MathEngine::iVector4& area = MathEngine::iVector4(0,0,0,0) ); + /* Sets the top left of the area to take from the image */ + void setStartImageArea( const signed long int x, const signed long int y ); /// Top left starting area. + /* Sets the bottom right of the area to take from the image */ + void setEndImageArea( const unsigned long int w, const unsigned long int h ); /// Bottom right image ends. + + /* Sets the pointer to a pointer for the image that the sprite will use */ + void setImage( VideoEngine::cImage** image ); + /* Sets the pointer to a pointer for the camera the sprite will be draw on */ + void setCamera( VideoEngine::cCamera** camera ); + + ///Gets + /* Gets the X position of the sprite on the surface, camera or video buffer */ + const signed long int getPosX() const; + /* Gets the Y position of the sprite on the surface, camera of video buffer */ + const signed long int getPosY() const; + /* Gets the position of the sprite on the surface, camera or video buffer */ + void getPosition( signed long int& x, signed long int& y ) const; + /* Gets the position of the sprite on the surface, camera or video buffer */ + const MathEngine::iVector4 getPosition() const; + + /* Gets the top left of the area to take from the image */ + void getStartImageArea( signed long int& x, signed long int& y ) const; + /* Gets the bottom right of the area to take from the image */ + void getEndImageArea( unsigned long int& w, unsigned long int& h ) const; + /* Gets the area of the image */ + const SDL_Rect& getImageArea() const; + + /* Gets the width of the sprite */ + const unsigned long int getWidth() const; + /* Gets the height of the sprite */ + const unsigned long int getHeight() const; + + /* Gets a pointer to the image used by the sprite */ + VideoEngine::cImage* getImage() const; + /* Gets a pointer to the camera used by the sprite */ + VideoEngine::cCamera* getCamera() const; + + /* Gets returns true if image pointer is not null other wise returns false */ + const bool getImageSetup() const; + /* Gets returns true if camera pointer is not null other wise returns false */ + const bool getCameraSetup() const; + + private: + void setPositionEnd(); + + private: + ///Variables + SDL_Rect m_position; /// Were the Sprite will be position on the screen (Upper Left) + + SDL_Rect m_imageArea; /// What part of the image to take + + VideoEngine::cImage** mpp_image;// = nullptr + VideoEngine::cCamera** mpp_camera;// = nullptr + };/// END CLASS DEFINITION cSprite +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CSPRITE_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.cpp new file mode 100644 index 0000000..1a21d06 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.cpp @@ -0,0 +1,269 @@ +#include "cVideo.hpp" + +/*** Custom Header Files ***/ +#include "cRenderer.hpp" +#include "../UtilityEngine/cUtility.hpp" + +using VideoEngine::cVideo; +using VideoEngine::cRenderer; +using UtilityEngine::cUtility; + +/*static*/ cVideo* cVideo::sp_inst = nullptr; + +cVideo::cVideo() +: m_xPos(100), m_yPos(100), m_width(640), m_height(480), m_colour(32), + m_hardwareVideo(false), m_fullscreen(false), m_vsync(false), + m_videoSettings(SDL_RENDERER_SOFTWARE), mp_window(nullptr), +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + m_rmask(0xff000000), + m_gmask(0x00ff0000), + m_bmask(0x0000ff00), + m_amask(0x000000ff) +#else + m_rmask(0x000000ff), + m_gmask(0x0000ff00), + m_bmask(0x00ff0000), + m_amask(0xff000000) +#endif +{} + +cVideo::~cVideo() +{ + CleanUp(); +} + +///Functions +/*static*/ cVideo& cVideo::Inst() +{ + if (sp_inst == nullptr) + sp_inst = new cVideo(); + return *sp_inst; +} + +/*static*/ void cVideo::Delete() +{ + delete sp_inst; + sp_inst = nullptr; +} + +const bool cVideo::Initialize() const +{ + bool rtn = IsInit(); + + if (rtn == false) { + if(SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) { + cUtility::Inst().Message("Video Initialized."); + rtn = true; + } else + cUtility::Inst().Message("Could not initialize Video. SDL_InitSubSystem():", __AT__, cUtility::eTypeSDL::SDL); + } + + return rtn; +} + +const bool cVideo::Setup() +{ + bool rtn = false; + CleanUp(); + VideoSettings(); + + mp_window = SDL_CreateWindow("Hello World!", 100, 100, m_width, m_height, SDL_WINDOW_SHOWN); + if (mp_window == nullptr) + cUtility::Inst().Message("Unable to set Window. SDL_CreateWindow():", __AT__, cUtility::eTypeSDL::SDL); + else + rtn = true; + return rtn; +} + +void cVideo::CleanUp() +{ + SDL_DestroyWindow(mp_window); + mp_window = nullptr; +} + +void cVideo::Display() +{ + SDL_RenderPresent(cRenderer::Inst().getRenderer()); +} + +void cVideo::ScreenShot( const cString& filename, const cString& dir /*= ""*/ ) +{ + VideoEngine::cRenderer::Inst().ScreenShot(filename, dir); +} + +SDL_Renderer* cVideo::CreateRender() +{ + SDL_Renderer* rtn = nullptr; + if (mp_window != nullptr) + rtn = SDL_CreateRenderer(mp_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE); + + if (rtn == nullptr) + cUtility::Inst().Message("Unable to set Renderer. SDL_CreateRenderer():", __AT__, cUtility::eTypeSDL::SDL); + + return rtn; +} + + +void cVideo::VideoSettings() +{ + m_videoSettings = 0; + + if (m_hardwareVideo == true) + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_ACCELERATED); + if (m_vsync == true) + m_videoSettings = (m_videoSettings | SDL_RENDERER_PRESENTVSYNC); + } + else + { + m_videoSettings = (m_videoSettings | SDL_RENDERER_SOFTWARE); + m_vsync = false; + } + + if (m_fullscreen == true) + m_videoSettings = (m_videoSettings | SDL_WINDOW_FULLSCREEN); +} + +///Set's +void cVideo::setWidth( const unsigned long int width /*= 640*/ ) +{ + m_width = width; +} + +void cVideo::setHeight( const unsigned long int height /*= 480*/ ) +{ + m_height = height; +} + +void cVideo::setColour( const unsigned long int colour /*= 32*/ ) +{ + m_colour = colour; +} + +void cVideo::setCaption( const cString& caption /*= ""*/ ) +{ + if (mp_window != nullptr) + SDL_SetWindowTitle(mp_window, caption.c_str()); + else + cUtility::Inst().Message("No window to set caption to."); +} + +void cVideo::setHardwareVideo( const bool hardware /*= false*/ ) +{ + m_hardwareVideo = hardware; + VideoSettings(); +} + +void cVideo::setFullScreen( const bool fullscreen /*= false*/ ) +{ + m_fullscreen = fullscreen; + VideoSettings(); +} + +void cVideo::setVSync( const bool vsync /*= false*/ ) +{ + m_vsync = vsync; + VideoSettings(); +} + +void cVideo::setDisplayMode( const SDL_DisplayMode& mode ) +{ + if (SDL_SetWindowDisplayMode(mp_window, &mode) < 0) + cUtility::Inst().Message("Unable to set display mode. SDL_SetWindowDisplayMode()", __AT__, cUtility::eTypeSDL::SDL); +} + +///Gets +const bool cVideo::IsInit() const +{ + bool rtn = false; + + if (SDL_WasInit(SDL_INIT_VIDEO) != 0) { + cUtility::Inst().Message("Video is initialized."); + rtn = true; + } else + cUtility::Inst().Message("Video is not initialized."); + + return rtn; +} + +const unsigned long int cVideo::getWidth() const +{ + return m_width; +} + +const unsigned long int cVideo::getHeight() const +{ + return m_height; +} + +const unsigned long int cVideo::getColour() const +{ + return m_colour; +} + +const cString cVideo::getCaption() const +{ + cString rtn = ""; + + if (mp_window != nullptr) + rtn = SDL_GetWindowTitle(mp_window); + else + cUtility::Inst().Message("No window to get caption from."); + + return rtn; +} + +const bool cVideo::getHardwareVideo() const +{ + return m_hardwareVideo; +} + +const bool cVideo::getFullScreen() const +{ + return m_fullscreen; +} + +const bool cVideo::getVSync() const +{ + return m_vsync; +} + +const unsigned long int cVideo::getVideoSettings() const +{ + return m_videoSettings; +} + +SDL_Window* cVideo::getWindow() +{ + return mp_window; +} + +SDL_DisplayMode cVideo::getDisplayMode() const +{ + SDL_DisplayMode display; + + if (SDL_GetWindowDisplayMode(mp_window, &display) < 0 ) + cUtility::Inst().Message("Could not get display mode. SDL_GetWindowDisplayMode():", __AT__, cUtility::eTypeSDL::SDL); + + return display; +} + +const unsigned long int cVideo::getRmask() const +{ + return m_rmask; +} + +const unsigned long int cVideo::getGmask() const +{ + return m_gmask; +} + +const unsigned long int cVideo::getBmask() const +{ + return m_bmask; +} + +const unsigned long int cVideo::getAmask() const +{ + return m_amask; +} diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp new file mode 100644 index 0000000..cadbcf4 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp @@ -0,0 +1,138 @@ +#ifndef _CVIDEO_HPP_ +#define _CVIDEO_HPP_ + +/*** SDL Header Files ***/ +#include + +/*** DLL Header File ***/ +#include "dllExport.h" + +/*** Custom Header Files ***/ +#include "../UtilityEngine/cString.hpp" +#include "../MathEngine/iVector/iVector2.hpp" + +using UtilityEngine::cString; + +namespace VideoEngine { + /* Singleton */ + class EXPORT_FROM_MYDLL cVideo + { + private: + cVideo(); + ~cVideo(); + + public: + ///Functions + static cVideo& Inst(); + static void Delete(); + + const bool Initialize() const; + + /* Creates the cVideo's mp_buff and mp_screen surfaces */ + const bool Setup(); + /* Uses SDL_Freesurface to delete cVideo's mp_buff and mp_screen surfaces */ + void CleanUp(); + + /* Used to Display the new frame */ + void Display(); + + /* ScreenShot */ + void ScreenShot( const cString& filename, const cString& dir = "" ); + + SDL_Renderer* CreateRender(); + + ///Sets + /* Sets the videos width resolution */ + void setWidth( const unsigned long int width = 640 ); + /* Sets the videos height resolution */ + void setHeight( const unsigned long int height = 480 ); + /* Sets the videos colour depth in bits */ + void setColour( const unsigned long int colour = 32 ); + /* Sets the caption on the displayed window */ + void setCaption( const cString& caption = "" ); + + /* Sets video to use hardware surfaces if true other wise software surfaces are used */ + void setHardwareVideo( const bool hardware = false ); + /* Sets the video to full screen if true other wise a window is used */ + void setFullScreen( const bool fullscreen = false ); + /* Sets the video to use double buffering other wise no buffering is used */ + void setVSync( const bool vsync = false ); + + void setDisplayMode( const SDL_DisplayMode& mode ); + + ///Gets + /* Gets return true if video was initialized */ + const bool IsInit() const; + /* Gets the videos width resolution */ + const unsigned long int getWidth() const; + /* Gets the videos height resolution */ + const unsigned long int getHeight() const; + /* Gets the videos colour depth in bits */ + const unsigned long int getColour() const; + /* Gets the caption displayed on the window */ + const cString getCaption() const; + + /* Gets returns true if hardware surfaces are being used other wise false is return */ + const bool getHardwareVideo() const; + /* Gets returns true if full screen is being used other wise false is return */ + const bool getFullScreen() const; + /* Gets returns true if Double Buffering is being used other wise false is return */ + const bool getVSync() const; + + /* Gets returns the SDL video flags */ + const unsigned long int getVideoSettings() const; + + /* Gets returns the SDL_Window pointer */ + SDL_Window* getWindow(); + + /* Gets returns the Display Mode */ + SDL_DisplayMode getDisplayMode() const; + + /* Gets returns the Red mask value */ + const unsigned long int getRmask() const; + /* Gets returns the Green mask value */ + const unsigned long int getGmask() const; + /* Gets returns the Blue mask value */ + const unsigned long int getBmask() const; + /* Gets returns the Alpha mask value */ + const unsigned long int getAmask() const; + + private: + ///Functions + void VideoSettings(); + + private: + ///Variables + SDL_Window* mp_window;// = nullptr + //SDL_Renderer* mp_rend;// = nullptr + + unsigned long int m_xPos;// = 100 + unsigned long int m_yPos;// = 100 + unsigned long int m_width;// = 640 + unsigned long int m_height;// = 480 + unsigned long int m_colour;// = 32 + + bool m_hardwareVideo;// = false + bool m_fullscreen;// = false + bool m_vsync;// = false + + unsigned long int m_videoSettings;// = SDL_RENDERER_SOFTWARE + + static cVideo* sp_inst;// = nullptr + + /*SDL interprets each pixel as a 32-bit number, so our masks must depend + on the endianness (byte order) of the machine */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + const unsigned long int m_rmask;// = 0xff000000; + const unsigned long int m_gmask;// = 0x00ff0000; + const unsigned long int m_bmask;// = 0x0000ff00; + const unsigned long int m_amask;// = 0x000000ff; +#else + const unsigned long int m_rmask;// = 0x000000ff; + const unsigned long int m_gmask;// = 0x0000ff00; + const unsigned long int m_bmask;// = 0x00ff0000; + const unsigned long int m_amask;// = 0xff000000; +#endif + };/// END CLASS DEFINITION cVideo +}/// END NAMESPACE DEFINITION VideoEngine +#endif/// END IFNDEF _CVIDEO_HPP_ diff --git a/TrooperEngineDLL/TrooperEngineDLL.vcxproj b/TrooperEngineDLL/TrooperEngineDLL.vcxproj new file mode 100644 index 0000000..a5dd701 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngineDLL.vcxproj @@ -0,0 +1,226 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + UTest + Win32 + + + + {B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8} + TrooperEngineDLL + 10.0.15063.0 + + + + DynamicLibrary + MultiByte + true + v141 + + + StaticLibrary + MultiByte + false + v141 + + + v141 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + /MP %(AdditionalOptions) + Disabled + $(TINYXML);$(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreadedDebugDLL + Level4 + false + EditAndContinue + true + NotUsing + %(PreprocessorDefinitions) + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + ../Debug;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.11\lib;$(SDL)\SDL_image-1.2.10\lib;$(SDL)\SDL-1.2.14\lib;%(AdditionalLibraryDirectories) + true + NotSet + false + + + + + MachineX86 + + + + + Full + ../LinkListDLLProject/dllExportFiles;dllExportFiles;$(SDL)\SDL_ttf-2.0.9\include;$(SDL)\SDL_mixer-1.2.8\include;$(SDL)\SDL_image-1.2.7\include;$(SDL)\SDL-1.2.13\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level4 + true + ProgramDatabase + true + + + sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;LinkList.lib;%(AdditionalDependencies) + $(OutDir)TrooperEngine.dll + ../Release;$(SDL)\SDL_ttf-2.0.9\lib;$(SDL)\SDL_mixer-1.2.8\lib;$(SDL)\SDL_image-1.2.7\lib;$(SDL)\SDL-1.2.13\lib;%(AdditionalLibraryDirectories) + false + true + true + false + + + MachineX86 + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters b/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters new file mode 100644 index 0000000..d5f9026 --- /dev/null +++ b/TrooperEngineDLL/TrooperEngineDLL.vcxproj.filters @@ -0,0 +1,363 @@ + + + + + {785f0a83-5f26-4f52-8607-42d79ef7e4a0} + + + {ce87c954-26c7-497c-a5c1-ca307fa85446} + + + {9447735f-408f-4a4c-896b-3cb056516952} + + + {78ca6e8e-15cd-4c35-a4c7-f718c6f2e517} + + + {a48949b4-948d-4bdb-a48d-a2bb08c05f43} + + + {fb99b84e-7997-4ebd-b3ea-dd0240ce62f6} + + + {98b7ca98-2ed4-4a41-84f2-abcb3fb384aa} + + + {aef9e043-2065-4d89-acae-33d6f5f55958} + + + {59e0e88b-7be3-4b1d-b3ac-6477daa761c8} + + + {4aa00373-6815-4cd3-a1c7-470f34bfa3d9} + + + {74c65105-2ee7-4bb9-8d44-ca75c80e8b9e} + + + {5a07ee53-1695-400c-86b3-c493e8e34417} + + + {839730ba-b9b8-40bc-a0e0-bcb2b16b83f7} + + + {2b72b3ea-71a4-4c02-988e-603172b3eda3} + + + {4a09c4e8-7d59-490d-8049-7a52f0aed3c8} + + + {6d0af3ff-4b2b-4b9c-85a2-c7db41550092} + + + {db4ff7f3-2b38-4f9d-9a92-aed4cb51f0ac} + + + {f6fc613b-8e1a-4df1-aee7-f37382d38981} + + + + + dllExportFiles + + + dllExportFiles + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + dllExportFiles + + + TrooperEngine\MathEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\EventEngine + + + TrooperEngine\EventEngine + + + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\AudioEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TimingEngine + + + TrooperEngine\NetworkEngine + + + TrooperEngine\TrooperEngineCore + + + TrooperEngine\MathEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\InputEngine + + + TrooperEngine\MathEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\iVector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\MathEngine\Vector + + + TrooperEngine\UtilityEngine + + + TrooperEngine\FXEngine + + + TrooperEngine\VideoEngine + + + TrooperEngine\TextTypeEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\UtilityEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\UtilityEngine\MSUNIX + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine + + + TrooperEngine\GUIEngine\GUIHelpers + + + TrooperEngine\GUIEngine + + + TrooperEngine\EventEngine + + + TrooperEngine\EventEngine + + + \ No newline at end of file diff --git a/TrooperEngineDLL/dllExportFiles/CompileSettings.h b/TrooperEngineDLL/dllExportFiles/CompileSettings.h new file mode 100644 index 0000000..8e5fa2f --- /dev/null +++ b/TrooperEngineDLL/dllExportFiles/CompileSettings.h @@ -0,0 +1,7 @@ +#ifndef _COMPILESETTINGS_H_ +#define _COMPILESETTINGS_H_ + +#define _STATIC_LIB_ 1 +#define _DEBUG_ 0 + +#endif/// END IFNDEF _COMPILESETTINGS_H_ \ No newline at end of file diff --git a/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp b/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp new file mode 100644 index 0000000..deafaa4 --- /dev/null +++ b/TrooperEngineDLL/dllExportFiles/TrooperEngine.hpp @@ -0,0 +1,84 @@ +#ifndef _TROOPERENGINE_HPP_ +#define _TROOPERENGINE_HPP_ + +#define _MYDLL_ + +#include "dllExport.h" + +/*** SDL Header Files ***/ +#include + +/*** TropperEngineCore Folder ***/ +#include "../TrooperEngine/TrooperEngineCore/cTrooperEngineCore.hpp" + +/*** VideoEngine Folder ***/ +#include "../TrooperEngine/VideoEngine/cVideo.hpp" +#include "../TrooperEngine/VideoEngine/cRenderer.hpp" +#include "../TrooperEngine/VideoEngine/cSprite.hpp" +#include "../TrooperEngine/VideoEngine/cAnimatedSprite.hpp" +#include "../TrooperEngine/VideoEngine/cImage.hpp" +#include "../TrooperEngine/VideoEngine/cCamera.hpp" + +/*** AudioEngine Folder ***/ +#include "../TrooperEngine/AudioEngine/cAudio.hpp" +#include "../TrooperEngine/AudioEngine/cSound.hpp" +#include "../TrooperEngine/AudioEngine/cMusic.hpp" + +/*** NetworkingEngine Folder ***/ +#include "../TrooperEngine/NetworkEngine/cNetwork.hpp" + +/*** InputEngine Folder ***/ +#include "../TrooperEngine/InputEngine/cInput.hpp" +#include "../TrooperEngine/InputEngine/cJoystick.hpp" +#include "../TrooperEngine/InputEngine/cKeyboard.hpp" +#include "../TrooperEngine/InputEngine/cMouse.hpp" +#include "../TrooperEngine/InputEngine/cKey.hpp" +#include "../TrooperEngine/InputEngine/cTextInput.hpp" + +/*** TimingEngine Folder ***/ +#include "../TrooperEngine/TimingEngine/cTiming.hpp" + +/*** MathEngine Folder ***/ +#include "../TrooperEngine/MathEngine/Vector/Vector2.hpp" +#include "../TrooperEngine/MathEngine/Vector/Vector3.hpp" +#include "../TrooperEngine/MathEngine/Vector/Vector4.hpp" + +#include "../TrooperEngine/MathEngine/iVector/iVector2.hpp" +#include "../TrooperEngine/MathEngine/iVector/iVector3.hpp" +#include "../TrooperEngine/MathEngine/iVector/iVector4.hpp" + +#include "../TrooperEngine/MathEngine/cCollision.hpp" +#include "../TrooperEngine/MathEngine/cRandom.hpp" + +/*** TextTypeEngine ***/ +#include "../TrooperEngine/TextTypeEngine/cTextType.hpp" +#include "../TrooperEngine/TextTypeEngine/cFont.hpp" +#include "../TrooperEngine/TextTypeEngine/cText.hpp" + +/*** EventEngine ***/ +#include "../TrooperEngine/EventEngine/cEventControl.hpp" +#include "../TrooperEngine/EventEngine/cEvent.hpp" + +/*** GUIEngine ***/ +#include "../TrooperEngine/GUIEngine/cGUI.hpp" +#include "../TrooperEngine/GUIEngine/cWindow.hpp" +#include "../TrooperEngine/GUIEngine/cLayout.hpp" +#include "../TrooperEngine/GUIEngine/cLabel.hpp" +#include "../TrooperEngine/GUIEngine/cButton.hpp" +#include "../TrooperEngine/GUIEngine/cTextButton.hpp" +#include "../TrooperEngine/GUIEngine/cBoxSizer.hpp" + +/*** GUIHelper ***/ +#include "../TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/Enums.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp" +#include "../TrooperEngine/GUIEngine/GUIHelpers/cTexture.hpp" + +/*** UtilityEngine ***/ +#include "../TrooperEngine/UtilityEngine/cUtility.hpp" +#include "../TrooperEngine/UtilityEngine/cString.hpp" + +/*** FXEngine ***/ +#include "../TrooperEngine/FXEngine/cGFX.hpp" + +#endif/// END IFNDEF _TROOPERENGINE_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/dllExportFiles/dllExport.h b/TrooperEngineDLL/dllExportFiles/dllExport.h new file mode 100644 index 0000000..6333428 --- /dev/null +++ b/TrooperEngineDLL/dllExportFiles/dllExport.h @@ -0,0 +1,19 @@ +#ifndef _DLLEXPORT_H_ +#define _DLLEXPORT_H_ + +#include "CompileSettings.h" + +#if _STATIC_LIB_ == 0 +# ifdef _MYDLL_ +# define EXPORT_FROM_MYDLL __declspec(dllimport) +# define EXPIMP_TEMPLATE extern +# else +# define EXPORT_FROM_MYDLL __declspec(dllexport) +# define EXPIMP_TEMPLATE +# endif +#else +# define EXPORT_FROM_MYDLL +# define EXPIMP_TEMPLATE +#endif + +#endif/// END IFNDEF _DLLEXPORT_H_ \ No newline at end of file diff --git a/TrooperEngineTest/EventEngineTest/EventEngineTest.cpp b/TrooperEngineTest/EventEngineTest/EventEngineTest.cpp new file mode 100644 index 0000000..020a18f --- /dev/null +++ b/TrooperEngineTest/EventEngineTest/EventEngineTest.cpp @@ -0,0 +1,48 @@ +#include "EventEngineTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +void EventEngineTest() +{ + // cString + printf("\nTesting cString -----\n\n"); + + UTest u("cString"); + + const char * _ctest = " \tfoo \r\n"; + cString ttest = _ctest; + u.test("cstring ctor", ttest.length() == 12); + ttest.trim(); + u.test("trim", ttest.length() == 3); + + cString x = "foo"; + cString y = "bar"; + cString z = x + "baz" + y; + + u.test("concat", z.length() == 9 && memcmp(z.c_str(), "foobazbar", 10) == 0); + + x = y = "foo"; + u.test("foo == foo", (x == y)); + u.test("foo > foo", !(x > y)); + u.test("foo >= foo", (x >= y)); + u.test("foo < foo", !(x < y)); + u.test("foo <= foo", (x <= y)); + + x = "bar"; + u.test("bar == foo", !(x == y)); + u.test("bar > foo", !(x > y)); + u.test("bar >= foo", !(x >= y)); + u.test("bar < foo", (x < y)); + u.test("bar <= foo", (x <= y)); + + u.test("foo == bar", !(y == x)); + u.test("foo > bar", (y > x)); + u.test("foo >= bar", (y >= x)); + u.test("foo < bar", !(y < x)); + u.test("foo <= bar", !(y <= x)); + + u.report(); +} \ No newline at end of file diff --git a/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp b/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp new file mode 100644 index 0000000..2fe2831 --- /dev/null +++ b/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp @@ -0,0 +1,6 @@ +#ifndef __EVENTENGINETEST__ +#define __EVENTENGINETEST__ + +void EventEngineTest(); + +#endif //__EVENTENGINETEST__ \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.cpp b/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.cpp new file mode 100644 index 0000000..366648c --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.cpp @@ -0,0 +1,53 @@ +#include "GUIXMLDefaultTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +void GUIXMLDefaultTest() +{ + UTest u("GUI XML Default"); + + GUIEngine::cGUI::Inst().Delete(); + GUIEngine::cGUI::Inst().Initialize("GUIXMLDefaultTest.xml", "xml/"); + printf("\nUsing GUIXMLDefaultTest.xml file.\n"); + + GUIEngine::cGUI::Inst().Display(); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + u.test("cPanel Position", panel->getPosition(false) == GUIHelpers::Position{ 0, 0 }); + + u.test("cPanel Size", panel->getSize(false) == GUIHelpers::Size{ 200, 200 }); + + u.test("cPanel Padding", panel->getPadding() == GUIHelpers::Padding{ 5, 5, 5, 5 }); + + u.test("cPanel Center", panel->getCenter() == GUIHelpers::Position{ 100, 100 }); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + u.test("cLayout Position", layout->getPosition(false) == GUIHelpers::Position{ 5, 5 }); + + u.test("cLayout Size", layout->getSize(false) == GUIHelpers::Size{ 190, 190 }); + + u.test("cLayout Padding", layout->getPadding() == GUIHelpers::Padding{ 5, 5, 5, 5 }); + + u.test("cLayout Center", layout->getCenter() == GUIHelpers::Position{ 100, 100 }); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + u.test("cLabel Position", label->getPosition(false) == GUIHelpers::Position{ 56, 96 }); + + u.test("cLabel Size", label->getSize(false) == GUIHelpers::Size{ 88, 8 }); + + u.test("cLabel Padding", label->getPadding() == GUIHelpers::Padding{ 5, 5, 5, 5 }); + + u.test("cLabel Center", label->getCenter() == GUIHelpers::Position{ 100, 100 }); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.hpp b/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.hpp new file mode 100644 index 0000000..928d377 --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLDefaultTest.hpp @@ -0,0 +1,6 @@ +#ifndef __GUIXMLDEFAULTTEST__ +#define __GUIXMLDEFAULTTEST__ + +void GUIXMLDefaultTest(); + +#endif // __GUIXMLDEFAULTTEST__ \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.cpp b/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.cpp new file mode 100644 index 0000000..2d853ea --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.cpp @@ -0,0 +1,51 @@ +#include "GUIXMLPositionTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +void GUIXMLPositionTest() +{ + UTest u("GUI XML Position"); + + GUIEngine::cGUI::Inst().Delete(); + + GUIEngine::cGUI::Inst().Initialize("GUIXMLPositionTest.xml", "xml/"); + printf("\nUsing GUIXMLPositionTest.xml file.\n"); + + GUIEngine::cGUI::Inst().Display(); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + //cWinTest(u, panel, GUIHelpers::Position{ 20, 20 }, GUIHelpers::Size{ 200, 200 }, GUIHelpers::Padding{ 5, 5, 5, 5 }, GUIHelpers::Position{ 120, 120 }); + + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + u.test("cLayout Position", layout->getPosition(false) == GUIHelpers::Position{ 25, 25 }); + + u.test("cLayout Size", layout->getSize(false) == GUIHelpers::Size{ 190, 190 }); + + u.test("cLayout Padding", layout->getPadding() == GUIHelpers::Padding{ 5, 5, 5, 5 }); + + u.test("cLayout Center", layout->getCenter() == GUIHelpers::Position{ 120, 120 }); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + u.test("cLabel Position", label->getPosition(false) == GUIHelpers::Position{ 76, 116 }); + + u.test("cLabel Size", label->getSize(false) == GUIHelpers::Size{ 88, 8 }); + + u.test("cLabel Padding", label->getPadding() == GUIHelpers::Padding{ 5, 5, 5, 5 }); + + u.test("cLabel Center", label->getCenter() == GUIHelpers::Position{ 120, 120 }); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.hpp b/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.hpp new file mode 100644 index 0000000..b1b6dfe --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLPositionTest.hpp @@ -0,0 +1,6 @@ +#ifndef __GUIXMLPOSITIONTEST__ +#define __GUIXMLPOSITIONTEST__ + +void GUIXMLPositionTest(); + +#endif // __GUIXMLPOSITIONTEST__ \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLTest.cpp b/TrooperEngineTest/GUIEngineTest/GUIXMLTest.cpp new file mode 100644 index 0000000..14e7ac5 --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLTest.cpp @@ -0,0 +1,348 @@ +#include "GUIXMLTest.hpp" + +void GUIXMLTest() +{ + printf("\nTesting GUI XML Test -----\n\n"); + +// GUIXMLDefaultTest(); +// +// GUIXMLPositionTest(); +// +// GUIXMLAlignTest(); +// +// GUIHelpers::eAlign topBottom[] = { GUIHelpers::eAlign::TOP, GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::BOTTOM }; +// GUIHelpers::eAlign leftRight[] = { GUIHelpers::eAlign::LEFT, GUIHelpers::eAlign::CENTER, GUIHelpers::eAlign::RIGHT }; +// +// GUIHelpers::eOrientation ori[] = { GUIHelpers::eOrientation::HORIZONTAL, GUIHelpers::eOrientation::VERTICAL }; +// +// GUIHelpers::eAlign* align = topBottom; +// for (int four = 0, plus = 0; four < 2; ++four) { +// for (int one = 0; one < 3; ++one) { +// for (int two = 0; two < 3; ++two) { +// for (int three = 0; three < 3; ++three) { +// GUIXMLAlignTest(align[one], align[two], align[three], ori[four]); +// } +// } +// } +// align = leftRight; +// } + + GUIXMLBoxSizerTest(); +} + +void GUIXMLDefaultTest() +{ + UTest u("GUI XML Default"); + + LoadFile("GUIXMLDefaultTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 100, 100 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 5, 5 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + + sets.pos = { 56, 96 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLPositionTest() +{ + UTest u("GUI XML Position"); + + LoadFile("GUIXMLPositionTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 20, 20 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 120, 120 }; + + cWindowTest("Panel", u, panel, sets); + + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 25, 25 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + sets.pos = { 76, 116 }; + sets.size = { 88, 8 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLAlignTest( const GUIHelpers::eAlign one /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, const GUIHelpers::eAlign two /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, + const GUIHelpers::eAlign three /*= GUIHelpers::eAlign::DEFAULT_ALIGN*/, const GUIHelpers::eOrientation orientation /*= GUIHelpers::eOrientation::DEFAULT_ORIENTATION*/ ) +{ + UTest u("GUI XML Align"); + + LoadFile("GUIXMLAlignTest.xml"); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 400, 400 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 200, 200 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + if (orientation != GUIHelpers::eOrientation::DEFAULT_ORIENTATION) + layout->setOrientation(orientation); + + sets.pos = { 5, 5 }; + sets.size = { 390, 390 }; + sets.pad = { 5, 5, 5, 5 }; + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0]; + + cString msg = ""; + + if (one != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(one); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 10, 10 }; + sets.center = { 74, 14}; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 10, 382 }; + sets.center = { 74, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 178 }; + sets.center = { 74, 182 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 136, 178 }; + sets.center = { 200, 182 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 10, 196 }; + sets.center = { 74, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 262, 178 }; + sets.center = { 326, 182 }; + break; + } + + sets.size = { 128, 8 }; + + cWindowTest("Label 'Hello world One' " + msg, u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[1]; + + if (two != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(two); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 128, 10 }; + sets.center = { 200, 14 }; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 128, 382 }; + sets.center = { 200, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 196 }; + sets.center = { 82, 200 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 128, 196 }; + sets.center = { 200, 200 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 128, 196 }; + sets.center = { 200, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 246, 196 }; + sets.center = { 318, 200 }; + break; + } + + sets.size = { 144, 8 }; + + cWindowTest("Label 'Hello world Two' " + msg, u, label, sets); + + label = (GUIEngine::cLabel*)layout->getChildren()[2]; + + if (three != GUIHelpers::eAlign::DEFAULT_ALIGN) + label->setAlign(three); + + switch (label->getAlign()) { + case GUIHelpers::eAlign::TOP: + msg = "Top"; + sets.pos = { 254, 10 }; + sets.center = { 322, 14 }; + break; + case GUIHelpers::eAlign::BOTTOM: + msg = "Bottom"; + sets.pos = { 254, 382 }; + sets.center = { 322, 386 }; + break; + case GUIHelpers::eAlign::LEFT: + msg = "Left"; + sets.pos = { 10, 214 }; + sets.center = { 78, 218 }; + break; + case GUIHelpers::eAlign::CENTER: + msg = "Center"; + sets.pos = { 132, 214 }; + sets.center = { 200, 218 }; + if (layout->getOrientation() == GUIHelpers::eOrientation::HORIZONTAL) { + sets.pos = { 254, 196 }; + sets.center = { 322, 200 }; + } + break; + case GUIHelpers::eAlign::RIGHT: + msg = "Right"; + sets.pos = { 254, 214 }; + sets.center = { 322, 218 }; + break; + } + sets.size = { 136, 8 }; + + cWindowTest("Label 'Hello world Three' " + msg, u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); +} + +void GUIXMLBoxSizerTest() +{ + UTest u("GUI XML BoxSizer"); + + LoadFile("GUIXMLBoxSizerTest.xml", true); + + std::vector objects = GUIEngine::cGUI::Inst().GetObjects(); + + GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0]; + + Settings sets; + sets.pos = { 0, 0 }; + sets.size = { 200, 200 }; + sets.pad = { 0, 0, 0, 0 }; + sets.center = { 100, 100 }; + + cWindowTest("Panel", u, panel, sets); + + GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0]; + + sets.pos = { 5, 5 }; + sets.size = { 190, 190 }; + sets.pad = { 5, 5, 5, 5 }; + + + cWindowTest("Layout", u, layout, sets); + + GUIEngine::cBoxSizer* boxsizer = (GUIEngine::cBoxSizer*)layout->getChildren()[0]; + + sets.pos = { 51, 15 }; + sets.size = { 172, 5 }; + sets.center = { 100, 91 }; + + GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[1]; + + //label->setFontSize(8); + + sets.pos = { 64, 182 }; + sets.size = { 72, 8 }; + sets.center = { 100, 186 }; + + cWindowTest("Label", u, label, sets); + + u.report(); + + GUIEngine::cGUI::Inst().Delete(); + + +} + +void LoadFile( const cString& filename, const bool show /*= false*/ ) +{ + GUIEngine::cGUI::Inst().Delete(); + GUIEngine::cGUI::Inst().Initialize(filename, "xml/"); + printf(cString("\nUsing " + filename + " file.\n").c_str()); + + if (show == true) + GUIEngine::cGUI::Inst().Display(); +} + +void cWindowTest(const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets) +{ + cWindowTest(msg, u, win, sets.pos, sets.size, sets.pad, sets.center); +} + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center) +{ + u.test(msg + " Position", win->getPosition() == pos); + + u.test(msg + " Size", win->getSize(false) == size); + + u.test(msg + " Padding", win->getPadding() == pad); + + u.test(msg + " Center", win->getCenter() == center); +} \ No newline at end of file diff --git a/TrooperEngineTest/GUIEngineTest/GUIXMLTest.hpp b/TrooperEngineTest/GUIEngineTest/GUIXMLTest.hpp new file mode 100644 index 0000000..6509f23 --- /dev/null +++ b/TrooperEngineTest/GUIEngineTest/GUIXMLTest.hpp @@ -0,0 +1,37 @@ +#ifndef __GUIXMLTEST__ +#define __GUIXMLTEST__ + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using UtilityEngine::cString; + +struct Settings +{ + GUIHelpers::Position pos; + GUIHelpers::Size size; + GUIHelpers::Padding pad; + GUIHelpers::Position center; +}; + +void GUIXMLTest(); + +void GUIXMLDefaultTest(); + +void GUIXMLPositionTest(); + +void GUIXMLAlignTest( const GUIHelpers::eAlign one = GUIHelpers::eAlign::DEFAULT_ALIGN, const GUIHelpers::eAlign two = GUIHelpers::eAlign::DEFAULT_ALIGN, + const GUIHelpers::eAlign three = GUIHelpers::eAlign::DEFAULT_ALIGN, const GUIHelpers::eOrientation orientation = GUIHelpers::eOrientation::DEFAULT_ORIENTATION); + +void GUIXMLBoxSizerTest(); + +void LoadFile( const cString& filename, const bool show = false ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets ); + +void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos, + const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center ); + +#endif // __GUIXMLTEST__ diff --git a/TrooperEngineTest/TrooperEngineTest.vcxproj b/TrooperEngineTest/TrooperEngineTest.vcxproj new file mode 100644 index 0000000..6e3fd56 --- /dev/null +++ b/TrooperEngineTest/TrooperEngineTest.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + UTest + Win32 + + + UTest + x64 + + + + {9225E043-EE77-43AA-A140-C9C2F85B1013} + TrooperEngineTest + 10.0.15063.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + v141 + + + v141 + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + true + $(SDL2_gfx);../TrooperEngineDLL/dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + true + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2)\VisualC\Win32\Debug;$(SDL2_gfx)\Win32\Debug;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + Console + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + $(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories) + + + odbc32.lib;odbccp32.lib;sdl2.lib;sdl2main.lib;sdl2_image.lib;sdl2_ttf.lib;sdl2_mixer.lib;sdl2_net.lib;tinyxml2.lib;TrooperEngineDLL.lib;sdl2_gfx.lib;%(AdditionalDependencies) + $(SDL2_gfx)\Win32\Release;../Debug;$(SDL2_ttf)\lib\x86;$(SDL2_mixer)\lib\x86;$(SDL2_image)\lib\x86;$(SDL2_net)\lib\x86;$(SDL2)\lib\x86;$(TINYXML)\tinyxml2\bin\Win32-Debug-Lib;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + Designer + + + + Designer + + + + + + \ No newline at end of file diff --git a/TrooperEngineTest/TrooperEngineTest.vcxproj.filters b/TrooperEngineTest/TrooperEngineTest.vcxproj.filters new file mode 100644 index 0000000..a9f1b01 --- /dev/null +++ b/TrooperEngineTest/TrooperEngineTest.vcxproj.filters @@ -0,0 +1,72 @@ + + + + + {549e0f16-9635-455e-b19a-4a887771cf5d} + + + {50a06b19-0711-478a-a15e-df325d10bebc} + + + {3305ea52-bd3f-4a02-a012-eb2923a77dbf} + + + {510356f7-3573-4526-b0a4-73d691ecba95} + + + {380e8810-ed24-4a4d-b569-b7c37e3647c6} + + + {30bb6c80-fc2a-4954-bf14-10c6dc5aceec} + + + + + UTest + + + UtitlityEngineTest + + + GUIEngineTest + + + EventEngineTest + + + + + UTest + + + + UtitlityEngineTest + + + GUIEngineTest + + + EventEngineTest + + + + + xml + + + xml + + + xml + + + xml + + + xml + + + xml + + + \ No newline at end of file diff --git a/TrooperEngineTest/UTest/UTest.cpp b/TrooperEngineTest/UTest/UTest.cpp new file mode 100644 index 0000000..4c9140a --- /dev/null +++ b/TrooperEngineTest/UTest/UTest.cpp @@ -0,0 +1,40 @@ +#include "UTest.hpp" + +const /*static*/ char * UTest::sp_pstr = "pass"; +const /*static*/ char * UTest::sp_fstr = "fail"; + +/*static*/ unsigned long int UTest::s_pass = 0; +/*static*/ unsigned long int UTest::s_fail = 0; + +UTest::UTest( const char * tstr ) { + init(tstr); +} + +void UTest::init( const char * tstr ) { + mp_tstr = tstr; + m_pass = m_fail = 0; +} + +void UTest::test( const char * description, const int flag ) { + const char * pf = nullptr; + if (flag) { + pf = sp_pstr; + ++m_pass; + ++s_pass; + } else { + pf = sp_fstr; + ++m_fail; + ++s_fail; + } + printf("%s: %s -> %s\n", mp_tstr, description, pf); +} + +void UTest::report() const { + printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail); +} + +/*static*/ void UTest::OverAllReport() +{ + printf("\nOver All pass: %ld, fail: %ld\n", s_pass, s_fail); +} + diff --git a/TrooperEngineTest/UTest/UTest.hpp b/TrooperEngineTest/UTest/UTest.hpp new file mode 100644 index 0000000..1028280 --- /dev/null +++ b/TrooperEngineTest/UTest/UTest.hpp @@ -0,0 +1,36 @@ +#ifndef __UTEST__ +#define __UTEST__ + +#include + +#define __UTest_VERSION "1.0.0" + +class UTest { +private: + UTest( UTest & ); // no copy constructor + UTest operator = ( UTest & ); // no assignment operator + UTest(){} +public: + static const char * version() { return __UTest_VERSION; } + + UTest( const char * ); + void init( const char * ); + void test( const char * description, const int flag ); + void report() const; + + static void OverAllReport(); + +private: + unsigned long int m_pass = 0; + unsigned long int m_fail = 0; + + const char * mp_tstr = nullptr; + + const static char * sp_pstr; /*= "pass";*/ + const static char * sp_fstr; /*= "fail";*/ + + static unsigned long int s_pass; + static unsigned long int s_fail; +}; + +#endif // __UTEST__ diff --git a/TrooperEngineTest/UtilityEngineTest/StringTest.cpp b/TrooperEngineTest/UtilityEngineTest/StringTest.cpp new file mode 100644 index 0000000..eceda4a --- /dev/null +++ b/TrooperEngineTest/UtilityEngineTest/StringTest.cpp @@ -0,0 +1,50 @@ +#include "StringTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using UtilityEngine::cString; + +void StringTest() +{ + // cString + printf("\nTesting cString -----\n\n"); + + UTest u("cString"); + + const char * _ctest = " \tfoo \r\n"; + cString ttest = _ctest; + u.test("cstring ctor", ttest.length() == 12); + ttest.trim(); + u.test("trim", ttest.length() == 3); + + cString x = "foo"; + cString y = "bar"; + cString z = x + "baz" + y; + + u.test("concat", z.length() == 9 && memcmp(z.c_str(), "foobazbar", 10) == 0); + + x = y = "foo"; + u.test("foo == foo", (x == y)); + u.test("foo > foo", !(x > y)); + u.test("foo >= foo", (x >= y)); + u.test("foo < foo", !(x < y)); + u.test("foo <= foo", (x <= y)); + + x = "bar"; + u.test("bar == foo", !(x == y)); + u.test("bar > foo", !(x > y)); + u.test("bar >= foo", !(x >= y)); + u.test("bar < foo", (x < y)); + u.test("bar <= foo", (x <= y)); + + u.test("foo == bar", !(y == x)); + u.test("foo > bar", (y > x)); + u.test("foo >= bar", (y >= x)); + u.test("foo < bar", !(y < x)); + u.test("foo <= bar", !(y <= x)); + + u.report(); +} \ No newline at end of file diff --git a/TrooperEngineTest/UtilityEngineTest/StringTest.hpp b/TrooperEngineTest/UtilityEngineTest/StringTest.hpp new file mode 100644 index 0000000..55ac022 --- /dev/null +++ b/TrooperEngineTest/UtilityEngineTest/StringTest.hpp @@ -0,0 +1,6 @@ +#ifndef __STRINGTEST__ +#define __STRINGTEST__ + +void StringTest(); + +#endif // __STRINGTEST__ diff --git a/TrooperEngineTest/main.cpp b/TrooperEngineTest/main.cpp new file mode 100644 index 0000000..4252ffd --- /dev/null +++ b/TrooperEngineTest/main.cpp @@ -0,0 +1,98 @@ +/* Copyright (C) 2016 Richard W. Allen +Program Name: SDL Pong C++ +Author: Richard W. Allen +Version: V1.0 +Date Started: August 24, 2016 +Date End: +Webpage: http://www.richardallenonline.com +IDE: Visual Studio 2015 +Compiler: C\C++ 2014 +Langage: C++ +License: GNU GENERAL PUBLIC LICENSE Version 2 +see license.txt for details + +*/ + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +/*** SDL Header Files ***/ +#include "SDL.h" + +#include "UTest/UTest.hpp" + +#include "UtilityEngineTest/StringTest.hpp" +#include "GUIEngineTest/GUIXMLTest.hpp" + +using UtilityEngine::cString; + +void CleanUp() +{ + TrooperEngineCore::cTrooperEngineCore::Delete(); +} + +int main(int argc, char *argv[]) +{ + argc, argv; + + printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n"); + + + UTest u("cVideo"); + + printf("\nTesting cVideo\n"); + + TrooperEngineCore::cTrooperEngineCore::Inst(); + VideoEngine::cVideo& video = VideoEngine::cVideo::Inst(); + video.Initialize(); + //core.VideoInit(); + + if (!video.Setup()) { + printf("database failed to open.\n"); + return 1; + } + + u.test("Video Initialize open", video.IsInit()); + + StringTest(); + + GUIXMLTest(); + + + UTest::OverAllReport(); + SDL_Event event; + bool run = true; + while (run) { + VideoEngine::cVideo::Inst().Display(); + //EventEngine::cEventControl::Inst().CheckEvents(); + while (SDL_PollEvent(&event)) { + /* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */ + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_SPACE: + run = false; + break; + case SDLK_RETURN: + VideoEngine::cVideo::Inst().ScreenShot("test.bmp"); + default: + break; + } + break; + + case SDL_KEYUP: + printf("Key release detected\n"); + break; + + default: + break; + } + } + } + + CleanUp(); + + //system("pause"); + + return 0; +} \ No newline at end of file diff --git a/TrooperEngineTest/test.bmp b/TrooperEngineTest/test.bmp new file mode 100644 index 0000000..293cca5 Binary files /dev/null and b/TrooperEngineTest/test.bmp differ diff --git a/TrooperEngineTest/xml/GUI.xml b/TrooperEngineTest/xml/GUI.xml new file mode 100644 index 0000000..0585838 --- /dev/null +++ b/TrooperEngineTest/xml/GUI.xml @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file diff --git a/TrooperEngineTest/xml/GUIXMLAlignTest.xml b/TrooperEngineTest/xml/GUIXMLAlignTest.xml new file mode 100644 index 0000000..3447c0c --- /dev/null +++ b/TrooperEngineTest/xml/GUIXMLAlignTest.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/TrooperEngineTest/xml/GUIXMLBoxSizerTest.xml b/TrooperEngineTest/xml/GUIXMLBoxSizerTest.xml new file mode 100644 index 0000000..7d41fdf --- /dev/null +++ b/TrooperEngineTest/xml/GUIXMLBoxSizerTest.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/TrooperEngineTest/xml/GUIXMLDefaultTest.xml b/TrooperEngineTest/xml/GUIXMLDefaultTest.xml new file mode 100644 index 0000000..67ef978 --- /dev/null +++ b/TrooperEngineTest/xml/GUIXMLDefaultTest.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/TrooperEngineTest/xml/GUIXMLPositionTest.xml b/TrooperEngineTest/xml/GUIXMLPositionTest.xml new file mode 100644 index 0000000..7fbafc4 --- /dev/null +++ b/TrooperEngineTest/xml/GUIXMLPositionTest.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/TrooperEngineTest/xml/include.xml b/TrooperEngineTest/xml/include.xml new file mode 100644 index 0000000..9f29440 --- /dev/null +++ b/TrooperEngineTest/xml/include.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file